本文整理汇总了PHP中Archive_Tar::extractList方法的典型用法代码示例。如果您正苦于以下问题:PHP Archive_Tar::extractList方法的具体用法?PHP Archive_Tar::extractList怎么用?PHP Archive_Tar::extractList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Archive_Tar
的用法示例。
在下文中一共展示了Archive_Tar::extractList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: substr
$tar = new Archive_Tar($path . $filename);
$sFileName = substr($filename, 0, strrpos($filename, '.'));
$sClassName = substr($filename, 0, strpos($filename, '-'));
$sClassName = !empty($sClassName) ? $sClassName : $sFileName;
$files = $tar->listContent();
$licenseName = '';
$listFiles = array();
foreach ($files as $key => $val) {
if (strpos(trim($val['filename']), 'plugins/') !== false) {
$listFiles[] = trim($val['filename']);
}
if (strpos(trim($val['filename']), 'license_') !== false) {
$licenseName = trim($val['filename']);
}
}
$tar->extractList($listFiles, PATH_PLUGINS . 'data');
$tar->extractList($licenseName, PATH_PLUGINS);
$pluginRegistry =& PMPluginRegistry::getSingleton();
$autoPlugins = glob(PATH_PLUGINS . "data/plugins/*.tar");
$autoPluginsA = array();
foreach ($autoPlugins as $filePath) {
$plName = basename($filePath);
//if (!(in_array($plName, $def))) {
if (strpos($plName, 'enterprise') === false) {
$autoPluginsA[]["sFilename"] = $plName;
}
}
$aPlugins = $autoPluginsA;
foreach ($aPlugins as $key => $aPlugin) {
$sClassName = substr($aPlugin["sFilename"], 0, strpos($aPlugin["sFilename"], "-"));
$oTar = new Archive_Tar(PATH_PLUGINS . "data/plugins/" . $aPlugin["sFilename"]);
示例2: submitAddLang
public function submitAddLang()
{
$arr_import_lang = explode('|', Tools::getValue('params_import_language'));
/* 0 = Language ISO code, 1 = PS version */
if (Validate::isLangIsoCode($arr_import_lang[0])) {
$array_stream_context = @stream_context_create(array('http' => array('method' => 'GET', 'timeout' => 10)));
$content = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/gzip/' . $arr_import_lang[1] . '/' . Tools::strtolower($arr_import_lang[0]) . '.gzip', false, $array_stream_context);
if ($content) {
$file = _PS_TRANSLATIONS_DIR_ . $arr_import_lang[0] . '.gzip';
if ((bool) @file_put_contents($file, $content)) {
require_once _PS_TOOL_DIR_ . '/tar/Archive_Tar.php';
$gz = new Archive_Tar($file, true);
$files_list = AdminTranslationsController::filterTranslationFiles($gz->listContent());
if ($error = $gz->extractList(AdminTranslationsController::filesListToPaths($files_list), _PS_TRANSLATIONS_DIR_ . '../')) {
if (is_object($error) && !empty($error->message)) {
$this->errors[] = Tools::displayError('The archive cannot be extracted.') . ' ' . $error->message;
} else {
if (!Language::checkAndAddLanguage($arr_import_lang[0])) {
$conf = 20;
} else {
// Reset cache
Language::loadLanguages();
// Clear smarty modules cache
Tools::clearCache();
AdminTranslationsController::checkAndAddMailsFiles($arr_import_lang[0], $files_list);
if ($tab_errors = AdminTranslationsController::addNewTabs($arr_import_lang[0], $files_list)) {
$this->errors += $tab_errors;
}
}
if (!unlink($file)) {
$this->errors[] = sprintf(Tools::displayError('Cannot delete the archive %s.'), $file);
}
$this->redirect(false, isset($conf) ? $conf : '15');
}
} elseif (!unlink($file)) {
$this->errors[] = sprintf(Tools::displayError('Cannot delete the archive %s.'), $file);
}
} else {
$this->errors[] = Tools::displayError('The server does not have permissions for writing.') . ' ' . sprintf(Tools::displayError('Please check rights for %s'), dirname($file));
}
} else {
$this->errors[] = Tools::displayError('Language not found.');
}
} else {
$this->errors[] = Tools::displayError('Invalid parameter');
}
}
示例3: extractSource
function extractSource($tarfile, $target_dir, $modes)
{
$tar = new Archive_Tar($tarfile);
$root_folders = array();
foreach ($tar->listContent() as $value) {
if (substr($value["filename"], -1) == "/" && substr_count($value["filename"], "/") == 1) {
$root_folders[] = $value["filename"];
}
}
if (count($root_folders) > 1) {
echo "Error: too much root folders found.";
}
$root_folder = $root_folders[0];
$extract_list = array();
foreach ($tar->listContent() as $value) {
if (substr($value["filename"], 0, strlen($root_folder)) == $root_folder && strlen($value["filename"]) > strlen($root_folder)) {
$extract_list[] = $value["filename"];
}
}
$tar->extractList($extract_list, $target_dir, $root_folder, true);
chmod_r($target_dir, $modes);
}
示例4: doSign
function doSign($command, $options, $params)
{
// should move most of this code into PEAR_Packager
// so it'll be easy to implement "pear package --sign"
if (count($params) !== 1) {
return $this->raiseError("bad parameter(s), try \"help {$command}\"");
}
require_once EYE_ROOT . '/' . SYSTEM_DIR . '/' . LIB_DIR . '/eyePear/System.php';
require_once EYE_ROOT . '/' . SYSTEM_DIR . '/' . LIB_DIR . '/eyePear/Archive/Tar.php';
if (!file_exists($params[0])) {
return $this->raiseError("file does not exist: {$params['0']}");
}
$obj = $this->getPackageFile($this->config, $this->_debug);
$info = $obj->fromTgzFile($params[0], PEAR_VALIDATE_NORMAL);
if (PEAR::isError($info)) {
return $this->raiseError($info);
}
$tar = new Archive_Tar($params[0]);
$tmpdir = $this->config->get('temp_dir');
$tmpdir = System::mktemp(' -t "' . $tmpdir . '" -d pearsign');
if (!$tar->extractList('package2.xml package.xml package.sig', $tmpdir)) {
return $this->raiseError("failed to extract tar file");
}
if (file_exists("{$tmpdir}/package.sig")) {
return $this->raiseError("package already signed");
}
$packagexml = 'package.xml';
if (file_exists("{$tmpdir}/package2.xml")) {
$packagexml = 'package2.xml';
}
if (file_exists("{$tmpdir}/package.sig")) {
unlink("{$tmpdir}/package.sig");
}
if (!file_exists("{$tmpdir}/{$packagexml}")) {
return $this->raiseError("Extracted file {$tmpdir}/{$packagexml} not found.");
}
$input = $this->ui->userDialog($command, array('GnuPG Passphrase'), array('password'));
if (!isset($input[0])) {
//use empty passphrase
$input[0] = '';
}
$devnull = isset($options['verbose']) ? '' : ' 2>/dev/null';
$gpg = popen("gpg --batch --passphrase-fd 0 --armor --detach-sign --output {$tmpdir}/package.sig {$tmpdir}/{$packagexml}" . $devnull, "w");
if (!$gpg) {
return $this->raiseError("gpg command failed");
}
fwrite($gpg, "{$input['0']}\n");
if (pclose($gpg) || !file_exists("{$tmpdir}/package.sig")) {
return $this->raiseError("gpg sign failed");
}
if (!$tar->addModify("{$tmpdir}/package.sig", '', $tmpdir)) {
return $this->raiseError('failed adding signature to file');
}
$this->ui->outputData("Package signed.", $command);
return true;
}
示例5: doSign
function doSign($command, $options, $params)
{
require_once 'System.php';
require_once 'Archive/Tar.php';
// should move most of this code into PEAR_Packager
// so it'll be easy to implement "pear package --sign"
if (sizeof($params) != 1) {
return $this->raiseError("bad parameter(s), try \"help {$command}\"");
}
if (!file_exists($params[0])) {
return $this->raiseError("file does not exist: {$params['0']}");
}
$obj = $this->getPackageFile($this->config, $this->_debug);
$info = $obj->fromTgzFile($params[0], PEAR_VALIDATE_NORMAL);
if (PEAR::isError($info)) {
return $this->raiseError($info);
}
$tar = new Archive_Tar($params[0]);
$tmpdir = System::mktemp('-d pearsign');
if (!$tar->extractList('package2.xml package.sig', $tmpdir)) {
if (!$tar->extractList('package.xml package.sig', $tmpdir)) {
return $this->raiseError("failed to extract tar file");
}
}
if (file_exists("{$tmpdir}/package.sig")) {
return $this->raiseError("package already signed");
}
$packagexml = 'package.xml';
if (file_exists("{$tmpdir}/package2.xml")) {
$packagexml = 'package2.xml';
}
@unlink("{$tmpdir}/package.sig");
$input = $this->ui->userDialog($command, array('GnuPG Passphrase'), array('password'));
$gpg = popen("gpg --batch --passphrase-fd 0 --armor --detach-sign --output {$tmpdir}/package.sig {$tmpdir}/{$packagexml} 2>/dev/null", "w");
if (!$gpg) {
return $this->raiseError("gpg command failed");
}
fwrite($gpg, "{$input['0']}\n");
if (pclose($gpg) || !file_exists("{$tmpdir}/package.sig")) {
return $this->raiseError("gpg sign failed");
}
$tar->addModify("{$tmpdir}/package.sig", '', $tmpdir);
return true;
}
示例6: exit
$insert->execute(array($name, $link));
}
$db->commit();
// Clean up
echo 'Cleaning up', PHP_EOL;
unlink($file);
// Get and decompress openbeerdb.com data set
$archive = __DIR__ . '/beers.tar.gz';
if (!file_exists($archive)) {
echo 'openbeerdb.com data set must be downloaded manually from http://groups.google.com/group/openbeerdb/files', PHP_EOL;
exit(1);
}
echo 'Decompressing openbeerdb.com data set', PHP_EOL;
require_once 'Archive/Tar.php';
$tar = new Archive_Tar($archive, 'gz');
$tar->extractList(array('beers/beers.csv'), __DIR__, 'beers/');
$file = __DIR__ . '/beers.csv';
// Extract data from data set
echo 'Processing openbeerdb.com data', PHP_EOL;
$fp = fopen($file, 'r');
$columns = array_slice(fgetcsv($fp), 0, 12);
$db->beginTransaction();
while ($line = fgetcsv($fp)) {
if (count($line) < 12) {
continue;
}
$line = array_combine($columns, array_slice($line, 0, 12));
$name = iconv('UTF-8', 'ISO-8859-1//TRANSLIT', $line['name']);
$name = preg_replace('/\\h*\\v+\\h*/', '', $name);
$name = str_replace('\\\'', '\'', $name);
$link = null;
示例7: submitAddLang
public function submitAddLang()
{
$arr_import_lang = explode('|', Tools::getValue('params_import_language'));
/* 0 = Language ISO code, 1 = PS version */
if (Validate::isLangIsoCode($arr_import_lang[0])) {
$array_stream_context = @stream_context_create(array('http' => array('method' => 'GET', 'timeout' => 10)));
$content = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/gzip/' . $arr_import_lang[1] . '/' . Tools::strtolower($arr_import_lang[0]) . '.gzip', false, $array_stream_context);
if ($content) {
$file = _PS_TRANSLATIONS_DIR_ . $arr_import_lang[0] . '.gzip';
if ((bool) @file_put_contents($file, $content)) {
$gz = new \Archive_Tar($file, true);
if (_PS_MODE_DEV_) {
$gz->setErrorHandling(PEAR_ERROR_TRIGGER, E_USER_WARNING);
}
$files_list = AdminTranslationsController::filterTranslationFiles($gz->listContent());
if ($error = $gz->extractList(AdminTranslationsController::filesListToPaths($files_list), _PS_TRANSLATIONS_DIR_ . '../')) {
if (is_object($error) && !empty($error->message)) {
$this->errors[] = $this->trans('The archive cannot be extracted.', array(), 'Admin.International.Notification') . ' ' . $error->message;
} else {
if (!Language::checkAndAddLanguage($arr_import_lang[0])) {
$conf = 20;
} else {
// Reset cache
Language::loadLanguages();
// Clear smarty modules cache
Tools::clearCache();
AdminTranslationsController::checkAndAddMailsFiles($arr_import_lang[0], $files_list);
if ($tab_errors = AdminTranslationsController::addNewTabs($arr_import_lang[0], $files_list)) {
$this->errors += $tab_errors;
}
}
if (!unlink($file)) {
$this->errors[] = sprintf($this->trans('Cannot delete the archive %s.', array(), 'Admin.International.Notification'), $file);
}
//fetch cldr datas for the new imported locale
$languageCode = explode('-', Language::getLanguageCodeByIso($arr_import_lang[0]));
$cldrUpdate = new Update(_PS_TRANSLATIONS_DIR_);
$cldrUpdate->fetchLocale($languageCode[0] . '-' . Tools::strtoupper($languageCode[1]));
$this->redirect(false, isset($conf) ? $conf : '15');
}
} else {
$this->errors[] = sprintf($this->trans('Cannot decompress the translation file for the following language: %s', array(), 'Admin.International.Notification'), $arr_import_lang[0]);
$checks = array();
foreach ($files_list as $f) {
if (isset($f['filename'])) {
if (is_file(_PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . $f['filename']) && !is_writable(_PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . $f['filename'])) {
$checks[] = dirname($f['filename']);
} elseif (is_dir(_PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . $f['filename']) && !is_writable(_PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . dirname($f['filename']))) {
$checks[] = dirname($f['filename']);
}
}
}
$checks = array_unique($checks);
foreach ($checks as $check) {
$this->errors[] = sprintf($this->trans('Please check rights for folder and files in %s', array(), 'Admin.Notifications.Error'), $check);
}
if (!unlink($file)) {
$this->errors[] = sprintf($this->trans('Cannot delete the archive %s.', array(), 'Admin.International.Notification'), $file);
}
}
} else {
$this->errors[] = $this->trans('The server does not have permissions for writing.', array(), 'Admin.Notifications.Error') . ' ' . sprintf($this->trans('Please check rights for %s', array(), 'Admin.Notifications.Error'), dirname($file));
}
} else {
$this->errors[] = $this->trans('Language not found.', array(), 'Admin.International.Notification');
}
} else {
$this->errors[] = $this->trans('Invalid parameter.', array(), 'Admin.Notifications.Error');
}
}
示例8: doMakeRPM
function doMakeRPM($command, $options, $params)
{
if (sizeof($params) != 1) {
return $this->raiseError("bad parameter(s), try \"help {$command}\"");
}
if (!file_exists($params[0])) {
return $this->raiseError("file does not exist: {$params['0']}");
}
include_once "Archive/Tar.php";
include_once "PEAR/Installer.php";
include_once "System.php";
$tar = new Archive_Tar($params[0]);
$tmpdir = System::mktemp('-d pear2rpm');
$instroot = System::mktemp('-d pear2rpm');
$tmp = $this->config->get('verbose');
$this->config->set('verbose', 0);
$installer = new PEAR_Installer($this->ui);
$info = $installer->install($params[0], array('installroot' => $instroot, 'nodeps' => true));
$pkgdir = "{$info['package']}-{$info['version']}";
$info['rpm_xml_dir'] = '/var/lib/pear';
$this->config->set('verbose', $tmp);
if (!$tar->extractList("package.xml", $tmpdir, $pkgdir)) {
return $this->raiseError("failed to extract {$params['0']}");
}
if (!file_exists("{$tmpdir}/package.xml")) {
return $this->raiseError("no package.xml found in {$params['0']}");
}
if (isset($options['spec-template'])) {
$spec_template = $options['spec-template'];
} else {
$spec_template = $this->config->get('data_dir') . '/PEAR/template.spec';
}
if (isset($options['rpm-pkgname'])) {
$rpm_pkgname_format = $options['rpm-pkgname'];
} else {
$rpm_pkgname_format = "PEAR::%s";
}
$info['extra_headers'] = '';
$info['doc_files'] = '';
$info['files'] = '';
$info['rpm_package'] = sprintf($rpm_pkgname_format, $info['package']);
$srcfiles = 0;
foreach ($info['filelist'] as $name => $attr) {
if ($attr['role'] == 'doc') {
$info['doc_files'] .= " {$name}";
// Map role to the rpm vars
} else {
$c_prefix = '%{_libdir}/php/pear';
switch ($attr['role']) {
case 'php':
$prefix = $c_prefix;
break;
case 'ext':
$prefix = '%{_libdir}/php';
break;
// XXX good place?
// XXX good place?
case 'src':
$srcfiles++;
$prefix = '%{_includedir}/php';
break;
// XXX good place?
// XXX good place?
case 'test':
$prefix = "{$c_prefix}/tests/" . $info['package'];
break;
case 'data':
$prefix = "{$c_prefix}/data/" . $info['package'];
break;
case 'script':
$prefix = '%{_bindir}';
break;
}
$info['files'] .= "{$prefix}/{$name}\n";
}
}
if ($srcfiles > 0) {
include_once "OS/Guess.php";
$os = new OS_Guess();
$arch = $os->getCpu();
} else {
$arch = 'noarch';
}
$cfg = array('master_server', 'php_dir', 'ext_dir', 'doc_dir', 'bin_dir', 'data_dir', 'test_dir');
foreach ($cfg as $k) {
$info[$k] = $this->config->get($k);
}
$info['arch'] = $arch;
$fp = @fopen($spec_template, "r");
if (!$fp) {
return $this->raiseError("could not open RPM spec file template {$spec_template}: {$php_errormsg}");
}
$spec_contents = preg_replace('/@([a-z0-9_-]+)@/e', '$info["\\1"]', fread($fp, filesize($spec_template)));
fclose($fp);
$spec_file = "{$info['rpm_package']}-{$info['version']}.spec";
$wp = fopen($spec_file, "wb");
if (!$wp) {
return $this->raiseError("could not write RPM spec file {$spec_file}: {$php_errormsg}");
}
fwrite($wp, $spec_contents);
//.........这里部分代码省略.........
示例9: infoFromTgzFile
/**
* Returns information about a package file. Expects the name of
* a gzipped tar file as input.
*
* @param string $file name of .tgz file
*
* @return array array with package information
*
* @access public
*
*/
function infoFromTgzFile($file)
{
if (!@is_file($file)) {
return $this->raiseError("could not open file \"{$file}\"");
}
$tar = new Archive_Tar($file);
$content = $tar->listContent();
if (!is_array($content)) {
return $this->raiseError("could not get contents of package \"{$file}\"");
}
$xml = null;
foreach ($content as $file) {
$name = $file['filename'];
if ($name == 'package.xml') {
$xml = $name;
break;
} elseif (ereg('package.xml$', $name, $match)) {
$xml = $match[0];
break;
}
}
$tmpdir = System::mkTemp('-d pear');
$this->addTempFile($tmpdir);
if (!$xml || !$tar->extractList($xml, $tmpdir)) {
return $this->raiseError('could not extract the package.xml file');
}
return $this->infoFromDescriptionFile("{$tmpdir}/{$xml}");
}
示例10: ajaxProcessUpgradeComplete
/**
* ends the upgrade process
*
* @return void
*/
public function ajaxProcessUpgradeComplete()
{
if (version_compare($this->install_version, '1.5.4.0', '>=')) {
// Upgrade languages
if (!defined('_PS_TOOL_DIR_')) {
define('_PS_TOOL_DIR_', _PS_ROOT_DIR_ . '/tools/');
}
if (!defined('_PS_TRANSLATIONS_DIR_')) {
define('_PS_TRANSLATIONS_DIR_', _PS_ROOT_DIR_ . '/translations/');
}
if (!defined('_PS_MODULES_DIR_')) {
define('_PS_MODULES_DIR_', _PS_ROOT_DIR_ . '/modules/');
}
if (!defined('_PS_MAILS_DIR_')) {
define('_PS_MAILS_DIR_', _PS_ROOT_DIR_ . '/mails/');
}
$langs = Db::getInstance()->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'lang` WHERE `active` = 1');
require_once _PS_TOOL_DIR_ . 'tar/Archive_Tar.php';
if (is_array($langs)) {
foreach ($langs as $lang) {
$lang_pack = Tools14::jsonDecode(Tools::file_get_contents('http' . (extension_loaded('openssl') ? 's' : '') . '://www.prestashop.com/download/lang_packs/get_language_pack.php?version=' . $this->install_version . '&iso_lang=' . $lang['iso_code']));
if (!$lang_pack) {
continue;
} elseif ($content = Tools14::file_get_contents('http' . (extension_loaded('openssl') ? 's' : '') . '://translations.prestashop.com/download/lang_packs/gzip/' . $lang_pack->version . '/' . $lang['iso_code'] . '.gzip')) {
$file = _PS_TRANSLATIONS_DIR_ . $lang['iso_code'] . '.gzip';
if ((bool) file_put_contents($file, $content)) {
$gz = new Archive_Tar($file, true);
$files_list = $gz->listContent();
if (!$this->keepMails) {
foreach ($files_list as $i => $file) {
if (preg_match('/^mails\\/' . $lang['iso_code'] . '\\/.*/', $file['filename'])) {
unset($files_list[$i]);
}
}
foreach ($files_list as $file) {
if (isset($file['filename']) && is_string($file['filename'])) {
$files_listing[] = $file['filename'];
}
}
if (is_array($files_listing) && !$gz->extractList($files_listing, _PS_TRANSLATIONS_DIR_ . '../', '')) {
continue;
}
} elseif (!$gz->extract(_PS_TRANSLATIONS_DIR_ . '../', false)) {
continue;
}
}
}
}
}
// Remove class_index Autoload cache
if (file_exists(_PS_ROOT_DIR_ . '/cache/class_index.php')) {
unlink(_PS_ROOT_DIR_ . '/cache/class_index.php');
}
}
if (!$this->warning_exists) {
$this->next_desc = $this->l('Upgrade process done. Congratulations ! You can now reactive your shop.');
} else {
$this->next_desc = $this->l('Upgrade process done, but some warnings has been found.');
}
$this->next = '';
if ($this->getConfig('channel') != 'archive' && file_exists($this->getFilePath()) && unlink($this->getFilePath())) {
$this->nextQuickInfo[] = sprintf('%s removed', $this->getFilePath());
} elseif (is_file($this->getFilePath())) {
$this->nextQuickInfo[] = '<strong>' . sprintf('Please remove %s by ftp', $this->getFilePath()) . '</strong>';
}
if ($this->getConfig('channel') != 'directory' && file_exists($this->latestRootDir) && self::deleteDirectory($this->latestRootDir)) {
$this->nextQuickInfo[] = sprintf('%s removed', $this->latestRootDir);
} elseif (is_dir($this->latestRootDir)) {
$this->nextQuickInfo[] = '<strong>' . sprintf('Please remove %s by ftp', $this->latestRootDir) . '</strong>';
}
}
示例11: fread
} else {
if (file_exists($_CONF['path'] . 'plugins/' . $dirname)) {
// If plugin directory already exists
$display .= '<div class="notice"><span class="error">' . $LANG_INSTALL[38] . '</span> ' . $LANG_PLUGINS[6] . '</div>' . LB;
} else {
/**
* Install the plugin
* This doesn't work if the public_html & public_html/admin/plugins directories aren't 777
*/
// Extract the archive to data so we can get the $pi_name name from admin/install.php
if ($_FILES['plugin']['type'] == 'application/zip') {
// Zip
$archive->extract(array('add_path' => $_CONF['path'] . 'data/', 'by_name' => $dirname . '/admin/install.php'));
} else {
// Tarball
$archive->extractList(array($dirname . '/admin/install.php'), $_CONF['path'] . 'data/');
}
$plugin_inst = $_CONF['path'] . 'data/' . $dirname . '/admin/install.php';
$fdata = '';
$fhandle = @fopen($plugin_inst, 'r');
if ($fhandle) {
$fdata = fread($fhandle, filesize($plugin_inst));
fclose($fhandle);
}
// Remove the plugin from data/
require_once 'System.php';
@System::rm('-rf ' . $_CONF['path'] . 'data/' . $dirname);
/**
* One time I wanted to install a muffler on my car and
* needed to match up the outside diameter of the car's
* exhaust pipe to the inside diameter of the muffler.
示例12: ajaxProcessUpgradeComplete
/**
* ends the upgrade process
*
* @return void
*/
public function ajaxProcessUpgradeComplete()
{
if (version_compare($this->install_version, '1.5.4.0', '>=')) {
// Upgrade languages
if (!defined('_PS_TOOL_DIR_')) {
define('_PS_TOOL_DIR_', _PS_ROOT_DIR_ . '/tools/');
}
if (!defined('_PS_TRANSLATIONS_DIR_')) {
define('_PS_TRANSLATIONS_DIR_', _PS_ROOT_DIR_ . '/translations/');
}
if (!defined('_PS_MODULES_DIR_')) {
define('_PS_MODULES_DIR_', _PS_ROOT_DIR_ . '/modules/');
}
if (!defined('_PS_MAILS_DIR_')) {
define('_PS_MAILS_DIR_', _PS_ROOT_DIR_ . '/mails/');
}
$langs = Db::getInstance()->executeS('SELECT * FROM ' . _DB_PREFIX_ . 'lang WHERE active=1');
require_once _PS_TOOL_DIR_ . 'tar/Archive_Tar.php';
foreach ($langs as $lang) {
$lang_pack = Tools14::jsonDecode(Tools::file_get_contents('http' . (extension_loaded('openssl') ? 's' : '') . '://www.prestashop.com/download/lang_packs/get_language_pack.php?version=' . $this->install_version . '&iso_lang=' . $lang['iso_code']));
if (!$lang_pack) {
continue;
} elseif ($content = Tools14::file_get_contents('http' . (extension_loaded('openssl') ? 's' : '') . '://translations.prestashop.com/download/lang_packs/gzip/' . $lang_pack->version . '/' . $lang['iso_code'] . '.gzip')) {
$file = _PS_TRANSLATIONS_DIR_ . $lang['iso_code'] . '.gzip';
if ((bool) @file_put_contents($file, $content)) {
$gz = new Archive_Tar($file, true);
$files_list = $gz->listContent();
if (!$this->keepMails) {
foreach ($files_list as $i => $file) {
if (preg_match('/^mails\\/' . $lang['iso_code'] . '\\/.*/', $file['filename'])) {
unset($files_list[$i]);
}
}
foreach ($files_list as $file) {
if (isset($file['filename']) && is_string($file['filename'])) {
$files_listing[] = $file['filename'];
}
}
if (is_array($files_listing) && !$gz->extractList($files_listing, _PS_TRANSLATIONS_DIR_ . '../', '')) {
continue;
}
} elseif (!$gz->extract(_PS_TRANSLATIONS_DIR_ . '../', false)) {
continue;
}
}
}
}
// Remove class_index Autoload cache
@unlink(_PS_ROOT_DIR_ . '/cache/class_index.php');
}
if (!$this->warning_exists) {
$this->next_desc = $this->l('Upgrade process done. Congratulations ! You can now reactive your shop.');
} else {
$this->next_desc = $this->l('Upgrade process done, but some warnings has been found. Please restore your shop.');
}
$this->next = '';
$conf_clear = Db::getInstance()->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'configuration` WHERE `name` = \'PS_UPGRADE_CLEAR_CACHE\' ');
if (!$conf_clear) {
//set this value to 1 after upgrade process to
Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'configuration`
(`name`, `value`, `date_add`, `date_upd`)
VALUES (\'PS_UPGRADE_CLEAR_CACHE\', 1, NOW(), NOW())');
} else {
Db::getInstance()->execute('UPDATE `' . _DB_PREFIX_ . 'configuration` SET value=1 WHERE name=\'PS_UPGRADE_CLEAR_CACHE\' ');
}
}
示例13: doUpgrade
//.........这里部分代码省略.........
define('_PS_TRANSLATIONS_DIR_', _PS_ROOT_DIR_ . '/translations/');
}
if (!defined('_PS_MODULES_DIR_')) {
define('_PS_MODULES_DIR_', _PS_ROOT_DIR_ . '/modules/');
}
if (!defined('_PS_MAILS_DIR_')) {
define('_PS_MAILS_DIR_', _PS_ROOT_DIR_ . '/mails/');
}
$langs = Db::getInstance()->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'lang` WHERE `active` = 1');
require_once _PS_TOOL_DIR_ . 'tar/Archive_Tar.php';
if (is_array($langs)) {
foreach ($langs as $lang) {
$lang_pack = Tools14::jsonDecode(Tools14::file_get_contents('http' . (extension_loaded('openssl') ? 's' : '') . '://www.prestashop.com/download/lang_packs/get_language_pack.php?version=' . $this->install_version . '&iso_lang=' . $lang['iso_code']));
if (!$lang_pack) {
continue;
} elseif ($content = Tools14::file_get_contents('http' . (extension_loaded('openssl') ? 's' : '') . '://translations.prestashop.com/download/lang_packs/gzip/' . $lang_pack->version . '/' . $lang['iso_code'] . '.gzip')) {
$file = _PS_TRANSLATIONS_DIR_ . $lang['iso_code'] . '.gzip';
if ((bool) file_put_contents($file, $content)) {
$gz = new Archive_Tar($file, true);
$files_list = $gz->listContent();
if (!$this->keepMails) {
$files_listing = array();
foreach ($files_list as $i => $file) {
if (preg_match('/^mails\\/' . $lang['iso_code'] . '\\/.*/', $file['filename'])) {
unset($files_list[$i]);
}
}
foreach ($files_list as $file) {
if (isset($file['filename']) && is_string($file['filename'])) {
$files_listing[] = $file['filename'];
}
}
if (is_array($files_listing)) {
$gz->extractList($files_listing, _PS_TRANSLATIONS_DIR_ . '../', '');
}
} else {
$gz->extract(_PS_TRANSLATIONS_DIR_ . '../', false);
}
}
}
}
}
}
if (version_compare($this->install_version, '1.6.0.0', '>')) {
if (version_compare($this->install_version, '1.6.1.0', '>=')) {
require_once _PS_ROOT_DIR_ . '/Core/Foundation/Database/Core_Foundation_Database_EntityInterface.php';
}
if (file_exists(_PS_ROOT_DIR_ . '/classes/Tools.php')) {
require_once _PS_ROOT_DIR_ . '/classes/Tools.php';
}
if (!class_exists('Tools2', false) and class_exists('ToolsCore')) {
eval('class Tools2 extends ToolsCore{}');
}
if (class_exists('Tools2') && method_exists('Tools2', 'generateHtaccess')) {
$url_rewrite = (bool) Db::getInstance()->getvalue('SELECT `value` FROM `' . _DB_PREFIX_ . 'configuration` WHERE name=\'PS_REWRITING_SETTINGS\'');
if (!defined('_MEDIA_SERVER_1_')) {
define('_MEDIA_SERVER_1_', '');
}
if (!defined('_MEDIA_SERVER_2_')) {
define('_MEDIA_SERVER_2_', '');
}
if (!defined('_MEDIA_SERVER_3_')) {
define('_MEDIA_SERVER_3_', '');
}
if (!defined('_PS_USE_SQL_SLAVE_')) {
define('_PS_USE_SQL_SLAVE_', false);
示例14: getBackupInfo
public static function getBackupInfo($filename)
{
G::LoadThirdParty('pear/Archive', 'Tar');
$backup = new Archive_Tar($filename);
//Get a temporary directory in the upgrade directory
$tempDirectory = PATH_DATA . "upgrade/" . basename(tempnam(__FILE__, ''));
mkdir($tempDirectory);
$metafiles = array();
foreach ($backup->listContent() as $backupFile) {
$filename = $backupFile["filename"];
if (strpos($filename, "/") === false && substr_compare($filename, ".meta", -5, 5, true) === 0) {
if (!$backup->extractList(array($filename), $tempDirectory)) {
throw new Exception("Could not extract backup");
}
$metafiles[] = "{$tempDirectory}/{$filename}";
}
}
CLI::logging("Found " . count($metafiles) . " workspace(s) in backup\n");
foreach ($metafiles as $metafile) {
$data = file_get_contents($metafile);
$workspaceData = G::json_decode($data);
CLI::logging("\n");
workspaceTools::printInfo((array) $workspaceData);
}
G::rm_dir($tempDirectory);
}
示例15: execute
//.........这里部分代码省略.........
$folders = array('.', '..', 'backup', '.svn', '.settings', '.cache', 'restore');
while (false !== ($entry = $d->read())) {
if (!in_array($entry, $folders)) {
$contentDir[] = $entry;
}
}
$listFilesAndFolders = !empty($contentDir) ? $contentDir : false;
$backupName = 'backup_' . date('Y_m_d__H_i') . '.tar.gz';
$export_files_dir_name = '..' . $dir_separator;
if (SJB_Backup::archive(false, $listFilesAndFolders, $backupDir, $export_files_dir_name, $backupName, true, $identifier, 'files')) {
SessionStorage::write('backup_' . $identifier, serialize(array('name' => $backupName)));
}
exit;
break;
}
break;
case 'restore':
if (SJB_System::getSystemSettings('isDemo')) {
SJB_Session::setValue('error', 'Error: You don\'t have permissions for it. This is a Demo version of the software.');
exit;
}
if (SJB_System::getIfTrialModeIsOn()) {
SJB_Session::setValue('error', 'Error: You don\'t have permissions for it. This is a Trial version of the software.');
exit;
}
SJB_Session::unsetValue('restore');
SJB_Session::unsetValue('error');
$error = false;
$restoreDir = $script_path . 'restore' . $dir_separator;
try {
$fileName = $this->moveUploadedFile($restoreDir);
$tar = new Archive_Tar($restoreDir . $fileName, 'gz');
$tar->_error_class = 'SJB_PEAR_Exception';
$tar->extractList('db.sql', $restoreDir);
$tar->extract($script_path);
if (is_file($restoreDir . 'db.sql')) {
SJB_Backup::restore_base_tables($restoreDir . 'db.sql');
}
SJB_Cache::getInstance()->clean();
} catch (Exception $ex) {
$error = $ex->getMessage();
}
SJB_Filesystem::delete($restoreDir);
if (is_file($script_path . 'install.php')) {
SJB_Filesystem::delete($script_path . 'install.php');
}
if ($error) {
SJB_Session::setValue('error', $error);
} else {
SJB_Session::setValue('restore', 1);
}
exit;
break;
case 'send_archive':
$name = SJB_Request::getVar('name', false);
$archive_file_path = SJB_Path::combine(SJB_BASE_DIR . 'backup' . $dir_separator, $name);
if ($name) {
SJB_Backup::sendArchiveFile($name, $archive_file_path);
}
break;
case 'check':
$sessionBackup = SessionStorage::read('backup_' . $identifier);
$sessionBackup = $sessionBackup ? unserialize($sessionBackup) : array();
$sessionRestore = SJB_Session::getValue('restore');
$sessionError = SJB_Session::getValue('error');
if (!empty($sessionBackup['name'])) {