function inituser($fromid, $toid) { $otu = new TTUser($fromid); $tu = new TTUser($toid); $all = $otu->getAll(false); $allr = array(); $now = time(); foreach ($all as $k => $v) { $arr = explode(':', $k); $arr[0] = $toid; $nk = implode(':', $arr); $nv = $v; $isobj = TTExtend::checkObj($v); if ($isobj) { $v['id'] = $nk; if (isset($v['stime'])) { $v['stime'] = $now - 50; } if (isset($v['pos']['y'])) { $arr = explode(':', $v['pos']['y']); if (count($arr) > 1 && ($arr[0] = $toid)) { $arr[0] = $toid; $v['pos']['y'] = implode(':', $arr); } } $allr[$nk] = json_encode($v); } else { $allr[$nk] = $nv; } } $tt = TT::get_tt('main', $toid); $tt->put($allr); //print_r($tu->getAll()); }
/** * 赠送礼物,暂只支持赠送已有物品 * @param $params * require u -- 送礼人id * f -- 受礼人id * msg -- 送礼人的留言 * option xid -- 礼物id,赠送已有物品时传此参数, * xtag -- 新买物品的xml id,赠送新买物品时传此参数 * @return * s -- OK */ public function send_gift($params) { $uid = $params['u']; $fid = $params['f']; $msg = $params['msg']; $xid = $params['xid']; $xtag = $params['xtag']; if (!$fid) { $ret['s'] = 'friendnotexsit'; return $ret; } if (!$xid) { //赠送已有物品 if (0) { //验证xml中是否存在此类物品 } //验证送礼人是否有此物品 $tm = new TTMain(); //礼物只能是装饰品? $gift_obj = $tm->getbyid($xid, $uid); if (!$gift_obj) { $ret['s'] = 'giftnotexsit'; return $ret; } //从送礼人的物品列表中除去此礼物 $tm->remove($uid, $gift_obj['id']); } if (!$xtag) { //赠送新买物品 if (0) { //验证xml中是否存在此类物品 } $tu = new TTUser($uid); $buy_ret = $tu->buyItem($xtag); if ($buy_ret['s'] != 'OK') { return $buy_ret; } //如何得到新买物品的id? } $db = ServerConfig::connect_main_mysql(0); $present = ModelFactory::Present($db); $now = time(); $data['user_id'] = $fid; $data['donor_id'] = $uid; $data['message'] = $msg; $data['item_id'] = $gift_obj['tag']; //如果是新买物品 $data['item_id'] = 新物品的tag $data['done'] = 0; //未被好友领取 $data['created_at'] = date(TM_FORMAT, $now); $present->insert($data); $ret['s'] = 'OK'; return $ret; }
/** * 达成成就 * @param $params * require u -- userid * tag -- 成就种类,对应xml的id * @return * s -- OK,others fail */ public function finish($params) { $uid = $params['u']; $tag = $params['tag']; $tu = new TTUser($uid); $id = $tu->getoid('achieves', TT::OTHER_GROUP); $achieves = $tu->getbyid($id); if ($achieves[$tag]) { $ret['s'] = 'repeat'; return $ret; } $config = AchieveConfig::getAchieve($tag); $count = $tu->getf($config['group']); if ($count < $config['aimNum']) { //检验是否真的完成 $ret['s'] = 'unfinish'; return $ret; } $achieves[$tag] = time(); $money = $tu->chMoney($config['rewardMoney']); $exp = $tu->numch('exp', $config['rewardRep']); if ($config['item']) { //成就达成的物品奖励 } $achieves['id'] = $id; // $ret['b'] = $achieves; $tu->puto($achieves); $ret['a'] = $tu->getbyid($id); $ret['s'] = 'OK'; return $ret; }
/** * 捡钱并结算 * @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; }
/** * 捡钱并结算 * @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; }
/** * 使用副驾驶 * @param $params * require u -- user_id * tag -- 副驾驶类别 * cid -- car id * @return * s -- OK * tag -- 副驾驶tag * car -- 测试信息 * copi -- 测试信息 */ public function apply_copolit($params) { $uid = $params['u']; $tag = $params['tag']; $cid = $params['cid']; $copi = self::$_config[$tag]; $stat['tag'] = $tag; $stat['op'] = 'apply_copolit'; $stat['num'] = $num; $stat['u'] = $uid; $stat['tm'] = $_SERVER['REQUEST_TIME']; $gemt = TT::GemTT(); if (!$copi) { $ret['s'] = 'copinotexist'; $stat['s'] = $ret['s']; $gemt->putKeep(null, $stat); return $ret; } $tu = new TTUser($uid); $id = $tu->getoid('copilot', TT::OTHER_GROUP); $copilot = $tu->getbyid($id); $car_obj = $tu->getbyid($cid); if (!$car_obj) { $ret['s'] = 'carnotexsit'; $stat['s'] = $ret['s']; $gemt->putKeep(null, $stat); return $ret; } if ($tag != 2006 && $car_obj['copolitTag']) { $ret['s'] = 'repeat'; $stat['s'] = $ret['s']; $gemt->putKeep(null, $stat); return $ret; } $goods = ItemConfig::getItem($car_obj['goodsTag']); if ($tag != 2006) { if ($copilot['bag'][$tag] < 1) { $ret['s'] = 'needbuy'; $stat['s'] = $ret['s']; $gemt->putKeep(null, $stat); return $ret; } $copilot['bag'][$tag] -= 1; $car_obj['copolitTag'] = $tag; } else { if ($goods['buytime'] >= 1800) { $car = ItemConfig::getItem($car_obj['tag']); $add_exp = $goods['exp'] * $car['goodsNumber']; //乘以载重箱,经验不包括好友帮助增加的箱数 if ($add_exp) { $tu->addExp($add_exp); } } unset($car_obj['addgoods']); unset($car_obj['accelerate']); unset($car_obj['t']); unset($car_obj['help']); unset($car_obj['goodsTag']); unset($car_obj['copolitTag']); } $copilot['id'] = $id; $now = time(); $tu->puto($copilot); if ($copi['addgoods']) { $car_obj['addgoods'] += $copi['addgoods']; } if ($copi['accelerate'] && $car_obj['t']) { if ($now - $car_obj['t'] + $copi['accelerate'] > $goods['buytime']) { $car_obj['t'] = $now - $goods['buytime']; } else { $car_obj['t'] -= $copi['accelerate']; } } $tu->puto($car_obj); $ret['s'] = 'OK'; $ret['tag'] = $tag; $stat['s'] = $ret['s']; $gemt->putKeep(null, $stat); return $ret; }
<?php require_once 'config.php'; include "./header.php"; $pid = $_REQUEST['xn_sig_user']; $sess = TTGenid::getbypid($pid); $user = new TTUser($sess['id']); $gem = $user->chGem(0); ?> <style> #content { height: 700px; font:12px/1.5 tahoma,arial,微软雅黑,宋体,sans-serif; } #header .logo { width:195px; height: 46px; background: url("<?php echo RenrenConfig::$resource_urlp; ?> /images/logo.png?v=1") no-repeat 10px center transparent; text-indent: -9999px; float: left; } #header .logo a { display: block; height: 36px;
public function checkshop($params) { $uid = $params['u']; $sid = $params['sid']; $tu = new TTUser($uid); $shop_obj = $tu->getbyid($sid); if (!$shop_obj) { $ret['s'] = 'notexsit'; return $ret; } $goods_list = $shop_obj['goods']; $condata = array(); if (!$goods_list) { $ret['s'] = 'nogoods'; return $ret; } foreach ($goods_list as $goods_id => $stime) { $goods_obj = $tu->getbyid($goods_id); $condata[$stime] = $goods_obj; } $ret['condata'] = $condata; $popu = $params[TT::POPU]; $ret['bpopu'] = $popu; $ua = UpgradeConfig::getUpgradeNeed($params['exp']); $ret['ua'] = $ua; //算人气 $shops = $tu->get(TT::SHOP_GROUP); foreach ($shops as $shop) { $ret['shop_num_shop'][] = $shop; if ($shop['pos'] != 's') { $item = ItemConfig::getItem($shop['tag']); $shop_num += $item['gridWidth']; } } $ret['ashopnum'] = $shop_num; if (!$shop_num) { $ret['s'] = 'noshopexist'; return $ret; } $shop_popu = $shop_num * 15; //只算店面人气 $popu += $shop_popu; if ($popu > $ua['maxpopu']) { $popu = $ua['maxpopu']; } $ret['apopu'] = $popu; $aid = $tu->getoid('advert', TT::OTHER_GROUP); $adv = $tu->getbyid($aid); $used_advert = $adv['use']; // $ret['bbbbbadvert'] = $adv; $computetime = $params[TT::COMPUTE_PONIT]; // $ret['now'] = date( TM_FORMAT,$now ); // $ret['lastcomputetime'] = date( TM_FORMAT,$computetime ); $selloutids = array(); $income = 0; $special = 0; //特殊商店的收入 $sale_count = 0; //销售份数 $now = time(); $sconfig = ItemConfig::getItem($shop_obj['tag']); // $ret['sconfig'][$s] = $sconfig; ksort($condata); $curtime = 0; //可以售卖新商品时间 $cgoods = array(); foreach ($condata as $t => $g) { $gconfig = ItemConfig::getItem($g['tag']); $ctime = $g['ctime']; //上次结算时间 if ($curtime < $t) { $curtime = $t; } //上架时间 if ($curtime < $ctime) { $curtime = $ctime; } $g['ctime'] = $now; $ret['tloop'][$t] = date(TM_FORMAT, $curtime); $gaps = array(); if ($used_advert) { $tmp = self::getTimeRates($tu, $gaps, $used_advert, $curtime, $popu, $ua['maxpopu'], $now, $shop_num); // $ret['advertisement'][$s][$t] = $tmp; } else { $gaps = array(array($now - $curtime, $popu / ($shop_num * 15))); } $ret['gaps'][$t] = $gaps; // foreach($gaps as $gr){ foreach ($gaps as $k => $gr) { //测试信息需要该索引值 $stime = $gr[0]; if ($sconfig['gridWidth']) { $pertime = $gconfig['selltime'] / ($sconfig['gridWidth'] * $gr[1]); } if ($pertime) { $snum = floor($stime / $pertime); } $ret['pertime'][$t][$k] = $pertime; if ($snum >= $g['num']) { //卖完了 $asnum = $g['num']; } else { $asnum = $snum; } // $ret['asnum'][$s][$t][$k][$g['tag'] ] = $asnum; $ret['sell'][$g['tag']] += $asnum; $sale_count += $asnum; //记录销售份数,成就用 $income += $asnum * $gconfig['sellmoney']; //sellmoney是单份物品的卖价 $g['num'] -= $asnum; // $g['scount'] += $asnum; if ($g['num'] == 0) { //当前时间段卖光此箱货物,继续卖下一个货物 $cgoods[] = $g; $selloutids[] = $g['id']; unset($shop_obj['goods'][$g['id']]); break; //跳出时间段循环,继续卖同一商店下一个上架时间的货物(在同一商店,同一时间上架但售卖顺序不同的货物,已在上架时微调成不同上架时间) } } $tu->puto($shop_obj, TT::SHOP_GROUP); if ($g['num'] != 0) { $tu->puto($g, TT::GOODS_GROUP); //未卖完的商品需要保存回库,继续卖同一商店下一个上架时间的货物(在同一商店,一时间上架但售卖顺序不同的货物,已在上架时微调成不同上架时间) break; //跳出上架时间循环,但是继续店铺循环,终止同一店铺的货物队列中其他货物的结算 } } //删除使用过的广告队列 unset($adv['use']); if ($used_advert) { //如果是空数组 $adv['use'] = $used_advert; } $adv['id'] = $aid; $tu->puto($adv, TT::ADVERT_GROUP, false); //总销售份数 $now_sale_count = $tu->numch('total_count', $sale_count); //总销售额 $now_total_sale = $tu->numch('total_sale', $income); $ret['s'] = 'OK'; $ret['income'] = $income; $ret['money'] = $tu->numch('money', $income); $ret['t'] = $now; $tu->remove($selloutids); $tu->putf(TT::COMPUTE_PONIT, $now); return $ret; }
/** * 卖出 * @param $data (对应数据库的一条记录) * @param $num * @return */ public function saleItem(&$data, $num = 1) { $tag = $data['tag']; $stat['tag'] = $tag; $stat['num'] = $num; $stat['u'] = $this->_u; $stat['op'] = 'sale'; $stat['tm'] = $_SERVER['REQUEST_TIME']; $gemt = TT::GemTT(); $item = ItemConfig::getItem($tag); if (!$item || !isset($item['tag'])) { $ret['s'] = 'notfind'; $stat['s'] = $ret['s']; $gemt->putKeep(null, $stat); return $ret; } if ($item['onlygem'] == 'true') { //对用宝石购买的物品,按1:10000换成金币再3折 $num = $item['gem'] * 3000; } else { if ($item['group'] == 'g') { $num = $item['sellmoney'] * $item['unitcout'] * 0.3; } else { $num = $item['money'] * 0.3; } } $rnum = $this->numch(TT::MONEY_STAT, $num); $tusys = new TTUser(0); $statid = 'usalenum_' . $item['tag']; $saled = $tusys->numch($statid, $num); //记录系统回购每种商品总数 $ret['s'] = 'OK'; $ret['money'] = $rnum; $stat['money'] = $cnum; $stat['t'] = 'money'; $stat['s'] = $ret['s']; $gemt->putKeep(null, $stat); return $ret; }
public function resetNull() { //解决上架的货物中num字段为空或零的情况 $ret = array(); for ($i = 1; $i < 50000; $i++) { $uid = $i; $tu = new TTUser($uid); $goods = $tu->get(TT::GOODS_GROUP); if ($goods) { foreach ($goods as $index => $goods_obj) { $ret[$i]['bgoods'][$index] = $goods_obj; // for debug $item = ItemConfig::getItem($goods_obj['tag']); $ret[$i]['item'][$index] = $item; // for debug if (!$goods_obj['num']) { $goods_obj['num'] = $item['unitcout']; } $ret[$i]['agoods'][$index] = $goods_obj; // for debug // save new goods_obj } } } return $ret; }
public static function dcheckout($params) { $uid = $params['u']; $sids = $params['sids']; $now = $params['now']; $tu = new TTUser($uid); if (!$now) { $now = time(); } $debug = true; $goods = $tu->get(TT::GOODS_GROUP); //$ret['goods']=$goods; foreach ($goods as $g) { $shopid = $g['pos']['y']; if (!$shopid || $shopid == 's') { continue; } if (!isset($condata[$shopid]['shop'])) { $shop = $tu->getbyid($shopid); if (!$shop) { //error log $ret['goods_no_shop'][] = $g; 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; } //$ret['condata'] = $condata; if (!$condata || !$total_width) { $ret['s'] = 'OK'; $ret['msg'] = 'nogoods'; $ret['condata'] = $condata; $ret['total_width'] = $total_width; return $ret; } $params = $tu->getf(array(TT::POPU, TT::EXP_STAT)); $popu = $params[TT::POPU]; $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; 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); $ret[$g['id']]['startctime'] = $curtime; $ret[$g['id']]['gaps'] = $gaps; $ret[$g['id']]['shop'] = $s; $ret[$g['id']]['mydata'] = $g; foreach ($gaps as $k => $gr) { //测试信息需要该索引值 $pertime = $gconfig['selltime'] / $gr[1] / $sconfig['gridWidth']; $snum = floor($gr[0] / $pertime); if ($snum >= $g['num']) { //卖完了 $asnum = $g['num']; } else { $asnum = $snum; } $ret['sell'][$g['tag']] += $asnum; $sale_count += $asnum; //记录销售份数,成就用 $income += $asnum * $gconfig['sellmoney']; //sellmoney是单份物品的卖价 $g['num'] -= $asnum; $curtime += floor($asnum * $pertime); // $g['ctime'] = $curtime; $shop['ctime'] = $curtime; if ($debug) { $ret[$g['id']][$k]['sell_num'] = $asnum; $ret[$g['id']][$k]['endcurtime'] = $curtime; $ret[$g['id']][$k]['gap'] = $gr[0]; $ret[$g['id']][$k]['pertime'] = $pertime; $ret[$g['id']][$k]['ratio'] = $gr[1]; $ret[$g['id']][$k]['left_num'] = $g['num']; $ret[$g['id']][$k]['basespertime'] = $gconfig['selltime']; $ret[$g['id']][$k]['shopwidth'] = $sconfig['gridWidth']; } if ($g['num'] == 0) { //当前时间段卖光此箱货物,继续卖下一个货物 $cgoods[] = $g; $selloutids[] = $g['id']; $shop_changed = true; unset($shop['goods'][$g['id']]); break; //跳出时间段循环,继续卖同一商店下一个上架时间的货物(在同一商店,同一时间上架但售卖顺序不同的货物,已在上架时微调成不同上架时间) } } if ($g['num'] != 0) { if (!$debug) { $tu->puto($g, TT::GOODS_GROUP); } break; //跳出上架时间循环,但是继续店铺循环,终止同一店铺的货物队列中其他货物的结算 } } //foreach goods if ($shop_changed) { if (!$debug) { $tu->puto($g, TT::GOODS_GROUP); } } } //foreach shop if ($debug) { $ret['total_width'] = $total_width; $ret['popu'] = $popu; $ret['maxpopu'] = $maxpopu; $ret['params'] = $params; } //总销售份数 //总销售额 //记录玩家每一种物品卖出量 $ret['s'] = 'OK'; $ret['income'] = $income; //$ret['money'] = $tu->numch('money',$income); $ret['t'] = $now; $ret['rids'] = $selloutids; $ret['u'] = $uid; return $ret; }
require_once '../config.php'; /* $ret['query'] = $_REQUEST; $ret['post'] = $_POST; $ret['get'] = $_GET; echo json_encode($ret); */ $op = $_REQUEST['op']; $pid = $_REQUEST['xn_sig_user']; if ($op && $pid) { $sess = TTGenid::getbypid($pid); $uid = $sess['id']; if (!$sess && $uid) { echo "{'s':'fail','msg':'not find {$pid} op={$op}'}"; return; } $tu = new TTUser($uid); $id = $tu->getdid('installbar', TT::OTHER_GROUP); $barobj = $tu->getbyid($id); if ($barobj[$op]) { echo "{'s':'fail','msg':'not find {$pid} op={$op}'}"; return; } else { $barobj['id'] = $id; $barobj[$op]['save'] = time(); $tu->puto($barobj, TT::OTHER_GROUP, false); echo "{'s':'ok'}"; return; } } echo "{'s':'fail','error':'pid={$pid} op={$op}'}";
<?php require_once '../../config.php'; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> <table> <tr> <?php $id = '4'; $user = new TTUser($id); $frd = $user->getf(TT::FRIEND_STAT); print_r($frd); $content = '<fb:name uid="loggedinuser"" firstnameonly="true" shownetwork="false"/>正在玩<a href="$facebook->canvas_url">開心酒店</a>,推薦你也來玩一把!<br><fb:req-choice url="kokopio" label="開始玩開心酒店"/>'; $gift = $_REQUEST["gift"]; if ($gift != NULL && $gift != '') { $content = '<fb:name uid="loggedinuser"" firstnameonly="true" shownetwork="false"/>用Mall送给你<a href="$facebook->canvas_url"><img src="../giftIcon/' . $gift . '"/></a>,快来领悟吧!<br/><fb:req-choice url="kokopio" label="開始玩mall"/>'; echo '<td>'; echo '<img src="../giftIcon/' . $gift . '"/>'; echo '</td>'; } ?> <td> <fb:serverfbml> <script type="text/fbml">
/** 五,增加好友箱数: 说明: 货车出发之后,放进仓库之前,好友均可点击,点击会增加货物箱数。 按钮问题:好友帮助加箱数的按钮,在货车运货过程中和货车回来都有。而当货车回来,但是没有放进仓库时,只有到好友家才有按钮,自己的副驾驶功能消失。 限制: 每人每日可帮一个好友一次。 级别越高增加的箱数越多。 级别: 箱数: 1 1 40 2 70 3 被帮助者奖励: 礼物为一箱货物。 帮助者奖励: 获得所进货物经验(进货+取货的经验和)相等的经验。 * @param $params * require u -- user id * f -- friend id * cid -- car id * type -- 1 表示加货 * 2 表示保鲜 * @return * s -- OK -- helped,已经拜访过 -- nofriend,不是朋友 -- freshed 今天已经操作过了 -- alreadyfresh 可能已被别人保鲜了 -- notexpiration 货物未过期 award exp --奖励经验 money --奖励金钱 */ public function help_car($params) { $uid = $params['u']; $nid = $params['f']; $cid = $params['cid']; $type = $params['type']; //兼容在线的旧flash版本 if (!$type) { $type = 1; } $tu = new TTUser($uid); $ftu = new TTUser($nid); $fdid = $tu->getdid($nid, 'fr'); $now = time(); $now_date = date('Ymd', $now); $fdata = $tu->getbyid($fdid); if (!$fdata) { $ret['s'] = 'nofriend'; return $ret; } $car = $ftu->getbyid($cid); if (!$car) { $ret['s'] = 'nocar ' . $cid; return $ret; } $goodsid = $car['goodsTag']; $gconfig = ItemConfig::getItem($goodsid); $add_exp = $gconfig['exp']; if (!$add_exp) { $ret['s'] = 'nogoods'; $ret['g'] = $gconfig; return $ret; } $level = $tu->getLevel(); $vt = $fdata['ht']; $vt_date = date('Ymd', $vt); $fdata['ht'] = $now; if ($type == 1) { //加货 if ($vt_date == $now_date && $fdata['help_car'] == '1') { $ret['s'] = 'helped'; return $ret; } $carconf = ItemConfig::getItem($car['tag']); $counts = count($car['help']); if ($counts > $carconf['gridWidth']) { $ret['help_time'] = $counts; $ret['gridW'] = $car['help']; $ret['s'] = 'max'; return $ret; } $num = 1; if ($level > 39) { $num = 2; } if ($level > 69) { $num = 3; } $car['help'][$uid] = $num; $fdata['help_car'] = 1; } if ($type == 2) { //保鲜 if ($vt_date == $now_date && $fdata['fresh'] == '1') { $ret['s'] = 'freshed'; return $ret; } if ($car['fresh']) { $ret['s'] = 'alreadyfresh'; return $ret; } if ($now - $car['t'] <= 3 * $gconfig['buytime']) { //货物未过期 $ret['s'] = 'notexpiration'; return $ret; } $car['fresh'] = $nid; $car['fresh'] = $params['f']; $fdata['fresh'] = 1; } $add_exp *= 2; $ret['type'] = $type; $ret['exp'] = $tu->addExp($add_exp); $ret['award']['exp'] = $add_exp; $tu->puto($fdata, 'fr', false); $ftu->puto($car, '', false); $ret['cid'] = $cid; $ret['s'] = 'OK'; $ret['t'] = $now; $ret['car'] = $car; // for debug return $ret; }
<html> <head> </head> <body> <?php //require_once '../config.php'; require_once 'freeGift.php'; print_r($_REQUEST); $key = $_GET['key']; $tt = TT::TTWeb(); $value = $tt->get($key); $type = $value['type']; $uid = $_POST['uid']; $user = new TTUser($uid); if ($type == 2 && $value['count'] > 0) { echo '<script type="text/javacsript">'; echo 'wodows.location = "http://apps.renren.com/livemall/";'; echo '</script>'; } elseif ($type == 1 && $value['count'] > 0) { $recv = $value['rcv']; if (!array_key_exists($uid, $recv)) { $user->chMoney(1000); $value['count'] = $value['count'] - 1; $value['clickTime'] += 1; $value['rcv'][] = $uid; $tt->puto($value); echo '<script type="text/javacsript">'; echo 'wodows.location = "http://apps.renren.com/livemall/";'; echo '</script>'; } } elseif ($type == 3 && $value['count'] > 0) {
/** 五,增加好友箱数: 说明: 货车出发之后,放进仓库之前,好友均可点击,点击会增加货物箱数。 按钮问题:好友帮助加箱数的按钮,在货车运货过程中和货车回来都有。而当货车回来,但是没有放进仓库时,只有到好友家才有按钮,自己的副驾驶功能消失。 限制: 每人每日可帮一个好友一次。 级别越高增加的箱数越多。 级别: 箱数: 1 1 20 2 40 3 被帮助者奖励: 礼物为一箱货物。 帮助者奖励: 获得所进货物经验(进货+取货的经验和)相等的经验。 * @param $params * require u -- user id * f -- friend id * cid -- car id * @return * s -- OK -- helped,已经拜访过 -- nofriend,不是朋友 award exp --奖励经验 money --奖励金钱 */ public function help_car($params) { $uid = $params['u']; $nid = $params['f']; $cid = $params['cid']; $tu = new TTUser($uid); $ftu = new TTUser($nid); $fdid = $tu->getdid($nid, 'fr'); $now = time(); $now_date = date('Ymd', $now); $fdata = $tu->getbyid($fdid); if (!$fdata) { $ret['s'] = 'nofriend'; return $ret; } $vt = $fdata['ht']; $vt_date = date('Ymd', $vt); if ($vt_date == $now_date && $fdata['help_car'] == '1') { $ret['s'] = 'helped'; return $ret; //for test } $car = $ftu->getbyid($cid); if (!$car) { $ret['s'] = 'nocar ' . $cid; return $ret; } $carconf = ItemConfig::getItem($car['tag']); $counts = count($car['help']); if ($counts > $carconf['gridWidth']) { $ret['help_time'] = $counts; $ret['gridW'] = $car['help']; $ret['s'] = 'max'; return $ret; } $goodsid = $car['goodsTag']; $gconfig = ItemConfig::getItem($goodsid); $add_exp = $gconfig['exp']; if (!$add_exp) { $ret['s'] = 'nogoods'; $ret['g'] = $gconfig; return $ret; } $level = $tu->getLevel(); $num = 1; if ($level > 39) { $num = 2; } if ($level > 69) { $num = 3; } //$mydata = TTGenid::getbyid($uid); $car['help'][$uid] = $num; $add_exp *= 4; $ret['exp'] = $tu->addExp($add_exp); $ret['award']['exp'] = $add_exp; $fdata['ht'] = $now; $fdata['help_car'] = 1; $tu->puto($fdata, 'fr', false); $ftu->puto($car, '', false); $ret['cid'] = $cid; $ret['s'] = 'OK'; $ret['t'] = $now; return $ret; }
$uid = $sess['id']; if ($session_key != $sess['session_key']) { $renren = new Renren(); $renren->api_key = RenrenConfig::$api_key; $renren->secret = RenrenConfig::$secret; $renren->session_key = $session_key; $renren->init($session_key); $rt = $renren->api_client->users_getLoggedInUser(); if ($rt['uid'] == $pid) { $sess['session_key'] = $session_key; TTGenid::update($sess, $sess['id']); } else { header('Location: ' . RenrenConfig::$canvas_url); } } $tu = new TTUser($uid); $iid = $tu->getdid('installbar', TT::OTHER_GROUP); $barobj = $tu->getbyid($iid); $install_bar = true; if ($barobj == null || $barobj['email'] == null) { $install_bar = true; } else { $install_bar = false; } if ($gflg) { $data = $ts->getbyid($gflg); $bids = $data['rfids']; if (strstr($bids, $pid)) { } else { //给玩家礼物 $flag = $data['gift_id'];
public function test_tt() { $tu = new TTUser(1); $tt = TT::get_tt('main', 1); $id = $tu->getdid(TT::SHOP_NUM); $str = '$tu->numch(TT::SHOP_NUM,$shop_num)'; echo "{$str}="; record_time($st); eval('print_r( ' . $str . ');'); record_time($st, $str); echo "\n"; $shop_num = 10; $str = '$tu->numch(TT::SHOP_NUM,$shop_num)'; echo "{$str}="; record_time($st); eval('print_r( ' . $str . ');'); record_time($st, $str); echo "\n"; $shop_num = -10; $str = '$tu->numch(TT::SHOP_NUM,$shop_num)'; echo "{$str}="; record_time($st); eval('print_r( ' . $str . ');'); record_time($st, $str); echo "\n"; $tu->putf('strint', '0000'); $str = '$tu->getf("strint")'; echo "{$str}="; record_time($st); eval('print_r( ' . $str . ');'); record_time($st, $str); echo "\n"; $shop_num = -10; $str = '$tu->numch("strint",$shop_num)'; echo "{$str}="; record_time($st); eval('print_r( ' . $str . ');'); record_time($st, $str); echo "\n"; $shop_num = 10; $str = '$tu->numch("strint",$shop_num)'; echo "{$str}="; record_time($st); eval('print_r( ' . $str . ');'); record_time($st, $str); echo "\n"; $tt->put("strint", 'a'); $str = '$tt->get("strint")'; echo "{$str}="; record_time($st); eval('print_r( ' . $str . ');'); record_time($st, $str); echo "\n"; $str = '$tt->numch("strint",100)'; echo "{$str}="; record_time($st); eval('print_r( ' . $str . ');'); record_time($st, $str); echo "\n"; $str = '$tt->numch("strint",100)'; echo "{$str}="; record_time($st); eval('print_r( ' . $str . ');'); record_time($st, $str); echo "\n"; }
<?php require_once 'config.php'; $linkid = $_REQUEST['linkid']; $fid = $_REQUEST['fid']; if (!$linkid || !$fid) { header('Location: ' . RenrenConfig::$canvas_url . '?help=invite'); } else { $tw = TT::LinkTT(); $irec = $tw->getbyuidx('lid', $linkid); } if ($irec) { $pid = $irec['uid']; $oid = $irec['oid']; $sess = TTGenid::getbypid($pid); $user = new TTUser($sess['id']); } if ($user) { $user->update_help($oid, $fid); } if ($_REQUEST['xn_sig_user']) { $fid = $_REQUEST['xn_sig_user']; } header('Location: cinema.php?fid=' . $linkid . '&xn_sig_user=' . $fid);
/** * 收取礼物 * @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; }
/** * update * @param $params * require u -- user * type -- 满足type * @return * s -- OK ,or other fail max,超出限制 notype,超出限制 * money -- total money * exp -- total exp * award money exp * d --新的对象 */ public function satisfy($params) { static $type2award = array(1 => array('money' => 10, 'exp' => 2)); $uid = $params['u']; $type = $params['type']; $award = $type2award[$type]; //$type = 1; if (!$award) { $ret['s'] = 'notype'; return $ret; } $tu = new TTUser($uid); $id = $tu->getoid('satisfy', TT::OTHER_GROUP); $data = $tu->getbyid($id); $data['id'] = $id; $now = time(); $now_date = date('Ymd', $now); if ($data['date'] != $now_date) { $data['r'] = array(); $data['date'] = $now_date; } if (++$data['r'][$type] > 10) { $ret['s'] = 'max'; return $ret; } $ret['award'] = $award; foreach ($award as $k => $v) { $ret[$k] = $tu->numch($k, $v); } $ret['d'] = $data; $ret['s'] = 'OK'; $tu->puto($data, '', false); return $ret; }
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> <?php include "config.php"; echo "<pre>"; $pid = $_REQUEST['xn_sig_user']; $sess = TTGenid::getbypid($pid); $uid = $sess['id']; $tu = new TTUser($uid); $session_key = $sess['session_key']; if (!$pid) { die('no pid'); } if (!$session_key) { die('no session key'); } $ar['pid'] = $pid; require_once 'renren.php'; $ren = new Renren(); $ren->api_key = RenrenConfig::$api_key; $ren->secret = RenrenConfig::$secret; $renren->session_key = $session_key; $ren->init($session_key); $ret = $ren->api_client->friends_getAppFriends(); if ($ret && $ret[0] && $ret[0] > 0) {
/** * 领取任务奖励 * * @param $params * require u -- uid * tid -- 任务id * @return * s -- OK,正常 * notexsit,该任务不存在 * cantgetaward,未完成的任务,不能领取奖励 * tid -- task id */ public function get_award($params) { $uid = $params['u']; $tid = $params['tid']; //判断用户是否正在任务中 $tu = new TTUser($uid); $task_obj = $tu->getbyid($tid); // $ret['task_obj'] = $task_obj; if (!$task_obj) { $ret['s'] = 'notexsit'; return $ret; } if ($task_obj['s'] != '2') { $ret['s'] = 'cantgetaward'; return $ret; } //两种奖励,分别根据$task_obj['ac'] (分享的奖励) 结算 $today_start = strtotime(date('Y-m-d', time())); if ($task_obj['ct'] < $today_start) { //如果是昨天的任务,领取奖励后此条记录删除 $tu->remove($tid); } else { $task_obj['s'] = '4'; $tu->puto($task_obj, TT::TASK_GROUP); } $ret['id'] = $tid; $ret['s'] = 'OK'; return $ret; }
$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; font:12px/1.5 tahoma,arial,微软雅黑,宋体,sans-serif; } #header .logo {
dotest('HelpGet.award', array('u' => 10997, 'tag' => 60102)); return; dotest('UserController.get_goods', array('u' => 57)); return; $now = 1282208631; $now = time(); dotest('GoodsController.dcheckout', array('u' => 26, 'now' => $now)); return; dotest('Man.update', array('u' => 8127, 'step' => '1')); exit; dotest('Friend.debug_get', array('u' => 4)); return; dotest('UserController.update_profile'); dotest('Friend.help_car'); return; $tu = new TTUser(2); $tu->update_help('60102', 3); $tu->update_help('60102', 4); $tu->update_help('60102', 5); dotest('Friend.get', array('u' => 2, 'f' => 24)); dotest('HelpGet.get', array('u' => 2)); dotest('HelpGet.open', array('u' => 2, 'tag' => '60102')); dotest('HelpGet.award', array('u' => 2, 'tag' => '60102')); return; $now = 1282208631; $now = time(); //dotest('GoodsController.checkout',array('u'=>61,'now'=>$now)); //return; dotest('GoodsController.dcheckout', array('u' => 138, 'now' => $now)); return; dotest('Gift.accept');
<?php require_once 'config.php'; $pid = $_POST['xn_sig_user']; $secret = Renrenconfig::$pay_secure; // if ($_POST['xn_sig_skey'] != md5($secret . $pid)) { $ret['app_res_code'] = "error invalid"; echo json_encode($ret); exit; } $ot = TT::get_tt('order'); $sess = TTGenid::getbypid($pid); $user = new TTUser($sess['id']); $oid = $_POST['xn_sig_order_id']; $payment = $ot->get($oid); if ($payment == null) { $ret['app_res_code'] = "error no order"; echo json_encode($ret); exit; } if ($payment['status'] == 0) { if ($payment['sandbox'] == 'true' && $pid != '30578' && $pid != '253382225') { $ret['app_res_user'] = $pid; $ret['app_res_amount'] = $payment['amount']; $ret['app_res_order_id'] = $oid; echo json_encode($ret); } else { if ($user->chGem($payment['gem'])) { $payment['status'] = 1; $payment['handledTime'] = time();
<?php /* $myloc=dirname(__FILE__); require_once $myloc.'/bg/base.php'; require_once LIB_ROOT.'ModelFactory.php'; require_once LIB_ROOT.'AutoIncIdGenerator.php'; $platform_id = "302268025"; $pid = "renren302268025"; $user_id = AutoIncIdGenerator::genid($platform_id); $p_user = AutoIncIdGenerator::genid($pid); echo "user_id = $user_id\n"; echo "p_user = $p_user\n"; require_once('config.php'); $linkid =':4c60c7314f3ef'; $tw = TT::TTWeb(); echo 'i.m here<br>'; $irec = $tw->getbyid($linkid); print_r($irec);*/ require_once 'config.php'; $user = new TTUser(13); $v = $user->getbyid('13:o:4c7dd4debd11e'); print_r($v); $v['tag'] = 60002; $user->puto($v);
} if (!$u) { $pid = $argv[2]; if (!$pid) { $pid = $_REQUEST['pid']; } if (!$pid) { $pid = $_COOKIE['user_name']; } if (!$pid) { die("no param"); } $data = TTGenid::getbypid($pid); } else { $data = TTGenid::getbyid($u); } if ($data['id']) { $u = $data['id']; } if (!$data) { die("{$u} {$pid} no u get"); } $tu = new TTUser($u); print_r($data); $tt = $tu->getAll(false); print_r(TTExtend::processmap($tt)); print_r($tt); ?> </body> </html>
</style> <?php require_once 'pop/freeGift.php'; $linkid = $_REQUEST['lid']; $tw = TT::LinkTT(); $link = $tw->getbyuidx('lid', $linkid); $touser = $_REQUEST['xn_sig_user']; ?> <xn:if-is-app-user> <div id='is_install'></div> <?php $fromuser = $link['pid']; $fsess = TTGenid::getbypid($fromuser); $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'];
/** * 获取广告 * @param $params * require u -- 玩家id * @return * s -- OK,other failed * use -- 使用广告宣传队列,包括历史和当前正在使用 * starttime=>tag * 1234445=>122 * bag tag=>num,数组 */ public function get($params) { $uid = $params['u']; $tu = new TTUser($uid); $id = $tu->getoid('advert', TT::OTHER_GROUP); $advbag = $tu->getbyid($id); // $ret['advbag'] = $advbag; if (!$advbag['bag'] && !$advbag['use']) { $ret['s'] = 'notexsit'; return $ret; } $advbag['s'] = 'OK'; $advbag['id'] = $id; return $advbag; }