<?php
$host = '127.0.0.1';
$username = '';
$password = '';
$chinese_jobs = false; //are the jobs stored in chinese?
$count_gm_in_top = false; // Should GMs be counted in the Top 10 lists?
$guild_name_change_price = 100000; // the amount of money it should cost for a guild leader to change the guilds name
$servnam =' My Server';
$version =' V2.0';
$exp =' 20x'; //Server Experience
$drop =' 15x';
$online =' Online';
$connection = mssql_connect($host, $login, $password);
if(!$connection) {
die("Невозможно подключиться к базе данных!");
// This was needed since there are 2 used databases
function do_query($query,$database)
{
mssql_select_db($database) OR DIE("Can't find the database!!");
return mssql_query($query);
}
/*
Authenticates the cookies
Returns the accesslevel, or when one is not logged in -1
*/
function auth()
{
if(isset($_COOKIE['PKO_login']))
{
if(isset($_COOKIE['PKO_password']))
{
$login = $_COOKIE['PKO_login'];
$password = $_COOKIE['PKO_password'];
$result = do_query("SELECT * FROM account_login WHERE name LIKE '$login' AND password = '$password'","AccountServer");
if(mssql_num_rows($result) > 0)
{
$result = do_query("SELECT gm FROM account WHERE act_name LIKE '$login'","GameDB");
$gm_level = mssql_fetch_array($result);
$gm_level = $gm_level['gm'];
return $gm_level;
}
else
{
setcookie("PKO_login", $login, -time()+60*60*24*30);
setcookie("PKO_password",$pw, -time()+60*60*24*30);
$page = "<font color=\"red\">Your cookies are not correct! You've been trying to hack me!</font><br>
<a href=\"index.php\">Login</a>";
}
}
else
{
setcookie("PKO_login", $login, -time()+60*60*24*30);
setcookie("PKO_password",$pw, -time()+60*60*24*30);
$page = "<font color=\"red\">Your cookies are not correct! You've been trying to hack me!</font><br>
<a href=\"index.php\">Login</a>";
}
}
else
{
return -1;
}
}
/*
Returns the level that set for the given experience.
*/
function exp_to_lv($exp)
{
$file = fopen("exp.txt","r");
while(!feof($file))
{
$line = explode(";",fgets($file));
if($line[2] > $exp)
{
$level = $line[1] - 1;
break;
}
}
fclose($file);
return $level;
}
/*
Returns the english variant of the given chinese class.
*/
function zh_to_eng($zh_job,$zh_jobs)
{
if($zh_jobs === true)
{
$file = fopen("job.txt","r");
while(!feof($file))
{
$line = explode(";",fgets($file));
if($line[0] == $zh_job)
{
$job = $line[2];
break;
}
}
fclose($file);
if(isset($job))
{
return $job;}
else {
return $zh_job;}
}
else
return $zh_job;
}
/*
Retrurn either the englih or the chinese verion of the jobs ID
*/
function id_to_job($id,$zh_jobs)
{
$file = fopen("job.txt","r");
while(!feof($file))
{
$line = explode(";",fgets($file));
if($line[1] == $id)
{
$job = $line[0];
break;
}
}
fclose($file);
if(isset($job))
{
if($zh_jobs == true)
return $job;
else
{$job = zh_to_eng($job,true);
return $job;}
}
else {
return $id;}
}
/*
Returns the Chinese version of the given English job
*/
function eng_to_zh($eng_job,$zh_jobs)
{
if($zh_jobs === true)
{
$file = fopen("job.txt","r");
while(!feof($file))
{
$line = explode(";",fgets($file));
if(strcasecmp($line[2],$eng_job) == 2) // YOU MIGHT NEED TO CHANGE THIS!!!
{
$job = $line[0];
break;
}
}
fclose($file);
if(isset($job))
return $job;
else
return $eng_job;
}
else
return $eng_job;
}
function isalphanumeric($test) {
return !(preg_match("/[^a-z,A-Z,0-9]/", $test));
?>
Примечание:
Где собака зарыта =(