コード例 #1
0
ファイル: WeChatCallBackJSZL.php プロジェクト: bsdcfp/wxmp
 public function process()
 {
     //只处理文本消息和自定义菜单消息
     if (!($this->_msgType != 'text' || $this->_msgType == 'event')) {
         interface_log(DEBUG, 0, "msgType:" . $this->_msgType);
         return $this->makeHint("你发的不是文字或菜单消息");
     }
     try {
         $STO = new SingleTableOperation("userinput", "ES");
         if ($this->_msgType == 'event' && $this->_event == 'CLICK') {
             $mode = $this->_eventKey;
             //更新用户mode
             $ret = $STO->getObject(array("userId" => $this->_fromUserName));
             if (!empty($ret)) {
                 $STO->updataObject(array('mode' => $mode), array("userId" => $this->_fromUserName));
             } else {
                 $STO->addObject(array("userId" => $this->_fromUserName, 'mode' => $mode));
             }
             return $this->makeHint("模式设置成:" . $mode);
         } else {
             $text = $this->_content;
             $ret = $STO->getObject(array("userId" => $this->_fromUserName));
             if (empty($ret)) {
                 $STO->addObject(array("userId" => $this->_fromUserName));
                 return $this->makeHint($text);
             } else {
                 $mode = $ret[0]['mode'];
                 $STO->updataObject(array('input' => $ret[0]['input']), array("userId" => $this->_fromUserName));
                 return $this->makeHint($text);
             }
         }
     } catch (DB_Exception $e) {
         interface_log(ERROR, EC_DB_OP_EXCEPTION, "query db error" . $e->getMessage());
     }
 }
コード例 #2
0
ファイル: logic.php プロジェクト: youngky2008/sp_cp
/**
 * 记录输入日志
 *
 * @param string $str_sp "BBK" "HS"
 * @param string $str_request_type "MO", "MR"
 * @param string $error_message
 */
function insert_log($dao, $query_string, $str_sp, &$optype, &$para, &$error_message)
{
    //$query_string = $_SERVER["QUERY_STRING"];
    init_log($str_sp);
    interface_log(INFO, 0, "request: " . $query_string);
    $query_url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'];
    $log_data = array('record_type' => 0, 'ip' => $_SERVER['REMOTE_ADDR'], 'url' => $query_url, 'content' => $query_string, 'create_time' => date('Y-m-d H:i:s'));
    $query_string = urldecode($query_string);
    parse_str($query_string, $para);
    //print "para:".var_export($para, true);
    if (isset($para['status']) || isset($para['statestr'])) {
        $log_data['op_type'] = 1;
        //MR
        $optype = 1;
        $str_sp .= "_MR";
    } else {
        $log_data['op_type'] = 0;
        //MO
        $optype = 0;
        $str_sp .= "_MO";
    }
    $ret = $dao->AddLog($log_data, $error_message);
    if ($ret != 0) {
        live_log(ERROR, $ret, $error_message);
        return EC_ACCESS_DB_ERROR;
    }
    //print "<p> str_sp: $str_sp.<p>";
    $bRet = CheckInput($str_sp, $para);
    if (!$bRet) {
        $error_message = "invalid input.";
        live_log(ERROR, EC_INVALID_INPUT, $error_message);
        return EC_INVALID_INPUT;
    }
    return EC_OK;
}
コード例 #3
0
ファイル: menuStub.php プロジェクト: bsdcfp/wxmp
 public static function reqMenu($interface, $data)
 {
     $token = tokenStub::getToken();
     //retry 3 times
     $retry = 3;
     while ($retry) {
         $retry--;
         if (false === $token) {
             interface_log(DEBUG, EC_OTHER, "get token error!");
             return false;
         }
         $url = WX_API_URL . "{$interface}?access_token=" . $token;
         interface_log(DEBUG, 0, "req url:" . $url . "  req data:" . json_encode($data));
         $ret = doCurlPostRequest($url, $data);
         interface_log(DEBUG, 0, "response:" . $ret);
         $retData = json_decode($ret, true);
         if (!$retData || $retData['errcode']) {
             interface_log(DEBUG, EC_OTHER, "req create menu error");
             if ($retData['errcode'] == 40014) {
                 $token = tokenStub::getToken(true);
             }
         } else {
             return $retData;
         }
     }
     return false;
 }
コード例 #4
0
ファイル: zinterface.php プロジェクト: bsdcfp/wxmp
function exitErrorInput()
{
    echo 'error input!';
    interface_log(INFO, EC_OK, "***** interface request end *****");
    interface_log(INFO, EC_OK, "*********************************");
    interface_log(INFO, EC_OK, "");
    exit(0);
}
コード例 #5
0
ファイル: jaray_submit.php プロジェクト: youngky2008/sp_cp
function handle_jaray_submit($dao, $query_string, $para, &$error_message)
{
    if ($para['event_type'] == "opt_in") {
        //订阅, 不转发给cp
        return EC_OK;
    }
    if ($para['event_type'] == "one_off") {
        //请求量非常大,但是无法正常处理,先保留
        return EC_OK;
    }
    $mr_data = array();
    $linkid = $para['transactionid'];
    $mr_data['mr_addr'] = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'];
    $mr_data['status'] = $para['status'];
    $mr_data['sp_code'] = intval($para['shortcode']);
    $mr_data['content'] = $para['momessage'];
    $mr_data['cmd'] = $para['momessage'];
    $mr_data['parter_symbol'] = INFOBIP;
    $mr_data['mo_time'] = date('Y-m-d H:i:s');
    $mr_data['mr_time'] = date('Y-m-d H:i:s');
    $mr_data['submit_flag'] = 1;
    //表示收到了MR请求
    $mr_data['mobile_num'] = $para['phone'];
    $mr_data['link_id'] = $linkid;
    if ($para['event_type'] == "opt_out") {
        //退订,直接转发
        $ret = TransmitAll($dao, $mr_data, $query_string, $error_message);
        if ($ret != 0) {
            live_log(ERROR, $ret, $error_message);
            interface_log(ERROR, $ret, "response: {$linkid}, err_msg: " . $error_message);
            return $ret;
        }
    }
    if ($para['event_type'] == "recurring_billing") {
        //包月计费,正常按照通道扣量
        $id = 0;
        $ret = write_original_data($dao, $mr_data, true, $id, $error_message);
        if ($ret != 0) {
            live_log(ERROR, $ret, $error_message);
            interface_log(ERROR, $ret, "response: {$linkid}, err_msg: " . $error_message);
            http_response_code(400);
            return $ret;
        }
        $ret = TransmitMo($dao, $id, $mr_data, true, $error_message);
        if ($ret != 0) {
            live_log(ERROR, $ret, $error_message);
            interface_log(ERROR, $ret, "response: {$linkid}, err_msg: " . $error_message);
            return $ret;
        }
    }
    return EC_OK;
}
コード例 #6
0
ファイル: WechatValid.php プロジェクト: hsiun/laputa
 public function valid()
 {
     if (false == $this->checkSignature()) {
         $ip = getIp();
         interface_log(ERROR, EC_OTHER, 'malicious: ' . $ip);
         exit(0);
     }
     $echoStr = $_GET["echostr"];
     if ($echoStr) {
         echo $echoStr;
         exit(0);
     }
 }
コード例 #7
0
ファイル: faceStub.php プロジェクト: bsdcfp/wxmp
 private static function requestToFace($interface, $data)
 {
     $data = array_merge($data, array('api_key' => API_KEY, 'api_secret' => API_SECRET));
     interface_log(DEBUG, 0, "url: " . FACE_URL . $interface . "\ndata:" . var_export($data, true));
     $json = doCurlGetRequest(FACE_URL . $interface, $data, FACE_TIMEOUT);
     interface_log(DEBUG, 0, 'response:' . $json);
     $data = json_decode($json, true);
     if (!$data || $data['error_code']) {
         return false;
     } else {
         return $data;
     }
 }
コード例 #8
0
ファイル: GetUserInfo.php プロジェクト: bsdcfp/wxmp
 public function process()
 {
     try {
         $this->_oTable->setTableName('cUser');
         $data = $this->_oTable->getObject($this->_args);
         $this->_data = $data;
     } catch (DB_Exception $e) {
         $errorNum = $this->_oTable->getErrorNum();
         $this->_retMsg = $this->_oTable->getErrorInfo() . $e->getMessage();
         $this->_retValue = genRetCode($errorNum);
         interface_log(ERROR, $this->_retValue, $this->_retMsg);
         return false;
     }
     return true;
 }
コード例 #9
0
ファイル: Ready.php プロジェクト: bsdcfp/wxmp
 public function process()
 {
     try {
         $this->_oTable->setTableName('cUser');
         $data = $this->_oTable->getObject(array('userId' => $this->_args['userId']));
         if (count($data) == 0) {
             $this->_retValue = EC_RECORD_NOT_EXIST;
             $this->_retMsg = "userId:" . $this->_args['userId'];
             interface_log(ERROR, $this->_retValue, $this->_retMsg);
             return false;
         }
         //检查用户是否有子弹
         if ($data[0]['bulletNum'] == 0) {
             $this->_retValue = EC_NOT_ENOUGH_BULLET;
             $this->_retMsg = "userId:" . $this->_args['userId'];
             interface_log(ERROR, $this->_retValue, $this->_retMsg);
             return false;
         }
         //检查用户是否已经在游戏中
         $this->_oTable->setTableName('cFight');
         $data = $this->_oTable->getObject(array('user1' => $this->_args['userId'], 'user2' => $this->_args['userId']), 1);
         if (count($data)) {
             $this->_retValue = EC_ALREADY_FIGHT;
             $this->_retMsg = "userId:" . $this->_args['userId'];
             interface_log(ERROR, $this->_retValue, $this->_retMsg);
             return false;
         }
         //检查用户是否已经在准备队列中
         $this->_oTable->setTableName('cWaitingUser');
         $data = $this->_oTable->getObject(array('userId' => $this->_args['userId']));
         if (empty($data)) {
             //把用户插入到准备队列
             $this->_oTable->addObject(array('userId' => $this->_args['userId']));
         }
         $this->_responseText = MYZL_HINT_READY_SUC;
     } catch (DB_Exception $e) {
         $errorNum = $this->_oTable->getErrorNum();
         $this->_retMsg = $this->_oTable->getErrorInfo() . $e->getMessage();
         $this->_retValue = genRetCode($errorNum);
         interface_log(ERROR, $this->_retValue, $this->_retMsg);
         return false;
     }
     return true;
 }
コード例 #10
0
ファイル: GlobalFunctions.php プロジェクト: youngky2008/sp_cp
function instance($interfaceName)
{
    $tmp = explode("_", $interfaceName);
    $dir = '';
    for ($i = 0; $i < count($tmp) - 1; $i++) {
        $dir = $dir . '/' . strtolower($tmp[$i]);
    }
    $file_name = dirname(__FILE__) . '/../interface/' . $dir . '/' . $interfaceName . '.php';
    if (file_exists($file_name)) {
        require_once $file_name;
        if (!class_exists($interfaceName)) {
            interface_log(ERROR, 0, "invalid interfaceName of {$interfaceName}");
            return null;
        } else {
            return new $interfaceName();
        }
    } else {
        interface_log(ERROR, 0, "invalid fileName of {$file_name}");
        return null;
    }
}
コード例 #11
0
ファイル: tokenStub.php プロジェクト: bsdcfp/wxmp
 public static function getToken($force = false)
 {
     try {
         $STO = new SingleTableOperation();
         $STO->setTableName("ctoken");
         if ($force == false) {
             $ret = $STO->getObject();
             interface_log(DEBUG, 0, "token data get from ctoken: " . json_encode($ret));
             if (count($ret) == 1) {
                 $token = $ret[0]['token'];
                 $expire = $ret[0]['expire'];
                 $addTimestamp = $ret[0]['addTimestamp'];
                 $current = time();
                 if ($addTimestamp + $expire + 30 < $current) {
                     return $token;
                 }
             }
         }
         $para = array("grant_type" => "client_credential", "appid" => WX_API_APPID, "secret" => WX_API_APPSECRET);
         $url = WX_API_URL . "token";
         interface_log(DEBUG, 0, "url:" . $url . "  req data:" . json_encode($para));
         $ret = doCurlGetRequest($url, $para);
         interface_log(DEBUG, 0, "response data:" . $ret);
         $retData = json_decode($ret, true);
         if (!$retData || $retData['errcode']) {
             interface_log(ERROR, EC_OTHER, "requst wx to get token error");
             return false;
         }
         //从返回数据中获取得到的access_token和它的过期时间,更新ctoken表
         $token = $retData['access_token'];
         $expire = $retData['expires_in'];
         $STO->delObject();
         $STO->addObject(array('token' => $token, "expire" => $expire, "addTimestamp" => time()));
         return $token;
     } catch (DB_Exception $e) {
         interface_log(ERROR, EC_DB_OP_EXCEPTION, "operate ctoken error! msg:" . $e->getMessage());
         return false;
     }
 }
コード例 #12
0
ファイル: AddUser.php プロジェクト: bsdcfp/wxmp
 public function process()
 {
     try {
         $oTableOperate = new SingleTableOperation('cUser', "MYZL");
         $data = $oTableOperate->getObject(array('userId' => $this->_args['userId']));
         if (count($data)) {
             $this->_retValue = EC_RECORD_EXIST;
             $this->_retMsg = "user already exist!";
             interface_log(ERROR, $this->_retValue, $this->_retMsg);
             return false;
         }
         //添加用户记录,设置相关的字段,这里可以根据自己的策略设置
         $oTableOperate->addObject(array('userId' => $this->_args['userId'], 'password' => $this->_args['password'], 'email' => $this->_args['email'], 'money' => 100, 'bulletNum' => 5, 'xsft' => 5, 'hdcx' => 5, 'chxs' => 5, 'sszm' => 5, 'addTimeStamp' => getCurrentTime()));
         $this->_responseText = MYZL_HINT_ADDUSER_SUC;
     } catch (DB_Exception $e) {
         $errorNum = $oTableOperate->getErrorNum();
         $this->_retMsg = $oTableOperate->getErrorInfo() . $e->getMessage();
         $this->_retValue = genRetCode($errorNum);
         interface_log(ERROR, $this->_retValue, $this->_retMsg);
         return false;
     }
     return true;
 }
コード例 #13
0
ファイル: UpdateUserInfo.php プロジェクト: bsdcfp/wxmp
 public function process()
 {
     try {
         $this->_oTable->setTableName('cUser');
         $userId = $this->_args['userId'];
         unset($this->_args['userId']);
         $data = $this->_oTable->getObject(array('userId' => $userId));
         if (count($data) != 1) {
             $this->_retValue = EC_RECORD_NOT_EXIST;
             $this->_retMsg = "user not exist or internel error!";
             interface_log(ERROR, $this->_retValue, $this->_retMsg);
             return false;
         }
         $this->_oTable->updateObject($this->_args, array('userId' => $userId));
     } catch (DB_Exception $e) {
         $errorNum = $this->_oTable->getErrorNum();
         $this->_retMsg = $this->_oTable->getErrorInfo() . $e->getMessage();
         $this->_retValue = genRetCode($errorNum);
         interface_log(ERROR, $this->_retValue, $this->_retMsg);
         return false;
     }
     return true;
 }
コード例 #14
0
ファイル: GetOpponent.php プロジェクト: bsdcfp/wxmp
 public function process()
 {
     try {
         $this->_oTable->setTableName('cUser');
         $data = $this->_oTable->getObject(array('userId' => $this->_args['userId']));
         if (count($data) == 0) {
             $this->_retValue = EC_RECORD_NOT_EXIST;
             $this->_retMsg = "userId:" . $this->_args['userId'];
             interface_log(ERROR, $this->_retValue, $this->_retMsg);
             return false;
         }
         $this->_oTable->setTableName('cFight');
         $data = $this->_oTable->getObject(array('user1' => $this->_args['userId'], 'user2' => $this->_args['userId']), 1);
         if (count($data) > 1) {
             $this->_retValue = EC_MULTIPLE_FIGHT;
             $this->_retMsg = "userId:" . $this->_args['userId'];
             interface_log(ERROR, $this->_retValue, $this->_retMsg);
             return false;
         } else {
             if (empty($data)) {
                 $this->_data = array();
                 return true;
             } else {
                 //match sucess
                 $this->_data = $data[0];
                 return true;
             }
         }
     } catch (DB_Exception $e) {
         $errorNum = $this->_oTable->getErrorNum();
         $this->_retMsg = $this->_oTable->getErrorInfo() . $e->getMessage();
         $this->_retValue = genRetCode($errorNum);
         interface_log(ERROR, $this->_retValue, $this->_retMsg);
         return false;
     }
     return true;
 }
コード例 #15
0
ファイル: infobip_mo.php プロジェクト: youngky2008/sp_cp
$mo_data = array();
$mo_data['mobile_num'] = $para['phone'];
$mo_data['content'] = $para['message'];
$mo_data['link_id'] = $para['transactionid'];
$mo_data['parter_symbol'] = INFOBIP;
$mo_data['mo_addr'] = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'];
$mo_data['submit_flag'] = 0;
$mo_data['sp_code'] = intval($para['shortcode']);
$mo_data['mo_time'] = date('Y-m-d H:i:s');
$mo_data['transmit_flag'] = Dao::TRANSMIT_FLAG_INITAL;
$linkid = $mo_data['link_id'];
$id = 0;
$ret = write_original_data($dao, $mo_data, true, $id, $error_message);
if ($ret != 0) {
    live_log(ERROR, $ret, $error_message);
    interface_log(ERROR, $ret, "response: {$linkid}, err_msg: " . $error_message);
    http_response_code(400);
    echo 202;
    return;
}
$ret = TransmitMo($dao, $id, $mo_data, false, $error_message);
if ($ret != 0) {
    live_log(ERROR, $ret, $error_message);
    interface_log(ERROR, $ret, "response: {$linkid}, err_msg: " . $error_message);
    echo 202;
    return;
}
echo 200;
live_log(INFO, EC_OK, "linkid: {$linkid}, infobip mo success.");
interface_log(INFO, EC_OK, "linkid: {$linkid}, infobip mo success.");
return;
コード例 #16
0
ファイル: ChipIn.php プロジェクト: bsdcfp/wxmp
 public function process()
 {
     try {
         DbFactory::getInstance('MYZL')->autoCommit();
         //先获取游戏数据中的msgForOther,如果otherId是当前用户,把msgForOther添加到用户提示文本_responseText中
         $msgForOther = $this->_fightInfo['msgForOther'];
         $otherId = $this->_fightInfo['otherId'];
         if ($otherId == $this->_fromUserName) {
             $this->_responseText .= $msgForOther;
             $this->_fightInfo['msgForOther'] = "";
         }
         //设置msgForOhter和otherId
         $this->_fightInfo['otherId'] = $this->_fromUserName == $this->_fightInfo['user1'] ? $this->_fightInfo['user2'] : $this->_fightInfo['user1'];
         if ($this->_fightInfo['msgForOther'] == "") {
             $this->_fightInfo['msgForOther'] = "对方已加注" . $this->_operand . "金币";
         } else {
             $this->_fightInfo['msgForOther'] .= ", 对方已加注" . $this->_operand . "金币";
         }
         //用户金币不足的情况
         if ($this->_userInfo['money'] < $this->_args['money']) {
             $this->_retValue = EC_NOT_ENOUGH_MONEY;
             interface_log(ERROR, $this->_retValue);
             return false;
         }
         //用户减金币,游戏加金币
         $this->_oTable->setTableName('cUser');
         $newMoney = $this->_userInfo['money'] - $this->_args['money'];
         $this->_oTable->updateObject(array('money' => $newMoney), array('userId' => $this->_args['userId']));
         $this->_fightInfo['money'] += $this->_args['money'];
         //设置下一个动作的操作码和操作人
         $ret = $this->setNextOpAndUser();
         if ($ret['code']) {
             $this->_retValue = EC_STEP_ERROR;
             $this->_retMsg = "fightId:" . $this->_fightId . " step:" . $this->_fightInfo['historyOp'];
             interface_log(ERROR, $this->_retValue, $this->_retMsg);
             return false;
         }
         //设置历史操作记录
         if ($this->_fightInfo['historyOp'] == '') {
             $newHistoyOp = "CHIP_IN," . $this->_args['userId'];
         } else {
             $newHistoyOp = $this->_fightInfo['historyOp'] . "|CHIP_IN," . $this->_args['userId'];
         }
         $this->_fightInfo['historyOp'] = $newHistoyOp;
         //更新下注金额的下限
         if ($this->_args['money'] > $this->_fightInfo['minMoney']) {
             $this->_fightInfo['minMoney'] = $this->_args['money'];
         }
         //更新游戏数据
         $this->_oTable->setTableName('cFight');
         $this->_oTable->updateObject($this->_fightInfo, array('fightId' => $this->_fightId));
         DbFactory::getInstance('MYZL')->tryCommit();
         //设置用户提示文本
         if ($this->_responseText) {
             $this->_responseText .= ', ' . sprintf(MYZL_HINT_CHIPIN_SUC, $this->_operand, $GLOBALS['constants']['stepName'][$this->_fightInfo['operation']]);
         } else {
             $this->_responseText = sprintf(MYZL_HINT_CHIPIN_SUC, $this->_operand, $GLOBALS['constants']['stepName'][$this->_fightInfo['operation']]);
         }
     } catch (DB_Exception $e) {
         DbFactory::getInstance('MYZL')->rollback();
         $errorNum = $this->_oTable->getErrorNum();
         $this->_retMsg = $this->_oTable->getErrorInfo() . $e->getMessage();
         $this->_retValue = genRetCode($errorNum);
         interface_log(ERROR, $this->_retValue, $this->_retMsg);
         return false;
     }
     return true;
 }
コード例 #17
0
ファイル: WeChatCallBackMYZL.php プロジェクト: bsdcfp/wxmp
 public function process()
 {
     if ($this->_msgType != 'event') {
         //在消息类型不为event的时候,直接给到用户提示信息
         return $this->makeHint(MYZL_HINT);
     }
     $retStr = "";
     $this->getOperandAndOperator();
     interface_log(DEBUG, 0, "interfaceName:" . $this->interfaceName . "  value:" . $this->value);
     //根据getOperanAndOperator中设置的interfaceName进行对应操作,并设置相应的返回信息
     if ($this->interfaceName == "WelcomeBack") {
         $retStr = "WelcomeBack";
     }
     if ($this->interfaceName == "WaitOp") {
         $retStr = "等待系统匹配玩家";
     }
     if ($this->interfaceName == "PutMagicHint") {
         $retStr = "请使用道具";
     }
     if ($this->interfaceName == "ChipInHint") {
         $retStr = "请下注";
     }
     if ($this->interfaceName == "MultiFightHint") {
         $retStr = "错误的游戏状态";
     }
     if ($this->interfaceName == "InputErrorHint") {
         $retStr = "输入错误";
     }
     if ($this->interfaceName == "DbErrorHint") {
         $retStr = "数据库连接错误";
     }
     if ($this->interfaceName == "SecondEndHint") {
         if ($this->_fromUserName == $this->fightInfo['current']) {
             $retStr = "等待对方结束游戏";
         } else {
             $retStr = " ";
             //不能为空字符换
         }
     }
     if ($this->interfaceName == "WaitOperation") {
         $retStr = "等待对方【" . $GLOBALS['constants']['stepName'][$this->value] . "】,请稍后重试";
     }
     if ($this->interfaceName == "WaitStart") {
         $retStr = "等待对方开始游戏!";
     }
     if ($retStr) {
         //上述情况可以直接根据GetOp返回的responseText给到用户提示
         return $this->makeHint($this->retStr ? $this->retStr . ($retStr == " " ? "" : ", ") . $retStr : $retStr);
     }
     //对需要进行逻辑处理的情况包含相应的文件,并new相应的对象
     if ($this->interfaceName == "Ready") {
         require_once dirname(__FILE__) . '/../interface/Ready.php';
         $obj = new Ready();
     }
     if ($this->interfaceName == "Start") {
         require_once dirname(__FILE__) . '/../interface/Start.php';
         $obj = new Start();
     }
     if ($this->interfaceName == "AddUser") {
         require_once dirname(__FILE__) . '/../interface/AddUser.php';
         $obj = new AddUser();
     }
     if ($this->interfaceName == "PutMagic") {
         require_once dirname(__FILE__) . '/../interface/PutMagic.php';
         $obj = new PutMagic();
         $obj->setOperand($this->value);
     }
     if ($this->interfaceName == "Shoot") {
         require_once dirname(__FILE__) . '/../interface/Shoot.php';
         $obj = new Shoot();
     }
     if ($this->interfaceName == "ChipIn") {
         require_once dirname(__FILE__) . '/../interface/ChipIn.php';
         $obj = new ChipIn();
         $obj->setOperand($this->value);
         interface_log(DEBUG, 0, 'this->value:' . $this->value . ' _operand:' . $obj->getOperand());
     }
     //执行new出来的对象的相应函数
     $ret = $obj->verifyCommonInput($this->_postObject);
     if (false == $ret) {
         $rt = $obj->renderOutput();
         return $this->makeHint($rt['retStr']);
     }
     $ret = $obj->initialize();
     if (false == $ret) {
         $rt = $obj->renderOutput();
         return $this->makeHint($rt['retStr']);
     }
     $ret = $obj->prepareData();
     if (false == $ret) {
         $rt = $obj->renderOutput();
         return $this->makeHint($rt['retStr']);
     }
     $ret = $obj->process();
     if (false == $ret) {
         $rt = $obj->renderOutput();
         interface_log(DEBUG, 0, var_export($rt, true));
         return $this->makeHint($rt['retStr']);
     }
     //获取对象中设置好的返回信息,并封装文本返回给用户
     return $this->makeHint($obj->getResponseText());
 }
コード例 #18
0
ファイル: xy_mo.php プロジェクト: youngky2008/sp_cp
$mo_data['mobile_num'] = $para['mobile'];
$mo_data['content'] = $para['content'];
$mo_data['link_id'] = $para['linkid'];
$mo_data['parter_symbol'] = XY;
$mo_data['mo_addr'] = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'];
$mo_data['submit_flag'] = 0;
$mo_data['mo_submit_date'] = $para['createDate'];
$mo_data['sp_code'] = intval($para['spcode']);
$mo_data['mo_time'] = date('Y-m-d H:i:s');
$mo_data['transmit_flag'] = Dao::TRANSMIT_FLAG_INITAL;
$linkid = $mo_data['link_id'];
$id = 0;
$ret = write_original_data($dao, $mo_data, true, $id, $error_message);
if ($ret != 0) {
    live_log(ERROR, $ret, $error_message);
    interface_log(ERROR, $ret, "response: {$linkid}, err_msg: " . $error_message);
    http_response_code(400);
    echo 202;
    return;
}
$ret = TransmitMo($dao, $id, $mo_data, false, $error_message);
if ($ret != 0) {
    live_log(ERROR, $ret, $error_message);
    interface_log(ERROR, $ret, "response: {$linkid}, err_msg: " . $error_message);
    echo 202;
    return;
}
echo 200;
live_log(INFO, EC_OK, "linkid: {$linkid}, hs mo success.");
interface_log(INFO, EC_OK, "linkid: {$linkid}, hs mo success.");
return;
コード例 #19
0
 private function _getNextUrl()
 {
     try {
         $ret = $this->_oTable->getObject(array('userName' => $this->_fromUserName));
         if (empty($ret)) {
             //插入
             $this->_oTable->addObject(array('userName' => $this->_fromUserName));
             $index = 1;
         } else {
             $index = $ret[0]['cur'];
         }
         $this->_index = $index;
         $ret = $this->_getPicUrlByIndex($index);
         if ($ret['code'] == 0) {
             $this->_oTable->updateObject(array('cur' => $index + 1), array('userName' => $this->_fromUserName));
             return array('data' => $ret['data'], 'code' => 0);
         } else {
             return $ret;
         }
     } catch (Exception $e) {
         interface_log(ERROR, EC_DB_OP_EXCEPTION, $e->getMessage());
         return array('data' => MR_HINT_INNER_ERROR, 'code' => 1);
     }
 }
コード例 #20
0
ファイル: AbstractInterface.php プロジェクト: bsdcfp/wxmp
 public function renderOutput()
 {
     $ret = array("timestamp" => time(), "retVal" => $this->_retValue, "retMsg" => genErrMsg($this->_retValue, $this->_retMsg), "retStr" => genRetStr($this->_retValue), "retData" => $this->_data);
     interface_log(DEBUG, 0, "ret:" . json_encode($ret));
     return $ret;
 }
コード例 #21
0
ファイル: Start.php プロジェクト: bsdcfp/wxmp
 public function process()
 {
     try {
         //获取msgForOther并设置用户提示文本
         $msgForOther = $this->_fightInfo['msgForOther'];
         $otherId = $this->_fightInfo['otherId'];
         if ($otherId == $this->_fromUserName) {
             $this->_responseText .= $msgForOther;
         }
         //设置用户提示文本
         $this->_fightInfo['otherId'] = $this->_fromUserName == $this->_fightInfo['user1'] ? $this->_fightInfo['user2'] : $this->_fightInfo['user1'];
         //$this->_fightInfo['lastOp'] = $this->_fromUserName . ',' . START . ',';
         if ($this->_fightInfo['operation'] == START) {
             $this->_fightInfo['gameNumber'] = 1;
             $this->_fightInfo['msgForOther'] = "对方开始上半局游戏";
         } else {
             $this->_fightInfo['gameNumber'] = 2;
             $this->_fightInfo['msgForOther'] = "对方开始下半局游戏";
         }
         //设置游戏数据
         $this->_fightInfo['current'] = $this->_fightInfo['first'];
         $this->_fightInfo['operator'] = $this->_fightInfo['first'];
         $this->_fightInfo['operation'] = CHIP_IN;
         //随机设置子弹在左轮中的位置
         $this->_fightInfo['count'] = rand(1, 6);
         $magicList1 = explode(',', $this->_fightInfo['magicUsed1']);
         $magicList2 = explode(',', $this->_fightInfo['magicUsed2']);
         if ($magicList1[count($magicList1) - 1] == CHXS || $magicList2[count($magicList2) - 1] == CHXS) {
         } else {
             //除非是用户使用CHXS导致的重新开始,否则重置游戏的money值为0
             $this->_fightInfo['money'] = 0;
         }
         //更新游戏数据
         unset($this->_fightInfo['fightId']);
         $this->_oTable->setTableName('cFight');
         $this->_oTable->updateObject($this->_fightInfo, array('fightId' => $this->_fightId));
         $this->_data = $this->_fightInfo;
         //设置用户提示文本
         $this->_responseText = sprintf(MYZL_HINT_START_SUC . ",", $this->_fightInfo['gameNumber'] == 1 ? "上" : "下");
         if ($this->_fromUserName == $this->_fightInfo['operator']) {
             $this->_responseText .= "请你下注";
         } else {
             $this->_responseText .= "等待对方下注";
         }
     } catch (DB_Exception $e) {
         $errorNum = $this->_oTable->getErrorNum();
         $this->_retMsg = $this->_oTable->getErrorInfo() . $e->getMessage();
         $this->_retValue = genRetCode($errorNum);
         interface_log(ERROR, $this->_retValue, $this->_retMsg);
         return false;
     }
     return true;
 }
コード例 #22
0
ファイル: GetOp.php プロジェクト: bsdcfp/wxmp
 public function process()
 {
     try {
         $this->_oTable->setTableName('cUser');
         $data = $this->_oTable->getObject(array('userId' => $this->_args['userId']));
         if (count($data) == 0) {
             $this->_retValue = EC_USER_NOT_EXIST;
             $this->_retMsg = "userId:" . $this->_args['userId'];
             interface_log(ERROR, $this->_retValue, $this->_retMsg);
             return false;
         }
         $this->_args['userId'] = DbFactory::getInstance('MYZL')->escape($this->_args['userId']);
         //分别获取cFight和cFightUncheck中的记录
         $this->_oTable->setTableName('cFight');
         $data = $this->_oTable->getObject(array("_where" => " (user1='" . $this->_args['userId'] . "' OR user2='" . $this->_args['userId'] . "')"));
         $this->_oTable->setTableName('cFightUncheck');
         $data1 = $this->_oTable->getObject(array("_where" => "operation='SECOND_END' AND (user1='" . $this->_args['userId'] . "' OR user2='" . $this->_args['userId'] . "')"));
         if (empty($data) && !empty($data1)) {
             //有一方尚未查看游戏结果的情况
             $data = $data1;
             //delete fight info in uncheck table
             $fightId = $data[0]['fightId'];
             if ($data[0]['current'] != $this->_args['userId']) {
                 //当前用户非最后一下开枪的用户,清理游戏数据
                 $this->_oTable->setTableName('cFightEnd');
                 $this->_oTable->addObject($data[0]);
                 $this->_oTable->setTableName('cFightUncheck');
                 $this->_oTable->delObject(array('fightId' => $fightId));
             }
         }
         if (empty($data) && empty($data1)) {
             $this->_retValue = EC_FIGHT_NOT_EXIST;
             $this->_retMsg = "fightId:" . $this->_args['fightId'] . " userId:" . $this->_args['userId'];
             interface_log(ERROR, $this->_retValue, $this->_retMsg);
             return false;
         } else {
             if (count($data) > 1) {
                 $this->_retValue = EC_MULTIPLE_FIGHT;
                 $this->_retMsg = "userId:" . $this->_args['userId'];
                 interface_log(ERROR, $this->_retValue, $this->_retMsg);
                 return false;
             } else {
                 $this->_fightInfo = $data[0];
                 $msgForOther = $this->_fightInfo['msgForOther'];
                 $otherId = $this->_fightInfo['otherId'];
                 if ($otherId == $this->_args['userId']) {
                     //设置用户提示文本,并把msgForOther更新为空,以免给用户重复的提示
                     $this->_responseText .= $msgForOther;
                     $this->_oTable->setTableName('cFight');
                     $this->_oTable->updateObject(array('msgForOther' => ""), array("fightId" => $this->_fightInfo['fightId']));
                 }
                 interface_log(DEBUG, 0, "reponseText:" . $this->_responseText);
                 $this->_data = $this->_fightInfo;
                 return true;
             }
         }
         $this->_data = array();
     } catch (DB_Exception $e) {
         $errorNum = $this->_oTable->getErrorNum();
         $this->_retMsg = $this->_oTable->getErrorInfo() . $e->getMessage();
         $this->_retValue = genRetCode($errorNum);
         interface_log(ERROR, $this->_retValue, $this->_retMsg);
         return false;
     }
     return true;
 }
コード例 #23
0
ファイル: menu.php プロジェクト: bsdcfp/wxmp
				),
				array(
					'type' => 'click',
					'name' => '重获新生',
					'key' => 'PUTMAGIC_CHXS'
				),
				array(
					'type' => 'click',
					'name' => '壶底抽薪',
					'key' => 'PUTMAGIC_HDCX'
				),
				array(
					'type' => 'click',
					'name' => '邪神附体',
					'key' => 'PUTMAGIC_XSFT'
				),
			)
		),
	)
);
*****/
$ret = menuStub::create('ABC', $menuData);
if (false === $ret) {
    interface_log(DEBUG, 0, "create menu fail!");
    echo "create menu fail!\n";
} else {
    interface_log(DEBUG, 0, "creat menu success");
    echo "create menu success!\n";
}
interface_log(DEBUG, 0, "***end menu***");
コード例 #24
0
ファイル: MysqliDb.php プロジェクト: hsiun/laputa
 /**
  * 执行一个sql更新
  **/
 public function update($sql)
 {
     interface_log(INFO, EC_OK, "SQL[{$sql}]");
     if (!$this->_conn || $this->ping($this->_conn)) {
         if ($this->_autoCommitTime) {
             throw new Exception('auto commit time is not zero when reconnect to db');
         } else {
             $this->connect();
         }
     }
     $startTime = getMillisecond();
     $urs = mysqli_query($this->_conn, $sql);
     if (!$urs) {
         throw new Exception('跟新失败:' . mysqli_error($this->_conn));
     } else {
         interface_log(INFO, EC_OK, "excute time:" . getMillisecond($startTime) . "(ms) SQL[{$sql}]");
         return $urs;
     }
 }
コード例 #25
0
 public function process()
 {
     //return $this->makeHint("系统正在升级!请稍候使用");
     try {
         if ($this->_msgType != 'image') {
             $contentStr = FF_HINT_TYPE_ERROR;
             if ($this->_msgType == 'text') {
                 $contents = (string) trim($this->_postObject->Content);
                 if ($contents == 'Hello2BizUser') {
                     $contentStr = FF_HINT_HELLO;
                 }
             }
             if ($this->_msgType == 'event') {
                 $event = (string) trim($this->_postObject->Event);
                 if ($event == 'subscribe') {
                     $contentStr = FF_HINT_HELLO;
                 }
             }
             return $this->makeHint($contentStr);
         }
         $this->_url = trim($this->_postObject->PicUrl);
         //下载图片到本地
         $fileName = $this->downloadPic();
         $this->_url = FF_URL_HEADER . $fileName;
         // 1.检验是否有脸
         $ret = faceStub::detect($this->_url);
         if ($ret === false) {
             return $this->makeHint(FF_HINT_FACE_ERROR);
         }
         if (count($ret['face']) == 0) {
             return $this->makeHint(FF_HINT_NO_FACE);
         }
         if (count($ret['face']) > 1) {
             return $this->makeHint(FF_HINT_MULTIPLE_FACE);
         }
         $faceId = $ret['face'][0]['face_id'];
         $oTable = new SingleTableOperation();
         // 插入face到cFace
         $oTable->setTableName('cface');
         $oTable->addObject(array('faceId' => $faceId, 'personName' => $this->_fromUserName, 'url' => $ret['url']));
         // 2.找到最像的脸
         $ret = faceStub::search($faceId, GROUP_NAME, 2);
         if ($ret === false) {
             return $this->makeHint(FF_HINT_FACE_ERROR);
         }
         $candidates = $ret['candidate'];
         if (count($candidates) == 0) {
             return $this->makeHint(FF_HINT_FACE_NO_CANDIDATE);
         }
         // 查找查询用户,看是否已上传过face
         $oTable->setTableName('cperson');
         $ret = $oTable->getObject(array('personName' => $this->_fromUserName));
         if (count($ret)) {
             $userFaceIds = array();
             foreach ($ret as $item) {
                 $userFaceIds[] = $item['faceId'];
             }
             $newCandidate = array();
             // 从结果集中删除掉用户自己
             foreach ($candidates as $item) {
                 if (!in_array($item['face_id'], $userFaceIds)) {
                     $newCandidate[] = $item;
                 }
             }
             $candidates = $newCandidate;
             // 更新用户的faceId
             $oTable->updateObject(array('faceId' => $faceId), array('personName' => $this->_fromUserName));
             // 更新faceplusplus的person:先删除person的face,再加入该faceId
             $result = faceStub::removeFaceFromPerson($this->_fromUserName, 'all');
             if ($result === false) {
                 return $this->makeHint(FF_HINT_FACE_ERROR);
             }
             $result = faceStub::addFaceToPerson($this->_fromUserName, $faceId);
             if ($result === false) {
                 return $this->makeHint(FF_HINT_FACE_ERROR);
             }
         } else {
             // 插入记录到cPerson
             $oTable->addObject(array('personName' => $this->_fromUserName, 'faceId' => $faceId));
             // 请求faceplusplus创建person和,并加到group中
             $result = faceStub::createPerson($this->_fromUserName, $faceId, GROUP_NAME);
             if ($result === false) {
                 return $this->makeHint(FF_HINT_FACE_ERROR);
             }
         }
         if (count($candidates) == 0) {
             return $this->makeHint(FF_HINT_FACE_NO_CANDIDATE);
         }
         // 从数据库中查询face的url
         $oTable->setTableName('cface');
         $ret = $oTable->getObject(array('faceId' => $candidates[0]['face_id']));
         if (count($ret) == 0) {
             return $this->makeHint(FF_HINT_FACE_NO_CANDIDATE);
         }
         $url = $ret[0]['url'];
         $resultStr = sprintf(SUCC_TPL_FINDFACE, $this->_fromUserName, $this->_toUserName, $this->_time, $url, $url);
         $oTable->setTableName('cstatus');
         $ret = $oTable->getObject(array('key' => 'lastTrain'));
         $lastTrain = $ret[0]['value'];
         date_default_timezone_set(PRC);
         $now = date('YmdG');
         if ($now != $lastTrain) {
             faceStub::train(GROUP_NAME, 'search');
             $oTable->updateObject(array('value' => $now), array('key' => 'lastTrain'));
         }
         return $resultStr;
     } catch (Exception $e) {
         interface_log(ERROR, EC_DB_OP_EXCEPTION, $e->getMessage());
         return $this->makeHint(FF_HINT_INNER_ERROR);
     }
 }
コード例 #26
0
ファイル: PutMagic.php プロジェクト: bsdcfp/wxmp
 public function process()
 {
     try {
         DbFactory::getInstance('MYZL')->autoCommit();
         //获取msgForOther并设置用户提示文本
         $msgForOther = $this->_fightInfo['msgForOther'];
         $otherId = $this->_fightInfo['otherId'];
         if ($otherId == $this->_fromUserName) {
             $this->_responseText .= $msgForOther;
             $this->_fightInfo['msgForOther'] = "";
         }
         //设置用户提示文本
         $this->_fightInfo['otherId'] = $this->_fromUserName == $this->_fightInfo['user1'] ? $this->_fightInfo['user2'] : $this->_fightInfo['user1'];
         if ($this->_fightInfo['msgForOther'] == "") {
             $this->_fightInfo['msgForOther'] = "对方已经使用道具";
         } else {
             $this->_fightInfo['msgForOther'] .= ", 对方已经使用道具";
         }
         //获取道具变量,使用这种方式是为了兼容后续可能出现的一次使用多个道具的情况
         $magic = $this->_args['magic'];
         if ($magic != '') {
             $xsft = 0;
             $hdcx = 0;
             $chxs = 0;
             $sszm = 0;
             if ($magic == XSFT) {
                 $xsft = 1;
             } else {
                 if ($magic == HDCX) {
                     $hdcx = 1;
                 } else {
                     if ($magic == CHXS) {
                         $chxs = 1;
                     } else {
                         if ($magic == SSZM) {
                             $sszm = 1;
                         } else {
                             $this->_retValue = EC_ERROR_MAGIC;
                             $this->_retMsg = "fightId:" . $this->_fightId . " userId:" . $this->_args['userId'] . " magic:" . $magic;
                             interface_log(ERROR, $this->_retValue, $this->_retMsg);
                             return false;
                         }
                     }
                 }
             }
             if ($this->_fightInfo['current'] == $this->_args['userId']) {
                 if ($hdcx) {
                     //如果当前轮次开枪的操作者是当前玩家,则当前玩家不能使用壶底抽薪的技能
                     $this->_retValue = EC_ERROR_MAGIC;
                     $this->_retMsg = "fightId:" . $this->_fightId . " userId:" . $this->_args['userId'] . " magic:" . HDCX;
                     interface_log(ERROR, $this->_retValue, $this->_retMsg);
                     return false;
                 }
             } else {
                 if ($xsft || $chxs || $sszm) {
                     //如果当前轮次开枪的操作者不是当前玩家,则当前玩家只能使用壶底抽薪的技能,其他的技能不可用
                     $this->_retValue = EC_ERROR_MAGIC;
                     $this->_retMsg = "fightId:" . $this->_fightId . " userId:" . $this->_args['userId'] . " magic:" . ($xsft ? XSFT : "") . ($chxs ? CHXS : "") . ($sszm ? SSZM : "");
                     interface_log(ERROR, $this->_retValue, $this->_retMsg);
                     return false;
                 }
             }
             if ($this->_args['magic']) {
                 //更新用户道具数
                 if ($this->_userInfo['xsft'] - $xsft < 0 || $this->_userInfo['hdcx'] - $hdcx < 0 || $this->_userInfo['chxs'] - $chxs < 0 || $this->_userInfo['sszm'] - $sszm < 0) {
                     $this->_retValue = EC_NOT_ENOUGH_MAGIC;
                     $this->_retMsg = "fightId:" . $this->_fightId . " userId:" . $this->_args['userId'] . " magic:" . ($xsft ? XSFT : " ") . ($chxs ? CHXS : " ") . ($sszm ? SSZM : " ") . ($hdcx ? HDCX : " ");
                     interface_log(ERROR, $this->_retValue, $this->_retMsg);
                     return false;
                 }
                 $this->_oTable->setTableName('cUser');
                 $this->_oTable->updateObject(array('xsft' => $this->_userInfo['xsft'] - $xsft, 'hdcx' => $this->_userInfo['hdcx'] - $hdcx, 'chxs' => $this->_userInfo['chxs'] - $chxs, 'sszm' => $this->_userInfo['sszm'] - $sszm), array('userId' => $this->_args['userId']));
             }
         }
         //设置下一步动作和操作码和操作人
         $ret = $this->setNextOpAndUser();
         if ($ret['code']) {
             $this->_retValue = EC_STEP_ERROR;
             $this->_retMsg = "fightId:" . $this->_fightId . " step:" . $this->_fightInfo['historyOp'];
             interface_log(ERROR, $this->_retValue, $this->_retMsg);
             return false;
         }
         //更新游戏数据中的magic1,magic2和magicUsed1和magicUsed2
         if ($this->_args['magic']) {
             $this->setMagic();
         }
         //更新历史操作记录
         if ($this->_fightInfo['historyOp'] == '') {
             $newHistoyOp = PUT_MAGIC . ',' . $this->_args['userId'];
         } else {
             $newHistoyOp = $this->_fightInfo['historyOp'] . "|" . PUT_MAGIC . ',' . $this->_args['userId'];
         }
         $this->_fightInfo['historyOp'] = $newHistoyOp;
         //更新游戏记录
         unset($this->_fightInfo['fightId']);
         $this->_oTable->setTableName('cFight');
         $this->_oTable->updateObject($this->_fightInfo, array('fightId' => $this->_fightId));
         DbFactory::getInstance('MYZL')->tryCommit();
         //设置用户提示文本
         if ($this->_responseText) {
             if ($this->_args['magic']) {
                 $this->_responseText .= ', ' . sprintf(MYZL_HINT_PUTMAGIC_SUC, $GLOBALS['constants']['magicName'][$this->_operand], $GLOBALS['constants']['stepName'][$this->_fightInfo['operation']]);
             } else {
                 $this->_responseText .= ', ' . sprintf(MYZL_HINT_PUTMAGIC_SUC_NO, $GLOBALS['constants']['stepName'][$this->_fightInfo['operation']]);
             }
         } else {
             if ($this->_args['magic']) {
                 $this->_responseText = sprintf(MYZL_HINT_PUTMAGIC_SUC, $GLOBALS['constants']['magicName'][$this->_operand], $GLOBALS['constants']['stepName'][$this->_fightInfo['operation']]);
             } else {
                 $this->_responseText = sprintf(MYZL_HINT_PUTMAGIC_SUC_NO, $GLOBALS['constants']['stepName'][$this->_fightInfo['operation']]);
             }
         }
     } catch (DB_Exception $e) {
         DbFactory::getInstance('MYZL')->rollback();
         $errorNum = $this->_oTable->getErrorNum();
         $this->_retMsg = $this->_oTable->getErrorInfo() . $e->getMessage();
         $this->_retValue = genRetCode($errorNum);
         interface_log(ERROR, $this->_retValue, $this->_retMsg);
         return false;
     }
     return true;
 }
コード例 #27
0
ファイル: Shoot.php プロジェクト: bsdcfp/wxmp
 public function process()
 {
     try {
         DbFactory::getInstance('MYZL')->autoCommit();
         //获取msgForOther并设置用户提示文本
         $msgForOther = $this->_fightInfo['msgForOther'];
         $otherId = $this->_fightInfo['otherId'];
         if ($otherId == $this->_fromUserName) {
             $this->_responseText .= $msgForOther;
             $this->_fightInfo['msgForOther'] = "";
         }
         //设置用户提示文本
         $this->_fightInfo['otherId'] = $this->_fromUserName == $this->_fightInfo['user1'] ? $this->_fightInfo['user2'] : $this->_fightInfo['user1'];
         if ($this->_fightInfo['msgForOther'] == "") {
             $this->_fightInfo['msgForOther'] = "对方开枪,";
         } else {
             $this->_fightInfo['msgForOther'] .= ", 对方开枪,";
         }
         //保存上一次操作状态
         unset($this->_fightInfo['lastInfo']);
         $this->_fightInfo['lastInfo'] = json_encode($this->_fightInfo);
         //计算结果
         $this->_result = $this->calculateResult();
         interface_log(DEBUG, 0, var_export($this->_result, true));
         //根据开枪结果设置用户提示文本和
         if ($this->_result['out']) {
             //子弹打出的情况
             $this->_responseText .= "子弹打出,";
             $this->_fightInfo['msgForOther'] .= "子弹打出,";
             if ($this->_fightInfo['gameNumber'] == 2) {
                 $this->_responseText .= "下半局结束,";
                 $this->_fightInfo['msgForOther'] .= "下半局结束,";
                 if ($this->_result['dead']) {
                     $this->_fightInfo['loss2'] = $this->_args['userId'];
                 } else {
                     $this->_fightInfo['loss2'] = -1;
                 }
                 $this->_fightInfo['operation'] = SECOND_END;
                 $this->_fightInfo['operator'] = 0;
                 $this->_fightInfo['count'] == 0;
                 //$this->_fightInfo ['current'] = $this->_fightInfo['first'];
             } else {
                 $this->_responseText .= "上半局结束,";
                 $this->_fightInfo['msgForOther'] .= "上半局结束,";
                 if ($this->_result['dead']) {
                     $this->_fightInfo['loss1'] = $this->_args['userId'];
                 } else {
                     $this->_fightInfo['loss1'] = -1;
                 }
                 $this->_fightInfo['first'] = $this->_fightInfo['first'] == $this->_fightInfo['user1'] ? $this->_fightInfo['user2'] : $this->_fightInfo['user1'];
                 $this->_fightInfo['operation'] = FIRST_END;
                 $this->_fightInfo['operator'] = 0;
                 $this->_fightInfo['count'] == 0;
                 $this->_fightInfo['current'] = $this->_fightInfo['first'];
             }
         } else {
             //子弹未打出的情况
             if ($this->_result['magicEffect'] == CHXS) {
                 $this->_responseText .= "本局游戏重新开始,";
                 $this->_fightInfo['msgForOther'] .= "本局游戏重新开始,";
                 $this->_fightInfo['count'] = 0;
                 if ($this->_fightInfo['gameNumber'] == 1) {
                     $this->_fightInfo['operation'] = START;
                 } else {
                     $this->_fightInfo['operation'] = FIRST_END;
                 }
                 $this->_fightInfo['operator'] = 0;
                 $this->_fightInfo['current'] = $this->_fightInfo['first'];
             } else {
                 //set current
                 $this->_responseText .= "子弹未打出,游戏继续";
                 $this->_fightInfo['msgForOther'] .= "子弹未打出,游戏继续";
                 $this->_fightInfo['current'] = $this->_fightInfo['current'] == $this->_fightInfo['user1'] ? $this->_fightInfo['user2'] : $this->_fightInfo['user1'];
                 $ret = $this->setNextOpAndUser();
                 if ($ret['code']) {
                     $this->_retValue = EC_STEP_ERROR;
                     $this->_retMsg = "fightId:" . $this->_fightId . " step:" . $this->_fightInfo['historyOp'];
                     interface_log(ERROR, $this->_retValue, $this->_retMsg);
                     return false;
                 }
                 if ($this->_result['magicEffect'] == SSZM) {
                 } else {
                     $this->_fightInfo['count']--;
                 }
             }
         }
         if ($this->_fightInfo['historyOp'] == '') {
             $newHistoyOp = SHOOT . ',' . $this->_args['userId'];
         } else {
             $newHistoyOp = $this->_fightInfo['historyOp'] . "|" . SHOOT . ',' . $this->_args['userId'];
         }
         $this->_fightInfo['historyOp'] = $newHistoyOp;
         if ($this->_result['out']) {
             //子弹打出的情况,分钱逻辑
             $this->divideMoney();
         }
         //清空magic1和magic2
         $this->_fightInfo['magic1'] = '';
         $this->_fightInfo['magic2'] = '';
         if ($this->_fightInfo['operation'] == SECOND_END) {
             //在操作码为SECOND_END的情况,把游戏数据移动到cFightUncheck中
             $this->_oTable->setTableName('cFightUncheck');
             $this->_oTable->addObject($this->_fightInfo);
             $this->_oTable->setTableName('cFight');
             $this->_oTable->delObject(array('fightId' => $this->_fightId));
             $this->_data = $this->_fightInfo;
         } else {
             //更新游戏数据
             unset($this->_fightInfo['fightId']);
             $this->_oTable->setTableName('cFight');
             $this->_oTable->updateObject($this->_fightInfo, array('fightId' => $this->_fightId));
             $this->_data = $this->_fightInfo;
         }
         DbFactory::getInstance('MYZL')->tryCommit();
     } catch (DB_Exception $e) {
         DbFactory::getInstance('MYZL')->rollback();
         $errorNum = $this->_oTable->getErrorNum();
         $this->_retMsg = $this->_oTable->getErrorInfo() . $e->getMessage();
         $this->_retValue = genRetCode($errorNum);
         interface_log(ERROR, $this->_retValue, $this->_retMsg);
         return false;
     }
     return true;
 }
コード例 #28
0
ファイル: bkk_mr.php プロジェクト: youngky2008/sp_cp
//组建原始数据,并插入到db中
$linkid = $para['linkid'];
$mr_data['mr_addr'] = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'];
$mr_data['status'] = $para['status'];
$mr_data['mr_submit_date'] = $para['mrTime'];
$mr_data['mr_time'] = date('Y-m-d H:i:s');
$mr_data['submit_flag'] = 1;
//表示收到了MR请求
$mr_data['mobile_num'] = $para['mobile'];
$mr_data['mcc'] = intval($para['mcc']);
$mr_data['mnc'] = intval($para['mnc']);
$mr_data['link_id'] = $linkid;
$id = 0;
$ret = write_original_data($dao, $mr_data, false, $id, $error_message);
if ($ret != 0) {
    live_log(ERROR, $ret, $error_message);
    interface_log(ERROR, $ret, "response: {$linkid}, err_msg: " . $error_message);
    http_response_code(400);
    echo 202;
    return;
}
$ret = TransmitMr($dao, $id, $mr_data, true, $error_message);
if ($ret != 0) {
    live_log(ERROR, $ret, $error_message);
    interface_log(ERROR, $ret, "response: {$linkid}, err_msg: " . $error_message);
    echo 200;
    return;
}
echo 200;
interface_log(INFO, EC_OK, "linkid: {$linkid}, bkk mr success.");
return;
コード例 #29
0
ファイル: interface.php プロジェクト: hsiun/laputa
 */
ini_set('display_errors', '1');
//include other file
require_once dirname(__FILE__) . '/class/WechatValid.php';
require_once dirname(__FILE__) . '/class/WechatCallBackEchoServer.php';
require_once dirname(__FILE__) . '/common/GlobalFunctions.php';
$wechatValid = new WechatValid();
$wechatValid->valid();
$wechatObj = new WechatCallBackEchoServer();
$postStr = $GLOBALS["HTTP_RAW_POST_DATA"];
interface_log(INFO, EC_OK, "******************************************************");
interface_log(INFO, EC_OK, "*************** interface requrest start *************");
interface_log(INFO, EC_OK, 'request:' . $postStr);
interface_log(INFO, EC_OK, 'get:' . var_export($_GET, true));
if (empty($postStr)) {
    interface_log(ERROR, EC_OK, "post data error!");
    exit(0);
}
$postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
$ret = $wechatObj->init($postObj);
if (!$ret) {
    interface_log(ERROR, EC_OK, "init post object error!");
    exit(0);
}
$retStr = $wechatObj->process();
interface_log(INFO, EC_OK, "response:" . $retStr);
echo $retStr;
interface_log(INFO, EC_OK, "*************** interface request end ****************");
interface_log(INFO, EC_OK, "******************************************************");
interface_log(INFO, EC_OK, "");