Exemplo n.º 1
0
 /**
  * 登录游戏
  *   
  * @param $params
  *    require   pid      -- platformid
  *    optional  anyfield  --头像等保存到 infos
  * @return 
  *    u      userid
  * 	  infos  map 玩家基本信息,头像
  *    a          玩家帐户信息,金币,宝石,经验
  *    accs   map 玩家相关数值信息
  *    t      server time
  */
 public function login($params)
 {
     $now = time();
     $params['at'] = $now;
     $data = TTGenid::genid($params, $new);
     $uid = $data['id'];
     $tu = new TTUser($uid);
     //if( 1 || $new ){
     if ($new) {
         //初始化用户信息
         $tu->initAccount();
     }
     $ret['infos'] = $data;
     $ret['u'] = $uid;
     $ret['a'] = $tu->getdata();
     $ret['s'] = 'OK';
     $cid = $tu->numch('_cid');
     $ret['cid'] = $cid;
     $data['_cid'] = $cid;
     TTGenid::save($data);
     $flashv = $params['fv'];
     if ($flashv) {
         $tu->putf('fv', $flashv);
     }
     $ret['t'] = time();
     $params['u'] = $uid;
     TTLog::record(array('m' => __METHOD__, 'tm' => $_SERVER['REQUEST_TIME'], 'intp1' => $new, 'u' => $uid, 'sp1' => $params['pid']));
     return $ret;
 }
Exemplo n.º 2
0
 public function genusers()
 {
     $ret = array();
     for ($i = 1; $i < 10; $i++) {
         $user['pid'] = "quest0{$i}";
         $user['name'] = "crab{$i}";
         $user['icon'] = "http://hdn.xnimg.cn/photos/hdn311/20090521/1025/tiny_9b7s_40842b204236.jpg";
         $ret[$i]['id'] = TTGenid::genid($user);
     }
     return $ret;
 }
Exemplo n.º 3
0
 /**
  * 邀请成为邻居
  * @param $params
  *  require  u           --  user id
  *           nid         --  neighbor id
  *       or   npid         --  neighbor平台id
  * @return 
  *           s           --  OK
  */
 public function invite_neighbor($params)
 {
     $uid = $params['u'];
     $nid = $params['nid'];
     if (!$nid) {
         $npid = $params['npid'];
         $datas = TTGenid::genid(array('pid' => $npid));
         $nid = $datas['id'];
     }
     $tu = new TTUser($uid);
     $ftu = new TTUser($nid);
     $mfdid = $ftu->getdid($uid, 'fr');
     $fdid = $tu->getdid($nid, 'fr');
     $fdata = $tu->getbyid($fdid);
     $mfdata = $ftu->getbyid($mfdid);
     if (!$fdata || !$mfdata) {
         //$ret['s']='nofriend';
         //return $ret;
         $fdata['id'] = $fdid;
         $mfdata['id'] = $mfdid;
     }
     $fdata['neighbor'] = 'invite';
     $mfdata['neighbor'] = 'invite';
     $ftu->puto($mfdata, 'fr', false);
     $tu->puto($fdata, 'fr', false);
     $ret['s'] = 'OK';
     return $ret;
 }
Exemplo n.º 4
0
 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')));
 }
Exemplo n.º 5
0
</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>
Exemplo n.º 6
0
}
$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);
Exemplo n.º 7
0
                 //加两箱的道具
                 $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 {