コード例 #1
0
/**
 * Add New Module
 */
function addNewModule($moduleName, $importFile)
{
    $modulePaths = app("laravel-modules")->modulePaths();
    foreach (array_keys($modulePaths) as $dir) {
        $targetDir = realpath($dir) . "/" . $moduleName . "/";
        if (!file_exists($targetDir)) {
            extractZip($importFile, $targetDir);
            return true;
        }
        break;
    }
    return false;
}
コード例 #2
0
/**
 * This function reads the content of a folder then the redExifJpg function or the extractZip function
 *
 * @param $directory
 *
 */
function copyFrom($directory)
{
    $status = "";
    //check if the gave directory is a real one
    if (is_dir($directory) && ($directory_handle = opendir($directory))) {
        while (($file = readdir($directory_handle)) !== false) {
            //check if $file it's not a directory itself or it's not a "." or ".." path
            if (!is_dir($file) && $file != "." && $file != "..") {
                //getting the file path info
                $path_info = pathinfo($file);
                //Check the file extension
                if ($path_info['extension'] == "jpg") {
                    readJPGExifData($file, $directory);
                } elseif ($path_info['extension'] == "zip") {
                    extractZip($file, $directory);
                } else {
                    $status = "No jpg images present in the remote folder";
                }
            }
        }
        closedir($directory_handle);
    }
    echo $status;
}
コード例 #3
0
function exec_ogp_module()
{
    if (!function_exists("curl_init")) {
        print_failure(get_lang('curl_needed'));
        return;
    }
    if ($_SESSION['users_group'] != "admin") {
        print_failure(get_lang('no_access'));
        return;
    }
    global $db;
    global $view;
    $version = $_GET['version'];
    $vtype = "SVN";
    echo "<h4>" . get_lang('dwl_update') . "</h4>\n";
    //This is usefull when you are downloading big files, as it
    //will prevent time out of the script
    set_time_limit(0);
    error_reporting(E_ALL);
    ini_set('display_errors', true);
    $baseDir = str_replace("modules" . DIRECTORY_SEPARATOR . "update", "", dirname(__FILE__));
    if (!is_writable($baseDir)) {
        if (!@chmod($baseDir, 0755)) {
            print_failure(get_lang_f('base_dir_not_writable', $baseDir));
            return;
        }
    }
    if (is_writable(sys_get_temp_dir())) {
        // Download file to temporary folder
        if (isset($_POST['mirror']) && !empty($_POST['mirror'])) {
            $mirror = $_POST['mirror'];
        } else {
            $mirror = "master";
        }
        $temp_dwl = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'svn.tar.gz';
        $fp = fopen($temp_dwl, 'w+');
        //This is the download destination
        $url = "http://" . $mirror . ".dl.sourceforge.net/project/ogpextras/Alternative-Snapshot/hldstart-code-{$version}.zip";
        //This is the download source
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_TIMEOUT, 500);
        curl_setopt($ch, CURLOPT_FILE, $fp);
        curl_exec($ch);
        curl_close($ch);
        fclose($fp);
        // Check if the file exists and the size is bigger than a 404 error page from sf.net
        if (file_exists($temp_dwl)) {
            $stat = stat($temp_dwl);
        } else {
            print_failure(get_lang_f('dwl_failed', $url));
            return;
        }
        if ($stat['size'] > 1500) {
            print_success(get_lang('dwl_complete'));
        } else {
            print_failure(get_lang_f('dwl_failed', $url));
            return;
        }
        echo "<h4>" . get_lang('install_update') . "</h4>\n";
        // Set default values for file checkings before installing
        $not_writable = get_lang('can_not_update_non_writable_files') . " :<br>";
        $filename = "";
        $overwritten = 0;
        $new = 0;
        $all_writable = TRUE;
        $filelist = "";
        $overwritten_files = "";
        $new_files = "";
        $unwanted_path = "hldstart-code-{$version}/trunk/upload";
        $extract_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . "OGP_update";
        if (!file_exists($extract_path)) {
            mkdir($extract_path, 0775);
        }
        $blacklist = array('/install.php', '/modules/gamemanager/rsync_sites_local.list');
        $blacklisted_files = $db->resultQuery('SELECT file_path FROM `OGP_DB_PREFIXupdate_blacklist`;');
        if ($blacklisted_files !== FALSE) {
            $curren_blacklist = array();
            foreach ($blacklisted_files as $blacklisted_file) {
                $curren_blacklist[] = $blacklisted_file['file_path'];
            }
            $blacklist = array_merge($curren_blacklist, $blacklist);
        }
        include 'unzip.php';
        // array|false extractZip( string $zipFile, string $extract_path [, string $remove_path, array $blacklist, array $whitelist] )
        $files = extractZip($temp_dwl, $extract_path, $unwanted_path, $blacklist, '');
        if (is_array($files) and count($files) > 0) {
            // Check file by file if already exists, if it matches, compares both files
            // looking for changes determining if the file needs to be updated.
            // Also determines if the file is writable
            $filelist = array();
            $i = 0;
            foreach ($files as $file) {
                $filename = str_replace($unwanted_path . "/", "", $file['filename']);
                if (in_array($filename, $blacklist)) {
                    continue;
                }
                $temp_file = $extract_path . DIRECTORY_SEPARATOR . $filename;
                $web_file = $baseDir . $filename;
                if (file_exists($web_file)) {
                    $temp = file_get_contents($temp_file);
                    $web = file_get_contents($web_file);
                    if ($temp != $web) {
                        if (!is_writable($web_file)) {
                            if (!@chmod($web_file, 0775)) {
                                $all_writable = FALSE;
                                $not_writable .= $web_file . "<br>";
                            } else {
                                $filelist[$i] = $file['filename'];
                                $i++;
                                $overwritten_files .= $filename . "<br>";
                                $overwritten++;
                            }
                        } else {
                            $filelist[$i] = $file['filename'];
                            $i++;
                            $overwritten_files .= $filename . "<br>";
                            $overwritten++;
                        }
                    }
                } else {
                    $filelist[$i] = $file['filename'];
                    $i++;
                    $new_files .= $filename . "<br>";
                    $new++;
                }
            }
        }
        // Once checkings are done the temp folder is removed
        if (file_exists($extract_path)) {
            rmdir_recurse($extract_path);
        }
        if ($all_writable) {
            // Extract the files that are set in $filelist, to the folder at $baseDir and removes 'upload' from the beggining of the path.
            $files = extractZip($temp_dwl, preg_replace("/\\/\$/", "", $baseDir), $unwanted_path, $blacklist, $filelist);
            if (is_array($files)) {
                // Updated files
                if ($overwritten > 0) {
                    print_success(get_lang_f('files_overwritten', $overwritten));
                    echo get_lang_f("updated_files", $overwritten_files);
                }
                if ($new > 0) {
                    print_success(get_lang_f('new_files', $new));
                    echo get_lang_f("updated_files", $new_files);
                }
                // update version info in db
                $db->query("UPDATE OGP_DB_PREFIXsettings SET value = '{$version}'\tWHERE setting = 'ogp_version'");
                $db->query("UPDATE OGP_DB_PREFIXsettings SET value = '{$vtype}'\tWHERE setting = 'version_type'");
                // Remove the downloaded package
                if (file_exists($temp_dwl)) {
                    unlink($temp_dwl);
                }
                // Remove files that are not related to the panel
                if (file_exists($baseDir . DIRECTORY_SEPARATOR . "hldstart-code-{$version}")) {
                    rmdir_recurse($baseDir . DIRECTORY_SEPARATOR . "hldstart-code-{$version}");
                }
                echo "<br>\n<h4>" . get_lang('updating_modules') . "</h4>\n";
                require_once 'modules/modulemanager/module_handling.php';
                $modules = $db->getInstalledModules();
                foreach ($modules as $row) {
                    update_module($db, $row['id'], $row['folder']);
                }
                print_success(get_lang('update_complete'));
            } else {
                print_failure("Failed extracting files.<br>There is not enough space available in the system temporary folder (" . sys_get_temp_dir() . ").</b>");
            }
        } else {
            print_failure($not_writable);
        }
    } else {
        print_failure(get_lang_f('temp_folder_not_writable', sys_get_temp_dir()));
    }
}
コード例 #4
0
ファイル: backuper.php プロジェクト: mul14/FiyoCMS
         mkdir('../../../../.backup/.table');
     }
     $date = md5(date("Ymd:His"));
     $file = "tbl-backup-{$date}";
     $c = backup_tables("{$_GET['table']}", '../../../../.backup/.table', "{$file}", true);
     if ($c) {
         $size = format_size(filesize("../../../../.backup/.table/{$file}.sql"));
         $time = date("Y/m/d H:i:s", filemtime("../../../../.backup/.table/{$file}.sql"));
         $r = "{$size} - {$time}";
         echo "{ \"file\":\"{$file}.sql\" , \"info\":\"{$r}\" }";
     }
 }
 if ($_GET['type'] == 'installer') {
     @unlink("../../../../.backup/{$_GET['file']}");
     $file = '../../../../system/installer.zip';
     extractZip($file, '../../../../system');
     if (!file_exists('../../../../.backup')) {
         mkdir('../../../../.backup');
     }
     backup_tables('*', '../../../../system/installer', 'data', true);
     archiveZip('../../../../system/installer', '../../../../system/installer.zip');
     $date = md5(date("Ymd:His"));
     $file = "installer-backup-{$date}.zip";
     $c = archiveZip('../../../../', "../../../../.backup/{$file}");
     if ($c) {
         $size = format_size(filesize("../../../../.backup/{$file}"));
         $time = date("Y/m/d H:i:s", filemtime("../../../../.backup/{$file}"));
         $r = "{$size} - {$time}";
         echo "{ \"file\":\"{$file}\" , \"info\":\"{$r}\" }";
     }
 }
コード例 #5
0
$dbInstaller->runScript($tectonicSql);
echo "Success!!\n";
// download tectonic summary data
echo "\nDownloading and loading tectonic summary data:\n";
$url = configure('GLOBAL_TECTONIC_SUMMARY_URL', 'ftp://hazards.cr.usgs.gov/web/hazdev-geoserve-ws/tectonic/', "Tectonic summary download url");
$filenames = array('tectonicsummary_nc.dat', 'tectonicsummary_neic.dat', 'tectonicsummary_ut.dat');
$download_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'tectonic_summary' . DIRECTORY_SEPARATOR;
// create temp directory
mkdir($download_path);
foreach ($filenames as $filename) {
    $downloaded_file = $download_path . $filename;
    downloadURL($url . $filename, $downloaded_file);
    // uncompress tectonic summary data
    if (pathinfo($downloaded_file)['extension'] === 'zip') {
        print 'Extracting ' . $downloaded_file . "\n";
        extractZip($downloaded_file, $download_path);
    }
}
// ----------------------------------------------------------------------
// Tectonic Summary data load
// ----------------------------------------------------------------------
// Tectonic Summary
echo "\nLoading tectonic summary data neic... ";
$dbInstaller->copyFrom($download_path . 'tectonicsummary_neic.dat', 'tectonic_summary', array('NULL AS \'\'', 'CSV', 'HEADER'));
echo "SUCCESS!!\n";
echo "\nLoading tectonic summary data nc... ";
$dbInstaller->copyFrom($download_path . 'tectonicsummary_nc.dat', 'tectonic_summary', array('NULL AS \'\'', 'CSV', 'HEADER'));
echo "SUCCESS!!\n";
echo "\nLoading tectonic summary data ut... ";
$dbInstaller->copyFrom($download_path . 'tectonicsummary_ut.dat', 'tectonic_summary', array('NULL AS \'\'', 'CSV', 'HEADER'));
echo "SUCCESS!!\n";
コード例 #6
0
 protected function unzipFile($path, $file)
 {
     $path = YiiBase::getPathOfAlias('webroot') . "/themes";
     require_once YiiBase::getPathOfAlias('application.components') . '/zip.php';
     $count_before = glob($path . '/*', GLOB_ONLYDIR);
     extractZip($file, '', $path);
     // if the unzip was successful we should have an extra directory
     $count_after = glob($path . '/*', GLOB_ONLYDIR);
     return $count_after > $count_before;
 }
コード例 #7
0
ファイル: install.php プロジェクト: ubick/lorekeepers.org
function ajax_unpack()
{
    // The call to exctract a path within the zip file
    extractZip(INSTALL_ROOT . '/' . SETUP_PACKAGE);
    echo "true";
    @unlink(INSTALL_ROOT . '/install.php');
    die;
}
コード例 #8
0
 protected function unzipFile($path, $file)
 {
     $path = str_replace("/core/protected", "/runtime/upgrade", Yii::app()->basePath);
     require_once YiiBase::getPathOfAlias('application.components') . '/zip.php';
     extractZip($file, '', $path);
     return true;
 }
コード例 #9
0
ファイル: installer.php プロジェクト: mul14/FiyoCMS
     $name_file = md5($name_file);
     $_SESSION['file'] = $path_file;
     $c = true;
 } else {
     if (isset($_POST['copy']) and !empty($_POST['url'])) {
         $url_file = $_POST['url'];
         if (!file_exists("../tmp")) {
             mkdir("../tmp");
         }
         $name_file = md5($url_file);
         $path_file = "../tmp/{$name_file}.zip";
         $c = @copy($url_file, $path_file);
     }
 }
 if (!empty($path_file) and $c) {
     if (extractZip($path_file, "../tmp/{$name_file}")) {
         if (file_exists("../tmp/{$name_file}/installer.php")) {
             include "../tmp/{$name_file}/installer.php";
             //Modules Installer
             if ($addons['type'] == 'modules') {
                 $folder = "../modules/{$addons['folder']}";
                 $copy = @copy_directory("../tmp/{$name_file}", $folder);
             } else {
                 if ($addons['type'] == 'plugins') {
                     insert_new_plg(@$addons['folder'], @$addons['parameter']);
                     $folder = "../plugins/{$addons['folder']}";
                     $copy = @copy_directory("../tmp/{$name_file}", $folder);
                 } else {
                     if ($addons['type'] == 'apps') {
                         if ($addons['app_type'] > 0) {
                             insert_new_apps($addons['name'], $addons['folder'], $addons['author'], $addons['app_type']);
コード例 #10
0
ファイル: update.php プロジェクト: mul14/FiyoCMS
				</script>
		<?php 
        }
    }
} else {
    echo 0;
}
if (isset($_POST['patching']) and $_POST['patching'] != false and $site_version != $latest_version and $xml) {
    $plink = $p['link'];
    $root = "../../..";
    $newfile = "{$root}/tmp/patch_{$p['number']}.zip";
    if (!file_exists("{$root}/tmp")) {
        mkdir("{$root}/tmp");
    }
    if (copy($plink, $newfile)) {
        if (extractZip($newfile, "{$root}/tmp")) {
            $dapur = siteConfig('backend_folder');
            if (siteConfig('backend_folder') != 'dapur') {
                copy_directory("{$root}/dapur", "{$root}/{$dapur}", true);
            }
            $db = new FQuery();
            $db->connect();
            $db->update(FDBPrefix . 'setting', array('value' => "{$p['number']}"), "name='version'");
            $sup = $p['number'];
            @unlink("{$root}/installer.php");
            ?>
				<script>		
					$(document).ready(function() {										
						$(".update-info").LoadingDot({
							"speed": 500,
							"maxDots": 4,
コード例 #11
0
ファイル: backup.php プロジェクト: mul14/FiyoCMS
                         copy_directory($apf, "../apps/{$folder}");
                         delete_directory("../{$folback}/apps/{$folder}/{$folder}");
                     }
                     alert('info', AddOns_installed);
                     if (isset($apps_info)) {
                         echo "<div class='install_info'>{$apps_info}</div>";
                     }
                 } else {
                     if (file_exists($thm)) {
                         extractZip($path_file, '../themes');
                         include $thm;
                         alert('info', AddOns_installed);
                         echo "<div class='install_info'>{$theme_info}</div>";
                     } else {
                         if (file_exists($atm)) {
                             extractZip($path_file, "../{$folback}/themes");
                             include $atm;
                             alert('info', AddOns_installed);
                             if (isset($theme_info)) {
                                 echo "<div class='install_info'>{$theme_info}</div>";
                             }
                         } else {
                             alert('error', File_uploaded_not_valid);
                         }
                     }
                 }
             }
         }
         $opendir = $folder;
     }
 }
コード例 #12
0
ファイル: updateCodera.php プロジェクト: DeadSpaghetti/codera
    $url = "https://github.com/DeadSpaghetti/codera/archive/master.zip";
    $copyLocation = "../../../";
    $downloadLocation = "../../../codera-master.zip";
    downloadZip($url, $downloadLocation);
    extractZip($downloadLocation, $copyLocation);
    deleteOldVersion();
    copyNewFiles($copyLocation . "codera-master/");
    $downloadLocation = "../../../";
    cleanupTempFiles($downloadLocation, $inDev);
    header("Location: ../index.php");
} else {
    $url = "https://github.com/DeadSpaghetti/codera/archive/indev.zip";
    $copyLocation = "../../../";
    $downloadLocation = "../../../codera-indev.zip";
    downloadZip($url, $downloadLocation);
    extractZip($downloadLocation, $copyLocation);
    deleteOldVersion();
    copyNewFiles($copyLocation . "codera-indev/");
    $downloadLocation = "../../../";
    cleanupTempFiles($downloadLocation, $inDev);
    header("Location: ../index.php");
}
function downloadZip($url, $downloadLocation)
{
    $file = file_get_contents($url);
    file_put_contents($downloadLocation, $file);
}
function extractZip($downloadLocation, $copyLocation)
{
    shell_exec("unzip -o {$downloadLocation} -d {$copyLocation}");
}
コード例 #13
0
<?php

extractZip('C:/Users/Kenny/Documents/EBooks/EBOOKS - EPUB - 626 BOOKS/', 'c:/unzip');
function zipstatus($status)
{
    switch ((int) $status) {
        case ZipArchive::ER_OK:
            return 'N No error';
        case ZipArchive::ER_MULTIDISK:
            return 'N Multi-disk zip archives not supported';
        case ZipArchive::ER_RENAME:
            return 'S Renaming temporary file failed';
        case ZipArchive::ER_CLOSE:
            return 'S Closing zip archive failed';
        case ZipArchive::ER_SEEK:
            return 'S Seek error';
        case ZipArchive::ER_READ:
            return 'S Read error';
        case ZipArchive::ER_WRITE:
            return 'S Write error';
        case ZipArchive::ER_CRC:
            return 'N CRC error';
        case ZipArchive::ER_ZIPCLOSED:
            return 'N Containing zip archive was closed';
        case ZipArchive::ER_NOENT:
            return 'N No such file';
        case ZipArchive::ER_EXISTS:
            return 'N File already exists';
        case ZipArchive::ER_OPEN:
            return 'S Can\'t open file';
        case ZipArchive::ER_TMPOPEN:
コード例 #14
0
ファイル: doupdate.php プロジェクト: vantezzen/synchro
        //Closing the zip file
        $zip->close();
        // Deleting the zip file
        unlink($file);
        return true;
    } else {
        return false;
    }
}
// Download update
$update = file_get_contents("http://bennetthollstein.de/files/synchro/update.php");
$f = fopen("UPDATES/update.zip", "w");
fwrite($f, $update);
fclose($f);
mkdir("UPDATES/update/");
if (!extractZip("UPDATES/update.zip", "UPDATES/update/")) {
    echo "Could not extract zip";
}
$from = "UPDATES/update/synchro-master";
$to = ".";
$error = array();
function error($message, $critical = false)
{
    global $error;
    if ($critical) {
        echo "FATAL ERROR: " . $message;
        exit;
    } else {
        echo "Error: " . $message . "<br>";
        return false;
    }
コード例 #15
0
ファイル: helpers.php プロジェクト: uiDeveloper116/webstore
/**
 * Download latest theme. We call this during install and also on the off chance that the default suddenly
 * goes missing.
 */
function downloadTheme($strTheme)
{
    $jLatest = getFile("http://" . _xls_get_conf('LIGHTSPEED_UPDATER', 'updater.lightspeedretail.com') . "/site/latesttheme/" . XLSWS_VERSIONBUILD . "/" . $strTheme);
    $result = json_decode($jLatest);
    if (empty($result)) {
        Yii::log("ERROR attempting to locate latesttheme " . $strTheme . " from Lightspeed", 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
        return false;
    }
    $strWebstoreInstall = "http://cdn.lightspeedretail.com/webstore/themes/" . $result->latest->filename;
    $data = getFile($strWebstoreInstall);
    if (stripos($data, "404 - Not Found") > 0 || empty($data)) {
        Yii::log("ERROR downloading theme " . $strTheme . " from Lightspeed CDN", 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
        return false;
    }
    $f = file_put_contents("themes/" . $result->latest->title . ".zip", $data);
    if ($f) {
        require_once YiiBase::getPathOfAlias('application.components') . '/zip.php';
        extractZip($result->latest->title . ".zip", '', YiiBase::getPathOfAlias('webroot.themes'));
        @unlink("themes/" . $result->latest->title . ".zip");
    } else {
        Yii::log("ERROR saving themes/" . $result->latest->title . ".zip", 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
        return false;
    }
    return true;
}