📄 create_role.php
字号:
<?php
set_time_limit(1800);
require_once("../functions/create_role_login.php");
//加载是否创建角色文件
require_once("../../interface/enter_game.php");
include_once("../configs/Configs.php");
/*开始创建角色start*/
if($_POST['action']=="role_register"){
//包含函数及配置文件
include_once("../functions/func_common.php");
//访问控制 - 非本域名无法提交数据
//include_once("../../functions/limit_access.php");
//判断验证码
//if(strtolower($_POST['txtCheckCode'])<>$_SESSION['verifycode']) echomsg("验证码输入错误!");
//if ($_POST['randid2']/$rand_passcode2>time() or $_POST['randid2']/$rand_passcode2+$rand_time<time()) echomsg("验证码已失效,请返回重新填写!");
//判断各值是否为空
$txtrolename=strtolower(trim($_POST["txtrolename"]));
$txtcityname=strtolower(trim($_POST["txtcityname"]));
$temp_country=rand(1,3);
$protect_date=$_POST['protect_date'];
$country=($_POST["country"]<>"") ? (int)($_POST["country"]) : $temp_country;
if($_POST["country"]<>"1" and $_POST["country"]<>"2" and $_POST["country"]<>"3") echomsg("你还没有选择国家!","?");
if($_POST['sex']=="0") $head_img=$_POST["player_head_img_0"];
else $head_img=$_POST["player_head_img_1"];
//$head_img=($_POST["player_head_img"]<>"") ? $_POST["player_head_img"] :"1";
//echo $head_img;exit;
//判断各项值的输入规范
if(strlen($txtrolename)<2 or strlen($txtrolename)>12 or strlen($txtcityname)<2 or strlen($txtcityname)>12) echomsg("君主名称或首都名称长度不正确!");
$char_limit=array("@","$","%","&",".","。",",",",","#","/","|","pp360","pp","<? echo $webgamesitename; ?>","逐鹿客服","逐鹿GM","逐鹿","游戏客服","GM","管理员","系统","AV","AV女优","av","鸡8","操逼","骚女","召妓","迷奸","妈B","操B","干B","日B","共产","法轮","中共","中央","台独","藏独");
foreach ($char_limit as $m){
if(strstr($txtrolename,$m)) echomsg("君主名称格式错误,请重新输入!");
if(strstr($txtcityname,$m)) echomsg("首都名称格式错误,请重新输入!");
}
if($txtrolename==$txtcityname) echomsg("君主名称与首都名称不能相同!");
//加载数据库类文件
include_once("../functions/class_mysql.php");
//判断君主名称和首都名称是否已经存在////////////////////////////////////////////////////////////////////////////
$check_query=$db->query("(select count(p_nickname) from player_info where `p_nickname`='".$txtrolename."' or `p_nickname`='".$txtcityname."')
union (select count(c_name) from city where `c_name`='".$txtrolename."' or `c_name`='".$txtcityname."') ");
$check_result=$db->result($check_query,0);
$check_city_query=$db->query("select c_id from city where c_name='".$txtcityname."';");
$check_list_city_num=$db->num_rows($check_city_query);
if ($check_list_city_num>0) echomsg("首都名己存在!");
$check_nickname_query=$db->query("select p_id from player_info where p_nickname='".$txtrolename."';");
$check_list_nickname_num=$db->num_rows($check_nickname_query);
if ($check_list_nickname_num>0) echomsg("君主名己存在!");
if($check_result>0) echomsg("君主或首都名称已存在,不能使用,请重新创建!");else{
//$area_min=1;$area_max=80;
//$area_x_min=1;$area_x_max=80;
//$area_y_min=1;$area_y_max=80;
//获取城市坐标开始//////////////////////////////////////////////////////////////
while(1){
$city_area=rand($area_min,$area_max);
$area_x=rand($area_x_min,$area_x_max);
$query=$db->query("select area from city_area where `area`='".$city_area."' and `area_x`='".$area_x."'");
$area_result = $db->num_rows($query);
$x=$city_area;$y=$area_x;
$sum=0;
if(($x-3)<$area_x_min){
$x_min=$area_x_max-3+$x;
}else{
$x_min = $x-3;
}
if(($x+3)>$area_x_max){
$x_max=(3+$x)-$area_x_max;
}else{
$x_max = $x+3;
}
if(($y-3)<$area_y_min){
$y_min=$area_y_max-3+$y;
}else{
$y_min = $y-3;
}
if(($y+3)>$area_y_max){
$y_max=(3+$y)-$area_y_max;
}else{
$y_max = $y+3;
}
//echo $x_min."|".$x_max."|".$y_min."|".$y_max;exit;
for($i=$x_min;$i<=$x_max;$i++)
{
for($j=$y_min;$j<=$y_max;$j++)
{
//查询该坐标上是否有玩家,没有数组数为0,有为1;
$query=$db->query("select * from city_area where `area`='".$i."' and `area_x`='".$j."';");
$mxs_num=$db->num_rows($query);
if($mxs_num=="1")
{
$sum=$sum+1;
}
}
}
if(!$area_result and $sum<10){
break;
}
}
/*
while(1){
$city_area=rand($area_min,$area_max);
$area_x=rand($area_x_min,$area_x_max);
$query=$db->query("select area from city_area where `area`='".$city_area."' and `area_x`='".$area_x."'");
$area_result = $db->num_rows($query);
if(!$area_result['area']){
break;
}
}
*/
//插入城池坐标
$query_city_area=$db->query("insert into city_area(`id`,`area`,`area_x`) values('','".$city_area."','".$area_x."') ");
//-----------------------------初始化数据------------------------------------------------------------------------------
//玩家基本信息(player_info)
$query_player_info=$db->query("insert into player_info(`p_id`,`u_id`,`p_nickname`,`p_country`,`p_score`,`p_citys`,`p_head_img`,`protect_date`,`sex`,`create_date`)
values('','".$_COOKIE["UserId"]."','".$txtrolename."','".$country."','".$p_score."','1','".$head_img."','".$protect_date."','".$_POST['sex']."', '".time()."') ");
$p_id=$db->insert_id();//玩家索引ID
//玩家城市信息(city)
$city_land_type = rand(1,5);
$query_city_info=$db->query("insert into city(`c_id`,`u_id`,`c_name`,`c_population`,`c_area`,`c_area_x`,`c_area_y`,`total_hills`,`free_hills`,`total_woodlands`,`free_woodlands`,`total_flats`,`free_flats`,`total_barracks`,`free_barracks`,`total_house`,`free_house`,`c_img`,`c_size`,`c_total_size`,`c_land_type`,`c_type`,`create_date`)
values('','".$_COOKIE["UserId"]."','".$txtcityname."','".$c_population_init."','".$city_area."','".$area_x."','0','".$free_hills_init."','".$grow_use_hills."','".$free_woodlands_init."','".$grow_use_woodlands."','".$free_flats_init."','".$grow_use_flats."','".$total_barracks_init."','".$free_barracks_init."',
'".$total_house_init."','".$free_house_init."','1','".$city_size."','".$city_size."', '".$city_land_type."', '1','".time()."') ");
$city_id=$db->insert_id();
//初始化总资源(resource)
$free_stores=$woods+$ores+$rices+$golds;
$query_total=$db->query("insert into resource(`r_id`,`u_id`,`c_id`,`total_stores`,`free_stores`,`total_house`,`free_house`,`woods`,`rices`,`ores`,`golds`,`woods_uplimit`,`rices_uplimit`,`ores_uplimit`,`golds_uplimit`)
values('','".$_COOKIE['UserId']."','".$city_id."','".$total_stores_init."','".$free_stores."','0','0','".$woods."','".$rices."','".$ores."','".$golds."','".$woods_uplimit."' ,'".$rices_uplimit."' ,'".$irons_uplimit."' ,'".$golds_uplimit."')");
//各建筑物的初始值(building)
$query_building=$db->query("insert into building(`b_id`,`u_id`,`c_id`,`b_iron_ore`,`b_gold_ore`,`b_cutting`,`b_farm`,`b_house`,`b_work_house`,`b_barracks`,`b_horse`,`b_pub`,`b_store`,`b_college`,`b_city_wall`,`b_citywall_fy`,`b_city_upgrade`)
values('','".$_COOKIE['UserId']."','".$city_id."','".$b_iron_ore."','".$b_gold_ore."','".$b_cutting."','".$b_farm."','".$b_house."','".$b_barracks."','".$b_soldiers."','".$b_horse."','".$b_pub."','".$b_store."','".$b_college."','".$b_city_wall."','".$b_city_fy."','".$b_city_upgrade."')");
//初始生产安排表
for($i=1;$i<=4;$i++){
$query_produce_info=$db->query("insert into resource_grow(`id`,`u_id`,`c_id`,`b_type`,`last_grow_time`,`worker_percent`,`true_workers`,`total_grow`) values('','".$_COOKIE['UserId']."','".$city_id."','".$i."','".time()."','100','0','0')");
}
//初始研究数据
$query_study=$db->query("insert into study(`id`,`u_id`,`c_id`) values('','".$_COOKIE['UserId']."','".$city_id."')");
//更新登录IP
$db->query("update player_info set `login_ip`='".$_SERVER['REMOTE_ADDR']."',`login_time`='".time()."',`online`='1' where `u_id`='".$_COOKIE["UserId"]."'");
//系统消息
$db->query("INSERT INTO `e_mail` ( `id` , `e_name` , `e_username` , `e_title` , `e_text` , `e_times` , `e_read` , `e_type` )
VALUES ('', '系统消息', '".$txtrolename."', '<? echo $webgamesitename; ?>欢迎您', '欢迎您来到<? echo $webgamesitename; ?>,祝你游戏愉快!', '".time()."', '0', '2');");
$db->close();
//记录COOKIE值
setcookie("NickName",$txtrolename,time()+$cookie_times,"/");
setcookie("CityName",$txtcityname,time()+$cookie_times,"/");
setcookie("CityId",$city_id,time()+$cookie_times,"/");
setcookie("CityArea",$city_area."|".$area_x,time()+$cookie_times,"/");
setcookie("Country",$country,time()+$cookie_times,"/");
$_COOKIE["NickName"]=$txtrolename;
$_COOKIE["CityId"]=$city_id;
$_COOKIE["CityArea"]=$city_area."|".$area_x;
$_COOKIE["Country"]=$country;
echomsg("","../?SessionId=".md5($login_md5_chars));
}
//结束创建
}
//获取验证码初始值
$randid=$rand_passcode1;
$thistime=time()*$rand_passcode2;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title><?php if($_GET['country']<>"") echo "角色创建";else echo "选择国家";?> - <? echo $webgamesitename; ?>网页游戏webgame</title>
<link href="../css/id.css" rel="stylesheet" type="text/css">
<link href="../css/css.css" rel="stylesheet" type="text/css">
<link href="../css/login.css" rel="stylesheet" type="text/css">
<link href="../css/styles.css" rel="stylesheet" type="text/css" />
<link href="../css/register.css" rel="stylesheet" type="text/css" />
</head>
<body>
<script language="javascript">
function killErrors()
{
return true;
}
window.onerror = killErrors;
</script>
<script language="javascript" type="text/javascript" src="../js/form_createrole_validator.js"></script>
<script language="javascript" type="text/javascript" src="../js/xmlhttprequest.js"></script>
<script language="javascript" type="text/javascript" src="../js/create_role_init.js"></script>
<script language="javascript" type="text/javascript" src="../js/create_role_passcode.js"></script>
<script>
//选择头像
<?php
$dir = "../img/header_0/";
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
$counter = 0;
while (($file = readdir($dh)) !== false) {
//echo "filename: $file : filetype: " . filetype($dir . $file) . "\n";
$counter++;
}
closedir($dh);
}
}
$counter = $counter -2;
?>
var CivilPic = new Array(<?php echo $counter;?>);
for(var i=0; i<<?php echo $counter;?>; i++)
{
CivilPic[i] = new Image();
var paths="../img/header_0/";
//alert(paths);
CivilPic[i].src = paths + (i+1) + ".jpg";
}
//头像提示
var CivilHint = new Array(<?php echo $counter;?>);
for(i=0;i<=<?php echo $counter;?>;i++){
CivilHint[i] = "法师";//法师
}
function changeHead_img0(obj)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -