rendered paste body<?php
require('inc/menu.inc.php');
$folder = "files/";
$file_ext = ".html";
if (is_dir($folder)) {
$act = $_GET['act'];
$acts = array('view', 'edit', 'new', 'delete','nothing');
if (!$act || !in_array($act, $acts)) {
$content .= "<a href=\"index2.php?act=view\">Go to Admin CP. " . $folder . "</a>\n";
} else {
if($act == 'nothing'){
echo "<--- please choose something from the left";
}
if ($act == 'view') {
$files = glob($folder . "*" . $file_ext);
if (count($files) == 0) {
$content .= "There are no <b>" . $file_ext . "</b> files in the folder <b>" . $folder .
"</b>\n";
} else {
$content .= "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n";
$content .= "<tr><td valign=\"top\">\n";
$content .= "<script language=\"Javascript\">\n";
$content .= "function confirmIt(filename){\n";
$content .= "\t var sure = confirm(\"Are you sure you want to delete \" + filename + \"?\");\n";
$content .= "\t if(sure){\n";
$content .= "\t\t return true;\n";
$content .= "\t }else {\n";
$content .= "\t\t return false;\n";
$content .= "\t }\n";
$content .= "}\n";
$content .= "</script>\n";
$content .= "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n";
$content .= "<tr id=\"trRowHeader\"><td>File Name</td><td>File Options</td><td>File Size</td></tr>\n";
foreach ($files as $file) {
$content .= "<tr class=\"trRowContent\"><td>" . str_replace($folder, null, $file) . "</td><td>• <a href=\"index2.php?act=edit&file=" . str_replace($folder, null, $file) ."\">Edit</a><br/>• <a href=\"".$folder . str_replace($folder, null, $file)."\">View</a> <br/>• <a href=\"index2.php?act=delete&file=".str_replace($folder, null, $file)."\" onClick=\"return confirmIt('".str_replace($folder, null, $file)."')\">Delete</a></td><td>" . filesize($file) . " bytes</td></tr>\n";
$filesizes += filesize($file);
}
$content .= "<tr class=\"trRowContent\"><td>Total Files: <b>" . count($files) . "</b></td><td colspan=\"2\">Total File Sizes: <b>" . number_format($filesizes) . "</b> bytes</td></tr>\n";
$content .= "<tr><td colspan=\"3\"><br/><br/><strong>Other Options:</strong><br/>• <a href=\"index2.php?act=new\">Create a New File</a></td></tr>\n";
$content .= "</table>\n";
$content .= "</td>\n";
$content .= "</table>\n";
}
}
if ($act == 'edit') {
$file = $_GET['file'];
if (file_exists($folder . $file)) {
if (!$_POST['submit']) {
if (is_readable($folder . $file)) {
$fg = file_get_contents($folder . $file);
echo "<form method=\"post\" action=\"index2.php?act=edit&file=" . $file . "\">\n";
echo "<center>\n";
echo "<textarea style=\"width:700px;height:600px;\" name=\"contents\">" . $fg ."</textarea>\n";
echo "<br><br>\n";
echo "<input type=\"submit\" name=\"submit\" value=\"Edit " . $file . "\"></form>\n";
}else {
echo "The file is not readable, please check the permissions of the file!\n";
}
}else {
$contents = $_POST['contents'];
if(!$contents){
echo "Please enter something for the file contents!\n";
}else {
if(!is_writable($folder . $file)){
echo "The file is not writable, please check the permissions of the file!\n";
}else {
$f = @fopen($folder . $file, "w");
fwrite($f, $contents);
fclose($f);
$content .= "<b>". $file ."</b> has been successfully updated, <a href=\"index2.php?act=edit&file=".$file."\">click here</a> to continue updating, or <a href=\"index2.php?act=view\">click here</a> to edit a different file!\n";
}
}
}
}
}
if($act == 'new'){
if(!$_POST['submit']){
$content .= "<form method=\"post\" action=\"index2.php?act=new\">\n";
$content .= "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n";
$content .= "<tr><td>File Name</td><td><input type=\"text\" name=\"filename\"></td><td><font color=\"red\">do not include <b>".$file_ext."</b></font></td></tr>\n";
$content .= "<tr><td colspan=\"3\" align=\"right\"><input type=\"submit\" name=\"submit\" value=\"Create New File\"></td></tr>\n";
$content .= "</table></form>\n";
}else {
$filename = urlencode($_POST['filename']);
if(!$filename){
$content .= "You did not supply a filename!\n";
}else {
$file = $folder . $filename . $file_ext;
if(file_exists($file)){
$content .= "This file already exists!\n";
}else {
$f = fopen($file, "w");
if(!$f){
$content .= "The file could not be created, please check your folder permissions!\n";
}else {
$content .= "The file <b>". str_replace($folder, null, $file) ."</b> has been created! <a href=\"index2.php?act=view\">Click here</a> to view your files!\n";
}
fclose($f);
}
}
}
}
if($act == 'delete'){
$file = $_GET['file'];
if(file_exists($folder . $file)){
unlink($folder . $file);
$content .= "The file <b>".$file."</b> has been deleted! <a href=\"index2.php?act=view\">Click here</a> to view your files!\n";
}else {
$content .= "This file does not exist!\n";
}
}
}
} else {
$content .= $folder . " is not a real folder!\n";
}
if (!empty($content))
{
?>
<!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>SANTA FE Storage :: Admin :: File Editor</title>
<link rel="Stylesheet" type="text/css" href="css/main.css" />
<script type="text/javascript" src="js/menu.js">
</script>
</head>
<body>
<table id="tblMain" width="736" cellpadding="0" cellspacing="0">
<tr>
<td colspan="6">
<img id="banner" src="images/banner.gif" width="736" height="109" alt="" />
</td>
</tr>
<tr>
<td colspan="6" height="21">
<div style="position:relative;">
<table id="tblMenuTop" cellpadding="0" cellspacing="0">
<tr>
<?php
echo createTopMenu();
?>
</tr>
</table>
<table id="tblMenuTop" cellpadding="0" cellspacing="0">
<tr>
<?php
echo createAdminMenu();
?>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td colspan="6">
<?php
echo $content;
?>
</td>
</tr>
<tr>
<td colspan="6">
<img id="footer" src="images/footer.gif" width="736" height="55" alt="" /></td>
</tr>
<table id="tblMenuBottom" cellpadding="0" cellspacing="0">
<tr>
<?php
echo createBottomMenu();
?>
</tr>
</table>
</body>
</html>
<?php
}
?>