• 12-10-2009, 13:23:47
    #1
    Arkadaşlar PHP bölümünde açtım böyle bir konu ama genel itibariyle adsense ile alakadar olabileceği için bu bölüme de açıyorum.

    Selamlar arkadaşlar. Bir ogame simülasyonu oyunum var. Ve premium hesap kullanmayanlarda genel durum bölümünde adsense kodlarım çıkıyor. Bunu diğer sayfalarıma da yapmak istiyorum fakat eklediğimde hiçbir değişiklik olmuyor. Başarıyla çalışan genel durum sayfamın kodları;
    <?php
    ##############################################################################
    # *																			 #
    # * XG PROYECT																 #
    # *  																		 #
    # * @copyright Copyright (C) 2008 - 2009 By lucky from Xtreme-gameZ.com.ar	 #
    # *																			 #
    # *																			 #
    # *  This program is free software: you can redistribute it and/or modify    #
    # *  it under the terms of the GNU General Public License as published by    #
    # *  the Free Software Foundation, either version 3 of the License, or       #
    # *  (at your option) any later version.									 #
    # *																			 #
    # *  This program is distributed in the hope that it will be useful,		 #
    # *  but WITHOUT ANY WARRANTY; without even the implied warranty of			 #
    # *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the			 #
    # *  GNU General Public License for more details.							 #
    # *																			 #
    ##############################################################################
    if(!defined('INSIDE')){ die(header("location:../../"));}
    function ShowOverviewPage($CurrentUser, $CurrentPlanet)
    {
    	global $xgp_root, $phpEx, $dpath, $game_config, $lang, $planetrow, $user;
    	include_once($xgp_root . 'includes/functions/InsertJavaScriptChronoApplet.' . $phpEx);
    	include_once($xgp_root . 'includes/classes/class.FlyingFleetsTable.' . $phpEx);
    	$FlyingFleetsTable = new FlyingFleetsTable();
    //Otomatik puan güncelleme
    $Tempo    = time();
                $kalan = $Tempo - $game_config['Otopuan'];
                $zaman = 60; //60 (Saniye) = 1 Dk / 3600 (Saniye) = 1 saat
                if($kalan > $zaman) { include("././otopuan.php");   }
    	$lunarow = doquery("SELECT * FROM {{table}} WHERE `id_owner` = '" . $CurrentPlanet['id_owner'] . "' AND `galaxy` = '" . $CurrentPlanet['galaxy'] . "' AND `system` = '" . $CurrentPlanet['system'] . "' AND `lunapos` = '" . $CurrentPlanet['planet'] . "';", 'lunas', true);
    	CheckPlanetUsedFields($lunarow);
    	$parse					= $lang;
    	$parse['planet_id'] 	= $CurrentPlanet['id'];
    	$parse['planet_name'] 	= $CurrentPlanet['name'];
    	$parse['galaxy_galaxy'] = $CurrentPlanet['galaxy'];
    	$parse['galaxy_system'] = $CurrentPlanet['system'];
    	$parse['galaxy_planet'] = $CurrentPlanet['planet'];
    	switch ($_GET['mode'])
    	{
    		case 'renameplanet':
    			if ($_POST['action'] == $lang['ov_planet_rename_action'])
    			{
    				$newname        = mysql_escape_string(strip_tags(trim($_POST['newname'])));
    				if (preg_match("/[^A-z0-9_\- ]/", $newname) == 1)
    				{
    					message($lang['ov_newname_error'], "game.php?page=overview&mode=renameplanet",2);
    				}
    				if ($newname != "")
    				{
    					doquery("UPDATE {{table}} SET `name` = '" . $newname . "' WHERE `id` = '" . $CurrentUser['current_planet'] . "' LIMIT 1;", "planets");
    					if ($CurrentPlanet['planet_type'] == 3)
    					{
    						doquery("UPDATE {{table}} SET `name` = '" . $newname . "' WHERE `galaxy` = '" . $CurrentPlanet['galaxy'] . "' AND `system` = '" . $CurrentPlanet['system'] . "' AND `lunapos` = '" . $CurrentPlanet['planet'] . "' LIMIT 1;", "lunas");
    					}
    				}
    			}
    			elseif ($_POST['action'] == $lang['ov_abandon_planet'])
    			{
    				return display(parsetemplate(gettemplate('overview/overview_deleteplanet'), $parse));
    			}
    			elseif ($_POST['kolonieloeschen'] == 1 && intval($_POST['deleteid']) == $CurrentUser['current_planet'])
    			{
    				if (md5($_POST['pw']) == $CurrentUser["password"] && $CurrentUser['id_planet'] != $CurrentUser['current_planet'])
    				{
    				// Koloni terketme başlangıç	
    				$sg = doquery("SELECT id,planet_type,galaxy,system,planet FROM {{table}} WHERE `id` = '". $user['current_planet'] ."';", 'planets', true);
    				$galaxy=$sg['galaxy'];
    				$system=$sg['system'];
    				$planet=$sg['planet'];
    				$lunapos=$sg['planet'];
    				if ($sg['planet_type']=="3")
    				{					
    					doquery("DELETE FROM {{table}} WHERE `lunapos` = '". $lunapos ."' and `galaxy` = '". $galaxy ."' and `system` = '". $system ."';", 'lunas');
    					doquery("DELETE FROM {{table}} WHERE `id` = '". $user['current_planet'] ."';", 'planets');
    					doquery("UPDATE {{table}} SET `id_luna` = '0' WHERE galaxy='{$galaxy}' and system='{$system}' and planet='{$planet}'", "galaxy");
    				}
    				else
    				{					
    					//$ay = doquery("SELECT * FROM {{table}} WHERE `id_planet` = '". $user['current_planet'] ."';", 'galaxy', true);
    					doquery("DELETE FROM {{table}} WHERE `lunapos` = '". $lunapos ."' and `galaxy` = '". $galaxy ."' and `system` = '". $system ."';", 'lunas');
    					doquery("DELETE FROM {{table}} WHERE `planet` = '". $planet ."' and `galaxy` = '". $galaxy ."' and `system` = '". $system ."';", 'planets');
    					doquery("DELETE FROM {{table}} WHERE `id_planet` = '". $user['current_planet'] ."';", 'galaxy');
    				}	
    					$QryUpdateUser    = "UPDATE {{table}} SET ";
    					$QryUpdateUser   .= "`current_planet` = `id_planet` ";
    					$QryUpdateUser   .= "WHERE ";
    					$QryUpdateUser   .= "`id` = '". $user['id'] ."' LIMIT 1";
    					doquery( $QryUpdateUser, "users");
    					message($lang['ov_planet_abandoned'], 'game.php?page=overview&mode=renameplanet');
    				}
    				elseif ($CurrentUser['id_planet'] == $CurrentUser["current_planet"])
    				{
    					message($lang['ov_principal_planet_cant_abanone'], 'game.php?page=overview&mode=renameplanet');
    				}
    				else
    				{
    					message($lang['ov_wrong_pass'], 'game.php?page=overview&mode=renameplanet');
    				}
    			}
    			return display(parsetemplate(gettemplate('overview/overview_renameplanet'), $parse));
    		break;
    		default:
    			if ($CurrentUser['new_message'] != 0)
    			{
    				$Have_new_message .= "<tr>";
    				if ($CurrentUser['new_message'] == 1)
    				{
    					$Have_new_message .= "<th colspan=4><a href=game.$phpEx?page=messages>". $lang['ov_have_new_message'] ."</a></th>";
    				}
    				elseif ($CurrentUser['new_message'] > 1)
    				{
    					$Have_new_message .= "<th colspan=4><a href=game.$phpEx?page=messages>";
    					$Have_new_message .= str_replace('%m', pretty_number($CurrentUser['new_message']), $lang['ov_have_new_messages']);
    					$Have_new_message .= "</a></th>";
    				}
    				$Have_new_message .= "</tr>";
    			}
    			$OwnFleets = doquery("SELECT * FROM {{table}} WHERE `fleet_owner` = '" . $CurrentUser['id'] . "';", 'fleets');
    			$Record = 0;
    			while ($FleetRow = mysql_fetch_array($OwnFleets))
    			{
    				$Record++;
    				$StartTime 	= $FleetRow['fleet_start_time'];
    				$StayTime 	= $FleetRow['fleet_end_stay'];
    				$EndTime 	= $FleetRow['fleet_end_time'];
    				$Label = "fs";
    				if ($StartTime > time())
    				{
    					$fpage[$StartTime] = $FlyingFleetsTable->BuildFleetEventTable ($FleetRow, 0, true, $Label, $Record);
    				}
    				if(($FleetRow['fleet_mission'] <> 4) && ($FleetRow['fleet_mission'] <> 10))
    				{
    					$Label = "ft";
    					if ($StayTime > time())
    					{
    						$fpage[$StayTime] = $FlyingFleetsTable->BuildFleetEventTable ($FleetRow, 1, true, $Label, $Record);
    					}
    					$Label = "fe";
    					if ($EndTime > time())
    					{
    						$fpage[$EndTime] = $FlyingFleetsTable->BuildFleetEventTable ($FleetRow, 2, true, $Label, $Record);
    					}
    				}
    			}
    			$OtherFleets = doquery("SELECT * FROM {{table}} WHERE `fleet_target_owner` = '" . $CurrentUser['id'] . "';", 'fleets');
    			$Record = 2000;
    			while ($FleetRow = mysql_fetch_array($OtherFleets))
    			{
    				if ($FleetRow['fleet_owner'] != $CurrentUser['id'])
    				{
    					if ($FleetRow['fleet_mission'] != 8)
    					{
    						$Record++;
    						$StartTime = $FleetRow['fleet_start_time'];
    						$StayTime = $FleetRow['fleet_end_stay'];
    						if ($StartTime > time())
    						{
    							$Label = "ofs";
    							$fpage[$StartTime] = $FlyingFleetsTable->BuildFleetEventTable ($FleetRow, 0, false, $Label, $Record);
    						}
    						if ($FleetRow['fleet_mission'] == 5)
    						{
    							$Label = "oft";
    							if ($StayTime > time())
    							{
    								$fpage[$StayTime] = $FlyingFleetsTable->BuildFleetEventTable ($FleetRow, 1, false, $Label, $Record);
    							}
    						}
    					}
    				}
    			}
    			$planets_query = doquery("SELECT * FROM `{{table}}` WHERE id_owner='{$CurrentUser['id']}' AND `destruyed` = 0", "planets");
    			$Colone  	= 1;
    			$AllPlanets = "<tr>";
    			while ($CurrentUserPlanet = mysql_fetch_array($planets_query))
    			{
    				if ($CurrentUserPlanet["id"] != $CurrentUser["current_planet"] && $CurrentUserPlanet['planet_type'] != 3)
    				{
    					$Coloneshow++;
    					$AllPlanets .= "<th>". $CurrentUserPlanet['name'] ."<br>";
    					$AllPlanets .= "<a href=\"game.php?page=overview&cp=". $CurrentUserPlanet['id'] ."&re=0\" title=\"". $CurrentUserPlanet['name'] ."\"><img src=\"". $dpath ."planeten/small/s_". $CurrentUserPlanet['image'] .".jpg\" height=\"50\" width=\"50\"></a><br>";
    					$AllPlanets .= "<center>";
    					if ($CurrentUserPlanet['b_building'] != 0)
    					{
    						UpdatePlanetBatimentQueueList ($CurrentUserPlanet, $CurrentUser);
    						if ($CurrentUserPlanet['b_building'] != 0 )
    						{
    							$BuildQueue      = $CurrentUserPlanet['b_building_id'];
    							$QueueArray      = explode ( ";", $BuildQueue );
    							$CurrentBuild    = explode ( ",", $QueueArray[0] );
    							$BuildElement    = $CurrentBuild[0];
    							$BuildLevel      = $CurrentBuild[1];
    							$BuildRestTime   = pretty_time( $CurrentBuild[3] - time() );
    							$AllPlanets     .= '' . $lang['tech'][$BuildElement] . ' (' . $BuildLevel . ')';
    							$AllPlanets     .= "<br><font color=\"#7f7f7f\">(". $BuildRestTime .")</font>";
    						}
    						else
    						{
    							CheckPlanetUsedFields ($CurrentUserPlanet);
    							$AllPlanets     .= $lang['ov_free'];
    						}
    					}
    					else
    					{
    						$AllPlanets    .= $lang['ov_free'];
    					}
    					$AllPlanets .= "</center></th>";
    					if ($Colone <= 1)
    						$Colone++;
    					else
    					{
    						$AllPlanets .= "</tr><tr>";
    						$Colone = 1;
    					}
    				}
    			}
    			$AllPlanets .= "</tr>";
    			if ($lunarow['id'] <> 0 && $lunarow['destruyed'] != 1 && $CurrentPlanet['planet_type'] != 3)
    			{
    				if ($CurrentPlanet['planet_type'] == 1 or $lunarow['id'] <> 0)
    				{
    					$moon = doquery ("SELECT `id`,`name`,`image` FROM {{table}} WHERE `galaxy` = '" . $CurrentPlanet['galaxy'] . "' AND `system` = '" . $CurrentPlanet['system'] . "' AND `planet` = '" . $CurrentPlanet['planet'] . "' AND `planet_type` = '3'", 'planets', true);
    					$parse['moon_img'] = "<a href=\"game.php?page=overview&cp=" . $moon['id'] . "&re=0\" title=\"" . $moon['name'] . "\"><img src=\"" . $dpath . "planeten/" . $moon['image'] . ".jpg\" height=\"50\" width=\"50\"></a>";
    					$parse['moon'] = $moon['name'] ." (" . $lang['fcm_moon'] . ")";
    				}
    				else
    				{
    					$parse['moon_img'] = "";
    					$parse['moon'] = "";
    				}
    			}
    			else
    			{
    				$parse['moon_img'] = "";
    				$parse['moon'] = "";
    			}
    			$parse['planet_diameter'] 		= pretty_number($CurrentPlanet['diameter']);
    			$parse['planet_field_current']  = $CurrentPlanet['field_current'];
    			$parse['planet_field_max'] 		= CalculateMaxPlanetFields($CurrentPlanet);
    			$parse['planet_temp_min'] 		= $CurrentPlanet['temp_min'];
    		    // Reklam -
    if ($CurrentUser['commander']>time()) {$parse['reklam'] = "";} else {$parse['reklam']='<script type="text/javascript"><!--
    google_ad_client = "pub-1670857600071293";
    /* ogame son */
    google_ad_slot = "6002813181";
    google_ad_width = 468;
    google_ad_height = 60;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>';}
    			$parse['planet_temp_max'] 		= $CurrentPlanet['temp_max'];
    			$StatRecord = doquery("SELECT `total_rank`,`total_points` FROM `{{table}}` WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . $CurrentUser['id'] . "';", 'statpoints', true);
    			$parse['user_username']        = $CurrentUser['username'];
    			if (count($fpage) > 0)
    			{
    				ksort($fpage);
    				foreach ($fpage as $time => $content)
    				{
    					$flotten .= $content . "\n";
    				}
    			}
    			if ($CurrentPlanet['b_building'] != 0)
    			{
    				include($xgp_root . 'includes/functions/InsertBuildListScript.' . $phpEx);
    				UpdatePlanetBatimentQueueList ($planetrow, $user);
    				if ($CurrentPlanet['b_building'] != 0)
    				{
    					$BuildQueue  		 = explode (";", $CurrentPlanet['b_building_id']);
    					$CurrBuild 	 		 = explode (",", $BuildQueue[0]);
    					$RestTime 	 		 = $CurrentPlanet['b_building'] - time();
    					$PlanetID 	 		 = $CurrentPlanet['id'];
    					$Build 		 		 = InsertBuildListScript ("overview");
    					$Build 	   			.= $lang['tech'][$CurrBuild[0]] . ' (' . ($CurrBuild[1]) . ')';
    					$Build 				.= "<br /><div id=\"blc\" class=\"z\">" . pretty_time($RestTime) . "</div>";
    					$Build 				.= "\n<script language=\"JavaScript\">";
    					$Build 				.= "\n	pp = \"" . $RestTime . "\";\n";
    					$Build 				.= "\n	pk = \"" . 1 . "\";\n";
    					$Build 				.= "\n	pm = \"cancel\";\n";
    					$Build 				.= "\n	pl = \"" . $PlanetID . "\";\n";
    					$Build 				.= "\n	t();\n";
    					$Build 				.= "\n</script>\n";
    					$parse['building'] 	 = $Build;
    				}
    				else
    				{
    					$parse['building'] = $lang['ov_free'];
    				}
    			}
    			else
    			{
    				$parse['building'] = $lang['ov_free'];
    			}
    			$parse['fleet_list']  			= $flotten;
    			$parse['Have_new_message'] 		= $Have_new_message;
    			$parse['planet_image'] 			= $CurrentPlanet['image'];
    			$parse['anothers_planets'] 		= $AllPlanets;
    			$parse["dpath"] 				= $dpath;
    			if($game_config['stat'] == 0)
    				$parse['user_rank']			= pretty_number($StatRecord['total_points']) . " (". $lang['ov_place'] ." <a href=\"game.php?page=statistics&range=".$StatRecord['total_rank']."\">".$StatRecord['total_rank']."</a> ". $lang['ov_of'] ." ".$game_config['users_amount'].")";
    			elseif($game_config['stat'] == 1 && $CurrentUser['authlevel'] < $game_config['stat_level'])
    				$parse['user_rank']			= pretty_number($StatRecord['total_points']) . " (". $lang['ov_place'] ." <a href=\"game.php?page=statistics&range=".$StatRecord['total_rank']."\">".$StatRecord['total_rank']."</a> ". $lang['ov_of'] ." ".$game_config['users_amount'].")";
    			else
    				$parse['user_rank']			= "-";
    			$parse['date_time']				= date("D M j H:i:s", time());
    			return display(parsetemplate(gettemplate('overview/overview_body'), $parse));
    		break;
    	}
    }
    ?>
    Reklam kodum;
    // Reklam -
    if ($CurrentUser['commander']>time()) {$parse['reklam'] = "";} else {$parse['reklam']='<script type="text/javascript"><!--
    google_ad_client = "pub-1670857600071293";
    /* ogame son */
    google_ad_slot = "6002813181";
    google_ad_width = 468;
    google_ad_height = 60;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>';}
  • 12-10-2009, 13:24:30
    #2
    Eklemek istediğim başka bir sayfanın kodu;
    <?php
    ##############################################################################
    # *																			 #
    # * XG PROYECT																 #
    # *  																		 #
    # * @copyright Copyright (C) 2008 - 2009 By lucky from Xtreme-gameZ.com.ar	 #
    # *																			 #
    # *																			 #
    # *  This program is free software: you can redistribute it and/or modify    #
    # *  it under the terms of the GNU General Public License as published by    #
    # *  the Free Software Foundation, either version 3 of the License, or       #
    # *  (at your option) any later version.									 #
    # *																			 #
    # *  This program is distributed in the hope that it will be useful,		 #
    # *  but WITHOUT ANY WARRANTY; without even the implied warranty of			 #
    # *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the			 #
    # *  GNU General Public License for more details.							 #
    # *																			 #
    ##############################################################################
    if(!defined('INSIDE')){ die(header("location:../../"));}
    class ShowBuildingsPage
    {
    	private function BuildingSavePlanetRecord ($CurrentPlanet)
    	{
    		$QryUpdatePlanet  = "UPDATE {{table}} SET ";
    		$QryUpdatePlanet .= "`b_building_id` = '". $CurrentPlanet['b_building_id'] ."', ";
    		$QryUpdatePlanet .= "`b_building` = '".    $CurrentPlanet['b_building']    ."' ";
    		$QryUpdatePlanet .= "WHERE ";
    		$QryUpdatePlanet .= "`id` = '".            $CurrentPlanet['id']            ."';";
    		doquery( $QryUpdatePlanet, 'planets');
    		return;
    	}
    	private function CancelBuildingFromQueue (&$CurrentPlanet, &$CurrentUser)
    	{
    		$CurrentQueue  = $CurrentPlanet['b_building_id'];
    		if ($CurrentQueue != 0)
    		{
    			$QueueArray          = explode ( ";", $CurrentQueue );
    			$ActualCount         = count ( $QueueArray );
    			$CanceledIDArray     = explode ( ",", $QueueArray[0] );
    			$Element             = $CanceledIDArray[0];
    			$BuildMode           = $CanceledIDArray[4];
    			if ($ActualCount > 1)
    			{
    				array_shift( $QueueArray );
    				$NewCount        = count( $QueueArray );
    				$BuildEndTime    = time();
    				for ($ID = 0; $ID < $NewCount ; $ID++ )
    				{
    					$ListIDArray          = explode ( ",", $QueueArray[$ID] );
    					$BuildEndTime        += $ListIDArray[2];
    					$ListIDArray[3]       = $BuildEndTime;
    					$QueueArray[$ID]      = implode ( ",", $ListIDArray );
    				}
    				$NewQueue        = implode(";", $QueueArray );
    				$ReturnValue     = true;
    				$BuildEndTime    = '0';
    			}
    			else
    			{
    				$NewQueue        = '0';
    				$ReturnValue     = false;
    				$BuildEndTime    = '0';
    			}
    			if ($BuildMode == 'destroy')
    			{
    				$ForDestroy = true;
    			}
    			else
    			{
    				$ForDestroy = false;
    			}
    			if ( $Element != false ) {
    			$Needed                        = GetBuildingPrice ($CurrentUser, $CurrentPlanet, $Element, true, $ForDestroy);
    			$CurrentPlanet['metal']       += $Needed['metal'];
    			$CurrentPlanet['crystal']     += $Needed['crystal'];
    			$CurrentPlanet['deuterium']   += $Needed['deuterium'];
    			}
    		}
    		else
    		{
    			$NewQueue          = '0';
    			$BuildEndTime      = '0';
    			$ReturnValue       = false;
    		}
    		$CurrentPlanet['b_building_id']  = $NewQueue;
    		$CurrentPlanet['b_building']     = $BuildEndTime;
    		return $ReturnValue;
    	}
    	private function RemoveBuildingFromQueue ( &$CurrentPlanet, $CurrentUser, $QueueID )
    	{
    		if ($QueueID > 1)
    		{
    			$CurrentQueue  = $CurrentPlanet['b_building_id'];
    			if ($CurrentQueue != 0)
    			{
    				$QueueArray    = explode ( ";", $CurrentQueue );
    				$ActualCount   = count ( $QueueArray );
    				$ListIDArray   = explode ( ",", $QueueArray[$QueueID - 2] );
    				$BuildEndTime  = $ListIDArray[3];
    				for ($ID = $QueueID; $ID < $ActualCount; $ID++ )
    				{
    					$ListIDArray          = explode ( ",", $QueueArray[$ID] );
    					$BuildEndTime        += $ListIDArray[2];
    					$ListIDArray[3]       = $BuildEndTime;
    					$QueueArray[$ID - 1]  = implode ( ",", $ListIDArray );
    				}
    				unset ($QueueArray[$ActualCount - 1]);
    				$NewQueue     = implode ( ";", $QueueArray );
    			}
    			$CurrentPlanet['b_building_id'] = $NewQueue;
    		}
    		return $QueueID;
    	}
    	private function AddBuildingToQueue (&$CurrentPlanet, $CurrentUser, $Element, $AddMode = true)
    	{
    		global $resource;
    		$CurrentQueue  = $CurrentPlanet['b_building_id'];
    		$Queue 				= $this->ShowBuildingQueue($CurrentPlanet, $CurrentUser);
    		$CurrentMaxFields  	= CalculateMaxPlanetFields($CurrentPlanet);
    		if ($CurrentPlanet["field_current"] >= ($CurrentMaxFields - $Queue['lenght']) && $_GET['cmd'] != 'destroy')
    			die(header("location:game.php?page=buildings"));
    		if ($CurrentQueue != 0)
    		{
    			$QueueArray    = explode ( ";", $CurrentQueue );
    			$ActualCount   = count ( $QueueArray );
    		}
    		else
    		{
    			$QueueArray    = "";
    			$ActualCount   = 0;
    		}
    		if ($AddMode == true)
    		{
    			$BuildMode = 'build';
    		}
    		else
    		{
    			$BuildMode = 'destroy';
    		}
    	if ($CurrentUser['commander']>time()) {$max=COMMANDER_BINA;} else {$max=NORMAL_BINA;}
    		if ( $ActualCount < $max)
    		{
    			$QueueID      = $ActualCount + 1;
    		}
    		else
    		{
    			$QueueID      = false;
    		}
    		if ( $QueueID != false )
    		{
    			if ($QueueID > 1)
    			{
    				$InArray = 0;
    				for ( $QueueElement = 0; $QueueElement < $ActualCount; $QueueElement++ )
    				{
    					$QueueSubArray = explode ( ",", $QueueArray[$QueueElement] );
    					if ($QueueSubArray[0] == $Element)
    					{
    						$InArray++;
    					}
    				}
    			}
    			else
    			{
    				$InArray = 0;
    			}
    			if ($InArray != 0)
    			{
    				$ActualLevel  = $CurrentPlanet[$resource[$Element]];
    				if ($AddMode == true)
    				{
    					$BuildLevel   = $ActualLevel + 1 + $InArray;
    					$CurrentPlanet[$resource[$Element]] += $InArray;
    					$BuildTime    = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
    					$CurrentPlanet[$resource[$Element]] -= $InArray;
    				}
    				else
    				{
    					$BuildLevel   = $ActualLevel - 1 - $InArray;
    					$CurrentPlanet[$resource[$Element]] -= $InArray;
    					$BuildTime    = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element) / 2;
    					$CurrentPlanet[$resource[$Element]] += $InArray;
    				}
    			}
    			else
    			{
    				$ActualLevel  = $CurrentPlanet[$resource[$Element]];
    				if ($AddMode == true)
    				{
    					$BuildLevel   = $ActualLevel + 1;
    					$BuildTime    = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
    				}
    				else
    				{
    					$BuildLevel   = $ActualLevel - 1;
    					$BuildTime    = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element) / 2;
    				}
    			}
    			if ($QueueID == 1)
    			{
    				$BuildEndTime = time() + $BuildTime;
    			}
    			else
    			{
    				$PrevBuild = explode (",", $QueueArray[$ActualCount - 1]);
    				$BuildEndTime = $PrevBuild[3] + $BuildTime;
    			}
    			$QueueArray[$ActualCount]       = $Element .",". $BuildLevel .",". $BuildTime .",". $BuildEndTime .",". $BuildMode;
    			$NewQueue                       = implode ( ";", $QueueArray );
    			$CurrentPlanet['b_building_id'] = $NewQueue;
    		}
    		return $QueueID;
    	}
    	private function ShowBuildingQueue ( $CurrentPlanet, $CurrentUser )
    	{
    		global $lang;
    		$CurrentQueue  = $CurrentPlanet['b_building_id'];
    		$QueueID       = 0;
    		if ($CurrentQueue != 0)
    		{
    			$QueueArray    = explode ( ";", $CurrentQueue );
    			$ActualCount   = count ( $QueueArray );
    		}
    		else
    		{
    			$QueueArray    = "0";
    			$ActualCount   = 0;
    		}
    		$ListIDRow    = "";
    		if ($ActualCount != 0)
    		{
    			$PlanetID     = $CurrentPlanet['id'];
    			for ($QueueID = 0; $QueueID < $ActualCount; $QueueID++)
    			{
    				$BuildArray   = explode (",", $QueueArray[$QueueID]);
    				$BuildEndTime = floor($BuildArray[3]);
    				$CurrentTime  = floor(time());
    				if ($BuildEndTime >= $CurrentTime)
    				{
    					$ListID       = $QueueID + 1;
    					$Element      = $BuildArray[0];
    					$BuildLevel   = $BuildArray[1];
    					$BuildMode    = $BuildArray[4];
    					$BuildTime    = $BuildEndTime - time();
    					$ElementTitle = $lang['tech'][$Element];
    					if ($ListID > 0)
    					{
    						$ListIDRow .= "<tr>";
    						if ($BuildMode == 'build')
    						{
    							$ListIDRow .= "	<td class=\"l\" colspan=\"2\">". $ListID .".: ". $ElementTitle ." ". $BuildLevel ."</td>";
    						}
    						else
    						{
    							$ListIDRow .= "	<td class=\"l\" colspan=\"2\">". $ListID .".: ". $ElementTitle ." ". $BuildLevel . " " . $lang['bd_dismantle']."</td>";
    						}
    						$ListIDRow .= "	<td class=\"k\">";
    						if ($ListID == 1)
    						{
    							$ListIDRow .= "		<div id=\"blc\" class=\"z\">". $BuildTime ."<br>";
    							$ListIDRow .= "		<a href=\"game.php?page=buildings&listid=". $ListID ."&amp;cmd=cancel&amp;planet=". $PlanetID ."\">".$lang['bd_interrupt']."</a></div>";
    							$ListIDRow .= "		<script language=\"JavaScript\">";
    							$ListIDRow .= "			pp = \"". $BuildTime ."\";\n";
    							$ListIDRow .= "			pk = \"". $ListID ."\";\n";
    							$ListIDRow .= "			pm = \"cancel\";\n";
    							$ListIDRow .= "			pl = \"". $PlanetID ."\";\n";
    							$ListIDRow .= "			t();\n";
    							$ListIDRow .= "		</script>";
    							$ListIDRow .= "		<strong color=\"lime\"><br><font color=\"lime\">". date("j/m H:i:s" ,$BuildEndTime) ."</font></strong>";
    						}
    						else
    						{
    							$ListIDRow .= "		<font color=\"red\">";
    							$ListIDRow .= "		<a href=\"game.php?page=buildings&listid=". $ListID ."&amp;cmd=remove&amp;planet=". $PlanetID ."\">".$lang['bd_cancel']."</a></font>";
    						}
    						$ListIDRow .= "	</td>";
    						$ListIDRow .= "</tr>";
    					}
    				}
    			}
    		}
    		$RetValue['lenght']    = $ActualCount;
    		$RetValue['buildlist'] = $ListIDRow;
    		return $RetValue;
    	}
    	public function ShowBuildingsPage (&$CurrentPlanet, $CurrentUser)
    	{
    		global $ProdGrid, $lang, $resource, $reslist, $phpEx, $dpath, $game_config, $_GET, $xgp_root;
    		include_once($xgp_root . 'includes/functions/IsTechnologieAccessible.' . $phpEx);
    		include_once($xgp_root . 'includes/functions/GetElementPrice.' . $phpEx);
    		CheckPlanetUsedFields ( $CurrentPlanet );
    		$parse			= $lang;
    		$Allowed['1'] 	= array(  1,  2,  3,  4, 12, 14, 15, 21, 22, 23, 24, 31, 33, 34, 35, 44, 45);
    		$Allowed['3'] 	= array( 12, 14, 21, 22, 23, 24, 34, 41, 42, 43);
    		if (isset($_GET['cmd']))
    		{
    			$bDoItNow 	= false;
    			$TheCommand = $_GET['cmd'];
    			$Element 	= $_GET['building'];
    			$ListID 	= $_GET['listid'];
    			if( isset ( $Element ))
    			{
    				if ( !strchr ( $Element, ",") && !strchr ( $Element, " ") &&
    					 !strchr ( $Element, "+") && !strchr ( $Element, "*") &&
    					 !strchr ( $Element, "~") && !strchr ( $Element, "=") &&
    					 !strchr ( $Element, ";") && !strchr ( $Element, "'") &&
    					 !strchr ( $Element, "#") && !strchr ( $Element, "-") &&
    					 !strchr ( $Element, "_") && !strchr ( $Element, "[") &&
    					 !strchr ( $Element, "]") && !strchr ( $Element, ".") &&
    					 !strchr ( $Element, ":"))
    				{
    					if (in_array( trim($Element), $Allowed[$CurrentPlanet['planet_type']]))
    					{
    						$bDoItNow = true;
    					}
    				}
    				else
    				{
    					header("location:game.php?page=buildings");
    				}
    			}
    			elseif ( isset ( $ListID ))
    			{
    				$bDoItNow = true;
    			}
    			if ($bDoItNow == true)
    			{
    				switch($TheCommand)
    				{
    					case 'cancel':
    						$this->CancelBuildingFromQueue ($CurrentPlanet, $CurrentUser);
    					break;
    					case 'remove':
    						$this->RemoveBuildingFromQueue ($CurrentPlanet, $CurrentUser, $ListID);
    					break;
    					case 'insert':
    						$this->AddBuildingToQueue ($CurrentPlanet, $CurrentUser, $Element, true);
    					break;
    					case 'destroy':
    						$this->AddBuildingToQueue ($CurrentPlanet, $CurrentUser, $Element, false);
    					break;
    				}
    			}
    		}
    		SetNextQueueElementOnTop($CurrentPlanet, $CurrentUser);
    		$Queue = $this->ShowBuildingQueue($CurrentPlanet, $CurrentUser);
    		$this->BuildingSavePlanetRecord($CurrentPlanet);
    	if ($CurrentUser['commander']>time()) {$max=COMMANDER_BINA;} else {$max=NORMAL_BINA;}
    		if ($Queue['lenght'] < $max)
    		{
    			$CanBuildElement = true;
    		}
    		else
    		{
    			$CanBuildElement = false;
    		}
    		$BuildingPage        = "";
    		$zaehler         	 = 1;
    		foreach($lang['tech'] as $Element => $ElementName)
    		{
    			if (in_array($Element, $Allowed[$CurrentPlanet['planet_type']]))
    			{
    				$CurrentMaxFields      = CalculateMaxPlanetFields($CurrentPlanet);
    				if ($CurrentPlanet["field_current"] < ($CurrentMaxFields - $Queue['lenght']))
    				{
    					$RoomIsOk = true;
    				}
    				else
    				{
    					$RoomIsOk = false;
    				}
    				if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element))
    				{
    					$HaveRessources        	= IsElementBuyable ($CurrentUser, $CurrentPlanet, $Element, true, false);
    					$parse                 	= array();
    					$parse 					= $lang;
    					$parse['dpath']        	= $dpath;
    					$parse['i']            	= $Element;
    					$BuildingLevel         	= $CurrentPlanet[$resource[$Element]];
    					$parse['nivel']        	= ($BuildingLevel == 0) ? "" : " (". $lang['bd_lvl'] . " " . $BuildingLevel .")";
    					$parse['n']            	= $ElementName;
    					$parse['descriptions'] 	= $lang['res']['descriptions'][$Element];
    					$ElementBuildTime      	= GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
    					$parse['time']         	= ShowBuildTime($ElementBuildTime);
    					$parse['price']        	= GetElementPrice($CurrentUser, $CurrentPlanet, $Element);
    					$parse['click']        	= '';
    					$NextBuildLevel        	= $CurrentPlanet[$resource[$Element]] + 1;
    					if ($RoomIsOk && $CanBuildElement)
    					{
    						if ($Queue['lenght'] == 0)
    						{
    							if ($NextBuildLevel == 1)
    							{
    								if ( $HaveRessources == true )
    									$parse['click'] = "<a href=\"game.php?page=buildings&cmd=insert&building=". $Element ."\"><font color=#00FF00>".$lang['bd_build']."</font></a>";
    								else
    									$parse['click'] = "<font color=#FF0000>".$lang['bd_build']."</font>";
    							}
    							else
    							{
    								if ( $HaveRessources == true )
    									$parse['click'] = "<a href=\"game.php?page=buildings&cmd=insert&building=". $Element ."\"><font color=#00FF00>". $lang['bd_build_next_level'] . $NextBuildLevel ."</font></a>";
    								else
    									$parse['click'] = "<font color=#FF0000>". $lang['bd_build_next_level'] . $NextBuildLevel ."</font>";
    							}
    						}
    						else
    						{
    							$parse['click'] = "<a href=\"game.php?page=buildings&cmd=insert&building=". $Element ."\"><font color=#00FF00>".$lang['bd_add_to_list']."</font></a>";
    						}
    					}
    					elseif ($RoomIsOk && !$CanBuildElement)
    					{
    						if ($NextBuildLevel == 1)
    							$parse['click'] = "<font color=#FF0000>".$lang['bd_build']."</font>";
    						else
    							$parse['click'] = "<font color=#FF0000>". $lang['bd_build_next_level'] . $NextBuildLevel ."</font>";
    					}
    					else
    						$parse['click'] = "<font color=#FF0000>".$lang['bd_no_more_fields']."</font>";
    					if ($Element == 31 && $CurrentUser["b_tech_planet"] != 0)
    					{
    						$parse['click'] = "<font color=#FF0000>".$lang['bd_working']."</font>";
    					}
    					if ($Element == 21 && $CurrentPlanet["b_hangar"] != 0)
    					{
    						$parse['click'] = "<font color=#FF0000>".$lang['bd_working']."</font>";
    					}
    					$BuildingPage .= parsetemplate(gettemplate('buildings/buildings_builds_row'), $parse);
    				}
    			}
    		}
    		if ($Queue['lenght'] > 0)
    		{
    			include($xgp_root . 'includes/functions/InsertBuildListScript.' . $phpEx);
    			$parse['BuildListScript']  = InsertBuildListScript ("buildings");
    			$parse['BuildList']        = $Queue['buildlist'];
    		}
    		else
    		{
    			$parse['BuildListScript']  = "";
    			$parse['BuildList']        = "";
    		}
    		$parse['BuildingsList']        = $BuildingPage;
    		display(parsetemplate(gettemplate('buildings/buildings_builds'), $parse));
    	}
    }
    ?>
    Ekleyip dosya kodlarını verebilir misiniz acaba? Ve de ne mantıkla neresine eklediğinizi anlatabilir misiniz. Bunun gibi eklemem gereken 8-9 sayfa daha var.
    Teşekkürler.
  • 12-10-2009, 17:11:42
    #3
    Arkadaşlar biraz acil bu, yardımcı olabilir misiniz?