本文整理匯總了PHP中TTLog::record方法的典型用法代碼示例。如果您正苦於以下問題:PHP TTLog::record方法的具體用法?PHP TTLog::record怎麽用?PHP TTLog::record使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類TTLog
的用法示例。
在下文中一共展示了TTLog::record方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: pick
/**
* 撿錢並結算
* @param $params
* require u -- 玩家id
* sid -- shop id 不僅限於cinema
* @return
* s -- OK
*/
public function pick($params)
{
$uid = $params['u'];
$sid = $params['sid'];
$now = time();
$tu = new TTUser($uid);
$shop_obj = $tu->getbyid($sid);
// $ret['now'] = $now; //for debug
// $ret['fnow'] = date( TM_FORMAT,$now ); //for debug
// $ret['bshopobj'] = $shop_obj; //for debug
// $ret['fbshopobj'] = date( TM_FORMAT,$shop_obj['ctime'] ); //for debug
if (!$shop_obj) {
$ret['s'] = 'notexist';
return $ret;
}
$item = ItemConfig::getItem($shop_obj['tag']);
if (!$item) {
$ret['s'] = 'itemnotexsit';
return $ret;
}
if ($shop_obj['tag'] == '60102') {
//電影院
if ($now - $shop_obj['ctime'] < $item['selltime'] * 60) {
//坐滿30個才開映,再過2小時才放映結束
$ret['s'] = 'time';
return $ret;
}
$money = $item['sellmoney'];
$shop_obj['ctime'] = $now;
} elseif ($shop_obj['tag'] == '60103' || $shop_obj['tag'] == '60104') {
//健身房和按摩店
if ($now - $shop_obj['ctime'] < $item['settletime']) {
//開業時間需滿足一定條件才可以收錢
$ret['s'] = 'time';
return $ret;
}
$money = $item['sellmoney'];
$shop_obj['ctime'] = $now;
} elseif ($shop_obj['tag'] == '60105' || $shop_obj['tag'] == '60106') {
//月巴克和8-11便利店
if ($now - $shop_obj['ctime'] < 3600) {
//開業1小時後就可以收錢,但最多隻能積累6~9小時
$ret['s'] = 'time';
return $ret;
}
$gap = $now - $shop_obj['ctime'];
$factor = floor($gap / 3600);
$money = $factor * $item['sellmoney'];
$shop_obj['ctime'] += $factor * 3600;
if ($gap > $item['settletime']) {
$money = floor($item['settletime'] / 3600) * $item['sellmoney'];
// $shop_obj['ctime'] += floor( $gap/3600 ) * 3600;
$shop_obj['ctime'] = $now;
}
}
$tu->chMoney($money);
$tu->puto($shop_obj, TT::CINEMA_GROUP);
// $ret['fashopobj'] = date( TM_FORMAT,$shop_obj['ctime'] ); //for debug
// $ret['ashopobj'] = $shop_obj; //for debug
TTLog::record(array('m' => __METHOD__, 'tm' => $_SERVER['REQUEST_TIME'], 'u' => $uid, 'intp1' => $money, 'sp1' => $shop_obj['ctime']));
$ret['money'] = $money;
$ret['s'] = 'OK';
return $ret;
}
示例2: _handle
protected function _handle(&$req)
{
//just add method map here
$method = $req['m'];
$mypre = $method;
if ($this->_debug) {
CrabTools::mydump($req['p'], REQ_DATA_ROOT . $mypre . '.param');
}
if (isset(self::$exist_methods[$method])) {
$caller =& self::$exist_methods[$method];
$c =& $caller[0];
$m = $caller[1];
} else {
$caller = explode('.', $method);
$cn = $caller[0];
$m = $caller[1];
$file = CONTROLLER_ROOT . "{$cn}.php";
if (!file_exists($file)) {
throw new JsonServerExecption("method {$method} file not exist:(" . CONTROLLER_ROOT . "{$cn}.php)");
}
@(require_once $file);
$c = new $cn();
if (!method_exists($c, $m)) {
throw new JsonServerExecption("{$cn} don't has callable method {$m}");
}
}
$log_method = array('Achieve.get' => 1, 'Achieve.finish' => 1, 'Advert.buy' => 1, 'Advert.set' => 1, 'Cinema.enter' => 1, 'Cinema.pick' => 1, 'Gift.send' => 1, 'Gift.accept' => 1, 'Man.update' => 1, 'UserController.login' => 1, 'UserController.precheckout' => 1, 'UserController.update_friends' => 1, 'UserController.enlarge_mall' => 1, 'ItemController.buy' => 1, 'ItemController.sale' => 1, 'CarController.buy' => 1, 'CarController.sale' => 1, 'CarController.go_goods' => 1, 'CarController.enlarge_garage' => 1, 'GoodsController.buy' => 1, 'GoodsController.remove' => 1, 'GoodsController.exhibit_goods' => 1, 'GoodsController.checkshop' => 1, 'GoodsController.checkout' => 1, 'TaskController.share' => 1, 'TaskController.request' => 1, 'TaskController.accept' => 1, 'TaskController.update' => 1, 'TaskController.finish' => 1, 'TaskController.get_award' => 1, 'Friend.dis_neighbor' => 1, 'Friend.invite_neighbor' => 1, 'Friend.accept_neighbor' => 1);
$ret = $c->{$m}($req['p']);
if ($this->_debug) {
CrabTools::myprint($ret, REQ_DATA_ROOT . $mypre . '.resp');
}
if (!$ret) {
$ret['s'] = "KO";
$ret['msg'] = "{$cn}::{$m} return null";
}
if ($ret['s'] == 'OK') {
if (array_key_exists($method, $log_method)) {
TTLog::record(array('m' => $method, 'p' => json_encode($params)));
}
}
return $ret;
}
示例3:
<?php
require_once 'ttserver/test_config.php';
//璁板綍鏃ュ織
$m = $_GET['m'];
if ($m) {
$_GET['tm'] = $_SERVER['REQUEST_TIME'];
TTLog::record($_GET);
}
示例4: update_help
/**
* 更新幫助獲取物品
* @param
tag
fid
* @return one or a array of help open objects
*/
public function update_help($tag, $fid)
{
$oid = $this->getoid($tag, 'ho');
$obj = $this->getbyid($oid);
$now = $_SERVER['REQUEST_TIME'];
$obj['help'][$fid] = $now;
$obj['id'] = $oid;
TTLog::record(array('s' => 'OK', 'm' => __METHOD__, 'tm' => $now, 'sp1' => $tag, 'intp1' => $fid));
$this->puto($obj);
}
示例5: items
//.........這裏部分代碼省略.........
$mano = $tu->getbyid($id);
$mean_gap = 20;
$now = time();
$mano['id'] = $id;
$level = $tu->getLevel();
if ($level > $conf['maxlevel']) {
$ret['s'] = 'level';
$ret['d'] = $mano;
//return $ret;
}
if ($v && $mano[$step]['vtime'] > 0) {
$ret['s'] = 'already';
$ret['d'] = $mano;
return $ret;
}
if ($d && $mano[$step]['dtime'] > 0) {
$ret['s'] = 'already';
$ret['d'] = $mano;
return $ret;
//
}
$award = array();
if ($v) {
$mano[$step]['vtime'] = $now;
$m = $conf['v_money'];
if ($m > 0) {
$ret['money'] = $tu->chMoney($m);
$award['money'] = $m;
}
$m = $conf['v_gem'];
if ($m > 0) {
$ret['gem'] = $tu->chGem($m);
$award['gem'] = $m;
}
$m = $conf['v_exp'];
if ($m > 0) {
$ret['exp'] = $tu->addExp($m);
$award['exp'] = $m;
}
$items = $conf['v_items'];
if ($items) {
foreach ($items as $item) {
$config = ItemConfig::getItem($item['tag']);
$idp = $item['idp'];
// $item['id']=$uid.$idp;
unset($item['idp']);
$item['pos'] = 's';
if ($config['group'] == 'g') {
$item['num'] = $config['unitcout'];
$tu->puto($item, TT::GOODS_GROUP);
} else {
$tu->puto($item, TT::ITEM_GROUP);
}
$award['items'][] = $item;
}
}
$tu->puto($mano);
$ret['award'] = $award;
$ret['s'] = 'OK';
return $ret;
}
$mano[$step]['dtime'] = $now;
$m = $conf['d_money'];
if ($m > 0) {
$ret['money'] = $tu->chMoney($m);
$award['money'] = $m;
}
$m = $conf['d_gem'];
if ($m > 0) {
$ret['gem'] = $tu->chGem($m);
$award['gem'] = $m;
}
$m = $conf['d_exp'];
if ($m > 0) {
$ret['exp'] = $tu->addExp($m);
$award['exp'] = $m;
}
$items = $conf['d_items'];
if ($items) {
foreach ($items as $item) {
$config = ItemConfig::getItem($item['tag']);
$idp = $item['idp'];
// $item['id']=$uid.$idp;
unset($item['idp']);
$item['pos'] = 's';
if ($config['group'] == 'g') {
$item['num'] = $config['unitcout'];
$tu->puto($item, TT::GOODS_GROUP);
} else {
$tu->puto($item, TT::ITEM_GROUP);
}
$award['items'][] = $item;
}
}
$tu->puto($mano);
TTLog::record(array('m' => __METHOD__, 'tm' => $_SERVER['REQUEST_TIME'], 'u' => $uid, 'intp1' => $step));
$ret['s'] = 'OK';
$ret['award'] = $award;
return $ret;
}
示例6: pick
/**
* 撿錢並結算
* @param $params
* require u -- 玩家id
* sid -- shop id 不僅限於cinema
* @return
* s -- OK
*/
public function pick($params)
{
$uid = $params['u'];
$sid = $params['sid'];
$now = time();
$tu = new TTUser($uid);
$shop_obj = $tu->getbyid($sid);
// $ret['now'] = $now; //for debug
// $ret['fnow'] = date( TM_FORMAT,$now ); //for debug
// $ret['bshopobj'] = $shop_obj; //for debug
// $ret['fbshopobj'] = date( TM_FORMAT,$shop_obj['ctime'] ); //for debug
if (!$shop_obj) {
$ret['s'] = 'notexist';
return $ret;
}
$item = ItemConfig::getItem($shop_obj['tag']);
if (!$item) {
$ret['s'] = 'itemnotexsit';
return $ret;
}
if ($now - $shop_obj['ctime'] < $item['mintime']) {
//開業mintime後就可以收錢,但最多隻能積累maxtime
$ret['s'] = 'time';
return $ret;
}
$gap = $now - $shop_obj['ctime'];
$factor = floor($gap / $item['mintime']);
$money = $factor * $item['sellmoney'];
$shop_obj['ctime'] += $factor * $item['mintime'];
if ($gap > $item['maxtime']) {
$money = floor($item['maxtime'] / $item['mintime']) * $item['sellmoney'];
$shop_obj['ctime'] = $now;
}
$tu->chMoney($money);
$tu->puto($shop_obj, TT::CINEMA_GROUP);
// $ret['fashopobj'] = date( TM_FORMAT,$shop_obj['ctime'] ); //for debug
// $ret['ashopobj'] = $shop_obj; //for debug
TTLog::record(array('m' => __METHOD__, 'tm' => $_SERVER['REQUEST_TIME'], 'u' => $uid, 'intp1' => $money, 'sp1' => $shop_obj['ctime']));
$ret['money'] = $money;
$ret['s'] = 'OK';
return $ret;
}
示例7: TTUser
$user = false;
$oid = 60102;
if ($linkid) {
$tw = TT::LinkTT();
$irec = $tw->getbyuidx('lid', $linkid);
$pid = $irec['uid'];
$sess = TTGenid::getbypid($pid);
$user = new TTUser($sess['id']);
}
$new = 0;
if ($_REQUEST['new']) {
$new = 1;
}
$mypid = $_REQUEST['xn_sig_user'];
$myid = TTGenid::getbypid($mypid);
TTLog::record(array('m' => 'help_open_shop', 'tm' => $_SERVER['REQUEST_TIME'], 'u' => $myid['id'], 'sp2' => $new, 'sp1' => $oid));
$sess = TTGenid::getbypid($pid);
$myuser = new TTUser($sess['id']);
$nowu = new TTUser($myid['id']);
if ($user) {
$obj = $user->get_help($oid);
} else {
$obj = $nowu->get_help($oid);
$pid = $mypid;
$user = $nowu;
}
?>
<style>
#content {
height: 700px;
示例8: _handle
protected function _handle(&$req)
{
//just add method map here
$tm = $_SERVER['REQUEST_TIME'];
$method = $req['m'];
$mypre = $method;
$log_nok = false;
if (array_key_exists($method, self::$log_NOK_methods)) {
$log_nok = true;
}
$req['p']['_cid'] = $req['cid'];
$u = $req['p']['u'];
if (!$log_nok) {
if (check_dup($u, $req['cid'], $ret)) {
TTLog::record(array('s' => 'dup', 'm' => $method, 'tm' => $tm, 'u' => $u, 'p' => $this->_raw_reg));
return $ret;
}
}
if ($this->_debug) {
CrabTools::mydump($req['p'], REQ_DATA_ROOT . $mypre . '.param');
}
if (isset(self::$exist_methods[$method])) {
$caller =& self::$exist_methods[$method];
$c =& $caller[0];
$m = $caller[1];
} else {
$caller = explode('.', $method);
$cn = $caller[0];
$m = $caller[1];
$file = CONTROLLER_ROOT . "{$cn}.php";
if (!file_exists($file)) {
throw new JsonServerExecption("method {$method} file not exist:(" . CONTROLLER_ROOT . "{$cn}.php)");
}
@(require_once $file);
$c = new $cn();
if (!method_exists($c, $m)) {
throw new JsonServerExecption("{$cn} don't has callable method {$m}");
}
}
try {
$ret = $c->{$m}($req['p']);
//for debug
if (isset(self::$record_users[$u])) {
$dt = TT::get_tt('debug');
$dt->needSV = true;
$dt->put(array('m' => $method, 'tm' => $_SERVER['REQUEST_TIME'], 'in' => $req['p'], 'out' => $ret));
}
if (!$u) {
$u = 'nouser';
}
} catch (Exception $e) {
$r['s'] = 'exc';
$r['msg'] = $e->getMessage();
$r['exce'] = $e->getTrace();
error_log($method . ':' . $r['msg']);
}
if ($this->_debug) {
CrabTools::myprint($ret, REQ_DATA_ROOT . $mypre . '.resp');
}
if (!$ret) {
$ret['s'] = "KO";
$ret['msg'] = "{$cn}::{$m} return null";
}
if ($log_nok) {
if ($ret['s'] != 'OK') {
TTLog::record(array('s' => 'OK', 'm' => $method, 'tm' => $tm, 'u' => $u, 'p' => $this->_raw_reg));
}
} else {
if (!array_key_exists($m, self::$nolog_methods)) {
TTLog::record(array('s' => $ret['s'], 'm' => $method, 'tm' => $tm, 'u' => $u, 'p' => $this->_raw_reg));
}
}
return $ret;
}
示例9: array
<?php
require_once '../config.php';
$linkid = $_REQUEST['linkid'];
$pid = $_REQUEST['pid'];
$ids = $_REQUEST['ids'];
$oid = $_REQUEST['oid'];
if ($pid && $ids && $linkid && $oid) {
$tw = TT::LinkTT();
$value = $tw->getbyuidx('lid', $linkid);
if (!$value) {
/*$value = array('linkid'=>$linkid,
'uid'=>$pid,
'date'=>date('Ymd'),
'geted'=> array(),
'ids' =>$_REQUEST['ids']*/
//);
$_REQUEST['geted'] = array();
$_REQUEST['time'] = date('Ymd');
$tw->put($_REQUEST);
//print_r($_REQUEST);
TTLog::record(array('m' => 'open_shop_invite', 'tm' => $_SERVER['REQUEST_TIME'], 'u' => $pid));
}
}
header('Location: ' . RenrenConfig::$canvas_url . '?c=invite');
示例10: checkout
//.........這裏部分代碼省略.........
ksort($gs);
$shop =& $vvv['shop'];
$curtime = $shop['ctime'];
//可以售賣新商品時間
$cgoods = array();
$shop_changed = false;
$shop_empty = true;
foreach ($gs as $t => $g) {
$gconfig = ItemConfig::getItem($g['tag']);
if (!$gconfig) {
continue;
}
$ctime = $g['ctime'];
//上次結算時間
if ($curtime < $t) {
$curtime = $t;
}
//上架時間
if ($curtime < $ctime) {
$curtime = $ctime;
}
if ($curtime < $g['stime']) {
$curtime = $g['stime'];
}
$gaps = self::getTimeRates($used_advert, $curtime, $now, $popu, $maxpopu, $total_width);
foreach ($gaps as $k => $gr) {
//測試信息需要該索引值
//$snum = floor( $gr[0]/$gconfig['selltime']*$gr[1] );
$pertime = $gconfig['selltime'] / $gr[1] / $sconfig['gridWidth'];
$snum = floor($gr[0] / $pertime);
if ($snum >= $g['num']) {
//賣完了
$asnum = $g['num'];
} else {
$asnum = $snum;
}
if ($asnum == 0) {
break;
}
$ret['sell'][$g['tag']] += $asnum;
$sale_count += $asnum;
//記錄銷售份數,成就用
$income += $asnum * $gconfig['sellmoney'];
//sellmoney是單份物品的賣價
$g['num'] -= $asnum;
$curtime += floor($asnum * $pertime);
//
$g['ctime'] = $curtime;
$shop_changed = true;
$shop['ctime'] = $curtime;
if ($g['num'] == 0) {
//當前時間段賣光此箱貨物,繼續賣下一個貨物
$cgoods[] = $g;
$selloutids[] = $g['id'];
unset($shop['goods'][$g['id']]);
break;
//跳出時間段循環,繼續賣同一商店下一個上架時間的貨物(在同一商店,同一時間上架但售賣順序不同的貨物,已在上架時微調成不同上架時間)
}
}
//foreach group
if ($g['num'] != 0) {
$tu->puto($g, TT::GOODS_GROUP);
$shop_empty = false;
break;
//跳出上架時間循環,但是繼續店鋪循環,終止同一店鋪的貨物隊列中其他貨物的結算
}
}
//foreach goods
if ($shop_changed) {
$shop['_s'] = 'goods';
if ($shop_empty) {
$shop['_s'] = 'empty';
unset($shop['goods']);
}
$tu->puto($shop, TT::GOODS_GROUP, false);
}
}
//foreach shop
//總銷售份數
$now_sale_count = $tu->numch('total_count', $sale_count);
//總銷售額
$now_total_sale = $tu->numch('total_sale', $income);
//記錄玩家每一種物品賣出量
if ($ret['sell']) {
foreach ($ret['sell'] as $gid => $num) {
$tu->numch("sale_goods_{$gid}", $num);
}
}
$ret['s'] = 'OK';
$ret['income'] = $income;
$ret['money'] = $tu->chMoney($income);
$ret['t'] = $now;
$ret['rids'] = $selloutids;
$ret['total_width'] = $total_width;
$ret['popu'] = $popu;
$ret['maxpopu'] = $maxpopu;
TTLog::record(array('m' => __METHOD__, 'u' => $uid, 'tm' => $_SERVER['REQUEST_TIME'], 'p' => json_encode($ret)));
$tu->remove($selloutids);
return $ret;
}
示例11: unset
if (array_key_exists($k, $value['invite']) && !$new) {
unset($ids[$k]);
} else {
$value['invite'][$k] = $v;
}
}
$_REQUEST['ids'] = $ids;
}
if (!$gid) {
$gid = 0;
}
$_REQUEST['geted'] = array(0);
if ($pid) {
$tw->put($value);
$tw->put($_REQUEST);
TTLog::record(array('m' => 'pub_invite', 'tm' => $_SERVER['REQUEST_TIME'], 'u' => $sess['id'], 'sp2' => $linkid, 'sp1' => $gid));
}
$sessionK = $_REQUEST['sessionK'];
$renren = new Renren();
$renren->session_key = $sessionK;
$renren->api_key = RenrenConfig::$api_key;
$renren->secret = RenrenConfig::$secret;
$renren->init($sessionK);
$noti = '<xn:name uid="' . $pid . '" linked="true"/><a href="' . RenrenConfig::$canvas_url . '">正在玩購物天堂,邀請你去幫他裝貨、卸貨,順便幫他搶幾個客人</a>';
$idstr = '';
foreach ($_REQUEST['ids'] as $k => $id) {
$idstr .= $k . ',';
}
$ids = substr($ids, 0, strlen($idstr) - 1);
$r = $renren->api_client->notifications_send($idstr, $noti);
header('Location: ' . RenrenConfig::$canvas_url . '?f=invite¬i=' . $r['result']);
示例12: changeUser
changeUser($pid);
}
function helpOpenShop($fid, $pid, $ot)
{
$obj = array('uid' => $pid, 'lid' => $fid, 'frd' => $_REQUEST['frd'], 'type' => 1, 'clickTime' => 0, 'count' => 0, 'oid' => $ot, 'date' => date('Ymd'), 'rcv' => array($pid => 1));
$tt = TT::LinkTT();
$id = $tt->put($obj);
//print_r($tt->getbyuidx('lid',$fid));
changeUser($pid);
}
$type = $_REQUEST['type'];
$fid = $_REQUEST['fid'];
$pid = $_REQUEST['pid'];
$ot = $_REQUEST['ot'];
switch ($type) {
case 1:
shareGoldCoin($fid, $pid);
break;
case 2:
shareTask($fid, $pid, $ot);
break;
case 3:
ShareGift($fid, $pid, $ot);
break;
case 4:
helpOpenShop($fid, $pid, $ot);
default:
break;
}
TTLog::record(array('m' => 'pub_feed', 'tm' => $_SERVER['REQUEST_TIME'], 'u' => $pid, 'sp2' => $ot, 'sp1' => $type));
示例13: move
/**
* 移動
* @param $params
* require u -- user id
* d -- item數組
* id -- type id(類型id)
* pos -- position information of items
* @return
* s -- OK ,or other fail
* notexsit ,不存在
* gem
*/
public function move($params)
{
$uid = $params['u'];
$tu = new TTUser($uid);
if ($tu->check_dup($params['_cid'], $ret)) {
return $ret;
}
$index = 1;
$ids = array();
$pop = 0;
$now = time();
foreach ($params['d'] as $index => $row) {
$item_obj = $tu->getbyid($row['id']);
if (!$item_obj) {
$ret['s'] = 'notexsit';
$ret['index'] = $index;
return $ret;
}
$item = ItemConfig::getItem($item_obj['tag']);
if (!$item) {
$ret['s'] = 'notexsit';
$ret['index'] = $index;
return $ret;
}
if ($item['type'] == 'ro' && $row['pos'] == 's') {
//todo $tu 結算
if ($item_obj['pos'] != 's') {
require_once 'GoodsController.php';
GoodsController::checkout($params);
$item_obj = $tu->getbyid($row['id']);
}
//*{//對貨物尚未賣完的店麵進行移動時要先單個結算,確定貨物隊列為空時才能移動
if ($item_obj['_s'] == 'goods') {
$ret['error'] = 'notempty';
$ret['s'] = 'OK';
$ret['index'] = $index;
TTLog::record(array('m' => __METHOD__, 'tm' => $_SERVER['REQUEST_TIME'], 'u' => $uid, 'sp2' => 'movegoodsshop', 'shoptag' => $item_obj['tag'], 'sp1' => $item_obj['id']));
continue;
}
}
if ($item['type'] != 'ro') {
//改為不計算店麵的人氣
if ($row['pos'] != 's' && $item_obj['pos'] == 's') {
$pop += $item['pop'];
if ($item['type'] == 'rs') {
//特殊店需從倉庫擺出,結算時間為擺放時間
$row['ctime'] = $now;
}
} else {
if ($row['pos'] == 's' && $item_obj['pos'] != 's') {
$pop -= $item['pop'];
if ($item['type'] == 'rs') {
//特殊店放入倉庫結算時間需置零
unset($row['ctime']);
}
}
}
}
foreach ($row as $k => $v) {
$item_obj[$k] = $v;
}
$ret[$row['id']] = $item;
$tu->puto($item_obj, '', false);
//reduce a get op
}
if ($pop) {
$popu = $tu->numch(TT::POPU, $pop);
}
if (!$ret['s']) {
$ret['s'] = 'OK';
}
return $ret;
}
示例14: update_popu
/**
*update popula
*$params
* u -- uid
* ids -- itemids with popu
* popu -- itemids with popu
**/
function update_popu($params)
{
$uid = $params['u'];
$ids = $params['ids'];
$tu = new ttuser($uid);
$ret['oldpopu'] = $tu->getf(TT::POPU);
$ret['s'] = 'OK';
if (!$ids) {
$tu->putf(TT::POPU, 0);
$ret['newpopu'] = $tu->getf(TT::POPU);
return $ret;
}
$items = $tu->getbyids($ids);
$popu = 0;
foreach ($items as $o) {
$conf = ItemConfig::getItem($o['tag']);
$popu += $conf['pop'];
}
$tu->putf(TT::POPU, $popu);
$ret['newpopu'] = $tu->getf(TT::POPU);
TTLog::record(array('m' => __METHOD__, 'u' => $uid, 'tm' => $_SERVER['REQUEST_TIME'], 'intp1' => $popu));
return $ret;
}
示例15: _handle
protected function _handle(&$req)
{
//just add method map here
$method = $req['m'];
$mypre = $method;
if ($this->_debug) {
CrabTools::mydump($req['p'], REQ_DATA_ROOT . $mypre . '.param');
}
if (isset(self::$exist_methods[$method])) {
$caller =& self::$exist_methods[$method];
$c =& $caller[0];
$m = $caller[1];
} else {
$caller = explode('.', $method);
$cn = $caller[0];
$m = $caller[1];
$file = CONTROLLER_ROOT . "{$cn}.php";
if (!file_exists($file)) {
throw new JsonServerExecption("method {$method} file not exist:(" . CONTROLLER_ROOT . "{$cn}.php)");
}
@(require_once $file);
$c = new $cn();
if (!method_exists($c, $m)) {
throw new JsonServerExecption("{$cn} don't has callable method {$m}");
}
}
$log_method = array('Achieve.finish' => 1, 'Advert.buy' => 1, 'Advert.set' => 1, 'Cinema.enter' => 1, 'Cinema.pick' => 1, 'Gift.send' => 1, 'Gift.accept' => 1, 'Man.update' => 1, 'UserController.update_friends' => 1, 'UserController.enlarge_mall' => 1, 'ItemController.buy' => 1, 'ItemController.sale' => 1, 'CarController.buy' => 1, 'CarController.sale' => 1, 'CarController.go_goods' => 1, 'CarController.enlarge_garage' => 1, 'CarController.buy_copolit' => 1, 'CarController.apply_copolit' => 1, 'GoodsController.checkout' => 1, 'Task.share' => 1, 'Task.request' => 1, 'Task.accept' => 1, 'Task.update' => 1, 'Task.finish' => 1, 'Task.get_award' => 1, 'Friend.dis_neighbor' => 1, 'HelpGet.award' => 1);
try {
$ret = $c->{$m}($req['p']);
} catch (Exception $e) {
$r['s'] = 'exc';
$r['msg'] = $e->getMessage();
$r['exce'] = $e->getTrace();
error_log($method . ':' . $r['msg']);
TTLog::record(array('s' => $ret['s'], 'm' => $method, 'tm' => $_SERVER['REQUEST_TIME'], 'p' => $this->_raw_reg));
}
if ($this->_debug) {
CrabTools::myprint($ret, REQ_DATA_ROOT . $mypre . '.resp');
}
if (!$ret) {
$ret['s'] = "KO";
$ret['msg'] = "{$cn}::{$m} return null";
TTLog::record(array('s' => 'rnull', 'm' => $method, 'tm' => $tm, 'p' => $this->_raw_reg));
}
$tm = $_SERVER['REQUEST_TIME'];
if ($ret['s'] == 'OK') {
if (array_key_exists($method, $log_method)) {
TTLog::record(array('s' => 'OK', 'm' => $method, 'tm' => $tm, 'p' => $this->_raw_reg));
}
}
//else{
// TTLog::record(array('s'=>$ret['s'],'m'=>$method,'tm'=>$tm,'p'=>$this->_raw_reg));
//}
return $ret;
}