function download_and_extract_zip($appname, $appdata) { # Get the contents. $zipped = @file_get_contents($appdata['download']); # If there's a download problem, tell the user. if (!$zipped) { return 'Download error.'; } # Open the zip file. $f = @fopen("{$appname}.zip", 'w+'); if (!is_resource($f)) { # If it didn't open properly, it's probably a permissions error. Tell the user. return 'Possible permissions error.'; } # Unzip. $result = fwrite($f, $zipped); fclose($f); $unzip_result = extract_zip("{$appname}.zip"); unlink("{$appname}.zip"); if ($unzip_result !== true) { # If there's an error, let the user know. return $unzip_result; } else { return true; } }
if (isset($_POST['ver']) && in_array($_POST['ver'], array('1', '2'))) { $download_ok = http_get_file($versions[$_POST['ver']]['url'], 'latest.zip'); } elseif ($_POST['ver'] == '0') { //use local file $download_ok = file_exists('latest.zip'); if (!$download_ok) { echo '<br/> File dosen\'t exists, try downloading the latest version.'; } } else { //use get latest stable url for remote $uri = Get_latest_version_url($versions[$_POST['ver']]['lang_code']); $download_ok = http_get_file($uri, 'latest.zip'); } //unzip if ($download_ok) { $done_zip = extract_zip('latest.zip', $_POST['folder']); } else { echo '<br/> File dosen\'t exists, try downloading the latest version.'; die; } //create database if (isset($_POST['mk_db']) && $_POST['mk_db'] == 'mkdb') { create_db($_POST['db_user'], $_POST['db_pass'], $_POST['server'], $_POST['db_name']); } //redirect to installer if ($done_zip) { ?> <div style="display: none;"> <?php includejQuery(); ?>
$html = curl_exec($ch); curl_close($ch); $_monitor_items['download']['completed'] = 1; /** ESTRAZIONE FILES */ $_monitor_items['status'] = 'extracting'; $_monitor_items['extract']['completed'] = 0; $_monitor_items['extract']['percent'] = 0; write_monitor(); sleep(3); $_monitor_items['extract']['percent'] = '20'; write_monitor(); sleep(2); $_monitor_items['extract']['percent'] = '60'; write_monitor(); /** EXTRAC THE ZIP */ extract_zip($_file_name, $_folder . 'temp/'); $_monitor_items['extract']['percent'] = '100'; $_monitor_items['extract']['completed'] = 1; write_monitor(); /** INSTALLAZIONE FILES */ $_monitor_items['status'] = 'installing'; $_monitor_items['install']['percent'] = 0; $_monitor_items['install']['completed'] = 0; write_monitor(); sleep(2); /** CHECK IF EXIST SCRIPT FILE TO EXEC */ if (file_exists($_folder . 'temp/install.php')) { /** EXEC FILE */ $_command_exec = 'sudo php ' . $_folder . 'temp/install.php'; shell_exec($_command_exec); }
<?php echo $this->lang->line('downloading_files'); ?> ...<br/> <?php download_remote_file_with_curl($download_zip, $download_path); ?> <?php download_remote_file_with_curl($download_sql, $sql_file); ?> <?php echo $this->lang->line('unpacking_zip_package'); ?> ...<br/> <?php if (extract_zip($download_path, $extract_path)) { ?> <?php echo $this->lang->line('installing'); ?> <?php echo $module_name; ?> <?php echo $this->lang->line('module'); ?> ...<br/> <?php delete_file($download_path); ?> <?php
$data['table_prefix'] = $xmldata->table_prefix; $data['cmsadmin'] = $xmldata->cmsadmin; $data['cmsadminemail'] = $xmldata->cmsadminemail; $data['cmspassword'] = $xmldata->cmspassword; $data['core_path'] = $xmldata->core_path; $data['base_url'] = $xmldata->context_web_url; $data['mgr_url'] = $xmldata->context_mgr_url; $data['connectors_url'] = $xmldata->context_connectors_url; $data['base_path'] = $xmldata->context_web_path; $data['mgr_path'] = $xmldata->context_mgr_path; $data['connectors_path'] = $xmldata->context_connectors_path; } print PHP_EOL . 'Extracting zip file.'; // Extract the zip to a our temporary src dir // extract_zip needs the target to have a trailing slash! extract_zip($args['zip'], $src . DIRECTORY_SEPARATOR, false); // Move into position // (both src and dest. target dirs must NOT contain trailing slash) recursive_copy($src . '/connectors', $target . basename($data['connectors_path'])); recursive_copy($src . '/core', rtrim($data['core_path'], DIRECTORY_SEPARATOR)); // <-- special since it doesn't have to be in docroot recursive_copy($src . '/manager', $target . basename($data['mgr_path'])); recursive_copy($src . '/setup', $target . 'setup'); recursive_copy($src . '/index.php', $target . 'index.php'); recursive_copy($src . '/config.core.php', $target . 'config.core.php'); recursive_copy($src . '/ht.access', $target . 'ht.access'); // cleanup // Write the data to the XML file so MODX can read it write_xml($xml, $xml_path); if (!$args['config'] && $args['installmode'] != 'upgrade') { write_xml($xml, 'config.xml');
function download_wordpress_plugins($repositories) { foreach ($repositories as $r) { $plugin = file_get_contents($r); file_put_contents('tmp.zip', $plugin); extract_zip('tmp.zip', 'wp-content/plugins/'); unlink('tmp.zip'); } }
#! /usr/bin/php <?php include 'config.php'; include 'function.php'; include 'ftp.class.php'; include 'pclzip.lib.php'; $result = get_ftp_content(FTP_FILE, STORAGE_TARGET); if ($result === false || !file_exists(STORAGE_TARGET)) { access_log('log', 'Download FTP file FAIL.'); exit; } access_log('log', 'Download FTP file OK.'); $current_path = dirname(__FILE__); $extract_path = $current_path . '/upload/'; if (!extract_zip(STORAGE_TARGET, $extract_path)) { access_log('log', 'ZIP extract fail.'); exit; } if (!file_exists($extract_path)) { access_log('log', 'No file.'); exit; } access_log('log', 'Obtain file.'); function extract_zip($target, $extract_path) { $zip = new PclZip($target); if ($zip->extract(PCLZIP_OPT_PATH, $extract_path) == 0) { return false; } else { return true; }