Incorrect integer value: '' for column 'id' at row 1...

Status
Niet open voor verdere reacties.

acdemaster

Gebruiker
Lid geworden
14 mrt 2007
Berichten
54
Ik snap niet hoe ik dit probleem kan oplossen...

Ik heb dus een gameserver, met babstats (stats systeem) maar ik moet op die site de server toevoegen als ik de gegevens in heb gevult komt er hetvolgende te staan: Incorrect integer value: '' for column 'id' at row 1,
ik weet niet wat ik er mee aan moet
kan iemand me verder helpen:D

alvast bedankt:)



(ik heb een eigen webserver met php en mysql server 5.0 en mysqladmin)
 
Laatst bewerkt:
Weet er niet zoveel van maar het lijkt erop dat je karakter/teken gebruikt dat niet is toegestaan bv het streepje of & , spatie...
Het is maar een idee van me.
 
Aangezien de kolom "id" heet gok ik erop dat hij "not null" en "auto increment" is. In ieder geval wil je in een kolom waar alleen maar een getal (= integer value) in mag iets anders dan een getal zetten. Ook een veel voorkomende fout is dat er niets in wordt gezet (aanhalingstekens met niets ertussen). Om een goed antwoord te kunnen geven is een beschrijving van de tabel nodig en welke insert-query je probeert uit te voeren. Kun je dat hier eens posten als je er niet uit komt?
 
Aangezien de kolom "id" heet gok ik erop dat hij "not null" en "auto increment" is. In ieder geval wil je in een kolom waar alleen maar een getal (= integer value) in mag iets anders dan een getal zetten. Ook een veel voorkomende fout is dat er niets in wordt gezet (aanhalingstekens met niets ertussen). Om een goed antwoord te kunnen geven is een beschrijving van de tabel nodig en welke insert-query je probeert uit te voeren. Kun je dat hier eens posten als je er niet uit komt?
http://img261.imageshack.us/img261/3962/tabelopstelling1ze1.png
Heb je hier iets aan?
Ik snap niet veel van je verhaal misschien kan je het wat 'makkelijker' uitleggen, ik het totaal geen verstand van php laat staan mysql:rolleyes:

toch bedankt dat je moeite heb genomen voor me:thumb:
 
Laatst bewerkt:
Dat is inderdaad de beschrijving van de tabel die ik zocht. Waar het bij jou mis gaat is bij de eerste kolom van de tabel met de naam "id". In je schermprint staat dat deze van het type "INT" is, in het nederlands: er mogen alleen getallen in staan. Wanneer je dan tekst in deze kolom zet krijg je de foutmelding uit je eerste bericht.

In je eerste bericht geef je aan dat je een server moet toevoegen op een bepaalde site. Denk je dat je de achterliggende php-code hiervan kunt vinden en hier kunt plaatsen? Ik verwacht dat daar de fout in zit.
 
PHP:
<?
/*
 * Copyright (c) 2002, Tomas Stucinskas a.k.a Baboon
 * All rights reserved.
 *
 * Redistribution and use with or without modification, are
 * permitted provided that the following conditions are met:
 *
 * Redistributions must retain the above copyright notice.
 * File readme.htm must not be removed from the package.
 *
 * Module name   : editservers.php
 * Author        : Tomas Stucinskas a.k.a Baboon
 * E-mail        : baboon@ai-hq.com
 */

require "header.php";

if ($status != "admin" || !$status) {
echo "You are not authorized to view this";
exit;
}

if(!$action) {

echo "<table width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"4\">";
echo "<tr><td><b>ID</b></td><td><b>ID Code</b></td><td><b>Server Name</b></td><td width=\"50%\"><b>Server Info</b></td><td><b>-</b></td><td><b>-</b></td></tr>";

$query = mysql_query("SELECT * FROM $servers_table ORDER BY id ASC") or die(mysql_error());
while($row = mysql_fetch_array($query)) {
echo "<tr><td>$row[id]&nbsp;</td><td>$row[idcode]&nbsp;</td><td>$row[name]&nbsp;</td><td>$row[info]&nbsp;</td><td><a href=\"editservers.php?$auth_args&action=edit&id=$row[id]\">Edit</a></td><td><a href=\"editservers.php?$auth_args&action=delete&id=$row[id]\">Delete</a></td></tr>";
}
echo "<form method=\"post\" action=\"editservers.php?$auth_args&action=add\">";
echo "<tr><td>-</td><td><input type=\"text\" name=\"newsidcode\" size=\"10\" maxlength=\"64\" /></td><td><input type=\"text\" name=\"newsname\" size=\"10\" maxlength=\"64\" /></td><td><textarea name=\"newsinfo\" cols=\"50\" rows=\"10\"></textarea></td><td><input type=\"submit\" name=\"addsubmit\" value=\"Add\" /></td><td>-</td></tr>";
echo "</form>";

echo "</table><br><br>";

echo "<a href=\"index.php?$auth_args\">Main menu</a>";
}

if($action == "delete") {

if(!$deletesubmit) {
echo "Are you sure you want to delete this server?<br>";
echo "<form method=\"post\" action=\"editservers.php?$auth_args&action=delete&id=$id\">";
echo "<input type=\"submit\" name=\"deletesubmit\" value=\"Yes\" /></form><br>";
echo "<a href=\"editservers.php?$auth_args\">Back</a>";
} else {
$query = mysql_query("DELETE FROM $servers_table WHERE id='$id'") or die(mysql_error());
echo "Server deleted. Redirecting...";
?>
<script>
function redirect()
{
window.location.replace("editservers.php?<?=$auth_args?>");
}
setTimeout("redirect();", 1250);
</script>

<?
}
}

if($action == "edit") {

if(!$editsubmit) {
$query = mysql_query("SELECT * FROM $servers_table WHERE id='$id'") or die(mysql_error());
$row = mysql_fetch_array($query);
echo "<form method=\"post\" action=\"editservers.php?$auth_args&action=edit&id=$id\">";
echo "Server ID Code:<br><input type=\"text\" name=\"newsidcode\" size=\"24\" maxlength=\"64\" value=\"$row[idcode]\" /><br><br>";
echo "Server Name:<br><input type=\"text\" name=\"newsname\" size=\"24\" maxlength=\"64\" value=\"$row[name]\" /><br><br>";
echo "Server Info:<br><textarea name=\"newsinfo\" cols=\"24\" rows=\"5\">$row[info]</textarea><br><br>";
echo "<input type=\"submit\" name=\"editsubmit\" value=\"Edit\" />";
echo "</form><br><br>\n";
echo "<a href=\"editservers.php?$auth_args\">Back</a>";
} else {
$newsinfo = nl2br($newsinfo);
$query = mysql_query("UPDATE $servers_table SET name='$newsname', idcode='$newsidcode', info='$newsinfo' WHERE id='$id'") or die(mysql_error());
echo "Server edited. Redirecting...";
?>
<script>
function redirect()
{
window.location.replace("editservers.php?<?=$auth_args?>");
}
setTimeout("redirect();", 1250);
</script>

<?
}
}

if($action == "add") {
$newsinfo = nl2br($newsinfo);
$query = mysql_query("INSERT INTO $servers_table VALUES ('', '$newsidcode', '$newsname', '', '', '$newsinfo', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '')") or die(mysql_error());
echo "Server added. Redirecting...";
?>
<script>
function redirect()
{
window.location.replace("editservers.php?<?=$auth_args?>");
}
setTimeout("redirect();", 1250);
</script>

<?

}



Ik weet niet of je dit bedoelde?
 
Ja, dat is het. Het gaat fout bij deze regel:
PHP:
$query = mysql_query("INSERT INTO $servers_table VALUES ('', '$newsidcode', '$newsname', '', '', '$newsinfo', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '')") or die(mysql_error());
Vervang deze regel door dit:
PHP:
$query = mysql_query("INSERT INTO $servers_table (idcode, name, info) VALUES ('$newsidcode', '$newsname', '$newsinfo')") or die(mysql_error());
 
Dank u wel:D :thumb:
dit was het probleem hij doet het nu (teminste de server is toegevoegd)
hardstikke bedankt:cool:
 
Het volgende probleem:confused:
Me server is toegevoegd, de uploader vind het spel maar...
als ik de stats wil laten uploaden (wat automatisch gaat)
komt het volgende te staan:


date = "Sun, 15 Jul 2007 21:26:09 GMT"
HTTP/1.1 404 Not Found
Uploading server status to http://192.***.*.*/ (intern ip)
HTTP/1.1 404 Not Found
server = "Apache/2.2.3 (win32) PHP/5.2.0"
connection = "close"
content-type = "text/html; charset=iso-8859-1"


Weet iemand een oplossing?
 
Hallo,

Ik heb een nieuwe versie geinstalleerd,
Als ik nu opnieuw een server wil toevoegen krijg ik dezelfde melding,
Incorrect integer value: " for column 'id' at row 1
Dit heb ik ook als ik een squad wil toevoegen enz.

Dit is een kopie van 'admin.php'

PHP:
<? ob_start() ?>
<?
/*
 * Copyright (c) 2003, Tomas Stucinskas a.k.a Baboon
 * All rights reserved.
 *
 * Redistribution and use with or without modification, are
 * permitted provided that the following conditions are met:
 *
 * Redistributions must retain the above copyright notice.
 * File licence.txt must not be removed from the package.
 *
 * Author        : Tomas Stucinskas a.k.a Baboon
 * E-mail        : [email]baboon@ai-hq.com[/email]
 */

error_reporting(E_ERROR | E_WARNING | E_PARSE);

$mtime1    = explode(" ", microtime());
$starttime = $mtime1[1] + $mtime1[0];

$base_folder  = "";
$mainscript   = $_SERVER['PHP_SELF']."?";
$adminaction  = $mainscript."action=admin_actions";
$content      = "";
$rowclass1    = "tablerow1";
$rowclass2    = "tablerow2";
$selectedasc  = "selectedasc";
$selecteddesc = "selecteddesc";
$unselected   = "unselected";

require $base_folder."config.php";
require $base_folder."common.php";
require $base_folder."weapons.php";
require $base_folder."gametypes.php";
require $base_folder."rating.php";
require $base_folder."functions.php";

if($HTTP_POST_VARS)   foreach($HTTP_POST_VARS   as $Key=>$Value) $$Key = $Value;
if($HTTP_COOKIE_VARS) foreach($HTTP_COOKIE_VARS as $Key=>$Value) $$Key = $Value;
if($HTTP_GET_VARS)    foreach($HTTP_GET_VARS    as $Key=>$Value) $$Key = $Value;
if($HTTP_SERVER_VARS) foreach($HTTP_SERVER_VARS as $Key=>$Value) $$Key = $Value;
if($HTTP_ENV_VARS)    foreach($HTTP_ENV_VARS    as $Key=>$Value) $$Key = $Value;

DBConnect();
MakeTableNames();

$loginform = "<form method=\"post\" action=\"$mainscript\">\n
              Username <input type=\"text\" name=\"username\" size=\"25\" maxlength=\"40\"></input><br>\n
              Password <input type=\"password\" name=\"password1\" size=\"25\" maxlength=\"40\"></input><br>\n
              <input type=\"submit\" name=\"loginsubmit\" value=\"Login\">\n
              </form>\n";

$logoutform = "<center><form method=\"post\" action=\"$mainscript\">\n
               <input type=\"submit\" name=\"logoutsubmit\" value=\"Logout\">\n
               </form></center>\n";
               
unset($auth_str);

if(isset($auth_string)) {
  $auth_str = $auth_string;
}
         
if(isset($logoutsubmit)) {
  unset($auth_str);
  setcookie("auth_string", "", time() + (86400*3), "/");
}

if(isset($loginsubmit)) {
  if($username == $admin_name && $password1 == $admin_pass) {
    $auth_str = md5($username)."|".md5($password1);
    setcookie("auth_string", $auth_str, time() + (86400*3), "/");
  }
}

if(isset($auth_str)) {
  $auth_str = explode("|", $auth_str);  
  if($auth_str["0"] != md5($admin_name) || $auth_str["1"] != md5($admin_pass)) {
    echo $loginform;
    exit;
  }
} else {
  echo $loginform;
  exit;
}

require $base_folder."phemplate_class.php";

if(!isset($action) || $action == "") $action = "admin_start";

if(file_exists($base_folder."modules/admin/$action.php")) {
  include $base_folder."modules/admin/$action.php";
} else {
  $content = "<P class=\"error\">Error: Module '$action' does not exist</P>";    
}

if(file_exists($base_folder."modules/admin/$action.php")) {
  include $base_folder."modules/admin/$action.php";
} else {
  $content .= "<P class=\"error\">No admin functions for this page</P>";    
}

$tpl = new phemplate();
$tpl->set_file("main", $base_folder."templates/admin/admin_main.htm");
$tpl->set_var("website_title", $website_title);
$tpl->set_var("charset",       $charset);
$tpl->set_var("mainscript",    $mainscript);
$tpl->set_var("version",       $version);
$tpl->set_var("base",          $base_folder);
$tpl->set_var("content", $content);
echo $tpl->process("", "main", 1);

$mtime2 = explode(" ", microtime());
$endtime = $mtime2[1] + $mtime2[0];
$totaltime = ($endtime - $starttime);
$totaltime = number_format($totaltime, 3);

//echo "<center><font size=\"1\" face=\"Tahoma, Verdana\" color=\"#999999\"><br><br>Page generated in $totaltime seconds</font></center>";
echo $logoutform;
?>

Ik hoop dat jullie me kunnen helpen:D
 
Laatst bewerkt:
Waarschijnlijk weer hetzelfde probleem. :rolleyes: Het zit hem in ieder geval niet in "admin.php" want daar zit geen sql (meer?) in.

Wel zie ik dat er verschillende bestanden aangeroepen worden met "$action.php". Als je weet welke bestanden dat zijn en de code wilt posten kunnen we daar misschien een fout een stukje sql ontdekken. Deze bestanden moeten in de map "modules/admin" te vinden zijn. "admin_start.php" is het (denk ik) niet.
 
Waarschijnlijk weer hetzelfde probleem. :rolleyes: Het zit hem in ieder geval niet in "admin.php" want daar zit geen sql (meer?) in.

Wel zie ik dat er verschillende bestanden aangeroepen worden met "$action.php". Als je weet welke bestanden dat zijn en de code wilt posten kunnen we daar misschien een fout een stukje sql ontdekken. Deze bestanden moeten in de map "modules/admin" te vinden zijn. "admin_start.php" is het (denk ik) niet.
Dus welke pagina moet ik posten?
 
Dat is niet met zekerheid te zeggen, er worden geen bestandsnamen genoemd in "admin.php". Uit één van je eerder posts maak ik op dat het misschien "editservers.php" is. Kijk anders eens in welk bestand de code "INSERT INTO $servers_table" voor komt.
 
Dat is niet met zekerheid te zeggen, er worden geen bestandsnamen genoemd in "admin.php". Uit één van je eerder posts maak ik op dat het misschien "editservers.php" is. Kijk anders eens in welk bestand de code "INSERT INTO $servers_table" voor komt.
Ik heb de volgende pagina's door gezocht voor INSERT INTO $servers_table:

config.php
common.php
weapons.php
gametypes.php
rating.php
functions.php

Zonder resultaat...
 
Begrijp ik het goed dat in de nieuwe versie geen bestand genaamd "editservers.php" meer voor komt? Er zal toch in een bestand waar servers in de database gezet worden moeten bestaan. Hierin zal de tekst "insert into" moeten voorkomen, want daar gaat het fout.
 
Begrijp ik het goed dat in de nieuwe versie geen bestand genaamd "editservers.php" meer voor komt? Er zal toch in een bestand waar servers in de database gezet worden moeten bestaan. Hierin zal de tekst "insert into" moeten voorkomen, want daar gaat het fout.
Voor insert into heb ik wel iets gevonden

in cammon.php
PHP:
<?
/*
 * Copyright (c) 2003, Tomas Stucinskas a.k.a Baboon
 * All rights reserved.
 *
 * Redistribution and use with or without modification, are
 * permitted provided that the following conditions are met:
 *
 * Redistributions must retain the above copyright notice.
 * File licence.txt must not be removed from the package.
 *
 * Author        : Tomas Stucinskas a.k.a Baboon
 * E-mail        : baboon@ai-hq.com
 *
 * Finalized     : 29th April 2005
 * Modified by   : Peter Jones a.k.a »TÐÖ« Ãzràél
 * E-mail        : azrael@tdosquad.co.uk
 * Website       : http://www.tdosquad.co.uk
 */

if($_GET["data"] == "requestVer") {
	echo "2.0.0 (Neos-Standalone)";
	exit();
}

if($_GET["version"]) {
	echo 'common.php 1.0.0';
	die();
}

$version    = "2.0.0 (Standalone)";     // Release version - Standalone Editon, do not edit

function DBConnect() { 
  global $dbhost, $dbusername, $dbuserpw, $dbname, $client;
  if(!isset($client) || $client == "") $client = "browser";
  if($client == "uploader") {
    mysql_pconnect($dbhost, $dbusername, $dbuserpw) or die(mysql_error()); 
    mysql_select_db($dbname) or die(mysql_error()); 
    mysql_query("SET OPTION SQL_BIG_SELECTS=1");
  } else if($client == "browser") {
    mysql_pconnect($dbhost, $dbusername, $dbuserpw) or die(mysql_error()); 
    mysql_select_db($dbname) or die(mysql_error());
    mysql_query("SET OPTION SQL_BIG_SELECTS=1");
  } 
} 

function DBQuery($query) {
  global $client;
  if(!isset($client) || $client == "") $client = "browser";
  if($client == "uploader") {
    if(!$result = mysql_query($query)) die(mysql_error());
  } else if($client == "browser") {
    if(!$result = mysql_query($query)) die(mysql_error());
  }
  return $result;
}
 
function DBNumRows($query) {
  global $client;
  if(!isset($client) || $client == "") $client = "browser";
  if($client == "uploader") {
    $result = mysql_num_rows($query);
  } else if($client == "browser") {
    $result = mysql_num_rows($query);
  }
  return $result;
}
 
function DBFetchArray($query) {
  global $client;
  if(!isset($client) || $client == "") $client = "browser";
  if($client == "uploader") {
    $result = mysql_fetch_array($query);
  } else if($client == "browser") {
    $result = mysql_fetch_array($query);
  }
  return $result;
}
 
function MakeTableNames() {
  global $tablepre;
  global $tablepre2;
  $tables = array("aliases", "awards", "games", "hof", "log", "maps", "mapstats", "monthawards", "playerawards", "players", 
                  "playergames", "playerips", "ranks", "squads", "servers", "serverhistory", "serverstats", "stats", 
				  "weapons", "weaponstats");
  $mtables = array("mapstats", "stats", "weaponstats");
  foreach($tables as $name) {
    global ${$name."_table"};
    ${$name."_table"} = $tablepre."_".$name;
  }
  foreach($mtables as $m_name) {
    global ${$m_name."_m_table"};
    ${$m_name."_m_table"} = $tablepre2."_".$m_name;
  }
}

function FormatTime($seconds) {
  $hours    = floor($seconds/3600);
  $seconds -= $hours * 3600; 
  $minutes  = floor($seconds/60);
  $seconds -= $minutes * 60; 
  return sprintf("%d:%02d:%02d", $hours, $minutes, $seconds);
}

function GetIP() {
  if(getenv(HTTP_CLIENT_IP)) {
    $ip = getenv(HTTP_CLIENT_IP);
  } elseif(getenv(HTTP_X_FORWARDED_FOR)) {
    $ip = getenv(HTTP_X_FORWARDED_FOR);
  } else {
    $ip = getenv(REMOTE_ADDR);
  }
  return $ip;
}

function GetRanking($id) {
  global $players_table;
  $list = DBquery("SELECT $players_table.id FROM $players_table WHERE $players_table.rating > 0 GROUP BY $players_table.id ORDER BY rating DESC, name ASC");
  while ($line = mysql_fetch_array($list, MYSQL_ASSOC)) {
	$i++;
    foreach ($line as $col_value) {
      if($col_value != $id){
	    $ni = $i+1;
	  } else {
	    $st = array('','2','3','4','5','6','7','8','9','10');
	    $nd = array('','2','3','4','5','6','7','8','9','10');
	    $rd = array('','2','3','4','5','6','7','8','9','10');
		$th = array('','1','2','3','4','5','6','7','8','9','10');
		foreach($st as $value){
	      switch ($ni) {
            case $value.'1': $nni = $ni."st"; break;
		  }
	    }
	    foreach($nd as $value){
	      switch ($ni) {
            case $value.'2': $nni = $ni."nd"; break;
		  }
	    }
		foreach($rd as $value){
	      switch ($ni) {
            case $value.'3': $nni = $ni."rd"; break;
		  }
	    }
		foreach($th as $value){
	      switch ($ni) {
            case $value.'0': $nni = $ni."th"; break;
			case $value.'4': $nni = $ni."th"; break;
			case $value.'5': $nni = $ni."th"; break;
			case $value.'6': $nni = $ni."th"; break;
			case $value.'7': $nni = $ni."th"; break;
			case $value.'8': $nni = $ni."th"; break;
			case $value.'9': $nni = $ni."th"; break;
			case '1'.$value: $nni = $ni."th"; break;
		  }
	    }
		switch ($ni) {
           case 0 : $nni = "1st"; break;
		  }
	    return $nni;
	  }
    }
  }
}

function GetMonthlyRanking($id) {
  global $players_table;
  $list = mysql_query("SELECT $players_table.id FROM $players_table WHERE $players_table.m_rating > 0 GROUP BY $players_table.id ORDER BY m_rating DESC, name ASC");
  while ($line = mysql_fetch_array($list, MYSQL_ASSOC)) {
	$i++;
    foreach ($line as $col_value) {
      if($col_value != $id){
	    $ni = $i+1;
	  } else {
	    $st = array('','2','3','4','5','6','7','8','9','10');
	    $nd = array('','2','3','4','5','6','7','8','9','10');
	    $rd = array('','2','3','4','5','6','7','8','9','10');
		$th = array('','1','2','3','4','5','6','7','8','9','10');
		foreach($st as $value){
	      switch ($ni) {
            case $value.'1': $nni = $ni."st"; break;
		  }
	    }
	    foreach($nd as $value){
	      switch ($ni) {
            case $value.'2': $nni = $ni."nd"; break;
		  }
	    }
		foreach($rd as $value){
	      switch ($ni) {
            case $value.'3': $nni = $ni."rd"; break;
		  }
	    }
		foreach($th as $value){
	      switch ($ni) {
            case $value.'0': $nni = $ni."th"; break;
			case $value.'4': $nni = $ni."th"; break;
			case $value.'5': $nni = $ni."th"; break;
			case $value.'6': $nni = $ni."th"; break;
			case $value.'7': $nni = $ni."th"; break;
			case $value.'8': $nni = $ni."th"; break;
			case $value.'9': $nni = $ni."th"; break;
			case '1'.$value: $nni = $ni."th"; break;
		  }
	    }
		switch ($ni) {
           case 0 : $nni = "1st"; break;
		  }
	    return $nni;
	  }
    }
  }
}

function GetLogins($value, $serverid) {
  global $serverhistory_table, $dow, $today, $yesterday;
  
  switch($dow) {
    case "Monday"    : $tws = date("d")     ; $twe = date("d") + 6 ; $lws = date("d") - 7 ; $lwe = date("d") - 1 ;break;
	case "Tuesday"   : $tws = date("d") - 1 ; $twe = date("d") + 5 ; $lws = date("d") - 8 ; $lwe = date("d") - 2 ;break;
	case "Wednesday" : $tws = date("d") - 2 ; $twe = date("d") + 4 ; $lws = date("d") - 9 ; $lwe = date("d") - 3 ;break;
    case "Thursday"  : $tws = date("d") - 3 ; $twe = date("d") + 3 ; $lws = date("d") -10 ; $lwe = date("d") - 4 ;break;
	case "Friday"    : $tws = date("d") - 4 ; $twe = date("d") + 2 ; $lws = date("d") -11 ; $lwe = date("d") - 5 ;break;
	case "Saturday"  : $tws = date("d") - 5 ; $twe = date("d") + 1 ; $lws = date("d") -12 ; $lwe = date("d") - 6 ;break;
	case "Sunday"    : $tws = date("d") - 6 ; $twe = date("d")     ; $lws = date("d") -13 ; $lwe = date("d") - 7 ;break;
  }
  
  $start_date = mktime(0, 0, 0, date("m")  , $tws, date("Y"));
  $this_start = date("Y-m-d", $start_date) ;
  $end_date = mktime(0, 0, 0, date("m")  , $twe, date("Y"));
  $this_end = date("Y-m-d", $end_date) ;
  $last_start_date =  mktime(0, 0, 0, date("m")  , $lws, date("Y"));
  $last_start = date("Y-m-d", $last_start_date) ;
  $last_end_date = mktime(0, 0, 0, date("m")  , $lwe, date("Y"));
  $last_end = date("Y-m-d", $last_end_date) ;
  $month_s_date = mktime(0, 0, 0, date("m")  , date("d") , date("Y"));
  $month_start = date("Y-m-01", $month_s_date) ;
  $month_e_date = mktime(0, 0, 0, date("m")  , date("d") , date("Y"));
  $month_end = date("Y-m-t", $month_e_date) ;
  $lmonth_s_date = mktime(0, 0, 0, date("m") - 1  , date("d") , date("Y"));
  $lmonth_start = date("Y-m-01", $lmonth_s_date) ;
  $lmonth_e_date = mktime(0, 0, 0, date("m") - 1  , date("d") , date("Y"));
  $lmonth_end = date("Y-m-t", $lmonth_e_date) ;
  $year_s_date = mktime(0, 0, 0, date("m")  , date("d") , date("Y"));
  $year_start = date("Y-01-01", $year_s_date) ;
  $year_e_date = mktime(0, 0, 0, date("m")  , date("d") , date("Y"));
  $year_end = date("Y-12-t", $year_e_date) ;
  $lyear_s_date = mktime(0, 0, 0, date("m") , date("d") , date("Y") - 1);
  $lyear_start = date("Y-01-01", $lyear_s_date) ;
  $lyear_e_date = mktime(0, 0, 0, date("m")  , date("d") , date("Y") - 1);
  $lyear_end = date("Y-12-t", $lyear_e_date) ;

  
  switch($value) {
    case "todays"      : $criteria = 'COUNT(name) as num' ; $conditions = "date = '$today'"; break;
    case "yesterdays"  : $criteria = 'players as num'     ; $conditions = "date = '$yesterday'"; break;
    case "this_week"   : $criteria = 'SUM(players) as num'; $conditions = "date >= '$this_start' AND date <= '$this_end'"; break;
    case "last_week"   : $criteria = 'SUM(players) as num'; $conditions = "date >= '$last_start' AND date <= '$last_end'"; break;
    case "this_month"  : $criteria = 'SUM(players) as num'; $conditions = "date >= '$month_start' AND date <= '$month_end'"; break;
	case "last_month"  : $criteria = 'SUM(players) as num'; $conditions = "date >= '$lmonth_start' AND date <= '$lmonth_end'"; break;
    case "this_year"   : $criteria = 'SUM(players) as num'; $conditions = "date >= '$year_start' AND date <= '$year_end'"; break;
    case "last_year"   : $criteria = 'SUM(players) as num'; $conditions = "date >= '$lyear_start' AND date <= '$lyear_end'"; break;
  }
  
  $sql = DBQuery("SELECT $criteria FROM $serverhistory_table WHERE serverid = '$serverid' AND $conditions");
  $row = DBFetchArray($sql);
  return $row["num"];
}


function GetWeaponLevels($plid, $wpnid) {
  global $stats_table, $weapons_table, $weaponstats_table;
  
  if($wpnid == "CAR15/M203 - Grenade" || $wpnid == "M16/M203 - Grenade") $type = "weapontype1";
	
  if($wpnid == "CAR15" || $wpnid == "CAR15/M203" || $wpnid == "M16" || $wpnid == "M249 SAW" || 
    $wpnid == "M16/M203" || $wpnid == "G3" || $wpnid == "G36" || $wpnid == "M240" || $wpnid == "M60") $type = "weapontype2";
  
  if($wpnid == "M24" || $wpnid == "Barrett .50 Cal" || $wpnid == "PSG1" || 
    $wpnid == "MCRT .300 Tactical" || $wpnid == "M21" || $wpnid == "MP5" || $wpnid == "Knife") $type = "weapontype3";
  
  if($wpnid == "Colt .45" || $wpnid == "M9 Beretta" || $wpnid == "AT4" || $wpnid == "Remington Shotgun") $type = "weapontype4";
  
  if($wpnid == "50 Cal Humvee" || $wpnid == "MiniGun" || $wpnid == "Grenade Launcher" || $wpnid == "50 Cal Emplacement" || 
    $wpnid == "E M Canon" || $wpnid == "50 Cal Truck" || $wpnid == "Frag Grenade" || $wpnid == "Claymore") $type = "weapontype5";


  switch($type) {
    case "weapontype1"   : $div = '50'; break;
    case "weapontype2"   : $div = '40'; break;
    case "weapontype3"   : $div = '30'; break;
    case "weapontype4"   : $div = '20'; break;
    case "weapontype5"   : $div = '10'; break;
  }

  $query = DBQuery("SELECT $weapons_table.id, $weapons_table.name, $weaponstats_table.record, $stats_table.id, 
                      sum($weaponstats_table.kills) as kills, $weaponstats_table.weapon, $stats_table.player 
				    FROM $weapons_table, $weaponstats_table, $stats_table 
				    WHERE $weaponstats_table.weapon = $weapons_table.id AND $stats_table.id = $weaponstats_table.record 
				    AND $weapons_table.name LIKE '$wpnid' AND $stats_table.player = '$plid' GROUP BY $stats_table.player");
					
  $row = DBFetchArray($query);
  if($div < '1') {
  	$row["exp"] = '0';
  } else {
    $kills = $row["kills"]/$div;
    if(floor($kills) > 49) {
      $row["exp"] = 50;
    } else {
      $row["exp"] = floor($kills);
    }
  }
  return $row["exp"];
}

function GetGameLevels($id, $type, $group, $section) {
  global $players_table, $stats_table, $stats_m_table;
    
	if($section == "overall") {
	  $table = $stats_table;
	} elseif($section == "month") {
	  $table = $stats_m_table;
	}
	
    if($group == "player") {
	  $conditions = " AND  game_type LIKE '$type' AND $players_table.id = '$id' GROUP BY $players_table.id";
	} elseif($group == "squad") {
	  $conditions = " AND  game_type LIKE '$type' AND $players_table.squad = '$id' GROUP BY $players_table.squad";
	}
					 
	$data = DBQuery("SELECT $players_table.id, $players_table.squad, $table.player, SUM($table.kills) AS kills, 
	                   SUM($table.psptakeovers) AS psptakeovers, SUM($table.score_1) AS score_1, 
	                   SUM($table.score_2) AS score_2, SUM($table.score_3) AS score_3, SUM($table.games) AS games, SUM($table.time) AS time 
					 FROM $players_table, $table 
					 WHERE $table.player = $players_table.id 
					 $conditions");
    
	$row = DBFetchArray($data);
	
	if($row["kills"] === '0') $row["kills"] = 1;
	if($row["score_1"] === '0') $row["score_1"] = 1;
	if($row["score_2"] === '0') $row["score_2"] = 1;
	if($row["score_3"] === '0') $row["score_3"] = 1;
	if($row["games"] === '0') $row["games"] = 1;
	if($row["time"] === '0') $row["time"] = 1;
	if(!($row["games"])) $div = '1';
	
	switch($type) {
	  case "Deathmatch"           : $crit3 =  $row["kills"]/100       AND $div = '3'                                                                 ; break;
	  case "Team Deathmatch"      : $crit3 =  $row["kills"]/100       /*AND $crit4 = $row["psptakeovers"]-10*/ AND $div = '2'                            ; break;
	  case "Team King of the Hill": $crit3 =  ($row["score_1"]/60)/60 AND $crit4 = $row["score_2"]/15 AND $crit5 = $row["score_3"]/15 AND $div = '5' ; break;
	  case "Search and Destroy"   : $crit3 =  $row["score_1"]/25      AND $crit4 = $row["score_2"]/8  AND $crit5 = $row["score_3"]/8  AND $div = '5' ; break;
	  case "Attack and Defend"    : $crit3 =  $row["score_1"]/12      AND $crit4 = $row["score_2"]/12 AND $crit5 = $row["score_3"]/12 AND $div = '5' ; break;
	  case "Capture the Flag"     : $crit3 =  $row["score_1"]/10      AND $crit4 = $row["score_2"]/10 AND $crit5 = $row["score_3"]/10 AND $div = '5' ; break;
	  case "Flagball"             : $crit3 =  $row["score_1"]/6       AND $crit5 = $row["score_3"]/6  AND $div = '4'                                 ; break;
	}
	
	if($group == "squad") {
	  $squad = DBQuery("SELECT COUNT(id) AS num FROM $players_table WHERE squad = '$id'");
	  $srow = DBFetchArray($squad);
	  $div = $div*$srow["num"];
	}
	$crit1 = $row["games"]/10;
	$crit2 = ($row["time"]/60)/60;
	$crit = $crit1 + $crit2 + $crit3 + $crit4 + $crit5;
	if($crit < 1){
	  $row[$type] = "Level 0";
	} elseif(!($crit)) {
	  $row[$type] = "Level 0";
	} else {
	  $level = $crit/$div;
	  if(floor($level) > 49) {$row[$type] = "Level 50";} else {$row[$type] = "Level ".floor($level)."";}
    }
  return $row[$type];
}

function GetWeaponUsage($value, $id, $type, $server, $gametype) {
  global $players_table, $stats_table, $weaponstats_table, $weapons_table;
 
  if($server   != -1)    $conditions .= " AND $stats_table.server='$server' ";
  if($gametype != "All") $conditions .= " AND $stats_table.game_type='$gametype' ";

  switch($type) {
    case "squad"     : $gettype = "GROUP BY $players_table.squad HAVING $players_table.squad = '$id'"   ; break;
	case "player"    : $gettype = "GROUP BY $players_table.id HAVING $players_table.id = '$id'"         ; break;
  }
  
  switch($value) {
    case "assault"   : $wpntype = "'CAR15', 'CAR15/M203', 'M16', 'M16/M203', 'G3', 'G36', 'MP5'"                                      ; break;
    case "support"   : $wpntype = "'M60', 'M240', 'M249 SAW'"                                                                         ; break;
    case "sniper"    : $wpntype = "'PSG1', 'MCRT .300 Tactical', 'M21', 'M24', 'Barrett .50 Cal'"                                     ; break;
    case "secondary" : $wpntype = "'Colt .45', 'M9 Beretta', 'Remington Shotgun'"                                                     ; break;
    case "other"     : $wpntype = "'Knife', 'CAR15/M203 - Grenade', 'M16/M203 - Grenade', 'Frag Grenade', 'Claymore', 'AT4'"          ; break;
    case "emplace"   : $wpntype = "'50 Cal Humvee', 'MiniGun', 'Grenade Launcher', '50 Cal Emplacement', 'E M Canon', '50 Cal Truck'" ; break;
  }
	
  $query = DBQuery("SELECT $players_table.id, $players_table.squad, $stats_table.id, $stats_table.player, 
                      $weapons_table.id, $weapons_table.name, $weaponstats_table.record, $weaponstats_table.weapon, SUM( $weaponstats_table.kills ) AS kills  
                    FROM $players_table, $stats_table, $weapons_table, $weaponstats_table WHERE $weapons_table.id = $weaponstats_table.weapon 
					AND $weaponstats_table.record = $stats_table.id AND $stats_table.player = $players_table.id
                    AND $weapons_table.name IN ($wpntype) 
					$conditions 
                    $gettype");
  while ($row = DBFetchArray($query)) {
    $kills = $row["kills"];
  }
  $ttlkills = DBQuery("SELECT $players_table.id, $players_table.squad, $stats_table.player, 
                         SUM($stats_table.kills) AS kills 
					   FROM $players_table, $stats_table WHERE $stats_table.player = $players_table.id 
					   AND $players_table.squad = '$id' $conditions GROUP BY $players_table.squad");
  while ($ttl_row = DBFetchArray($ttlkills)) {
    $tkills = $ttl_row["kills"];
    $div = ($tkills+1);
    $result = round ($kills/$div, 1);
  }
  return $result;
}

function GetMapWeaponUsage($value, $id, $server) {
  global $stats_table, $weaponstats_table, $weapons_table, $mapstats_table, $maps_table;
 
  if($server   != -1)    $conditions .= " AND $stats_table.server='$server' ";
  
  switch($value) {
    case "assault"   : $wpntype = "'CAR15', 'CAR15/M203', 'M16', 'M16/M203', 'G3', 'G36', 'MP5'"                                      ; break;
    case "support"   : $wpntype = "'M60', 'M240', 'M249 SAW'"                                                                         ; break;
    case "sniper"    : $wpntype = "'PSG1', 'MCRT .300 Tactical', 'M21', 'M24', 'Barrett .50 Cal'"                                     ; break;
    case "secondary" : $wpntype = "'Colt .45', 'M9 Beretta', 'Remington Shotgun'"                                                     ; break;
    case "other"     : $wpntype = "'Knife', 'CAR15/M203 - Grenade', 'M16/M203 - Grenade', 'Frag Grenade', 'Claymore', 'AT4'"          ; break;
    case "emplace"   : $wpntype = "'50 Cal Humvee', 'MiniGun', 'Grenade Launcher', '50 Cal Emplacement', 'E M Canon', '50 Cal Truck'" ; break;
  }
	
  $query = DBQuery("SELECT $maps_table.id, $mapstats_table.map, $mapstats_table.record, $weaponstats_table.record, 
                      $weaponstats_table.weapon, SUM( $weaponstats_table.kills ) AS kills, 
					  $weapons_table.*, $stats_table.id, $stats_table.server
                    FROM $maps_table, $mapstats_table, $weaponstats_table, $weapons_table, $stats_table
                    WHERE $maps_table.id = '$id' AND $mapstats_table.map = $maps_table.id
                    AND $mapstats_table.record = $weaponstats_table.record AND $weaponstats_table.record = $stats_table.id 
                    AND $weaponstats_table.weapon = $weapons_table.id AND $weapons_table.name IN ($wpntype)
                    $conditions GROUP BY $maps_table.id");
  while ($row = DBFetchArray($query)) {
    if(!($row["kills"])){$kills = 0;} else {$kills = $row["kills"];}
  }
  $ttlkills = DBQuery("SELECT $maps_table.id, $mapstats_table.map, $mapstats_table.record, $weaponstats_table.record, 
                        $weaponstats_table.weapon, SUM( $weaponstats_table.kills ) AS kills, 
					    $stats_table.id, $stats_table.server
                      FROM $maps_table, $mapstats_table, $weaponstats_table, $stats_table
                      WHERE $maps_table.id = '$id' AND $mapstats_table.map = $maps_table.id
                      AND $mapstats_table.record = $weaponstats_table.record AND $weaponstats_table.record = $stats_table.id 
                      $conditions GROUP BY $maps_table.id");
  while ($ttl_row = DBFetchArray($ttlkills)) {
    if(!($ttl_row["kills"])){
	  $result = 0;
	} else {
      $tkills = $ttl_row["kills"];
      $div = ($tkills/100);
      $result = round ($kills/$div, 0);
	}
  }
  return $result;
}

function GetRatioColor($ratio) {
  if($ratio < '1.00' AND $ratio > '0.00') {
    $class = "red";
  } elseif($ratio > '1.00') {
    $class = "green";
  } elseif($ratio === '0.00') {
    $class = "blue";
  } else {
    $class = "blue";
  }
  return $class;
}
   
function GetPlayers1List($current, $all, $query_str) {
  $query           = DBQuery($query_str);
  $players1         = array();
  $row             = array();
  $count           = 0;
  if($all != 0) {
    $row["name"]     = "Select Player";
    $row["id"]       = -1;
    if($current == $row["id"]) {
      $row["selected"] = "selected=\"selected\"";
    } else {
      $row["selected"] = "";
    }
    $players1[$count] = $row;
    $count++;
  }
  while($row = DBFetchArray($query)) {
  $row["name"] = htmlspecialchars(base64_decode(str_replace(" ", "+", $row["name"])));
    if($current == $row["id"]) {
      $row["selected"] = "selected=\"selected\"";
    } else {
      $row["selected"] = "";
    }
    $players1[$count] = $row;
    $count++;
  }
  return $players1;
}

function GetPlayers2List($current, $all, $query_str) {
  $query           = DBQuery($query_str);
  $players2         = array();
  $row             = array();
  $count           = 0;
  if($all != 0) {
    $row["name"]     = "Select Player";
    $row["id"]       = -1;
    if($current == $row["id"]) {
      $row["selected"] = "selected=\"selected\"";
    } else {
      $row["selected"] = "";
    }
    $players2[$count] = $row;
    $count++;
  }
  while($row = DBFetchArray($query)) {
  $row["name"] = htmlspecialchars(base64_decode(str_replace(" ", "+", $row["name"])));
    if($current == $row["id"]) {
      $row["selected"] = "selected=\"selected\"";
    } else {
      $row["selected"] = "";
    }
    $players2[$count] = $row;
    $count++;
  }
  return $players2;
}

function GetSquadsList($current, $all) {
  global $squads_table;
  $query          = DBQuery("SELECT * FROM $squads_table ORDER BY name");
  $squads         = array();
  $row            = array();
  $count          = 0;
  if($all != 0) {
    $row["name"]    = "All";
    $row["id"]      = -1;
    if($current == $row["id"]) {
      $row["selected"] = "selected=\"selected\"";
    } else {
      $row["selected"] = "";
    }
    $squads[$count] = $row;
    $count++;
  }
  while($row = DBFetchArray($query)) {
    if($current == $row["id"]) {
      $row["selected"] = "selected=\"selected\"";
    } else {
      $row["selected"] = "";
    }
    $squads[$count] = $row;
    $count++;
  }
  return $squads;
}

function GetServersList($current, $all, $query_str) {
  $query           = DBQuery($query_str);
  $servers         = array();
  $row             = array();
  $count           = 0;
  if($all != 0) {
    $row["name"]     = "All";
    $row["id"]       = -1;
    if($current == $row["id"]) {
      $row["selected"] = "selected=\"selected\"";
    } else {
      $row["selected"] = "";
    }
    $servers[$count] = $row;
    $count++;
  }
  while($row = DBFetchArray($query)) {
    if($current == $row["id"]) {
      $row["selected"] = "selected=\"selected\"";
    } else {
      $row["selected"] = "";
    }
    $servers[$count] = $row;
    $count++;
  }
  return $servers;
}

function GetGameTypesList($current, $all, $query_str) {
  $query             = DBQuery($query_str);
  $gametypes         = array();
  $row               = array();
  $count             = 0;
  if($all != 0) {
    $row["name"]       = "All";
    $row["game_type"]  = "All";
    if($current == $row["game_type"]) {
      $row["selected"] = "selected=\"selected\"";
    } else {
      $row["selected"] = "";
    }
    $gametypes[$count] = $row;
    $count++;
  }
  while($row = DBFetchArray($query)) {
    if($current == $row["game_type"]) {
      $row["selected"] = "selected=\"selected\"";
    } else {
      $row["selected"] = "";
    }
    $row["name"] = $row["game_type"];
    $gametypes[$count] = $row;
    $count++;
  }
  return $gametypes;
}

function GetRank($rating) {
  global $players_table, $ranks_table;
  if($rating < 0) $rating = 0;
  $max_rank_query   = DBQuery("SELECT * FROM $ranks_table ORDER BY rating DESC LIMIT 1");
  $max_rank         = DBFetchArray($max_rank_query);
  $max_rank         = $max_rank["id"];
  $rank_query       = DBQuery("SELECT * FROM $ranks_table WHERE rating<='$rating' ORDER BY rating DESC");
  $rank             = DBFetchArray($rank_query);
  if($max_rank == $rank["id"]) {
    $max_rating_query = DBQuery("SELECT * FROM $players_table ORDER BY rating DESC LIMIT 1");
    $max_rating       = DBFetchArray($max_rating_query);
    $max_rating       = $max_rating["rating"];
    if($max_rating > $rating) {
      $rank = DBFetchArray($rank_query);
    }
  }
  return $rank;
}

function ShortenGameType($gametype) {
  switch($gametype) {
    case "Cooperative"           : $gametype = "COOP";   break;
    case "Deathmatch"            : $gametype = "DM";     break;
    case "Team Deathmatch"       : $gametype = "TDM";    break;
    case "King of the Hill"      : $gametype = "KOTH";   break;
    case "Team King of the Hill" : $gametype = "TKOTH";  break;
    case "Capture the Flag"      : $gametype = "CTF";    break;
    case "Flagball"              : $gametype = "FB";     break;
    case "Attack and Defend"     : $gametype = "A&D";    break;
    case "Search and Destroy"    : $gametype = "S&D";    break;
    default                      : $gametype = "unknown";
  }
  return $gametype;  
}

function ShortenGameName($gamename) {
  $gamename = str_replace("Delta Force Land Warrior",      "DFLW",  $gamename);
  $gamename = str_replace("Delta Force Task Force Dagger", "DFTFD", $gamename);
  $gamename = str_replace("Delta Force Black Hawk Down",   "DFBHD", $gamename);
  $gamename = str_replace("Delta Force 2",                 "DF2",   $gamename);
  $gamename = str_replace("Delta Force",                   "DF",    $gamename);
  return $gamename;
}

function ParseMessage($msg, $tpl, $t, $s, &$target, &$source) {
  $tpl   = "-".$tpl."-";
  $msg   = "-".$msg."-";
  $parts = explode("$", $tpl);
  $num   = count($parts);
  $part  = $msg;
  $found = array();
  $index = 1;
  for($i = 0; $i < $num; $i++) {
    $old_part = $part;
    $part = strstr($part, $parts[$i]);
    if(!$part) return FALSE;
    $parti = substr($part, 0, strlen($parts[$i]));
    if($i != 0) {
      $ply = substr($old_part, strlen($parts[$i-1]), strlen($old_part) - strlen($part) - strlen($parts[$i-1]));
      $found[$index] = $ply;
      $index++;     
    }
  }
  $target = $found[$t];
  $source = $found[$s];
  return TRUE;
}

function Multipage($url, $total, $perpage, $page) {
  $multipage = "";
  if($total > $perpage) {
	$pages = $total  / $perpage;
	$pages = ceil($pages);
	if ($page == $pages) {
	  $to = $pages;
	} elseif ($page == $pages-1) {
	  $to = $page+1;
	} elseif ($page == $pages-2) {
	  $to = $page+2;
	} else {
	  $to = $page+3;
	}

	if($page == 1 || $page == 2 || $page == 3) {
	  $from = 1;
	} else {
	  $from = $page-3;
	}

	$fwd_back = "<a href=\"$url&page=1\">&laquo;</a>&nbsp;";

	for($i = $from; $i <= $to; $i++) {
	  if($i != $page) {
	    $fwd_back .= "<a href=\"$url&page=$i\">$i</a>&nbsp;";
	  } else {
	    $fwd_back .= "<b>$i</b>&nbsp;";
	  }
	}

	$fwd_back .= "<a href=\"$url&page=$pages\">&raquo;</a>";
	$multipage = $fwd_back;
  }
  return $multipage;
}

function formatRow($id, $table) {

  $query = mysql_query("select * from $table WHERE id = '$id'");
  $num_fields = @mysql_num_fields($query);

  $row = @mysql_fetch_row($query);
  $string = "INSERT INTO $table VALUES(";
  for($i = 0; $i < $num_fields; $i++) {
    if($i < ($num_fields-1)) {
	  $string .= '"'.$row[$i].'", ';
	} else {
	  $string .= '"'.$row[$i].'"';
    }
  }
  $string .= ");\r\n";
  return $string;
}

function folderPerm($ftpInfoArr, $folderPath, $perm) {
	$ftpConn = ftp_connect($ftpInfoArr["fServer"]);
	$ftpLogin = ftp_login($ftpConn, $ftpInfoArr["fUser"], $ftpInfoArr["fPass"]);

	if (ftp_site($ftpConn, 'CHMOD '.$perm.' '.$ftpInfoArr["fRoot"].$folderPath) !== false) {
		ftp_close($ftpConn);
		return true;
	} else {
	ftp_close($ftpConn);
		die("Unable to CHMOD Folder!");
		return false;
	}
}
?>
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan