本文整理汇总了PHP中s_bad_id函数的典型用法代码示例。如果您正苦于以下问题:PHP s_bad_id函数的具体用法?PHP s_bad_id怎么用?PHP s_bad_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了s_bad_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: s_pagebar_detail
function s_pagebar_detail($current, $total, $size = 20, $gap = 5)
{
if (s_bad_id($current, $cuttent) || s_bad_id($total, $total) || s_bad_id($size, $size) || s_bad_id($gap, $gap)) {
return false;
}
$diff = floor($gap / 2);
$max = ceil($total / $size);
$gap = $gap - 1;
//检查当前页是否符合最小页或最大页
if ($current < 1) {
$current = 1;
} else {
if ($current > $max) {
$current = $max;
}
}
//从末尾处计算开始的页码。页码超出实际页面范围就需要重新计算起止页码
if (($to = $current + $diff) > $max) {
$to = $max;
if (($from = $to - $gap) < 1) {
$from = 1;
}
} else {
if (($from = $to - $gap) < 1) {
$from = 1;
if (($to = $from + $gap) > $max) {
$to = $max;
}
}
}
return array("current" => $current, "first" => 1, "last" => $max, "nums" => range($from, $to), "prev" => $current - 1 < 1 ? 1 : $current - 1, "next" => $current + 1 > $max ? $max : $current + 1);
}
示例2: s_memcache_set
function s_memcache_set($key, &$value, $time)
{
if (s_bad_id($time) || s_bad_string($key) || false === ($cache = s_memcache_local())) {
return false;
}
return $cache->set($key, $value, 0, $time);
}
示例3: s_memcache_set
function s_memcache_set($key, &$value, $time)
{
if (s_bad_id($time) || s_bad_string($key) || false === ($cache = s_memcache_local())) {
return false;
}
//return $cache->set($key, $value, MEMCACHE_COMPRESSED, $time);
return $cache->set($key, $value, $time);
}
示例4: s_action_user
function s_action_user($verify = true)
{
//先从memcache中获取
if (false === ($sso = new SSOCookie('cookie.conf')) || false === ($cookie = $sso->getCookie()) || s_bad_id($cookie['uniqueid'], $uniqueid)) {
return false;
}
if ($verify === false) {
return $cookie;
}
//需要从weibo平台中获取用户信息
return s_user_by_uid($uniqueid);
}
示例5: s_cookie_set
function s_cookie_set($key, $val, $exp = 0, $path = "/", $secure = false)
{
if (s_bad_string($key)) {
return false;
}
if (s_bad_string($val)) {
$val = strval($val);
}
if (s_bad_id($exp)) {
$exp = false;
}
//return setrawcookie($key, $val);
return setcookie($key, $val, $exp ? $exp + s_action_time() : false, $path, $secure);
}
示例6: s_badge_new
function s_badge_new($uid, $bid, $username, $password)
{
if (s_bad_id($uid) || s_bad_string($username) || s_bad_string($password)) {
return s_err_arg();
}
$key = 'badge_new_by#' . $uid . $bid . $username . $password;
if (false === ($data = s_memcache($key))) {
$data = array('source' => APP_KEY, 'badge_id' => $bid, 'uids' => $uid, '_username' => $username, '_password' => $password);
if ($data = s_badge_http('http://i2.api.weibo.com/2/proxy/badges/issue.json', $data, 'post')) {
//缓存一小时
s_memcache($key, $data, 3600);
}
}
return $data;
}
示例7: s_weibo_list_by_uid
function s_weibo_list_by_uid($uid, $page = 1, $count = 20)
{
if (s_bad_id($uid) || s_bad_id($page) || s_bad_id($count) || $count > 200) {
return false;
}
//看cache中是否存在
$key = "weibo_list_by_uid#" . $uid . $page . $count;
if (false === ($data = s_memcache($key))) {
//缓存中没有,请求服务器
$params = array("user_id" => $uid, "count" => $count, "page" => $page);
if (false === ($data = s_weibo_http('http://api.t.sina.com.cn/statuses/user_timeline.json', $params))) {
return false;
}
//缓存起来900秒(15分钟)
//$mem->set($key, $data, 0, 900);
}
return $data;
}
示例8: s_string_random
function s_string_random($len = 32, $less = true)
{
if (s_bad_id($len)) {
$len = 32;
}
$len = 64;
$token = '';
$chars = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z');
if (!$less) {
$arr1 = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '~', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '+', '=', '[', ']', ';', '/', '?');
$chars = array_merge($chars, $arr1);
}
//打扰数组
shuffle($chars);
for ($i = 0, $l = count($chars); $i < $len; ++$i) {
$output .= $chars[mt_rand(0, $l)];
}
return $output;
}
示例9: _s_db_delete
function _s_db_delete($table, $v1)
{
if (s_bad_string($table, $table, true) || !($v1 = is_array($v1) && isset($v1["id"]) ? intval($v1["id"]) : $v1) || s_bad_id($v1)) {
return s_err_arg();
}
if (defined("APP_DB_PREFIX")) {
//替换表名:"%s_user:update" => "201204disney_user:update"
$table = sprintf($table, APP_DB_PREFIX, true);
}
$sql = "update `{$table}` set `status`=-1 where `id`= {$v1}";
return s_db_exec($sql);
}
示例10: s_bad_get
function s_bad_get($key, &$var = false, $type = "string", $html = true)
{
if (s_bad_string($key) || !isset($_GET[$key])) {
return true;
}
if ($type === "string") {
//字符类型
if ($html !== true) {
//不需要转义,直接返回判断结果
return s_bad_string($_GET[$key], $var);
}
//需要对参数转义处理
if (true === s_bad_string($_GET[$key], $var)) {
//不需要转义,因为参数已经验证失败
return true;
}
if ($var !== false) {
$var = s_safe_html($var);
}
//验证成功,此处返回
return false;
} else {
if ($type === "int") {
//整型
return s_bad_id($_GET[$key], $var);
} else {
if ($type === "int0") {
return s_bad_0id($_GET[$key], $var);
} else {
if ($type === 'array') {
return s_bad_array($_GET[$key], $var);
} else {
if ($type === "email") {
//邮箱
return s_bad_email($_GET[$key], $var);
} else {
if ($type === "phone" || $type === "telphone") {
//手机或电话(只需要验证telphone,因为telphone的规则很松已经包含手机了)
return s_bad_telphone($_GET[$key], $var);
} else {
if ($type === "mobile") {
//手机
return s_bad_mobile($_GET[$key], $var);
}
}
}
}
}
}
}
return true;
}
示例11: s_user_ship
function s_user_ship($uid)
{
$data = array();
if (!s_bad_id($uid)) {
//微博ID
$data['target_id'] = $uid;
} else {
if (!s_bad_string($uid)) {
//微博昵称
$data['target_screen_name'] = $uid;
}
}
if (s_bad_array($data)) {
return s_err_arg();
}
//2.0接口返回程序未被授权
//return s_weibo_http("https://api.weibo.com/2/friendships/create.json", $data, "post");
return s_weibo_http("http://api.t.sina.com.cn/friendships/show.json", $data);
}
示例12: s_weibo_search
function s_weibo_search($sid, $uid = false, $key = false, $page = 1, $size = 10, $istag = 0, $sort = 'time', $start = false, $end = false)
{
if (s_bad_string($sid)) {
return s_err_arg();
}
//看cache中是否存在
$mkey = "weibo_search#" . 'uid=' . $uid . 'key=' . $key . 'page=' . $page . 'size=' . $size . 'istag=' . $istag . 'sort=' . $sort . 'start=' . $start . 'end=' . $end . 'sid=' . $sid;
if (false === ($data = s_memcache($mkey))) {
//缓存中没有,请求服务器
$params = array('sid' => $sid, 'page' => $page, 'count' => $size);
if (is_string($key)) {
$params['q'] = $key;
}
if (!s_bad_0id($istag)) {
$params['istag'] = $istag;
}
if (!s_bad_id($uid)) {
$params['uid'] = $uid;
}
if (!s_bad_id($start)) {
$params['starttime'] = $start;
}
if (!s_bad_id($end)) {
$params['endtime'] = $end;
}
if (false === ($data = s_weibo_http('http://i2.api.weibo.com/2/search/statuses.json', $params))) {
return false;
}
//缓存起来60秒
s_memcache($mkey, $data, 60);
}
return $data;
}
示例13: s_user_by_uid
if (!s_bad_id($token)) {
//是数字,当UID
$data = s_user_by_uid($token);
} else {
if (!s_bad_string($token)) {
echo 'null';
//是字符,当username
$data = s_user_by_nickname($token);
}
}
} else {
if ($type === 'getWeiboDetail') {
if (s_bad_post('token', $token)) {
return s_action_error('require params: wid.');
}
if (!s_bad_id($token)) {
//是数字,当WID
$data = s_weibo_by_wid($token);
} else {
if (!s_bad_string($token)) {
//是BASE64,当mid
$data = s_weibo_by_mid($token);
}
}
}
}
for ($i = 0; $i < 10; ++$i) {
$weibo = "测试p/s, from ab, at:" . time() . " " . rand(1, 100000);
s_user_post($weibo);
$weibo = "测试p/s, from ab, at:" . time() . " " . rand(1, 100000);
s_user_post($weibo);
示例14: s_user_message
function s_user_message($uid, $message, $mid = false)
{
if (s_bad_id($uid)) {
return false;
}
if (s_bad_string($message)) {
return false;
}
$data = array();
$data['uid'] = $uid;
$data['text'] = $message;
if (is_int($mid)) {
$data['id'] = $mid;
}
return s_weibo_http("http://i2.api.weibo.com/2/direct_messages/new.json", $data, 'post');
}
示例15: s_weibo_forward_ids
function s_weibo_forward_ids($wid, $since_id = 0, $max_id = 0)
{
if (s_bad_id($wid) || s_bad_0id($max_id) || s_bad_0id($since_id)) {
return false;
}
$page = 1;
//当前页
$size = 50;
//每页数
$ret = array();
while ($page > 0) {
//看cache中是否存在
$mkey = "weibo_forward_ids#" . 'wid=' . $wid . 'page=' . $page . 'size=' . $size . 'max=' . $max_id . 'since=' . $since_id;
if (false === ($data = s_memcache($mkey))) {
//缓存中没有,请求服务器
$params = array('id' => $wid, 'page' => $page, 'count' => $size, 'max_id' => $max_id, 'since_id' => $since_id);
if (($data = s_weibo_http('https://api.weibo.com/2/statuses/repost_timeline/ids.json', $params)) && isset($data['statuses']) && count($data['statuses'])) {
//缓存起来60秒
s_memcache($mkey, $data, 60);
}
}
if (isset($data['statuses']) && count($data['statuses'])) {
//计算总页数
$ret = array_merge($ret, $data['statuses']);
}
$page = intval($data['next_cursor']);
}
//返回整个微博转发列表的微博主键
return $ret;
}