1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-17 20:01:47 +02:00

Start addressing the changes needed - still need to handle xml default prefs, some of the new directory names.....

This commit is contained in:
SteveD
2013-02-15 21:15:35 +00:00
parent 28020162e7
commit a4ce03f454

View File

@@ -1,350 +1,398 @@
<?php <?php
/* /*
+ ----------------------------------------------------------------------------+ + ----------------------------------------------------------------------------+
| e107 website system | e107 website system
| |
| Copyright (C) 2008-2009 e107 Inc | Copyright (C) 2008-2009 e107 Inc
| http://e107.org/ | http://e107.org/
| |
| Standalone page aimed to reset core preferences | Standalone page aimed to reset core preferences
| |
| Released under the terms and conditions of the | Released under the terms and conditions of the
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_files/utilities/resetcore.php,v $ | $Source: /cvs_backup/e107_0.8/e107_files/utilities/resetcore.php,v $
| $Revision$ | $Revision$
| $Date$ | $Date$
| $Author$ | $Author$
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
/* #################################################### /*
@TODO: Needs detailed review/fixing:
- Handle XML-based default prefs
To use this file, you must edit the following line, removing the // so it reads: - Review existing definitions of constants
define("ACTIVE", true); - Define new constants (e_CORE, etc) properly
If you don't, the script will not be usable. */
When you have finished with resetcore you should swap true for false so it can't be used by /* ####################################################
people it shouldn't be used by.
*/ To use this file, you must edit the following line, removing the // so it reads:
define("ACTIVE", true);
define("ACTIVE", false); If you don't, the script will not be usable.
//FIXME build e_CACHE from e107_config.php - resetcore.php is a stand alone page When you have finished with resetcore you should swap true for false so it can't be used by
define('e_CACHE', '../cache/'); people it shouldn't be used by.
/* #################################################### */ */
define('ACTIVE', false);
$register_globals = true; //define('ACTIVE', TRUE);
if(function_exists('ini_get'))
{
$register_globals = ini_get('register_globals'); /* #################################################### */
}
if($register_globals == true)
{
while (list($global) = each($GLOBALS)) if(ACTIVE !== true)
{ {
if (!preg_match('/^(_POST|_GET|_COOKIE|_SERVER|_FILES|GLOBALS|HTTP.*|_REQUEST|eTimingStart)$/', $global)) echo "<span class='headertext2'>Currently disabled. To enable please open this file in a text editor and follow the instructions to activate.</span>";
{ exit;
unset($$global); }
}
} $register_globals = true;
unset($global); if(function_exists('ini_get'))
} {
$register_globals = ini_get('register_globals');
require_once("../../e107_config.php"); }
//TODO build e_CACHE from e107_config.php - resetcore.php is a stand alone page if($register_globals == true)
mysql_connect($mySQLserver, $mySQLuser, $mySQLpassword); {
mysql_select_db($mySQLdefaultdb); while (list($global) = each($GLOBALS))
define("MAGIC_QUOTES_GPC", (ini_get('magic_quotes_gpc') ? TRUE : FALSE)); {
if (!preg_match('/^(_POST|_GET|_COOKIE|_SERVER|_FILES|GLOBALS|HTTP.*|_REQUEST|eTimingStart)$/', $global))
define("e107_INIT", TRUE); {
require_once('../../'.$HANDLERS_DIRECTORY.'arraystorage_class.php'); unset($$global);
$eArrayStorage = new ArrayData(); }
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> unset($global);
<html xmlns="http://www.w3.org/1999/xhtml"> }
<head>
<title>e107 resetcore</title>
<link rel="stylesheet" href="style.css" /> // build e_CACHE and other constants from e107_config.php - resetcore.php is a stand alone page
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> $siteRoot = realpath(dirname(__FILE__).'./../../').'/';
<meta http-equiv="content-style-type" content="text/css" /> require_once($siteRoot.'e107_config.php');
</head> if (!isset($mySQLdefaultdb)) return FALSE;
<body> if (!isset($mySQLprefix)) return FALSE;
<div class='mainbox'>
<a href="http://e107.org"><img src="../../<?php echo($IMAGES_DIRECTORY); ?>logo_template_large.png" alt="Logo" style="border: 0px; vertical-align: middle;" /></a> <span class='headertext'>e107 Reset Core Utility</span> $hash = substr(md5($mySQLdefaultdb.".".$mySQLprefix),0,10);
<br />
<br />
<br /> mysql_connect($mySQLserver, $mySQLuser, $mySQLpassword);
<br /> mysql_select_db($mySQLdefaultdb);
<?php define("MAGIC_QUOTES_GPC", (ini_get('magic_quotes_gpc') ? TRUE : FALSE));
if(ACTIVE !== true) { define('e_CACHE', $siteRoot.$SYSTEM_DIRECTORY.$hash.'/cache/');
echo "<span class='headertext2'>Currently disabled. To enable please open this file in a text editor and follow the instructions to activate.</span>"; define('e_CORE', $siteRoot.'core/'); // @TODO: Allow for override
exit;
} define('e107_INIT', TRUE);
if (isset($_POST['usubmit'])) {
if (($row = e_verify()) !== FALSE) { require_once('../../'.$HANDLERS_DIRECTORY.'arraystorage_class.php');
extract($row); $eArrayStorage = new ArrayData();
$result = mysql_query("SELECT * FROM ".$mySQLprefix."core WHERE e107_name='pref_backup' "); ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
$bu_exist = ($row = mysql_fetch_array($result) ? TRUE : FALSE); <html xmlns="http://www.w3.org/1999/xhtml">
<head>
$admin_directory = "e107_admin"; <title>e107 resetcore</title>
<link rel="stylesheet" href="style.css" />
// <input type='radio' name='mode' value='1' /> <span class='headertext2'>Manually edit core values</span><br /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="content-style-type" content="text/css" />
echo "<span class='headertext2'><b>Please select which method you want to use, then click the button to proceed ...</b></span><br /><br /><br /><br /> </head>
<table style='width: auto; margin-left:auto; margin-right: auto;'> <body>
<tr> <div class='mainbox'>
<td> <a href="http://e107.org"><img src="../../<?php echo($IMAGES_DIRECTORY); ?>logo_template_large.png" alt="Logo" style="border: 0px; vertical-align: middle;" /></a> <span class='headertext'>e107 Reset Core Utility</span>
<form method='post' action='".$_SERVER['PHP_SELF']."'> <br />
<input type='radio' name='mode' value='2' /> <span class='headertext2'>Reset core to default values</span><br />". ($bu_exist ? "<input type='radio' name='mode' value='3' /> <span class='headertext2'>Restore core backup</span>" : "<br />( There is no backed-up core - unable to offer option to restore backup )")."<br /><br /><input class='button' type='submit' name='reset_core_sub' value='Select method then click here to continue' /> <br />
<br />
<input type='hidden' name='a_name' value='".$_POST['a_name']."' /> <br />
<input type='hidden' name='a_password' value='".$_POST['a_password']."' /> <?php
</form>
</td> if (isset($_POST['usubmit']))
</tr> {
</table> if (($row = e_verify()) !== FALSE)
"; {
extract($row);
$END = TRUE;
} else { $result = mysql_query("SELECT * FROM ".$mySQLprefix."core WHERE e107_name='pref_backup' ");
$message = "<b>Administrator not found in database / incorrect password / insufficient permissions - aborting.</b><br />"; $bu_exist = ($row = mysql_fetch_array($result) ? TRUE : FALSE);
$END = TRUE;
} $admin_directory = "e107_admin";
}
// <input type='radio' name='mode' value='1' /> <span class='headertext2'>Manually edit core values</span><br />
if (isset($_POST['reset_core_sub']) && $_POST['mode'] == 2) echo "<span class='headertext2'><b>Please select which method you want to use, then click the button to proceed ...</b></span><br /><br /><br /><br />
{ <table style='width: auto; margin-left:auto; margin-right: auto;'>
if (($at = e_verify()) === FALSE) { <tr>
exit; <td>
} <form method='post' action='".$_SERVER['PHP_SELF']."'>
<input type='radio' name='mode' value='2' /> <span class='headertext2'>Reset core to default values</span><br />". ($bu_exist ? "<input type='radio' name='mode' value='3' /> <span class='headertext2'>Restore core backup</span>" : "<br />( There is no backed-up core - unable to offer option to restore backup )")."<br /><br /><input class='button' type='submit' name='reset_core_sub' value='Select method then click here to continue' />
$tmpr = substr(str_replace($_SERVER['DOCUMENT_ROOT'], "", $_SERVER['SCRIPT_FILENAME']), 1);
$root = "/".substr($tmpr, 0, strpos($tmpr, "/"))."/"; <input type='hidden' name='a_name' value='".$_POST['a_name']."' />
$e_HTTP = $root; <input type='hidden' name='a_password' value='".$_POST['a_password']."' />
$admin_directory = "e107_admin";
$url_prefix = substr($_SERVER['PHP_SELF'], strlen($e_HTTP), strrpos($_SERVER['PHP_SELF'], "/")+1-strlen($e_HTTP)); </form>
$num_levels = substr_count($url_prefix, "/"); </td>
$link_prefix = ''; </tr>
for($i = 1; $i <= $num_levels; $i++) { </table>
$link_prefix .= "../"; ";
}
$END = TRUE;
define("e_ADMIN", $e_HTTP.$admin_directory."/"); } else {
define("e_SELF", "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']); $message = "<b>Administrator not found in database / incorrect password / insufficient permissions - aborting.</b><br />";
define("e_QUERY", preg_replace("#&|/?PHPSESSID.*#i", "", $_SERVER['QUERY_STRING'])); $END = TRUE;
define('e_BASE', $link_prefix); }
$e_path = (!strpos($_SERVER['SCRIPT_FILENAME'], ".php") ? $_SERVER['PATH_TRANSLATED'] : $_SERVER['SCRIPT_FILENAME']); }
define("e_PATH", $e_path);
if (isset($_POST['reset_core_sub']) && $_POST['mode'] == 2)
$pref_language = "English"; {
include_once("../../".$LANGUAGES_DIRECTORY."English/lan_prefs.php"); if (($at = e_verify()) === FALSE)
require_once("../../".$FILES_DIRECTORY."def_e107_prefs.php"); {
exit;
$PrefOutput = $eArrayStorage->WriteArray($pref); }
mysql_query("DELETE FROM ".$mySQLprefix."core WHERE e107_name='SitePrefs' OR e107_name='SitePrefs_Backup'"); $tmpr = substr(str_replace($_SERVER['DOCUMENT_ROOT'], "", $_SERVER['SCRIPT_FILENAME']), 1);
if (!mysql_query("INSERT INTO ".$mySQLprefix."core VALUES ('SitePrefs', '{$PrefOutput}')")) { $root = "/".substr($tmpr, 0, strpos($tmpr, "/"))."/";
$message = "Rebuild failed ..."; $e_HTTP = $root;
$END = TRUE; $admin_directory = "e107_admin";
} else { $url_prefix = substr($_SERVER['PHP_SELF'], strlen($e_HTTP), strrpos($_SERVER['PHP_SELF'], "/")+1-strlen($e_HTTP));
mysql_query("INSERT INTO ".$mySQLprefix."core VALUES ('SitePrefs_Backup', '{$PrefOutput}')"); $num_levels = substr_count($url_prefix, "/");
$message = "Core reset. <br /><br /><a href='../../index.php'>Click here to continue</a>"; $link_prefix = '';
$END = TRUE; for($i = 1; $i <= $num_levels; $i++) {
} $link_prefix .= "../";
} }
function recurse_pref($ppost) { define("e_ADMIN", $e_HTTP.$admin_directory."/");
$search = array("\"", "'", "\\", '\"', "\'", "$", "?"); define("e_SELF", "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']);
$replace = array("&quot;", "&#39;", "&#92;", "&quot;", "&#39;", "&#036;", "&copy;"); define("e_QUERY", preg_replace("#&|/?PHPSESSID.*#i", "", $_SERVER['QUERY_STRING']));
foreach ($ppost as $key => $value) { define('e_BASE', $link_prefix);
if(!is_array($value)){ $e_path = (!strpos($_SERVER['SCRIPT_FILENAME'], ".php") ? $_SERVER['PATH_TRANSLATED'] : $_SERVER['SCRIPT_FILENAME']);
$ret[$key] = str_replace($search, $replace, $text); define("e_PATH", $e_path);
} else {
$ret[$key] = recurse_pref($value);
} $pref_language = "English";
} include_once("../../".$LANGUAGES_DIRECTORY.'English/lan_prefs.php');
return $ret; require_once(e_CORE.'def_e107_prefs.php');
}
$PrefOutput = $eArrayStorage->WriteArray($pref);
if (isset($_POST['coreedit_sub']))
{ mysql_query("DELETE FROM ".$mySQLprefix."core WHERE e107_name='SitePrefs' OR e107_name='SitePrefs_Backup'");
if (($at = e_verify()) === FALSE) { if (!mysql_query("INSERT INTO ".$mySQLprefix."core VALUES ('SitePrefs', '{$PrefOutput}')"))
exit; {
} $message = "Rebuild failed ...";
$END = TRUE;
$pref = recurse_pref($_POST); }
else
$PrefOutput = $eArrayStorage->WriteArray($pref); {
mysql_query("INSERT INTO ".$mySQLprefix."core VALUES ('SitePrefs_Backup', '{$PrefOutput}')");
mysql_query("DELETE FROM ".$mySQLprefix."core WHERE e107_name='SitePrefs' OR e107_name='SitePrefs_Backup'"); $message = "Core reset. <br /><br /><a href='../../index.php'>Click here to continue</a>";
mysql_query("INSERT INTO ".$mySQLprefix."core VALUES ('SitePrefs', '{$PrefOutput}')"); $END = TRUE;
mysql_query("INSERT INTO ".$mySQLprefix."core VALUES ('SitePrefs_Backup', '{$PrefOutput}')"); }
}
$message = "Core settings successfully updated. <br /><br /><a href='../../index.php'>Click here to continue</a>";
$END = TRUE;
}
function recurse_pref($ppost)
if (isset($_POST['reset_core_sub']) && $_POST['mode'] == 3) { {
if (($at = e_verify()) === FALSE) { $search = array("\"", "'", "\\", '\"', "\'", "$", "?");
exit; $replace = array("&quot;", "&#39;", "&#92;", "&quot;", "&#39;", "&#036;", "&copy;");
} foreach ($ppost as $key => $value) {
if(!is_array($value)){
$result = mysql_query("SELECT * FROM ".$mySQLprefix."core WHERE e107_name='pref_backup'"); $ret[$key] = str_replace($search, $replace, $text);
$row = mysql_fetch_array($result); } else {
$ret[$key] = recurse_pref($value);
$pref = unserialize(base64_decode($row['e107_value'])); }
}
$PrefOutput = $eArrayStorage->WriteArray($pref); return $ret;
}
mysql_query("DELETE FROM ".$mySQLprefix."core WHERE `e107_name` = 'SitePrefs' OR `e107_name` = 'SitePrefs_Backup'");
mysql_query("INSERT INTO ".$mySQLprefix."core VALUES ('SitePrefs', '{$PrefOutput}')"); if (isset($_POST['coreedit_sub']))
mysql_query("INSERT INTO ".$mySQLprefix."core VALUES ('SitePrefs_Backup', '{$PrefOutput}')"); {
if (($at = e_verify()) === FALSE) {
$message = "Core backup successfully restored. <br /><br /><a href='../../index.php'>Click here to continue</a>"; exit;
$END = TRUE; }
}
$pref = recurse_pref($_POST);
if (isset($_POST['reset_core_sub']) && $_POST['mode'] == 1) $PrefOutput = $eArrayStorage->WriteArray($pref);
{
if (($at = e_verify()) === FALSE) { mysql_query("DELETE FROM ".$mySQLprefix."core WHERE e107_name='SitePrefs' OR e107_name='SitePrefs_Backup'");
exit; mysql_query("INSERT INTO ".$mySQLprefix."core VALUES ('SitePrefs', '{$PrefOutput}')");
} mysql_query("INSERT INTO ".$mySQLprefix."core VALUES ('SitePrefs_Backup', '{$PrefOutput}')");
$result = @mysql_query("SELECT * FROM ".$mySQLprefix."core WHERE e107_name='SitePrefs'"); $message = "Core settings successfully updated. <br /><br /><a href='../../index.php'>Click here to continue</a>";
$row = @mysql_fetch_array($result); $END = TRUE;
}
$pref = $eArrayStorage->ReadArray($row['e107_value']);
if (isset($_POST['reset_core_sub']) && $_POST['mode'] == 3) {
echo " if (($at = e_verify()) === FALSE) {
<span class='headertext2'><b>Edit your individual core items and click the button to save - <span class='headertext'>use this script with caution</span>.</b></span><br /><br /> exit;
<form method='post' action='".$_SERVER['PHP_SELF']."'> }
<table style='width:95%'>\n";
$result = mysql_query("SELECT * FROM ".$mySQLprefix."core WHERE e107_name='pref_backup'");
while (list($key, $prefr) = each($pref)) { $row = mysql_fetch_array($result);
if (is_array($prefr)) {
foreach ($prefr as $akey => $apref) { $pref = unserialize(base64_decode($row['e107_value']));
echo "<tr><td class='headertext2' style='width:50%; text-align:right;'>{$key}[{$akey}]&nbsp;&nbsp;</td>
<td style='width:50%'><input type='text' name='{$key}[{$akey}]' value='{$apref}' size='50' maxlength='100' /></td></tr>\n"; $PrefOutput = $eArrayStorage->WriteArray($pref);
} mysql_query("DELETE FROM ".$mySQLprefix."core WHERE `e107_name` = 'SitePrefs' OR `e107_name` = 'SitePrefs_Backup'");
} else { mysql_query("INSERT INTO ".$mySQLprefix."core VALUES ('SitePrefs', '{$PrefOutput}')");
echo "<tr><td class='headertext2' style='width:50%; text-align:right;'>{$key}&nbsp;&nbsp;</td> mysql_query("INSERT INTO ".$mySQLprefix."core VALUES ('SitePrefs_Backup', '{$PrefOutput}')");
<td style='width:50%'><input type='text' name='{$key}' value='{$prefr}' size='50' maxlength='100' /></td></tr>\n";
} $message = "Core backup successfully restored. <br /><br /><a href='../../index.php'>Click here to continue</a>";
} $END = TRUE;
echo " }
<tr>
<td colspan='2' style='text-align:center'><br /><input class='button' type='submit' name='coreedit_sub' value='Save Core Settings' /></td>
</tr> if (isset($_POST['reset_core_sub']) && $_POST['mode'] == 1)
</table> {
<input type='hidden' name='a_name' value='".$_POST['a_name']."' /> if (($at = e_verify()) === FALSE) {
<input type='hidden' name='a_password' value='".preg_replace("/\W/", '', $_POST['a_password'])."' /> exit;
</form>"; }
$END = TRUE;
} $result = @mysql_query("SELECT * FROM ".$mySQLprefix."core WHERE e107_name='SitePrefs'");
$row = @mysql_fetch_array($result);
if (isset($message)) {
echo "<br /><br /><div style='text-align:center'><span class='headertext2'>{$message}</span></div><br />"; $pref = $eArrayStorage->ReadArray($row['e107_value']);
}
echo "
if (isset($END)) { <span class='headertext2'><b>Edit your individual core items and click the button to save - <span class='headertext'>use this script with caution</span>.</b></span><br /><br />
echo "<br /></div></body></html>"; <form method='post' action='".$_SERVER['PHP_SELF']."'>
exit; <table style='width:95%'>\n";
}
while (list($key, $prefr) = each($pref)) {
echo "<span class='headertext2'> if (is_array($prefr)) {
This is the e107 resetcore utility. It allows you to completely rebuild your core if it becomes corrupt, or to restore a backup. <br />It won't affect your actual content (news posts, forum posts, articles etc).<br /> foreach ($prefr as $akey => $apref) {
<b>Only run this utility if your site is failing to load due to a critical core error, or if you need to change a setting and can't log into your admin area.</b></span><br /><br /><br /><br /> echo "<tr><td class='headertext2' style='width:50%; text-align:right;'>{$key}[{$akey}]&nbsp;&nbsp;</td>
<td style='width:50%'><input type='text' name='{$key}[{$akey}]' value='{$apref}' size='50' maxlength='100' /></td></tr>\n";
<span class='headertext'>Please enter your main administrator username and password to continue ...</span><br /><br />
<form method='post' action='".$_SERVER['PHP_SELF']."'> }
<table style='width:95%'> } else {
<tr> echo "<tr><td class='headertext2' style='width:50%; text-align:right;'>{$key}&nbsp;&nbsp;</td>
<td style='width:50%; text-align:right;' class='mediumtext'>Main administrator name:</td> <td style='width:50%'><input type='text' name='{$key}' value='{$prefr}' size='50' maxlength='100' /></td></tr>\n";
<td style='width:50%'> }
<input class='tbox' type='text' name='a_name' size='30' value='' maxlength='100' /> }
</td> echo "
</tr> <tr>
<tr> <td colspan='2' style='text-align:center'><br /><input class='button' type='submit' name='coreedit_sub' value='Save Core Settings' /></td>
<td style='width:50%; text-align:right;' class='mediumtext'>Main administrator Password:</td> </tr>
<td style='width:50%'> </table>
<input class='tbox' type='password' name='a_password' size='30' value='' maxlength='100' /> <input type='hidden' name='a_name' value='".$_POST['a_name']."' />
</td> <input type='hidden' name='a_password' value='".preg_replace("/\W/", '', $_POST['a_password'])."' />
</tr> </form>";
<tr> $END = TRUE;
<td colspan='2' style='text-align:center'> }
<br />
<input class='button' type='submit' name='usubmit' value='Continue' /> if (isset($message)) {
</td> echo "<br /><br /><div style='text-align:center'><span class='headertext2'>{$message}</span></div><br />";
</tr> }
</table>
<br /> if (isset($END)) {
</div> echo "<br /></div></body></html>";
</body> exit;
</html>"; }
function e_verify() { echo "<span class='headertext2'>
global $mySQLprefix; This is the e107 resetcore utility. It allows you to completely rebuild your core if it becomes corrupt, or to restore a backup. <br />It won't affect your actual content (news posts, forum posts, articles etc).<br />
if (ACTIVE !== TRUE) { <b>Only run this utility if your site is failing to load due to a critical core error, or if you need to change a setting and can't log into your admin area.</b></span><br /><br /><br /><br />
exit;
} <span class='headertext'>Please enter your main administrator username and password to continue ...</span><br /><br />
if (MAGIC_QUOTES_GPC == FALSE) { <form method='post' action='".$_SERVER['PHP_SELF']."'>
$a_name = addslashes($_POST['a_name']); <table style='width:95%'>
} <tr>
else <td style='width:50%; text-align:right;' class='mediumtext'>Main administrator name:</td>
{ <td style='width:50%'>
$a_name = $_POST['a_name']; <input class='tbox' type='text' name='a_name' size='30' value='' maxlength='100' />
} </td>
</tr>
$a_name = str_replace('/*', '', $a_name); <tr>
<td style='width:50%; text-align:right;' class='mediumtext'>Main administrator Password:</td>
$result = mysql_query("SELECT * FROM ".$mySQLprefix."user WHERE user_name='".$a_name."'"); <td style='width:50%'>
$row = mysql_fetch_array($result); <input class='tbox' type='password' name='a_password' size='30' value='' maxlength='100' />
</td>
if (($row['user_password'] === md5($_POST['a_password'])) && ($row['user_perms'] === '0') && (ACTIVE === TRUE)) { </tr>
clear_cache(); <tr>
return $row; <td colspan='2' style='text-align:center'>
} else { <br />
return FALSE; <input class='button' type='submit' name='usubmit' value='Continue' />
} </td>
} </tr>
</table>
function clear_cache() { <br />
// $dir = "../cache/"; </div>
$dir = e_CACHE; </body>
$pattern = "*.cache.php"; </html>";
$deleted = false;
$pattern = str_replace(array("\*", "\?"), array(".*", "."), preg_quote($pattern));
if (substr($dir, -1) != "/") { /**
$dir .= "/"; * Verify main admin data
} */
if (is_dir($dir)) { function e_verify() {
$d = opendir($dir); global $mySQLprefix;
while ($file = readdir($d)) { if (ACTIVE !== TRUE)
if (is_file($dir.$file) && preg_match("/^{$pattern}$/", $file)) { {
if (unlink($dir.$file)) { exit();
$deleted[] = $file; }
} if (MAGIC_QUOTES_GPC == FALSE)
} {
} $a_name = addslashes($_POST['a_name']);
closedir($d); }
return true; else
} else { {
return false; $a_name = $_POST['a_name'];
} }
}
$a_name = str_replace('/*', '', $a_name);
$result = mysql_query("SELECT * FROM ".$mySQLprefix."user WHERE user_name='".$a_name."'");
$row = mysql_fetch_array($result);
// @TODO: Will need to handle other password encodings as well
if (($row['user_password'] === md5($_POST['a_password'])) && ($row['user_perms'] === '0') && (ACTIVE === TRUE))
{
clear_cache();
return $row;
}
else
{
return FALSE;
}
}
/**
* Clear all cache files
*/
function clear_cache()
{
// $dir = "../cache/";
$dir = e_CACHE;
$pattern = "*.cache.php";
$deleted = false;
$pattern = str_replace(array("\*", "\?"), array(".*", "."), preg_quote($pattern));
if (substr($dir, -1) != "/") {
$dir .= "/";
}
if (is_dir($dir)) {
$d = opendir($dir);
while ($file = readdir($d)) {
if (is_file($dir.$file) && preg_match("/^{$pattern}$/", $file)) {
if (unlink($dir.$file)) {
$deleted[] = $file;
}
}
}
closedir($d);
return true;
} else {
return false;
}
}
?> ?>