/**
 * Get an array that represents directory tree
 * 
 * from http://php.net/manual/en/function.scandir.php
 * @param string $directory     Directory path
 * @param bool $recursive         Include sub directories
 * @param bool $listDirs         Include directories on listing
 * @param bool $listFiles         Include files on listing
 * @param regex $exclude         Exclude paths that matches this regex
 */
function directoryToArray($directory, $recursive = true, $listDirs = false, $listFiles = true, $exclude = '')
{
    $arrayItems = array();
    $skipByExclude = false;
    $handle = opendir($directory);
    if ($handle) {
        while (false !== ($file = readdir($handle))) {
            preg_match("/(^(([\\.]){1,2})\$|(\\.(svn|git|md))|(Thumbs\\.db|\\.DS_STORE))\$/iu", $file, $skip);
            if ($exclude) {
                preg_match($exclude, $file, $skipByExclude);
            }
            if (!$skip && !$skipByExclude) {
                if (is_dir($directory . DIRECTORY_SEPARATOR . $file)) {
                    if ($recursive) {
                        $arrayItems = array_merge($arrayItems, directoryToArray($directory . DIRECTORY_SEPARATOR . $file, $recursive, $listDirs, $listFiles, $exclude));
                    }
                    if ($listDirs) {
                        $file = $directory . DIRECTORY_SEPARATOR . $file;
                        $arrayItems[] = $file;
                    }
                } else {
                    if ($listFiles) {
                        $file = $directory . DIRECTORY_SEPARATOR . $file;
                        $arrayItems[] = $file;
                    }
                }
            }
        }
        closedir($handle);
    }
    return $arrayItems;
}
Exemplo n.º 2
0
function tt_add_jscss()
{
    if (!is_admin()) {
        wp_deregister_script('jquery');
    }
    if (defined('WPCF7_VERSION')) {
        wp_deregister_style('contact-form-7');
    }
    if (defined('QTX_VERSION')) {
        wp_deregister_style('qtranslate-style');
    }
    if (defined('GOOGLEMAPS')) {
        wp_enqueue_script('googlemaps', '//maps.googleapis.com/maps/api/js?v=3.exp&language=en&key=AIzaSyAO77hGcvxmsvOn1RSjDFQMI4YUnW89MDo', false, null, false);
    }
    wp_enqueue_script('jquery', get_stylesheet_directory_uri() . '/js/libs/_jquery.js', false, null, false);
    if ($js_lib = directoryToArray(get_stylesheet_directory(), '/js/libs/', array('js'))) {
        foreach ($js_lib as $name => $js) {
            wp_enqueue_script($name, $js, array('jquery'), null, true);
        }
    }
    wp_enqueue_script('libs', get_stylesheet_directory_uri() . '/js/lib.js', array('jquery'), null, true);
    wp_enqueue_script('logic', get_stylesheet_directory_uri() . '/js/logic.js', array('libs'), null, true);
    wp_enqueue_style('libs', get_stylesheet_directory_uri() . '/style/elements/libs.css');
    wp_enqueue_style('scss', get_stylesheet_directory_uri() . '/style/style.css');
    if (class_exists('Woocommerce')) {
        wp_enqueue_style('custom-woo', get_stylesheet_directory_uri() . '/style/woo.css');
    }
}
Exemplo n.º 3
0
function tt_add_jscss()
{
    if (!is_admin()) {
        wp_deregister_script('jquery');
    }
    if (defined('WPCF7_VERSION')) {
        wp_deregister_style('contact-form-7');
    }
    if (defined('QTX_VERSION')) {
        wp_deregister_style('qtranslate-style');
    }
    if (defined('GOOGLEMAPS')) {
        wp_enqueue_script('googlemaps', '//maps.googleapis.com/maps/api/js?key=' . GOOGLEMAPS, false, null, false);
    }
    wp_enqueue_script('jquery', get_stylesheet_directory_uri() . '/js/libs/_jquery.js', false, null, false);
    if ($js_lib = directoryToArray(get_stylesheet_directory(), '/js/libs/', array('js'))) {
        foreach ($js_lib as $name => $js) {
            wp_enqueue_script($name, $js, array('jquery'), null, true);
        }
    }
    wp_enqueue_script('libs', get_stylesheet_directory_uri() . '/js/lib.js', array('jquery'), null, true);
    wp_enqueue_script('init', get_stylesheet_directory_uri() . '/js/init.js', array('libs'), null, true);
    if ($style_lib = directoryToArray(get_stylesheet_directory(), '/style/libs/', array('css', 'scss'))) {
        foreach ($style_lib as $name => $lib) {
            wp_enqueue_style($name, $lib);
        }
    }
    wp_enqueue_style('main', get_stylesheet_directory_uri() . '/style/style.scss');
    if (class_exists('Woocommerce')) {
        wp_enqueue_style('custom-woo-styles', get_stylesheet_directory_uri() . '/style/woo.scss');
        wp_enqueue_script('custom-woo-scripts', get_stylesheet_directory_uri() . '/js/woo.js', false, null, true);
    }
    wp_enqueue_style('responsive', get_stylesheet_directory_uri() . '/style/rwd.scss');
}
Exemplo n.º 4
0
function directoryToArray($directory, $onlyFiles = false, $originalDirectory = '', $recursive = true)
{
    $originalDirectory = $originalDirectory == '' ? $directory : $originalDirectory;
    $array_items = array();
    if ($handle = opendir($directory)) {
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != "..") {
                if (is_dir($directory . "/" . $file)) {
                    if ($recursive) {
                        $array_items = array_merge($array_items, directoryToArray($directory . "/" . $file, $onlyFiles, $originalDirectory, $recursive));
                    }
                    //$file = $directory . "/" . $file;
                    if (!$onlyFiles) {
                        $file = str_replace($originalDirectory, '', $directory) . "/" . $file;
                        $array_items[] = preg_replace("/\\/\\//si", "/", $file);
                    }
                } else {
                    //$file = $directory . "/" . $file;
                    $file = str_replace($originalDirectory, '', $directory) . "/" . $file;
                    $array_items[] = preg_replace("/\\/\\//si", "/", $file);
                }
            }
        }
        closedir($handle);
    }
    return $array_items;
}
Exemplo n.º 5
0
function directoryToArray($directory, $recursive, $inspector, $folder_nou)
{
    $array_items = array();
    if ($handle = opendir($directory)) {
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != "..") {
                if (is_dir($directory . "/" . $file)) {
                    if ($recursive) {
                        $array_items = array_merge($array_items, directoryToArray($directory . "/" . $file, $recursive, $inspector, $folder_nou));
                    }
                } else {
                    $file = $directory . "/" . $file;
                    $file = preg_replace("/\\/\\//si", "/", $file);
                    $size = filesize($file) / 1024;
                    $play = getAudioFilePlayTime($inspector, $file);
                    rename($file, $folder_nou . basename($file));
                    $file = str_replace("/home1/tineretp/www", "http://74.220.207.111/~tineretp/", $file);
                    $array_items[] = array("path" => $file, "size" => $size, "play_time" => $play);
                }
            }
        }
        closedir($handle);
    }
    return $array_items;
}
Exemplo n.º 6
0
function get_templates()
{
    $tpldir_array = array();
    $tpldir_path = SITE_ROOT . 'template';
    $tpldir_array = directoryToArray($tpldir_path, false, true, false);
    foreach ($tpldir_array as $key => $value) {
        $tpldir_array[$key] = str_ireplace($tpldir_path, '', $value);
        $tpldir_array[$key] = str_ireplace(array('\\', '/'), '', $tpldir_array[$key]);
    }
    return $tpldir_array;
}
Exemplo n.º 7
0
function directoryToArray($directory, $extension = "", $full_path = true)
{
    $array_items = array();
    if ($handle = opendir($directory)) {
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != "..") {
                if (is_dir($directory . "/" . $file)) {
                    $array_items = array_merge($array_items, directoryToArray($directory . "/" . $file, $extension, $full_path));
                } else {
                    if (!$extension || ereg("." . $extension, $file)) {
                        $array_items[] = $file;
                    }
                }
            }
        }
        closedir($handle);
    }
    return $array_items;
}
Exemplo n.º 8
0
function directoryToArray($directory, $recursive)
{
    $array_items = array();
    if ($handle = opendir($directory)) {
        while (false !== ($file = readdir($handle))) {
            if ($file != '.' && $file != '..' && $file != 'Thumbs.db' && $file != 'error_log') {
                if (is_dir($directory . '/' . $file)) {
                    if ($recursive) {
                        $array_items = array_merge($array_items, directoryToArray($directory . '/' . $file, $recursive));
                    }
                } else {
                    $file = $directory . '/' . $file;
                    $array_items[] = preg_replace('/\\/\\//si', '/', $file);
                }
            }
        }
        closedir($handle);
    }
    return $array_items;
}
Exemplo n.º 9
0
function directoryToArray($directory, $recursive)
{
    $array_items = array();
    if ($handle = opendir($directory)) {
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != "..") {
                if (is_dir($directory . "/" . $file)) {
                    if ($recursive) {
                        $array_items = array_merge($array_items, directoryToArray($directory . "/" . $file, $recursive));
                    }
                    $file = $directory . "/" . $file;
                    $array_items[] = preg_replace("/\\/\\//si", "/", $file);
                } else {
                    $file = $directory . "/" . $file;
                    $array_items[] = preg_replace("/\\/\\//si", "/", $file);
                }
            }
        }
        closedir($handle);
    }
    return $array_items;
}
Exemplo n.º 10
0
function get_static_db_file_from_storage ($db_file_name) {
		
		global $db_storage_folder;
		global $read_only_folder;
		global $tempfs_work_folder;
		global $static_db_file_pattern;
		
		$valid_db_file = null;
			// get file list from Storage location.
		$db_file_list = directoryToArray($db_storage_folder,false,false,true,$static_db_file_pattern);

		// sort the list so that the newest files come first
		arsort ($db_file_list);

		// try to open files in starting with the newest. If a valid db file is found then it is used. 
		foreach ($db_file_list as $file) {
			if (verify_sqlite_file($file)) // file found
				{
				//error_log  ( "This file is good! <br />");
				$valid_db_file = $file;
				break;
				}
			
			// try to open file
		}

		// valid DB file found? Yes- nice; No - Take from Read Only storage.
		if ($valid_db_file == null) $valid_db_file = $read_only_folder . $db_file_name;

		error_log ("using file " . $valid_db_file);

		// copy file to tempfs
		if (!copy($valid_db_file, $tempfs_work_folder . $db_file_name )) {
			error_log ( "failed to copy $file...\n");
		}

}
function checkEventFilesForKey($keyCheckString)
{
    global $eventDirectory;
    $keyExist = false;
    $eventFiles = array();
    $eventFiles = directoryToArray($eventDirectory, false);
    foreach ($eventFiles as $eventFile) {
        if (strpos(file_get_contents($eventFile), $keyCheckString) !== false) {
            // do stuff
            $keyExist = true;
            break;
            // return $keyExist;
        }
    }
    return $keyExist;
}
Exemplo n.º 12
0
/**
 * get array of thumbnails and info
 * @param  string  $upload_path the upload sub path
 * @param  string  $type        optional thumbnail type eg thumbsm, thumbnail to filter by
 * @param  string  $filename    optional filename to filter
 * @param  boolean $recurse     optional true: recurse into subdirectories
 * @return array                assoc array with thumbnail attributes
 */
function getThumbnails($upload_path = '', $type = '', $filename = '', $recurse = false)
{
    $thumbs_array = array();
    $files = directoryToArray(GSTHUMBNAILPATH . tsl($upload_path), $recurse);
    foreach ($files as $file) {
        $split = strpos(basename($file), '.');
        $thumbtype = substr(basename($file), 0, $split);
        $origfile = substr(basename($file), $split + 1);
        if (!empty($filename) && $filename !== $origfile) {
            continue;
        }
        if (empty($thumbtype) || !empty($type) && $type !== $thumbtype) {
            continue;
        }
        // debugLog('thumbnail ' . $file);
        $thumb = getimagesize($file);
        $thumb['width'] = $thumb[0];
        unset($thumb[0]);
        $thumb['height'] = $thumb[1];
        unset($thumb[1]);
        $thumb['type'] = $thumb[2];
        unset($thumb[2]);
        $thumb['attrib'] = $thumb[3];
        unset($thumb[3]);
        $thumb['uploadpath'] = tsl(getRelPath($upload_path, GSTHUMBNAILPATH));
        $thumb['primaryfile'] = GSDATAUPLOADPATH . $thumb['uploadpath'] . $origfile;
        $thumb['filesize'] = filesize($file);
        $thumb['primaryurl'] = getUploadURI($origfile, $thumb['uploadpath']);
        $thumb['thumbfile'] = getThumbnailFile(basename($file), $upload_path, '');
        $thumb['thumburl'] = getThumbnailURI(basename($file), $upload_path, '');
        $thumb['thumbtype'] = $thumbtype;
        $thumbs_array[$upload_path . basename($file)] = $thumb;
    }
    return $thumbs_array;
}
Exemplo n.º 13
0
<?php

require 'lib/bk_zip.php';
/* include zip lib */
require 'lib/bk_db.php';
/*include export code lib*/
$name_zip_file .= date("j-n-Y");
/* get date now  */
$name_zip_file .= '-user.zip';
$files_to_zip = directoryToArray('../public_html', true);
/*Export DB*/
backup_tables('db_host', 'user_db', 'user_db_pass', 'db_name');
/*Zip file*/
$result = create_zip($files_to_zip, $name_zip_file);
/*Transfer file via FTP */
$server = 'IP FTP';
$ftp_user_name = "Username FTP";
$ftp_user_pass = "******";
$connection = ftp_connect($server);
$login = ftp_login($connection, $ftp_user_name, $ftp_user_pass);
if (!$connection || !$login) {
    die('Connection attempt failed!');
}
$upload = ftp_put($connection, $name_zip_file, $name_zip_file, FTP_ASCII);
if (!$upload) {
    echo 'FTP upload failed!';
}
ftp_close($connection);
/*Delete file zip and sql after backup*/
$files_db = glob("*.sql");
foreach ($files_db as $file_db) {
	<link rel="alternate" type="application/rss+xml" title="<?php 
echo $config['team'];
?>
 Releases RSS Feed" href="rss.xml" />
	<link rel="shortcut icon" href="design/favicon.ico" />
	<title><?php 
echo $config['team'];
?>
 Release Portal</title>
</head>
<body>
	<div id="contentwrapper">
	
		<div id="banner">
		<?php 
$bannersListe = directoryToArray('design/banners');
//Récupère la liste des bannières
$rand = mt_rand(0, count($bannersListe) - 1);
//Choisir une bannière au hasard
echo '<img src="', $bannersListe[$rand], '" alt="banniere" />';
unset($bannersListe, $rand);
?>
</div>
		
		<div id="menu">
			<ul>
				<li><a href="index.php?crk=releases&spg=1">[ Latest Releases ]</a></li>
				<li><a href="index.php?crk=search">[ Search Database ]</a></li>
				<li><a href="index.php?crk=about">[ About <?php 
echo $config['accro'];
?>
Exemplo n.º 15
0
function createTemplateDropdown()
{
    global $template;
    # create themes dropdown
    $theme_options = '<select name="theme-folder" id="theme-folder" >';
    $templates = directoryToArray(GSTHEMESPATH, false);
    $theme_dir_array = array();
    foreach ($templates as $file) {
        if (is_dir($file)) {
            // only a theme if GSTEMPLATEFILE  (template.php) exists
            if (file_exists($file . '/' . GSTEMPLATEFILE)) {
                $sel = "";
                $theme_dir_array[] = $file;
                $theme = basename($file);
                if ($template == $theme) {
                    $sel = "selected";
                }
                $theme_options .= '<option ' . $sel . ' value="' . $theme . '" >' . $theme . '</option>';
            }
        }
    }
    // edit theme/root files
    if (getDef('GSTHEMEEDITROOT', true)) {
        $theme_options .= '<option value="." style="font-style:italic">' . i18n_r('THEME_ROOT') . '</option>';
    }
    $theme_options .= '</select> ';
    # check to see how many themes are available
    if (count($theme_dir_array) == 1) {
        $theme_options = '';
    }
    return $theme_options;
}
Exemplo n.º 16
0
</tr>
</table>
</div>

<div class="item">
<table cellpadding="10" cellspacing="10" border="0" width="100%">
<tr>
<td width="10%">&nbsp;</td>
<td width="80%">
<p><h1>Available photos</h1></p>
<table cellpadding="5" cellspacing="5" border="0" align="center" valign="top">

<form action="photoupload.php" method="post" enctype="multipart/form-data">
<?php 
$path = "/var/www/anymeal/photos";
$jpgs = directoryToArray($path);
$i = 0;
foreach ($jpgs as $jpeg) {
    if ($i % 4 == 0) {
        echo "<tr>";
    }
    echo '<td width="33%" align="center" valign="middle">';
    print '<p><a href="photos/' . $jpeg . '"><img src="photos/' . $jpeg . '" width="90" border="0" alt=""></a><br>';
    print '<input type="checkbox" name="deletecandidates[]" value="' . $jpeg . '">' . $jpeg . '</p>';
    echo "</td>";
    if (($i + 1) % 4 == 0) {
        echo "</tr>";
    }
    $i = $i + 1;
}
/* foreach */
function printFontsInstalled($ELEMENT, $FONT)
{
    global $DEBUG, $PLUGINS, $pluginDirectory;
    $fontsDirectory = "/usr/share/fonts/truetype/";
    //$FONTS_LIST_CMD = "/usr/bin/fc-list";
    //$FONT_LIST = system($FONTS_LIST_CMD);
    //if($DEBUG)
    //	print_r($FONT_LIST);
    $FONTS_INSTALLED = directoryToArray($fontsDirectory, true);
    //, $recursive)($pluginDirectory);
    //print_r($PLUGINS_READ);
    echo "<select name=\"" . $ELEMENT . "\">";
    for ($i = 0; $i <= count($FONTS_INSTALLED) - 1; $i++) {
        $FONTINFO = pathinfo($FONTS_INSTALLED[$i]);
        $FONTS_INSTALLED_TEMP = basename($FONTS_INSTALLED[$i], '.' . $FONTINFO['extension']);
        if ($FONTS_INSTALLED_TEMP == $FONT) {
            echo "<option selected value=\"" . $FONTS_INSTALLED_TEMP . "\">" . $FONTS_INSTALLED_TEMP . "</option>";
        } else {
            echo "<option value=\"" . $FONTS_INSTALLED_TEMP . "\">" . $FONTS_INSTALLED_TEMP . "</option>";
        }
    }
    echo "</select>";
}
Exemplo n.º 18
0
function search($terms)
{
    // TODO: add metadata description search too.
    global $thumbnailPrefix, $database;
    $terms = mysql_escape_string($terms);
    $terms = explode(' ', $terms);
    logAction('search', $terms);
    jsonStart();
    $results = 0;
    // Get all virt. dirs
    $query = "select * from {$GLOBALS['tablePrefix']}clients";
    $response = mysql_query($query, $database);
    // Add virt. dir paths to an array
    $dirs = array();
    while ($client = mysql_fetch_assoc($response)) {
        $folder = $client['path'] . '/' . $client['name'];
        // Only provide virtual dirs we have access to.
        if (permForPath($folder, 'read')) {
            $dirs[] = $folder;
        }
    }
    // Remove any nested virt. directories
    $conDirs = condensePathsArray($dirs);
    // Each virt. directory
    foreach ($conDirs as $folder) {
        // For every file in virt. dir
        $filestructure = directoryToArray($folder, true);
        foreach ($filestructure as $item) {
            $name = $item['name'];
            $type = $item['type'];
            $path = $item['path'];
            $image = false;
            // Check if any of the terms fall into the file name
            $present = false;
            foreach ($terms as $term) {
                $pos = strpos(strtolower($name), strtolower($term));
                if ($pos !== false) {
                    $present = true;
                }
            }
            // Check if file is hidden (.*)
            $hidden = false;
            if (startsWith($name, '.') || startsWith($name, $thumbnailPrefix)) {
                $hidden = true;
            }
            // Add files to JSON
            if ($present && !$hidden) {
                $id = $path . '/' . $name;
                $id = str_replace("/", "_", $id);
                $id = str_replace(".", "_", $id);
                $metadata = getMeta($path, $name, $id, true);
                $image = $metadata['image'] == 1 ? true : false;
                $date = $metadata['date'];
                $description = $metadata['description'];
                $flags = $metadata['flags'] == '' ? 'normal' : $metadata['flags'];
                jsonAdd("\"rank\":\"{$results}\",\"image\": \"{$image}\",\"type\": \"{$type}\", \"path\": \"{$path}\",\"description\": \"{$description}\",\"name\": \"{$name}\",\"date\":\"{$date}\", \"id\": \"{$id}\",\"flags\": \"{$flags}\" ");
                $results++;
            }
        }
    }
    if ($results > 0) {
        echo jsonReturn('search');
    }
}
Exemplo n.º 19
0
function get_language_array()
{
    $return_array = array();
    $path = SITE_ROOT . 'source/language/';
    $return_array = directoryToArray($path, false, true, false);
    foreach ($return_array as $key => $value) {
        $return_array[$key] = str_replace(array($path, '/', '\\'), '', $value);
    }
    return $return_array;
}
Exemplo n.º 20
0
        $theme_dir_array[] = $file;
        $sel = "";
        if (file_exists($curpath . '/template.php')) {
            if ($template == $file) {
                $sel = "selected";
            }
            $theme_options .= '<option ' . $sel . ' value="' . $file . '" >' . $file . '</option>';
        }
    }
}
$theme_options .= '</select> ';
# check to see how many themes are available
if (count($theme_dir_array) == 1) {
    $theme_options = '';
}
$templates = directoryToArray(GSTHEMESPATH . $template . '/', true);
$theme_templates .= '<span id="themefiles"><select class="text" id="theme_files" style="width:425px;" name="f" >';
$allowed_extensions = array('php', 'css', 'js', 'html', 'htm');
foreach ($templates as $file) {
    $extension = pathinfo($file, PATHINFO_EXTENSION);
    if (in_array($extension, $allowed_extensions)) {
        $filename = pathinfo($file, PATHINFO_BASENAME);
        $filenamefull = substr(strstr($file, '/theme/' . $template . '/'), strlen('/theme/' . $template . '/'));
        if ($template_file == $filenamefull) {
            $sel = "selected";
        } else {
            $sel = "";
        }
        if ($filename == 'template.php') {
            $templatename = i18n_r('DEFAULT_TEMPLATE');
        } else {
             set_time_limit(0);
             $fileContents = file_get_contents(BASE_PATH . '/' . $dir);
             if (false === $createZip->addFile($fileContents, $basename)) {
                 throw new FbX($ccms['lang']['system']['error_write'] . ": " . $fileName);
             }
         }
     }
 } else {
     if ($scantype != 'file') {
         $basename .= substr($basename, -1, 1) != '/' ? '/' : '';
         $file_collection[] = array('dir' => $basename);
         log_current_backup_state($progressfile, $file_collection);
         if (0) {
             $createZip->addDirectory($basename);
         }
         $files = directoryToArray(BASE_PATH . '/' . $dir, $scantype == 'tree', $regex_to_match);
         /*
          * opendir+readdir deliver the file set in arbitrary order.
          *
          * In order for this code to work, we'll need a known order of the files.
          */
         sort($files, SORT_STRING);
         foreach ($files as $file) {
             $zipPath = explode(BASE_PATH . '/' . $dir, $file, 2);
             $zipPath = $zipPath[1];
             if (is_dir($file)) {
                 $file_collection[] = array('dir' => $basename . $zipPath);
                 log_current_backup_state($progressfile, $file_collection);
                 if (0) {
                     $createZip->addDirectory($basename . $zipPath);
                 }
                $sel = "selected";
            }
            $theme_options .= '<option ' . $sel . ' value="' . $file . '" >' . $file . '</option>';
        }
    }
}
$theme_options .= '</select> ';
# check to see how many themes are available
if (count($theme_dir_array) == 1) {
    $theme_options = '';
}
# if no template is selected, use the default
if ($template == '') {
    $template = 'template.php';
}
$templates = directoryToArray(GSTHEMESPATH . $TEMPLATE . '/', true);
$theme_templates .= '<span id="themefiles"><select class="text" id="theme_files" style="width:425px;" name="f" >';
$allowed_extensions = array('php', 'css', 'js', 'html', 'htm');
foreach ($templates as $file) {
    $extension = pathinfo($file, PATHINFO_EXTENSION);
    if (in_array($extension, $allowed_extensions)) {
        $filename = pathinfo($file, PATHINFO_BASENAME);
        $filenamefull = substr(strstr($file, '/theme/' . $TEMPLATE . '/'), strlen('/theme/' . $TEMPLATE . '/'));
        if ($TEMPLATE_FILE == $filenamefull) {
            $sel = "selected";
        } else {
            $sel = "";
        }
        if ($filename == 'template.php') {
            $templatename = i18n_r('DEFAULT_TEMPLATE');
        } else {
Exemplo n.º 23
0
                "navTabId":"",
                "rel":"",
                "callbackType":"forward",
                "forwardUrl":"admin.php?mod=backup&action=index",
                "confirmMsg":""
            }';
        }
        break;
    default:
        //DEBUG 查询并返回信息链接
        $page_array = array();
        $backup_dir = SITE_ROOT . './data/backup';
        $backup_dir_array = directoryToArray($backup_dir, false, true, FALSE);
        foreach ($backup_dir_array as $key => $value) {
            $backup_id = substr($value, -1);
            $page_array[$backup_id]['path'] = str_replace(SITE_ROOT, '', $value . DIRECTORY_SEPARATOR);
            $tmp_array = directoryToArray($value, false, false, true);
            if ($issqlfile) {
                $sql_backup_file = $tmp_array[0];
                $www_backup_file = $tmp_array[1];
            } else {
                $sql_backup_file = $tmp_array[1];
                $www_backup_file = $tmp_array[0];
            }
            $page_array[$backup_id]['files_sql'] = str_replace($value . DIRECTORY_SEPARATOR, '', $sql_backup_file);
            $page_array[$backup_id]['files_www'] = str_replace($value . DIRECTORY_SEPARATOR, '', $www_backup_file);
        }
        ksort($page_array);
        include template('admin/backup/list');
        break;
}
Exemplo n.º 24
0
function directoryToArray($directory, $recursive, $regex_to_match = null)
{
    $array_items = array();
    if ($handle = opendir($directory)) {
        if (substr($directory, -1, 1) != '/') {
            $directory .= '/';
        }
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != "..") {
                $path = $directory . $file;
                if (is_dir($path)) {
                    if ($recursive) {
                        $subarr = directoryToArray($path, $recursive, $regex_to_match);
                        // do not include empty subdirectories
                        if (count($subarr) > 0) {
                            $array_items = array_merge($array_items, array($path), $subarr);
                        }
                    }
                } else {
                    if (empty($regex_to_match) || preg_match($regex_to_match, $path)) {
                        $array_items[] = $path;
                    }
                }
            }
        }
        closedir($handle);
    }
    return $array_items;
}
Exemplo n.º 25
0
$configEmail = '';
// Include backup functions file
include 'includes/backup_functions.php';
$backupName = "backup-" . date('d-m-y') . '-' . date('H-i-s') . '.zip';
$createZip = new createZip();
if (isset($configBackup) && is_array($configBackup) && count($configBackup) > 0) {
    // Lets backup any files or folders if any
    foreach ($configBackup as $dir) {
        $basename = basename($dir);
        // dir basename
        if (is_file($dir)) {
            $fileContents = file_get_contents($dir);
            $createZip->addFile($fileContents, $basename);
        } else {
            $createZip->addDirectory($basename . "/");
            $files = directoryToArray($dir, true);
            $files = array_reverse($files);
            foreach ($files as $file) {
                $zipPath = explode($dir, $file);
                $zipPath = $zipPath[1];
                // skip any if required
                $skip = false;
                foreach ($configSkip as $skipObject) {
                    if (strpos($file, $skipObject) === 0) {
                        $skip = true;
                        break;
                    }
                }
                if ($skip) {
                    continue;
                }
Exemplo n.º 26
0
function directoryToArray($directory, $recursive)
{
    $me = basename($_SERVER['PHP_SELF']);
    $array_items = array();
    if ($handle = opendir($directory)) {
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != ".." && $file != $me && substr($file, 0, 1) != '.') {
                if (is_dir($directory . "/" . $file)) {
                    if ($recursive) {
                        $array_items = array_merge($array_items, directoryToArray($directory . "/" . $file, $recursive));
                    }
                } else {
                    $file = $directory . "/" . $file;
                    $array_items[] = preg_replace("/\\/\\//si", "/", $file);
                }
            }
        }
        closedir($handle);
        asort($array_items);
    }
    return $array_items;
}