Location: PHPKode > projects > SiteX > admin/maintenance.php
<?PHP
ob_start();
session_start();

include("../includes/globals.php.inc");
include("../includes/functions.php");
include("../lang/English.php");
if(strtolower($sxSetup['Language']) != 'english') include("../lang/".$sxSetup['Language'].".php");
include("../themes/$THEME_FOLDER/config.php.inc");

if(!userAdmin())
	loginError($sxLang['LoginRequired']);

// Regenerate photos
if($sxPhotoRegenerate)
{
	ini_set("memory_limit","-1");
	
	// Traverse directory and gather file names
	$photos = array();
	
	if($sxSetup['GalleryStoreFullsize'])
		$photo_source = "../".$sxContentDir['PhotoFullsize'];
	else
		$photo_source = "../".$sxContentDir['PhotoScaled'];
	
	if($current_dir = @opendir($photo_source))
	{
		while($entryname = @readdir($current_dir))
		{
			if(($entryname != '.')AND($entryname != '..')AND($entryname != '.htaccess'))
				array_push($photos, $entryname);
		}
		@closedir($current_dir);
	
	}
	else
	{
		header("Location:$PHP_SELF?sxMaintenanceOp=gallery&message=" . $sxLang['MessageDirErrorOpening'] . "#sxMaintenanceTop");
		die();
	}
	
	// Resize photos
	foreach ($photos as $filename)
	{
		// Size max width or height - 1 to trim mishap edges
		$size_thumb = $sxSetup['GalleryMaxDimensionThumb'] - 1;
		$size_scaled = $sxSetup['GalleryMaxDimensionPhoto'] - 1;
		
		// Set JPG compression (for JPG images only)
		$compression_thumb = $sxSetup['GalleryCompressionThumb'];
		$compression_scaled = $sxSetup['GalleryCompressionPhoto'];
		
		// Read raw image
		if((imageCompatibility() == "truecolor")OR(imageCompatibility() == "normal"))
		{
			$sxImageInfo = getimagesize($photo_source.$filename);
			switch($sxImageInfo[2])
			{
				case 1: $image = imagecreatefromgif($photo_source.$filename); 	break;
				case 2: $image = imagecreatefromjpeg($photo_source.$filename); 	break;
				case 3: $image = imagecreatefrompng($photo_source.$filename); 	break;
				case 6: $image = imagecreatefromwbmp($photo_source.$filename); 	break;
			}
			$width_original = $sxImageInfo[0];
			$height_original = $sxImageInfo[1];
		}
		
		// Get filesize
		$filesize_original = filesize($photo_source.$filename);
			
		// Check if dimension change needed for scaled image change and make scaled image
		if(($width_original > $size_scaled)OR($height_original > $size_scaled))
		{
			$dimensions = resizeDimensions($width_original, $height_original, $size_scaled);
			$sxScaledWidth = $dimensions[0]+1;
			$sxScaledHeight = $dimensions[1]+1;
		}
		else
		{
			$sxScaledWidth = $width_original;
			$sxScaledHeight = $height_original;
		}
		//-----------------------------=============================----------------------------
		// Form scaled image	
		if(imageCompatibility() == "truecolor")
		{
			$sxScaledImage = imagecreatetruecolor($sxScaledWidth, $sxScaledHeight);
			imagecopyresampled($sxScaledImage, $image, 0, 0, 0, 0, $sxScaledWidth, $sxScaledHeight, $width_original, $height_original);
		}
		elseif(imageCompatibility() == "normal")
		{
			$sxScaledImage = imagecreate($sxScaledWidth, $sxScaledHeight);
			imagecopyresized($sxScaledImage, $image, 0, 0, 0, 0, $sxScaledWidth, $sxScaledHeight, $width_original, $height_original);
		}
		
		// Watermark scaled image
		if($sxSetup['GalleryWatermarking'] == 1)
			$sxScaledImage = sxWatermarkImage($sxScaledImage, $sxScaledWidth, $sxScaledHeight);
		
		// Create scaled image	
		switch($sxImageInfo[2])
		{
			case 1: imagegif($sxScaledImage,  "../".$sxContentDir['PhotoScaled'].$filename); 						break;
			case 2: imagejpeg($sxScaledImage, "../".$sxContentDir['PhotoScaled'].$filename, $compression_scaled); 	break;
			case 3: imagepng($sxScaledImage,  "../".$sxContentDir['PhotoScaled'].$filename); 						break;
			case 6: imagewbmp($sxScaledImage, "../".$sxContentDir['PhotoScaled'].$filename); 						break;
		}
		imagedestroy($sxScaledImage);
		
		$filesize_scaled = filesize("../".$sxContentDir['PhotoScaled'].$filename);
		
		// Resize image for thumbnail
		$dimensions = resizeDimensions($width_original, $height_original, $size_thumb);
		if((imageCompatibility() == "truecolor")OR(imageCompatibility() == "normal"))
		{
			if(imageCompatibility() == "truecolor")
			{
				$image_new_thumb = imagecreatetruecolor($dimensions[0]+1, $dimensions[1]+1);
				imagecopyresampled($image_new_thumb, $image, 0, 0, 0, 0, $dimensions[0]+1, $dimensions[1]+1, $width_original, $height_original);
			}
			elseif(imageCompatibility() == "normal")
			{
				$image_new_thumb = imagecreate($dimensions[0]+1, $dimensions[1]+1);
				imagecopyresized($image_new_thumb, $image, 0, 0, 0, 0, $dimensions[0]+1, $dimensions[1]+1, $width_original, $height_original);
			}
			
			switch($sxImageInfo[2])
			{
				case 1: imagegif($image_new_thumb,  "../".$sxContentDir['PhotoThumb'].$filename); 						break;
				case 2: imagejpeg($image_new_thumb, "../".$sxContentDir['PhotoThumb'].$filename, $compression_thumb); 	break;
				case 3: imagepng($image_new_thumb,  "../".$sxContentDir['PhotoThumb'].$filename); 						break;
				case 6: imagewbmp($image_new_thumb, "../".$sxContentDir['PhotoThumb'].$filename); 						break;
			}
			imagedestroy($image_new_thumb);
		}
		
		// Set final size/dimension data for db
		if($sxSetup['GalleryStoreFullsize'])
		{
			$width_final = $width_original;
			$height_final = $height_original;
			$filesize_final = $filesize_original;
			$fullsize = 1;
		}
		else
		{
			@unlink("../".$sxContentDir['PhotoFullsize'].$filename);
			$width_final = $sxScaledWidth;
			$height_final = $sxScaledHeight;
			$filesize_final = $filesize_scaled;
			$fullsize = 0;
		}
		
		$query = "UPDATE $DB_Photos SET filesize='$filesize_final', height='$height_final', width='$width_final' WHERE filename='$filename'";
		$result = mysql_query($query, $Link) or queryError("152", mysql_error());
	}
	
	header("Location:$PHP_SELF?sxMaintenanceOp=gallery&message=" . $sxLang['MessageMaintenanceRegenCompleted'] . "#sxMaintenanceTop");
	die();
}

// Reset photo hit counters
if($sxPhotoStatsReset)
{
	$query = "UPDATE $DB_Photos SET views='0'";
	$result = mysql_query($query, $Link) or queryError("823", mysql_error());
	
	header("Location:$PHP_SELF?sxMaintenanceOp=gallery&message=" . $sxLang['MessagePhotoStatsReset'] . "#sxMaintenanceTop");
	die();
}

// Clean unvalidated users
if($sxUsersUnvalidated)
{
	switch($sxUserUnvalidatedOption)
	{
		case 1 : 	$sxTimeout = $NOW-604800; 	break; // 1 week
		case 2 : 	$sxTimeout = $NOW-1209600; 	break; // 2 weeks
		case 3 : 	$sxTimeout = $NOW-2419200; 	break; // 1 month
		default : 	$sxTimeout = $NOW; 			break; // all
	}
	$query = "SELECT id FROM $DB_Users WHERE membersince <= '$sxTimeout' AND validated='0'";
	$result = mysql_query($query, $Link) or queryError("813", mysql_error());
	while($ROW = mysql_fetch_object($result))
		deleteUser($ROW->id);

	header("Location:$PHP_SELF?sxMaintenanceOp=users&message=" . $sxLang['MessageUnvalidUsersRemoved'] . "#sxMaintenanceTop");
	die();
}

// Merge: comprehensive
if($sxMergeComp)
{
	$sxTotalHits = 0;
	$query = "SELECT * FROM $DB_Hit_Counters";
	$result = mysql_query($query, $Link) or queryError("820", mysql_error());
	while($ROW = mysql_fetch_object($result))
	{
		$sxTotalHits = $sxTotalHits + $ROW->hits;
		$query2 = "DELETE FROM $DB_Hit_Counters WHERE id='$ROW->id'";
		$result2 = mysql_query($query2, $Link) or queryError("821", mysql_error());
	}
	$query2 = "INSERT INTO $DB_Hit_Counters (page, hits) VALUES ('Merged Hits ".date("Y-m-d")."', '$sxTotalHits')"; // use $sxLang['HitsMergedHits']
	$result2 = mysql_query($query2, $Link) or queryError("822", mysql_error());

	header("Location:$PHP_SELF?sxMaintenanceOp=hitstats&message=" . $sxLang['MessageHitStatsMerged'] . "#sxMaintenanceTop");
	die();

}

// Merge: page-by-page
if($sxMergePBP)
{
	// Find unique pages
	$sxMergePages = array();
	$query = "SELECT * FROM $DB_Hit_Counters ORDER BY page";
	$result = mysql_query($query, $Link) or queryError("816", mysql_error());
	while($ROW = mysql_fetch_object($result))
	{
		$sxSp = strpos($ROW->page,"php?");
		if($sxSp)
		{
			$sxThisPage = substr($ROW->page,0,$sxSp+3);
			if(!array_search($sxThisPage,$sxMergePages))
				array_push($sxMergePages,$sxThisPage);
		}
	}

	// Merge stats from unique pages (does not merge directories since it doesn't need to
	foreach($sxMergePages as $value)
	{
		$sxMyHits = 0;
		$query = "SELECT * FROM $DB_Hit_Counters WHERE page LIKE '$value%'";
		$result = mysql_query($query, $Link) or queryError("817", mysql_error());
		while($ROW = mysql_fetch_object($result))
		{
			$sxMyHits = $sxMyHits + $ROW->hits;
			$query2 = "DELETE FROM $DB_Hit_Counters WHERE id='$ROW->id'";
			$result2 = mysql_query($query2, $Link) or queryError("818", mysql_error());
		}
		$query2 = "INSERT INTO $DB_Hit_Counters (page, hits) VALUES ('$value', '$sxMyHits')";
		$result2 = mysql_query($query2, $Link) or queryError("819", mysql_error());
	}
	
	header("Location:$PHP_SELF?sxMaintenanceOp=hitstats&message=" . $sxLang['MessagePageByPageMerged'] . "#sxMaintenanceTop");
	die();
}

// RSS regeneration
if($sxRegenerateRSS)
{
	writeRSSXML();
	header("Location:$PHP_SELF?sxMaintenanceOp=rss&message=" . $sxLang['MessageRSSFeedGen'] . "#sxMaintenanceTop");
	die();
}

// Forum flag removal
if($sxClearForumFlags)
{
	switch($sxForumFlagOption)
	{
		case 1 : 	$sxTimeout = $NOW-604800; 	break; // 1 week
		case 2 : 	$sxTimeout = $NOW-1209600; 	break; // 2 weeks
		case 3 : 	$sxTimeout = $NOW-2419200; 	break; // 1 month
		case 4 : 	$sxTimeout = $NOW-14515200; break; // 6 months
		default : 	$sxTimeout = $NOW; 			break; // all
	}
	
	$query = "SELECT id FROM $DB_Forums_Posts WHERE lastedit <= '$sxTimeout' ";
	$result = mysql_query($query, $Link) or queryError("813", mysql_error());
	while($ROW = mysql_fetch_object($result))
	{
		$query2 = "DELETE FROM $DB_Forums_Unread WHERE postid='$ROW->id'";
		$result2 = mysql_query($query2, $Link) or queryError("814", mysql_error());
	}

	header("Location:$PHP_SELF?sxMaintenanceOp=forums&message=" . $sxLang['MessageOldFlagsRemoved'] . "#sxMaintenanceTop");
	die();
}

// Test write permissions
if($sxTestPerms)
{
	// Check to see if server can be written to
	if(sxContentWriteable() == TRUE)
	{
		$query = "UPDATE $DB_Setup SET setup_value='1' WHERE setup_key='ContentWriteable'";
		$result = mysql_query($query, $Link) or queryError("128", mysql_error());
		
		// Update '/content' directory image
		sxUpdateContentDirectories();
		
		header("Location: $PHP_SELF?message=" . $sxLang['MessageWritePermsCorrect'] . "");
		die();
	}
	else
	{
		$query = "UPDATE $DB_Setup SET setup_value='0' WHERE setup_key='ContentWriteable'";
		$result = mysql_query($query, $Link) or queryError("128", mysql_error());

		header("Location: $PHP_SELF?message=" . $sxLang['MessageWritePermsIncorrect'] . "");
		die();
	}
}

// Zombie removal
if ($sxRemoveZombies)
{
	$sxZombies = array();
	$rootpath = "../";
	
	// Cleanse avatar folder of zombie images
	$dir = $rootpath.$sxContentDir['Avatar'];
	$current_dir = opendir($dir);
	while($entryname = readdir($current_dir))
	{
		if(is_dir("$dir/$entryname") and ($entryname != "." and $entryname!=".."))
		{
			// Do nothing
		}
		elseif($entryname != "." and $entryname!="..")
		{
			$query2 = "SELECT avatar FROM $DB_Users WHERE avatar='$entryname'";
			$result2 = mysql_query($query2, $Link) or queryError("8", mysql_error());
			
			if(mysql_num_rows($result2) == 0)
			{
				if(@unlink("${dir}${entryname}"))
					array_push($sxZombies, "${dir}${entryname}");
			}
		}
	}
	closedir($current_dir);

	// Cleanse file folder of zombies
	$dir = $rootpath.$sxContentDir['Files'];
	$current_dir = @opendir($dir);
	while($entryname = @readdir($current_dir))
	{
		if(@is_dir("$dir/$entryname") and ($entryname != "." and $entryname!=".."))
		{
			// Do nothing
		}
		elseif($entryname != "." and $entryname!="..")
		{
			$query2 = "SELECT filename FROM $DB_Files WHERE filename='$entryname'";
			$result2 = mysql_query($query2, $Link) or queryError("8", mysql_error());
			
			if(mysql_num_rows($result2) == 0)
			{
				if(@unlink("${dir}${entryname}"))
					array_push($sxZombies, "${dir}${entryname}");
			}
		}
	}
	@closedir($current_dir);
	
	// Cleanse photo fullsize folder of zombie images
	$dir = $rootpath.$sxContentDir['PhotoFullsize'];
	$current_dir = @opendir($dir);
	while($entryname = @readdir($current_dir))
	{
		if(@is_dir("$dir/$entryname") and ($entryname != "." and $entryname!=".."))
		{
			// Do nothing
		}
		elseif($entryname != "." and $entryname != ".." and $entryname != ".htaccess")
		{
			$query2 = "SELECT filename FROM $DB_Photos WHERE filename='$entryname'";
			$result2 = mysql_query($query2, $Link) or queryError("8", mysql_error());
			
			if(mysql_num_rows($result2) == 0)
			{
				if(@unlink("${dir}${entryname}"))
					array_push($sxZombies, "${dir}${entryname}");
			}
		}
	}
	@closedir($current_dir);
	
	// Cleanse photo scaled folder of zombie images
	$dir = $rootpath.$sxContentDir['PhotoScaled'];
	$current_dir = @opendir($dir);
	while($entryname = @readdir($current_dir))
	{
		if(@is_dir("$dir/$entryname") and ($entryname != "." and $entryname!=".."))
		{
			// Do nothing
		}
		elseif($entryname != "." and $entryname != ".." and $entryname != ".htaccess")
		{
			$query2 = "SELECT filename FROM $DB_Photos WHERE filename='$entryname'";
			$result2 = mysql_query($query2, $Link) or queryError("8", mysql_error());
			
			if(mysql_num_rows($result2) == 0)
			{
				if(@unlink("${dir}${entryname}"))
					array_push($sxZombies, "${dir}${entryname}");
			}
		}
	}
	@closedir($current_dir);
	
	// Cleanse photo thumbs folder of zombie images
	$dir = $rootpath.$sxContentDir['PhotoThumb'];
	$current_dir = @opendir($dir);
	while($entryname = @readdir($current_dir))
	{
		if(@is_dir("$dir/$entryname") and ($entryname != "." and $entryname!=".."))
		{
			// Do nothing
		}
		elseif($entryname != "." and $entryname!="..")
		{
			$query2 = "SELECT filename FROM $DB_Photos WHERE filename='$entryname'";
			$result2 = mysql_query($query2, $Link) or queryError("8", mysql_error());
			
			if(mysql_num_rows($result2) == 0)
			{
				if(@unlink("${dir}${entryname}"))
					array_push($sxZombies, "${dir}${entryname}");
			}
		}
	}
	@closedir($current_dir);

	// Cleanse security folder of zombie images
	$dir = $rootpath.$sxContentDir['Security'];
	$current_dir = @opendir($dir);
	while($entryname = @readdir($current_dir))
	{
		if(@is_dir("$dir/$entryname") and ($entryname != "." and $entryname!=".."))
		{
			// Do nothing
		}
		elseif($entryname != "." and $entryname!="..")
		{
			$query2 = "SELECT filename FROM $DB_Security_Image WHERE filename='$entryname'";
			$result2 = mysql_query($query2, $Link) or queryError("8", mysql_error());
			
			if(mysql_num_rows($result2) == 0)
			{
				if(@unlink("${dir}${entryname}"))
					array_push($sxZombies, "${dir}${entryname}");
			}
		}
	}
	@closedir($current_dir);
	
	// Cleanse title picture folder of zombie images
	$dir = $rootpath.$sxContentDir['TitleImage'];
	$current_dir = @opendir($dir);
	while($entryname = @readdir($current_dir))
	{
		if(@is_dir("$dir/$entryname") and ($entryname != "." and $entryname!=".."))
		{
			// Do nothing
		}
		elseif($entryname != "." and $entryname!="..")
		{
			$query2 = "SELECT filename FROM $DB_Title_Pictures WHERE filename='$entryname'";
			$result2 = mysql_query($query2, $Link) or queryError("8", mysql_error());
			
			if(mysql_num_rows($result2) == 0)
			{
				if(@unlink("${dir}${entryname}"))
					array_push($sxZombies, "${dir}${entryname}");
			}
		}
	}
	@closedir($current_dir);
	
	$message = $sxLang['MessageZombiesCleaned'].count($sxZombies);
	
	if (count($sxZombies) > 0)
	{
		$message .= "<br /><br />";
		foreach ($sxZombies as $value)
			$message .= $value . ', ';
		$message = substr($message, 0, strlen($message)-2);
	}
}
if(isset($sxChangeMaintenanceMode) == TRUE)
{
	if($sxSetup['Maintenance'] == 1)
		$sxNewMM = 0;
	else
		$sxNewMM = 1;

	$query = "UPDATE $DB_Setup SET setup_value='$sxNewMM' WHERE setup_key='Maintenance'";
	$result = mysql_query($query, $Link) or queryError("55", mysql_error());
	
	writeRSSXML();
	
	header("Location:$PHP_SELF?message=".$sxLang['MaintenanceUpdated']);
	die();
}


$sxTitleAddendum = $sxLang['AdminHeading'] . ' - ' .$sxLang['MaintenanceHeading'];
include("../themes/$THEME_FOLDER/header.php");
?>   
<div class="bodyWrapper">
   <h1 class="sxAdminHeading"><?PHP echo $sxLang['MaintenanceHeading']; ?></h1>
   <div class="sxAdminBreadcrumbs"><?PHP if(userAdmin()) { ?><a href="index.php"><?PHP echo $sxLang['AdminBreadcrumb']; ?><?PHP }?><?PHP if(userEditor()) { ?><a href="editor_index.php"><?PHP echo $sxLang['EditorBreadcrumb']; ?><?PHP }?></a> > <?PHP echo $sxLang['MaintenanceHeading']; ?></div>   
   <?PHP echoMessage($message); ?>
   <form name="sxFormMaintenance" action="<?PHP echo $PHP_SELF; ?>" method="post" enctype="multipart/form-data">
    <strong><?PHP echo $sxLang['PreferencesItemMaint']; ?></strong>&nbsp;&nbsp;<input type="checkbox" name="edit_maintenance" value="1"<?PHP if($sxSetup['Maintenance'] == 1) echo ' checked="checked"'; ?> onclick="window.location='<?PHP echo $PHP_SELF.'?sxChangeMaintenanceMode=true'; ?>'" />&nbsp;&nbsp;(<?php echo $sxLang['On']; ?> / <?php echo $sxLang['Off']; ?>)
		<div class="sxSection"><?PHP echo $sxLang['MaintenanceItemFunctions']; ?></div>	
		<ul style="float:left;margin-right:15px;">
			<li><?PHP if(!$sxMaintenanceOp) echo '> '; ?><a name="sxMaintenanceTop" href="<?PHP echo $PHP_SELF; ?>#sxMaintenanceTop"><?PHP echo $sxLang['OverviewOptionsWriteable']; ?></a></li>
			<li><?PHP if($sxMaintenanceOp == 'zombies') echo '> '; ?><a href="<?PHP echo $PHP_SELF; ?>?sxMaintenanceOp=zombies#sxMaintenanceTop"><?PHP echo $sxLang['OverviewOptionsZombies']; ?></a></li>
			<li><?PHP if($sxMaintenanceOp == 'forums') echo '> '; ?><a href="<?PHP echo $PHP_SELF; ?>?sxMaintenanceOp=forums#sxMaintenanceTop"><?PHP echo getComponentName(6); ?></a></li>
			<li><?PHP if($sxMaintenanceOp == 'hitstats') echo '> '; ?><a href="<?PHP echo $PHP_SELF; ?>?sxMaintenanceOp=hitstats#sxMaintenanceTop"><?PHP echo $sxLang['HitsHeadingStats'] ; ?></a></li>
			<li><?PHP if($sxMaintenanceOp == 'gallery') echo '> '; ?><a href="<?PHP echo $PHP_SELF; ?>?sxMaintenanceOp=gallery#sxMaintenanceTop"><?PHP echo getComponentName(2); ?></a></li>
			<li><?PHP if($sxMaintenanceOp == 'users') echo '> '; ?><a href="<?PHP echo $PHP_SELF; ?>?sxMaintenanceOp=users#sxMaintenanceTop"><?PHP echo $sxLang['MaintenanceUsers']; ?></a></li>
			<li><?PHP if($sxMaintenanceOp == 'rss') echo '> '; ?><a href="<?PHP echo $PHP_SELF; ?>?sxMaintenanceOp=rss#sxMaintenanceTop"><?PHP echo $sxLang['MaintenanceRSS']; ?></a></li>
		</ul>
		<fieldset><legend><?PHP
		switch($sxMaintenanceOp)
		{
			default :
				echo $sxLang['OverviewOptionsWriteable'];
				break;
			case 'zombies' :
				echo $sxLang['OverviewOptionsZombies'];
				break;
			case 'forums' :
				echo getComponentName(6);
				break;
			case 'hitstats' :
				echo $sxLang['HitsHeadingStats'] ;
				break;
			case 'gallery' :
				echo getComponentName(2);
				break;
			case 'users' :
				echo $sxLang['MaintenanceUsers'];
				break;
			case 'rss' :
				echo $sxLang['MaintenanceRSS'];
				break;
		}
		?></legend>
		<?PHP
		switch($sxMaintenanceOp)
		{
			default : ?>
				<p><strong><?php echo $sxLang['MaintenanceInfo']; ?>:</strong> <?php echo $sxLang['MaintenanceWriteableInfo']; ?></p>
				<p><strong><?php echo $sxLang['MaintenanceStatus']; ?>:</strong> <?PHP 	if($sxSetup['ContentWriteable'])
									echo $sxLang['On'];
								else
									echo $sxLang['Off']; ?></p>
				<p><strong><?php echo $sxLang['MaintenanceOperations']; ?>:</strong> <a href="<?PHP echo $PHP_SELF; ?>?sxTestPerms=TRUE"><?PHP echo $sxLang['OverviewRetest']; ?></a></p><br />
				<?PHP
				break;
			case 'zombies' : ?>
				<p><strong><?php echo $sxLang['MaintenanceInfo']; ?>:</strong> <?php echo $sxLang['MaintenanceZombieInfo']; ?></p>
				<p><strong><?php echo $sxLang['MaintenanceOperations']; ?>:</strong> <a href="<?PHP echo $_SERVER['PHP_SELF']; ?>?sxRemoveZombies=TRUE"><?PHP echo $sxLang['OverviewOptionsZombiesRemove']; ?></a></p><br />
				<?PHP
				break;
			case 'forums' ?>
				<p><strong><?php echo $sxLang['MaintenanceInfo']; ?>:</strong> <?php echo $sxLang['MaintenanceForumsInfo']; ?></p>
				<p><strong><?php echo $sxLang['MaintenanceStatus']; ?>:</strong> <?PHP
				$query = "SELECT id FROM $DB_Forums_Unread";
				$result = mysql_query($query, $Link) or queryError("51231", mysql_error());
				echo $sxLang['MaintenanceForumsUnreadFlags'] .': ';
				echo number_format(mysql_num_rows($result));
				?></p>
				<p><strong><?php echo $sxLang['MaintenanceOperations']; ?>:</strong> 
				<?PHP echo $sxLang['MaintenanceOptionsFlags']; ?> <select name="sxForumFlagOption">
				<option value="1"><?PHP echo $sxLang['MaintenanceOptionsFlagsOption1']; ?></option>
				<option value="2"><?PHP echo $sxLang['MaintenanceOptionsFlagsOption2']; ?></option>
				<option value="3"><?PHP echo $sxLang['MaintenanceOptionsFlagsOption3']; ?></option>
				<option value="4"><?PHP echo $sxLang['MaintenanceOptionsFlagsOption4']; ?></option>
				<option value="5"><?PHP echo $sxLang['MaintenanceOptionsFlagsOption5']; ?></option></select>
				<input type="submit" name="sxClearForumFlags" value="<?php echo $sxLang['MaintenanceButtonExecute']; ?>" class="sxButton" /></p><br />
				<?PHP
				break;
			case 'hitstats' : ?>
				<p><strong><?php echo $sxLang['MaintenanceInfo']; ?>:</strong> <?php echo $sxLang['MaintenanceHitStatsInfo']; ?></p>
				<p><strong><?php echo $sxLang['MaintenanceStatus']; ?>:</strong> <?PHP
				$query = "SELECT id FROM $DB_Hit_Counters";
				$result = mysql_query($query, $Link) or queryError("51232", mysql_error());
				echo $sxLang['MaintenanceHitStatsRecords'] .': ';
				echo number_format(mysql_num_rows($result));
				?></p>
				<p><strong><?php echo $sxLang['MaintenanceOperations']; ?>:</strong>
				<ul>
					<li><a href="<?PHP echo $PHP_SELF; ?>?sxMergeComp=1"><?php echo $sxLang['MaintenanceHitCompMerge']; ?></a></li>
					<li><a href="<?PHP echo $PHP_SELF; ?>?sxMergePBP=1"><?php echo $sxLang['MaintenanceHitPageMerge']; ?></a></li>
				</ul></p>
				<?PHP
				break;
			case 'gallery' : ?>
				<p><strong><?php echo $sxLang['MaintenanceInfo']; ?>:</strong> <?php echo $sxLang['MaintenanceGalleryInfo']; ?></p>
				<p><strong><?php echo $sxLang['MaintenanceOperations']; ?>:</strong>
				<ul>
					<li><a href="<?PHP echo $PHP_SELF; ?>?sxPhotoStatsReset=1"><?PHP echo $sxLang['MaintenanceOptionsResetStats']; ?></a></li>
					<li><a href="<?PHP echo $PHP_SELF; ?>?sxPhotoRegenerate=1"><?PHP echo $sxLang['MaintenanceOptionsRegenThumbsScaled']; ?></a></li>
				</ul></p><br />
				<?PHP
				break;
			case 'users' : ?>
				<p><strong><?php echo $sxLang['MaintenanceInfo']; ?>:</strong> <?php echo $sxLang['MaintenanceUsersInfo']; ?></p>
				<p><strong><?php echo $sxLang['MaintenanceStatus']; ?>:</strong> <?PHP
				$query = "SELECT id FROM $DB_Users WHERE validated='0'";
				$result = mysql_query($query, $Link) or queryError("51232", mysql_error());
				echo $sxLang['MaintenanceUsersUnvalidated'] .': ';
				echo number_format(mysql_num_rows($result));
				?></p>
				<p><strong><?php echo $sxLang['MaintenanceOperations']; ?>:</strong>
				<ul>
					<li><?PHP echo $sxLang['MaintenanceOptionsNullUsers']; ?> <select name="sxUserUnvalidatedOption">
						<option value="1"><?PHP echo $sxLang['MaintenanceOptionsNullUsersOption1']; ?></option>
						<option value="2"><?PHP echo $sxLang['MaintenanceOptionsNullUsersOption2']; ?></option>
						<option value="3"><?PHP echo $sxLang['MaintenanceOptionsNullUsersOption3']; ?></option>
						<option value="4"><?PHP echo $sxLang['MaintenanceOptionsNullUsersOption4']; ?></option></select></li>
						<input type="submit" name="sxUsersUnvalidated" value="<?php echo $sxLang['MaintenanceButtonExecute']; ?>" class="sxButton" />
					<li><a href="user_options.php"><?php echo $sxLang['MaintenanceUsersCleaner']; ?></a></li>
				</ul></p><br />
				<?PHP
				break;
			case 'rss' : ?>
				<p><strong><?php echo $sxLang['MaintenanceInfo']; ?>:</strong> <?php echo $sxLang['MaintenanceRSSInfo']; ?></p>
				<p><strong><?php echo $sxLang['MaintenanceOperations']; ?>:</strong> <a href="<?PHP echo $PHP_SELF; ?>?sxRegenerateRSS=1"><?PHP echo $sxLang['MaintenanceOptionsRegenRSS']; ?></a></p><br />
				<?PHP
				break;
		}
		?>
		</fieldset>
	<?PHP if(function_exists("fopen")){ ?>
	<div class="sxSection" style="clear:left;"><?PHP echo $sxLang['OverviewItemUpgrades']; ?></div>
	<ul>
		<li>
		<?PHP
		$sxVersion = sxCheckVersion();
		if($sxVersion)
		{
			echo $sxLang['MaintenanceVersionIs'].$sxVersion.'.<br />';
			
			if($sxVersion != $sxSetup['Version'])
				echo '<a href="http://sitex.bjsintay.com/page.php?page=Downloads">' . $sxLang['OverviewNewUpdate'] . ' ' . $sxSetup['Version'] . '.</a>';
			else
				echo $sxLang['OverviewVersion1'] . ' ' . $sxLang['OverviewVersion2'];
		}
		else
			echo $sxLang['MaintenanceVersionCheckFail'];
		?> <?PHP } ?></li>
	</ul>
	</form>
</div>
<?PHP
include("../themes/$THEME_FOLDER/footer.php");
ob_end_flush();
?>
Return current item: SiteX