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