Exemplo n.º 1
0
 /**
  * 捡钱并结算
  * @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;
 }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
<?php

require_once 'ttserver/test_config.php';
//璁板綍鏃ュ織
$m = $_GET['m'];
if ($m) {
    $_GET['tm'] = $_SERVER['REQUEST_TIME'];
    TTLog::record($_GET);
}
Exemplo n.º 4
0
 /**
 * 更新帮助获取物品
 * @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);
 }
Exemplo n.º 5
0
 /**
          * update
 * @param $params
 *  require u        -- user 
 *                    step  -- 新手步数
 *                 //  v  -- view
 *                 //  d  -- do
 * @return 
 *  s   -- OK ,or other fail
          *  money  -- total money
          *  exp    -- total exp 
 *  award 
                  money
                  exp
                  items(物品对象数组) 
 *  d   --新的manual对象
 */
 public function update($params)
 {
     $uid = $params['u'];
     //$da = $params['d'];
     $step = $params['step'];
     //$v = ;//$da['v'];
     $d = 1;
     //;$da['d'];
     $ret = array();
     $conf = self::getAwardConf($step);
     if (!$v && !$d) {
         $ret['s'] = 'noaction';
         return $ret;
     }
     if (!$conf) {
         $ret['s'] = 'noconf';
         return $ret;
     }
     $tu = new TTUser($uid);
     $id = $tu->getoid('mannual', TT::OTHER_GROUP);
     $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;
 }
Exemplo n.º 6
0
 /**
  * 捡钱并结算
  * @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;
 }
Exemplo n.º 7
0
$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;
Exemplo n.º 8
0
 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;
 }
Exemplo n.º 9
0
<?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');
Exemplo n.º 10
0
 /**
  * 结算卖货 with goods
  * @param $params
  *   u   - userid
  *   sids  - shop ids
  * @return 
  *   s  - OK,noneed(短期内没有需要结算的商品),busy(太快)
  *   income  - 获得金币
  *   money   - 总金币
  *   selloutids - 卖完删除的id
  *   goods   --数量有辩护的商品列表
  */
 public static function checkout($params)
 {
     $uid = $params['u'];
     $sids = $params['sids'];
     $now = time();
     $tu = new ttuser($uid);
     //获取人气和宣传值
     $goods = $tu->get(TT::GOODS_GROUP);
     foreach ($goods as $g) {
         $shopid = $g['pos']['y'];
         if (!$shopid || $shopid == 's') {
             continue;
         }
         $shop = $condata[$shopid]['shop'];
         if (!$condata[$shopid]['shop']) {
             $shop = $tu->getbyid($shopid);
             if (!$shop) {
                 $shop = $tu->getbyid($shopid);
                 //error log
                 continue;
             }
             $condata[$shopid]['shop'] = $shop;
             $item = ItemConfig::getItem($shop['tag']);
             $condata[$shopid]['sconfig'] = $item;
             $total_width += $item['gridWidth'];
         }
         $stime = $g['stime'];
         //上架时间
         $condata[$shopid]['goods'][$stime] = $g;
     }
     if (!$condata || !$total_width) {
         $ret['s'] = 'OK';
         $ret['msg'] = 'nogoods';
         return $ret;
     }
     $params = $tu->getf(array(TT::POPU, TT::EXP_STAT));
     $popu = $params[TT::POPU];
     if ($popu < 0) {
         $popu = 0;
     }
     $ua = UpgradeConfig::getUpgradeNeed($params['exp']);
     $maxpopu = $ua['maxpopu'];
     $aid = $tu->getoid('advert', TT::OTHER_GROUP);
     $adv = $tu->getbyid($aid);
     $used_advert = $adv['use'];
     if (!$used_advert) {
         $used_advert = array();
     }
     //处理广告
     foreach ($used_advert as $k => $v) {
         $adv = AdvertConfig::getAdvert($tag);
         if ($start + $adv['allTime'] < $now) {
             continue;
         }
         $savead[$k] = $v;
     }
     if ($savead) {
         $adv['use'] = $savead;
         $tu->puto($adv);
     } else {
         if ($used_advert) {
             unset($adv['use']);
             $tu->puto($adv);
         }
     }
     $selloutids = array();
     $income = 0;
     $sale_count = 0;
     //销售份数
     $popu += 15 * $total_width;
     foreach ($condata as $s => $vvv) {
         $sconfig =& $vvv['sconfig'];
         $gs =& $vvv['goods'];
         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;
 }
Exemplo n.º 11
0
        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&noti=' . $r['result']);
Exemplo n.º 12
0
    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));
Exemplo n.º 13
0
 /**
  * 移动
  * @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;
 }
Exemplo n.º 14
0
 /**
  *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;
 }
Exemplo n.º 15
0
 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;
 }
Exemplo n.º 16
0
 /**
  * 收取礼物
  * @param $params
  *  require         u        -- user id
  *                  gids      -- gift ids
  * @return 
  *  s       -- OK ,or other fail
  *  id2id   -- 新旧ids映射
  */
 public function accept($params)
 {
     $uid = $params['u'];
     $tu = new TTUser($uid);
     $gifts = $params['gids'];
     foreach ($gifts as $gid) {
         $d = $tu->getbyid($gid);
         $oid = $d['id'];
         if ($d) {
             $tag = $d['gtag'];
             if ($tag) {
                 $d['tag'] = $tag;
             } else {
                 $tag = $d['tag'];
             }
             $conf = ItemConfig::getItem($tag);
             if (!$conf) {
                 continue;
             }
             $g = $conf['group'];
             if (!$g) {
                 $g = TT::ITEM_GROUP;
             }
             $id = $tu->getdid(null, $g);
             $id2id[$gid] = $id;
             $d['id'] = $id;
             unset($d['msg']);
             $d['pos'] = 's';
             $tu->puto($d);
         } else {
             $id2id[$gid] = null;
         }
         $rids[] = $oid;
     }
     $tu->remove($rids);
     $ret['s'] = 'OK';
     $ret['id2id'] = $id2id;
     TTLog::record(array('m' => __METHOD__, 'tm' => $_SERVER['REQUEST_TIME'], 'u' => $uid, 'intp1' => $d['fid'], 'sp1' => $tag));
     return $ret;
 }
Exemplo n.º 17
0
$tsess = TTGenid::getbypid($touser);
$ftu = new TTUser($fsess['id']);
$ttu = new TTUser($tsess['id']);
$att = $tsess['authat'];
$ut = $tsess['ut'];
$gemd = $tsess['gemd'];
if ($link['gift']) {
    $lg = $link['gift'];
} else {
    $lg = 0;
}
$new = 0;
if ($_REQUEST['new']) {
    $new = 1;
}
TTLog::record(array('m' => 'accept_invite', 'tm' => $_SERVER['REQUEST_TIME'], 'u' => $fromuser, 'sp1' => $lg, 'sp2' => $new, 'intp1' => $touser));
//$tudata=$ftu->getf(array('name','icon'));
$getted = $link['geted'];
$ids = $link['ids'];
$got = false;
$invite = false;
if (strtotime($link['date']) < strtotime('20100906')) {
    foreach ($ids as $id) {
        if ($id == $touser) {
            $invite = true;
            break;
        }
    }
    foreach ($getted as $u => $v) {
        if ($u == $touser) {
            $got = true;
Exemplo n.º 18
0
<?php

require_once 'config.php';
require_once 'pop/freeGift.php';
//
$key = $_REQUEST['fid'];
$tt = TT::LinkTT();
$value = $tt->getbyuidx('lid', $key);
$type = $value['type'];
$uid = $_POST['xn_sig_user'];
$new = 0;
if ($_REQUEST['new']) {
    $new = 1;
}
TTLog::record(array('m' => 'feed_back', 'tm' => $_SERVER['REQUEST_TIME'], 'sp1' => $type, 'u' => $uid, 'sp2' => 1));
$session = TTGenid::getbypid($uid);
$user = new TTUser($session['id']);
?>
<style type="text/css">
.padding_content {
	padding: 8px;
}

.center {
	text-align: center;
}

.gift_img {
	padding: 17px 11px 0px 0px;
	text-align: center;
}