Example #1
0
/**
 * Unzip the source_file in the destination dir
 *
 * @param   string      The path to the ZIP-file.
 * @param   string      The path where the zipfile should be unpacked, if false the directory of the zip-file is used
 * @param   boolean     Indicates if the files will be unpacked in a directory with the name of the zip-file (true) or not (false) (only if the destination directory is set to false!)
 * @param   boolean     Overwrite existing files (true) or not (false)
 *
 * @return  boolean     Succesful or not
 */
function unzip($src_file, $dest_dir = false, $create_zip_name_dir = true, $overwrite = true)
{
    if (!@function_exists('zip_open')) {
        return false;
    }
    if (!is_resource(zip_open($src_file))) {
        $src_file = dirname($_SERVER['SCRIPT_FILENAME']) . '/' . $src_file;
    }
    if (!is_resource($zip = zip_open($src_file))) {
        return false;
    }
    $splitter = $create_zip_name_dir === true ? '.' : '/';
    if ($dest_dir === false) {
        $dest_dir = substr($src_file, 0, strrpos($src_file, $splitter)) . '/';
    }
    // Create the directories to the destination dir if they don't already exist
    create_dirs($dest_dir);
    $response_folder = '';
    // For every file in the zip-packet
    while ($zip_entry = zip_read($zip)) {
        // Now we're going to create the directories in the destination directories
        // If the file is not in the root dir
        $pos_last_slash = strrpos(zip_entry_name($zip_entry), '/');
        if ($pos_last_slash !== false) {
            // Create the directory where the zip-entry should be saved (with a "/" at the end)
            $entry_folder = substr(zip_entry_name($zip_entry), 0, $pos_last_slash + 1);
            create_dirs($dest_dir . $entry_folder);
            if ($response_folder == '') {
                $response_folder = $entry_folder;
            }
        }
        // Open the entry
        if (zip_entry_open($zip, $zip_entry, 'r')) {
            // The name of the file to save on the disk
            $file_name = $dest_dir . zip_entry_name($zip_entry);
            // Check if the files should be overwritten or not
            if ($overwrite === true || $overwrite === false && !is_file($file_name)) {
                // Get the content of the zip entry
                $fstream = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
                if (!is_dir($file_name)) {
                    file_put_contents($file_name, $fstream);
                }
                // Set the rights
                if (file_exists($file_name)) {
                    chmod($file_name, 0777);
                }
            }
            // Close the entry
            zip_entry_close($zip_entry);
        }
    }
    // Close the zip-file
    zip_close($zip);
    return $response_folder;
}
Example #2
0
 public static function get_filename()
 {
     $dir = date('Y/m');
     $dir = self::$log_dir . '/' . $dir;
     create_dirs($dir);
     $filename = $dir . '/' . date('d') . '.log';
     if (!file_exists($filename)) {
         file_put_contents($filename, '');
     }
     return $filename;
 }
Example #3
0
function install()
{
    global $_plugin;
    global $success;
    global $error;
    global $errors;
    !plugin_is_installed($_plugin['name']) or $error = $errors['installed'];
    create_dirs($_plugin['dir']) or $error = $errors['create_dir'];
    set_as_installed() or $error = $errors['installing'];
    $success = $_plugin['name'] . ' was successfully installed';
}
Example #4
0
/**
 * Unzip the source_file in the destination dir
 *
 * @param   string      The path to the ZIP-file.
 * @param   string      The path where the zipfile should be unpacked, if false the directory of the zip-file is used
 * @param   boolean     Indicates if the files will be unpacked in a directory with the name of the zip-file (true) or not (false) (only if the destination directory is set to false!)
 * @param   boolean     Overwrite existing files (true) or not (false)
 *  
 * @return  boolean     Succesful or not
 */
function unzip($src_file, $dest_dir = false, $create_zip_name_dir = true, $overwrite = true)
{
    if ($zip = zip_open($src_file)) {
        if ($zip) {
            $splitter = $create_zip_name_dir === true ? "." : "/";
            if ($dest_dir === false) {
                $dest_dir = substr($src_file, 0, strrpos($src_file, $splitter)) . "/";
            }
            // Create the directories to the destination dir if they don't already exist
            create_dirs($dest_dir);
            // For every file in the zip-packet
            while ($zip_entry = zip_read($zip)) {
                // Now we're going to create the directories in the destination directories
                // If the file is not in the root dir
                $pos_last_slash = strrpos(zip_entry_name($zip_entry), "/");
                if ($pos_last_slash !== false) {
                    // Create the directory where the zip-entry should be saved (with a "/" at the end)
                    create_dirs($dest_dir . substr(zip_entry_name($zip_entry), 0, $pos_last_slash + 1));
                }
                // Open the entry
                if (zip_entry_open($zip, $zip_entry, "r")) {
                    // The name of the file to save on the disk
                    $file_name = $dest_dir . zip_entry_name($zip_entry);
                    // Check if the files should be overwritten or not
                    if ($overwrite === true || $overwrite === false && !is_file($file_name)) {
                        // Get the content of the zip entry
                        $fstream = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
                        if (!is_dir($file_name)) {
                            file_put_contents($file_name, $fstream);
                        }
                        // Set the rights
                        //chmod($file_name, 0755);
                    }
                    // Close the entry
                    zip_entry_close($zip_entry);
                }
            }
            // Close the zip-file
            zip_close($zip);
        }
    } else {
        return false;
    }
    return true;
}
Example #5
0
include_once 'lib/setup/twversion.class.php';
$TWV = new TWVersion();
$smarty->assign('tiki_version_name', preg_replace('/^(\\d+\\.\\d+)([^\\d])/', '\\1 \\2', $TWV->version));
// Available DB Servers
$dbservers = array();
if (function_exists('mysqli_connect')) {
    $dbservers['mysqli'] = tra('MySQL Improved (mysqli)');
}
if (function_exists('mysql_connect')) {
    $dbservers['mysql'] = tra('MySQL classic (mysql)');
}
$smarty->assignByRef('dbservers', $dbservers);
$errors = '';
check_session_save_path();
get_webserver_uid();
$errors .= create_dirs($multi);
if ($errors) {
    error_and_exit();
}
// Second check try to connect to the database
// if no local.php => no con
// if local then build dsn and try to connect
//   then get con or nocon
//adodb settings
if (!defined('ADODB_FORCE_NULLS')) {
    define('ADODB_FORCE_NULLS', 1);
}
if (!defined('ADODB_ASSOC_CASE')) {
    define('ADODB_ASSOC_CASE', 2);
}
if (!defined('ADODB_CASE_ASSOC')) {
function plugin_leedUpdateSourcePlugin()
{
    //récupération du fichier
    $lienMasterLeedPlugin = $_POST['plugin_leedUpdateSource_sourcePlugin'];
    echo $lienMasterLeedPlugin;
    create_dirs(Plugin::path() . 'upload/');
    $fichierCible = './' . Plugin::path() . 'upload/LeedMasterPlugin.zip';
    if (copy($lienMasterLeedPlugin, $fichierCible)) {
        echo '<h3>Opérations</h3>';
        echo 'Fichier <a href="' . $lienMasterLeedPlugin . '">' . $lienMasterLeedPlugin . '</a> téléchargé<br /><br />';
        $retour = unzip_leed($fichierCible, './plugins/', false, true);
        if ($retour) {
            echo '<b>Opération réalisée avec succès</b><br />';
        } else {
            echo '<b>Opération réalisée avec des erreurs</b>';
        }
    } else {
        echo 'récupération foireuse du fichier zip';
    }
    // si des plugins sont actifs, les fichiers enabled sont a remplacer par les fichiers disabled
    // parcourir tous les répertoires de plugins
    if ($retour) {
        $dir = './plugins/';
        $files = glob($dir . '*/*.plugin.disabled.php');
        foreach ($files as $value) {
            if (file_exists($value) && file_exists(str_replace('.plugin.disabled.php', '.plugin.enabled.php', $value))) {
                rename($value, str_replace('.plugin.disabled.php', '.plugin.enabled.php', $value));
                echo 'renomage du fichier : ' . $value . ' en ' . str_replace('.plugin.disabled.php', '.plugin.enabled.php', $value) . '<br />';
            }
        }
    }
    echo '<b>Toutes les opérations sont terminées. Vos plugins sont à jour</b>';
}
            mkdir($subdir);
        }
    }
}
/*
$num = 0;
$original_id = $image_id;
while(file_exists("$ll_owner_key/rendered/$image_id"))
{
	++$num;
	$image_id = "$original_id_$num";
}
*/
if ($is_ll) {
    if (isset($_REQUEST['image'])) {
        create_dirs($image_id);
    }
} else {
    return;
}
$cut_dir = "{$ll_owner_key}/{$image_id}/cuts";
$upload_dir = "{$ll_owner_key}/{$image_id}/uploads";
$render_dir = "{$ll_owner_key}/{$image_id}/rendered";
switch ($action) {
    case "upload-cut":
        upload_cut($cut_dir);
        break;
    case "upload-render":
        upload_render($upload_dir, $image_id);
        break;
    case "render-sculpt":
function main()
{
    $opts = parse_options();
    create_dirs($opts);
    $dbs = run('mysql ' . $opts['connection'] . ' -e "show databases" -B -N');
    $seconds = array('hourly' => 60 * 60, 'daily' => 60 * 60 * 24, 'weekly' => 60 * 60 * 24 * 7, 'monthly' => 60 * 60 * 24 * 30, 'yearly' => 60 * 60 * 24 * 365.25);
    $time = time();
    foreach ($dbs as $db) {
        $db = trim($db);
        if (array_search($db, $opts['exclude'])) {
            continue;
        }
        $old_file = false;
        foreach ($opts['keep'] as $name => $keep) {
            $dir = "{$opts['backup-dir']}/{$name}";
            $minutes = $seconds[$name];
            $files = run("ls -t {$dir} | grep '.{$db}.tar.gz'", true);
            if ($keep === -1 || empty($files) || $time - filemtime("{$dir}/{$files['0']}") >= $seconds[$name]) {
                $file = "{$dir}/" . strftime('%Y_%m_%d_%H:%M:%S') . "__{$db}.tar.gz";
                if (empty($old_file)) {
                    run("mysqldump {$opts['extra']} {$opts['connection']} {$db} | gzip -c > {$file}");
                    $old_file = $file;
                } else {
                    run("cp {$old_file} {$file}");
                    $file = $old_file;
                }
                ok("Created {$name} backup {$file}");
                if ($keep !== -1 && count($files) > $keep) {
                    run("rm {$dir}/" . array_pop($files));
                }
            }
        }
    }
    exit(0);
}
<?php

require_once 'mobi-config/web_constants.php';
if (is_dir(AUX_PATH)) {
    create_dirs(AUX_PATH, array('logs', 'tmp', 'pushd', 'maptiles'));
    create_dirs(AUX_PATH . '/pushd', array('apns_feedback', 'apns_push', 'emergency', 'my_stellar', 'shuttle'));
    create_dirs(AUX_PATH . '/maptiles', array('raw', 'crushed'));
    // create the symlink that exposes maptiles to outside http requests
    if (is_link('mobi-web/api/map/tile')) {
        unlink('mobi-web/api/map/tile');
    }
    symlink(AUX_PATH . '/maptiles/crushed', 'mobi-web/api/map/tile');
} else {
    echo AUX_PATH . " does not yet exist, this directory needs to be created with the same permissions as webserver";
}
function create_dir($path)
{
    if (file_exists($path)) {
        if (!is_dir($path)) {
            throw new Exception("{$path} already exists AND is not a directory, it needs to be a directory");
        }
    } else {
        mkdir($path);
    }
}
function create_dirs($base, $dirs)
{
    foreach ($dirs as $dir) {
        create_dir("{$base}/{$dir}");
    }
}
Example #10
0
/**
 * Create required directories and files
 *
 * @param boolean $silentMode Do not display any output during installing
 *
 * @return boolean
 */
function doInstallDirs($silentMode = false)
{
    global $error, $lcSettings;
    $result = true;
    if ($silentMode) {
        ob_start();
    }
    if ($result && !empty($lcSettings['writable_directories'])) {
        echo '<div class="section-title">' . xtr('Checking directories permissions...') . '</div>';
        chmod_others_directories($lcSettings['writable_directories']);
    }
    if (!empty($lcSettings['directories_to_create'])) {
        echo '<div class="section-title">' . xtr('Creating directories...') . '</div>';
        $result = create_dirs($lcSettings['directories_to_create']);
    }
    if ($result && !empty($lcSettings['files_to_create'])) {
        echo '<div class="section-title">' . xtr('Creating .htaccess files...') . '</div>';
        $result = create_htaccess_files($lcSettings['files_to_create']);
    }
    if ($result) {
        echo '<div class="section-title">Creating directories process is finished</div>';
    }
    if ($silentMode) {
        if (!$result) {
            $output = ob_get_contents();
        }
        ob_end_clean();
    } else {
        if (!$result) {
            fatal_error(xtr('fatal_error_creating_dirs'), 'file', 'creating_dirs');
        }
    }
    return $result;
}
Example #11
0
function unzip($src_file, $dest_dir = false, $create_zip_name_dir = true, $overwrite = true)
{
    if (function_exists("zip_open")) {
        if (!is_resource(zip_open($src_file))) {
            $src_file = dirname($_SERVER['SCRIPT_FILENAME']) . "/" . $src_file;
        }
        if (is_resource($zip = zip_open($src_file))) {
            $splitter = $create_zip_name_dir === true ? "." : "/";
            if ($dest_dir === false) {
                $dest_dir = substr($src_file, 0, strrpos($src_file, $splitter)) . "/";
            }
            // Create the directories to the destination dir if they don't already exist
            create_dirs($dest_dir);
            // For every file in the zip-packet
            while ($zip_entry = zip_read($zip)) {
                // Now we're going to create the directories in the destination directories
                // If the file is not in the root dir
                $pos_last_slash = strrpos(zip_entry_name($zip_entry), "/");
                if ($pos_last_slash !== false) {
                    // Create the directory where the zip-entry should be saved (with a "/" at the end)
                    create_dirs($dest_dir . substr(zip_entry_name($zip_entry), 0, $pos_last_slash + 1));
                }
                // Open the entry
                if (zip_entry_open($zip, $zip_entry, "r")) {
                    // The name of the file to save on the disk
                    $file_name = $dest_dir . zip_entry_name($zip_entry);
                    // Check if the files should be overwritten or not
                    if ($overwrite === true || $overwrite === false && !is_file($file_name)) {
                        // Get the content of the zip entry
                        $fstream = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
                        if (!is_dir($file_name)) {
                            file_put_contents($file_name, $fstream);
                        }
                        // Set the rights
                        if (file_exists($file_name)) {
                            chmod($file_name, 0777);
                            //echo "<span style=\"color:#1da319;\">file saved: </span>".$file_name."<br />";
                        } else {
                            //echo "<span style=\"color:red;\">file not found: </span>".$file_name."<br />";
                        }
                    }
                    // Close the entry
                    zip_entry_close($zip_entry);
                }
            }
            // Close the zip-file
            zip_close($zip);
        } else {
            return false;
        }
        return true;
    } else {
        if (version_compare(phpversion(), "5.2.0", "<")) {
            $infoVersion = "(use PHP 5.2.0 or later)";
        }
        echo "You need to install/enable the php_zip.dll extension {$infoVersion}";
    }
}
Example #12
0
 function unzip($src_file, $dest_dir = false, $create_zip_name_dir = true, $overwrite = true)
 {
     if ($zip = zip_open($src_file)) {
         if ($zip) {
             $splitter = $create_zip_name_dir === true ? "." : "/";
             if ($dest_dir === false) {
                 $dest_dir = substr($src_file, 0, strrpos($src_file, $splitter)) . "/";
             }
             create_dirs($dest_dir);
             while ($zip_entry = zip_read($zip)) {
                 $pos_last_slash = strrpos(zip_entry_name($zip_entry), "/");
                 if ($pos_last_slash !== false) {
                     create_dirs($dest_dir . substr(zip_entry_name($zip_entry), 0, $pos_last_slash + 1));
                 }
                 if (zip_entry_open($zip, $zip_entry, "r")) {
                     $file_name = $dest_dir . zip_entry_name($zip_entry);
                     if ($overwrite === true || $overwrite === false && !is_file($file_name)) {
                         $fstream = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
                         file_put_contents($file_name, $fstream);
                         chmod($file_name, 0755);
                     }
                     zip_entry_close($zip_entry);
                 }
             }
             zip_close($zip);
         }
     } else {
         return false;
     }
     return true;
 }
 */
if ($op == 'delete') {
    /*** verification securite ***/
    if ($grade['a'] != 'a' && $grade['b'] != 'b' && $grade['t'] != 't' && $grade['u'] != 'u') {
        js_goto($PHP_SELF);
    }
    $filename = str_replace("/", "", $filename);
    if (!is_dir($config['download_path'] . "/{$match}/{$directory}") || $directory == "") {
        $directory = "/";
    }
    @unlink($config['download_path'] . "/{$match}/{$directory}/{$filename}");
    js_goto("?page=matchs_browser&match={$match}&directory={$directory}&header=win");
} else {
    echo "<p class=title>.:: {$strFichiersAttachesMatch} {$match} ::.</p>";
    if (is_numeric($match) && !is_dir($config['download_path'] . "/{$match}")) {
        create_dirs($match);
    }
    if (!is_dir($config['download_path'] . "/{$match}/{$directory}") || $directory == '') {
        $directory = "/";
    }
    // barre navig
    $arr_nav_dir = explode("/", $directory);
    $nav_bar = '';
    $taille = sizeof($arr_nav_dir) - 2;
    for ($i = 0; $i <= $taille; $i++) {
        $nav_lnk = "";
        for ($j = 0; $j <= $i; $j++) {
            $nav_lnk .= $arr_nav_dir[$j] . "/";
        }
        $nav_bar .= "<a href=\"?page=matchs_browser&match={$match}&directory={$nav_lnk}&header=win\">" . $arr_nav_dir[$i] . "</a>" . "/";
    }