0

This is the error I keep getting, This script works fine with the local SQL server running on my windows test box but when I try it with the SQL server running on my shared web hosting account with go daddy it gives this error, I think obviously their databases are configured differently or are newer than mine are. Here is the error and code that is in funcs.php

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/content/a/4/7/a4789787/html/genesis2/funcs.php on line 185

funcs.php

<?
include("html.php");


function CheckTurns ($numturns) {
	global $users, $config;
	$turns2 = $config[maxturns] + 1;
	if ($numturns > $turns2) 
		TheEnd('<span class="cbad">FATAL ERROR</span>: attempted to use more turns than avaliable!.');
	else if ($numturns > $users[turns])
		TheEnd('<span class="cbad">FATAL ERROR</span>: attempted to use more turns than available!');		
}

// SQLSEL will return the value of the variable in the admin database (Useful for the new installer)

function sqlsel ($var) {
	global $admindb, $adminid;
	return mysql_query("SELECT $var FROM $admindb where id=$adminid");
}

// Gzip

function CNum ($amt, $prefix, $nosign)
{
	$pos = "+";
	$neg = "-";
	if ($nosign)
		$neg = $pos = "";
   $some = "<span class=";
    	if ($amt < 0)
		$some .=  "'cbad'>".$neg.$prefix;
	elseif ($amt > 0)
		$some .=  "'cgood'>".$pos.$prefix;
	else	 $some .= "'cneutral>'";
   $some .= commas(abs($amt))."</span>";
      return $some;
}

// check Prom Enhanced Technical Documents for this 
// (just released to official prom enhanced coders)
// checklevel ($users[disabled])
// zEro

function checklevel ($chk) {
	switch ($chk)
	{
		case 0:
		case 1: $lvl = 0; break;
		case 2: $lvl = 7; break;
		case 3: $lvl = 3;
		case 4: $lvl = 0; break;
		case 5: $lvl = 1; break;
		case 6: $lvl = 4; break;
		case 7: $lvl = 5; break;
		case 8: $lvl = 6; break;
		case 9: $lvl = 2; break; 
	}
	return $lvl;
}

// Made by gzip... debug_($param1,$param2)

function debug_ () 
{ 
$arr_fargs = func_get_args(); 
//echo "\n<//--Debug Start--\n"; 
?><br>Debug Start<br><span class="debug"><? 
for($a=0;sizeof($arr_fargs)>$a;$a++) 
{ 
   if (is_array($arr_fargs[$a]))  
      { 
         foreach ($arr_fargs[$a] as $key => $value) { echo "[".$key."] $value\n<br>"; } 
         unset ($arr_fargs[$a]); 
      } 
} 
if (!is_array($arr_fargs[$a]))  
   { 
      foreach ($arr_fargs as $key => $value) { echo "[".$key."] $value\n<br>"; } 
      unset ($arr_fargs); 
   } 
?></span><br>Debug End<br><? 
}

// sqldrop is used to drop tables from mysql
function sqldrop ($table)
{
	mysql_query("DROP TABLE IF EXISTS $table");
}

function sql_load_file($file) 
{
	mysql_query("SOURCE $file");
}

function sqlQuotes (&$str)
{
	$str = str_replace("'","''",stripslashes($str));
}

// adds commas to a number
function commas ($str)
{
	return number_format($str,0,".",",");
}

// Con...
function updateinfo($file) 
{  
	if (is_file($file)) 
	{ 
		$cup_hd = fopen ($file, "r"); 
		$a=0; 
		while (!feof ($cup_hd)) 
		{ 
    		$cup_buff[$a] = fgets($cup_hd, 4096); 
			$a++; 
		} 
		fclose ($cup_hd); 
	} 
	else 
	{ 
		echo "Error: Please enter a valid file<br>"; 
	} 
	for ($a=0;$a<sizeof($cup_buff);$a++) 
	{ 
		if ($cup_buff[$a] <= VSI) 
		{  
			mail($config[adminemail],"New Version of Genesis!","Informing that the new version of Genesis Enhanced is now avaliable for download.");
		} 
		elseif ($cup_buff[$a] > VSI)
			mail($config[adminemail],"Problems with Genesis!","Informing that you have a newest version that the one released. Contact your provider!.");
	}
} 


function betagame($file) 
{  
	if (is_file($file)) 
	{ 
		$cup_hd = fopen ($file, "r"); 
		$a=0; 
		while (!feof ($cup_hd)) 
		{ 
    		$cup_buff[$a] = fgets($cup_hd, 4096); 
			$a++; 
		} 
		fclose ($cup_hd); 
	} 
	else 
	{ 
		echo "Error: Please enter a valid file<br>"; 
	} 
	for ($a=0;$a<sizeof($cup_buff);$a++) 
	{ 
		return $cup_buff[$a];
	}
} 



// remove commas, make integer
function fixInputNum (&$num)
{
	$num = round(str_replace(",","",$num));
}

// randomize the mt_rand() function
function randomize ()
{
	mt_srand((double)microtime()*1000000);
}

// pluralize a string
function plural ($num, $plur, $sing)
{
	if ($num != 1)
		return $plur;
	else	return $sing;
}

// evaluate an SQL query, return first cell of first row
// useful for "SELECT count(*) ..." queries
function sqleval ($query)
{
	$data = mysql_fetch_row(mysql_query($query));
	return $data[0];
	unset($data);
}

// prints a number, colored according to its positivity/negativity.
// Set nosign=1 to omit the +/-
function printCNum ($amt, $prefix, $nosign)
{
	$pos = "+";
	$neg = "-";
	if ($nosign)
		$neg = $pos = "";
?>
<span class=<?
       	if ($amt < 0)
		print '"cbad">'.$neg.$prefix;
	elseif ($amt > 0)
		print '"cgood">'.$pos.$prefix;
	else	print '"cneutral">';
	print	commas(abs($amt));?></span><?
}

// returns the requested networth
function getNetworth (&$user)
{
	global $config;
	return floor(($user[armtrp] * .1) + ($user[lndtrp] * .2) + ($user[flytrp] * .3) + ($user[seatrp] * .4) + ($user[land] * 10) + ($user[peasants] * .05) + (($user[cash]+$user[savings]-$user[loan]) / 10000) + ($user[food] * .001) + ($user[towers] * 10) + ($user[wizards] * .5));

//			floor(($users[infantry] * .1) + ($users[tanks] * .2) +  ($users[helis] * .3) + ($users[ships] * .4) + ($users[land] * 10) + ($users[peasants]*.05) + (($users[cash]+$users[savings]-$users[loan]) / 10000) + ($users[food]*.001) + (($users[land]-$users[freeland])*5) + ($users[towers] * 10) + ($users[wizards] * 0.5));


}
function pci ()
{
	global $users, $urace;
	return round(12.5 * (1 + (($users[shops] * 1.275) / $users[land])) * $urace[pci],2);
}


// loads the information for the specified user number
function loadUser ($num)
{
	global $playerdb;
	return mysql_fetch_array(mysql_query("SELECT * FROM $playerdb WHERE num='$num';"));
}

// loads the information for the specified race number
function loadRace ($race)
{
	global $racedb;
	return mysql_fetch_array(mysql_query("SELECT * FROM $racedb WHERE id='$race';"));
}

// loads the information for the specified era number
function loadEra ($era)  {   
	global $eradb;   
	return mysql_fetch_array(mysql_query("SELECT * FROM $eradb WHERE id='$era'"));  
}

function loadClan ($num)
{
	global $clandb;
	return mysql_fetch_array(mysql_query("SELECT * FROM $clandb WHERE num='$num';"));
}

function loadClanTags ()
{
	global $clandb;
	$clans = mysql_query("SELECT num,tag FROM $clandb;");
	while ($clan = mysql_fetch_array($clans))
		$ctags["$clan[num]"] = $clan[tag];
	$ctags["0"] = "None";
	return $ctags;
}

// Loads all race names into an associative array, intended for the scorelists
function loadRaceTags ()
{
	global $racedb;
	$races = mysql_query("SELECT id,name FROM $racedb;");
	while ($race = mysql_fetch_array($races))
		$rtags["$race[id]"] = $race[name];
	return $rtags;
}

// Loads all era names, intended for the scorelists
function loadEraTags ()
{
	global $eradb;
	$eras = mysql_query("SELECT id,name FROM $eradb;");
	while ($era = mysql_fetch_array($eras))
		$etags["$era[id]"] = $era[name];
	return $etags;
}

// Example: saveClanData($uclan,"name motd ally1 war3");
function saveClanData (&$clan, $data)
{
	global $clandb, $lockdb;
	if ($lockdb)
		return;
	$items = explode(" ",$data);
	$update = "";
	$i = 0;
	while ($tmp = $items[$i++])
	{
		$data = $clan[$tmp];
		if (is_numeric($data))
			$update .= "$tmp=$data";
		else
		{
			sqlQuotes($clan[$tmp]);
			$update .= "$tmp='$data'";
		}
		if ($items[$i]) $update .= ",";
	}
	if (!mysql_query("update $clandb set $update where num=$clan[num];"))
		print "FATAL ERROR: Failed to update clan data $update for clan #$clan[num]!<BR>\n";
}



// Example: saveUserData($users,"cash networth armtrp lndtrp flytrp seatrp etc");
function saveUserData (&$user, $data)
{
	global $playerdb, $lockdb;
	if ($lockdb)
		return;
	$items = explode(" ",$data);
	$update = "";
	$i = 0;
	while ($tmp = $items[$i++])
	{
		$data = $user[$tmp];
		if (is_numeric($data))
			$update .= "$tmp=$data";
		else
		{
			sqlQuotes($data);
			$update .= "$tmp='$data'";
		}
		if ($items[$i]) $update .= ",";
	}
	if (!mysql_query("UPDATE $playerdb SET $update WHERE num=$user[num];"))
		print "FATAL ERROR: Failed to update player data $update for user #$user[num]!<BR>\n";
}

// Saves data for a particular user, updating their networth in the process
// MUST specify "networth" among the fields to save!
// Example: saveUserDataNet($users,"networth cash armtrp lndtrp flytrp seatrp etc");
function saveUserDataNet (&$user, $data)
{
	$user[networth] = getNetworth($user);
	return saveUserData($user, $data);
}

// function to return amount of land
function gimmeLand($currland, $bonus, $era)
{
	if ($era == 1)
		$multip = 1.8;
	elseif ($era == 2)
		$multip = 1.4;
	elseif ($era == 3)
		$multip = 1.0;
	
	return ceil((1 / ($currland * .00022 + .25)) * 20 * $bonus * $multip);
}

function calcSizeBonus ($networth)
{
	if ($networth <= 100000)
		$size = 0.524;
	elseif ($networth <= 500000)
		$size = 0.887;
	elseif ($networth <= 1000000)
		$size = 1.145;
	elseif ($networth <= 10000000)
		$size = 1.294;
	elseif ($networth <= 100000000)
		$size = 1.454;
	else	$size = 1.674;
	return $size;
}



function printStatsBar ()
{
	global $users, $uera, $config, $urace;
	if ($users[land] == 0) { $wpa = 0; }
	else
	$wpa = round(sqrt($users[wizards] / $users[land]) * $urace[magic],2);
?>
<script>

document.documentElement.style.webkitTouchCallout = "none";

</script>


<tr>
<form action="../">
<td align="center" width="95" class="c">

<center>
<table width="100%" class="menus">
<b
<select  name="URL"  onchange="window.location.href= this.form.URL.options

[this.form.URL.selectedIndex].value" style="width: 303px;">
    
 'toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1,width=320,height=300')">   <option>Menu</option>
      

    <option value="<?=$config[main]?>?action=main">Main</option>
    <option value="<?=$config[main]?>?action=guide">Game Guide</option>
    <option value="<?=$config[main]?>?action=status">Empire Status</option>
    <option value="<?=$config[main]?>?action=scores">Scores</option>
    <option value="<?=$config[main]?>?action=search">Empire Search</option>
    <option value="<?=$config[main]?>?action=news">News Search</option>
    <option value="<?=$config[main]?>?action=contacts">Clan Contacts</option>
    <option value="<?=$config[main]?>?action=forums">Forum</option>
    <option value="<?=$config[main]?>?action=farm">Farm</option>
    <option value="<?=$config[main]?>?action=cash">Cash</option>
    <option value="<?=$config[main]?>?action=land">Explore</option>
    <option value="<?=$config[main]?>?action=build">Build</option>
    <option value="<?=$config[main]?>?action=pvtmarketbuy">Black Market</option>
    <option value="<?=$config[main]?>?action=pubmarketbuy">Public Market</option>
   
    <option value="<?=$config[main]?>?action=bank">World Bank</option>
    <option value="<?=$config[main]?>?action=lottery">Lottery</option>
    <option value="<?=$config[main]?>?action=aid">Foreign Aid</option>
    <option value="<?=$config[main]?>?action=clan">Clans</option>
    <option value="<?=$config[main]?>?action=military">War Center</option>
    <option value="<?=$config[main]?>?action=magic">Magic Center</option>
	<option value="<?=$config[main]?>?action=messages">Messages</option>
	<option value="<?=$config[main]?>?action=manage">Manage Empire</option>
	<option value="<?=$config[main]?>?action=delete">Delete Account</option>
<option value="<?=$config[main]?>?action=logout">Logout</option>
</select>

<input name="WINDOW_NAMER" type="HIDDEN" value="1">

</form>

</tr>
</table>
</b>

<table style="width:100%">
     <th class="acenter">Turns: <?=$users[turns]?></th>
    <th class="acenter">Money: $<?=commas($users[cash])?></th>
    <th class="acenter">Land: <?=commas($users[land])?></th>
    <th class="acenter"><?=$uera[runes]?>: <?=commas($users[runes])?></th>
</table>
<table style="width:100%">
    <th class="acenter"><?=$uera[food]?>: <?=commas($users[food])?></th>
    <th class="acenter">Health: <?=$users[health]?>%</th>
    <th class="acenter">Networth: $<?=commas($users[networth])?></th></tr>
</table>
<?
}



// Casher Strategy

function strategyCash ()
{
	global $users;
	if (($users[shops] / $users[land]) > .33 && ($users[homes] / $users[land]) > .44)
			return 2;
	else
		return 1;
}

// Indy Strategy

function strategyIndy ()
{
	global $users;
	if (($users[industry] / $users[land]) > .65)
		return 1.6;
	else
		return 1;
}

// Farmer Strategy

function strategyFarm ()
{
	global $users;
	if (($users[farms] / $users[land]) > .65)
		return 1.6;
	else
		return 1;
}

// Expenses

function expenses ()
{
	global $users, $urace;
		$loanpayed = round($users[loan] / 200);
		$expenses = round(($users[armtrp] * .8) + ($users[lndtrp] * 1.2) + ($users[flytrp] * 1.7) + ($users[seatrp] * 2.4) + ($users[land] * 4) + ($users[wizards] * .5));
		$expbonus = round($expenses * ($urace[costs] - ($users[barracks] / $users[land])));
		if ($expbonus > $expenses / 2)				// expenses bonus limit
			$expbonus = round($expenses / 2);
		$expenses -= $expbonus;
		return $expenses;
}			


function popbase ()
{
		global $users;
		$taxrate = $users[tax] / 100;
		if ($users[tax] > 40)
			$taxpenalty = ($taxrate - 0.40) / 2;
		if ($users[tax] < 20)
			$taxpenalty = ($taxrate - 0.20) / 2;
		$popland = $users[land] - $users[homes] + $users[freeland];
		$popbase = round(((5.2 * $popland) + (23 * $users[homes])) / ($taxrate + $taxpenalty));
      if ($popbase > ((10 * $popland) + (80 * $users[homes]))) {
          $popbase=(10 * $users[land]) + (80 * $users[homes]);
      }
    if ($popbase < 50 * $users[homes]) {
        $popbase = 50 * $users[homes];
    }
		return $popbase;

}


// Food Production

function foodpro ()
{
	global $users, $urace;
	return round(($users[freeland] * 15) + ($users[farms] * 75) + ($users[land] * 2) * $urace[farms]);
}


function income ($size)
{
	global $users, $urace;

	$cashbonus=1;
	$pci= pci();
	$taxrate = $users[tax] / 100;
	$health = $users[health] / 100;	
	$income = round(($pci*$cashbonus*$taxrate*$health * $users[peasants]) + ($users[shops] * 1000));
	return $income;
}

round(($pci*$cashbonus*$taxrate*$health * $users[peasants]) + ($users[shops] * 1000));

function foodcon ()
{
	global $users, $urace;
	return round((($users[armtrp] * .04) + ($users[lndtrp] * .010) + ($users[flytrp] * .015) + ($users[seatrp] * .0010) + ($users[peasants] * .03) + ($users[wizards] * .10)) * $urace[food]);
}

// Take a specified number of turns performing the given action
// Valid actions (so far): cash, land, war; others will be added as necessary
function takeTurns ($numturns, $action,$printturns=0)
{
	global $config;
	global $users, $urace, $uera, $landgained, $cashgained, $foodgained, $time;
	if ($users[era] == 1)
	{
		$urace[ind] *= .95;
		$urace[runes] *= 1.4;
	}
	if ($users[era] == 3)
	{
		$urace[ind] *= 1.15;
		$urace[runes] *= .80;
	}

	$users[idle] == time();

	if ($users[cash] < 0)
		$users[cash] = 0;

	if ($users[food] < 0)
		$users[food] = 0;

	// Check turns function
	// - zEro
	// ALPHA Testing...

	CheckTurns($numturns);


	
		if (($action == 'cash') || ($action == 'land') || ($action == 'farm'))	// Actions which can be aborted
		$nonstop = 0;
	else	$nonstop = 1;

	$taken = 0;
	while ($taken < $numturns)					// use up specified number of turns
	{
		$taken++;
		$users[networth] = getNetworth($users);
		if ($action == 'land')					// exploring?
		{
			$tmp = gimmeLand($users[land],$urace[expl],$users[era]);
			$users[land] += $tmp;
			$users[freeland] += $tmp;
			$landgained += $tmp;
		}
		$size = calcSizeBonus($users[networth]);		// size bonus/penalty
		$loanrate = $config[loanbase] + $size;			// update savings and loan
		$saverate = $config[savebase];
		$users[loan] *= 1 + ($loanrate / 52 / 100);
		if ($users[turnsused] > $config[protection])		// no savings interest while under protection
			$users[savings] *= 1 + ($saverate / 52 / 100);
		$users[loan] = round($users[loan]);
		$users[savings] = round($users[savings]);
		if ($users[savings] > ($users[networth] * 1000))
			$users[savings] = $users[networth] * 1000;
// income

		$income = income($size);

		// Here we check the strategy!

		$income *= strategyCash();

		if ($action == 'cash')					// cashing?
			// Era Hack 
			if ($users[era] == 2) {
				$income = round($income * 1.53);
			}
			elseif ($users[era] == 3) {
				$income = round($income * 1.15);
			}
			else
				$income = round($income * 1.25);
		$wartax = 0;
		if ($warflag)						// war tax?
			$wartax = $networth / 1000;


// expenses

		$expenses = expenses();

		$money = $income - ($expenses + $loanpayed + $wartax);
		$cashgained += $money;
		$users[loan] -= $loanpayed;
		$users[cash] += $money;

// build extra units


		$armtrp = ceil(($users[industry] * ($users[ind_armtrp] / 100)) * 8 * $urace[ind]);
		$armtrp *= strategyIndy();
		$users[armtrp] += $armtrp;
		$lndtrp = ceil(($users[industry] * ($users[ind_lndtrp] / 100)) * 4 * $urace[ind]);
		$lndtrp *= strategyIndy();
		$users[lndtrp] += $lndtrp;
		$flytrp = ceil(($users[industry] * ($users[ind_flytrp] / 100)) * 2.5 * $urace[ind]);
		$flytrp *= strategyIndy();
		$users[flytrp] += $flytrp;
		$seatrp = ceil(($users[industry] * ($users[ind_seatrp] / 100)) * 1.25 * $urace[ind]);
		$seatrp *= strategyIndy();
		$users[seatrp] += $seatrp;




// update food

		$foodpro = foodpro();
		$foodcon = foodcon();

		$foodpro *= strategyFarm();

		if ($action == 'farm')					// farming?
			// Era Hack 2 
			if ($users[era] == 2) {
				$foodpro = round($foodpro * 1.15);
			}
			elseif ($users[era] == 3) {
				$foodpro = round($foodpro * 1.25);
			}
			else
				$foodpro = round($foodpro * 1.53);

		$food = $foodpro - $foodcon;
		$users[food] += $food;
		$foodgained += $food;


// health
		if ($users[health] < 101)
			$users[health]++;
		if ($users[health] >= 100) 
			$users[health] = 100;
// taxes
		$taxrate = $users[tax] / 100;
		if ($users[tax] > 40)
			$taxpenalty = ($taxrate - 0.40) / 2;
		if ($users[tax] < 20)
			$taxpenalty = ($taxrate - 0.20) / 2;
// update population

		$popbase = popbase();
	
		if ($users[peasants] != $popbase)
			$peasants = ($popbase - $users[peasants]) / 10;
		if ($users[peasants] < 15)
			$peasants = 15;
		$users[peasants] += $peasants;

// gain magic energy
		$runes = 0;
		if (($users[labs] / $users[land]) > .25)
			$runes = mt_rand(round($users[labs] * 3),round($users[labs] * 3.5));
		else	$runes = round($users[labs] * 3);
		$runes = round($runes * $urace[runes]);
		$users[runes] += $runes;
		$wizards = 0;

// These values in the midst of adjustment

		if ($users[wizards] < ($users[labs] * 30))
			$wizards = round($users[labs] * .7);
		elseif ($users[wizards] < ($users[labs] * 149))
			$wizards = round($users[labs] * .25);
		elseif ($users[wizards] > ($users[labs] * 150))
			$wizards = 0;
		elseif ($users[wizards] > ($users[labs] * 175))
			$wizards = round($users[wizards] * -.075);
		elseif ($users[wizards] > ($users[labs] * 200))
			$wizards = round($users[wizards] * -.2);
		
		$users[wizards] += $wizards;


// print status report
if ($printturns==2) echo ""; // some spam hack - gzip 
else 
{

?>

<table class="empstatus">
<tr><td style="vertical-align:top"><table>
    <tr class="inputtable"><th colspan="2">Economic Status</th></tr>
    <tr><th>Income:</th>
        <td>$<?=commas($income)?></td></tr>
    <tr><th>Expenses:</th>
        <td>$<?=commas($expenses)?></td></tr>
    <tr><th>War Tax:</th>
        <td>$<?=commas($wartax)?></td></tr>
    <tr><th>Loan Pay:</th>
        <td>$<?=commas($loanpayed)?></td></tr>
    <tr><th>Net:</th>
        <td><?printCNum($money,"$",0);?></td></tr>
    </table></td>

    <td style="vertical-align:top"> <table>   
    <tr class="inputtable"><th colspan="2">Agriculture</th></tr>
    <tr><th>Produced:</th>
        <td><?=commas($foodpro)?></td></tr>
    <tr><th>Consumed:</th>
        <td><?=commas($foodcon)?></td></tr>
    <tr><th>Net:</th>
        <td><?printCNum($food,"",0);?></th></tr>
    </table></td>

    <td style="vertical-align:top"><table>
    <tr class="inputtable"><th colspan="2">Population & Military Status</th></tr>
    <tr><th><?=$uera[peasants]?>:</th>
        <td><?printCNum($peasants,"",0);?></td></tr>
    <tr><th><?=$uera[wizards]?>:</th>
        <td><?printCNum($wizards,"",0);?></td></tr>
    <tr><th><?=$uera[runes]?>:</th>
        <td><?printCNum($runes,"",0);?></td></tr>
    <tr><th><?=$uera[armtrp]?>:</th>
        <td><?printCNum($armtrp,"",0);?></td></tr>
    <tr><th><?=$uera[lndtrp]?>:</th>
        <td><?printCNum($lndtrp,"",0);?></td></tr>
    <tr><th><?=$uera[flytrp]?>:</th>
        <td><?printCNum($flytrp,"",0);?></td></tr>
    <tr><th><?=$uera[seatrp]?>:</th>
        <td><?printCNum($seatrp,"",0);?></td></tr>
    </table></td></tr>
</table>

<?
}

		if (($users[tax] > 40) && ($peasants < 0))
		{
if ($printturns==2) echo ""; // some spam hack - gzip 
else 
{

?>
<span class="cbad">Your high tax rate is angering your residents.</span><br>
<?
}
		}
		elseif (($users[tax] < 20) && ($peasants > 0))
		{
if ($printturns==2) echo ""; // some spam hack - gzip 
else 
{

?>
<span class="cgood">Your low tax rate is encouraging immigration.</span><br>
<?
}
		}
if ($printturns==2) echo ""; // some spam hack - gzip 
else 
{

?>
<center><hr style="width:50%">
<?
}
		$users[turnsused]++;
		$users[turns]--;
// ran out of money/food? lose 3% of all units
		if (($users[food] < 0) || ($users[cash] < 0))
		{
			$users[peasants] = round($users[peasants] * .97);
			for ($i = 0; $i < 4; $i++)
				$users[$trplst[$i]] = round($users[$trplst[$i]] * .97);
			$users[wizards] = round($users[wizards] * .97);
			if ($users[food] < 0)	$users[food] = 0;
			if ($users[cash] < 0)	$users[cash] = 0;
?>
<span class="cbad">Due to lack of food or cash, 3% of your population and military have left!<?
			if ($nonstop)
			{
?></span><br>
<?
			}
			else
			{
?> Turns were stopped!</span><br>
<?
				break;
			}
		}
	}
	saveUserDataNet($users,"networth land freeland savings loan cash armtrp lndtrp flytrp seatrp food health peasants runes wizards turnsused turns idle");
	return $taken;
}

function TheEnd ($reason)	// End current action
{
	global $users, $config, $version;
?>
<?=$reason?><br>
<?
	if ($users[num])
		printStatsBar();
?>


<?
	HTMLendfull();
	exit;
}

function printScoreHeader ($color)
{
global $config;
?>
<tr class="era<?=$color?>">
    <th style="width:5%" class="aright">Rank</th>
    <th style="width:25%">Empire</th>
    <th style="width:10%" class="aright">Land</th>
    <th style="width:15%" class="aright">Networth</th>
<? if ($config[clans] > 0)
    print "<th style=\"width:10%\">Clan</th>";
?>
    <th style="width:10%">Race</th>
    <th style="width:5%">Era</th>
    <th style="width:5%">Kills</a></th></tr>
<?
}

function printScoreLine ()
{
	global $users, $enemy, $rtags, $ctags, $etags, $racedb, $eradb, $config;
   $ownclan = loadClan($users[clan]);

	$color = "normal";

	if ($enemy[num] == $users[num])
		$color = "self";

/* as of version 2.2 you can see your clan mates on the score sheet. */

	elseif (($enemy[clan] > 0) && ($enemy[clan] == $users[clan]))
			$color = "ally";

	elseif ($enemy[land] == 0)
		$color = "dead";
	elseif ($enemy[disabled] == 3)
			$color = "disabled";
	elseif ($enemy[disabled] == 2)
			$color = "admin";


	elseif (($enemy[turnsused] <= $config[protection]) || ($enemy[vacation] > $config[vacationdelay]))
		$color = "protected";
?>
<tr class="m<?=$color?>">
    <td class="aright"><?if ($enemy[online]) echo "*";?><?=$enemy[rank]?></td>
    <td class="acenter"><?=$enemy[empire]?> (#<?=$enemy[num]?>)</td>
    <td class="aright"><?=commas($enemy[land])?></td>
    <td class="aright">$<?=commas($enemy[networth])?></td>
<?
	if ($config[clans] > 0) {
		print "<td class=\"acenter\">";
		?><?=$ctags["$enemy[clan]"]?><?
		print "</td>";
	}
?>
    <td class="acenter"><?=$rtags["$enemy[race]"]?></td>
    <td class="acenter"><?=$etags["$enemy[era]"]?></td>
    <td class="acenter"><?=$enemy[kills]?></td></tr>
<?
print "<!-- Enemy clan $enemy[clan] -->";
}

function printSearchHeader ($color)
{

global $config;
?>
<tr class="era<?=$color?>">
    <th style="width:5%" class="aright">Rank</th>
    <th style="width:35%">Empire</th>
    <th style="width:10%" class="aright">Land</th>
    <th style="width:15%" class="aright">Networth</th>
<? if ($config[clans] > 0) { ?>
    <th style="width:10%">Clan</th>
<? } ?>
    <th style="width:10%">Race</th>
    <th style="width:5%">Era</th>
    <th style="width:8%">O</th>
    <th style="width:8%">D</th>
    <th style="width:4%">K</th></tr>
<?
}

function printSearchLine ()
{
	global $users, $enemy, $rtags, $ctags, $etags, $racedb, $eradb, $config, $uclan;
	$color = "normal";
	if ($enemy[num] == $users[num])
		$color = "self";

	elseif ($enemy[land] == 0)
		$color = "dead";
	elseif ($enemy[disabled] == 3)
		$color = "disabled";
	elseif ($enemy[disabled] == 2)
		$color = "admin";
	elseif (($enemy[turnsused] <= $config[protection]) || ($enemy[vacation] > $config[vacationdelay]))
		$color = "protected";
?>
<tr class="m<?=$color?>">
    <td class="aright"><?if ($enemy[online]) echo "*";?><?=$enemy[rank]?></td>
    <td class="acenter"><?=$enemy[empire]?> (#<?=$enemy[num]?>)</td>
    <td class="aright"><?=commas($enemy[land])?></td>
    <td class="aright">$<?=commas($enemy[networth])?></td>
<?
	if ($config[clans] > 0) {
		print "<td class=\"acenter\">";
		?><?=$ctags["$enemy[clan]"]?><?
		print "</td>";	
	}
?>
    <td class="acenter"><?=$rtags["$enemy[race]"]?></td>
    <td class="acenter"><?=$etags["$enemy[era]"]?></td>
    <td class="acenter"><?=$enemy[offtotal]?> (<?if ($enemy[offtotal]) echo round($enemy[offsucc]/$enemy[offtotal]*100); else echo 0;?>%)</td>
    <td class="acenter"><?=$enemy[deftotal]?> (<?if ($enemy[deftotal]) echo round($enemy[defsucc]/$enemy[deftotal]*100); else echo 0;?>%)</td>
    <td class="acenter"><?=$enemy[kills]?></td></tr>
<?
}

function printMainStats ($user, $race, $era)
{
	global $config;
?>
<body>
</tr>
</tr>
<table style=width:313px">
<th width="4">News</th>
	<th colspan="3">Welcome to genesis!</th>
</table>
<table style="width:313px">
<tr class="era<?=$user[era]?>"><th colspan="3"><?=$user[empire]?> (#<?=$user[num]?>)</th></tr>
    <tr><td style="width:40%">
    <table class="empstatus" style="width:100%">
        <tr><th><pink>Turns</pink></th><?              ?><td><label><pink><?=$user[turns]?> </td></pink></tr>
        <tr><th><gold>Turns Stored</gold></th><?       ?><td><label><gold><?=$user[turnsstored]?> (Max <?=$config[maxstoredturns]?>)</gold></label></td></tr>
        <tr><th><red>Rank</th><?               ?><td><label><red>#<?=$user[rank]?></td></tr>
        <tr><th><tan><?=$era[peasants]?></tan></th><??><td><label><tan><?=commas($user[peasants])?></tan></td></tr>
        <tr><th><brown>Land Acres</brown></th><?         ?><td><label><brown><?=commas($user[land])?></td></brown></tr>
        <tr><th><green>Money</green></th><?              ?><td><label><green>$<?=commas($user[cash])?></td></green></tr>
        <tr><th><grey><?=$era[food]?></th></grey><?    ?><td><label><grey><?=commas($user[food])?></td></grey></tr>
        <tr><th><blue><?=$era[runes]?></th></blue><?   ?><td><label><blue><?=commas($user[runes])?></td></blue></tr>
        <tr><th><lightblue>Networth</th></lightblue><?           ?><td><label><lightblue>$<?=commas($user[networth])?></td></lightblue></tr>
    </table></td>
    <td style="width:20%"></td>
    <td style="width:40%">
    <table class="empstatus" style="width:100%">
        <tr><th><orange>Era</th></orange><?               ?><td><label><orange><?=$era[name]?></td></orange></tr>
        <tr><th><corn>Race</th></corn><?              ?><td><label><corn><?=$race[name]?></td></corn></tr>
        <tr><th><lightgreen>Health</th></lightgreen><?            ?><td><label><lightgreen><?=$user[health]?>%</td></lightgreen></tr>
        <tr><th><yellow>Tax Rate</th></yellow><?          ?><td><label><yellow><?=$user[tax]?>%</td></yellow></tr>
        <tr><th><cadet><?=$era[armtrp]?></th></cadet><? ?><td><label><cadet><?=commas($user[armtrp])?></td></cadet></tr>
        <tr><th><almond><?=$era[lndtrp]?></th></almond><? ?><td><label><almond><?=commas($user[lndtrp])?></td></almond></tr>
        <tr><th><sky><?=$era[flytrp]?></th></sky><? ?><td><label><sky><?=commas($user[flytrp])?></td></sky></tr>
        <tr><th><wood><?=$era[seatrp]?></th></wood><? ?><td><label><wood><?=commas($user[seatrp])?></td></wood></tr>
        <tr><th><lightpink><?=$era[wizards]?></th></lightpink><??><td><label><lightpink><?=commas($user[wizards])?></td></lightpink></tr>
    </table></td></tr>
</table>
<?
}

function numNewMessages ()
{
	global $messagedb, $users;
	return sqleval("SELECT COUNT(*) FROM $messagedb WHERE dest=$users[num] AND time>$users[msgtime] AND deleted=0;");
}
function numTotalMessages ()
{
	global $messagedb, $users;
	return sqleval("SELECT COUNT(*) FROM $messagedb WHERE dest=$users[num] AND deleted=0;");
}

// The final 8 arguments are optional
function addNews ($event, $src, $dest, $data0 /*, $data1, $data2, $data3, $data4, $data5, $data6, $data7, $data8*/)
{
	global $newsdb, $time, $lockdb;
	if ($lockdb)
		return;
	$data_l = "data0";
	$data_n = "$data0";

	$numargs = func_num_args();
     
	for ($i = 4; $i < $numargs; $i++)
	{
		$n = func_get_arg($i);
		$data_l .= ",data".($i-3);
		$data_n .= ",".$n;
	}
	mysql_query("INSERT INTO $newsdb (time,num_s,clan_s,num_d,clan_d,event,$data_l) VALUES ($time,$src[num],$src[clan],$dest[num],$dest[clan],$event,$data_n);");
}

function printNews (&$user)
{
	global $newsdb, $playerdb, $clandb, $uera, $time;

	$news = mysql_query("SELECT time,num_s,p1.empire AS name_s,c1.name AS clan_s,p1.era AS era_s,num_d,p2.empire AS name_d,c2.name AS clan_d,p2.era AS era_d,event,data0,data1,data2,data3,data4,data5,data6,data7,data8 FROM $newsdb LEFT JOIN $playerdb AS p1 ON (num_s=p1.num) LEFT JOIN $playerdb AS p2 ON (num_d=p2.num) LEFT JOIN $clandb AS c1 ON (clan_s=c1.num) LEFT JOIN $clandb AS c2 ON (clan_d=c2.num) WHERE num_d=$user[num] AND time>$user[newstime] ORDER BY time ASC;");
	if (!mysql_num_rows($news))
		return 0;
?>
<table class="inputtable" border>
<tr><th>Time</th>
    <th colspan="2">Event</th></tr>
<?
	while ($new = mysql_fetch_array($news))
	{
?>
<tr style="vertical-align:top"><th><?
		$hours = ($time-$new[time])/3600;
		if ($hours > 24)
		{
			$days = floor($hours/24);
			print $days." days, ";
			$hours -= $days*24;
		}
		print round($hours,1)." hours ago";
?></th>
<?
	
		$eera = loadEra($new[era_s]);
		switch ($new[event])
		{
		case 99:
?>    <td colspan="2"><span class="cgood">You have received 6 turns for not logging during 18 hours!</span></td></tr>
<?			break;
		case 100:
			switch ($new[data0])
			{
			case 1:	$type = 'food';		break;
			case 2:	$type = 'armtrp';	break;
			case 3:	$type = 'lndtrp';	break;
			case 4:	$type = 'flytrp';	break;
			case 5:	$type = 'seatrp';	break;
			}
?>    <td colspan="2"><span class="cgood">You sold <?=commas($new[data1])?> <?=$uera[$type]?> on the market for $<?=commas($new[data3])?></span></td></tr>
<?			break;
		case 101:
?>    <td colspan="2"><span class="cgood">The winning lottery ticket number is announced. You look at your lottery ticket and it matches! You have won $<?=commas($new[data0])?>!</span></td></tr>
<?			break;

		case 102:
?>    <td><span class="cgood"><?=$new[name_s]?> (#<?=$new[num_s]?>) has sent you <?=commas($new[data0])?> <?=$uera[seatrp]?> carrying...</span></td>
    <td><?
			if ($new[data1])	print commas($new[data1])." $uera[armtrp]<br>\n";
			if ($new[data2])	print commas($new[data2])." $uera[lndtrp]<br>\n";
			if ($new[data3])	print commas($new[data3])." $uera[flytrp]<br>\n";
			if ($new[data4])	print "$".commas($new[data4])."<br>\n";
			if ($new[data5])	print commas($new[data5])." $uera[runes]<br>\n";
			if ($new[data6])	print commas($new[data6])." $uera[food]<br>\n";
?>    </td></tr>
<?			break;
		case 110:
?>    <td colspan="2"><span class="cgood">You founded <?=$new[clan_d]?>.</span></td></tr>
<?			break;
		case 111:
?>    <td colspan="2"><span class="cwarn">You disbanded <?=$new[clan_d]?>.</span></td></tr>
<?			break;
		case 112:
?>    <td colspan="2"><span class="cgood"><?
			if ($new[num_s] == $new[num_d])
				print "You";
			else	print "$new[name_s] (#$new[num_s])";
?> joined <?=$new[clan_d]?>.</span></td></tr>
<?			break;
		case 113:
?>    <td colspan="2"><span class="cwarn"><?
			if ($new[num_s] == $new[num_d])
				print "You";
			else	print "$new[name_s] (#$new[num_s])";
?> left <?=$new[clan_d]?>.</span></td></tr>
<?			break;
		case 114:
?>    <td colspan="2"><span class="cwarn"><?=$new[name_s]?> (#<?=$new[num_s]?> removed you from <?=$new[clan_d]?>.</span></td></tr>
<?			break;
		case 115:
?>    <td colspan="2"><span class="cgood"><?=$new[name_s]?> (#<?=$new[num_s]?> made you leader of <?=$new[clan_d]?>.</span></td></tr>
<?			break;
		case 116:
?>    <td colspan="2"><span class="cgood">You inherited leadership of <?=$new[clan_d]?>.</span></td></tr>
<?			break;
		case 117:
?>    <td colspan="2"><span class="cwarn"><?=$new[name_s]?> (#<?=$new[num_s]?> dropped you from the disbanded <?=$new[clan_d]?>.</span></td></tr>
<?			break;
		case 118:
?>    <td colspan="2"><span class="cgood"><?=$new[name_s]?> (#<?=$new[num_s]?> made you a Minister of Foreign Affairs of <?=$new[clan_d]?>.</span></td></tr>
<?			break;
		case 119:
?>    <td colspan="2"><span class="cwarn"><?=$new[name_s]?> (#<?=$new[num_s]?> has removed you from your position as Minister of Foreign Affairs of <?=$new[clan_d]?>.</span></td></tr>
<?			break;
		case 201:
?>    <td colspan="2"><span class=<?
			if ($new[data0] < 0)
				print '"cwarn">'."You find $new[name_s] (#$new[num_s]) attempting to view your empire!";
			else	print '"cbad">'."You find another empire viewing your stats!";
?></span></td></tr>
<?			break;
		case 202:
?>    <td colspan="2"><span class=<?
			if ($new[data0] < 0)
				print '"cwarn">'."$new[name_s] (#$new[num_s]) tried to eliminate your forces!";
			else
			{
				print '"cbad">';
				if ($new[data0] == 0)
					print "1";
				else	print "3";
				print "% of your forces were eliminated by $new[name_s] (#$new[num_s])!";
			}
?></span></td></tr>
<?			break;
		case 204:
?>    <td colspan="2"><span class=<?
			if ($new[data0] < 0)
				print '"cwarn">'."You notice $new[name_s] (#$new[num_s]) trying to cause storms on your land!";
			else
			{
				print '"cbad">'."Storms have blown away ".commas($new[data1])." $uera[food] and $".commas($new[data2]);
				if ($new[data0] == 0)
					print ", though your shield protected most of your goods.";
				else	print "!";
			}
?></span></td></tr>
<?			break;
		case 205:
?>    <td colspan="2"><span class=<?
			if ($new[data0] < 0)
				print '"cwarn">'."You find $new[name_s] (#$new[num_s]) attempting to disturb your $uera[runes]!";
			else
			{
				print '"cbad">'."Lightning destroyed ".commas($new[data1])." of your $uera[runes]";
				if ($new[data0] == 0)
					print ", though your shield absorbed most of the damage.";
				else	print "!";
			}
?></span></td></tr>
<?			break;
		case 206:
?>    <td colspan="2"><span class=<?
			if ($new[data0] < 0)
				print '"cwarn">'."You find $new[name_s] (#$new[num_s]) attempting to send monsters into your empire!";
			else
			{
				print '"cbad">'."Monsters have destroyed part of your empire";
				if ($new[data0] == 0)
					print ", though your shield kept most of them out.";
				else	print "!";
			}
?></span></td></tr>
<?			break;
		case 211:
			if ($new[data0] < 0)
			{
?>    <td colspan="2"><span class="cwarn">You find <?=$new[name_s]?> (#<?=$new[num_s]?>) attempting to fight with your <?=$uera[wizards]?>!</span></td></tr>
<?			}
			elseif ($new[data0] == 0)
			{
?>    <td><span class="cwarn">You find <?=$new[name_s]?> (#<?=$new[num_s]?>) losing a fight with your wizards!</span></td>
    <td>You killed <?=$new[data2]?> <?=$eera[wizards]?>, losing <?=$new[data1]?> <?=$uera[wizards]?> in the process.</td></tr>
<?			}
			else
			{
?>    <td><span class="cbad">Your <?=$uera[wizards]?> were defeated by <?=$new[name_s]?> (#<?=$new[num_s]?>) and you lost <?=$new[data0]?> acres of land!</span></td>
    <td>You lost <?=$new[data1]?> <?=$uera[wizards]?>, but you managed to kill <?=$new[data2]?> of your attacker's <?=$eera[wizards]?>.</td></tr>
<?			}
			break;
		case 212:
?>    <td colspan="2"><span class=<?
			if ($new[data0] < 0)
				print '"cwarn">'."You find $new[name_s] (#$new[num_s]) trying to embezzle your money!";
			else
			{
				print '"cbad">'."Someone stole $".commas($new[data1])." from your treasury";
				if ($new[data0] == 0)
					print ", though your shield prevented them from stealing more.";
				else	print "!";
			}
?></span></td></tr>
<?			break;
		case 300:
?>    <td colspan="2"><span class="cwarn">Your forces came to the aid of <?=sqleval("SELECT empire FROM $playerdb WHERE num=$new[data0];")?> (#<?=$new[data0]?>) in defense from <?=$new[name_s]?> (#<?=$new[num_s]?>)!</span></td></tr>
<?			break;
		case 301:
?>    <td colspan="2"><span class="cbad">As <?=$new[name_s]?> (#<?=$new[num_s]?>) delivers their final blow, your empire collapses...</span></td></tr>
<?			break;
		case 302:
		case 303:
?>    <td><span class="cbad"><?=$new[name_s]?> (#<?=$new[num_s]?>) attacked you!</span></td>
    <td><?
			if ($new[data0])
				print "Your enemy captured $new[data0] acres of land and destroyed:<br>";
			else	print "You held your defense and your enemy was repelled, but you lost:<br>";

			if ($new[data1]) print commas($new[data1])." $uera[armtrp]<br>";
			if ($new[data2]) print commas($new[data2])." $uera[lndtrp]<br>";
			if ($new[data3]) print commas($new[data3])." $uera[flytrp]<br>";
			if ($new[data4]) print commas($new[data4])." $uera[seatrp]<br>";
			print "You managed to destroy:<br>";
			if ($new[data5]) print commas($new[data5])." $eera[armtrp]<br>";
			if ($new[data6]) print commas($new[data6])." $eera[lndtrp]<br>";
			if ($new[data7]) print commas($new[data7])." $eera[flytrp]<br>";
			if ($new[data8]) print commas($new[data8])." $eera[seatrp]<br>";
?></td></tr>
<?			break;
		case 304:
		case 305:
		case 306:
		case 307:
			switch ($new[event])
			{
			case 304:	$unit = armtrp;	break;
			case 305:	$unit = lndtrp;	break;
			case 306:	$unit = flytrp;	break;
			case 307:	$unit = seatrp;	break;
			}

?>    <td><span class="cbad"><?=$new[name_s]?> (#<?=$new[num_s]?>) attacked you!</span></td>
    <td><?
			if ($new[data0])
				print "Your enemy captured $new[data0] acres of land and destroyed:<br>";
			else	print "You held your defense and your enemy was repelled, but you lost:<br>";

			if ($new[data1]) print commas($new[data1])." $uera[$unit]<br>";
			print "You managed to destroy:<br>";
			if ($new[data2]) print commas($new[data2])." $eera[$unit]<br>";
?></td></tr>
<?			break;


		}
	}
?>
</table>
<?
	return 1;
}


//Below are all forums related function by Ahmad Farhan


//Function to get data for display of forums(main page)
function loadAllForums()
{
	global $forumdb;
	$query=mysql_query("select * from $forumdb order by forum_id");
	return $query;
}

//same variant of the above function but this time i get 1 particular forum
function forumsData($forum_id)
{
	global $forumdb;
	$query=mysql_query("select * from $forumdb where forum_id='$forum_id'");
	return $query;
}


//Function to get data for display of forums
//(inside the category.where you see the list of all available massages in a category)
function loadForumData($forum_id)
{
	global $threaddb;
	$query=mysql_query("select * from $threaddb where forum_id='$forum_id' and parent_id='0' order by modified desc;");
	return $query;
}

//Function to get data for display of thread list(when you see the massage content and all its reply)
function loadThreadData($thread_id)
{
	global $threaddb;
	$query=mysql_query("select * from $threaddb where thread_id='$thread_id' or parent_id='$thread_id' order by added;");
	return $query;
}

//get the amout of thread int a certain category
function getThread($forum_id)
{
	global $threaddb;
	$query="select count(*) from $threaddb where forum_id='$forum_id' and parent_id='$parent_id'";
	return sqleval($query);
}

//get amount of post in a certain category
function getPost($forum_id)
{
	global $threaddb;
	$query="select count(*) from $threaddb where forum_id='$forum_id'";
	return sqleval($query);
}


//used to parse the content of the post so that all newline charactor is converted into </br>
//and spaces to &nbsp--notes--see what i've change for info on this..
function parseText($text)
{
	$text=ereg_replace(" ","&nbsp",$text);
	$text=ereg_replace("\n","</br>",$text);
	return $text;
}

//to insert the post into the database
function post($parent, $forum, $title, $content, $author)
{
		global $threaddb;
		$query=mysql_query("insert into $threaddb values(null,'$parent','$forum','$title','$content','$author',now(),now())");
		if (!($parent==0))
			$query=mysql_query("update $threaddb set modified=now() where thread_id='$parent'");
}

//update the forums' data
function updateForum($forum_id,$forum_name,$notes,$mod)
{
	global $forumdb;

	if(!$mod)
		$mod=0;
	$query=mysql_query("update $forumdb set forum_name='$forum_name',notes='$notes',mod='$mod' where forum_id='$forum_id'");
}


//add a new forum into the database
function addForum($forum_name,$notes,$mod)
{
	if(!$mod)
		$mod=0;
	global $forumdb;
	$query=mysql_query("insert into $forumdb values(null,'$forum_name','$notes','$mod')");
}


//delete a forum
function deleteForum($forum_id,$orphaned)
{
	global $forumdb;
	$query=mysql_query("delete from $forumdb where forum_id='$forum_id'");
	if ($orphaned==1)
	{
		global $threaddb;
		mysql_query("delete from $threaddb where forum_id='$forum_id'");
	}
}

//get the selected thread/post
function loadPostData($thread_id,$clan)
{
	global $clanThreaddb;
	global $threaddb;

	if ($clan==0)
		$db=$threaddb;
	else
		$db=$clanThreaddb;

	$query=mysql_query("select * from $db where thread_id='$thread_id'");
	return $query;

}

//move the selected thread(forum admin)
function movePost($thread_id,$forum_id)
{
	global $threaddb;
	mysql_query("update $threaddb set forum_id='$forum_id' where thread_id='$thread_id' or parent_id='$thread_id'");


}

//edit title
function editTitle($thread_id,$title,$clan)
{
	global $clanThreaddb;
	global $threaddb;

	if ($clan==0)
		$db=$threaddb;
	else
		$db=$clanThreaddb;
	mysql_query("update $db set title='$title' where thread_id ='$thread_id'");
}

//edit content
function editContent($thread_id,$content,$clan)
{
	global $clanThreaddb;
	global $threaddb;

	if ($clan==0)
		$db=$threaddb;
	else
		$db=$clanThreaddb;
	mysql_query("update $db set content='$content' where thread_id ='$thread_id'");
}

//create new  clan forum forum(used when creating a clan.. )
function createClanForum($clan_id,$clan_name)
{
	global $clanForumdb;
	$clan_name .= " clan forum";
	mysql_query("insert into $clanForumdb values('$clan_id','$clan_name')");
}

// delete a clan forum(when disbanding a clan)
function deleteClanForum($clan_id)
{
	global $clanForumdb;
	mysql_query("delete from $clanForumdb where num='$clan_id'");
}

//load the clan forum.:)
function loadClanForum ($num)
{
	global $clanForumdb;
	$query="SELECT name FROM $clanForumdb WHERE num='$num'";
	return sqleval($query);
}

//a variation of the loadForumData() funtion but instead this one load the data for the clan forum
function loadClanForumData($num)
{
	global $clanThreaddb;
	$query=mysql_query("select * from $clanThreaddb where forum=$num and parent_id='0' order by modified desc");
	return $query;
}

//a variation of the post() function for the clan forum
function clanPost($clan_id,$parent,$empire,$title, $content)
{
		global $clanThreaddb;
		$query=mysql_query("insert into $clanThreaddb values('$clan_id','$parent',null,now(),'$empire','$title','$content',now())");
		if (!($parent==0))
			$query=mysql_query("update $threaddb set modified=now() where thread_id='$parent'");
}


//a variation of the loadThreadData() function...for them clan forums....
function loadClanThreadData($thread_id)
{
	global $clanThreaddb;
	$query=mysql_query("select * from $clanThreaddb where thread_id='$thread_id' or parent_id='$thread_id' order by added;");
	return $query;
}

//same as getPost function only i modified it to get the amount of replies in a thread
function getReplies($thread_id)
{
	global $threaddb;
	$query="select count(*) from $threaddb where parent_id='$thread_id'";
	return sqleval($query);
}
// variation of getReplies function for use with clan forum
function getClanReplies($thread_id)
{
	global $clanThreaddb;
	$query="select count(*) from $clanThreaddb where parent_id='$thread_id'";
	return sqleval($query);
}

//get user's title(normal user,forum admin etc. etc.)
//eg. getTitle(checklevel($user[disabled]))
function getTitle($id)
{
	global $titledb;
	$query="select title from $titledb where id='$id'";
	return sqleval($query);


}

//used to get the chacklevel of a specific user given thier alias
function getCheckLevel($alias)
{
	global $playerdb;
	$query="select disabled from $playerdb where alias='$alias' ";
	$disabled= sqleval($query);
	return checklevel($disabled);

}

//used to get the leader of a clan(used in clan forums)
//eg. leader=getClanLeader($users[clan]);
function getClanLeader($clan_id)
{
	global $clandb;
	$query="select founder from $clandb where num='$clan_id'";
	return sqleval($query);

}

// used to get the last person to post in a post $clan=1 when in clan forum and clan=0 when in normal forum
function getLastPoster($thread_id,$clan)
{
	global $threaddb;
	global $clanThreaddb;
	if ($clan==0)
		$db=$threaddb;
	else
		$db=$clanThreaddb;

	$query="select author from $db where thread_id=\"$thread_id\" or parent_id=\"$thread_id\" order by added desc";
	return sqleval($query);

}

/* Here starts the part for messages.php */


// Messages Function

function do_parse ($body) { /* Font Styles Added 05:32 a.m. 29/03/2002 By gzip*/   
 
$body = strip_tags($body);   
    
$body = ereg_replace("\[b\]", "<b>", $body);    
$body = ereg_replace("\[/b\]", "</b>", $body);    
$body = ereg_replace("\[i\]", "<i>", $body);    
$body = ereg_replace("\[/i\]", "</i>", $body);    
$body = ereg_replace("\[u\]", "<u>", $body);   
$body = ereg_replace("\[/u\]", "</u>", $body);    
$body = ereg_replace("\[code\]", "<pre>", $body);    
$body = ereg_replace("\[/code\]", "</pre>", $body);  
$body = ereg_replace("\[big\]", "<h2>", $body);    
$body = ereg_replace("\[/big\]", "</h2>", $body);  
$body = ereg_replace("\[medium\]", "<h3>", $body);    
$body = ereg_replace("\[/medium\]", "</h3>", $body);  
$body = ereg_replace("\[/color\]", "</font>", $body); 
  
$body = ereg_replace("\[color:", "<font size:1 color=", $body);   
$body = ereg_replace("\]", ">", $body);    
 
return $body;   
}



?>

Thanks

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by 4789787
0

Wow! Too much code posted.
Anyway, did you happen to notice the sticky at the very top of the forum?
Does it look familiar?

0

What sticky? I dont see anything having to do with my problem..

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.