Exemple #1
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';
 }
Exemple #2
0
 public function actionBuchangGem()
 {
     glog::info(json_encode($_REQUEST), 'addgem');
     glog::info(json_encode($_SERVER), 'addgem');
     $hour = date("H");
     if ($hour < 10 || $hour > 21) {
         // 10:00 ~ 21:59 才能使用这个接口,防止阿里云的云盾自动发起回调...
         // 有没有更好的处理方法...
         return $this->response(array('s' => 'ERROR', 'msg' => '操作时间不合法'));
     }
     $keys = array('section_id', 'product_id', 'platform', 'operator', 'optime');
     $params = array();
     foreach ($keys as $key) {
         ${$key} = trim(self::getParam($key));
         if (empty(${$key})) {
             $msg = "need param [{$key}]";
             glog::info($msg, 'addgem');
             return $this->response(array('s' => 'ERROR', 'msg' => $msg));
         }
         $params[$key] = ${$key};
     }
     $now = time();
     if ($now - $params['optime'] > 60 || $params['optime'] - $now > 60) {
         return $this->response(array('s' => 'ERROR', 'msg' => '操作已过期'));
     }
     $pid = self::getParam('pid');
     if ($pid) {
         $um = model_LoginUser::searchUniq('pid', $pid);
         if (!$um) {
             return $this->response(array('ErrorCode' => 0, 'ErrorDesc' => "用户[{$pid}]不存在"));
         }
         $uid = $um->id();
     } else {
         $uid = self::getParam('uid');
     }
     if (empty($uid)) {
         return $this->response(array('s' => 'ERROR', 'msg' => "需要UID参数"));
     }
     if ($params['platform'] != P_PLATFORM) {
         return $this->response(array('s' => StatusCode::error, 'msg' => "平台信息不匹配"));
     }
     if ($product_id == 'custom') {
         if (!in_array(P_PLATFORM, array('qqandroid', 'kunlun'))) {
             return $this->response(array('s' => StatusCode::error, 'msg' => P_PLATFORM . "平台不支持自定义额度支付"));
         }
         $params['cash'] = trim(self::getParam('cash'));
         if (!is_numeric($params['cash']) || $params['cash'] <= 0) {
             return $this->response(array('s' => StatusCode::error, 'msg' => "自定义额度{$params['cash']}不合法"));
         }
     } else {
         $payment_config = getApp()->getPaymentConifg();
         if (!isset($payment_config[$product_id])) {
             $msg = "product_id[{$product_id}] not exists";
             glog::info($msg, 'addgem');
             return $this->response(array('s' => 'ERROR', 'msg' => $msg));
         }
     }
     // 验证参数
     if (0 && !isset($_REQUEST['__no_sig__']) && !$this->verify_signature($params, 'qxs%Mt6v@nVdUb9d')) {
         return $this->response(array('s' => 'ERROR', 'msg' => "signature verification failed"));
     }
     PL_Session::$usecookie = false;
     $_REQUEST['cid'] = PL_Session::gencid($uid, $section_id);
     $player = getApp()->getPlayer();
     $mon = getApp()->getPaymentMongoConnection();
     $mongoid = new MongoID();
     $transaction_id = $mongoid->{'$id'};
     // 生成新的订单信息
     $payment_info = $player->createPaymentInfo($product_id);
     if ($product_id == 'custom') {
         $payment_info['cash'] = $params['cash'];
         if (P_PLATFORM == 'kunlun') {
             $payment_info['sumGem'] = $payment_info['cash'] * 15;
         }
     }
     $payment_info['transaction_id'] = $transaction_id;
     $payment_info['create_t'] = getApp()->now;
     $payment_info['source'] = 'buchang';
     $payment_info['msg'] = $params['operator'] . "给玩家补偿未到账的支付,";
     $old_vip = $payment_info['_vip'];
     $old_gem = $payment_info['ogem'];
     // 订单上次处理异常 或者 新的订单
     $ret = $player->process_payment($payment_info);
     if ($ret['s'] == StatusCode::ok) {
         $msg = "transaction [{$transaction_id}] processed";
         glog::info($msg, 'addgem');
         if (1) {
             $gem_add_and_reward = $ret['info']['gem_add_and_reward'];
             // 补发传书
             $msg = array('type' => 'system', 'key' => uniqid(), 'time' => getApp()->now, 'content' => "您未到账的{$gem_add_and_reward}元宝已经补发到账,祝您游戏愉快~");
             model_Chat::sendMsg($msg, $uid, 'origin', $section_id);
         } else {
             $gem_add_and_reward = $ret['info']['gem_add_and_reward'];
             $reward_gem = ceil($gem_add_and_reward * 0.1);
             // 补发传书
             $msg = array('type' => 'system', 'key' => uniqid(), 'time' => getApp()->now, 'content' => "您未到账的{$gem_add_and_reward}元宝已经补发到账,现在额外补偿您{$reward_gem}元宝,祝您游戏愉快~");
             $awards = array(array('tag' => 'gem', 'num' => $reward_gem));
             $msg['status'] = 'award';
             $cdkey = model_Cdkey::gen($awards, "{$reward_gem}元宝");
             $msg['cdkey'] = $cdkey;
             model_Chat::sendMsg($msg, $uid, 'origin', $section_id);
         }
         // 发邮件
         $login_model = new model_LoginUser($uid);
         $login_model->get(array('pid' => 1, 'email' => 1));
         $pid = $login_model['pid'];
         $email = $login_model['email'];
         $login_model->opOne('buchange_gem_t', getApp()->now);
         $login_model->save();
         $new_gem = $player->numberGet('base', 'gem');
         $new_vip = $player->numberGet('vip', 'lvl');
         $platform = P_PLATFORM;
         $name = $player->stringGet('base', 'name');
         $cash = $payment_config[$product_id]['cash'];
         $operator = $params['operator'];
         $subject = "[{$operator}]BuChangChongZhi[{$platform}][{$section_id}][{$uid}][{$cash} yuan]";
         $time = date("Y-m-d H:i:s");
         $content = "操作时间: {$time} \n";
         $content .= "操作人:{$operator}\n平台: {$platform}\nPID:{$pid}\nemail:{$email}\nUID:{$uid}\n分区:{$section_id}\n门派名:{$name}\n";
         $content .= "充值前:\nvip:{$old_vip}\ngem:{$old_gem}\n";
         $content .= "充值后:\nvip:{$new_vip}\ngem:{$new_gem}\n";
         model_Util::sendemail('*****@*****.**', $subject, $content);
         return $this->response(array('s' => 'OK', 'msg' => $msg, 'ret' => $ret));
     } else {
         $msg = "transaction[{$transaction_id}] failed," . $ret['msg'];
         glog::info($msg, 'addgem');
         return $this->response(array('s' => 'ERROR', 'msg' => $msg, 'ret' => $ret));
     }
 }
Exemple #3
0
 public function __construct()
 {
     $ser = $this;
     //读取请求之前,验证是否多点登录
     //在执行controller 逻辑之前判断
     self::rEvent('E_BCR', function () use($ser) {
         if ($_REQUEST['__noauth__'] == 1) {
             return;
         }
         $app = app();
         $sec = $app->getsec();
         $uid = $app->getuid();
         $um = new model_LoginUser($uid);
         $d = $um->get();
         if ($d['isban']) {
             exit(0);
         }
         //合服阻挡进入
         $filter_config = dzm_base::load_config('mergesec', 'prevent_enter');
         model_Util::preventEnter($filter_config, $sec, $uid);
         $cm = $app->vget('CM');
         $cc = $app->vget('CC');
         if ($app->vget('RESOVER')) {
             return;
         }
         $iccs = $app->vget('ICCS');
         $icms = $app->vget('ICMS');
         $skip_sig_check_method = $app->vget('skip_sig_check_method');
         $skip_sig_check_controller = $app->vget('skip_sig_check_controller');
         if (!isset($skip_sig_check_method[$cm]) && !isset($skip_sig_check_controller[$cc])) {
             // 验证数据签名
             $req =& $app->vget('REQARR');
             $ret = $ser->authSig($req);
             if ($ret) {
                 //glog::info(json_encode($ret),'sign');
                 //glog::info(json_encode($req),'sign');
                 $app->vset('RESARR', $ret);
                 $ser->finishResponse();
                 exit(0);
             }
         }
         //do nothing , 登陆,打点,都没有session
         if ($cc == 'System' || $cc == 'Statistic') {
             return;
         }
         if (isset($iccs[$cc]) || isset($icms[$cm])) {
             $app->vset('NOLOG', true);
             return;
         }
         $sess = $app['session'];
         if ($sess->isDupLogin()) {
             $app->vset('RESARR', array('s' => 'dup'));
             $ser->finishResponse();
             //
             exit(0);
         }
     });
     //退出之前,结果已经返回客户端
     self::rEvent('E_QUIT', function () {
         //记录日志,增加统计
         $app = app();
         $req =& $app->vget('REQARR');
         $res =& $app->vget('RESARR');
         $ss =& $app->vget('session');
         $uid = $app->getuid();
         $sec = $app->getsec();
         $ltime = $app->getltime();
         //本次登录时间
         $cm = $app->vget('CM');
         $s = $res['s'];
         $time = $_SERVER['REQUEST_TIME'];
         //全日志
         /* TODO 做个开关,只针对一小部分人开启全日志
         			$hour = date('Ymd',$time);
                     $request_end_time = microtime(true);
                     glog::detail($uid,$sec,$cm,$request_end_time-$app->request_start_time,$req,$res);
                     */
         if ($uid == 68321 || $uid == 5225) {
             $req['_SERVER'] = $_SERVER;
             glog::detail($uid, $sec, $cm, $request_end_time - $app->request_start_time, $req, $res);
         }
         //处理统计,
         //todo:实时统计的东西也放到这里来
         $stats =& $app->ref('STATS');
         if ($stats) {
             foreach ($stats as &$object) {
                 $object['_tm'] = $time;
                 $object['_sec'] = $sec;
                 $object['_u'] = $uid;
                 $object['_cm'] = $cm;
                 $object['_s'] = 'OK';
                 $object['_ver'] = P_VERSION;
                 $object['_lvl'] = $_SESSION['lvl'];
                 $object['_it'] = $_SESSION['init_time'];
                 $object['_vip'] = $_SESSION['vip'];
                 $object['istest'] = $_SESSION['istest'];
                 $object['_source'] = $_SESSION['source'];
                 try {
                     //                        model_OpLog::add($object);
                 } catch (Exception $ex) {
                     //error_log($ex->getMessage());
                     error_log("记录日志出错");
                     error_log(json_encode($object));
                 }
             }
             // scribe关闭连接
             try {
                 model_StatLog::close();
             } catch (Exception $ex) {
                 error_log("scribe日志关闭出错");
             }
             if ($s == 'OK') {
                 return;
             }
         }
         if (!$cm) {
             return;
         }
         //明确的设置了不记录log
         if ($app->vget('NOLOG')) {
             return;
         }
         if ($app->vget['DEBUG']) {
             error_log("session: " . print_r($_SESSION, true) . "\n", 3, LOG_ROOT . "/debug.log");
         }
         $logp =& $app->vget('LOGP');
         if (!$logp) {
             $logp =& $req['p'];
         }
         $logp['_cm'] = $cm;
         $logp['_u'] = $uid;
         $logp['_sec'] = $sec;
         $logp['_s'] = $s;
         $logp['_tm'] = $time;
         $logp['msg'] = $res['msg'];
         //			model_OpLog::add($logp);
     });
 }
Exemple #4
0
 public function action_check_vip()
 {
     echo date('Y-m-d H:i:s') . "统计充值\n";
     // 读取所有的充值信息,计算每个账号的真实充值
     $mon = getApp()->getPaymentMongoConnection();
     $rows = $mon->find(array('status' => StatusCode::payment_finished, 'action' => 'recharge_gem'), array(), array('_tm' => 1));
     $payments = array();
     $payments_check = array();
     foreach ($rows as $r) {
         $uid = $r['_u'];
         $section_id = $r['_sec'];
         $payments_check[$section_id][$uid] += $r['agem'];
     }
     echo date('Y-m-d H:i:s') . "统计充值完毕\n";
     $maxuid = model_LoginUser::maxuid();
     for ($uid = $maxuid; $uid >= 1; $uid--) {
         $login_model = new model_LoginUser($uid);
         $login_model->get(array('pid' => 1, 'istest' => 1, 'secs' => 1, 'isdev' => 1, 'isban' => 1));
         $d = $login_model->doc();
         $pid = $d['pid'];
         $istest = $d['istest'] == 1 ? 'test' : '';
         $isdev = $d['isdev'] == 1 ? 'dev' : '';
         $isban = $d['isban'] == 1 ? 'enable' : 'disabled';
         if (empty($d['secs'])) {
             $d['secs'] = array();
         }
         foreach ($d['secs'] as $section_id => $timestamp) {
             $player = new model_Player($uid, $section_id);
             $data = $player->getFields(array('vip', 'gem', 'total_gem_added', 'total_gem_rewarded', 'total_gem_rewarded2', 'total_gem_used'));
             $gemorder_agem = $payments_check[$section_id][$uid];
             if ($gemorder_agem > 0 || $data['total_gem_added'] > 0 || $data['vip']['lvl'] > 4) {
                 $gemorder_cash = $gemorder_agem / 10;
                 $db_cash = $data['total_gem_added'] / 10;
                 if ($db_cash != $gemorder_cash) {
                     echo "E,{$pid},{$uid},{$section_id},{$istest},{$isdev},        ";
                     echo "{$data['vip']['lvl']}, {$gemorder_cash} != {$db_cash}    {$isban}\n";
                 } else {
                     //echo "O,$uid,$section_id\n";
                 }
             } else {
                 //echo "O,$uid,$section_id\n";
             }
         }
         if ($uid % 1000 == 0) {
             echo date('Y-m-d H:i:s') . "\t current uid: {$uid}\n";
         }
     }
 }