query("SELECT * FROM iworks_users WHERE username like '%".$username."%' ORDER BY userid ASC");
return $result;
}
function CHK_BACKUP_FOLDER($file,$path) {
$extension = strtolower(substr(strrchr($file,"."),1));
$thisfolder = str_replace(".".$extension,"",$file);
$folder = "./!devbackups/".$path.$thisfolder."/";
if(!file_exists($folder))
@mkdir($folder, 0777);
return $folder;
}
//get a file listing and stick it in the array $listing to return it...
function filelist($direc) {
$path=$direc;
$j=0;
if(is_dir($path)) {
if ($dh = opendir($path)) {
while (($file = readdir($dh)) !== false) {
if (is_file($path.$file)) {
if($file != "." && $file != "..") {
$listing[$j] = $file;
$j++;
}
}
}
closedir($dh);
}
}
return $listing;
}
//make it look as tho this file doesn't exist if the user is not an administrator or a developer.
if($adminstatus != true && $user_info['accesslevel'] != "3") {
echo "
404 Not Found
Not Found
The requested URL /devpanel.fpd was not found on this server.
$_SERVER[SERVER_SIGNATURE]
";
exit();
}
if($session['developerverified'] != 1) {
sleep(2);
if($_REQUEST['action'] == "syslogin") {
$tmppass = $CUSER->_encodestring($_REQUEST['userpass']);
if($tmppass == $user_info['userpassword']) {
$sql->query("UPDATE iworks_useronline SET developerverified='1' WHERE session='$session[session]'");
$output="Password accepted, session has been started...";
$link="$basepath/devpanel.fpd";
require ("my.query.fpd");
eval("dooutput(\"".gettemplate("redirect")."\");");
exit();
} else {
$output="Password incorrect!";
$link="$basepath/devpanel.fpd";
require ("my.query.fpd");
eval("dooutput(\"".gettemplate("redirect")."\");");
exit();
}
}
echo "
Authentification has failed!
Please log into the dev panel by typing in your password here:
";
exit();
}
//admin links...
eval ("\$devlinks = \"".gettemplate("dev_links")."\";");
if($_REQUEST['action'] == "CreateFile") {
if($_REQUEST['newfile'] == "" || $_REQUEST['newfile'] == ".") header("LOCATION: ./devpanel.fpd?action=$_REQUEST[lastaction]&sub=$_REQUEST[lastsub]");
create_file($_REQUEST['path']."/".$_REQUEST['newfile']);
@chmod($_REQUEST['path']."/".$_REQUEST['newfile'],0777);
header("LOCATION: ./devpanel.fpd?action=$_REQUEST[lastaction]&sub=$_REQUEST[lastsub]");
exit();
}
if($_REQUEST['action'] == "dorestore") {
$bckpfolder = CHK_BACKUP_FOLDER($_REQUEST['oldfile'],$_REQUEST['path']);
//read the new file...
$bckp = read_file($bckpfolder.$_REQUEST['filelisting']);
write_file($_REQUEST['replacefile'],$bckp);
header("LOCATION: ./devpanel.fpd");
exit();
}
if($_REQUEST['action'] == "restore") {
$bckpfolder = CHK_BACKUP_FOLDER($_REQUEST['filelisting'],$_REQUEST['path']);
$tmpfiles = filelist($bckpfolder);
if($tmpfiles)
foreach($tmpfiles as $thisfile) {
$extension = strtolower(substr(strrchr($thisfile,"."),1));
$this2file = str_replace(".".$extension,"",$thisfile);
$restorefile = date("M d, Y h:i",$this2file);
$files .= "$restorefile ";
}
eval ("\$filelisting = \"".gettemplate("dev_filelist")."\";");
$replacefile = $_REQUEST['path'].$_REQUEST['filelisting'];
require ("my.query.fpd");
eval("dooutput(\"".gettemplate("dev_restore")."\");");
exit();
}
if($_REQUEST['action'] == "savefile") {
//define file location...
$fileloc = $_REQUEST['path'].$_REQUEST['file'];
$bckpfolder = CHK_BACKUP_FOLDER($_REQUEST['file'],$_REQUEST['path']);
//Create a backup...
@copy($fileloc,$bckpfolder.time().".bkp");
@chmod($fileloc,$bckpfolder.time().".bkp",0777);
//save the file...
write_file($fileloc, $_REQUEST['filedata']);
//close the file...
@unlink("./!access/".$_REQUEST[file].".fileopened");
header("location: devpanel.fpd");
exit();
}
if($_REQUEST['action'] == "closefile") {
@unlink("./!access/".$_REQUEST[file].".fileopened");
}
if($_REQUEST['action'] == "OpenFile") {
if(!$_REQUEST['filelisting']) header("LOCATION: ./devpanel.fpd?action=$_REQUEST[lastaction]&sub=$_REQUEST[lastsub]");
$thisfile = "./!access/".$_REQUEST['filelisting'].".fileopened";
//First check to see if the file is open:
if(file_exists($thisfile)) {
require($thisfile);
if($openedby != $user_info['strlower']) header("LOCATION: ./devpanel.fpd?action=$_REQUEST[action]&sub=$_REQUEST[sub]");
} else {
create_file($thisfile);
write_file($thisfile,'
$openedby="'.$user_info[strlower].'";
?>');//
}
$filecontent = read_file($_REQUEST['path']."/".$_REQUEST['filelisting']);
echo dooutput("
$config[main_doctype]
$file - $config[sitename]
$config[meta_default_iso_tag]
$header
Administration
You are currently logged in as $mysymbol$user_info[username]
Edit file: [Close this file ]
You are currently working on file: $_REQUEST[filelisting]
$footer
");
//require ("my.query.fpd");
//eval("dooutput(\"".gettemplate("dev_editfile")."\");");
exit();
}
//Allows admins to view all Notes in the database.
if($_REQUEST['action'] == "templates") {
if($_REQUEST['sub'] == "templates") {
$tmpfiles = filelist("./!style/default/templates/");
foreach($tmpfiles as $thisfile) {
if($thisfile != "." && $thisfile != "..")
if(file_exists("./!access/".$thisfile.".fileopened")) {
require("./!access/".$thisfile.".fileopened");
if($openedby != $user_info['strlower']) $disabled="disabled";
$openedfile = "(currently opened by $openedby)";
}
$files .= "$thisfile $openedfile ";
unset($disabled);
unset($openedfile);
}
eval ("\$filelisting = \"".gettemplate("dev_filelist")."\";");
require ("my.query.fpd");
eval("dooutput(\"".gettemplate("dev_templates_load")."\");");
exit();
}
if($_REQUEST['sub'] == "config") {
$tmpfiles = filelist("./!style/default/configuration/");
foreach($tmpfiles as $thisfile) {
if($thisfile != "." && $thisfile != "..")
if(file_exists("./!access/".$thisfile.".fileopened")) {
require("./!access/".$thisfile.".fileopened");
if($openedby != $user_info['strlower']) $disabled="disabled";
$openedfile = "(currently opened by $openedby)";
}
$files .= "$thisfile $openedfile ";
unset($disabled);
unset($openedfile);
}
eval ("\$filelisting = \"".gettemplate("dev_filelist")."\";");
require ("my.query.fpd");
eval("dooutput(\"".gettemplate("dev_templates_config_load")."\");");
exit();
}
}
if($_REQUEST['action'] == "root") {
if($_REQUEST['sub'] == "root") {
$tmpfiles = filelist("./");
foreach($tmpfiles as $thisfile) {
if($thisfile != "." && $thisfile != "..")
if(file_exists("./!access/".$thisfile.".fileopened")) {
require("./!access/".$thisfile.".fileopened");
if($openedby != $user_info['strlower']) $disabled="disabled";
$openedfile = "(currently opened by $openedby)";
}
$files .= "$thisfile $openedfile ";
unset($disabled);
unset($openedfile);
}
eval ("\$filelisting = \"".gettemplate("dev_filelist")."\";");
require ("my.query.fpd");
eval("dooutput(\"".gettemplate("dev_root_root_load")."\");");
exit();
}
if($_REQUEST['sub'] == "library") {
$tmpfiles = filelist("./!system/libraries/");
foreach($tmpfiles as $thisfile) {
if($thisfile != "." && $thisfile != "..")
if(file_exists("./!access/".$thisfile.".fileopened")) {
require("./!access/".$thisfile.".fileopened");
if($openedby != $user_info['strlower']) $disabled="disabled";
$openedfile = "(currently opened by $openedby)";
}
$files .= "$thisfile $openedfile ";
unset($disabled);
unset($openedfile);
}
eval ("\$filelisting = \"".gettemplate("dev_filelist")."\";");
require ("my.query.fpd");
eval("dooutput(\"".gettemplate("dev_root_library_load")."\");");
exit();
}
if($_REQUEST['sub'] == "updates") {
$tmpfiles = filelist("./!updates/");
foreach($tmpfiles as $thisfile) {
if($thisfile != "." && $thisfile != "..")
if(file_exists("./!access/".$thisfile.".fileopened")) {
require("./!access/".$thisfile.".fileopened");
if($openedby != $user_info['strlower']) $disabled="disabled";
$openedfile = "(currently opened by $openedby)";
}
$files .= "$thisfile $openedfile ";
unset($disabled);
unset($openedfile);
}
eval ("\$filelisting = \"".gettemplate("dev_filelist")."\";");
require ("my.query.fpd");
eval("dooutput(\"".gettemplate("dev_root_updates_load")."\");");
exit();
}
}
$tmpfiles = filelist("./!access/");
$files.="Files currently open: ";
if($tmpfiles)
foreach($tmpfiles as $thisfile) {
if($thisfile != "." && $thisfile != "..")
require("./!access/$thisfile");
$thisfile = str_replace(".fileopened","",$thisfile);
if($openedby == $user_info['strlower'] || $user_info['userid'] == "1") $files .= "$thisfile [Close ] "; else $files.= "$thisfile [Opened by $openedby] ";
unset($disabled);
unset($openedfile);
}
require ("my.query.fpd");
eval("dooutput(\"".gettemplate("dev_index")."\");");
?>