function auth_playcrab($key) { static $use_auth = false; if (!$use_auth) { return true; } $now = $_SERVER['REQUEST_TIME']; if (!$key) { $pid = ''; //get by $sess = TTGenid::getbypid($pid); $kdata[] = $sess['pid']; $kdata[] = $sess['id']; $kdata[] = $now; return base64_encode(implode(':', $kdata)); } $keyd = base64_decode($key); $kdata = explode(':', $keyd, 3); if ($kdata[2] < 100) { return false; } if ($kdata[2] + 3600 > $now) { return $key; } $kdata[2] = $now; return base64_encode(implode(':', $kdata)); return md5($key . $secret) == $auth; }
/** * 查看礼物 * @param $params * require u -- user id * @return * s -- OK ,or other fail * d -- the man obj array(array('id',u,fid,gid,fname,fpic)) */ public function view($params) { $uid = $params['u']; $tu = new TTUser($uid); $gifts = $tu->get(TT::GIFT_GROUP); $ret = array(); foreach ($gifts as $index => $gift) { if ($gift['fid']) { $fdata = TTGenid::getbyid($gift['fid']); $gifts[$index]['name'] = $fdata['name']; $gifts[$index]['icon'] = $fdata['icon']; } } $ret['d'] = $gifts; $ret['s'] = 'OK'; return $ret; }
function get_friends($uid, $sess = null, $tu = null) { require_once WEB_ROOT . '../renren/renren.php'; require_once WEB_ROOT . '../renren/config.php'; if (!$sess) { $sess = TTGenid::getbyid($uid); } $pid = $sess['pid']; $sk = $sess['session_key']; $ren = new Renren(); $ren->api_key = RenrenConfig::$api_key; $ren->secret = RenrenConfig::$secret; $renren->session_key = $sk; $ren->init($sk); $ret = $ren->api_client->friends_getAppFriends(); if ($ret[0] > 1) { return implode(',', $ret); } return ''; }
/** * */ protected function auth($key) { return true; $now = $_SERVER['REQUEST_TIME']; if (!$key) { $pid = ''; //get by $sess = TTGenid::getbypid($pid); $kdata[] = $sess['pid']; $kdata[] = $sess['id']; $kdata[] = $now; return base64_encode(implode(':', $kdata)); } $keyd = base64_decode($key); $kdata = explode(':', $keyd, 3); if ($kdata[2] < 100) { return false; } if ($kdata[2] + 3600 > $now) { return $key; } $kdata[2] = $now; return base64_encode(implode(':', $kdata)); }
public function debug_get($params) { $now = time(); $uid = $params['u']; $tu = new TTUser($uid); $fids = $params['fids']; $infos = $tu->get('fr', false); if (!$fids) { $fids = $tu->getf(TT::FRIEND_STAT); if (!$fids) { $fids = "quest01,quest02,quest03,quest04,quest05,quest06,quest07,quest08,quest09"; } /* if($infos){ $ret['infos']=TTExtend::processlist($infos); $ret['s'] = 'OK'; return $ret; } */ } else { $tu->putf(TT::FRIEND_STAT, $fids); } $fl = explode(',', $fids); $rinfos = array(); $dup = array(); $now = time(); $dup['253382225'] = 1; //$fl[]='253382225'; $friend_count = 0; //记录好友个数 foreach ($fl as $pid) { if ($dup[$pid]) { continue; } $dup[$pid] = 1; $finfos = TTGenid::getbypid($pid); //by tingkun $id = $finfos['id']; if ($id) { $fdid = $tu->getdid($id, 'fr'); $fdata = json_decode($infos[$fdid], true); //if(!$fdata || $fdata['ut']<$now - 3600){ if (!$fdata || $fdata['ut'] < $now - 3600) { $ftu = new TTUser($finfos['id']); $acc = $ftu->getdata(); $acc['name'] = $finfos['name']; $acc['icon'] = $finfos['icon']; $acc['pid'] = $pid; $acc['ut'] = $now; $acc['id'] = $fdid; $acc['dbid'] = $id; $tu->puto($acc); $rinfos[] = $acc; } else { $rinfos[] = $fdata; } unset($infos[$fdid]); } else { $ret['notget'][] = $pid; } //$rids = array_keys($infos); //$tu->remove($rids); $friend_count++; } if ($friend_count > $tu->getf('friend_count')) { $tu->putf('friend_count', $friend_count); } //* $rinfos[] = array('name' => 'GM', 'icon' => 'http://hdn.xnimg.cn/photos/hdn121/20100807/1345/h_tiny_WtRB_190e0000358b2f75.jpg', 'pid' => '253382225', 'exp' => '10000', 'dbid' => 2, 'ht' => $now, 'help_car' => 1); //GM //*/ $ret['infos'] = $rinfos; $ret['fids'] = $fids; $ret['s'] = 'OK'; return $ret; }
static function testGenId() { echo "test genid\n"; $data['pid'] = 'uning'; print_r($data = TTGenid::genid($data)); $data['newdatapid'] = 'uning1'; print_r(TTGenid::update($data)); print_r(TTGenid::genid($data)); $data['newdatapid'] = 'uning1 update iii'; $data['i newdatapid'] = 'uning1 update iii'; print_r(TTGenid::update($data)); print_r(TTGenid::genid(array('pid' => 'uning'))); }
<?php $myloc = dirname(__FILE__); require_once '../base.php'; echo "<pre>\n"; $u = $argv[1]; if (!$u) { $u = $_REQUEST['u']; } if (!$u) { $pid = $argv[2]; if (!$pid) { $pid = $_REQUEST['pid']; } if ($pid) { $data = TTGenid::getbypid($pid); print_r($data); $u = $data['id']; } } $op = $argv[2]; if (!$op) { $op = $_REQUEST['op']; } $t = $argv[3]; if (!$t) { $t = $_REQUEST['t']; } $tm = $argv[4]; if (!$tm) { $t = $_REQUEST['tm'];
<?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;
<?php require_once 'config.php'; $data = array('uid' => 100, 'fid' => 12, 'gift_id' => 3); $pid = $_GET['fbid']; $session = TTGenid::getbypid($pid); $linkid = uniqid(); $tts = TT::TTweb(); $data['id'] = $linkid; $data['tm'] = time(); $tts->puto($data); print_r($tts->getbyid($linkid)); $giftid = $_GET['gid']; $fids = $_GET['fids']; $linkid = $_GET['linkid']; if ($fids) { $tts = TT::TTweb(); $data['id'] = $linkid; $data['tm'] = time(); $tts->puto($data); return; } if ($linkid) { } ?> <form > <input name='linkid' value='<?php echo uniqid(); ?> '/>
} $ar['pid'] = $pid; $ar['authat'] = time(); 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->users_getInfo(array($pid), array("uid", "name", "sex", "star", "zidou", "vip", "tinyurl", "birthday", "email_hash")); if ($ret[0]['name']) { $ar['icon'] = $ret[0]['headurl']; unset($ret[0]['headurl']); unset($ret[0]['tinyurl']); foreach ($ret[0] as $kk => $vv) { $ar[$kk] = $vv; } } $ar['session_key'] = $session_key; TTGenid::genid($ar); echo '<pre>'; print_r($ar); $ret = $ren->api_client->friends_getAppFriends(); if ($ret && $ret[0] && $ret[0] > 0) { $fidstr = implode(',', $ret); $tu->putf(TT::FRIEND_STAT, $fidstr); echo "friends OK\n"; } else { echo "failed\n"; } print_r($ret);
function getUserLevel() { $ses = TTGenid::getbypid($_REQUEST['pid']); $user = new TTUser($ses['id']); return $user->getLevel(); }
if (!$u) { $pid = $argv[2]; } if (!$u) { $pid = 1; } $tc = TT::get_tt('genid', 'slave'); $pid = $_REQUEST['pid']; if ($pid) { $sess = TTGenid::getbypid($pid); $u = $sess['id']; if (!$u) { die("not find pid {$pid}"); } } $t = TTGenid::getbyid($u); $pid = $t['pid']; $sk = $t['session_key']; if ($pid) { echo "{$pid}({$u})({$t['name']}):<br/> <a target='_blank' href='../../renren/static/flash/loader_demo.php?pid={$pid}'>play demo</a> | "; if (is_numeric($pid)) { echo "<a target='panel' href='../../renren/update_info.php?xn_sig_user={$pid}'>更新平台信息</a> | "; echo "<a target='panel' href='../../renren/update_friends.php?xn_sig_user={$pid}'>更新好友信息</a> | "; echo "<a target='panel' href='add_user_money.php?pid={$pid}'>加金币或宝石</a> | "; echo "<a target='panel' href='view_user_deals.php?u={$u}'>最近消费记录</a> | "; echo "<a target='_blank' href='http://msg.renren.com/SendMessage.do?id={$pid}'>发人人站内信</a> | "; } echo "<a target='panel' href='get_user.php?u={$u}'>查看数据</a> \n"; } ?> <hr/>
/** * 更新用户信息 * @param $params * require infos -- 用户数据 * option icon -- headicon * option name -- mall name * option gender -- * option session -- session key * @return * s -- OK */ public function update_info($params) { $infos = $params['infos']; $uid = $params['u']; TTGenid::update($infos, $uid); $ret['s'] = 'OK'; return $ret; }
<body bgcolor="#ffffff"> <div style="overflow: hidden;width:780px;height:<?php echo $height . 'px'; ?> ;border:#3399bb solid 1px;"> <table width="100%"> <tr> <td align="right"><a onclick="toFlash()" style="cursor: pointer;"><img src="../../static/images/css/close.png" border="0"/></a></td> </tr> </table> <table width="700px"> <?php require_once '../freeGift.php'; $gid = $_REQUEST["gift"]; $pid = $_REQUEST['pid']; $us = TTGenid::getbypid($pid); $exclude = "0"; $user = new TTUser($us['id']); $mode = 'all'; if (!$gid) { $mode = 'naf'; } //$key = date('Ymd').$pid; $tt = TT::LinkTT(); $feed = $tt->getbyuidx('uid', $pid); if ($feed) { $today = $feed['time']; $arr = '0'; if ($today == date('Ymd')) { foreach ($feed['invite'] as $k => $v) { $arr .= ',' . $k;
//加两箱的道具 $copilot['bag'][2004] += 2; //加6小时的道具 $str = '100000金币,5个宝石,2份加两箱的道具,2份加6小时的道具'; } else { $tu->chMoney(50000); $tu->chGem(3); $copilot['bag'][2002] += 1; //加两箱的道具 $str = '50000金币,3个宝石,1份加两箱的道具'; } } } $tu->puto($copilot); $sess['caward'] += 1; TTGenid::genid($sess); echo "<div style='font-size:16px;margin:20px;'>已经补偿给你<span style='font-weigth:bold;color:red;'>{$str}</span>请注意查收。<a href='" . RenrenConfig::$canvas_url . "'>返回游戏</a></div>"; } else { if ($sess['caward'] && $sess['caward'] == 2) { $tu = new TTUser($u); //$getids[]=$tu->getdid('caward'); $getids[] = $tu->getdid('exp'); $getids[] = $tu->getdid(''); $coid = $tu->getoid('copilot', TT::OTHER_GROUP); $getids[] = $coid; $datas = $tu->getbyids($getids); $level = $tu->getLevel($datas['exp']); $str = ""; if ($level > 30) { $str = '300000金币,15个宝石,4份加两箱的道具,6份加6小时的道具'; } else {
// $pid = $_REQUEST['xn_sig_user']; $session_key = $_REQUEST['xn_sig_session_key']; $gflg = $_REQUEST['glink']; $sess = TTGenid::getbypid($pid); $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);
echo "<pre>\n"; $u = $argv[1]; if (!$u) { $u = $_REQUEST['u']; } if (!$u) { $pid = $argv[2]; if (!$pid) { $pid = $_REQUEST['pid']; } if (!$pid) { die("no param"); } $data = TTGenid::getbypid($pid); } else { $data = TTGenid::getbyid($u); } $u = $data['id']; if (!$u) { die("no u get"); } 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;
</head> <body> <?php include "config.php"; echo "<pre>"; $pid = $_REQUEST['xn_sig_user']; //$pid ='253382225'; if (!$pid) { die('no pid'); } $ar['pid'] = $pid; $ar['authat'] = time(); require_once 'renren.php'; $ren = new Renren(); $ren->api_key = RenrenConfig::$api_key; $ren->secret = RenrenConfig::$secret; $ren->init(); $ret = $ren->api_client->users_getInfo(array($pid), array("uid", "name", "sex", "star", "zidou", "vip", "tinyurl", "birthday", "email_hash")); if ($ret[0]['name']) { $ar['icon'] = $ret[0]['headurl']; unset($ret[0]['headurl']); unset($ret[0]['tinyurl']); foreach ($ret[0] as $kk => $vv) { $ar[$kk] = $vv; } } print_r($ar); $sess = TTGenid::genid($ar); ?> </body></html>
echo "<a href='?start={$e}'>next</a> | "; } $last = $num - $page_num + 10; echo "<a href='?start={$last}'>last</a> "; echo "<hr/>\n"; $pid = $_REQUEST['pid']; if ($pid) { $sess = TTGenid::getbypid($pid); $u = $sess['id']; if (!$u) { die("not find pid {$pid}"); } $e = $u + 1; } for ($i = $u; $i < $e; ++$i) { $t = TTGenid::getbyid($i); $pid = $t['pid']; $sk = $t['session_key']; if ($pid) { echo "{$pid}({$i})({$t['name']}): <a target='_blank' href='../../renren/static/flash/loader_demo.php?pid={$pid}'>play demo</a> | "; if (is_numeric($pid)) { echo "<a target='_blank' href='user_panel.php?pid={$pid}'>User Panel</a> | "; echo "<a target='_blank' href='../../renren/update_info.php?xn_sig_user={$pid}'>get platform data</a> | "; echo "<a target='_blank' href='../../renren/update_friends.php?xn_sig_user={$pid}'>update friends</a> | "; echo "<a target='_blank' href='add_user_money.php?pid={$pid}'>add money</a> | "; echo "<a target='_blank' href='http://msg.renren.com/SendMessage.do?id={$pid}'>renren站内信</a> | "; } echo "<a target='_blank' href='get_user.php?u={$i}'>view data</a> \n"; } } if ($s >= 0) {
/** * 互相加为好友 */ public function add_friends($params) { $pids = $params['pids']; $ret['pids'] = $pids; $apids = explode(",", $pids); $length = count($apids); for ($i = 0; $i < $length; $i++) { $ui = TTGenid::getbypid($apids[$i]); $tu = new TTUser($ui['id']); $ret['bf'][$i] = $tu->getf(TT::FRIEND_STAT); $tu->putf(TT::FRIEND_STAT, $pids); $ret['af'][$i] = $tu->getf(TT::FRIEND_STAT); } /* $pids1 = $params['pids1']; $pids2 = $params['pids2']; $ret['pids1'] = $pids1; $ret['pids2'] = $pids2; $pid_array1 = explode(",",$pids1); $pid_array2 = explode(",",$pids2); $ret['array1'] = $pid_array1; $ret['array2'] = $pid_array2; foreach( $pid_array1 as $pid1 ){ $u1 = TTGenid::getbypid( $pid1 ); $tu1 = new TTUser( $u1['id'] ); } foreach( $pid_array2 as $pid2 ){ $u2 = TTGenid::getbypid( $pid2 ); $tu2 = new TTUser( $u2['id'] ); } $ret['bfids1'] = $tu1->getf( TT::FRIEND_STAT ); $ret['bfids2'] = $tu2->getf( TT::FRIEND_STAT ); // $tu1->putf( TT::FRIEND_STAT,$pid2 ); // $tu2->putf( TT::FRIEND_STAT,$pid1 ); $ret['afids1'] = $tu1->getf( TT::FRIEND_STAT ); $ret['afids2'] = $tu2->getf( TT::FRIEND_STAT ); */ return $ret; }
if (array_key_exists($touser, $ids)) { $invite = true; } if (array_key_exists($touser, $getted)) { $got = true; } } if ($invite && $new == 1 && !$gemd && !$ut && !$got) { $ftu->numch('invite_num', 1); $cid = $ftu->getoid('copilot', TT::OTHER_GROUP); $copilot = $ftu->getbyid($cid); $copilot['id'] = $cid; $copilot['bag'][2004] += 1; $ftu->puto($copilot); $tsess['gemd'] = 1; TTGenid::update($tsess, $tsess['id']); } if ($invite) { $gid = $link['gift']; if ($gid) { ?> <div id='content'> <div class='container'> <div class='canvas'> <div id="header"> <div id="navga"> <div class="logo"><a href="<?php echo RenrenConfig::$canvas_url; ?> " target="_top" title="开始游戏!">logo</a></div> <div id="tabs">
}); }else{ install_swf(pid); update_info(); <?php if (!$sess['notification0914']) { echo "send_notification0914();"; $sess['notification0914'] = 1; TTGenid::save($sess); } else { if ($sess['notification0914'] === 1) { echo "send_notification0914();"; $sess['notification0914'] = 2; TTGenid::save($sess); } } ?> } PF.set_page_ok(); }, before_fbinit:function(){//after FB.init callback }, cb:function(){//after config callback } }