define('VERSION','V1.7 © 2007'); session_start(); if($_POST[user]) { $_SESSION[username]=$_POST[user]; $_SESSION[password]=$_POST[pass]; } $msg=""; $q=$_GET[q]; extract($_POST); if($submit=="Update") { $file = ""; foreach ($_POST as $key=>$value) { if(substr($key,0,4)=="line" && $value>'') { $file .= trim(urldecode($value))."\r\n"; } } foreach ($_POST as $key=>$value) { if(substr($key,0,4)<>"line") { if($value=="on") { $value="1"; } $file = str_replace("##$key##",$value,$file); } } $file = preg_replace('/(##[a-z_]*##)/','0',$file); $filename = "../includes/config.php"; // Let's make sure the file exists and is writable first. if (is_writable($filename)) { if (!$handle = fopen($filename,'w')) { die("Cannot open file `$filename`."); } if (fwrite($handle,$file) === FALSE) { die("Cannot write to file `$filename`."); } $msg="Settings successfully updated!"; fclose($handle); } else { $msg="Your config file is not writable. config.php should be CHMOD 666"; } $_SESSION[username]=$username; $_SESSION[password]=$password; } $filename = "../includes/config.php"; include ($filename); $line = file($filename); if(!count($line)) { die ("Unable to open `$filename`. Make sure that this admin folder has been uploaded in the root folder that contains your `docs` and `includes` folders."); } if(!is_writable($filename)) { die ("Your config file is not writable. config.php should be CHMOD 666"); } if($_POST[submit]=="Login" && ( !isset($username) || !isset($password) ) ) { // write variables to config file $username = $_POST[user]; $password = $_POST[pass]; $line[1] .= '//---------------------------------------------------------------------------------- $username = "'.$username.'"; // Admin username $password = "'.$password.'"; // Admin password //---------------------------------------------------------------------------------- '; $file = trim(implode('',$line)); if (!$handle = fopen($filename,'w')) { die("Cannot open file `$filename`."); } if (fwrite($handle,$file) === FALSE) { die("Cannot write to file `$filename`."); } $msg="Username and Password successfully added!"; fclose($handle); } if($_SESSION[username]<>$username || $_SESSION[password]<>$password || $username=='' || $password=='') { echo '
'; } echo '
'; if($template>"") { $text = @file("../includes/articles/$template","r"); echo ''; } include("footer.php"); exit; } if($q=="newarticle") { echo ''; include("footer.php"); exit; } if($q=="keywords") { include("keywords.php"); exit; } if($q) { $filename = "../includes/pages/$q"; if(!is_writable($filename)) { die("$q is not writable! All files in your includes/pages directory should be CHMOD 666"); } $text = @file($filename,"r"); echo 'EDIT PAGE : '.$q.' '; include("footer.php"); exit; } $line = file($filename); echo 'This page will allow you to update your site settings.include("footer.php"); ?>