Пример #1
0
 protected function __construct()
 {
     parent::__construct();
     $app = $this;
     $app['mods'] = array('index' => ROOT . '/IndexServer.php');
     PL_Session::$randsid = true;
     $app->mshare('session', function () use($app) {
         return PL_Session::start();
     });
     $app->mshare('session.storage', function () use($app) {
         //return new PL_Session_Redis();
         return new PL_Session_File();
     });
 }
Пример #2
0
 function actionFpass()
 {
     if ($s = PL_Session::canStart()) {
         die('auth');
     }
     $now = $_SERVER['REQUEST_TIME'];
     if ($gtime = $s->getGtime() < $now - 5 * 36000) {
         die('链接已经过期,重新找回密码');
     }
     $lum = new model_LoginUser($s->getid());
     $d = $lum->get();
     if ($_POST['npass']) {
     }
     include $this->viewRoot . 'findpasspage.php';
 }
Пример #3
0
 function actionIndex()
 {
     $pid = $_REQUEST['pid'];
     if (!$pid) {
         $pid = $_COOKIE['pid'];
     }
     if (!$pid) {
         $pid = 'wplayers' . mt_rand(1, 100);
     }
     setcookie('pid', $pid);
     $um = model_LoginUser::genbypid($pid, $isnew);
     $u = $um->_id;
     $sess = PL_Session::start($u, 's1');
     $_SESSION['isNew'] = 1;
     $cid = $sess->getCid($u);
     $this->bodyView = $this->viewRoot . 'index.body.php';
     $this->tailerView = $this->viewRoot . 'index.tailer.php';
     include $this->viewRoot . 'layout.php';
 }
Пример #4
0
 /**  
  * actionPayment
  * @author 符璨
  * @param
  *          pid
  *          uid
  *          appid
  *          sec
  *          transaction_id:订单id
  *          cashier_id:支付单id
  *          cash:支付金额
  *          status:
  *          time:支付单生成时间戳
  *          product_id:购买产品编号
  *          product_cnt
  *          sig:签名
  * @return
  *      s 状态码
  *          100:玩家数据不存在
  *          108:签名验证错误
  *          11:product_id或其他原因引起的加载支付配置错误引发的异常
  *          ok:支付成功
  * @desc
  *      提供给cashier服务器调用的支付接口
  */
 public function actionPayment()
 {
     $now = getApp()->now;
     //取出所有参数
     $pid = $_POST['pid'];
     $uid = $_POST['uid'];
     $appid = $_POST['appid'];
     $transaction_id = $_POST['transaction_id'];
     $cashier = $_POST['cashier'];
     $cash = $_POST['cash'];
     $status = $_POST['status'];
     $create_t = $_POST['create_t'];
     $product_id = $_POST['product_id'];
     $product_cnt = $_POST['product_cnt'];
     $channel = $_POST['channel'];
     $channel_id = $_POST['channel_id'];
     $sec = $_POST['sec'];
     $isrepay = $_POST['isrepay'];
     //验证签名
     $data = array('pid' => $pid, 'uid' => $uid, 'appid' => $appid, 'channel' => $channel, 'channel_id' => $channel_id, 'sec' => $sec, 'transaction_id' => $transaction_id, 'cashier' => $cashier, 'cash' => $cash, 'status' => $status, 'create_t' => $create_t, 'product_id' => $product_id, 'product_cnt' => $product_cnt, 'isrepay' => $isrepay);
     ksort($data);
     $sig = md5(http_build_query($data) . '171ca1475ffcd016fca228cd716f14b7');
     if ($sig != $_POST['sig']) {
         echo json_encode(array('s' => StatusCode::invalid_siginature));
         return;
     }
     //加锁避免重复处理
     $redis = DbConfig::getRedis('rank');
     $lock_key = "payment_{$transaction_id}";
     $lock_res = $redis->SETNX($lock_key, $now);
     if ($lock_res) {
         //60秒过期
         $redis->SETEX($lock_key, 60, $now);
     } else {
         echo json_encode(array('s' => StatusCode::can_not_do));
         return;
     }
     //判断账单是否处理避免重复处理
     $mon = getApp()->getPaymentMongoConnection();
     $order = $mon->findOne(array('transaction_id' => $transaction_id));
     if ($order) {
         echo json_encode(array('s' => StatusCode::ok));
         return;
     }
     unset($data['time']);
     unset($data['uid']);
     //$data['cashier_t'] = $cashier_t;
     $data['process_t'] = $now;
     $data['_u'] = is_numeric($uid) ? intval($uid) : $uid;
     $data['action'] = 'recharge_gem';
     $data['_sec'] = $data['sec'];
     $data['_tm'] = $data['create_t'];
     $player = new model_Player($uid, $sec);
     $user_data = $player->getFields(array('level', 'vip.lvl', 'gem'));
     $data['_lvl'] = $user_data['level'];
     $data['_vip'] = $user_data['vip']['lvl'];
     $data['ogem'] = $user_data['gem'];
     $data['order_id'] = $transaction_id;
     if ($data['channel'] == "zongle") {
         //需求使用纵乐sdk发布cps包 by zhangjun
         $data['source'] = $data['channel'] . $data['channel_id'];
     } else {
         $data['source'] = $data['channel'];
     }
     //根据pid获取uid并生成用户session
     PL_Session::$usecookie = false;
     $_REQUEST['cid'] = PL_Session::gencid($uid, $sec);
     //uid非法
     if (!$uid || $uid < 0) {
         //玩家不存在
         glog::info("异常的支付数据[uid:{$uid}][section_id:{$sec}][transaction_id:{$transaction_id}][product_id:{$product_id}]", 'payment');
         echo json_encode(array('s' => StatusCode::exception));
         return;
     }
     try {
         $player = getApp()->getPlayer();
     } catch (Exception $e) {
         //玩家不存在
         glog::info("异常的支付数据[uid:{$uid}][section_id:{$sec}][transaction_id:{$transaction_id}][product_id:{$product_id}]", 'payment');
         echo json_encode(array('s' => StatusCode::exception, 'msg' => 'error1'));
         return;
     }
     $data['cash'] = $data['cash'] / 100;
     //cash通知单位是分
     if ($channel == 'wanpay_web') {
         $this->processWanpay($data);
     }
     $ret = $player->process_payment($data, true, $data['cash']);
     $redis->DEL($lock_key);
     echo json_encode($ret);
 }