本文整理汇总了PHP中getDirectory函数的典型用法代码示例。如果您正苦于以下问题:PHP getDirectory函数的具体用法?PHP getDirectory怎么用?PHP getDirectory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getDirectory函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDirectory
function getDirectory($path = '.', $ignore = '', $regexp_ignore = array())
{
//echo $path."\n";
$dirTree = array();
$dirTreeTemp = array();
$ignore[] = '.';
$ignore[] = '..';
$dh = @opendir($path);
while (false !== ($file = readdir($dh))) {
if (!in_array($file, $ignore)) {
if (!is_dir("{$path}/{$file}")) {
$reIgnore = 0;
//for($i=0;$i<count($regexp_ignore);$i++){
if (preg_match($regexp_ignore[0], $file)) {
$reIgnore = 1;
//print "$regexp_ignore[0],$path ,$file - ".(string)preg_match($regexp_ignore[0], $file)."\n";
}
//}
if ($reIgnore == 0) {
$dirTree["{$path}"][] = $file;
}
} else {
$dirTreeTemp = getDirectory("{$path}/{$file}", $ignore, $regexp_ignore);
if (is_array($dirTreeTemp)) {
$dirTree = array_merge($dirTree, $dirTreeTemp);
}
}
}
}
closedir($dh);
return $dirTree;
}
示例2: getDirectory
function getDirectory($path = '.', $level = 0)
{
$ignore = array('cgi-bin', '.', '..');
// Directories to ignore when listing output. Many hosts
// will deny PHP access to the cgi-bin.
$dh = @opendir($path);
// Open the directory to the handle $dh
while (false !== ($file = readdir($dh))) {
// Loop through the directory
if (!in_array($file, $ignore)) {
// Check that this file is not to be ignored
if (is_dir("{$path}/{$file}")) {
// Its a directory, so we need to keep reading down...
getDirectory("{$path}/{$file}", $level + 1);
// Re-call this same function but on a new directory.
// this is what makes function recursive.
} else {
$tpath = $path;
$tpath .= '/' . $file;
print '<option data-img-src="' . $tpath . '" value="' . $tpath . '">' . $file . '</option>';
}
}
}
closedir($dh);
// Close the directory handle
}
示例3: DeleteHTMLReports
static function DeleteHTMLReports()
{
global $CONFIG;
if (!empty($CONFIG["gl_st_ders"]) && is_numeric($CONFIG["gl_st_derd"])) {
foreach (array(STATISTIC_PERIOD_TYPE_MONTH, STATISTIC_PERIOD_TYPE_YEAR, STATISTIC_PERIOD_TYPE_DAY) as $type) {
$files = getDirectory(PATH_STATS . $type, "");
foreach ($files as $file) {
$mtime = @filemtime(PATH_STATS . $type . "/" . $file);
if (!empty($mtime) && $mtime < time() - 86400 * $CONFIG["gl_st_derd"]) {
@unlink(PATH_STATS . $type . "/" . $file);
}
}
}
$tables = array(DATABASE_STATS_AGGS_GOALS, DATABASE_STATS_AGGS_PAGES_ENTRANCE, DATABASE_STATS_AGGS_PAGES_EXIT, DATABASE_STATS_AGGS_CRAWLERS, DATABASE_STATS_AGGS_DOMAINS, DATABASE_STATS_AGGS_BROWSERS, DATABASE_STATS_AGGS_RESOLUTIONS, DATABASE_STATS_AGGS_COUNTRIES, DATABASE_STATS_AGGS_VISITS, DATABASE_STATS_AGGS_SYSTEMS, DATABASE_STATS_AGGS_LANGUAGES, DATABASE_STATS_AGGS_CITIES, DATABASE_STATS_AGGS_REGIONS, DATABASE_STATS_AGGS_ISPS, DATABASE_STATS_AGGS_QUERIES, DATABASE_STATS_AGGS_PAGES, DATABASE_STATS_AGGS_REFERRERS, DATABASE_STATS_AGGS_AVAILABILITIES, DATABASE_STATS_AGGS_DURATIONS, DATABASE_STATS_AGGS_CHATS, DATABASE_STATS_AGGS_SEARCH_ENGINES, DATABASE_STATS_AGGS_VISITORS);
$result = queryDB(true, "SELECT * FROM `" . DB_PREFIX . DATABASE_STATS_AGGS . "` WHERE `year`<" . date("Y") . " AND `aggregated`=1 AND `time`<" . (time() - 86400 * $CONFIG["gl_st_derd"]) . " LIMIT 1;");
if ($result) {
if ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
foreach ($tables as $table) {
queryDB(true, "DELETE FROM `" . DB_PREFIX . $table . "` WHERE `year`<" . date("Y") . " AND day=" . $row["day"] . " AND month=" . $row["month"] . " AND year=" . $row["year"]);
}
queryDB(true, "DELETE FROM `" . DB_PREFIX . DATABASE_STATS_AGGS . "` WHERE `year`<" . date("Y") . " AND `aggregated`=1 AND day=" . $row["day"] . " AND month=" . $row["month"] . " AND year=" . $row["year"] . " LIMIT 1;");
}
}
}
}
示例4: getDirectory
function getDirectory($path = '.', $level = 0)
{
$ignore = array('cgi-bin', '.', '..');
// Directories to ignore when listing output. Many hosts
// will deny PHP access to the cgi-bin.
$dh = @opendir($path);
// Open the directory to the handle $dh
while (false !== ($file = readdir($dh))) {
// Loop through the directory
if (!in_array($file, $ignore)) {
// Check that this file is not to be ignored
str_repeat(' ', $level * 4);
// Just to add spacing to the list, to better
// show the directory tree.
if (is_dir("{$path}/{$file}")) {
// Its a directory, so we need to keep reading down...
echo "{$path}/{$file};";
getDirectory("{$path}/{$file}", $level + 1);
// Re-call this same function but on a new directory.
// this is what makes function recursive.
} else {
echo "{$path}/{$file};";
// Just print out the filename
}
}
}
closedir($dh);
// Close the directory handle
}
示例5: runTestAutoLoader
function runTestAutoLoader($autoLoader = null)
{
$directory = getDirectory();
$mwVendorPath = $directory . '/../../vendor/autoload.php';
$localVendorPath = $directory . '/../vendor/autoload.php';
if (is_readable($localVendorPath)) {
$autoLoader = registerAutoloaderPath('local', $localVendorPath);
} elseif (is_readable($mwVendorPath)) {
$autoLoader = registerAutoloaderPath('MediaWiki', $mwVendorPath);
}
if (!$autoLoader instanceof \Composer\Autoload\ClassLoader) {
return false;
}
return true;
}
示例6: getDirectory
function getDirectory($path = '.', $level = 0)
{
$ignore = array('cgi-bin', '.', '..');
// Directories to ignore when listing output. Many hosts
// will deny PHP access to the cgi-bin.
$dh = @opendir($path);
// Open the directory to the handle $dh
while (false !== ($file = readdir($dh))) {
// Loop through the directory
if (!in_array($file, $ignore)) {
// Check that this file is not to be ignored
$spaces = str_repeat(' ', $level * 4);
// Just to add spacing to the list, to better
// show the directory tree.
if (is_dir("{$path}/{$file}")) {
// Its a directory, so we need to keep reading down...
echo "<hr>";
echo " Gallery Name:<strong>{$spaces} {$file}</strong><br />";
echo "<hr>";
getDirectory("{$path}/{$file}", $level + 1);
// Re-call this same function but on a new directory.
// this is what makes function recursive.
} else {
$filetype = filetype("{$path}/{$file}");
$filesize = filesize("{$path}/{$file}");
/* echo "$spaces $file<br />";
echo "$spaces $filetype<br />";
echo "$spaces $filesize<br />";
echo"<br>";
echo"<br>"*/
$ext = pathinfo($file, PATHINFO_EXTENSION);
echo "{$file}<br />Type: {$ext}<br />Size: {$filesize} kb<br />";
echo "<br>";
// Just print out the filename
//echo filetype("$path/$file");
//echo filesize("$path/$file");
}
}
}
closedir($dh);
// Close the directory handle
}
示例7: getDirectory
function getDirectory($path = '.')
{
echo '<ul>';
$ignore = array('.svn', '.', '..', 'support', 'gc_tc.html');
$dh = @opendir($path);
while (false !== ($file = readdir($dh))) {
if (!in_array($file, $ignore)) {
if (is_dir("{$path}/{$file}")) {
echo "<li><button>" . htmlspecialchars($file) . "</button>";
getDirectory("{$path}/{$file}");
} else {
if (preg_match('/\\.html?$/', $file) && !preg_match("/^\\d\\d\\d-/", $file)) {
echo "<li><a href=\"" . htmlspecialchars("{$path}/{$file}") . "\">" . htmlspecialchars($file) . "</a> <samp></samp>";
}
}
}
}
closedir($dh);
echo '</ul>';
}
示例8: getDirectory
function getDirectory($path = '.')
{
echo '<ul>';
$ignore = array('non-automated', 'Watir', 'support', 'invalid', 'bugs', 'reftest');
$files = @scandir($path);
if ($files) {
natcasesort($files);
foreach ($files as $file) {
if ($file[0] !== '.' && !in_array($file, $ignore)) {
if (is_dir("{$path}/{$file}")) {
echo "<li><button>" . htmlspecialchars($file) . "</button>";
getDirectory("{$path}/{$file}");
} else {
if (preg_match('/\\.html?$/', $file) && !preg_match("/^\\d\\d\\d-/", $file)) {
echo "<li><a href=\"" . htmlspecialchars("{$path}/{$file}") . "\">" . htmlspecialchars($file) . "</a> <samp></samp>";
}
}
}
}
}
echo '</ul>';
}
示例9: getConfig
function getConfig()
{
global $CONFIG;
loadConfig();
$skeys = array("gl_db_host", "gl_db_user", "gl_db_pass", "gl_db_name");
$xml = "<gl_c h=\"" . base64_encode(substr(md5file(FILE_CONFIG), 0, 5)) . "\">\r\n";
foreach ($CONFIG as $key => $val) {
if (is_array($val)) {
$xml .= "<conf key=\"" . base64_encode($key) . "\">\r\n";
foreach ($val as $skey => $sval) {
$xml .= "<sub key=\"" . base64_encode($skey) . "\">" . base64_encode($sval) . "</sub>\r\n";
}
$xml .= "</conf>\r\n";
} else {
if (!in_array($key, $skeys) || SERVERSETUP) {
$xml .= "<conf value=\"" . base64_encode($val) . "\" key=\"" . base64_encode($key) . "\" />\r\n";
} else {
$xml .= "<conf value=\"" . base64_encode("") . "\" key=\"" . base64_encode($key) . "\" />\r\n";
}
}
}
if (SERVERSETUP) {
$xml .= "<translations>\r\n";
$files = getDirectory("./_language", "index", true);
foreach ($files as $translation) {
$lang = str_replace(".php", "", str_replace("lang", "", $translation));
$xml .= "<language key=\"" . base64_encode($lang) . "\" />\r\n";
}
$xml .= "</translations>\r\n";
if (@file_exists(FILE_CARRIERLOGO)) {
$xml .= "<carrier_logo content=\"" . fileToBase64(FILE_CARRIERLOGO) . "\" />\r\n";
}
if (@file_exists(FILE_CARRIERHEADER)) {
$xml .= "<carrier_header content=\"" . fileToBase64(FILE_CARRIERHEADER) . "\" />\r\n";
}
if (@file_exists(FILE_INVITATIONLOGO)) {
$xml .= "<invitation_logo content=\"" . fileToBase64(FILE_INVITATIONLOGO) . "\" />\r\n";
}
}
$xml .= "<php_cfg_vars post_max_size=\"" . base64_encode(cfgFileSizeToBytes(!isnull(@get_cfg_var("post_max_size")) ? get_cfg_var("post_max_size") : MAX_POST_SIZE_SAFE_MODE)) . "\" upload_max_filesize=\"" . base64_encode(cfgFileSizeToBytes(!isnull(@get_cfg_var("upload_max_filesize")) ? get_cfg_var("upload_max_filesize") : MAX_UPLOAD_SIZE_SAFE_MODE)) . "\" />\r\n";
$xml .= "</gl_c>\r\n";
return $xml;
}
示例10: buildTracking
function buildTracking()
{
global $VISITOR, $CONFIG, $DATASETS;
$VISITOR = array();
$outdatedVisitors = array();
$itarray = array_keys($DATASETS);
foreach ($itarray as $file) {
$dataset = $DATASETS[$file];
if (strpos($file, PATH_DATA_EXTERNAL) !== false && substr($file, 0, strlen(PATH_DATA_EXTERNAL)) == PATH_DATA_EXTERNAL) {
$userid = substr(str_replace(PATH_DATA_EXTERNAL, "", $file), 0, USER_ID_LENGTH);
$browsers = getDirectory(PATH_DATA_EXTERNAL . $userid . "/b/", ".");
if (count($browsers) > 0) {
foreach ($browsers as $browserid) {
$browser = new ExternalBrowser($browserid, $userid);
$chat = new ExternalChat($userid, $browserid);
if (!isset($VISITOR[$userid])) {
$VISITOR[$userid] = new UserExternal($userid);
}
if (($bStime = getDataSetTime($browser->SessionFile)) != -1) {
if ($bStime < time() - $CONFIG["timeout_track"]) {
$browser->Destroy();
continue;
}
$VISITOR[$userid]->Browsers[$browserid] = $browser;
} else {
if (($cStime = getDataSetTime($chat->SessionFile)) != -1) {
$chat->Load();
if ($cStime < time() - $CONFIG["timeout_clients"]) {
$chat->Destroy();
continue;
}
if (isnull($chat->FirstActive)) {
$chat->FirstActive = time();
}
$chat->History[0] = array($chat->FirstActive, LIVEZILLA_URL . FILE_CHAT, $chat->Code, true);
$VISITOR[$userid]->Browsers[$browserid] = $chat;
} else {
$browser->Destroy();
$chat->Destroy();
}
}
}
} else {
$outdatedVisitors[] = $userid;
}
}
}
foreach ($outdatedVisitors as $folder) {
deleteDirectory(PATH_DATA_EXTERNAL . $folder);
}
}
示例11: getFile
/**
* getFile
*
* Returns the information for the file specified by parameter fullPath.
* If the designated file is a directory the directory content is returned
* as the children of the file.
*
* @param filePath File path string
* @param rootDir Root directory
* @param args HTTP QUERY-STRING arguments decoded.
* @param status Receives the final result (200, 204 or 404).
*
* @return An array of 1 FILE_INFO object or NULL in case no match was found.
**/
function getFile($filePath, $rootDir, $args, &$status)
{
if (file_exists($filePath)) {
$files = array();
$uri = parsePath($filePath, $rootDir);
$fileInfo = fileToStruct($uri->dirPath, $rootDir, $uri->filename, $args);
if (!fileFilter($fileInfo, $args)) {
if (property_exists($fileInfo, "directory")) {
$fileInfo->children = getDirectory($filePath, $rootDir, $args, $status);
$fileInfo->_EX = true;
}
// Don't give out details about the root directory.
if ($filePath === $rootDir) {
$fileInfo->name = ".";
$fileInfo->size = 0;
}
$files[] = $fileInfo;
}
$status = $files ? HTTP_V_OK : HTTP_V_NO_CONTENT;
return $files;
}
$status = HTTP_V_NOT_FOUND;
return null;
}
示例12: playAllMusic
function playAllMusic($directory)
{
mountNetworkShare($directory);
$files = getDirectory($directory);
if ($fp = fopen('/tmp/runmono.jsp', 'w')) {
while (list(, $file) = each($files['files'])) {
if ($file['icon'] == 'audio') {
fwrite($fp, $file['name'] . "|0|0|file://" . $file['path'] . "|\n");
}
}
fclose($fp);
}
$file = '/tmp/runmono.jsp';
$options = "pod='2,,'";
if ($fp = fopen('/tmp/runmono.html', 'w')) {
fwrite($fp, "<body bgcolor=black link=black onloadset='go'>");
fwrite($fp, "<a onfocusload name='go' href='file://{$file}' {$options}></a>");
fwrite($fp, "<a href='http://127.0.0.1:8883/start.cgi?list' tvid='home'></a>");
fwrite($fp, "<a href='http://127.0.0.1:8883/start.cgi?list' tvid='source'></a>");
fwrite($fp, "<br><font size='6' color='#ffffff'><b>Press Return on your remote to go back to your previous location</b></font>");
fclose($fp);
}
exec("echo 212 > /tmp/irkey");
exec("sleep 2");
exec("killall amp_test");
exec("killall mono");
exec("killall pod");
exec("echo /tmp/runmono.html > /tmp/gaya_bc");
}
示例13: getConfig
function getConfig($xml = "")
{
global $_CONFIG, $CONFIG, $INTERNAL;
$skeys = array("gl_db_host", "gl_db_user", "gl_db_pass", "gl_db_name");
$hashfile = FILE_CONFIG;
$ms = base64_decode($_CONFIG["gl_lzst"]) == 1;
$cindex = 0;
$cfiles = getDirectory(PATH_CONFIG, "config.inc.php");
foreach ($_CONFIG as $index => $server_val) {
if (is_array($server_val)) {
$xml .= "<conf key=\"" . base64_encode($index) . "\">\r\n";
foreach ($server_val as $skey => $sval) {
if (!is_array($sval)) {
$xml .= "<sub key=\"" . base64_encode($skey) . "\">" . $sval . "</sub>\r\n";
}
}
$xml .= "</conf>\r\n";
} else {
if (!(is_int($index) && is_array($server_val))) {
$xml .= "<conf value=\"" . $server_val . "\" key=\"" . base64_encode($index) . "\" />\r\n";
}
}
}
if (!empty($CONFIG["gl_root"])) {
$cfiles = array_merge(array("config.inc.php"), $cfiles);
}
$rootBased = $CONFIG["gl_root"];
foreach ($cfiles as $file) {
if (substr($file, 0, 7) == "config." && strpos($file, ".inc.php") == strlen($file) - 8) {
$chost = str_replace("inc.php", "", str_replace("config.", "", $file));
$chost = strlen($chost) > 0 ? substr($chost, 0, strlen($chost) - 1) : $chost;
if (!$ms || (empty($_GET["ws"]) && strtolower($_SERVER["HTTP_HOST"]) == strtolower($chost) || empty($chost) && strtolower($_SERVER["HTTP_HOST"]) == strtolower($CONFIG["gl_host"]) || !empty($_GET["ws"]) && base64_decode($_GET["ws"]) == $chost || !empty($rootBased) && SERVERSETUP && !MANAGEMENT || in_array($chost, $INTERNAL[CALLER_SYSTEM_ID]->WebsitesConfig) || in_array($chost, $INTERNAL[CALLER_SYSTEM_ID]->WebsitesUsers))) {
if (!empty($chost) && file_exists(str_replace("config.inc", "config." . $chost . ".inc", FILE_CONFIG))) {
$hashfile = str_replace("config.inc", "config." . $chost . ".inc", FILE_CONFIG);
requireDynamic($hashfile, LIVEZILLA_PATH . "_config/");
loadConfig(false);
initDataProvider();
}
foreach ($_CONFIG as $index => $server_val) {
if (is_int($index) && is_array($server_val)) {
$xml .= "<site index=\"" . base64_encode($cindex) . "\">\r\n";
foreach ($server_val as $key => $site_val) {
if (is_array($site_val)) {
$xml .= "<conf key=\"" . base64_encode($key) . "\">\r\n";
foreach ($site_val as $skey => $sval) {
$xml .= "<sub key=\"" . base64_encode($skey) . "\">" . $sval . "</sub>\r\n";
}
$xml .= "</conf>\r\n";
} else {
if (!in_array($key, $skeys) || SERVERSETUP) {
$xml .= "<conf value=\"" . $site_val . "\" key=\"" . base64_encode($key) . "\" />\r\n";
} else {
$xml .= "<conf value=\"" . base64_encode("") . "\" key=\"" . base64_encode($key) . "\" />\r\n";
}
}
}
$cindex++;
if ($CONFIG["gl_host"] == base64_decode($server_val["gl_host"])) {
$xml .= "<db_conf>\r\n";
if (!empty($CONFIG["db"]["cct"])) {
$xml .= "<cct>\r\n";
foreach ($CONFIG["db"]["cct"] as $cct) {
$xml .= $cct->GetXML();
}
$xml .= "</cct>\r\n";
}
if (!empty($CONFIG["db"]["ccpp"])) {
$xml .= "<ccpp>\r\n";
foreach ($CONFIG["db"]["ccpp"] as $ccpp) {
$xml .= $ccpp->GetXML();
}
$xml .= "</ccpp>\r\n";
}
if (!empty($CONFIG["db"]["gl_email"])) {
$xml .= "<gl_email>\r\n";
foreach ($CONFIG["db"]["gl_email"] as $mb) {
$xml .= $mb->GetXML();
}
$xml .= "</gl_email>\r\n";
}
$xml .= "</db_conf>\r\n";
}
$xml .= "</site>\r\n";
}
}
}
}
}
if (SERVERSETUP) {
$xml .= "<translations>\r\n";
$files = getDirectory("./_language", "index", true);
foreach ($files as $translation) {
if (strpos($translation, ".bak.") === false) {
$lang = str_replace(".php", "", str_replace("lang", "", $translation));
$parts = explode(".", $lang);
if (ISSUBSITE && strpos($translation, SUBSITEHOST) !== false || !ISSUBSITE && substr_count($translation, ".") == 1) {
$xml .= "<language key=\"" . base64_encode($parts[0]) . "\" blocked=\"" . base64_encode(@filesize("./_language/" . $translation) == 0 ? 1 : "0") . "\" />\r\n";
} else {
if (ISSUBSITE && strpos($translation, SUBSITEHOST) === false && !@file_exists(getLocalizationFileString($parts[0], false))) {
$xml .= "<language key=\"" . base64_encode($parts[0]) . "\" derived=\"" . base64_encode(1) . "\" />\r\n";
//.........这里部分代码省略.........
示例14: getDirectory
// $arguments = array();
//
// for ( $arg = reset( $args ); $arg !== false; $arg = next( $args ) ) {
//
// //// FIXME: This check will fail if started from a different directory
// if ( $arg === basename( __FILE__ ) ) {
// continue;
// }
//
// $arguments[] = $arg;
// }
//
// return $arguments;
}
/**
* @return string
*/
function getDirectory()
{
$directory = $GLOBALS['argv'][0];
if ($directory[0] !== DIRECTORY_SEPARATOR) {
$directory = $_SERVER['PWD'] . DIRECTORY_SEPARATOR . $directory;
}
$directory = dirname($directory);
return $directory;
}
$skinDirectory = dirname(getDirectory());
$config = isReadablePath("{$skinDirectory}/phpunit.xml.dist");
$mw = isReadablePath(dirname(dirname($skinDirectory)) . "/tests/phpunit/phpunit.php");
echo "php {$mw} -c {$config} " . implode(' ', addArguments($GLOBALS['argv']));
passthru("php {$mw} -c {$config} " . implode(' ', addArguments($GLOBALS['argv'])));
示例15: backupTool_settings
function backupTool_settings()
{
// set upload limits if server permits //
@ini_set('upload_max_filesize', '100M');
@ini_set('post_max_size', '105M');
@ini_set('memory_limit', '350M');
@ini_set('max_execution_time', '300');
// end of set //
$backupList = array();
// create backup dir if not present
if (!file_exists(getSystemRoot(RAZOR_ADMIN_FILENAME) . RAZOR_BACKUP_DIR)) {
mkdir(getSystemRoot(RAZOR_ADMIN_FILENAME) . RAZOR_BACKUP_DIR, 0755);
}
if (isset($_GET['backup']) && $_GET['backup']) {
$fileName = str_replace(array(',', "'", '"', '?', '/', '*', '(', ')', '@', '!', '&', '=', '<', '>'), '', $_POST['backupname']);
$errorMsg = backupTool_checkName($fileName);
if (!$errorMsg) {
// do backup //
$tempfileArray = array();
getDirectory($tempfileArray, getSystemRoot(RAZOR_ADMIN_FILENAME) . RAZOR_DATASTORE_DIR);
$zipfilename = $fileName . '.zip';
// form is posted, handle it
$zipfile = new zipfile();
// new stuff //
foreach ($tempfileArray as $file) {
$f_tmp = @fopen($file, 'r');
if ($f_tmp) {
$dump_buffer = fread($f_tmp, filesize($file));
$tempFile = explode('../', $file);
$zipfile->addFile($dump_buffer, $tempFile[1]);
fclose($f_tmp);
}
}
// new stuff //
$dump_buffer = $zipfile->file();
// write the file to disk //
if (put2file(RAZOR_BACKUP_DIR . $zipfilename, $dump_buffer, strlen($dump_buffer))) {
MsgBox(lt('Backup created'), 'greenbox');
} else {
MsgBox(lt('Error creating backup'), 'redbox');
}
} else {
MsgBox($errorMsg, 'redbox');
}
}
if (isset($_GET['restore']) && $_GET['restore'] && $_SESSION['adminType'] != 'user') {
set_time_limit(60);
// new - clean datastore first //
$cleanfileArray = array();
getDirectory($cleanfileArray, getSystemRoot(RAZOR_ADMIN_FILENAME) . RAZOR_DATASTORE_DIR);
foreach ($cleanfileArray as $file) {
if ($file != 'razor_data.txt') {
// try using the delete function here so this works with ftp mode too //
unlink($file);
// try using the delete function here so this works with ftp mode too //
}
}
$zip = new SimpleUnzip();
$filename = getSystemRoot(RAZOR_ADMIN_FILENAME) . RAZOR_BACKUP_DIR . $_GET['restore'];
$entries = $zip->ReadFile($filename);
$restoreMess = '';
$restoreOK = 'greenbox';
foreach ($entries as $entry) {
// check dir exists, if not create it //
if ($entry->Path != '' && !file_exists('../' . $entry->Path)) {
$splitPath = array();
$splitPath = explode('/', $entry->Path);
$checkPath = '..';
foreach ($splitPath as $pathBit) {
$checkPath .= '/' . $pathBit;
if (!file_exists($checkPath)) {
mkdir($checkPath, 0755);
}
}
}
// check end //
if (put2file($entry->Path . '/' . $entry->Name, $entry->Data)) {
$restoreMess .= lt('Restoring') . " {$entry->Name} <br />";
} else {
$restoreMess .= lt('error restoring') . " {$entry->Name} <br />";
$restoreOK = 'redbox';
}
}
MsgBox($restoreMess, $restoreOK);
}
if (isset($_GET['delete']) && $_GET['delete']) {
deleteFile(RAZOR_BACKUP_DIR . $_GET['delete']);
}
if (isset($_GET['upload']) && $_GET['upload'] && isset($_POST['upload']) && $_SESSION['adminType'] != 'user') {
$filename = basename($_FILES['file-upload']['name']);
$stripFileName = explode('.', $filename);
if (end($stripFileName) == 'zip') {
$backupDir = getSystemRoot(RAZOR_ADMIN_FILENAME) . RAZOR_BACKUP_DIR;
$backupFiles = readDirContents($backupDir);
$counter = 0;
while (in_array($filename, $backupFiles)) {
$counter++;
$filename = $stripFileName[0] . '(' . $counter . ')' . '.' . $stripFileName[1];
}
$result = uploadFile(RAZOR_BACKUP_DIR . $filename, $_FILES['file-upload']['tmp_name']);
//.........这里部分代码省略.........