/** * Write the content * If no content is given, then try to make a read instead */ public function write($ret) { if ($ret == '') { $ret = fileread($this->file); } else { $ret = filewrite($this->file, $ret); } return $ret; }
function compile($file) { echo "<b>" . $file . "</b>\n"; if (is_file($file)) { // compile it $c = new smartClosure(); $result = $c->add($file)->simpleMode()->_compile(); // write it $compiled = substr($result, strpos($result, '*/') + 3); $compiled = "/* smartVISU, Martin Gleiß, 2013, GPL [http://www.gnu.de] */\n" . $compiled; filewrite(substr($file, 0, -3) . ".min.js", $compiled); // status $pos = strpos($result, '\'') + 1; echo str_replace(" Size", "", str_replace("\\n", ", ", substr($result, $pos + 50, strpos($result, ');') - $pos - 1 - 104))); echo "\n"; } else { echo "...not found!\n"; } }
xoops_cp_footer(); } exit(); } if ($action == 'rename') { if ( $confirm == '1') { $new_filename = "{$_POST['workpath']}/{$_POST['new_filename']}"; $old_filename = "{$_POST['workpath']}/{$_POST['old_filename']}"; //safemodeon($_POST['workpath'], '', $_POST['new_filename'], 'renamed'); filecheck($_POST['workpath'], '', $_POST['new_filename'], ''); fileexists($_POST['workpath'], $new_filename,'', 'File'); folderwrite($_POST['workpath'], '','', 'rename'); filewrite($_POST['workpath'], '$new_filename','', 'rename'); renameit($_POST['workpath'], $old_filename, $new_filename, 'File'); redirect_header("javascript:history.go(-1)",1,"Unknown Error: File not renamed!"); exit(); } else { include XOOPS_ROOT_PATH."/class/xoopsformloader.php"; xoops_cp_header(); $sform = new XoopsThemeForm("Rename File", "op", "filemanager.php?action=rename&confirm=1"); $sform->addElement(new XoopsFormLabel(_AM_CURRENTFILENAME, basename($file))); $sform->addElement(new XoopsFormText("Rename File: ", 'new_filename', 30, 80, basename($file)), false); $sform->addElement(new XoopsFormHidden('old_filename', basename(htmlentities($file)))); $sform->addElement(new XoopsFormHidden('workpath', $_GET['workpath'])); $button_tray = new XoopsFormElementTray('',''); $button_tray->addElement(new XoopsFormButton('', 'save', "Rename", 'submit')); $sform->addElement($button_tray);
$button_tray->addElement(new XoopsFormButton('', 'save', "Delete", 'submit')); $sform->addElement($button_tray); $sform->display(); xoops_cp_footer(); } exit; } if ($action == 'rename') { if ($confirm == '1') { $new_filename = "{$HTTP_POST_VARS['workpath']}/{$HTTP_POST_VARS['new_filename']}"; $old_filename = "{$HTTP_POST_VARS['workpath']}/{$HTTP_POST_VARS['old_filename']}"; //safemodeon($HTTP_POST_VARS['workpath'], '', $HTTP_POST_VARS['new_filename'], 'renamed'); filecheck($HTTP_POST_VARS['workpath'], '', $HTTP_POST_VARS['new_filename'], ''); fileexists($HTTP_POST_VARS['workpath'], $new_filename, '', 'File'); folderwrite($HTTP_POST_VARS['workpath'], '', '', 'rename'); filewrite($HTTP_POST_VARS['workpath'], '$new_filename', '', 'rename'); renameit($HTTP_POST_VARS['workpath'], $old_filename, $new_filename, 'File'); redirect_header("javascript:history.go(-1)", 1, "Unknown Error: File not renamed!"); exit; } else { include XOOPS_ROOT_PATH . "/class/xoopsformloader.php"; xoops_cp_header(); $sform = new XoopsThemeForm("Rename File", "op", "filemanager.php?action=rename&confirm=1"); $sform->addElement(new XoopsFormLabel(_AM_CURRENTFILENAME, basename($file))); $sform->addElement(new XoopsFormText("Rename File: ", 'new_filename', 30, 80, basename($file)), false); $sform->addElement(new XoopsFormHidden('old_filename', basename(htmlentities($file)))); $sform->addElement(new XoopsFormHidden('workpath', $_GET['workpath'])); $button_tray = new XoopsFormElementTray('', ''); $button_tray->addElement(new XoopsFormButton('', 'save', "Rename", 'submit')); $sform->addElement($button_tray); $sform->display();
@mysql_query("SET NAMES \'utf8\'"); $ask = mysql_query("SELECT * FROM ' . $table . '"); while($b = mysql_fetch_assoc($ask)) { ?>'; for ($i = 1; $i <= $many; $i++) { $file .= "\n" . $_POST["constant" . $i] . "\n<?php " . 'echo $b[' . $i . ']."\\n"; ?>'; } $file .= $_POST["constant" . $manyy] . "\n\n<?php } ?>"; $filename = '../inc/' . $table . '.php'; $ic .= filewrite($filename, $file) . '<br>'; /* CREATE FILE WHICH WILL INCLUDE FINISH */ /* CREATE ADMIN FILE START */ $z = 1; $types = NULL; while (isset($_POST["type" . $z])) { $types .= '$vartype[' . ($z - 1) . '] = \'' . $_POST["type" . $z] . '\';' . "\n"; $z++; } $ali = file_get_contents('customadmin.txt'); $ali = str_replace(array("{{table}}", "{{types}}"), array($table, $types), $ali); $filename = '../admin/customadmin.php'; $y = 1; while (file_exists($filename)) { $filename = '../admin/custom' . $y . 'admin.php'; $y++; } $ic .= filewrite($filename, $ali); /* CREATE ADMIN FILE FINISH */ } include "../template.php";
function allowupdate() { global $UPDATELOG; // Number of seconds per "period" // Default is 1 hour == 60 * 60 == 3600 seconds $PERIOD = 3600; // Number of updates within $PERIOD $ALLOWEDUPDATES = 3; $times = @file($UPDATELOG); // If the file doesn't exist, this must be the first update, // so write the file and allow the update // ALLOW the update if (!$times) { filewrite($UPDATELOG, time() + "\n"); return true; } else { // Read the first line in the file 'updatetimes' // which represents the first update time $first = $times[0]; // Then get the time now $now = time(); // If we've been called in the same period as the original timestamp // AND the total number of stamps is less than $ALLOWEDUPDATES // ALLOW the update if ($now - $first < $PERIOD && sizeof($times) < $ALLOWEDUPDATES) { filewrite($UPDATELOG, $now); return true; } else { if ($now - $first > $PERIOD) { unlink($UPDATELOG); filewrite($UPDATELOG, $now); return true; } else { if ($now - $first < $PERIOD && sizeof($times) > $ALLOWEDUPDATES) { return false; } else { return false; } } } } }