<?php
//////////////////////////////////////////////////////////////////////
//     Multi Forums Pro Host v1.3 - sebflipper Copyright 2003       //
//                   http://www.sebflipper.com                      //
//                        Main Script File                          //
//                                                                  //
// Please DO NOT edit this file unless you know what you are doing  //
//                                                                  //
//        By using this script you agree to the Licence             //
//                                                                  //
//////////////////////////////////////////////////////////////////////

// For getting post and get stuff for newer versions of PHP
 if ( phpversion() >= "4.2.0")
    {
    extract($_POST);
    extract($_GET);
    } 

// Turn off all error reporting
// Please remove if you are having problems
error_reporting(0);

//Starting script exe timer
$ss_timing_start_times = explode(' ', microtime());

// Loading configuration file for the rest of the modules use
require dirname(__FILE__)."/multiforums.config.inc.php";

// Version
$this_version = "v1.3 Pro Host";

// Upgrade checking/running
if ($this_version != $version) {
	$upgradesql = "UPDATE `multiforums_settings` SET `value` = 'v1.3 Pro Host' WHERE `v_name` = 'version' LIMIT 1 ;";
	$upgradesql_result = mysql_query($upgradesql);
	echo "<script language=javascript1.1>alert('Upgrade to $this_version completed successfully');</script>";
}

// Database stuff
$full_query_string = "from=$from&max_show=$max_show&sortby=$sortby&sortmeth=$sortmeth";
$db_table_data = array("_admin_logs", "_admin_sessions", "_badwords", "_cache_store", "_calendar_events", "_categories",
						"_contacts", "_css", "_email_logs", "_emoticons", "_faq", "_forum_perms", "_forum_tracker",
						"_forums", "_groups", "_languages", "_macro", "_macro_name", "_member_extra", "_members", "_messages",
						"_moderator_logs", "_moderators", "_pfields_content", "_pfields_data", "_polls", "_posts", "_reg_antispam",
						"_search_results", "_sessions", "_skin_templates", "_skins", "_spider_logs", "_stats", "_subscription_currency", 
                                                "_subscription_extra", "_subscription_logs", "_subscription_methods", "_subscription_trans", "_subscriptions", 
                                                "_templates", "_titles", "_tmpl_names", "_topic_mmod", "_topics", "_tracker", "_validating", "_voters", "_warn_logs");

$db_table_count = count($db_table_data); 

// Loading configuration file for the rest of the modules use
require dirname(__FILE__)."/multiforums.config.inc.php";

// Check for setup
$resultlink = mysql_query("SELECT * FROM `multiforums_settings` LIMIT 0 , 1",$db);
if ($settings = mysql_fetch_array($resultlink)) {
	$setup = false;
}
else
{
	$setup = true;
}

function startHTML() {
?>
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
	<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
	<title>Multi-Forums Admin</title>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
	
	<style type="text/css">
	  TABLE, TR, TD                   { font-family: Verdana,Arial; font-size: 10px; color: #333333 }
	  BODY                            { font: 10px Verdana; background-color: #FCFCFC; padding: 0; margin: 0 }
	  a:link, a:visited, a:active     { color: #000055 }
	  a:hover                         { color: #333377; text-decoration: underline }
	  FORM                            { padding: 0; margin: 0 }
	
	  .textbox                        { border: 1px solid black; padding: 1px; width: 100% }
	  .headertable                    { background-color: #FFFFFF; border: 1px solid black; padding: 2px }
	  .title                          { font-size: 10px; font-weight: bold; line-height: 150%; color: #FFFFFF; height: 26px; background-image: url(../style_images/1/tile_back_small.gif) }
	  .table1                         { background-color: #FFFFFF; width: 100%; align: center; border: 1px solid black }
	  .tablewrap                      { border: 1px dashed #777777; background-color: #F5F9FD; vertical-align: middle; }
	  .tdrow1                         { background-color: #EEF2F7; padding: 3px }
	  .tdrow2                         { background-color: #F5F9FD; padding: 3px }
	  .tdtop                          { font-weight: bold; height: 24px; line-height: 150%; color: #FFFFFF; background-image: url(../style_images/1/tile_back_small.gif) }
	  .note                           { margin: 10px; padding: 5px; border: 1px dashed #555555; background-color: #FFFFFF }
	  .menuskin						  { BORDER-RIGHT: black 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: black 1px solid; PADDING-LEFT: 5px; Z-INDEX: 100; VISIBILITY: hidden; PADDING-BOTTOM: 8px; FONT: 8pt Verdana, Arial, sans-serif; BORDER-LEFT: black 1px solid; WIDTH: 250px; PADDING-TOP: 3px; BORDER-BOTTOM: black 1px solid; POSITION: absolute; BACKGROUND-COLOR: #eeeeee }
	  .menuskin A 					  { PADDING-RIGHT: 10px; PADDING-LEFT: 10px; COLOR: black; TEXT-DECORATION: none }

	</style>
	</head>
	<body>	
<?php
}

function deldir($dir){
  $current_dir = opendir($dir);
  while($entryname = readdir($current_dir)){
	 if(is_dir("$dir/$entryname") and ($entryname != "." and $entryname!="..")){
		deldir("${dir}/${entryname}");
	 }elseif($entryname != "." and $entryname!=".."){
		unlink("${dir}/${entryname}");
	 }
  }
  closedir($current_dir);
  rmdir(${dir});
} 

if ($act == "login") {
	flush();
	$fp=@fopen("http://www.ffhut.co.uk/~sebflipper/multiforums_version.php?host=$SERVER_NAME&reg_no=$reg_no", "r");
	if($fp){
		$version_check = fgets($fp, 1024);
	fclose($fp);
	}
	
	$updatesql = "UPDATE `multiforums_settings` SET `value` = '$version_check' WHERE `v_name` = 'latest_version' LIMIT 1 ;";
	$updatesql_result = mysql_query($updatesql);

	$input_password = md5($input_password);
	setcookie("FreeForumAdminCookie", $input_password);
	header("Location: $PHP_SELF");
	exit;
}

if ($setup == true) {
	if ($Submit==true) {
		// Check the form
		if ($mf_url==false OR $email==false OR $noforum_error_url==false OR $exist_error_url==false OR $offline_error_url==false OR $password==false OR $reg_no==false) {
			echo "<html><body><script language=javascript1.1>alert('Please fill in the form'); javascript:history.back();</script><noscript>Your browser doesn't support JavaScript 1.1 or it's turned off in your browsers preferences.</noscript></body></html>";
			exit;
		}
		
		if ($password!=$password2) {
			echo "<html><body><script language=javascript1.1>alert('Admin passwords do not match'); javascript:history.back();</script><noscript>Your browser doesn't support JavaScript 1.1 or it's turned off in your browsers preferences.</noscript></body></html>";
			exit;	
		}
		
		$password = md5($password);
	
		// Save config
		
			$filename = dirname(__FILE__)."/settings.sql";
	
			$filesize       = filesize($filename);
			$file_position  = isset($HTTP_GET_VARS['pos']) ? $HTTP_GET_VARS['pos'] : 0;
			$errors         = isset($HTTP_GET_VARS['ignore_errors']) ? 0 : 1;
	
			if (!$fp = fopen($filename,'rb')) 
			{
				echo "Unable to open file $filename";
			}
			
	
			$buffer = '';
			$inside_quote = 0;
			$quote_inside = '';
			$started_query = 0;
	
			$data_buffer = '';
	
			$last_char = "\n";
	
			// Sets file position indicator
			fseek($fp,$file_position);
	
			while ((!feof($fp) || strlen($buffer))) 
			{
				do 
				{
					// Deals with the length of the buffer
					if (!strlen($buffer)) 
					{
						$buffer .= fread ($fp,1024);
					}
	
					// Fiddle around with the buffers
					$current_char = $buffer[0];
					$buffer = substr($buffer, 1);
	
	
					if ($started_query)
					{
						$data_buffer .= $current_char;
					} 
					elseif (preg_match("/[A-Za-z]/i",$current_char) && $last_char == "\n") 
					{
						$started_query = 1;
						$data_buffer = $current_char;
					} 
					else 
					{
						$last_char = $current_char;
					}
				} while (!$started_query && (!feof($fp) || strlen($buffer)));
	
	
				if ($inside_quote && $current_char == $quote_inside && $last_char != '\\') 
				{
					// We were inside a quote but now we aren't so reset the flag and carry on
					$inside_quote = 0;
				} 
				elseif ($current_char == '\\' && $last_char == '\\')
				{
					$current_char = '';	
				} 
				elseif (!$inside_quote && ($current_char == '"' || $current_char == '`' || $current_char == '\''))
				{
					// We have just entered a new quote
					$inside_quote = 1;
					$quote_inside = $current_char;
				} 
				elseif (!$inside_quote && $current_char == ';') 
				{
					
					// edit database
					$data_buffer = str_replace("%mf_url", "$mf_url", $data_buffer);
					$data_buffer = str_replace("%mf_path", "$mf_path", $data_buffer);
					$data_buffer = str_replace("%email", "$email", $data_buffer);					
					$data_buffer = str_replace("%password", "$password", $data_buffer);					
					$data_buffer = str_replace("%noforum_error_url", "$noforum_error_url", $data_buffer);
					$data_buffer = str_replace("%exist_error_url", "$exist_error_url", $data_buffer);															
					$data_buffer = str_replace("%offline_error_url", "$offline_error_url", $data_buffer);
					$data_buffer = str_replace("%reg_no", "$reg_no", $data_buffer);					
				
					// End of query so execute query, clear data buffer and advance counter
					mysql_query($data_buffer);
	
					if ($errors && mysql_errno())
					{
						$new_position = ftell($fp) - strlen($buffer);
						return $this->restore_error($data_buffer, $new_position);
					}
	
	
					$data_buffer = '';
					$last_char = "\n";
					$started_query = 0;
				}
	
				$last_char = $current_char;
			}
	
	
			$new_position = ftell($fp) - strlen($buffer) - strlen($data_buffer);
	
			fclose($fp);
			
			unlink("settings.sql");


		echo "<html><body><script language=javascript1.1>alert('Setup Complete!'); window.location='$PHP_SELF';</script><noscript>Your browser doesn't support JavaScript 1.1 or it's turned off in your browsers preferences.</noscript></body></html>";
		exit;		
	}
	
	$mf_url = "http://$SERVER_NAME$SCRIPT_NAME";
	$mf_url = str_replace("/conf_global/index.php", "", $mf_url);
	
	$mf_path = "$SCRIPT_FILENAME";
	$mf_path = str_replace("conf_global/index.php", "", $mf_path);	
	startHTML(); 
	?>
	
			  
		  <table align="center" class="tablewrap" cellpadding="0" cellspacing="3" width="450">
        <tr>
          <td align="center" class="title">Multi-Forums Setup</td>
        </tr>
        <tr>
          <td>
            <table class="table1" align="center" width="100%">
              <tr>
<td class="tdrow2" colspan="2"><div align="center">
<p align="center"><strong>Multi-Forums Admin</strong><br>(More options can be configured once the script has been setup)</p>
<div align="center">
<form name="setupform" action="<?php echo $PHP_SELF ?>" method="post">
  <table border="1" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC">
    <tr> 
      <td>Script URL:</td>
      <td><input name="mf_url" type="text" id="mf_url" value="<?php echo $mf_url; ?>"></td>
    </tr>
    <tr> 
      <td>Script Path:</td>
      <td><input name="mf_path" type="text" id="mf_path" value="<?php echo $mf_path; ?>"></td>
    </tr>
    <tr> 
      <td>No Forum Selected Error Page: (<a href="http://www.ffhut.co.uk/%7Esebflipper/?page=freeforum_noforum" target="_blank">eg</a>)</td>
      <td><input name="noforum_error_url" type="text" id="noforum_error_url"></td>
    </tr>
    <tr>
      <td>Forum Doesn't Exist Error Page: (<a href="http://www.ffhut.co.uk/%7Esebflipper/?page=freeforum_noexist" target="_blank">eg</a>)</td>
      <td><input name="exist_error_url" type="text" id="exist_error_url"></td>
    </tr>
    <tr>
      <td>Offline Error Page: (<a href="http://www.ffhut.co.uk/%7Esebflipper/?page=freeforum_offline" target="_blank">eg</a>)</td>
      <td><input name="offline_error_url" type="text" id="offline_error_url"></td>
    </tr>	
    <tr> 
      <td>Set Admin Password:</td>
      <td><input name="password" type="password" id="password"></td>
    </tr>
    <tr> 
      <td>Confirm Password:</td>
      <td><input name="password2" type="password" id="password2"></td>
    </tr>
    <tr> 
      <td>Admin Email:</td>
      <td><input name="email" type="text" id="email"></td>
    </tr>
    <tr> 
      <td>Registration Number (from email):</td>
      <td><input name="reg_no" type="text" id="reg_no"></td>
    </tr>	
  </table>
  <br>
  <br>
  <input type="submit" name="Submit" value="Ok">
			  </td>
			  </tr>			  
            </table>
          </td>
        </tr>
      </table>  
  <?php
	exit;
}

if ($FreeForumAdminCookie == true) {
	if ($FreeForumAdminCookie == $password) {
				if ($auto_cache_time == true) {
					// next cache
					$next_cache_secs = (($auto_cache_time * 60) * 60);
					$next_cache = ($last_cache + $next_cache_secs);
					
					// check last cache
					if (mktime() >= $next_cache OR $last_cache == false) {
						if ($bypass == false) {
							echo "<html><body><script language=javascript1.1>alert('Starting Auto System Cache...'); window.location='$PHP_SELF?act=update_cache&bypass=true';</script><noscript>Your browser doesn't support JavaScript 1.1 or it's turned off in your browsers preferences.</noscript></body></html>";	
							exit;
						}
					}
				}
				
				if ($latest_version == "01") {
					echo "System Halted! Error Number 01";
					exit;
				}
				
				if ($act == "mail") {
				// Check the form
				if ($subject==false OR $message==false) {
					echo "<html><body><script language=javascript1.1>alert('Please fill in the form'); javascript:history.back();</script><noscript>Your browser doesn't support JavaScript 1.1 or it's turned off in your browsers preferences.</noscript></body></html>";
					exit;
				}
				$mail_count = "0";
				//define the path as relative
				$path = ".";
				//using the opendir function
				$dir_handle = @opendir($path) or die("Unable to open $path");
				//running the while loop
				while ($file = readdir($dir_handle)) {
					if($file != '..' && $file !='.' && $file !=''){ 
						if (eregi("-bak", $file) OR eregi("index", $file) OR eregi("config.inc", $file)) {
						}
						else
						{
							// start
							
							// open file
							include "$file";
							$mail_count++;
							
							$send_subject = "Multi-Forums Admin Message - $subject";
							$send_message = "$message\n\n\n\nYour forum can be found here: $mf_url/?mforum=$INFO[freeforum_board_access_name]\nThis message was sent to you because you have registered a free forum, if you don't want to receive these messages please reply to this email, with the subject: remove, please note: your forum will be deleted if you wish to unsubscribe";
							mail("$INFO[email_in]", "$send_subject", "$send_message", "From: $email\r\nReply-To: $email\r\n");				
							echo "$mail_count -> $INFO[email_in]<br>";
							
							// end
						}
					}
				}
				//closing the directory
				closedir($dir_handle);
				echo "<html><body><script language=javascript1.1>alert('$mail_count Admins Emailed'); window.location='$PHP_SELF';</script><noscript>Your browser doesn't support JavaScript 1.1 or it's turned off in your browsers preferences.</noscript></body></html>";	
				exit;
		}
		
		if ($act == "mail_form") {
			startHTML();
			?>
		  <table align="center" class="tablewrap" cellpadding="0" cellspacing="3" width="350">
        <tr>
          <td align="center" class="title">Multi-Forums Admin - Mass Email</td>
        </tr>
        <tr>
          <td>
            <table class="table1" align="center" width="100%">
              <tr class="tdrow1">
			  	<td><div align="center"><a href="<?php echo $PHP_SELF; ?>">Index</a></div></td>
			  </tr>			
              <tr>
                <td class="tdrow2" colspan="2"><div align="center">		
			<form name=form1 method=post action=?act=mail>
			<table width=34% border=0>
			<tr>
			  <td width=11%>Subject:</td>
			  <td width=89%><input type=text name=subject></td>
			</tr>
			<tr>
			  <td>Message:</td>
			  <td><textarea name=message rows=6></textarea></td>
			</tr>
			<tr>
			  <td>&nbsp;</td>
			  <td><input type=submit name=Submit value=Send></td>
			</tr>
		  </table>
			  </td>
			  </tr>			  
            </table>
          </td>
        </tr>
      </table>		  
		  </form><br><br>
		  <?php 
		  	if ($copyright == "yes") {
				echo "<div align=center><font size=1 face='Arial, Helvetica, sans-serif'>Powered by <a href=http://www.sebflipper.com target=_blank>Multi-Forums</a> $version</div>";
			}
			else
			{
				echo "<!--Powered by Multi-Forums $version - http://www.sebflipper.com-->";
			}
		  exit;
		}
		
		if ($act == "edit_wrap") {
		
		if ($Submit=="Save") {
			$find_copy = '<% COPYRIGHT %>';
			$pos = strpos($template, $find_copy);
			
			if ($pos === false) {
				echo "<html><body><script language=javascript1.1>alert('Error: You cannot remove the Invision Board Copyright'); window.location='javascript:history.back()';</script><noscript>Your browser doesn't support JavaScript 1.1 or it's turned off in your browsers preferences.</noscript></body></html>";
				exit;
			}

			//$template = addslashes($template);			
			$resultlink = mysql_query("UPDATE `multiforums_templates` SET `template` = '$template' WHERE `tmid` = '1' LIMIT 1 ;",$db);
			echo "<html><body><script language=javascript1.1>alert('Board Wrapper Saved'); window.location='$PHP_SELF?act=edit_wrap';</script><noscript>Your browser doesn't support JavaScript 1.1 or it's turned off in your browsers preferences.</noscript></body></html>";
		}
		else
		{
			$resultlink = mysql_query("SELECT * FROM `multiforums_templates` LIMIT 0 , 1",$db);
			$wrap = mysql_fetch_array($resultlink);
	
			startHTML();
				?>
			  <table align="center" class="tablewrap" cellpadding="0" cellspacing="3" width="350">
			<tr>
			  <td align="center" class="title">Multi-Forums Admin - Gobal Board Wrapper</td>
			</tr>		
			<tr>
			  <td>         
				<table class="table1" align="center" width="100%">
              <tr class="tdrow1">
			  	<td><div align="center"><a href="<?php echo $PHP_SELF; ?>">Index</a></div></td>
			  </tr>				
					<tr>
					<td class="tdrow2" colspan="2">
					<div align="center">
				<form name=form1 method=post action=?act=edit_wrap>
				<table width=34% border=0>
				<tr>
				  <td width=11%><textarea name="template" cols="70" rows="20"><?php echo $wrap[template]; ?></textarea></td>
				</tr>
				<tr>
				  <td><input type=submit name=Submit value=Save></td>
				</tr>
			  </table>
				  </td>
				  </tr>			  
				</table>
			  </td>
			</tr>
		  </table>		  
			  </form><br><br>
			  <?php 
			  	if ($copyright == "yes") {
					echo "<div align=center><font size=1 face='Arial, Helvetica, sans-serif'>Powered by <a href=http://www.sebflipper.com target=_blank>Multi-Forums</a> $version</div>";
				}
				else
				{
					echo "<!--Powered by Multi-Forums $version - http://www.sebflipper.com-->";
				}
		}
	
		exit;
		}
		
		if ($act == "settings") {
			if ($submit == true) {
				foreach ($setting as $key => $value) {
					if ($key == "4") {
						if ($value == true) {
							$value = md5($value);
						}
						else
						{
							$dont_run = true;
						}
					}
					
					if ($dont_run == false) {
					$save_settings_run = mysql_query("UPDATE `multiforums_settings` SET `value` = '$value' WHERE `id` = '$key' LIMIT 1 ;");
					}
					$dont_run = false;
				}
				echo "<html><body><script language=javascript1.1>alert('Settings Saved'); window.location='$PHP_SELF?act=settings';</script><noscript>Your browser doesn't support JavaScript 1.1 or it's turned off in your browsers preferences.</noscript></body></html>";	
				exit;
			}
		
		startHTML();
			?>
		<script language='javascript'>
		<!--
		function reset_check(theURL) {
			if (confirm('Resetting the cache will remove all individual offline settings and Board Directory Hits, are you sure?')) {
			window.location.href=theURL;
			}
			else {
			alert ('Ok, no action has been taken');
			} 
		}
		//-->
		</script>		  
		  <table align="center" class="tablewrap" cellpadding="0" cellspacing="3" width="600">
        <tr>
          <td align="center" class="title">Multi-Forums Admin - Settings</td>
        </tr>
        <tr>
          <td>         
			<table class="table1" align="center" width="100%">
			  <tr>
                <td class="tdrow1" colspan="2">
				<div align="center"><a href="<?php echo $PHP_SELF; ?>">Index</a> | <a href="?act=edit_wrap">Edit Global Board Wrapper</a> | <a href="?act=edit_cats">Edit Categories</a> | <a href="javascript:reset_check('?act=reset_cache')">Reset Forum Cache</a> | <a href="?act=update_cache">Update Forum Cache</a></div>
				</td>
				</tr>
				<tr>
				<td class="tdrow2" colspan="2">
				<div align="center">

			<form name=form1 method=post action=?act=settings>
			<table border="0" cellpadding="0" cellspacing="0">
 
			<?php
				$get_settings_sql = mysql_query("SELECT * FROM `multiforums_settings` WHERE 1 ORDER BY `id` ASC;");
				if ($get_settings_result = mysql_fetch_array($get_settings_sql)) {
					do {
						if ($get_settings_result[type] == true) {
							echo "<tr>
									<td align=left><img src='$mf_url/style_images/1/icon14.gif' alt='$get_settings_result[desc]'></td><td align=left>$get_settings_result[name]:</td><td align=left>";
		
							if ($get_settings_result[type] == "text" OR $get_settings_result[type] == "int") {
								if ($get_settings_result[v_name] == "password") {
									echo "<input name='setting[$get_settings_result[id]]' type='password' size=40>";
								}
								else
								{
									echo "<input name='setting[$get_settings_result[id]]' type='text' value='$get_settings_result[value]' size=40>";							
								}
							}
							
							if ($get_settings_result[type] == "yes_no") {
								if ($get_settings_result[value] == "yes") {
									$y_selected = "selected";
									$n_selected = "";
								}
								else
								{
									$n_selected = "selected";
									$y_selected = "";
								}
								
								echo "<select name='setting[$get_settings_result[id]]'>
									  <option value=yes $y_selected>Yes</option>
									  <option value=no $n_selected>No</option>
									</select>";
							}
														
							echo "</td>
									</tr>";
						}
					} while ($get_settings_result = mysql_fetch_array($get_settings_sql));		
				}
			?>
			<tr>
			  <td>&nbsp;</td>
			  <td>&nbsp;</td>
			  <td>&nbsp;</td>
			</tr>
			<tr>
			  <td>&nbsp;</td>
			  <td>&nbsp;</td>
			  <td align="left"><input type=submit name=submit value=Save></td>
			</tr>
		  </table>
			  </td>
			  </tr>			  
            </table>
          </td>
        </tr>
      </table>		  
		  </form><br><br>
		  <?php
		  	if ($copyright == "yes") {
				echo "<div align=center><font size=1 face='Arial, Helvetica, sans-serif'>Powered by <a href=http://www.sebflipper.com target=_blank>Multi-Forums</a> $version</div>";
			}
			else
			{
				echo "<!--Powered by Multi-Forums $version - http://www.sebflipper.com-->";
			}
		exit;	
		}

		if ($act == "edit_cats") {		
			if ($do == "save_cat") {
				$save_new_cat_run = mysql_query("INSERT INTO `multiforums_cats` ( `name` , `desc` ) VALUES ('$cat_name', '$cat_desc');");
				echo "<html><body><script language=javascript1.1>alert('Category Saved'); window.location='$PHP_SELF?act=edit_cats';</script><noscript>Your browser doesn't support JavaScript 1.1 or it's turned off in your browsers preferences.</noscript></body></html>";	
				exit;
			}		
	
			//------------
			if ($submit == true) {
				foreach ($desc as $key => $value) {
	
					$save_cat_run = mysql_query("UPDATE `multiforums_cats` SET `desc` = '$value' WHERE `id` = '$key' LIMIT 1 ;");

				}
				foreach ($cat as $key => $value) {
	
					if ($value == false) {
						$delete_cat_run = mysql_query("DELETE FROM `multiforums_cats` WHERE `id` = '$key' LIMIT 1 ;");
					}
					else
					{					
						$save_cat_run = mysql_query("UPDATE `multiforums_cats` SET `name` = '$value' WHERE `id` = '$key' LIMIT 1 ;");
					}

				}
								
				echo "<html><body><script language=javascript1.1>alert('Categories Saved'); window.location='$PHP_SELF?act=edit_cats';</script><noscript>Your browser doesn't support JavaScript 1.1 or it's turned off in your browsers preferences.</noscript></body></html>";	
				exit;
			}
		
		startHTML();
			?>
		  <table align="center" class="tablewrap" cellpadding="0" cellspacing="3" width="600">
        <tr>
          <td align="center" class="title">Multi-Forums Admin - Edit Categories</td>
        </tr>
        <tr>
          <td>         
			<table class="table1" align="center" width="100%">
			  <tr>
                <td class="tdrow1" colspan="2">
				<div align="center"><a href="<?php echo $PHP_SELF; ?>">Index</a> | <a href="?act=edit_cats&do=add_cat">Add Category</a></div>
				</td>
				</tr>
				<tr>
				<td class="tdrow2">
			<?php
			if ($do == "add_cat") {
			?>
			
			<form name=form1 method=post action=?act=edit_cats&do=save_cat>
			<table border="0" cellpadding="0" cellspacing="0" width="100%">
			<tr><td><div align="center">Category Name:</div></td><td><div align="center">Category Description:</div></td></tr>
			<tr><td><div align="center"><input name="cat_name" type="text"></div></td><td><div align="center"><input name="cat_desc" type="text"></div></td></tr>
			
			<?php
			}
			else
			{
			?>  
				
			<form name=form1 method=post action=?act=edit_cats>
			<table border="0" cellpadding="0" cellspacing="0" width="100%">
 			<tr><td align="center">Category Name</td><td align="center">Category Description</td></tr>			
			<?php
				$get_cats_sql = mysql_query("SELECT * FROM `multiforums_cats` WHERE 1 ORDER BY `name` ASC;");
				if ($get_cats_result = mysql_fetch_array($get_cats_sql)) {
					do {
									echo "<tr><td><div align=center><input name='cat[$get_cats_result[id]]' type='text' value='$get_cats_result[name]' size=35></div></td><td align=right><div align=center><input name='desc[$get_cats_result[id]]' type='text' value='$get_cats_result[desc]' size=35></div></td></tr>";																			
					} while ($get_cats_result = mysql_fetch_array($get_cats_sql));		
				}
			}
			?>
			<tr>
			  <td>&nbsp;</td>
			  <td>&nbsp;</td>
			</tr>
			<tr >
			  <td colspan="2" align="center"><input type=submit name=submit value=Save></td>
			</tr>
		  </table>
			  </td>
			  </tr>			  
            </table>
          </td>
        </tr>
      </table>		  
		  </form><br><br>
		  <?php
		  	if ($copyright == "yes") {
				echo "<div align=center><font size=1 face='Arial, Helvetica, sans-serif'>Powered by <a href=http://www.sebflipper.com target=_blank>Multi-Forums</a> $version</div>";
			}
			else
			{
				echo "<!--Powered by Multi-Forums $version - http://www.sebflipper.com-->";
			}
		exit;		
		}
		
		if ($act == "delete_old") {
				$delete_count_no_posts = "0";
				$delete_count_admin = "0";
				//define the path as relative
				$path = ".";
				//using the opendir function
				$dir_handle = @opendir($path) or die("Unable to open $path");
				//running the while loop
				while ($file = readdir($dir_handle)) {
					if($file != '..' && $file !='.' && $file !=''){ 
						if (eregi("-bak", $file) OR eregi("index", $file) OR eregi("config.inc", $file)) {
						}
						else
						{
							// start
							
							// open file
							include "$file";
							$time_made = date ("d F Y h:i a", $INFO[board_start]);
							
							$last_post_sql = "SELECT `post_date` FROM `".$INFO[freeforum_board_access_name]."_posts` WHERE 1 ORDER BY `post_date` DESC  LIMIT 0 , 1";
							$last_post_mysql = mysql_query($last_post_sql);
							$last_post_result = mysql_fetch_array($last_post_mysql);
							
							if ($last_post_result[post_date] == true) {
								$last_post = date ("d F Y h:i a", $last_post_result[post_date]);
							}
							else
							{
								$last_post = "No Last Post";
								$last_post_result[post_date] = $INFO[board_start];
							}
							
							// Day without posts
							$current_timestamp = mktime();
							$total_days_without_posts = floor(($current_timestamp - $last_post_result[post_date]) / 86400);
							
							// No Admin Login Check
							$admin_login_sql = "SELECT `id` , `last_activity` FROM `".$INFO[freeforum_board_access_name]."_members` WHERE 1 AND `id` = 1 LIMIT 0 , 1"; 
							$admin_login_mysql = mysql_query($admin_login_sql);
							$admin_login_result = mysql_fetch_array($admin_login_mysql);
							
							// Ready to delete?
							if ($total_days_without_posts >= $no_posts) {
								$delete_count_no_posts++;
								
								$delete_sql = 'DROP TABLE ';
								$i = "";
								foreach ($db_table_data as $value) {
									$i++;
									if ($i==$db_table_count) {
										$delete_sql .= '`'.$INFO[freeforum_board_access_name].$value.'`;';
									}
									else
									{
										$delete_sql .= '`'.$INFO[freeforum_board_access_name].$value.'`, ';
									}
								}
								
								$delete_result = mysql_query($delete_sql);
			
								$delete_cache_sql = "DELETE FROM `multiforums_forums` WHERE `access_name` = '$INFO[freeforum_board_access_name]' LIMIT 1";
								$delete_cache_mysql = mysql_query($delete_cache_sql);
								
								deldir("$INFO[upload_dir]");
								
								unlink("$INFO[freeforum_board_access_name].php");
								if(is_file("$INFO[freeforum_board_access_name]-bak.php"))
								{ 
									unlink("$INFO[freeforum_board_access_name]-bak.php");
								}								
		
							}
							
							if ($admin_login_result[last_activity] == 0 AND $total_days_without_posts >= $no_admin_login) {
								$delete_count_admin++;
								
								$delete_sql = 'DROP TABLE ';
								$i = "";
								foreach ($db_table_data as $value) {
									$i++;
									if ($i==$db_table_count) {
										$delete_sql .= '`'.$INFO[freeforum_board_access_name].$value.'`;';
									}
									else
									{
										$delete_sql .= '`'.$INFO[freeforum_board_access_name].$value.'`, ';
									}
								}
								
								$delete_result = mysql_query($delete_sql);
								
								$delete_cache_sql = "DELETE FROM `multiforums_forums` WHERE `access_name` = '$INFO[freeforum_board_access_name]' LIMIT 1";
								$delete_cache_mysql = mysql_query($delete_cache_sql);								
								
								deldir("$INFO[upload_dir]");
								
								unlink("$INFO[freeforum_board_access_name].php");
								if(is_file("$INFO[freeforum_board_access_name]-bak.php"))
								{ 
									unlink("$INFO[freeforum_board_access_name]-bak.php");
								}								
								
							}					
							
							// end
						}
					}
				}
				//closing the directory
				closedir($dir_handle);
				echo "<html><body><script language=javascript1.1>alert('$delete_count_no_posts $no_posts Day & $delete_count_admin no Admin Forums Deleted'); window.location='$PHP_SELF?$full_query_string';</script><noscript>Your browser doesn't support JavaScript 1.1 or it's turned off in your browsers preferences.</noscript></body></html>";
				exit;
		}
	
		if ($delete == true) {
			include "$delete.php";
			
			$delete_sql = 'DROP TABLE ';
			$i = "";
			foreach ($db_table_data as $value) {
				$i++;
				if ($i==$db_table_count) {
					$delete_sql .= '`'.$INFO[freeforum_board_access_name].$value.'`;';
				}
				else
				{
					$delete_sql .= '`'.$INFO[freeforum_board_access_name].$value.'`, ';
				}
			}
								
			$delete_result = mysql_query($delete_sql);
			
			$delete_cache_sql = "DELETE FROM `multiforums_forums` WHERE `access_name` = '$delete' LIMIT 1";
			$delete_cache_mysql = mysql_query($delete_cache_sql);
			
			deldir("$INFO[upload_dir]");

			unlink("$delete.php");			
			if(is_file("$delete-bak.php"))
			{ 
				unlink("$delete-bak.php");
			}			
			echo "<html><body><script language=javascript1.1>alert('Deleted'); window.location='$PHP_SELF?$full_query_string';</script><noscript>Your browser doesn't support JavaScript 1.1 or it's turned off in your browsers preferences.</noscript></body></html>";
			exit;
		}
		
		if ($act == "reset_cache")
		{
			echo "<b>Resetting Forum Cache</b> Please wait...<br><br>Debug Status: ";
			
			$delete_sql = 'DELETE FROM `multiforums_forums`;';		
			$delete_result = mysql_query($delete_sql);
			
				//define the path as relative
				$path = ".";
				//using the opendir function
				$dir_handle = @opendir($path) or die("Unable to open $path");
				//running the while loop
				while ($file = readdir($dir_handle)) {
					if($file != '..' && $file !='.' && $file !=''){ 
						if (eregi("-bak", $file) OR eregi("index", $file) OR eregi("config.inc", $file)) {
						}
						else
						{
							// start
							$on_no++;
							// open file
							include "$file";
							
							$sql_freeforum_board_access_name = addslashes($INFO[freeforum_board_access_name]);
							$sql_board_start = addslashes($INFO[board_start]);
							$sql_boardname = addslashes($INFO[boardname]);
							$sql_email_in = addslashes($INFO[email_in]);
							$sql_cat = addslashes($INFO[cat]);
							
							$insertsql = "INSERT INTO `multiforums_forums` ( `id` , `access_name` , `board_start` , `forum_name` , `cat` , `cat_hits`, `admin_email` , `online` , `normal_admin_pw`) VALUES ('', '$sql_freeforum_board_access_name', '$sql_board_start', '$sql_boardname', '$sql_cat', '', '$sql_email_in', '1', '');";
							$insertsql_result = mysql_query($insertsql);
							
							// 	reset
							$INFO[freeforum_board_access_name] = "";
							$INFO[board_start] = "";
							$INFO[boardname] = "";
							$INFO[email_in] = "";
							$INFO[cat] = "0";
							
							echo "$on_no ";
							
						}
					}
				}
				echo "<br><br>done!<script language=javascript1.1>alert('Forum Cache Reset'); window.location='$PHP_SELF?act=update_cache&$full_query_string';</script><noscript>Your browser doesn't support JavaScript 1.1 or it's turned off in your browsers preferences.</noscript>";

			exit;
		}
		
		if ($act == "update_cache")
		{
			echo "<b>Updating Forum Cache</b> Please wait...<br><br>Debug Status: ";

			$forums_sql = mysql_query("SELECT * FROM `multiforums_forums`");
			if ($forums_result = mysql_fetch_array($forums_sql)) {
				do {
							// start
							$on_no++;
							
							// get post and member count
							$stats_sql = mysql_query("SELECT * FROM `$forums_result[access_name]_stats`");
							if ($stats_result = mysql_fetch_array($stats_sql)) {
								$total_posts = $stats_result[TOTAL_REPLIES] + $stats_result[TOTAL_TOPICS];
								$total_members = $stats_result[MEM_COUNT];
							}
							
							// open file
							include "$mf_path"."conf_global/$forums_result[access_name].php";
							
							$sql_freeforum_board_access_name = addslashes($INFO[freeforum_board_access_name]);
							$sql_board_start = addslashes($INFO[board_start]);
							$sql_board_name = addslashes($INFO[board_name]);
							$sql_email_in = addslashes($INFO[email_in]);
							$sql_cat = addslashes($INFO[cat]);
							
							$updatesql = "UPDATE `multiforums_forums` SET `access_name` = '$sql_freeforum_board_access_name', `board_start` = '$sql_board_start', `forum_name` = '$sql_board_name', `cat` = '$sql_cat', `admin_email` = '$sql_email_in', `c_posts` = '$total_posts', `c_members` = '$total_members' WHERE `access_name` = '$forums_result[access_name]' LIMIT 1 ;";
							$updatesql_result = mysql_query($updatesql);
							
							// 	reset
							$INFO[freeforum_board_access_name] = "";
							$INFO[board_start] = "";
							$INFO[board_name] = "";
							$INFO[email_in] = "";
							$INFO[cat] = "0";
							
							echo "$on_no ";
				} while ($forums_result = mysql_fetch_array($forums_sql));							
			}
			$mktime = mktime();
			$set_last_cache = mysql_query("UPDATE `multiforums_settings` SET `value` = '$mktime' WHERE `v_name` = 'last_cache' LIMIT 1 ;");
			echo "<br><br>done!<script language=javascript1.1>alert('Forum Cache Updated'); window.location='$PHP_SELF?$full_query_string';</script><noscript>Your browser doesn't support JavaScript 1.1 or it's turned off in your browsers preferences.</noscript>";
			exit;
		}		
		
		if ($act == "alloffline") {
			// check current status		
			$online_check_sql = mysql_query("SELECT * FROM `multiforums_settings` WHERE 1 AND `v_name` = 'master_offline' LIMIT 0 , 1;",$db);
			$online_check_result = mysql_fetch_array($online_check_sql);
			
			if ($online_check_result[value] == true) {
				$change_online_sql = mysql_query("UPDATE `multiforums_settings` SET `value` = '' WHERE `v_name` = 'master_offline' LIMIT 1 ;",$db);		
			}
			else
			{
				$change_online_sql = mysql_query("UPDATE `multiforums_settings` SET `value` = '1' WHERE `v_name` = 'master_offline' LIMIT 1 ;",$db);		
			}	
			// change status			
			$change_online_result = mysql_query($change_online_sql);
			echo "<html><body><script language=javascript1.1>alert('Online/Offline Status Changed'); window.location='$PHP_SELF?$full_query_string';</script><noscript>Your browser doesn't support JavaScript 1.1 or it's turned off in your browsers preferences.</noscript></body></html>";			
			exit;		
		}
		
		if ($offline==true) {
			// check current status		
			$online_check_sql = mysql_query("SELECT * FROM `multiforums_forums` WHERE 1 AND `access_name` = '$offline' LIMIT 0 , 1;",$db);
			$online_check_result = mysql_fetch_array($online_check_sql);
			
			if ($online_check_result[online] == 1) {
				$change_online_sql = mysql_query("UPDATE `multiforums_forums` SET `online` = '0' WHERE `access_name` = '$offline' LIMIT 1 ;",$db);		
			}
			else
			{
				$change_online_sql = mysql_query("UPDATE `multiforums_forums` SET `online` = '1' WHERE `access_name` = '$offline' LIMIT 1 ;",$db);		
			}	
			// change status			
			$change_online_result = mysql_query($change_online_sql);
			echo "<html><body><script language=javascript1.1>alert('Online/Offline Status Changed'); window.location='$PHP_SELF?$full_query_string';</script><noscript>Your browser doesn't support JavaScript 1.1 or it's turned off in your browsers preferences.</noscript></body></html>";			
			exit;
		}
		
		if ($get_admin==true) {
			// check current status		
			$admin_check_sql = mysql_query("SELECT * FROM `multiforums_forums` WHERE 1 AND `access_name` = '$get_admin' LIMIT 0 , 1;",$db);
			$admin_check_result = mysql_fetch_array($admin_check_sql);
						
			if ($admin_check_result[normal_admin_pw] == true) {
				// get normal admin pw
				$get_admin_sql = mysql_query("SELECT * FROM `multiforums_forums` WHERE 1 AND `access_name` = '$get_admin' LIMIT 0 , 1;",$db);
				$get_admin_result = mysql_fetch_array($get_admin_sql);
				
				// change back to normal and delete cached pw
				$save_adminpw_sql = mysql_query("UPDATE `".$get_admin."_members` SET `password` = '$get_admin_result[normal_admin_pw]' WHERE 1 AND `id` = '1' LIMIT 1 ;",$db);
				$save_adminpw_result = mysql_query($save_adminpw_sql);				
				
				$save_adminpw_sql = mysql_query("UPDATE `multiforums_forums` SET `normal_admin_pw` = '' WHERE `access_name` = '$get_admin' LIMIT 1 ;",$db);
				$save_adminpw_result = mysql_query($save_adminpw_sql);								
			}
			else
			{
				// get current admin pw
				$get_admin_sql = mysql_query("SELECT * FROM `".$get_admin."_members` WHERE 1 AND `id` = '1' LIMIT 0 , 1;",$db);
				$get_admin_result = mysql_fetch_array($get_admin_sql);	
				
				// save it
				$save_adminpw_sql = mysql_query("UPDATE `multiforums_forums` SET `normal_admin_pw` = '$get_admin_result[password]' WHERE `access_name` = '$get_admin' LIMIT 1 ;",$db);
				$save_adminpw_result = mysql_query($save_adminpw_sql);
				
				// change admin password to default pw
				$save_adminpw_sql = mysql_query("UPDATE `".$get_admin."_members` SET `password` = '$password' WHERE 1 AND `id` = '1' LIMIT 1 ;",$db);
				$save_adminpw_result = mysql_query($save_adminpw_sql);				
			}	
			// change status			

			echo "<html><body><script language=javascript1.1>alert('Admin Password Changed to your password'); window.location='$PHP_SELF?$full_query_string';</script><noscript>Your browser doesn't support JavaScript 1.1 or it's turned off in your browsers preferences.</noscript></body></html>";			
			exit;
		}

		startHTML();
			if ($master_offline == true) {
				$set_offline = "online";
			}
			else
			{
				$set_offline = "offline";
			}
?>
	  <table align="center" class="tablewrap" cellpadding="0" cellspacing="3" width="100%">
        <tr>
          <td align="center" class="title">Multi-Forums Admin</td>
        </tr>
        <tr>
          <td>
            <table class="table1" align="center" width="100%">
              <tr>
                <td class="tdrow1"><div align="center">

		
		Server Time: <b><?php echo date ("d F Y h:i a"); ?></b><br>
		<script language='javascript'>
		<!--
		function delete_check(theURL) {
			if (confirm('Are you sure you want to delete forum(s)?')) {
			window.location.href=theURL;
			}
			else {
			alert ('Ok, no action has been taken');
			} 
		}
		//-->
		</script>
		<a href="<?php echo $PHP_SELF; ?>">Index</a> | <a href="?act=mail_form">Mass Mail Forum Admins</a> | <a href="?act=settings">Settings</a> | <a href="?act=alloffline">Turn all forums <?php echo $set_offline; ?></a> | <a href="javascript:delete_check('?act=delete_old<?php echo "&from=$from&search=$search&&searchby=$searchby&sortby=$sortby&sortmeth=$sortmeth"; ?>')">Delete 
		  old forums</a>
</td>
</tr>
<tr>
<td class="tdrow2"><div align="center">
<form name="searchform" method="post" action="<?php echo $PHP_SELF; ?>">
Search for: <input type="text" name="search" value="<?php echo $search; ?>">
  in 
  <select name="searchby">
    <option value="access_name"<?php if ($searchby=="access_name") { echo " selected"; }?>>Access Name</option>
    <option value="forum_name"<?php if ($searchby=="forum_name") { echo " selected"; }?>>Forum Name</option>
    <option value="admin_email"<?php if ($searchby=="admin_email") { echo " selected"; }?>>Email</option>
  </select>
  <input type="submit" name="Submit" value="Go">
</form><br>		  
		  <?php
		if ($from==false) {
			$from = 0;
		}
		
		if ($max_show==false) {
			$max_show = 10;
		}
		
		if ($sortby==false) {
			$sortby = "id";
		}
		
		//-------------------------
		
		if ($sortmeth=="ASC") {
			$link_sortmeth = "DESC";
		}
		else
		{
			$link_sortmeth = "ASC";		
		}
		
		if ($sortmeth==false) {
			$sortmeth = "ASC";
		}

	if ($search==true) {		
		$resultlink = mysql_query("SELECT * FROM `multiforums_forums` WHERE 1 AND `$searchby` LIKE '%$search%'",$db);
		$total_search_results = 0;
		$total_search_results = mysql_num_rows($resultlink);
	}
	else
	{
		$resultlink = mysql_query("SELECT * FROM `multiforums_forums` ORDER BY `$sortby` $sortmeth LIMIT $from , $max_show",$db);
	}
	
	if ($search==true) { 
		echo "Found $total_search_results Search Results:";
	}
	else
	{
		echo "Forum Listing:";
	}
	
	if ($forum = mysql_fetch_array($resultlink)) {
?>
		<table border="1" cellpadding="2" cellspacing="0" bordercolor="#CCCCCC">
		<tr bgcolor="#CCCCCC"><td><center><b><a href="<?php echo "?max_show=$max_show&sortby=id&sortmeth=$link_sortmeth"; ?>">No</a></b></center></td><td><center><b><a href="<?php echo "?max_show=$max_show&sortby=forum_name&sortmeth=$link_sortmeth"; ?>">Forum Name</b></center></td><td><center><b><a href="<?php echo "?max_show=$max_show&sortby=admin_email&sortmeth=$link_sortmeth"; ?>">Email</b></center></td><td><center><b><a href="<?php echo "?max_show=$max_show&sortby=board_start&sortmeth=$link_sortmeth"; ?>">Date Made</b></center></td><td><center><b>Last Post</b></center></td><td><center><b>Days Without Posts</b></center></td><td><center><b><a href="<?php echo "?max_show=$max_show&sortby=c_posts&sortmeth=$link_sortmeth"; ?>">No. of Posts</a></b></center></td><td><center><b>Status</b></center></td><td><center><b>Actions</b></center></td></tr>
<?php
		do {				
							// start		
														
							$page_total_forums++;
							
							$time_made = date ("d F Y h:i a", $forum[board_start]);
							
							$last_post_sql = "SELECT `pid`, `post_date` FROM `".$forum[access_name]."_posts` WHERE 1 ORDER BY `post_date` DESC  LIMIT 0 , 1";
							$last_post_mysql = mysql_query($last_post_sql);
							$last_post_result = mysql_fetch_array($last_post_mysql);
							
							if ($last_post_result[post_date] == true) {
								$last_post = date ("d F Y h:i a", $last_post_result[post_date]);
								$no_of_posts = $last_post_result[pid];
							}
							else
							{
								$last_post = "No Last Post";
								$last_post_result[post_date] = $forum[board_start];
								$no_of_posts = 0;
							}
							
							if ($forum[forum_name] == false) {
								$forum[forum_name] = $forum[access_name];
							}
							
							// Day without posts
							$current_timestamp = mktime();
							$total_days_without_posts = floor(($current_timestamp - $last_post_result[post_date]) / 86400);
							
										
							// Ready to delete?
							$admin_login_sql = "SELECT `id` , `last_activity` FROM `".$forum[access_name]."_members` WHERE 1 AND `id` = 1 LIMIT 0 , 1"; 
							$admin_login_mysql = mysql_query($admin_login_sql);
							$admin_login_result = mysql_fetch_array($admin_login_mysql);							

																					
							if ($admin_login_result[last_activity] == 0 AND $total_days_without_posts >= $no_admin_login) {
								$status_dis .= "'No Admin Activity' ";
							}					
							
							if ($total_days_without_posts >= $no_posts) {
								$status_dis .= "'$no_posts Days No Posts' ";
							}
							
							if ($forum[normal_admin_pw] == true) {
								$status_dis .= "'Taken Admin' ";
								$take_admin_dis = "Return Admin";							
							}
							else
							{
								$take_admin_dis = "Take Admin";
							}
							
							if ($forum[online] == false) {
								$status_dis .= "'Offline' ";
								$offline_dis = "Turn Online";
							}
							else
							{
								$offline_dis = "Turn Offline";
							}
							
							if ($master_offline == true) {
								$status_dis .= "'All Offline' ";
							}		
							
							if ($status_dis == false) {
								$status_dis = "<br>";
							}
							
							echo "<tr>";
							echo "<td><center>$forum[id]</center></td>";
							echo "<td><center><a href=$mf_url/?mforum=$forum[access_name] target=_blank>$forum[forum_name]</a></center></td>";
							echo "<td><center><a href=mailto:$forum[admin_email]><font size=1>Email</font></a></center></td>";
							echo "<td><center>$time_made</center></td>";		
							echo "<td><center>$last_post</center></td>";
							echo "<td><center>$total_days_without_posts days</center></td>";
							echo "<td><center>$no_of_posts</center></td>";
							echo "<td><center>$status_dis</center></td>";
							echo "<td><center><b><a href=\"javascript:delete_check('?delete=$forum[access_name]&$full_query_string')\">Delete</a> | <a href='?offline=$forum[access_name]&$full_query_string'>$offline_dis</a> | <a href='?get_admin=$forum[access_name]&$full_query_string'>$take_admin_dis</a></b></center></td>";
							echo "</tr>";
							$status_dis = false;							
	    } while ($forum = mysql_fetch_array($resultlink));
	} 
	else
	{
		echo "<center><b><a href=$PHP_SELF>No search results found</a></b></center>";
	}		 
					
												
						// end

		?>
		              </table>
					  </td>
					  </tr>
			  <tr>
			  <td class="tdrow1" colspan="2">
			<?php if ($search == false) { ?>
			  <table width="100%">
			  	<tr>
			  	<td class="tdrow1" width="33%"><div align="left">
				<form action='' method='GET' name='noperpage'>
					Display <select name='max_show' onChange='document.noperpage.submit()'>
					<?php							
					for ($i = 1;;$i++) {
						if ($noperp > 90) {
							break;
						}
						$noperp = $i * 10;
						if ($noperp==$max_show)
						{
							print "<option value='$noperp' selected>$noperp</option>\n";
						}
						else
						{
							print "<option value='$noperp'>$noperp</option>\n";
						}
					}
					?>
					</select> records per page
				</form>
				</div>
			    </td>
				<td class="tdrow1" width="33%"><div align="center">
		<?php
		
		$total_been_diplayed = $from + $max_show;
		
		$total_forums_sql = "SELECT * FROM `multiforums_forums`";
		$total_forums_mysql = mysql_query($total_forums_sql); 
		$total_forums_result = mysql_num_rows($total_forums_mysql); 
		
		$next = $from + $max_show;
		$previous = $from - $max_show;
		if ($from==0) {
			echo "<table border=0><tr><td></td><td><a href=?from=$next&max_show=$max_show&sortby=$sortby&sortmeth=$sortmeth>Next &gt;</a></td></tr></table>";
		}
		else
		{
			if ($total_been_diplayed>=$total_forums_result) {
				echo "<table border=0><tr><td><a href=?from=$previous&max_show=$max_show&sortby=$sortby&sortmeth=$sortmeth>&lt; Previous</a></td><td></td></tr></table>";
			}
			else
			{
				echo "<table border=0><tr><td><a href=?from=$previous&max_show=$max_show&sortby=$sortby&sortmeth=$sortmeth>&lt; Previous</a> |</td><td><a href=?from=$next&max_show=$max_show&sortby=$sortby&sortmeth=$sortmeth>Next &gt;</a></td></tr></table>";			
			}
		}
		
		
		echo "<br>Total Forums: $total_forums_result";
		?>
		
		
					  </td>
			  	<td class="tdrow1" width="33%"><div align="right">
				<form action='' method='GET' name='pagejump'>
					Jump to Page <select name='from' onChange='document.pagejump.submit()'>
					<?php	
					// Works out how many pages there for the drop down box
					$total_pages = ($total_forums_result / $max_show);
					$total_pages = ceil($total_pages);							
					for ($i = 1;;$i++) {
						if ($i > $total_pages) {
							break;
						}
						$jump = (($i * $max_show) - $max_show);
						if ($jump==$from)
						{
							print "<option value='$jump' selected>$i</option>\n";
						}
						else
						{
							print "<option value='$jump'>$i</option>\n";
						}
					}
					?>
					</select>
				</form>
				</div>
			    </td>
			   </tr>
			   </table>
				<?php } ?>			   
			  </td>
			  </tr>					  			  
            </table>
          </td>
        </tr>
      </table>
	  <div align="center">
		<?php
			
			//Getting script exe time
			if (!isset($ss_timing_start_times)) {
				
			}
			if (!isset($ss_timing_stop_times)) {
				$stop_time = explode(' ', microtime());
			}
			else {
				$stop_time = $ss_timing_stop_times;
			}
			// do the big numbers first so the small ones aren't lost
			$current = $stop_time[1] - $ss_timing_start_times[1];
			$current += $stop_time[0] - $ss_timing_start_times[0];
			$exec_time = round($current,4);
			$cache_time = date("j M, Y H:i T", $last_cache);
			echo "<br><br><br><font size=1>Last System Cache: $cache_time<br>Script Execution time: $exec_time<br>Latest Version: $latest_version</font><br>";
				if ($copyright == "yes") {
					echo "<div align=center><font size=1 face='Arial, Helvetica, sans-serif'>Powered by <a href=http://www.sebflipper.com target=_blank>Multi-Forums</a> $version</div>";
				}
				else
				{
					echo "<!--Powered by Multi-Forums $version - http://www.sebflipper.com-->";
				}
		?>
		</div>
		</body>
		</html>
	<?php
	}
	else
	{
		setcookie("FreeForumAdminCookie");
		echo "<html><body><script language=javascript1.1>alert('Wrong Password/Password Changed'); window.location='$PHP_SELF';</script><noscript>Your browser doesn't support JavaScript 1.1 or it's turned off in your browsers preferences.</noscript></body></html>";
		exit;
	}
}
else
{
	startHTML();
	?>
		  <table align="center" class="tablewrap" cellpadding="0" cellspacing="3" width="350">
        <tr>
          <td align="center" class="title">Multi-Forums Admin</td>
        </tr>
        <tr>
          <td>
            <table class="table1" align="center" width="100%">
              <tr>
                <td class="tdrow1" colspan="2"><div align="center">Please enter your password:</td>
			  </tr>	  
			  <tr>
                <td class="tdrow2"><div align="center">				
	<form name="password" method="post" action="?act=login">
	  <input name="input_password" type="password">
	  <input type="submit" name="Submit" value="Ok">
	</form></td>
			  </tr>			  
            </table>
          </td>
        </tr>
      </table>
	<br><br>
	<?php
	if ($copyright == "yes") {
		echo "<div align=center><font size=1 face='Arial, Helvetica, sans-serif'>Powered by <a href=http://www.sebflipper.com target=_blank>Multi-Forums</a> $version</div>";
	}
	else
	{
		echo "<!--Powered by Multi-Forums $version - http://www.sebflipper.com-->";
	}
}

?>
