mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-07-05 12:24:20 +00:00
first commit
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
#################################################################################
|
||||
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
|
||||
## --------------------------------------------------------------------------- ##
|
||||
## Filename addTroops.php ##
|
||||
## Developed by: Dzoki & Advocatie ##
|
||||
## License: TravianX Project ##
|
||||
## Thanks to: Dzoki & itay2277 (edit troops) ##
|
||||
## Copyright: TravianX (c) 2010-2011. All rights reserved. ##
|
||||
## ##
|
||||
#################################################################################
|
||||
|
||||
include_once("../../Account.php");
|
||||
|
||||
mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS);
|
||||
mysql_select_db(SQL_DB);
|
||||
|
||||
if ($session->access < ADMIN) die("Access Denied: You are not Admin!");
|
||||
|
||||
$id = $_POST['id'];
|
||||
$village = $database->getVillage($id);
|
||||
$user = $database->getUserArray($village['owner'],1);
|
||||
$coor = $database->getCoor($village['wref']);
|
||||
$varray = $database->getProfileVillages($village['owner']);
|
||||
$type = $database->getVillageType($village['wref']);
|
||||
$fdata = $database->getResourceLevel($village['wref']);
|
||||
$units = $database->getUnit($village['wref']);
|
||||
|
||||
$u1 = $_POST['u1'];
|
||||
$u2 = $_POST['u2'];
|
||||
$u3 = $_POST['u3'];
|
||||
$u4 = $_POST['u4'];
|
||||
$u5 = $_POST['u5'];
|
||||
$u6 = $_POST['u6'];
|
||||
$u7 = $_POST['u7'];
|
||||
$u8 = $_POST['u8'];
|
||||
$u9 = $_POST['u9'];
|
||||
$u10 = $_POST['u10'];
|
||||
////////////////////
|
||||
$u11 = $_POST['u11'];
|
||||
$u12 = $_POST['u12'];
|
||||
$u13 = $_POST['u13'];
|
||||
$u14 = $_POST['u14'];
|
||||
$u15 = $_POST['u15'];
|
||||
$u16 = $_POST['u16'];
|
||||
$u17 = $_POST['u17'];
|
||||
$u18 = $_POST['u18'];
|
||||
$u19 = $_POST['u19'];
|
||||
$u20 = $_POST['u20'];
|
||||
////////////////////
|
||||
$u21 = $_POST['u21'];
|
||||
$u22 = $_POST['u22'];
|
||||
$u23 = $_POST['u23'];
|
||||
$u24 = $_POST['u24'];
|
||||
$u25 = $_POST['u25'];
|
||||
$u26 = $_POST['u26'];
|
||||
$u27 = $_POST['u27'];
|
||||
$u28 = $_POST['u28'];
|
||||
$u29 = $_POST['u29'];
|
||||
$u30 = $_POST['u30'];
|
||||
////////////////////
|
||||
$u31 = $_POST['u31'];
|
||||
$u32 = $_POST['u32'];
|
||||
$u33 = $_POST['u33'];
|
||||
$u34 = $_POST['u34'];
|
||||
$u35 = $_POST['u35'];
|
||||
$u36 = $_POST['u36'];
|
||||
$u37 = $_POST['u37'];
|
||||
$u38 = $_POST['u38'];
|
||||
$u39 = $_POST['u39'];
|
||||
$u40 = $_POST['u40'];
|
||||
////////////////////
|
||||
$u41 = $_POST['u41'];
|
||||
$u42 = $_POST['u42'];
|
||||
$u43 = $_POST['u43'];
|
||||
$u44 = $_POST['u44'];
|
||||
$u45 = $_POST['u45'];
|
||||
$u46 = $_POST['u46'];
|
||||
$u47 = $_POST['u47'];
|
||||
$u48 = $_POST['u48'];
|
||||
$u49 = $_POST['u49'];
|
||||
$u50 = $_POST['u50'];
|
||||
|
||||
if($user['tribe'] == 1){
|
||||
$q = "UPDATE ".TB_PREFIX."units SET u1 = $u1, u2 = $u2, u3 = $u3, u4 = $u4, u5 = $u5, u6 = $u6, u7 = $u7, u8 = $u8, u9 = $u9, u10 = $u10 WHERE vref = $id";
|
||||
mysql_query($q);
|
||||
} else if($user['tribe'] == 2){
|
||||
$q = "UPDATE ".TB_PREFIX."units SET u11 = '$u11', u12 = '$u12', u13 = '$u13', u14 = '$u14', u15 = '$u15', u16 = '$u16', u17 = '$u17', u18 = '$u18', u19 = '$u19', u20 = '$u20' WHERE vref = $id";
|
||||
mysql_query($q);
|
||||
} else if($user['tribe'] == 3){
|
||||
$q = "UPDATE ".TB_PREFIX."units SET u21 = '$u21', u22 = '$u22', u23 = '$u23', u24 = '$u24', u25 = '$u25', u26 = '$u26', u27 = '$u27', u28 = '$u28', u29 = '$u29', u30 = '$u30' WHERE vref = $id";
|
||||
mysql_query($q);
|
||||
} else if($user['tribe'] == 4){
|
||||
$q = "UPDATE ".TB_PREFIX."units SET u31 = '$u31', u32 = '$u32', u33 = '$u33', u34 = '$u34', u35 = '$u35', u36 = '$u36', u37 = '$u37', u38 = '$u38', u39 = '$u39', u40 = '$u40' WHERE vref = $id";
|
||||
mysql_query($q);
|
||||
} else if($user['tribe'] == 5){
|
||||
$q = "UPDATE ".TB_PREFIX."units SET u41 = '$u41', u42 = '$u42', u43 = '$u43', u44 = '$u44', u45 = '$u45', u46 = '$u46', u47 = '$u47', u48 = '$u48', u49 = '$u49', u50 = '$u50' WHERE vref = $id";
|
||||
mysql_query($q);
|
||||
}
|
||||
|
||||
mysql_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Changed troop anmount in village <a href=\'admin.php?p=village&did=$id\'>$id</a> ',".time().")");
|
||||
|
||||
header("Location: ../../../Admin/admin.php?p=addTroops&did=".$id."&d");
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
#################################################################################
|
||||
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
|
||||
## --------------------------------------------------------------------------- ##
|
||||
## Filename gold.php ##
|
||||
## Developed by: Dzoki ##
|
||||
## License: TravianX Project ##
|
||||
## Copyright: TravianX (c) 2010-2011. All rights reserved. ##
|
||||
## ##
|
||||
#################################################################################
|
||||
include_once("../../Account.php");
|
||||
mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS);
|
||||
mysql_select_db(SQL_DB);
|
||||
if ($session->access < ADMIN) die("Access Denied: You are not Admin!");
|
||||
|
||||
$id = $_POST['id'];
|
||||
$admid = $_POST['admid'];
|
||||
mysql_query("UPDATE ".TB_PREFIX."users SET cp = cp + ".$_POST['cp']." WHERE id = ".$id."");
|
||||
|
||||
$name = $database->getUserField($id,"username",0);
|
||||
mysql_query("Insert into ".TB_PREFIX."admin_log values (0,$admid,'Added ".$_POST['cp']." Cultural Points to user <a href=\'admin.php?p=player&uid=$id\'>$name</a> ',".time().")");
|
||||
|
||||
header("Location: ../../../Admin/admin.php?p=player&uid=".$id."&cp=ok");
|
||||
?>
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
#################################################################################
|
||||
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
|
||||
## --------------------------------------------------------------------------- ##
|
||||
## Filename editUser.php ##
|
||||
## Developed by: Dzoki ##
|
||||
## License: TravianX Project ##
|
||||
## Copyright: TravianX (c) 2010-2011. All rights reserved. ##
|
||||
## ##
|
||||
#################################################################################
|
||||
include_once("../../Account.php");
|
||||
mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS);
|
||||
mysql_select_db(SQL_DB);
|
||||
if ($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!");
|
||||
|
||||
$id = $_POST['id'];
|
||||
$user = $database->getUserArray($id,1);
|
||||
mysql_query("UPDATE ".TB_PREFIX."users SET email = '".$_POST['email']."', tribe = ".$_POST['tribe'].", location = '".$_POST['location']."', desc1 = '".$_POST['desc1']."', `desc2` = '".$_POST['desc2']."' WHERE id = ".$_POST['id']."");
|
||||
mysql_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Changed <a href=\'admin.php?p=village&did=$id\'>".$user['username']."</a>\'s profile',".time().")");
|
||||
|
||||
|
||||
header("Location: ../../../Admin/admin.php?p=player&uid=".$id."");
|
||||
?>
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
#################################################################################
|
||||
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
|
||||
## --------------------------------------------------------------------------- ##
|
||||
## Filename gold.php ##
|
||||
## Developed by: Dzoki ##
|
||||
## License: TravianX Project ##
|
||||
## Copyright: TravianX (c) 2010-2011. All rights reserved. ##
|
||||
## ##
|
||||
#################################################################################
|
||||
include_once("../../Account.php");
|
||||
mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS);
|
||||
mysql_select_db(SQL_DB);
|
||||
if ($session->access < ADMIN) die("Access Denied: You are not Admin!");
|
||||
|
||||
$id = $_POST['id'];
|
||||
$gold = $_POST['gold'];
|
||||
|
||||
$q = "UPDATE ".TB_PREFIX."users SET gold = gold + ".$_POST['gold']." WHERE id != '0'";
|
||||
mysql_query($q);
|
||||
mysql_query("Insert into ".TB_PREFIX."admin_log values (0,$id,'Added <b>$gold</b> gold to all users',".time().")");
|
||||
|
||||
|
||||
header("Location: ../../../Admin/admin.php?p=gold&g");
|
||||
?>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
#################################################################################
|
||||
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
|
||||
## --------------------------------------------------------------------------- ##
|
||||
## Filename gold_1.php ##
|
||||
## Developed by: Dzoki ##
|
||||
## License: TravianX Project ##
|
||||
## Copyright: TravianX (c) 2010-2011. All rights reserved. ##
|
||||
## ##
|
||||
#################################################################################
|
||||
include_once("../../Account.php");
|
||||
mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS);
|
||||
mysql_select_db(SQL_DB);
|
||||
if ($session->access < ADMIN) die("Access Denied: You are not Admin!");
|
||||
|
||||
$id = $_POST['id'];
|
||||
$admid = $_POST['admid'];
|
||||
mysql_query("UPDATE ".TB_PREFIX."users SET gold = gold + ".$_POST['gold']." WHERE id = ".$id."");
|
||||
|
||||
$name = $database->getUserField($id,"username",0);
|
||||
mysql_query("Insert into ".TB_PREFIX."admin_log values (0,$admid,'Added <b>".$_POST['gold']."</b> gold to user <a href=\'admin.php?p=player&uid=$id\'>$name</a> ',".time().")");
|
||||
|
||||
header("Location: ../../../Admin/admin.php?p=player&uid=".$id."&g=ok");
|
||||
?>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
#################################################################################
|
||||
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
|
||||
## --------------------------------------------------------------------------- ##
|
||||
## Filename gold.php ##
|
||||
## Developed by: Dzoki ##
|
||||
## License: TravianX Project ##
|
||||
## Copyright: TravianX (c) 2010-2011. All rights reserved. ##
|
||||
## ##
|
||||
#################################################################################
|
||||
include_once("../../Session.php");
|
||||
mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS);
|
||||
mysql_select_db(SQL_DB);
|
||||
if ($session->access < ADMIN) die("Access Denied: You are not Admin!");
|
||||
|
||||
$id = $_POST['id'];
|
||||
$amt = $_POST['vill_amount'];
|
||||
|
||||
for($i=1;$i<=$amt;$i++) {
|
||||
|
||||
$kid = rand(1,4);
|
||||
|
||||
$wid = $database->generateBase($kid);
|
||||
$database->setFieldTaken($wid);
|
||||
$time = time();
|
||||
$q = "insert into `s1_vdata`(`wref`,`owner`,`name`,`capital`,`pop`,`cp`,`celebration`,`type`,`wood`,`clay`,`iron`,`maxstore`,`crop`,`maxcrop`,`lastupdate`,`loyalty`,`exp1`,`exp2`,`exp3`,`created`) values ('$wid','3','World Wonder',0,233,232,0,0,80000.00,80000.00,80000.00,80000,80000.00,80000,1314974534,100,0,0,0,1314968914)";
|
||||
mysql_query($q) or die(mysql_error());
|
||||
$q = "insert into ".TB_PREFIX."fdata (`vref`,`f1`,`f1t`,`f2`,`f2t`,`f3`,`f3t`,`f4`,`f4t`,`f5`,`f5t`,`f6`,`f6t`,`f7`,`f7t`,`f8`,`f8t`,`f9`,`f9t`,`f10`,`f10t`,`f11`,`f11t`,`f12`,`f12t`,`f13`,`f13t`,`f14`,`f14t`,`f15`,`f15t`,`f16`,`f16t`,`f17`,`f17t`,`f18`,`f18t`,`f19`,`f19t`,`f20`,`f20t`,`f21`,`f21t`,`f22`,`f22t`,`f23`,`f23t`,`f24`,`f24t`,`f25`,`f25t`,`f26`,`f26t`,`f27`,`f27t`,`f28`,`f28t`,`f29`,`f29t`,`f30`,`f30t`,`f31`,`f31t`,`f32`,`f32t`,`f33`,`f33t`,`f34`,`f34t`,`f35`,`f35t`,`f36`,`f36t`,`f37`,`f37t`,`f38`,`f38t`,`f39`,`f39t`,`f40`,`f40t`,`f99`,`f99t`,`wwname`) values ($wid,0,1,0,4,0,1,0,3,0,2,0,2,0,3,0,4,0,4,0,3,0,3,0,4,0,4,0,1,0,4,0,2,0,1,0,2,20,17,20,11,20,15,20,10,10,22,10,25,0,0,0,0,10,19,0,0,0,0,0,0,10,23,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,16,0,0,1,40,'World Wonder')";
|
||||
mysql_query($q);
|
||||
$database->addUnits($wid);
|
||||
$database->addTech($wid);
|
||||
$database->addABTech($wid);
|
||||
$q = "UPDATE ".TB_PREFIX."units SET u41 = u41 + '150000', u42 = u42 + '150000', u43 = u43 + '150000', u44 = u44 + '150000', u45 = u45 + '150000', u46 = u46 + '150000', u47 = u47 + '150000', u48 = u48 + '150000' , u49 = u49 + '150000', u50 = u50 + '150000' WHERE vref = '".$wid."'";
|
||||
mysql_query($q);
|
||||
}
|
||||
|
||||
|
||||
mysql_query("Insert into ".TB_PREFIX."admin_log values (0,$id,'Added <b>$amt</b> WW Villages',".time().")");
|
||||
|
||||
|
||||
header("Location: ../../../Admin/admin.php?p=natarend&g");
|
||||
?>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<dwsync>
|
||||
<file name="userCount.php" server="D:/wamp/www/New/" local="129157402737451172" remote="129157402730000000" />
|
||||
</dwsync>
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
#################################################################################
|
||||
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
|
||||
## --------------------------------------------------------------------------- ##
|
||||
## Filename admin.php ##
|
||||
## Developed by: Dzoki ##
|
||||
## License: TravianX Project ##
|
||||
## Copyright: TravianX (c) 2010-2011. All rights reserved. ##
|
||||
## ##
|
||||
#################################################################################
|
||||
session_start();
|
||||
include("../GameEngine/Database.php");
|
||||
include("../GameEngine/Admin/database.php");
|
||||
?>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<link REL="shortcut icon" HREF="favicon.ico"/>
|
||||
<title>Admin Control Panel - TravianX</title>
|
||||
<link rel=stylesheet type="text/css" href="../img/admin/admin.css">
|
||||
<link rel=stylesheet type="text/css" href="../img/admin/acp.css">
|
||||
<link rel=stylesheet type="text/css" href="../img/../img.css">
|
||||
<script src="mt-full.js?423cb" type="text/javascript"></script>
|
||||
<script src="ajax.js" type="text/javascript"></script>
|
||||
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<meta http-equiv="imagetoolbar" content="no">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script language="javascript">
|
||||
function aktiv() {this.srcElement.className='fl1'; }
|
||||
function inaktiv() {event.srcElement.className='fl2'; }
|
||||
|
||||
function del(e,id){
|
||||
if(e == 'did'){ var conf = confirm('Dou you really want delete village id '+id+'?'); }
|
||||
if(e == 'unban'){ var conf = confirm('Dou you really want unban player '+id+'?'); }
|
||||
if(e == 'stopDel'){ var conf = confirm('Dou you really want stop deleting user '+id+'?'); }
|
||||
if(conf){return true;}else{return false;}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<div id="ltop1">
|
||||
<div style="position:relative; width:231px; height:100px; float:left;">
|
||||
<img src="../img/x.gif" width="1" height="1">
|
||||
</div>
|
||||
<img class="fl2" src="../img/admin/x1.gif" width="70" height="100" border="0" onmouseover="this.className='fl1'" onmouseout="this.className='fl2'"><img class="fl2" src="../img/admin/x2.gif" width="70" height="100" border="0" onmouseover="this.className='fl1'" onmouseout="this.className='fl2'"><img class="fl2" src="../img/admin/x3.gif" width="70" height="100" border="0" onmouseover="this.className='fl1'" onmouseout="this.className='fl2'"><img class="fl2" src="../img/admin/x4.gif" width="70" height="100" border="0" onmouseover="this.className='fl1'" onmouseout="this.className='fl2'"><img class="fl2" src="../img/admin/x5.gif" width="70" height="100" border="0" onmouseover="this.className='fl1'" onmouseout="this.className='fl2'"></div>
|
||||
|
||||
<div id="lmidall">
|
||||
<div id="lmidlc">
|
||||
<div id="lleft">
|
||||
<a href="index.php"><img src="../img/en/a/travian0.gif" class="logo_plus" width="116" height="60" border="0"></a>
|
||||
|
||||
<table id="navi_table" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td class="menu">
|
||||
<?php
|
||||
if($funct->CheckLogin()){?>
|
||||
<a href="admin.php">ACP Home</a>
|
||||
|
||||
<a href="<?php echo HOMEPAGE; ?>">Homepage</a>
|
||||
|
||||
<a href="#"></a><a href="#"></a>
|
||||
|
||||
<a href="?p=server_info">Server Info</a>
|
||||
<a href="?p=online">Online users</a>
|
||||
<a href="?p=search">Search</a>
|
||||
<a href="?p=message">Msg/Rep</a>
|
||||
<a href="?p=ban">Ban</a>
|
||||
<a href="?p=config">Config</a>
|
||||
<a href="?p=config_editor">Config Editor</a>
|
||||
|
||||
<a href="#"></a><a href="#"></a><a href="#"></a>
|
||||
<a href="?action=logout">Logout</a>
|
||||
<?php }?>
|
||||
</td>
|
||||
</tr>
|
||||
</table></div>
|
||||
<div id="lmid1">
|
||||
<div id="lmid3">
|
||||
|
||||
<?php
|
||||
|
||||
if($funct->CheckLogin()){
|
||||
if($_POST or $_GET){
|
||||
if($_GET['p'] and $_GET['p']!="search"){
|
||||
$filename = '../Templates/Admin/'.$_GET['p'].'.tpl';
|
||||
if(file_exists($filename)){
|
||||
include($filename);
|
||||
}else{
|
||||
include('../Templates/Admin/404.tpl');
|
||||
}
|
||||
}else{
|
||||
include('../Templates/Admin/search.tpl');
|
||||
}
|
||||
if($_POST['p'] and $_POST['s']){
|
||||
$filename = '../Templates/Admin/results_'.$_POST['p'].'.tpl';
|
||||
if(file_exists($filename)){
|
||||
include($filename);
|
||||
}else{
|
||||
include('../Templates/Admin/404.tpl');
|
||||
}
|
||||
}
|
||||
}else{
|
||||
include('../Templates/Admin/home.tpl');
|
||||
}
|
||||
}else{
|
||||
@@ -0,0 +1,70 @@
|
||||
var http_request = false;
|
||||
|
||||
function macheRequest(url, id)
|
||||
{
|
||||
|
||||
http_request = false;
|
||||
|
||||
if (window.XMLHttpRequest)
|
||||
{ // Mozilla, Safari,...
|
||||
http_request = new XMLHttpRequest();
|
||||
if (http_request.overrideMimeType)
|
||||
{
|
||||
http_request.overrideMimeType('text/xml');
|
||||
// zu dieser Zeile siehe weiter unten
|
||||
}
|
||||
}
|
||||
else if (window.ActiveXObject)
|
||||
{ // IE
|
||||
try
|
||||
{
|
||||
http_request = new ActiveXObject("Msxml2.XMLHTTP");
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
try
|
||||
{
|
||||
http_request = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!http_request)
|
||||
{
|
||||
alert('Ende :( Kann keine XMLHTTP-Instanz erzeugen');
|
||||
return false;
|
||||
}
|
||||
http_request.onreadystatechange = function()
|
||||
{
|
||||
alertInhalt2(id);
|
||||
};
|
||||
http_request.open('GET', url, true);
|
||||
http_request.send(null);
|
||||
|
||||
}
|
||||
|
||||
function alertInhalt2(id)
|
||||
{
|
||||
|
||||
if (http_request.readyState == 4)
|
||||
{
|
||||
if (http_request.status == 200)
|
||||
{
|
||||
// alert(http_request.responseText);
|
||||
myElement = document.getElementById(id);
|
||||
if (myElement != null)
|
||||
{
|
||||
myElement.innerHTML = http_request.responseText;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
alert('Bei dem Request ist ein Problem aufgetreten.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,309 @@
|
||||
<?php
|
||||
#################################################################################
|
||||
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
|
||||
## --------------------------------------------------------------------------- ##
|
||||
## Filename database.php ##
|
||||
## Developed by: Dzoki ##
|
||||
## License: TravianX Project ##
|
||||
## Copyright: TravianX (c) 2010-2011. All rights reserved. ##
|
||||
## ##
|
||||
#################################################################################
|
||||
|
||||
include("../GameEngine/config.php");
|
||||
include("../GameEngine/Data/buidata.php");
|
||||
|
||||
class adm_DB {
|
||||
var $connection;
|
||||
|
||||
function adm_DB(){
|
||||
global $database;
|
||||
$this->connection = mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS) or die(mysql_error());
|
||||
mysql_select_db(SQL_DB, $this->connection) or die(mysql_error());
|
||||
}
|
||||
|
||||
function Login($username,$password) {
|
||||
$q = "SELECT password FROM ".TB_PREFIX."users where username = '$username' and access >= ".MULTIHUNTER;
|
||||
$result = mysql_query($q, $this->connection);
|
||||
$dbarray = mysql_fetch_array($result);
|
||||
if($dbarray['password'] == md5($password)) {
|
||||
mysql_query("Insert into ".TB_PREFIX."admin_log values (0,'X','$username logged in (IP: <b>".$_SERVER['REMOTE_ADDR']."</b>)',".time().")");
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
mysql_query("Insert into ".TB_PREFIX."admin_log values (0,'X','<font color=\'red\'><b>IP: ".$_SERVER['REMOTE_ADDR']." tried to log in with username <u> $username</u> but access was denied!</font></b>',".time().")");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function recountPopUser($uid){
|
||||
global $database;
|
||||
$villages = $database->getProfileVillages($uid);
|
||||
for ($i = 0; $i <= count($villages)-1; $i++) {
|
||||
$vid = $villages[$i]['wref'];
|
||||
$this->recountPop($vid);
|
||||
}
|
||||
}
|
||||
|
||||
function recountPop($vid){
|
||||
global $database;
|
||||
$fdata = $database->getResourceLevel($vid);
|
||||
$popTot = 0;
|
||||
for ($i = 1; $i <= 40; $i++) {
|
||||
$lvl = $fdata["f".$i];
|
||||
$building = $fdata["f".$i."t"];
|
||||
if($building){
|
||||
$popTot += $this->buildingPOP($building,$lvl);
|
||||
}
|
||||
}
|
||||
$q = "UPDATE ".TB_PREFIX."vdata set pop = $popTot where wref = $vid";
|
||||
mysql_query($q, $this->connection);
|
||||
}
|
||||
|
||||
function buildingPOP($f,$lvl){
|
||||
$name = "bid".$f;
|
||||
global $$name;
|
||||
$popT = 0;
|
||||
$dataarray = $$name;
|
||||
for ($i = 0; $i <= $lvl; $i++) {
|
||||
$popT += $dataarray[$i]['pop'];
|
||||
}
|
||||
return $popT;
|
||||
}
|
||||
|
||||
function getWref($x,$y) {
|
||||
$q = "SELECT id FROM ".TB_PREFIX."wdata where x = $x and y = $y";
|
||||
$result = mysql_query($q, $this->connection);
|
||||
$r = mysql_fetch_array($result);
|
||||
return $r['id'];
|
||||
}
|
||||
|
||||
function AddVillage($post){
|
||||
global $database;
|
||||
$wid = $this->getWref($post['x'],$post['y']);
|
||||
$uid = $post['uid'];
|
||||
$status = $database->getVillageState($wid);
|
||||
$status = 0;
|
||||
if($status == 0){
|
||||
mysql_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Added new village <b><a href=\'admin.php?p=village&did=$wid\'>$wid</a></b> to user <b><a href=\'admin.php?p=player&uid=$uid\'>$uid</a></b>',".time().")");
|
||||
$database->setFieldTaken($wid);
|
||||
$database->addVillage($wid,$uid,'new village','0');
|
||||
$database->addResourceFields($wid,$database->getVillageType($wid));
|
||||
$database->addUnits($wid);
|
||||
$database->addTech($wid);
|
||||
$database->addABTech($wid);
|
||||
}
|
||||
}
|
||||
|
||||
function Punish($post){
|
||||
global $database;
|
||||
$villages = $database->getProfileVillages($post['uid']);
|
||||
$admid = $post['admid'];
|
||||
$user = $database->getUserArray($post['uid'],1);
|
||||
for ($i = 0; $i <= count($villages)-1; $i++) {
|
||||
$vid = $villages[$i]['wref'];
|
||||
if($post['punish']){
|
||||
$popOld = $villages[$i]['pop'];
|
||||
$proc = 100-$post['punish'];
|
||||
$pop = floor(($popOld/100)*($proc));
|
||||
if($pop <= 1 ){$pop = 2;}
|
||||
$this->PunishBuilding($vid,$proc,$pop);
|
||||
|
||||
}
|
||||
if($post['del_troop']){
|
||||
if($user['tribe'] == 1) {
|
||||
$unit = 1;
|
||||
}else if($user['tribe'] == 2) {
|
||||
$unit = 11;
|
||||
}else if($user['tribe'] == 3) {
|
||||
$unit = 21;
|
||||
}
|
||||
$this->DelUnits($villages[$i]['wref'],$unit);
|
||||
}
|
||||
if($post['clean_ware']){
|
||||
$time = time();
|
||||
$q = "UPDATE ".TB_PREFIX."vdata SET `wood` = '0', `clay` = '0', `iron` = '0', `crop` = '0', `lastupdate` = '$time' WHERE wref = $vid;";
|
||||
mysql_query($q, $this->connection);
|
||||
}
|
||||
}
|
||||
mysql_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Punished user: <a href=\'admin.php?p=player&uid=".$post['uid']."\'>".$post['uid']."</a> with <b>-".$post['punish']."%</b> population',".time().")");
|
||||
}
|
||||
|
||||
function PunishBuilding($vid,$proc,$pop){
|
||||
global $database;
|
||||
$q = "UPDATE ".TB_PREFIX."vdata set pop = $pop where wref = $vid;";
|
||||
mysql_query($q, $this->connection);
|
||||
$fdata = $database->getResourceLevel($vid);
|
||||
for ($i = 1; $i <= 40; $i++) {
|
||||
if($fdata['f'.$i]>1){
|
||||
$zm = ($fdata['f'.$i]/100)*$proc;
|
||||
if($zm < 1){$zm = 1;}else{$zm = floor($zm);}
|
||||
$q = "UPDATE ".TB_PREFIX."fdata SET `f$i` = '$zm' WHERE `vref` = $vid;";
|
||||
mysql_query($q, $this->connection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function DelUnits($vid,$unit){
|
||||
for ($i = $unit; $i <= 9+$unit; $i++) {
|
||||
$this->DelUnits2($vid,$unit);
|
||||
}
|
||||
}
|
||||
|
||||
function DelUnits2($vid,$unit){
|
||||
$q = "UPDATE ".TB_PREFIX."units SET `u$unit` = '0' WHERE `vref` = $vid;";
|
||||
mysql_query($q, $this->connection);
|
||||
}
|
||||
|
||||
function DelPlayer($uid,$pass){
|
||||
global $database;
|
||||
$ID = $_SESSION['id'];//$database->getUserField($_SESSION['username'],'id',1);
|
||||
if($this->CheckPass($pass,$ID)){
|
||||
$villages = $database->getProfileVillages($uid);
|
||||
for ($i = 0; $i <= count($villages)-1; $i++) {
|
||||
$this->DelVillage($villages[$i]['wref']);
|
||||
}
|
||||
$name = $database->getUserField($uid,"username",0);
|
||||
mysql_query("Insert into ".TB_PREFIX."admin_log values (0,$ID,'Deleted user <a>$name</a>',".time().")");
|
||||
$q = "DELETE FROM ".TB_PREFIX."users WHERE `id` = $uid;";
|
||||
mysql_query($q, $this->connection);
|
||||
}
|
||||
}
|
||||
|
||||
function getUserActive() {
|
||||
$time = time() - (60*5);
|
||||
$q = "SELECT * FROM ".TB_PREFIX."users where timestamp > $time and username != 'support'";
|
||||
$result = mysql_query($q, $this->connection);
|
||||
return $this->mysql_fetch_all($result);
|
||||
}
|
||||
|
||||
function CheckPass($password,$uid){
|
||||
$q = "SELECT password FROM ".TB_PREFIX."users where id = '$uid' and access = ".ADMIN;
|
||||
$result = mysql_query($q, $this->connection);
|
||||
$dbarray = mysql_fetch_array($result);
|
||||
if($dbarray['password'] == md5($password)) {
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function DelVillage($wref){
|
||||
$q = "SELECT * FROM ".TB_PREFIX."vdata WHERE `wref` = $wref and capital = 1;";
|
||||
$result = mysql_query($q, $this->connection);
|
||||
if(mysql_num_rows($result) > 0){
|
||||
mysql_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Deleted village <b>$wref</b>',".time().")");
|
||||
$q = "DELETE FROM ".TB_PREFIX."vdata WHERE `wref` = $wref and capital = 1;";
|
||||
mysql_query($q, $this->connection);
|
||||
$q = "DELETE FROM ".TB_PREFIX."units WHERE `vref` = $wref;";
|
||||
mysql_query($q, $this->connection);
|
||||
$q = "DELETE FROM ".TB_PREFIX."bdata WHERE `wid` = $wref;";
|
||||
mysql_query($q, $this->connection);
|
||||
$q = "DELETE FROM ".TB_PREFIX."abdata WHERE `wid` = $wref;";
|
||||
mysql_query($q, $this->connection);
|
||||
$q = "DELETE FROM ".TB_PREFIX."fdata WHERE `vref` = $wref;";
|
||||
mysql_query($q, $this->connection);
|
||||
$q = "DELETE FROM ".TB_PREFIX."training WHERE `vref` = $wref;";
|
||||
mysql_query($q, $this->connection);
|
||||
$q = "DELETE FROM ".TB_PREFIX."movement WHERE `from` = $wref;";
|
||||
mysql_query($q, $this->connection);
|
||||
$q = "UPDATE ".TB_PREFIX."wdata SET `occupied` = '0' WHERE `id` = $wref;";
|
||||
mysql_query($q, $this->connection);
|
||||
}
|
||||
}
|
||||
|
||||
function DelBan($uid,$id){
|
||||
global $database;
|
||||
$name = $database->getUserField($uid,"username",0);
|
||||
mysql_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Unbanned user <a href=\'admin.php?p=player&uid=$uid\'>$name</a>',".time().")");
|
||||
$q = "UPDATE ".TB_PREFIX."users SET `access` = '".USER."' WHERE `id` = $uid;";
|
||||
mysql_query($q, $this->connection);
|
||||
$q = "UPDATE ".TB_PREFIX."banlist SET `active` = '0' WHERE `id` = $id;";
|
||||
mysql_query($q, $this->connection);
|
||||
}
|
||||
|
||||
function AddBan($uid,$end,$reason){
|
||||
global $database;
|
||||
$name = $database->getUserField($uid,"username",0);
|
||||
mysql_query("Insert into ".TB_PREFIX."admin_log values (0,".$_SESSION['id'].",'Banned user <a href=\'admin.php?p=player&uid=$uid\'>$name</a>',".time().")");
|
||||
$q = "UPDATE ".TB_PREFIX."users SET `access` = '0' WHERE `id` = $uid;";
|
||||
mysql_query($q, $this->connection);
|
||||
$time = time();
|
||||
$admin = $_SESSION['id']; //$database->getUserField($_SESSION['username'],'id',1);
|
||||
$name = $database->getUserField($uid,'username',0);
|
||||
$q = "INSERT INTO ".TB_PREFIX."banlist (`uid`, `name`, `reason`, `time`, `end`, `admin`, `active`) VALUES ($uid, '$name' , '$reason', '$time', '$end', '$admin', '1');";
|
||||
mysql_query($q, $this->connection);
|
||||
}
|
||||
|
||||
function search_player($player){
|
||||
$q = "SELECT id,username FROM ".TB_PREFIX."users WHERE `username` LIKE '%$player%' and username != 'support'";
|
||||
$result = mysql_query($q, $this->connection);
|
||||
return $this->mysql_fetch_all($result);
|
||||
}
|
||||
|
||||
function search_email($email){
|
||||
$q = "SELECT id,email FROM ".TB_PREFIX."users WHERE `email` LIKE '%$email%' and username != 'support'";
|
||||
$result = mysql_query($q, $this->connection);
|
||||
return $this->mysql_fetch_all($result);
|
||||
}
|
||||
|
||||
function search_village($village){
|
||||
$q = "SELECT * FROM ".TB_PREFIX."vdata WHERE `name` LIKE '%$village%' or `wref` LIKE '%$village%'";
|
||||
$result = mysql_query($q, $this->connection);
|
||||
return $this->mysql_fetch_all($result);
|
||||
}
|
||||
|
||||
function search_alliance($alliance){
|
||||
$q = "SELECT * FROM ".TB_PREFIX."alidata WHERE `name` LIKE '%$alliance%' or `tag` LIKE '%$alliance%' or `id` LIKE '%$alliance%'";
|
||||
$result = mysql_query($q, $this->connection);
|
||||
return $this->mysql_fetch_all($result);
|
||||
}
|
||||
|
||||
function search_ip($ip){
|
||||
$q = "SELECT * FROM ".TB_PREFIX."login_log WHERE `ip` LIKE '%$ip%'";
|
||||
$result = mysql_query($q, $this->connection);
|
||||
return $this->mysql_fetch_all($result);
|
||||
}
|
||||
|
||||
function search_banned(){
|
||||
$q = "SELECT * FROM ".TB_PREFIX."banlist where active = '1'";
|
||||
$result = mysql_query($q, $this->connection);
|
||||
return $this->mysql_fetch_all($result);
|
||||
}
|
||||
|
||||
function Del_banned(){
|
||||
//$q = "SELECT * FROM ".TB_PREFIX."banlist";
|
||||
$result = mysql_query($q, $this->connection);
|
||||
return $this->mysql_fetch_all($result);
|
||||
}
|
||||
|
||||
/***************************
|
||||
Function to process MYSQLi->fetch_all (Only exist in MYSQL)
|
||||
References: Result
|
||||
***************************/
|
||||
function mysql_fetch_all($result) {
|
||||
$all = array();
|
||||
if($result) {
|
||||
while ($row = mysql_fetch_assoc($result)){ $all[] = $row; }
|
||||
return $all;
|
||||
}
|
||||
}
|
||||
|
||||
function query_return($q) {
|
||||
$result = mysql_query($q, $this->connection);
|
||||
return $this->mysql_fetch_all($result);
|
||||
}
|
||||
|
||||
/***************************
|
||||
Function to do free query
|
||||
References: Query
|
||||
***************************/
|
||||
function query($query) {
|
||||
return mysql_query($query, $this->connection);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
$admin = new adm_DB;
|
||||
include("function.php");
|
||||
?>
|
||||
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
#################################################################################
|
||||
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
|
||||
## --------------------------------------------------------------------------- ##
|
||||
## Filename function.php ##
|
||||
## Developed by: Dzoki ##
|
||||
## License: TravianX Project ##
|
||||
## Copyright: TravianX (c) 2010-2011. All rights reserved. ##
|
||||
## ##
|
||||
#################################################################################
|
||||
|
||||
class funct {
|
||||
|
||||
function CheckLogin(){
|
||||
if($_SESSION['access'] >= MULTIHUNTER && isset($_SESSION['id'])){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function Act($get){
|
||||
global $admin,$database;
|
||||
|
||||
switch($get['action']){
|
||||
case recountPop:
|
||||
$admin->recountPop($get['did']);
|
||||
break;
|
||||
case recountPopUsr:
|
||||
$admin->recountPopUser($get['uid']);
|
||||
break;
|
||||
case StopDel:
|
||||
//stop deleting
|
||||
break;
|
||||
case delVil:
|
||||
$admin->DelVillage($get['did']);
|
||||
break;
|
||||
case delBan:
|
||||
$admin->DelBan($get['uid'],$get['id']);
|
||||
//remove ban
|
||||
break;
|
||||
case addBan:
|
||||
if($get['time']){$end = time()+$get['time']; }else{$end = '';}
|
||||
|
||||
if(preg_match("/^[0-9]+$/",$get['uid'])){
|
||||
//if(eregi("^[0-9]*+$",$get['uid'])){
|
||||
$get['uid'] = $get['uid'];
|
||||
}else{
|
||||
$get['uid'] = $database->getUserField($get['uid'],'id',1);
|
||||
}
|
||||
|
||||
$admin->AddBan($get['uid'],$end,$get['reason']);
|
||||
//add ban
|
||||
break;
|
||||
case delOas:
|
||||
//oaza
|
||||
break;
|
||||
case logout:
|
||||
$this->LogOut();
|
||||
break;
|
||||
}
|
||||
if($get['action'] == 'logout'){
|
||||
header("Location: admin.php");
|
||||
}else{
|
||||
header("Location: ".$_SERVER['HTTP_REFERER']);
|
||||
}
|
||||
}
|
||||
|
||||
function Act2($post){
|
||||
global $admin,$database;
|
||||
switch($post['action']){
|
||||
case DelPlayer:
|
||||
$admin->DelPlayer($post['uid'],$post['pass']);
|
||||
header("Location: ?p=search&msg=ursdel");
|
||||
break;
|
||||
case punish:
|
||||
$admin->Punish($post);
|
||||
header("Location: ".$_SERVER['HTTP_REFERER']);
|
||||
break;
|
||||
case addVillage:
|
||||
$admin->AddVillage($post);
|
||||
header("Location: ".$_SERVER['HTTP_REFERER']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function LogIN($username,$password){
|
||||
global $admin,$database;
|
||||
if($admin->Login($username,$password)){
|
||||
//$_SESSION['username'] = $username;
|
||||
$_SESSION['access'] = $database->getUserField($username,'access',1);
|
||||
$_SESSION['id'] = $database->getUserField($username,'id',1);
|
||||
header("Location: ".$_SERVER['HTTP_REFERER']);
|
||||
//header("Location: admin.php");
|
||||
}else{
|
||||
echo "Error";
|
||||
}
|
||||
}
|
||||
|
||||
function LogOut(){
|
||||
$_SESSION['access'] = '';
|
||||
$_SESSION['id'] = '';
|
||||
}
|
||||
|
||||
public function procResType($ref) {
|
||||
global $session;
|
||||
switch($ref) {
|
||||
case 1: $build = "Woodcutter"; break;
|
||||
case 2: $build = "Clay Pit"; break;
|
||||
case 3: $build = "Iron Mine"; break;
|
||||
case 4: $build = "Cropland"; break;
|
||||
case 5: $build = "Sawmill"; break;
|
||||
case 6: $build = "Brickyard"; break;
|
||||
case 7: $build = "Iron Foundry"; break;
|
||||
case 8: $build = "Grain Mill"; break;
|
||||
case 9: $build = "Bakery"; break;
|
||||
case 10: $build = "Warehouse"; break;
|
||||
case 11: $build = "Granary"; break;
|
||||
case 12: $build = "Blacksmith"; break;
|
||||
case 13: $build = "Armoury"; break;
|
||||
case 14: $build = "Tournament Square"; break;
|
||||
case 15: $build = "Main Building"; break;
|
||||
case 16: $build = "Rally Point"; break;
|
||||
case 17: $build = "Marketplace"; break;
|
||||
case 18: $build = "Embassy"; break;
|
||||
case 19: $build = "Barracks"; break;
|
||||
case 20: $build = "Stable"; break;
|
||||
case 21: $build = "Workshop"; break;
|
||||
case 22: $build = "Academy"; break;
|
||||
case 23: $build = "Cranny"; break;
|
||||
case 24: $build = "Town Hall"; break;
|
||||
case 25: $build = "Residence"; break;
|
||||
case 26: $build = "Palace"; break;
|
||||
case 27: $build = "Treasury"; break;
|
||||
case 28: $build = "Trade Office"; break;
|
||||
case 29: $build = "Great Barracks"; break;
|
||||
case 30: $build = "Great Stable"; break;
|
||||
case 31: $build = "City Wall"; break;
|
||||
case 32: $build = "Earth Wall"; break;
|
||||
case 33: $build = "Palisade"; break;
|
||||
case 34: $build = "Stonemason's Lodge"; break;
|
||||
case 35: $build = "Brewery"; break;
|
||||
case 36: $build = "Trapper"; break;
|
||||
case 37: $build = "Hero's Mansion"; break;
|
||||
case 38: $build = "Great Warehouse"; break;
|
||||
case 39: $build = "Great Granary"; break;
|
||||
case 40: $build = "Wonder of the World"; break;
|
||||
case 41: $build = "Horse Drinking Trough"; break;
|
||||
default: $build = "Error"; break;
|
||||
}
|
||||
return $build;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
$funct = new funct;
|
||||
if($funct->CheckLogin()){
|
||||
if($_GET['action']){
|
||||
$funct->Act($_GET);
|
||||
}
|
||||
if($_POST['action']){
|
||||
$funct->Act2($_POST);
|
||||
}
|
||||
}
|
||||
if($_POST['action']=='login'){
|
||||
$funct->LogIN($_POST['name'],$_POST['pw']);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,6 @@
|
||||
Hello %USER%,
|
||||
|
||||
Thank you for registering on our server.
|
||||
Since the %START% at %TIME% Romans, Gauls and Teutons attack each other on this game world. Right now, %PLAYERS% players in %ALLI% Alliances are fighting for supremacy.
|
||||
|
||||
TravianX Team
|
||||
Reference in New Issue
Block a user