$mysql_conf['host'], 'port' => $mysql_conf['port'], 'user' => $mysql_conf['user'], 'passwd' => $mysql_conf['passwd'], 'dbname' => DBNAME_PREFIX . $mysql_conf['instance_id'] )); return $conn; } private function isForbidCity() { return false; /*if (in_array(strtolower($_REQUEST['province']), array( strtolower('Shanghai'), strtolower('Beijing'), '上海', '北京' )) || in_array(strtolower($_REQUEST['city']), array( strtolower('Guangzhou'), strtolower('Shenzhen'), strtolower('Chengdu'), '广州', '深圳', '成都' )) ) { return true; } return false;*/ } public function getSwitch() { /*if (SERVER_ENV != _ONLINE) { echo json_encode(array( 'errcode' => 0, 'errmsg' => '', 'payable' => 1 )); die(); }*/ //error_log(json_encode($_REQUEST)); $payable = 0; /* 1:玩家进入第一天,战斗7次,开放充值(除北上广深成)。 2:玩家进入第二天,战斗7次,已充值玩家战斗2次(除北上广深成)。 3:玩家进入第三天,战斗7次,已充值玩家战斗2次。 */ if (phpcommon\isValidSessionId($_REQUEST['account_id'], $_REQUEST['session_id'])) { $recharge_times = 0; $conn = $this->getMysql($_REQUEST['account_id']); $row = $conn->execQueryOne('SELECT recharge_times_total FROM user WHERE accountid=:accountid;', array( ':accountid' => $_REQUEST['account_id'] )); if ($row) { $recharge_times = $row['recharge_times_total']; } $register_time = phpcommon\extractRegisterTimeFromSessionId($_REQUEST['session_id']); $nowtime = time(); $register_time = phpcommon\getdayseconds($register_time); $nowtime = phpcommon\getdayseconds($nowtime); if ($nowtime - $register_time > 3600 * 24 * 2) { //第三天 if ($_REQUEST['battle_times'] >= 2) { $payable = 1; } else if ($recharge_times > 0 && $_REQUEST['battle_times'] >= 1) { $payable = 1; } } else if ($nowtime - $register_time > 3600 * 24 * 1) { //第二天 if ($this->isForbidCity()) { } else { if ($_REQUEST['battle_times'] >= 2) { $payable = 1; } else if ($recharge_times > 0 && $_REQUEST['battle_times'] >= 2) { $payable = 1; } } } else { //第一天 if ($this->isForbidCity()) { } else if ($_REQUEST['battle_times'] >= 3) { $payable = 1; } } } echo json_encode(array( 'errcode' => 0, 'errmsg' => '', 'payable' => $payable )); } }