当前位置: 首页>>代码示例>>PHP>>正文


PHP Tools::deleteDirectory方法代码示例

本文整理汇总了PHP中Tools::deleteDirectory方法的典型用法代码示例。如果您正苦于以下问题:PHP Tools::deleteDirectory方法的具体用法?PHP Tools::deleteDirectory怎么用?PHP Tools::deleteDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tools的用法示例。


在下文中一共展示了Tools::deleteDirectory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: install

 public function install()
 {
     if (Db::getInstance()->getValue('SELECT id_module FROM ' . _DB_PREFIX_ . 'module WHERE name =\'' . pSQL($this->name) . '\'')) {
         return true;
     }
     Tools::deleteDirectory($this->cache_data, false);
     if (!$this->installDb() || !$this->installTab() || !Configuration::updateGlobalValue('GF_INSTALL_CALC', 0) || !Configuration::updateGlobalValue('GF_CURRENT_LEVEL', 1) || !Configuration::updateGlobalValue('GF_CURRENT_LEVEL_PERCENT', 0) || !Configuration::updateGlobalValue('GF_NOTIFICATION', 0) || !parent::install() || !$this->registerHook('displayBackOfficeHeader')) {
         return false;
     }
     return true;
 }
开发者ID:WhisperingTree,项目名称:etagerca,代码行数:11,代码来源:gamification.php

示例2: installTheme

 protected function installTheme($theme_dir, $sandbox = false, $redirect = true)
 {
     if (!$sandbox) {
         $uniqid = uniqid();
         $sandbox = _PS_CACHE_DIR_ . 'sandbox' . DIRECTORY_SEPARATOR . $uniqid . DIRECTORY_SEPARATOR;
         mkdir($sandbox);
         Tools::recurseCopy(_PS_ALL_THEMES_DIR_ . $theme_dir, $sandbox . $theme_dir);
     }
     $xml_file = $sandbox . $theme_dir . '/Config.xml';
     if (!$this->checkXmlFields($xml_file)) {
         $this->errors[] = $this->l('Bad configuration file');
     } else {
         $imported_theme = $this->importThemeXmlConfig(simplexml_load_file($xml_file));
         foreach ($imported_theme as $theme) {
             if (Validate::isLoadedObject($theme)) {
                 if (!copy($sandbox . $theme_dir . '/Config.xml', _PS_ROOT_DIR_ . '/config/xml/themes/' . $theme->directory . '.xml')) {
                     $this->errors[] = $this->l('Can\'t copy configuration file');
                 }
                 $target_dir = _PS_ALL_THEMES_DIR_ . $theme->directory;
                 if (file_exists($target_dir)) {
                     Tools::deleteDirectory($target_dir);
                 }
                 $theme_doc_dir = $target_dir . '/docs/';
                 if (file_exists($theme_doc_dir)) {
                     Tools::deleteDirectory($theme_doc_dir);
                 }
                 mkdir($target_dir);
                 mkdir($theme_doc_dir);
                 Tools::recurseCopy($sandbox . $theme_dir . '/themes/' . $theme->directory . '/', $target_dir . '/');
                 Tools::recurseCopy($sandbox . $theme_dir . '/doc/', $theme_doc_dir);
                 Tools::recurseCopy($sandbox . $theme_dir . '/modules/', _PS_MODULE_DIR_);
             } else {
                 $this->errors[] = $theme;
             }
         }
     }
     if (!count($this->errors)) {
         if ($redirect) {
             Tools::redirectAdmin(Context::getContext()->link->getAdminLink('AdminThemes') . '&conf=18');
         } else {
             return true;
         }
     } else {
         return false;
     }
 }
开发者ID:tmdhosting,项目名称:TMDHosting-PrestaShop-Technology-Theme,代码行数:46,代码来源:ThemeInstallHelper.php

示例3: uploadImageZip

 public function uploadImageZip($product)
 {
     // Move the ZIP file to the img/tmp directory
     if (!($zipfile = tempnam(_PS_TMP_IMG_DIR_, 'PS')) or !move_uploaded_file($_FILES['image_product']['tmp_name'], $zipfile)) {
         $this->_errors[] = Tools::displayError('An error occurred during the ZIP file upload.');
         return false;
     }
     // Unzip the file to a subdirectory
     $subdir = _PS_TMP_IMG_DIR_ . uniqid() . '/';
     try {
         if (!Tools::ZipExtract($zipfile, $subdir)) {
             throw new Exception(Tools::displayError('An error occurred while unzipping your file.'));
         }
         $types = array('.gif' => 'image/gif', '.jpeg' => 'image/jpeg', '.jpg' => 'image/jpg', '.png' => 'image/png');
         $_POST['id_product'] = (int) $product->id;
         $imagesTypes = ImageType::getImagesTypes('products');
         $highestPosition = Image::getHighestPosition($product->id);
         foreach (scandir($subdir) as $file) {
             if ($file[0] == '.') {
                 continue;
             }
             // Create image object
             $image = new Image();
             $image->id_product = (int) $product->id;
             $image->position = ++$highestPosition;
             $image->cover = $highestPosition == 1 ? true : false;
             // Call automated copy function
             $this->validateRules('Image', 'image');
             $this->copyFromPost($image, 'image');
             if (sizeof($this->_errors)) {
                 throw new Exception('');
             }
             if (!$image->add()) {
                 throw new Exception(Tools::displayError('Error while creating additional image'));
             }
             if (filesize($subdir . $file) > $this->maxImageSize) {
                 $image->delete();
                 throw new Exception(Tools::displayError('Image is too large') . ' (' . filesize($subdir . $file) / 1000 . Tools::displayError('kB') . '). ' . Tools::displayError('Maximum allowed:') . ' ' . $this->maxImageSize / 1000 . Tools::displayError('kB'));
             }
             $ext = substr($file, -4) == 'jpeg' ? '.jpeg' : substr($file, -4);
             $type = isset($types[$ext]) ? $types[$ext] : '';
             if (!isPicture(array('tmp_name' => $subdir . $file, 'type' => $type))) {
                 $image->delete();
                 throw new Exception(Tools::displayError('Image format not recognized, allowed formats are: .gif, .jpg, .png'));
             }
             if (!($new_path = $image->getPathForCreation())) {
                 throw new Exception(Tools::displayError('An error occurred during new folder creation'));
             }
             if (!imageResize($subdir . $file, $new_path . '.' . $image->image_format)) {
                 $image->delete();
                 throw new Exception(Tools::displayError('An error occurred while resizing image.'));
             }
             foreach ($imagesTypes as $k => $imageType) {
                 if (!imageResize($image->getPathForCreation() . '.jpg', $image->getPathForCreation() . '-' . stripslashes($imageType['name']) . '.jpg', $imageType['width'], $imageType['height'])) {
                     $image->delete();
                     throw new Exception(Tools::displayError('An error occurred while copying image.') . ' ' . stripslashes($imageType['name']));
                 }
             }
             Module::hookExec('watermark', array('id_image' => $image->id, 'id_product' => $image->id_product));
         }
     } catch (Exception $e) {
         if ($error = $e->getMessage()) {
         }
         $this->_errors[] = $error;
         Tools::deleteDirectory($subdir);
         return false;
     }
     Tools::deleteDirectory($subdir);
     return true;
 }
开发者ID:nicolasjeol,项目名称:hec-ecommerce,代码行数:70,代码来源:AdminProducts.php

示例4: deleteCacheDirectory

 public static function deleteCacheDirectory()
 {
     Tools::deleteDirectory(CACHEFS_DIR, false);
 }
开发者ID:liu33851861,项目名称:CZD_Yaf_Extension,代码行数:4,代码来源:CacheFs.php

示例5: downloadAddonsThemes

 public function downloadAddonsThemes()
 {
     if (!$this->logged_on_addons) {
         return false;
     }
     if (!$this->isFresh(self::CACHE_FILE_CUSTOMER_THEMES_LIST, 86400)) {
         file_put_contents(_PS_ROOT_DIR_ . self::CACHE_FILE_CUSTOMER_THEMES_LIST, Tools::addonsRequest('customer_themes'));
     }
     $customer_themes_list = file_get_contents(_PS_ROOT_DIR_ . self::CACHE_FILE_CUSTOMER_THEMES_LIST);
     if (!empty($customer_themes_list) && ($customer_themes_list_xml = @simplexml_load_string($customer_themes_list))) {
         foreach ($customer_themes_list_xml->theme as $addons_theme) {
             //get addons theme if folder does not exist
             $ids_themes = Tools::unSerialize(Configuration::get('PS_ADDONS_THEMES_IDS'));
             if (!is_array($ids_themes) || is_array($ids_themes) && !in_array((string) $addons_theme->id, $ids_themes)) {
                 $zip_content = Tools::addonsRequest('module', array('id_module' => pSQL($addons_theme->id), 'username_addons' => pSQL(trim($this->context->cookie->username_addons)), 'password_addons' => pSQL(trim($this->context->cookie->password_addons))));
                 $uniqid = uniqid();
                 $sandbox = _PS_CACHE_DIR_ . 'sandbox' . DIRECTORY_SEPARATOR . $uniqid . DIRECTORY_SEPARATOR;
                 mkdir($sandbox);
                 file_put_contents($sandbox . (string) $addons_theme->getName() . '.zip', $zip_content);
                 if ($this->extractTheme($sandbox . (string) $addons_theme->getName() . '.zip', $sandbox)) {
                     if ($theme_directory = $this->installTheme(self::UPLOADED_THEME_DIR_NAME, $sandbox, false)) {
                         $ids_themes[$theme_directory] = (string) $addons_theme->id;
                     }
                 }
                 Tools::deleteDirectory($sandbox);
             }
             Configuration::updateValue('PS_ADDONS_THEMES_IDS', serialize($ids_themes));
         }
     }
 }
开发者ID:M03G,项目名称:PrestaShop,代码行数:30,代码来源:AdminThemesController.php

示例6: submitImportLang

 public function submitImportLang()
 {
     if (!isset($_FILES['file']['tmp_name']) || !$_FILES['file']['tmp_name']) {
         $this->errors[] = Tools::displayError('No file has been selected.');
     } else {
         require_once _PS_TOOL_DIR_ . 'tar/Archive_Tar.php';
         $gz = new Archive_Tar($_FILES['file']['tmp_name'], true);
         $filename = $_FILES['file']['name'];
         $iso_code = str_replace(array('.tar.gz', '.gzip'), '', $filename);
         if (Validate::isLangIsoCode($iso_code)) {
             $themes_selected = Tools::getValue('theme', array(self::DEFAULT_THEME_NAME));
             $files_list = AdminTranslationsController::filterTranslationFiles($gz->listContent());
             $files_paths = AdminTranslationsController::filesListToPaths($files_list);
             $uniqid = uniqid();
             $sandbox = _PS_CACHE_DIR_ . 'sandbox' . DIRECTORY_SEPARATOR . $uniqid . DIRECTORY_SEPARATOR;
             if ($gz->extractList($files_paths, $sandbox)) {
                 foreach ($files_list as $file2check) {
                     //don't validate index.php, will be overwrite when extract in translation directory
                     if (pathinfo($file2check['filename'], PATHINFO_BASENAME) == 'index.php') {
                         continue;
                     }
                     if (preg_match('@^[0-9a-z-_/\\\\]+\\.php$@i', $file2check['filename'])) {
                         if (!AdminTranslationsController::checkTranslationFile(file_get_contents($sandbox . $file2check['filename']))) {
                             $this->errors[] = sprintf(Tools::displayError('Validation failed for: %s'), $file2check['filename']);
                         }
                     } elseif (!preg_match('@^[0-9a-z-_/\\\\]+\\.(html|tpl|txt)$@i', $file2check['filename'])) {
                         $this->errors[] = sprintf(Tools::displayError('Unidentified file found: %s'), $file2check['filename']);
                     }
                 }
                 Tools::deleteDirectory($sandbox, true);
             }
             if (count($this->errors)) {
                 return false;
             }
             if ($gz->extractList($files_paths, _PS_TRANSLATIONS_DIR_ . '../')) {
                 foreach ($files_list as $file2check) {
                     if (pathinfo($file2check['filename'], PATHINFO_BASENAME) == 'index.php' && file_put_contents(_PS_TRANSLATIONS_DIR_ . '../' . $file2check['filename'], Tools::getDefaultIndexContent())) {
                         continue;
                     }
                 }
                 // Clear smarty modules cache
                 Tools::clearCache();
                 if (Validate::isLanguageFileName($filename)) {
                     if (!Language::checkAndAddLanguage($iso_code)) {
                         $conf = 20;
                     } else {
                         // Reset cache
                         Language::loadLanguages();
                         AdminTranslationsController::checkAndAddMailsFiles($iso_code, $files_list);
                         $this->checkAndAddThemesFiles($files_list, $themes_selected);
                         $tab_errors = AdminTranslationsController::addNewTabs($iso_code, $files_list);
                         if (count($tab_errors)) {
                             $this->errors += $tab_errors;
                             return false;
                         }
                     }
                 }
                 $this->redirect(false, isset($conf) ? $conf : '15');
             }
             $this->errors[] = Tools::displayError('The archive cannot be extracted.');
         } else {
             $this->errors[] = sprintf(Tools::displayError('ISO CODE invalid "%1$s" for the following file: "%2$s"'), $iso_code, $filename);
         }
     }
 }
开发者ID:dev-lav,项目名称:htdocs,代码行数:65,代码来源:AdminTranslationsController.php

示例7: processDelete

 public function processDelete()
 {
     $obj = $this->loadObject();
     if ($obj && is_dir(_PS_ALL_THEMES_DIR_ . $obj->directory)) {
         Tools::deleteDirectory(_PS_ALL_THEMES_DIR_ . $obj->directory . '/');
     }
     if ($obj && $obj->isUsed()) {
         $this->errors[] = $this->l('This theme is already used by at least one shop. Please choose another theme first.');
         return false;
     }
     return parent::processDelete();
 }
开发者ID:rrameshsat,项目名称:Prestashop,代码行数:12,代码来源:AdminThemesController.php

示例8: processImportTheme

 public function processImportTheme()
 {
     $this->display = 'importtheme';
     if (defined('_PS_HOST_MODE_')) {
         return true;
     }
     if (isset($_FILES['themearchive']) && isset($_POST['filename']) && Tools::isSubmit('theme_archive_server')) {
         $uniqid = uniqid();
         $sandbox = _PS_CACHE_DIR_ . 'sandbox' . DIRECTORY_SEPARATOR . $uniqid . DIRECTORY_SEPARATOR;
         mkdir($sandbox);
         $archive_uploaded = false;
         if (Tools::getValue('filename') != '') {
             if ($_FILES['themearchive']['error'] || !file_exists($_FILES['themearchive']['tmp_name'])) {
                 $this->errors[] = sprintf($this->l('An error has occurred during the file upload (%s)'), $_FILES['themearchive']['error']);
             } elseif (substr($_FILES['themearchive']['name'], -4) != '.zip') {
                 $this->errors[] = $this->l('Only zip files are allowed');
             } elseif (!move_uploaded_file($_FILES['themearchive']['tmp_name'], $sandbox . 'uploaded.zip')) {
                 $this->errors[] = $this->l('An error has occurred during the file copy.');
             } elseif (Tools::ZipTest($sandbox . 'uploaded.zip')) {
                 $archive_uploaded = true;
             } else {
                 $this->errors[] = $this->l('Zip file seems to be broken');
             }
         } elseif (Tools::getValue('themearchiveUrl') != '') {
             if (!Validate::isModuleUrl($url = Tools::getValue('themearchiveUrl'), $this->errors)) {
                 $this->errors[] = $this->l('Only zip files are allowed');
             } elseif (!move_uploaded_file($url, $sandbox . 'uploaded.zip')) {
                 $this->errors[] = $this->l('Error during the file download');
             } elseif (Tools::ZipTest($sandbox . 'uploaded.zip')) {
                 $archive_uploaded = true;
             } else {
                 $this->errors[] = $this->l('Zip file seems to be broken');
             }
         } elseif (Tools::getValue('theme_archive_server') != '') {
             $filename = _PS_ALL_THEMES_DIR_ . Tools::getValue('theme_archive_server');
             if (substr($filename, -4) != '.zip') {
                 $this->errors[] = $this->l('Only zip files are allowed');
             } elseif (!copy($filename, $sandbox . 'uploaded.zip')) {
                 $this->errors[] = $this->l('An error has occurred during the file copy.');
             } elseif (Tools::ZipTest($sandbox . 'uploaded.zip')) {
                 $archive_uploaded = true;
             } else {
                 $this->errors[] = $this->l('Zip file seems to be broken');
             }
         } else {
             $this->errors[] = $this->l('You must upload or enter a location of your zip');
         }
         if ($archive_uploaded) {
             if (!Tools::ZipExtract($sandbox . '/uploaded.zip', $sandbox . 'uploaded/')) {
                 $this->errors[] = $this->l('Error during zip extraction');
             } else {
                 if (!$this->checkXmlFields($sandbox)) {
                     $this->errors[] = $this->l('Bad configuration file');
                 } else {
                     $imported_theme = $this->importThemeXmlConfig(simplexml_load_file($sandbox . 'uploaded/Config.xml'));
                     if (Validate::isLoadedObject($imported_theme)) {
                         if (!copy($sandbox . 'uploaded/Config.xml', _PS_ROOT_DIR_ . '/config/xml/themes/' . $imported_theme->directory . '.xml')) {
                             $this->errors[] = $this->l('Can\'t copy configuration file');
                         }
                         $target_dir = _PS_ALL_THEMES_DIR_ . $imported_theme->directory;
                         $theme_doc_dir = $target_dir . '/docs/';
                         if (file_exists($theme_doc_dir)) {
                             Tools::deleteDirectory($theme_doc_dir);
                         }
                         $this->recurseCopy($sandbox . 'uploaded/themes/' . $imported_theme->directory, $target_dir);
                         $this->recurseCopy($sandbox . 'uploaded/doc/', $theme_doc_dir);
                         $this->recurseCopy($sandbox . 'uploaded/modules/', _PS_MODULE_DIR_);
                     } else {
                         $this->errors[] = $imported_theme;
                     }
                 }
             }
         }
         Tools::deleteDirectory($sandbox);
         if (count($this->errors) > 0) {
             $this->display = 'importtheme';
         } else {
             Tools::redirectAdmin(Context::getContext()->link->getAdminLink('AdminThemes') . '&conf=18');
         }
     }
 }
开发者ID:dev-lav,项目名称:htdocs,代码行数:81,代码来源:AdminThemesController.php

示例9: configureShop

 /**
  * PROCESS : configureShop
  * Set default shop configuration
  */
 public function configureShop(array $data = array())
 {
     // Clear smarty cache
     $this->clearSmartyCache();
     //clear image cache in tmp folder
     Tools::deleteDirectory(_PS_TMP_IMG_DIR_, false);
     $default_data = array('shop_name' => 'My Shop', 'shop_activity' => '', 'shop_country' => 'us', 'shop_timezone' => 'US/Eastern', 'use_smtp' => false, 'smtp_server' => '', 'smtp_login' => '', 'smtp_password' => '', 'smtp_encryption' => 'off', 'smtp_port' => 25);
     foreach ($default_data as $k => $v) {
         if (!isset($data[$k])) {
             $data[$k] = $v;
         }
     }
     Context::getContext()->shop = new Shop(1);
     Configuration::loadConfiguration();
     $id_country = Country::getByIso($data['shop_country']);
     // Set default configuration
     Configuration::updateGlobalValue('PS_SHOP_DOMAIN', Tools::getHttpHost());
     Configuration::updateGlobalValue('PS_SHOP_DOMAIN_SSL', Tools::getHttpHost());
     Configuration::updateGlobalValue('PS_INSTALL_VERSION', _PS_INSTALL_VERSION_);
     Configuration::updateGlobalValue('PS_LOCALE_LANGUAGE', $this->language->getLanguageIso());
     Configuration::updateGlobalValue('PS_SHOP_NAME', $data['shop_name']);
     Configuration::updateGlobalValue('PS_SHOP_ACTIVITY', $data['shop_activity']);
     Configuration::updateGlobalValue('PS_COUNTRY_DEFAULT', $id_country);
     Configuration::updateGlobalValue('PS_LOCALE_COUNTRY', $data['shop_country']);
     Configuration::updateGlobalValue('PS_TIMEZONE', $data['shop_timezone']);
     Configuration::updateGlobalValue('PS_CONFIGURATION_AGREMENT', (int) $data['configuration_agrement']);
     // Set mails configuration
     Configuration::updateGlobalValue('PS_MAIL_METHOD', $data['use_smtp'] ? 2 : 1);
     Configuration::updateGlobalValue('PS_MAIL_SERVER', $data['smtp_server']);
     Configuration::updateGlobalValue('PS_MAIL_USER', $data['smtp_login']);
     Configuration::updateGlobalValue('PS_MAIL_PASSWD', $data['smtp_password']);
     Configuration::updateGlobalValue('PS_MAIL_SMTP_ENCRYPTION', $data['smtp_encryption']);
     Configuration::updateGlobalValue('PS_MAIL_SMTP_PORT', $data['smtp_port']);
     // Activate rijndael 128 encrypt algorihtm if mcrypt is activated
     Configuration::updateGlobalValue('PS_CIPHER_ALGORITHM', function_exists('mcrypt_encrypt') ? 1 : 0);
     // Set logo configuration
     if (file_exists(_PS_IMG_DIR_ . 'logo.jpg')) {
         list($width, $height) = getimagesize(_PS_IMG_DIR_ . 'logo.jpg');
         Configuration::updateGlobalValue('SHOP_LOGO_WIDTH', round($width));
         Configuration::updateGlobalValue('SHOP_LOGO_HEIGHT', round($height));
     }
     // Active only the country selected by the merchant
     Db::getInstance()->execute('UPDATE ' . _DB_PREFIX_ . 'country SET active = 0 WHERE id_country != ' . (int) $id_country);
     // Set localization configuration
     $version = str_replace('.', '', _PS_VERSION_);
     $version = substr($version, 0, 2);
     $localization_file_content = @Tools::file_get_contents('http://api.prestashop.com/localization/' . $version . '/' . $data['shop_country'] . '.xml');
     if (!@simplexml_load_string($localization_file_content)) {
         $localization_file_content = false;
     }
     if (!$localization_file_content) {
         $localization_file = _PS_ROOT_DIR_ . '/localization/default.xml';
         if (file_exists(_PS_ROOT_DIR_ . '/localization/' . $data['shop_country'] . '.xml')) {
             $localization_file = _PS_ROOT_DIR_ . '/localization/' . $data['shop_country'] . '.xml';
         }
         $localization_file_content = file_get_contents($localization_file);
     }
     $locale = new LocalizationPackCore();
     $locale->loadLocalisationPack($localization_file_content, '', true);
     // Create default employee
     if (isset($data['admin_firstname']) && isset($data['admin_lastname']) && isset($data['admin_password']) && isset($data['admin_email'])) {
         $employee = new Employee();
         $employee->firstname = Tools::ucfirst($data['admin_firstname']);
         $employee->lastname = Tools::ucfirst($data['admin_lastname']);
         $employee->email = $data['admin_email'];
         $employee->passwd = md5(_COOKIE_KEY_ . $data['admin_password']);
         $employee->last_passwd_gen = date('Y-m-d h:i:s', strtotime('-360 minutes'));
         $employee->bo_theme = 'default';
         $employee->active = true;
         $employee->id_profile = 1;
         $employee->id_lang = Configuration::get('PS_LANG_DEFAULT');
         $employee->bo_show_screencast = 1;
         if (!$employee->add()) {
             $this->setError($this->language->l('Cannot create admin account'));
             return false;
         }
     } else {
         $this->setError($this->language->l('Cannot create admin account'));
         return false;
     }
     // Update default contact
     if (isset($data['admin_email'])) {
         Configuration::updateGlobalValue('PS_SHOP_EMAIL', $data['admin_email']);
         $contacts = new Collection('Contact');
         foreach ($contacts as $contact) {
             $contact->email = $data['admin_email'];
             $contact->update();
         }
     }
     return true;
 }
开发者ID:rrameshsat,项目名称:Prestashop,代码行数:95,代码来源:install.php

示例10: postProcessCallback

    public function postProcessCallback()
    {
        $return = false;
        $installed_modules = array();
        foreach ($this->map as $key => $method) {
            $modules = Tools::getValue($key);
            if (strpos($modules, '|')) {
                $modules_list_save = $modules;
                $modules = explode('|', $modules);
            } else {
                $modules = empty($modules) ? false : array($modules);
            }
            $module_errors = array();
            if ($modules) {
                foreach ($modules as $name) {
                    $full_report = null;
                    if ($key == 'update') {
                        if (ConfigurationTest::test_dir('modules/' . $name, true, $full_report)) {
                            Tools::deleteDirectory('../modules/' . $name . '/');
                        } else {
                            $module = Module::getInstanceByName(urldecode($name));
                            $this->errors[] = $this->l(sprintf("Module %s can't be upgraded : ", $module->displayName)) . $full_report;
                            continue;
                        }
                    }
                    // If Addons module, download and unzip it before installing it
                    if (!file_exists('../modules/' . $name . '/' . $name . '.php')) {
                        $filesList = array(array('type' => 'addonsNative', 'file' => Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, 'loggedOnAddons' => 0), array('type' => 'addonsBought', 'file' => Module::CACHE_FILE_CUSTOMER_MODULES_LIST, 'loggedOnAddons' => 1));
                        foreach ($filesList as $f) {
                            if (file_exists(_PS_ROOT_DIR_ . $f['file'])) {
                                $file = $f['file'];
                                $content = Tools::file_get_contents(_PS_ROOT_DIR_ . $file);
                                $xml = @simplexml_load_string($content, null, LIBXML_NOCDATA);
                                foreach ($xml->module as $modaddons) {
                                    if ($name == $modaddons->name && isset($modaddons->id) && ($this->logged_on_addons || $f['loggedOnAddons'] == 0)) {
                                        if ($f['loggedOnAddons'] == 0) {
                                            if (file_put_contents('../modules/' . $modaddons->name . '.zip', Tools::addonsRequest('module', array('id_module' => pSQL($modaddons->id))))) {
                                                $this->extractArchive('../modules/' . $modaddons->name . '.zip', false);
                                            }
                                        }
                                        if ($f['loggedOnAddons'] == 1 && $this->logged_on_addons) {
                                            if (file_put_contents('../modules/' . $modaddons->name . '.zip', Tools::addonsRequest('module', array('id_module' => pSQL($modaddons->id), 'username_addons' => pSQL(trim($this->context->cookie->username_addons)), 'password_addons' => pSQL(trim($this->context->cookie->password_addons)))))) {
                                                $this->extractArchive('../modules/' . $modaddons->name . '.zip', false);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    // Check potential error
                    if (!($module = Module::getInstanceByName(urldecode($name)))) {
                        $this->errors[] = $this->l('Module not found');
                    } elseif ($key == 'install' && $this->tabAccess['add'] !== '1') {
                        $this->errors[] = Tools::displayError('You do not have permission to install this module.');
                    } elseif ($key == 'uninstall' && ($this->tabAccess['delete'] !== '1' || !$module->getPermission('configure'))) {
                        $this->errors[] = Tools::displayError('You do not have permission to delete this module.');
                    } elseif ($key == 'configure' && ($this->tabAccess['edit'] !== '1' || !$module->getPermission('configure') || !Module::isInstalled(urldecode($name)))) {
                        $this->errors[] = Tools::displayError('You do not have permission to configure this module.');
                    } elseif ($key == 'install' && Module::isInstalled($module->name)) {
                        $this->errors[] = Tools::displayError('This module is already installed:') . ' ' . $module->name;
                    } elseif ($key == 'uninstall' && !Module::isInstalled($module->name)) {
                        $this->errors[] = Tools::displayError('This module has already been uninstalled:') . ' ' . $module->name;
                    } else {
                        if ($key == 'update' && !Module::isInstalled($module->name)) {
                            $this->errors[] = Tools::displayError('This module need to be installed in order to be updated:') . ' ' . $module->name;
                        } else {
                            // If we install a module, force temporary global context for multishop
                            if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL && $method != 'getContent') {
                                Context::getContext()->tmpOldShop = clone Context::getContext()->shop;
                                Context::getContext()->shop = new Shop();
                            }
                            //retrocompatibility
                            if (Tools::getValue('controller') != '') {
                                $_POST['tab'] = Tools::safeOutput(Tools::getValue('controller'));
                            }
                            $echo = '';
                            if ($key != 'update') {
                                // We check if method of module exists
                                if (!method_exists($module, $method)) {
                                    throw new PrestaShopException('Method of module can\'t be found');
                                }
                                // Get the return value of current method
                                $echo = $module->{$method}();
                            }
                            // If the method called is "configure" (getContent method), we show the html code of configure page
                            if ($key == 'configure' && Module::isInstalled($module->name)) {
                                if (isset($module->multishop_context)) {
                                    $this->multishop_context = $module->multishop_context;
                                }
                                $backlink = self::$currentIndex . '&token=' . $this->token . '&tab_module=' . $module->tab . '&module_name=' . $module->name;
                                $hooklink = 'index.php?tab=AdminModulesPositions&token=' . Tools::getAdminTokenLite('AdminModulesPositions') . '&show_modules=' . (int) $module->id;
                                $tradlink = 'index.php?tab=AdminTranslations&token=' . Tools::getAdminTokenLite('AdminTranslations') . '&type=modules&lang=';
                                $toolbar = '<table class="table" cellpadding="0" cellspacing="0" style="margin:auto;text-align:center"><tr>
									<th>' . $this->l('Module') . ' <span style="color: green;">' . $module->name . '</span></th>
									<th><a href="' . $backlink . '" style="padding:5px 10px">' . $this->l('Back') . '</a></th>
									<th><a href="' . $hooklink . '" style="padding:5px 10px">' . $this->l('Manage hooks') . '</a></th>
									<th style="padding:5px 10px">' . $this->l('Manage translations') . ' ';
                                foreach (Language::getLanguages(false) as $language) {
                                    $toolbar .= '<a href="' . $tradlink . $language['iso_code'] . '#' . $module->name . '" style="margin-left:5px"><img src="' . _THEME_LANG_DIR_ . $language['id_lang'] . '.jpg" alt="' . $language['iso_code'] . '" title="' . $language['iso_code'] . '" /></a>';
//.........这里部分代码省略.........
开发者ID:FAVHYAN,项目名称:a3workout,代码行数:101,代码来源:AdminModulesController.php

示例11: extractTheme

 protected function extractTheme($theme_zip_file, $sandbox)
 {
     if (!Tools::ZipExtract($theme_zip_file, $sandbox . 'uploaded/')) {
         $this->errors[] = $this->l('Error during zip extraction');
     } else {
         if (!$this->checkXmlFields($sandbox)) {
             $this->errors[] = $this->l('Bad configuration file');
         } else {
             $imported_theme = $this->importThemeXmlConfig(simplexml_load_file($sandbox . 'uploaded/Config.xml'));
             foreach ($imported_theme as $theme) {
                 if (Validate::isLoadedObject($theme)) {
                     if (!copy($sandbox . 'uploaded/Config.xml', _PS_ROOT_DIR_ . '/config/xml/themes/' . $theme->directory . '.xml')) {
                         $this->errors[] = $this->l('Can\'t copy configuration file');
                     }
                     $target_dir = _PS_ALL_THEMES_DIR_ . $theme->directory;
                     $theme_doc_dir = $target_dir . '/docs/';
                     if (file_exists($theme_doc_dir)) {
                         Tools::deleteDirectory($theme_doc_dir);
                     }
                     Tools::recurseCopy($sandbox . 'uploaded/themes/' . $theme->directory, $target_dir);
                     Tools::recurseCopy($sandbox . 'uploaded/doc/', $theme_doc_dir);
                     Tools::recurseCopy($sandbox . 'uploaded/modules/', _PS_MODULE_DIR_);
                 } else {
                     $this->errors[] = $theme;
                 }
             }
         }
     }
     if (!count($this->errors)) {
         return $theme->directory;
     }
     return false;
 }
开发者ID:carloslastresDev,项目名称:HealthyTaiwan_UsingPrestaShop,代码行数:33,代码来源:AdminThemesController.php

示例12: deleteCacheDirectory

 /**
  * Delete cache directory
  */
 public static function deleteCacheDirectory()
 {
     Tools::deleteDirectory(_PS_CACHEFS_DIRECTORY_, false);
 }
开发者ID:toufikadfab,项目名称:PrestaShop-1.5,代码行数:7,代码来源:CacheFs.php

示例13: addProductImages3D

 public function addProductImages3D($product_id, $pack = "3d_image_pack", $dirs = "images3d")
 {
     if (isset($_FILES[$pack]) && $_FILES[$pack] && $_FILES[$pack]['name']) {
         if ($error = checkImageUploadError($_FILES[$pack])) {
             $this->_errors[] = $error;
         }
         if (!sizeof($this->_errors) and !empty($_FILES[$pack]['tmp_name'])) {
             try {
                 if (!($zipfile = tempnam(_PS_TMP_IMG_DIR_, 'PS')) or !move_uploaded_file($_FILES[$pack]['tmp_name'], $zipfile)) {
                     return false;
                     //throw new Exception(Tools::displayError('An error occurred during the ZIP file upload.'));
                 }
                 $subdir = _PS_IMG_DIR_ . $dirs . '/' . $product_id . '/';
                 Tools::deleteDirectory($subdir);
                 if (!Tools::ZipExtract($zipfile, $subdir)) {
                     throw new Exception(Tools::displayError('An error occurred while unzipping your file.'));
                 }
                 $types = array('.gif' => 'image/gif', '.jpeg' => 'image/jpeg', '.jpg' => 'image/jpg', '.png' => 'image/png');
                 $files = array_slice(scandir($subdir), 2);
                 foreach ($files as $file) {
                     if (filesize($subdir . $file) > $this->maxImageSize) {
                         throw new Exception(Tools::displayError('Image is too large') . ' (' . filesize($subdir . $file) / 1000 . Tools::displayError('kB') . '). ' . Tools::displayError('Maximum allowed:') . ' ' . $this->maxImageSize / 1000 . Tools::displayError('kB'));
                     }
                     $ext = substr($file, -4) == 'jpeg' ? '.jpeg' : substr($file, -4);
                     $type = isset($types[$ext]) ? $types[$ext] : '';
                     if (!isPicture(array('tmp_name' => $subdir . $file, 'type' => $type))) {
                         throw new Exception(Tools::displayError('Image format not recognized, allowed formats are: .gif, .jpg, .png'));
                     }
                     imageResize($subdir . $file, $subdir . $file, 600, 600);
                     //Module::hookExec('watermark', array('id_image' => $image->id, 'id_product' => $image->id_product));
                 }
                 $images_3d_count = count($files);
             } catch (Exception $e) {
                 $error = $e->getMessage();
                 $this->_errors[] = $error;
                 Tools::deleteDirectory($subdir);
             }
             unlink($zipfile);
         }
     }
 }
开发者ID:WhisperingTree,项目名称:etagerca,代码行数:41,代码来源:images3d.php

示例14: ajaxProcessRestoreFiles

 /**
  * ajaxProcessRestoreFiles restore the previously saved files, 
  * and delete files that weren't archived
  *
  * @return boolean true if succeed
  */
 public function ajaxProcessRestoreFiles()
 {
     // loop
     $this->next = 'restoreFiles';
     if (!file_exists($this->autoupgradePath . DIRECTORY_SEPARATOR . $this->fromArchiveFileList) || !file_exists($this->autoupgradePath . DIRECTORY_SEPARATOR . $this->toRemoveFileList)) {
         // cleanup current PS tree
         $fromArchive = $this->_listArchivedFiles($this->autoupgradePath . DIRECTORY_SEPARATOR . $this->restoreFilesFilename);
         foreach ($fromArchive as $k => $v) {
             $fromArchive[$k] = '/' . $v;
         }
         file_put_contents($this->autoupgradePath . DIRECTORY_SEPARATOR . $this->fromArchiveFileList, serialize($fromArchive));
         // get list of files to remove
         $toRemove = $this->_listFilesToRemove();
         $this->nextQuickInfo[] = sprintf($this->l('%s file(s) will be removed before restoring backup files'), count($toRemove));
         file_put_contents($this->autoupgradePath . DIRECTORY_SEPARATOR . $this->toRemoveFileList, serialize($toRemove));
         if ($fromArchive === false || $toRemove === false) {
             if (!$fromArchive) {
                 $this->nextQuickInfo[] = '[ERROR] ' . sprintf($this->l('backup file %s does not exists'), $this->fromArchiveFileList);
             }
             if (!$toRemove) {
                 $this->nextQuickInfo[] = '[ERROR] ' . sprintf($this->l('file "%s" does not exists'), $this->toRemoveFileList);
             }
             $this->nextDesc = $this->l('Unable to remove upgraded files.');
             $this->next = 'error';
             return false;
         }
     }
     // first restoreFiles step
     if (!isset($toRemove)) {
         $toRemove = unserialize(file_get_contents($this->autoupgradePath . DIRECTORY_SEPARATOR . $this->toRemoveFileList));
     }
     if (count($toRemove) > 0) {
         for ($i = 0; $i < self::$loopRemoveUpgradedFiles; $i++) {
             if (count($toRemove) <= 0) {
                 $this->stepDone = true;
                 $this->status = 'ok';
                 $this->next = 'restoreFiles';
                 $this->nextDesc = $this->l('Files from upgrade has been removed.');
                 $this->nextQuickInfo[] = $this->l('files from upgrade has been removed.');
                 file_put_contents($this->autoupgradePath . DIRECTORY_SEPARATOR . $this->toRemoveFileList, serialize($toRemove));
                 return true;
             } else {
                 $filename = array_shift($toRemove);
                 $file = rtrim($this->prodRootDir, DIRECTORY_SEPARATOR) . $filename;
                 if (file_exists($file)) {
                     if (is_file($file) && @unlink($file)) {
                         $this->nextQuickInfo[] = sprintf('%s removed', $filename);
                     } else {
                         if (!file_exists($file)) {
                             $this->nextQuickInfo[] = sprintf('[NOTICE] %s does not exists', $filename);
                         } elseif (is_dir($file)) {
                             Tools::deleteDirectory($file, true);
                             $this->nextQuickInfo[] = sprintf('[NOTICE] %s directory deleted', $filename);
                         } else {
                             $this->next = 'error';
                             $this->nextDesc = sprintf($this->l('error when removing %1$s'), $filename);
                             $this->nextQuickInfo[] = sprintf($this->l('%s not removed'), $filename);
                             return false;
                         }
                     }
                 }
             }
         }
         file_put_contents($this->autoupgradePath . DIRECTORY_SEPARATOR . $this->toRemoveFileList, serialize($toRemove));
         $this->nextDesc = sprintf($this->l('%s left to remove'), count($toRemove));
         $this->next = 'restoreFiles';
         return true;
     }
     // very second restoreFiles step : extract backup
     // if (!isset($fromArchive))
     //	$fromArchive = unserialize(file_get_contents($this->autoupgradePath.DIRECTORY_SEPARATOR.$this->fromArchiveFileList));
     $filepath = $this->autoupgradePath . DIRECTORY_SEPARATOR . $this->restoreFilesFilename;
     $destExtract = $this->prodRootDir;
     if ($res = $this->ZipExtract($filepath, $destExtract)) {
         $this->next = 'restoreDb';
         $this->nextDesc = $this->l('Files restored. Now restoring database ...');
         // get new file list
         $this->nextQuickInfo[] = $this->l('Files restored.');
         // once it's restored, do not delete the archive file. This has to be done manually
         // and we do not empty the var, to avoid infinite loop.
         return true;
     } else {
         $this->next = "error";
         $this->nextDesc = sprintf($this->l('unable to extract %1$s into %2$s .'), $filepath, $destExtract);
         return false;
     }
     return true;
 }
开发者ID:nicolasjeol,项目名称:hec-ecommerce,代码行数:94,代码来源:AdminSelfUpgrade.php

示例15: tearDownAfterClass

 public static function tearDownAfterClass()
 {
     \Tools::deleteDirectory(_PS_CACHE_DIR_ . 'cldr-test');
 }
开发者ID:M03G,项目名称:PrestaShop,代码行数:4,代码来源:RepositoryTest.php


注:本文中的Tools::deleteDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。