function s_action_redirect($url) { if (s_bad_string($url)) { $url = defined('APP_NAME') ? '/' . APP_NAME : ''; } if (!s_bad_ajax()) { return s_action_json(array('error' => 1, 'redirect' => $url)); } //302 header("Location: {$url}"); return ""; }
function s_action_redirect($url, $delay = 0, $msg = false) { if (s_bad_string($url)) { $url = defined('APP_NAME') ? '/' . APP_NAME : ''; } if (s_bad_ajax()) { if ($delay !== 0) { //需要提示,输出页面 return; } //非ajax请求,又没有提示语句,直接302 if (is_string($msg)) { $url .= $msg; } header("Location: {$url}"); return; } return s_action_json(array('error' => 1, 'redirect' => $url)); }
$names[md5($name)] = array("name" => $name, "count" => $num); } //计算活动天数及每天中奖数量 $avg = floor($sum / $days); if (s_bad_post('confirm', $confirm, 'int')) { $params['key'] = $akey; $params['name'] = $name; $params['start'] = $start; $params['stop'] = $stop; $params['odds'] = $odds; $params['items'] = $items; $params['nums'] = $nums; $params['confirm'] = 1; $params['avg'] = $avg; //未确认 return s_action_json($params); } //将配置信息存储起来 $data = array('name' => $name, 'key' => $akey, 'start' => $start, 'stop' => $stop, 'odds' => $odds, 'uid' => $user['id'], 'uname' => $user['screen_name'], 'sum' => $sum, 'fdate' => date('Y-m-d'), 'ftime' => date('Y-m-d H:i:s')); //$sql = sprintf("insert into `%s_bingo_config (`name`, `key`, `start`, `stop`, `odds`, `uid`, `uname`, `sum`, `fdate`, `ftime`) values('%s', '%s', %s, '%s', '%s', '%s', '%s', '%s', %d, '%s', '%s')`;", //FRAMEWORK_DBPREFIX, $name, $akey, $start, $stop, $odds, $user['id'], $user['screen_name'], $sum, date('Y-m-d'), date('Y-m-d H:i:s')); $cid = s_db(sprintf("%s_bingo_config:insert", FRAMEWORK_DBPREFIX), $data); //产生sum个优惠码 $codes = array(); foreach ($names as $key => $data) { $max = $data["count"]; $arr = array_fill(0, $max, $key); $codes = array_merge($arr, $codes); } //打乱顺序,再分配中奖时间 shuffle($codes);
function s_action_error($message = "no params.", $code = 99, $type = "json") { $error = array('error' => $code, 'errmsg' => $message); s_action_json($error); }
<?php require_once "devinc.common.php"; echo FRAMEWORK_DIR; s_action_json(array("error" => 1));
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); $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); $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); } echo s_action_json(array("error" => 0));