1
This commit is contained in:
parent
37e5c17bcf
commit
1011f703a1
@ -17,6 +17,24 @@ class FriendController{
|
||||
));
|
||||
return $conn;
|
||||
}
|
||||
|
||||
protected function getAllMysql()
|
||||
{
|
||||
global $g_conf_mysql_cluster;
|
||||
$conns = array();
|
||||
foreach ($g_conf_mysql_cluster as $mysql_conf) {
|
||||
$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']
|
||||
));
|
||||
array_push($conns, $conn);
|
||||
}
|
||||
return $conns;
|
||||
}
|
||||
|
||||
protected function getSeasonPoint($seaPoint_id)
|
||||
{
|
||||
$seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php');
|
||||
@ -107,25 +125,48 @@ class FriendController{
|
||||
public function selectUserByName()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$conn = $this->getMysql();
|
||||
if(!$conn){
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '玩家不存在');
|
||||
$conns = $this->getAllMysql();
|
||||
if (!$conns) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
$accountid = '';
|
||||
$user_name = $_REQUEST['user_name'];
|
||||
$row = $conn->execQueryOne('SELECT accountid FROM user WHERE user_name=:user_name;',
|
||||
array(
|
||||
':user_name' => $user_name,
|
||||
));
|
||||
if (!$row) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '玩家不存在');
|
||||
return;
|
||||
foreach ($conns as $conn) {
|
||||
$row = $conn->execQueryOne('SELECT accountid FROM user WHERE user_name=:user_name;',
|
||||
array(
|
||||
':user_name' => $user_name,
|
||||
));
|
||||
$flag = 0;
|
||||
if (!$row) {
|
||||
// phpcommon\sendError(ERR_USER_BASE + 2, '玩家不存在');
|
||||
// return;
|
||||
$robot_meta_cluster = require('../res/robot@robot.php');
|
||||
for ($i = 0; $i < count($robot_meta_cluster); $i++) {
|
||||
$robot_id = 10000 + $i;
|
||||
$robot_meta = getRobotConfig($robot_meta_cluster, $robot_id);
|
||||
if ($robot_meta['name'] == $user_name) {
|
||||
$flag = 1;
|
||||
$accountid = '6000_2004_robot' . $i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($flag == 0) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '玩家不存在');
|
||||
return;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$accountid = $row['accountid'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
'fri_accountid' => $row['accountid'],
|
||||
'fri_accountid' => $accountid,
|
||||
));
|
||||
}
|
||||
|
||||
@ -175,20 +216,32 @@ class FriendController{
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, 'session无效');
|
||||
return;
|
||||
}
|
||||
$conn = $this->getMysql($account_id);
|
||||
if (!$conn) {
|
||||
$conns = $this->getAllMysql();
|
||||
if (!$conns) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
$user_name = $_REQUEST['user_name'];
|
||||
$row = $conn->execQueryOne('SELECT accountid FROM user WHERE accountid!=:account_id AND user_name=:user_name;',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':user_name' => $user_name,
|
||||
));
|
||||
if ($row) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '名字重名');
|
||||
return;
|
||||
foreach ($conns as $conn) {
|
||||
$row = $conn->execQueryOne('SELECT accountid FROM user WHERE accountid!=:account_id AND user_name=:user_name;',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':user_name' => $user_name,
|
||||
));
|
||||
if ($row) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '名字重名');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$robot_meta_cluster = require('../res/robot@robot.php');
|
||||
for ($i = 0; $i < count($robot_meta_cluster); $i++) {
|
||||
$robot_id = 10000 + $i;
|
||||
$robot_meta = getRobotConfig($robot_meta_cluster, $robot_id);
|
||||
if ($robot_meta['name'] == $user_name) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '名字重名');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode(array(
|
||||
|
Loading…
x
Reference in New Issue
Block a user