diff --git a/webapp/controller/FriendController.class.php b/webapp/controller/FriendController.class.php deleted file mode 100644 index 29756ee..0000000 --- a/webapp/controller/FriendController.class.php +++ /dev/null @@ -1,301 +0,0 @@ - $mysql_conf['host'], - 'port' => $mysql_conf['port'], - 'user' => $mysql_conf['user'], - 'passwd' => $mysql_conf['passwd'], - 'dbname' => DBNAME_PREFIX . $mysql_conf['instance_id'] - )); - array_push($conns, $conn); - } - return $conns; - } - - public function selectUserInfo() - { - $target_id = $_REQUEST['target_id']; - $conns = $this->getAllMysql(); - $flag = 0; - $max_rank = 1; - $rank = 1; - $avatar_url = 18001; - $vip_level = 0; - foreach ($conns as $conn) { - $row = $conn->execQueryOne('SELECT account_id, user_name, avatar_url, game_times, win_times, kill_his, kills, harm_his, harm, integral, modify_time, alive_time, add_HP, head_kuang_id, max_integral, sex FROM user WHERE account_id=:account_id;', - array( - ':account_id' => $target_id, - )); - if ($row) { - $flag = 1; - } - - $rowbags = $conn->execQuery('SELECT id, color_id FROM bag WHERE account_id=:account_id AND status=0;', - array( - ':account_id' => $target_id, - )); - if ($rowbags) { - $flag = 1; - } - - $rowequip = $conn->execQueryOne('SELECT using_id FROM equip WHERE account_id=:account_id;', - array( - ':account_id' => $target_id, - )); - $rowlv = $conn->execQueryOne('SELECT using_id, lv FROM equip WHERE account_id=:account_id AND id=:id;', - array( - ':account_id' => $target_id, - ':id' => $rowequip['using_id'] - )); - if ($rowequip || $rowlv) { - $flag = 1; - } - if ($flag == 1) { - break; - } - $max_rank = 1; - $rank = 1; - $seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php'); - for ($ii = 1; $ii <= count($seaPoint_meta_table); $ii++) { - $seaPoint = mt\SeasonPoint::getOldSeasonPoint($ii); - if ($row['integral'] >= $seaPoint['min'] && $row['integral'] <= $seaPoint['max'] - || $seaPoint['max'] == -1) { - $rank = $ii; - break; - } - if ($row['max_integral'] >= $seaPoint['min'] && $row['max_integral'] <= $seaPoint['max'] - || $seaPoint['max'] == -1) { - $max_rank = $ii; - break; - } - } - $addreward = new classes\Addreward(); - $vip_level = $addreward->getVipLevel($target_id); - $avatar_url = $row['avatar_url']; - } - - if ($flag == 0) { - phpcommon\sendError(ERR_USER_BASE + 1, '玩家不存在'); - return; - } - echo json_encode(array( - 'errcode' => 0, - 'errmsg' => '', - 'account_id' => $row['account_id'], - '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'], - 'head_kuang_id' => $row['head_kuang_id'], - 'vip_level' => $vip_level, - 'max_rank' => $max_rank, - 'bags' => $rowbags, - 'equip' => $rowlv, - 'sex' => $row['sex'], - )); - } - - public function selectUser() - { - $target_id = $_REQUEST['target_id']; - $conns = $this->getAllMysql(); - $flag = 0; - $name = ''; - foreach ($conns as $conn) { - $row = $conn->execQueryOne('SELECT user_name FROM user WHERE account_id=:account_id;', - array( - ':account_id' => $target_id, - )); - if ($row) { - $flag = 1; - $name = $row['user_name']; - break; - } - } - if ($flag == 0) { - phpcommon\sendError(ERR_USER_BASE + 1, '玩家不存在'); - return; - } - - echo json_encode(array( - 'errcode' => 0, - 'errmsg' => '', - 'name' => $name, - )); - } - - public function selectUserByName() - { - $account_id = $_REQUEST['account_id']; - $conns = $this->getAllMysql(); - $account_id = ''; - $user_name = $_REQUEST['user_name']; - foreach ($conns as $conn) { - $row = $conn->execQueryOne('SELECT account_id FROM user WHERE user_name=:user_name;', - array( - ':user_name' => $user_name, - )); - $flag = 0; - if (!$row) { - $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; - $account_id = '6511_2005_robot' . $i; - break; - } - } - if ($flag != 0) { - break; - } - } else { - $flag = 1; - $account_id = $row['account_id']; - break; - } - } - - if ($flag == 0) { - phpcommon\sendError(ERR_USER_BASE + 2, '玩家不存在'); - return; - } - - echo json_encode(array( - 'errcode' => 0, - 'errmsg' => '', - 'fri_account_id' => $account_id, - )); - } - - public function createRoleInfo() - { - $account_id = $_REQUEST['account_id']; - $conn = $this->_getMysql($account_id); - $user_name = $_REQUEST['user_name']; - $avatar_url = $_REQUEST['avatar_url']; - $sex = $_REQUEST['sex']; - $this->updateRoleInfo($account_id, $user_name, $avatar_url, $sex); - $item_id = metatable\getParameterByName('creator_hair_m'); - if ($sex == 1) { - $item_id = metatable\getParameterByName('creator_hair_f'); - } - if ($item_id != 0) { - $ret = $conn->execScript('INSERT INTO bag(account_id, id, color_id, status, num, active_time, create_time, modify_time) ' . - ' VALUES(:account_id, :id, 0, :status, :num, :active_time, :create_time, :modify_time) ' . - ' ON DUPLICATE KEY UPDATE account_id=:account_id, id=:id, color_id=0, status=:status, num=:num, active_time=:active_time, modify_time=:modify_time;', - array( - ':account_id' => $account_id, - ':id' => $item_id, - ':active_time' => 0, - ':status' => 0, - ':num' => 1, - ':create_time' => phpcommon\getNowTime(), - ':modify_time' => phpcommon\getNowTime() - )); - if(!$ret){ - die(); - } - } - $addreward = new classes\Addreward(); - $addreward->addReward($avatar_url, 1, $account_id, 0, 0); - echo json_encode(array( - 'errcode' => 0, - 'errmsg' => '', - 'user_name' => $user_name, - 'avatar_url' => $avatar_url, - 'create_user' => 1, - 'sex' => $sex, - )); - } - - protected function updateRoleInfo($account_id, $user_name, $avatar_url, $sex) - { - $conn = $this->_getMysql($account_id); - $ret = $conn->execScript('UPDATE user SET user_name=:user_name, avatar_url=:avatar_url, modify_time=:modify_time, create_user=1, sex=:sex ' . - ' WHERE account_id=:account_id;', - array( - ':user_name' => $user_name, - ':avatar_url' => $avatar_url, - ':modify_time' => phpcommon\getNowTime(), - ':account_id' => $account_id, - ':sex' => $sex, - )); - if (!$ret) { - die(); - return; - } - } - - public function changeRoleInfo() - { - $account_id = $_REQUEST['account_id']; - $user_name = $_REQUEST['user_name']; - $avatar_url = $_REQUEST['avatar_url']; - $sex = $_REQUEST['sex']; - $this->updateRoleInfo($account_id, $user_name, $avatar_url, $sex); - echo json_encode(array( - 'errcode' => 0, - 'errmsg' => '', - 'user_name' => $user_name, - 'avatar_url' => $avatar_url, - 'create_user' => 1, - 'sex' => $sex, - )); - } - - public function selRepeatName() - { - $account_id = $_REQUEST['account_id']; - $conns = $this->getAllMysql(); - $user_name = $_REQUEST['user_name']; - foreach ($conns as $conn) { - $row = $conn->execQueryOne('SELECT account_id FROM user WHERE account_id!=: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( - 'errcode' => 0, - 'errmsg' => '', - )); - } -}