1
This commit is contained in:
parent
6338752291
commit
b2386e0fd7
103
webapp/controller/FriendController.class.php
Normal file
103
webapp/controller/FriendController.class.php
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require 'classes/Quest.php';
|
||||||
|
require 'classes/AddReward.php';
|
||||||
|
|
||||||
|
class FriendController{
|
||||||
|
|
||||||
|
protected function getMysql($account_id)
|
||||||
|
{
|
||||||
|
$mysql_conf = getMysqlConfig(crc32($account_id));
|
||||||
|
$conn = new phpcommon\Mysql(array(
|
||||||
|
'host' => $mysql_conf['host'],
|
||||||
|
'port' => $mysql_conf['port'],
|
||||||
|
'user' => $mysql_conf['user'],
|
||||||
|
'passwd' => $mysql_conf['passwd'],
|
||||||
|
'dbname' => 'gamedb2004_' . $mysql_conf['instance_id']
|
||||||
|
));
|
||||||
|
return $conn;
|
||||||
|
}
|
||||||
|
protected function getSeasonPoint($seaPoint_id)
|
||||||
|
{
|
||||||
|
$seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php');
|
||||||
|
$seaPoint_meta = getSeasonPointConfig($seaPoint_meta_table, $seaPoint_id);
|
||||||
|
$seaPoint = array(
|
||||||
|
'id' => $seaPoint_meta['id'],
|
||||||
|
'min' => $seaPoint_meta['min_point'],
|
||||||
|
'max' => $seaPoint_meta['max_point'],
|
||||||
|
'des' => $seaPoint_meta['des'],
|
||||||
|
);
|
||||||
|
return $seaPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function selectUserInfo()
|
||||||
|
{
|
||||||
|
$account_id = $_REQUEST['account_id'];
|
||||||
|
$conn = $this->getMysql($account_id);
|
||||||
|
if(!$conn){
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 1, '玩家不存在');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$row = $conn->execQueryOne('SELECT accountid, user_name, avatar_url, game_times, win_times, kill_his, kills, harm_his, harm, integral, modify_time, alive_time, add_HP FROM user WHERE accountid=:account_id;',
|
||||||
|
array(
|
||||||
|
':account_id' => $account_id,
|
||||||
|
));
|
||||||
|
if (!$row) {
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 1, '玩家不存在');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$rank = 1;
|
||||||
|
$seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php');
|
||||||
|
for ($ii = 1; $ii <= count($seaPoint_meta_table); $ii++) {
|
||||||
|
$seaPoint = $this->getSeasonPoint($ii);
|
||||||
|
if ($row['integral'] >= $seaPoint['min'] && $row['integral'] <= $seaPoint['max']
|
||||||
|
|| $seaPoint['max'] == -1) {
|
||||||
|
$rank = $ii;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode(array(
|
||||||
|
'errcode' => 0,
|
||||||
|
'errmsg' => '',
|
||||||
|
'accountid' => $row['accountid'],
|
||||||
|
'user_name' => $row['user_name'],
|
||||||
|
'avatar_url' => $row['avatar_url'],
|
||||||
|
'game_times' => $row['game_times'],
|
||||||
|
'win_times' => $row['win_times'],
|
||||||
|
'kill_his' => $row['kill_his'],
|
||||||
|
'kills' => $row['kills'],
|
||||||
|
'harm_his' => $row['harm_his'],
|
||||||
|
'harm' => $row['harm'],
|
||||||
|
'level' => $rank,
|
||||||
|
'modify_time' => $row['modify_time'],
|
||||||
|
'alive_time' => $row['alive_time'],
|
||||||
|
'add_HP' => $row['add_HP'],
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function selectUser()
|
||||||
|
{
|
||||||
|
$account_id = $_REQUEST['account_id'];
|
||||||
|
$conn = $this->getMysql($account_id);
|
||||||
|
if(!$conn){
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 1, '玩家不存在');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$row = $conn->execQueryOne('SELECT accountid FROM user WHERE accountid=:account_id;',
|
||||||
|
array(
|
||||||
|
':account_id' => $account_id,
|
||||||
|
));
|
||||||
|
if (!$row) {
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 1, '玩家不存在');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode(array(
|
||||||
|
'errcode' => 0,
|
||||||
|
'errmsg' => '',
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
Loading…
x
Reference in New Issue
Block a user