Compare commits

...

5 Commits

Author SHA1 Message Date
aozhiwei
1011f703a1 1 2020-12-04 11:55:34 +08:00
aozhiwei
37e5c17bcf 1 2020-12-04 10:31:03 +08:00
aozhiwei
a41c8d4a18 1 2020-12-03 17:02:33 +08:00
aozhiwei
164c88857e 1 2020-12-02 17:03:09 +08:00
aozhiwei
9fff301380 1 2020-12-02 15:57:22 +08:00
10 changed files with 254 additions and 102 deletions

2
res
View File

@ -1 +1 @@
config
../conf_test/game2004api/webapp/res5991

View File

@ -97,6 +97,7 @@ CREATE TABLE `user` (
`share_video_sums` int(11) NOT NULL DEFAULT '0' COMMENT '分享录频次数',
`biogame_times` int(11) NOT NULL DEFAULT '0' COMMENT '生化模式场次',
`create_user` int(11) NOT NULL DEFAULT '0' COMMENT '是否创角',
PRIMARY KEY (`idx`),
UNIQUE KEY `accountid` (`accountid`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

View File

@ -320,7 +320,7 @@ function isValidSessionId($account_id, $session_id)
}
if (SERVER_ENV == _ONLINE) {
$channel = extractChannel($account_id);
if ($channel == 6000) {
if ($channel == 6000 && !defined('ENABLE_6000_CHANNEL')) {
return false;
}
}

View File

@ -97,7 +97,6 @@ class ActivityController{
'quailty' => $lot_conf['quailty'],
'jilv' => $lot_conf['jilv'],
'time' => $lot_conf['time'],
'day' => $lot_conf['day'],
);
return $l;
}
@ -668,11 +667,11 @@ class ActivityController{
//确定商品id和数量
$weight_sum = 0;
$weight_array = $this->getExplode($l['weight']);
if ($type == 1) {
if ($l['day'] != $day) {
continue;
}
}
// if ($type == 1) {
// if ($l['day'] != $day) {
// continue;
// }
// }
for ($ii = 0; $ii < count($weight_array); $ii++) {
$weight_sum += $weight_array[$ii][0];
}

View File

@ -58,7 +58,10 @@ class AdditemController{
$item_num = $_REQUEST['item_num'];
$accountid = $_REQUEST['account_id'];
$time = $_REQUEST['time'];
if (phpcommon\getIPv4() != '116.228.166.182') {
// if (phpcommon\getIPv4() != '116.228.166.182') {
// return;
// }
if ($_REQUEST['passwd'] != 'kingsome') {
return;
}
$conn = $this->getMysql($accountid);
@ -114,7 +117,10 @@ class AdditemController{
$item_num = $_REQUEST['item_num'];
$accountid = $_REQUEST['account_id'];
$time = $_REQUEST['time'];
if (phpcommon\getIPv4() != '116.228.166.182') {
// if (phpcommon\getIPv4() != '116.228.166.182') {
// return;
// }
if ($_REQUEST['passwd'] != 'kingsome') {
return;
}
$conn = $this->getMysql($accountid);
@ -146,7 +152,10 @@ class AdditemController{
$item_num = $_REQUEST['item_num'];
$accountid = $_REQUEST['account_id'];
$time = $_REQUEST['time'];
if (phpcommon\getIPv4() != '116.228.166.182') {
// if (phpcommon\getIPv4() != '116.228.166.182') {
// return;
// }
if ($_REQUEST['passwd'] != 'kingsome') {
return;
}
$conn = $this->getMysql($accountid);

View File

@ -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');
@ -84,7 +102,7 @@ class FriendController{
public function selectUser()
{
$account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id);
$conn = $this->getMysql();
if(!$conn){
phpcommon\sendError(ERR_USER_BASE + 1, '玩家不存在');
return;
@ -103,5 +121,189 @@ class FriendController{
'errmsg' => '',
));
}
public function selectUserByName()
{
$account_id = $_REQUEST['account_id'];
$conns = $this->getAllMysql();
if (!$conns) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
$accountid = '';
$user_name = $_REQUEST['user_name'];
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' => $accountid,
));
}
public function changeRoleInfo()
{
$account_id = $_REQUEST['account_id'];
//登录校验
$login = loginVerify($account_id, $_REQUEST['session_id']);
if (!$login) {
phpcommon\sendError(ERR_USER_BASE + 1, 'session无效');
return;
}
$conn = $this->getMysql($account_id);
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
$user_name = $_REQUEST['user_name'];
$avatar_url = $_REQUEST['avatar_url'];
$ret = $conn->execScript('UPDATE user SET user_name=:user_name, avatar_url=:avatar_url, modify_time=:modify_time, create_user=1 ' .
' WHERE accountid=:accountid;',
array(
':user_name' => $user_name,
':avatar_url' => $avatar_url,
':modify_time' => time(),
':accountid' => $account_id
));
if (!$ret) {
die();
return;
}
echo json_encode(array(
'errcode' => 0,
'errmsg' => '',
'user_name' => $user_name,
'avatar_url' => $avatar_url,
'create_user' => 1,
));
}
public function selRepeatName()
{
$account_id = $_REQUEST['account_id'];
//登录校验
$login = loginVerify($account_id, $_REQUEST['session_id']);
if (!$login) {
phpcommon\sendError(ERR_USER_BASE + 1, 'session无效');
return;
}
$conns = $this->getAllMysql();
if (!$conns) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
$user_name = $_REQUEST['user_name'];
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(
'errcode' => 0,
'errmsg' => '',
));
}
public function rechargeDiamond()
{
$account_id = $_REQUEST['account_id'];
//登录校验
$login = loginVerify($account_id, $_REQUEST['session_id']);
if (!$login) {
phpcommon\sendError(ERR_USER_BASE + 1, 'session无效');
return;
}
$conn = $this->getMysql($account_id);
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
$row = $conn->execQueryOne('SELECT diamond_num FROM user WHERE accountid=:account_id;',
array(
':account_id' => $account_id,
));
if (!$row) {
phpcommon\sendError(ERR_USER_BASE + 1, '玩家不存在');
return;
}
$num = $_REQUEST['num'];
$ret = $conn->execScript('UPDATE user SET diamond_num=:diamond_num, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':modify_time' => time(),
':accountid' => $account_id,
':diamond_num' => $num + $row['diamond_num'],
));
if (!$ret) {
die();
return;
}
$item_list = array();
$all_item_list = array();
array_push($item_list, array(
'item_id' => 10003,
'item_num' => $num,
'time' => 0,
));
array_push($all_item_list, array(
'item_id' => 10003,
'item_num' => $num,
'time' => 0,
));
$diamond_num = $num + $row['diamond_num'];
echo json_encode(array(
'errcode' => 0,
'errmsg' => '',
'diamond_nums' => $diamond_num,
'item_list' => $item_list,
'all_item_list' => $all_item_list,
));
}
}
?>

View File

@ -122,66 +122,11 @@ class RankController{
ini_set('memory_limit','3072M');
//击杀榜
$r = $this->getRedis();
/*$channel = phpcommon\extractChannel($account_id);
$kill_rank_db = $r->get("game2004api:kill_rank_" . $channel);
$kill_db = json_decode($kill_rank_db);
$i = 0;
foreach ($kill_db as $kill) {
$name = '';
$avatar_url = '';
if ($i > 49) {
break;
}
if ($kill_db[$i][0] == $account_id) {
$kill_rank = $i + 1;
}
if ($kill_db[$i][2] == '' || $kill_db[$i][1] == '') {
if ($kill_db[$i][0] == $account_id) {
$name = $myname;
$avatar_url = $myavatar_url;
} else {
$address = '../res/robot@robot' . 1 . '.php';
$robot_meta_cluster = require($address);
$j = Rand(1, 100);
$robot_id = 1000 + $j;
$robot_meta = getRobotConfig($robot_meta_cluster, $robot_id);
$rob = array(
'name' => $robot_meta['name'],
'avatar_url' => $robot_meta['avatar_url'],
);
if ($kill_db[$i][1] == '') {
$name = $rob['name'];
} else {
$name = $kill_db[$i][1];
}
if ($kill_db[$i][2] == '') {
$avatar_url = $rob['avatar_url'];
} else {
$avatar_url = $kill_db[$i][2];
}
}
} else {
$name = $kill_db[$i][1];
$avatar_url = $kill_db[$i][2];
}
$url = urldecode($avatar_url);
array_push($kill_list, array(
'account_id' => $kill_db[$i][0],
'name' => $name,
'avatar_url' => $url,
'kill' => $kill_db[$i][3],
'alive'=> $kill_db[$i][4],
'harm' => $kill_db[$i][5],
'win_rate' => $kill_db[$i][6],
'win_game' => $kill_db[$i][7],
));
$i++;
}*/
//胜场榜
$channel = phpcommon\extractChannel($account_id);
$win_rank_db = $r->get("game2004api:win_rank_" . $channel);
if ($_SERVER['HTTP_HOST'] == 'game2001api-banshu.kingsome.cn') {
$win_rank_db = $r->get("game2004api_2001:win_rank_" . $channel);
}
$win_db = json_decode($win_rank_db);
$i = 0;
foreach ($win_db as $win) {
@ -239,6 +184,9 @@ class RankController{
//积分榜
$channel = phpcommon\extractChannel($account_id);
$integral_rank_db = $r->get("game2004api:integral_rank_" . $channel);
if ($_SERVER['HTTP_HOST'] == 'game2001api-banshu.kingsome.cn') {
$integral_rank_db = $r->get("game2004api_2001:integral_rank_" . $channel);
}
$integral_db = json_decode($integral_rank_db);
$i = 0;
foreach ($integral_db as $integral) {
@ -247,6 +195,9 @@ class RankController{
if ($i > 49) {
break;
}
if ($integral_db[$i][1] == '游客' || $integral_db[$i][1] == '极乐玩家') {
continue;
}
$score = 0;
$rank = 0;
$seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php');
@ -311,8 +262,6 @@ class RankController{
'errcode' => 0,
'errmsg' => "",
'user_list' => $user_list,
//'kill_rank' => $kill_rank,
//'kill_list' => $kill_list,
'win_rank' => $win_rank,
'win_list' => $win_list,
'integral_rank' => $integral_rank,

View File

@ -146,8 +146,10 @@ class RoleController{
public function roleInfo()
{
$account_id = $_REQUEST['account_id'];
$user_name = $_REQUEST['name'];
$avatar_url = $_REQUEST['avatar_url'];
//$user_name = $_REQUEST['name'];
//$avatar_url = $_REQUEST['avatar_url'];
$user_name = '游客';
$avatar_url = '1';
$switch_id = 1;
$switch_id = isset($_REQUEST['switch_id']);
//登录校验
@ -184,9 +186,9 @@ class RoleController{
break;
}
}
$ret = $conn->execScript('INSERT INTO user(accountid, user_name, avatar_url, game_times, win_times, kills, harm, add_HP, alive_time, coin_num, integral, kill_his, alive_time_his, harm_his, add_HP_his, act_share_time, act_share_status, create_time, modify_time, first_fight, collect_status, keys_num, battle_re_times, shop_flush_times, kefu_status, sign_sum, box_num, diamond_num, sum_coin, pass_status, score, season_status, recharge_times_total, first_gift, season_time, free_coin, free_diamond, season_end_score, kill_modifytime, win_modifytime, rank_modifytime, vip_score, first_login, daily_first_login, daily_time, free_box, update_time, season_games, season_win, sea_max_kill, sea_max_hart, sea_avg_kill, free_lot_ticket, free_dou_lot_ticket, daily_order1, daily_order2, daily_order3, first_bee, newhand, coin_times, newInfo, first_day_ad, share_video_times, share_video_sums, act_video_status, act_ad_status, biogame_times) ' .
' VALUES(:accountid, :user_name, :avatar_url, 0, 0, 0, 0, 0, 0, 200, 0, 0, 0, 0, 0, 0, 0, :create_time, :modify_time, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, :season_time, 0, 0, 0, 0, 0, 0, 0, 0, 0, :daily_time, 0,:update_time,0,0,0,0,0,0,0,0,0,0,0,0,0,:newInfo,0,0,0,0,0,0) ' .
' ON DUPLICATE KEY UPDATE accountid=:accountid, user_name=:user_name, avatar_url=:avatar_url, game_times=0, win_times=0, kills=0, harm=0, add_HP=0, alive_time=0, coin_num=0, integral=0, kill_his=0, alive_time_his=0, harm_his=0, add_HP_his=0, act_share_time=0, act_share_status=0, modify_time=:modify_time, first_fight=0, collect_status=0, keys_num=0, battle_re_times=0, shop_flush_times=0, kefu_status=0, sign_sum=0, box_num=0, diamond_num=0, sum_coin=0, pass_status=0, score=0, season_status=1, recharge_times_total=0, first_gift=0, season_time=:season_time, free_coin=0, free_diamond=0, season_end_score=0, kill_modifytime=0, win_modifytime=0, rank_modifytime=0, vip_score=0, first_login=0, daily_first_login=0, daily_time=:daily_time, free_box=0, update_time=:update_time, season_games=0, season_win=0, sea_max_kill=0, sea_max_hart=0, sea_avg_kill=0, free_lot_ticket=0, free_dou_lot_ticket=0, daily_order1=0, daily_order2=0, daily_order3=0, first_bee=0, newhand=0, coin_times=0, newInfo=:newInfo, first_day_ad=0, share_video_times=0, share_video_sums=0, act_video_status=0, act_ad_status=0, biogame_times=0;',
$ret = $conn->execScript('INSERT INTO user(accountid, user_name, avatar_url, game_times, win_times, kills, harm, add_HP, alive_time, coin_num, integral, kill_his, alive_time_his, harm_his, add_HP_his, act_share_time, act_share_status, create_time, modify_time, first_fight, collect_status, keys_num, battle_re_times, shop_flush_times, kefu_status, sign_sum, box_num, diamond_num, sum_coin, pass_status, score, season_status, recharge_times_total, first_gift, season_time, free_coin, free_diamond, season_end_score, kill_modifytime, win_modifytime, rank_modifytime, vip_score, first_login, daily_first_login, daily_time, free_box, update_time, season_games, season_win, sea_max_kill, sea_max_hart, sea_avg_kill, free_lot_ticket, free_dou_lot_ticket, daily_order1, daily_order2, daily_order3, first_bee, newhand, coin_times, newInfo, first_day_ad, share_video_times, share_video_sums, act_video_status, act_ad_status, biogame_times, create_user) ' .
' VALUES(:accountid, :user_name, :avatar_url, 0, 0, 0, 0, 0, 0, 200, 0, 0, 0, 0, 0, 0, 0, :create_time, :modify_time, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, :season_time, 0, 0, 0, 0, 0, 0, 0, 0, 0, :daily_time, 0,:update_time,0,0,0,0,0,0,0,0,0,0,0,0,0,:newInfo,0,0,0,0,0,0,0) ' .
' ON DUPLICATE KEY UPDATE accountid=:accountid, user_name=:user_name, avatar_url=:avatar_url, game_times=0, win_times=0, kills=0, harm=0, add_HP=0, alive_time=0, coin_num=0, integral=0, kill_his=0, alive_time_his=0, harm_his=0, add_HP_his=0, act_share_time=0, act_share_status=0, modify_time=:modify_time, first_fight=0, collect_status=0, keys_num=0, battle_re_times=0, shop_flush_times=0, kefu_status=0, sign_sum=0, box_num=0, diamond_num=0, sum_coin=0, pass_status=0, score=0, season_status=1, recharge_times_total=0, first_gift=0, season_time=:season_time, free_coin=0, free_diamond=0, season_end_score=0, kill_modifytime=0, win_modifytime=0, rank_modifytime=0, vip_score=0, first_login=0, daily_first_login=0, daily_time=:daily_time, free_box=0, update_time=:update_time, season_games=0, season_win=0, sea_max_kill=0, sea_max_hart=0, sea_avg_kill=0, free_lot_ticket=0, free_dou_lot_ticket=0, daily_order1=0, daily_order2=0, daily_order3=0, first_bee=0, newhand=0, coin_times=0, newInfo=:newInfo, first_day_ad=0, share_video_times=0, share_video_sums=0, act_video_status=0, act_ad_status=0, biogame_times=0, create_user=0;',
array(
':accountid' => $account_id,
':user_name' => $user_name,
@ -247,28 +249,11 @@ class RoleController{
'act_video_status' => 0,
'act_ad_status' => 0,
'biogame_times' => 0,
'user_name' => $user_name,
'avatar_url' => $avatar_url,
'create_user' => 0,
));
} else {
if ($avatar_url != '') {
if ($user_name != $row['user_name']) {
$ret = $conn->execScript('UPDATE user SET user_name=:user_name, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':user_name' => $user_name,
':modify_time' => time()
));
}
if ($avatar_url != $row['avatar_url']) {
$ret = $conn->execScript('UPDATE user SET avatar_url=:avatar_url, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':avatar_url' => $avatar_url,
':modify_time' => time()
));
}
}
$nowTime = phpcommon\getdayseconds(time());
$daily_first_login = $row['daily_first_login'];
$coin_times = $row['coin_times'];
@ -359,6 +344,9 @@ class RoleController{
'act_video_status' => $row['act_video_status'],
'act_ad_status' => $act_ad_status,
'biogame_times' => $row['biogame_times'],
'user_name' => $row['user_name'],
'avatar_url' => $row['avatar_url'],
'create_user' => $row['create_user'],
));
}
}
@ -630,7 +618,7 @@ class RoleController{
$rank = $_REQUEST['rank'];
$ar = $this->getRankReward($rank);
$coin_num = $ar['zbmode_param'];
$row = $conn->execQueryOne('SELECT daily_time, coin_num, biogame_times FROM user WHERE accountid=:accountid;',
$row = $conn->execQueryOne('SELECT daily_time, coin_num, biogame_times, game_times, integral FROM user WHERE accountid=:accountid;',
array(
':accountid' => $account_id
));
@ -652,7 +640,7 @@ class RoleController{
if ($daily_time == 0 || ($nowTime - phpcommon\getdayseconds($daily_time) > 0)) {
$daily_time = time();
}
$ret = $conn->execScript('UPDATE user SET coin_num=:coin_num, modify_time=:modify_time, daily_time=:daily_time, biogame_times=:biogame_times ' .
$ret = $conn->execScript('UPDATE user SET coin_num=:coin_num, modify_time=:modify_time, daily_time=:daily_time, biogame_times=:biogame_times, integral=:integral, game_times=:game_times, kill_modifytime=:kill_modifytime ' .
'WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
@ -660,14 +648,17 @@ class RoleController{
':modify_time' => time(),
':daily_time' => $daily_time,
':biogame_times' => $row['biogame_times'] + 1,
':integral' => $row['integral'] + 10,
':game_times' => $row['game_times'] + 1,
':kill_modifytime' => time(),
));
if (!$ret) {
die();
return;
}
//刷新任务
//$quest = new classes\Quest();
//$quest->triggerQuest(QUEST_DAY_FIGHT, 1, 1, $account_id);
$quest = new classes\Quest();
$quest->triggerQuest(QUEST_DAY_FIGHT, 1, 1, $account_id);
echo json_encode(array(
'errcode' => 0,

View File

@ -1,5 +1,6 @@
<?php
require '../config/config.php';
require 'bootstrap/init.php';
if (empty($_REQUEST['c']) || empty($_REQUEST['a'])) {

View File

@ -320,7 +320,7 @@ function isValidSessionId($account_id, $session_id)
}
if (SERVER_ENV == _ONLINE) {
$channel = extractChannel($account_id);
if ($channel == 6000) {
if ($channel == 6000 && !defined('ENABLE_6000_CHANNEL')) {
return false;
}
}