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


PHP Tools::copy方法代码示例

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


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

示例1: psmHelperIntegrateFile

 function psmHelperIntegrateFile($target, $modules)
 {
     $version = '';
     $origin = '';
     $files = array();
     foreach ($modules as $module) {
         $file = _PS_MODULE_DIR_ . $module . '/' . $target;
         if (file_exists($file)) {
             $content = Tools::file_get_contents($file);
             $ver = ($start = strpos($content, 'PSM_VERSION[')) !== false && ($end = strpos($content, ']', $start)) !== false ? Tools::substr($content, $start + 12, $end - $start - 12) : false;
             if ($ver && Tools::version_compare($ver, $version, '>')) {
                 $version = $ver;
                 $origin = $file;
             }
             $files[$file] = $ver;
         }
     }
     foreach ($files as $file => $ver) {
         if (Tools::version_compare($version, $ver, '>') && $origin != $file) {
             Tools::copy($origin, $file);
         }
     }
 }
开发者ID:Oldwo1f,项目名称:yakaboutique,代码行数:23,代码来源:psm_helper_integrate.php

示例2: importFileSelectColumn

 public static function importFileSelectColumn(array $file, $media, $campaign_id, $module_name)
 {
     switch ((string) $media) {
         case 'sms':
             $media_letter = 'S';
             $redirect_step = 3;
             break;
         case 'fax':
             $media_letter = 'F';
             $redirect_step = 4;
             break;
         default:
             Tools::redirectAdmin('index.php?controller=AdminMarketingX&token=' . Tools::getAdminTokenLite('AdminMarketingX'));
             exit;
     }
     $error = $file['error'];
     if ($error === 0) {
         $file_path = $file['tmp_name'];
         $file_copy = _PS_MODULE_DIR_ . (string) $module_name . DIRECTORY_SEPARATOR . 'import' . DIRECTORY_SEPARATOR . basename($file_path) . '_copy.csv';
         if (file_exists($file_path)) {
             Tools::copy($file_path, $file_copy);
         } else {
             return false;
         }
         Db::getInstance()->update('expressmailing_' . $media, array('campaign_date_update' => date('Y-m-d H:i:s'), 'path_to_import' => str_replace('\\', '/', $file_copy)), 'campaign_id = ' . (int) $campaign_id);
         Tools::redirectAdmin('index.php?controller=AdminMarketing' . $media_letter . 'Step' . $redirect_step . '&campaign_id=' . (int) $campaign_id . '&token=' . Tools::getAdminTokenLite('AdminMarketing' . $media_letter . 'Step' . $redirect_step));
         exit;
     }
     return false;
 }
开发者ID:Oldwo1f,项目名称:yakaboutique,代码行数:30,代码来源:em_tools.php

示例3: copyImg15

function copyImg15($id_entity, $id_image = null, $url, $entity = 'products')
{
    $tmpfile = tempnam(_PS_TMP_IMG_DIR_, 'ps_import');
    //fichier tempo vide
    $watermark_types = explode(',', Configuration::get('WATERMARK_TYPES'));
    switch ($entity) {
        default:
        case 'products':
            $image_obj = new Image($id_image);
            $path = $image_obj->getPathForCreation();
            break;
        case 'categories':
            $path = _PS_CAT_IMG_DIR_ . (int) $id_entity;
            break;
    }
    $url = str_replace(' ', '%20', trim($url));
    // Evaluate the memory required to resize the image: if it's too much, you can't resize it.
    if (!ImageManager::checkImageMemoryLimit($url)) {
        return false;
    }
    //Echo("in routine url, before the copy");
    // 'file_exists' doesn't work on distant file, and getimagesize make the import slower.
    // Just hide the warning, the traitment will be the same.
    //echo(" - Copy image to:".$tmpfile." and then resize in :".$path);
    echo " register_globals: " . ini_get('register_globals');
    echo " safe_mode: " . ini_get('safe_mode');
    echo " allow_url_fopen: " . ini_get('allow_url_fopen');
    //if(isset($sourceFile))
    //{
    //$array_img = explode('/',$sourceFile);
    //}
    //if(copy($_POST['source'],"img/".end($array_img))){
    //echo(" - Copy ".$sourceFile." image to:"._PS_IMG_DIR_.end($array_img)." and then resize in :".$path);
    //if(copy($sourceFile,_PS_IMG_DIR_.end($array_img)))
    if ($version < 16000) {
        if (@copy($url, $tmpfile)) {
            ImageManager::resize($tmpfile, $path . '.jpg');
            //ImageManager::resize(_PS_IMG_DIR_.end($array_img), $path.'.jpg');
            $images_types = ImageType::getImagesTypes($entity);
            foreach ($images_types as $image_type) {
                ImageManager::resize($tmpfile, $path . '-' . stripslashes($image_type['name']) . '.jpg', $image_type['width'], $image_type['height']);
            }
            //ImageManager::resize(_PS_IMG_DIR_.end($array_img), $path.'-'.stripslashes($image_type['name']).'.jpg', $image_type['width'], $image_type['height']);
            if (in_array($image_type['id_image_type'], $watermark_types)) {
                Hook::exec('actionWatermark', array('id_image' => $id_image, 'id_product' => $id_entity));
            }
        } else {
            echo " - @copy failed, please check Apache parameters like safe_mode=off, register_globals=off, allows_url_fopen=true and writting right in /img/tmp and img/p folders";
            unlink($tmpfile);
            return false;
        }
    } else {
        if (Tools::copy($url, $tmpfile)) {
            ImageManager::resize($tmpfile, $path . '.jpg');
            //ImageManager::resize(_PS_IMG_DIR_.end($array_img), $path.'.jpg');
            $images_types = ImageType::getImagesTypes($entity);
            foreach ($images_types as $image_type) {
                ImageManager::resize($tmpfile, $path . '-' . stripslashes($image_type['name']) . '.jpg', $image_type['width'], $image_type['height']);
            }
            //ImageManager::resize(_PS_IMG_DIR_.end($array_img), $path.'-'.stripslashes($image_type['name']).'.jpg', $image_type['width'], $image_type['height']);
            if (in_array($image_type['id_image_type'], $watermark_types)) {
                Hook::exec('actionWatermark', array('id_image' => $id_image, 'id_product' => $id_entity));
            }
        } else {
            echo " - @copy failed, please check Apache parameters like safe_mode=off, register_globals=off, allows_url_fopen=true and writting right in /img/tmp and img/p folders";
            unlink($tmpfile);
            return false;
        }
    }
    unlink($tmpfile);
    return true;
}
开发者ID:EliosIT,项目名称:PS_AchatFilet,代码行数:72,代码来源:images_category_upload_resizing.php

示例4: duplicate

    public function duplicate()
    {
        if (!Validate::isLoadedObject($this)) {
            return false;
        }
        $cart = new Cart($this->id);
        $cart->id = null;
        $cart->id_shop = $this->id_shop;
        $cart->id_shop_group = $this->id_shop_group;
        if (!Customer::customerHasAddress((int) $cart->id_customer, (int) $cart->id_address_delivery)) {
            $cart->id_address_delivery = (int) Address::getFirstCustomerAddressId((int) $cart->id_customer);
        }
        if (!Customer::customerHasAddress((int) $cart->id_customer, (int) $cart->id_address_invoice)) {
            $cart->id_address_invoice = (int) Address::getFirstCustomerAddressId((int) $cart->id_customer);
        }
        if ($cart->id_customer) {
            $cart->secure_key = Cart::$_customer->secure_key;
        }
        $cart->add();
        if (!Validate::isLoadedObject($cart)) {
            return false;
        }
        $success = true;
        $products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'cart_product` WHERE `id_cart` = ' . (int) $this->id);
        $product_gift = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT cr.`gift_product`, cr.`gift_product_attribute` FROM `' . _DB_PREFIX_ . 'cart_rule` cr LEFT JOIN `' . _DB_PREFIX_ . 'order_cart_rule` ocr ON (ocr.`id_order` = ' . (int) $this->id . ') WHERE ocr.`id_cart_rule` = cr.`id_cart_rule`');
        $id_address_delivery = Configuration::get('PS_ALLOW_MULTISHIPPING') ? $cart->id_address_delivery : 0;
        foreach ($products as $product) {
            if ($id_address_delivery) {
                if (Customer::customerHasAddress((int) $cart->id_customer, $product['id_address_delivery'])) {
                    $id_address_delivery = $product['id_address_delivery'];
                }
            }
            foreach ($product_gift as $gift) {
                if (isset($gift['gift_product']) && isset($gift['gift_product_attribute']) && (int) $gift['gift_product'] == (int) $product['id_product'] && (int) $gift['gift_product_attribute'] == (int) $product['id_product_attribute']) {
                    $product['quantity'] = (int) $product['quantity'] - 1;
                }
            }
            $success &= $cart->updateQty((int) $product['quantity'], (int) $product['id_product'], (int) $product['id_product_attribute'], null, 'up', (int) $id_address_delivery, new Shop((int) $cart->id_shop), false);
        }
        // Customized products
        $customs = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
			SELECT *
			FROM ' . _DB_PREFIX_ . 'customization c
			LEFT JOIN ' . _DB_PREFIX_ . 'customized_data cd ON cd.id_customization = c.id_customization
			WHERE c.id_cart = ' . (int) $this->id);
        // Get datas from customization table
        $customs_by_id = array();
        foreach ($customs as $custom) {
            if (!isset($customs_by_id[$custom['id_customization']])) {
                $customs_by_id[$custom['id_customization']] = array('id_product_attribute' => $custom['id_product_attribute'], 'id_product' => $custom['id_product'], 'quantity' => $custom['quantity']);
            }
        }
        // Insert new customizations
        $custom_ids = array();
        foreach ($customs_by_id as $customization_id => $val) {
            Db::getInstance()->execute('
				INSERT INTO `' . _DB_PREFIX_ . 'customization` (id_cart, id_product_attribute, id_product, `id_address_delivery`, quantity, `quantity_refunded`, `quantity_returned`, `in_cart`)
				VALUES(' . (int) $cart->id . ', ' . (int) $val['id_product_attribute'] . ', ' . (int) $val['id_product'] . ', ' . (int) $id_address_delivery . ', ' . (int) $val['quantity'] . ', 0, 0, 1)');
            $custom_ids[$customization_id] = Db::getInstance(_PS_USE_SQL_SLAVE_)->Insert_ID();
        }
        // Insert customized_data
        if (count($customs)) {
            $first = true;
            $sql_custom_data = 'INSERT INTO ' . _DB_PREFIX_ . 'customized_data (`id_customization`, `type`, `index`, `value`) VALUES ';
            foreach ($customs as $custom) {
                if (!$first) {
                    $sql_custom_data .= ',';
                } else {
                    $first = false;
                }
                $customized_value = $custom['value'];
                if ((int) $custom['type'] == 0) {
                    $customized_value = md5(uniqid(rand(), true));
                    Tools::copy(_PS_UPLOAD_DIR_ . $custom['value'], _PS_UPLOAD_DIR_ . $customized_value);
                    Tools::copy(_PS_UPLOAD_DIR_ . $custom['value'] . '_small', _PS_UPLOAD_DIR_ . $customized_value . '_small');
                }
                $sql_custom_data .= '(' . (int) $custom_ids[$custom['id_customization']] . ', ' . (int) $custom['type'] . ', ' . (int) $custom['index'] . ', \'' . pSQL($customized_value) . '\')';
            }
            Db::getInstance()->execute($sql_custom_data);
        }
        return array('cart' => $cart, 'success' => $success);
    }
开发者ID:prestanesia,项目名称:PrestaShop,代码行数:82,代码来源:Cart.php

示例5: installFixtures

 /**
  * PROCESS : installFixtures
  * Install fixtures (E.g. demo products)
  */
 public function installFixtures($entity = null, array $data = array())
 {
     $fixtures_path = _PS_INSTALL_FIXTURES_PATH_ . 'apple/';
     $fixtures_name = 'apple';
     $zip_file = _PS_ROOT_DIR_ . '/download/fixtures.zip';
     $temp_dir = _PS_ROOT_DIR_ . '/download/fixtures/';
     // try to download fixtures if no low memory mode
     if ($entity === null) {
         if (Tools::copy('http://api.prestashop.com/fixtures/' . $data['shop_country'] . '/' . $data['shop_activity'] . '/fixtures.zip', $zip_file)) {
             Tools::deleteDirectory($temp_dir, true);
             if (Tools::ZipTest($zip_file)) {
                 if (Tools::ZipExtract($zip_file, $temp_dir)) {
                     $files = scandir($temp_dir);
                     if (count($files)) {
                         foreach ($files as $file) {
                             if (!preg_match('/^\\./', $file) && is_dir($temp_dir . $file . '/')) {
                                 $fixtures_path = $temp_dir . $file . '/';
                                 $fixtures_name = $file;
                                 break;
                             }
                         }
                     }
                 }
             }
         }
     }
     // Load class (use fixture class if one exists, or use InstallXmlLoader)
     if (file_exists($fixtures_path . '/install.php')) {
         require_once $fixtures_path . '/install.php';
         $class = 'InstallFixtures' . Tools::toCamelCase($fixtures_name);
         if (!class_exists($class, false)) {
             $this->setError($this->language->l('Fixtures class "%s" not found', $class));
             return false;
         }
         $xml_loader = new $class();
         if (!$xml_loader instanceof InstallXmlLoader) {
             $this->setError($this->language->l('"%s" must be an instane of "InstallXmlLoader"', $class));
             return false;
         }
     } else {
         $xml_loader = new InstallXmlLoader();
     }
     // Install XML data (data/xml/ folder)
     $xml_loader->setFixturesPath($fixtures_path);
     if (isset($this->xml_loader_ids) && $this->xml_loader_ids) {
         $xml_loader->setIds($this->xml_loader_ids);
     }
     $languages = array();
     foreach (Language::getLanguages(false) as $lang) {
         $languages[$lang['id_lang']] = $lang['iso_code'];
     }
     $xml_loader->setLanguages($languages);
     if ($entity) {
         $xml_loader->populateEntity($entity);
     } else {
         $xml_loader->populateFromXmlFiles();
         Tools::deleteDirectory($temp_dir, true);
         @unlink($zip_file);
     }
     if ($errors = $xml_loader->getErrors()) {
         $this->setError($errors);
         return false;
     }
     // IDS from xmlLoader are stored in order to use them for fixtures
     $this->xml_loader_ids = $xml_loader->getIds();
     unset($xml_loader);
     // Index products in search tables
     Search::indexation(true);
     return true;
 }
开发者ID:toufikadfab,项目名称:PrestaShop-1.5,代码行数:74,代码来源:install.php

示例6: installExternalCarrier

 public static function installExternalCarrier($config)
 {
     $carrier = new Carrier();
     $carrier->hydrate($config);
     $carrier->name = $config['name'];
     $carrier->id_zone = $config['id_zone'];
     $carrier->active = $config['active'];
     $carrier->deleted = $config['deleted'];
     $carrier->delay = $config['delay'];
     $carrier->shipping_handling = $config['shipping_handling'];
     $carrier->range_behavior = $config['range_behavior'];
     $carrier->is_module = $config['is_module'];
     $carrier->shipping_external = $config['shipping_external'];
     $carrier->external_module_name = $config['external_module_name'];
     $carrier->need_range = $config['need_range'];
     $carrier->setTaxRulesGroup($config['id_tax_rules_group'], true);
     $languages = Language::getLanguages(true);
     foreach ($languages as $language) {
         if ($language['iso_code'] == 'lv') {
             $carrier->delay[(int) $language['id_lang']] = $config['delay'][$language['iso_code']];
         }
         if ($language['iso_code'] == 'lt') {
             $carrier->delay[(int) $language['id_lang']] = $config['delay'][$language['iso_code']];
         }
         if ($language['iso_code'] == Language::getIsoById(Configuration::get('PS_LANG_DEFAULT'))) {
             $carrier->delay[(int) $language['id_lang']] = $config['delay'][$language['iso_code']];
         }
     }
     if ($carrier->add()) {
         $groups = Group::getGroups(true);
         foreach ($groups as $group) {
             Db::getInstance()->autoExecute(_DB_PREFIX_ . 'carrier_group', array('id_carrier' => (int) $carrier->id, 'id_group' => (int) $group['id_group']), 'INSERT');
         }
         // $range_price = new RangePrice();
         // $range_price->id_carrier = $carrier->id;
         // $range_price->delimiter1 = '0';
         // $range_price->delimiter2 = '10000';
         // $range_price->add();
         // $range_weight = new RangeWeight();
         // $range_weight->id_carrier = $carrier->id;
         // $range_weight->delimiter1 = '0';
         // $range_weight->delimiter2 = '10000';
         // $range_weight->add();
         // Add weight ranges to carrier
         $rangePrices = array();
         foreach ($config['ranges'] as $range) {
             $rangeWeight = new RangeWeight();
             $rangeWeight->hydrate(array('id_carrier' => $carrier->id, 'delimiter1' => (double) $range['delimiter1'], 'delimiter2' => (double) $range['delimiter2']));
             $rangeWeight->add();
             // Save range ID and price and set it after the Zones have been added
             $rangePrices[] = array('id_range_weight' => $rangeWeight->id, 'price' => $range['price']);
         }
         // Update prices in delivery table for each range (need IDs)
         foreach ($rangePrices as $rangePrice) {
             $data = array('price' => $rangePrice['price']);
             $where = 'id_range_weight = ' . $rangePrice['id_range_weight'];
             Db::getInstance()->update('delivery', $data, $where);
         }
         // Add Europe for EVERY carrier range
         // Automatically creates rows in delivery table, price is 0
         $id_zone_europe = Zone::getIdByName('Europe');
         $carrier->addZone($id_zone_europe ? $id_zone_europe : 1);
         // Copy Logo
         if (!Tools::copy(dirname(__FILE__) . '/logo.png', _PS_SHIP_IMG_DIR_ . '/' . (int) $carrier->id . '.png')) {
             return false;
         }
         DpdCarrierOptions::setCarrierOptions((int) $carrier->id, (int) $carrier->id, $config['type']);
         // Return ID Carrier
         return (int) $carrier->id;
     }
     return false;
 }
开发者ID:uab-balticode,项目名称:dpd-shipping-module-prestashop-2,代码行数:72,代码来源:dynamicparceldistribution.php

示例7: Image

 $product_has_images = (bool) Image::getImages($id_lang, $product->id);
 $image = new Image();
 $image->id_product = (int) $product->id;
 $image->position = Image::getHighestPosition($product->id) + 1;
 $image->cover = !$product_has_images ? true : false;
 $field_error = $image->validateFields(UNFRIENDLY_ERROR, true);
 $lang_field_error = $image->validateFieldsLang(UNFRIENDLY_ERROR, true);
 $id_shop_list = array();
 $errors = array();
 $warnings = array();
 $id_shop_list[] = $product->id_shop_default;
 if ($image->add()) {
     $image->associateTo($id_shop_list);
     $image->getPathForCreation();
     $image_final = $image->getPathForCreation() . '.jpg';
     if (Tools::copy($url, $image_final)) {
         $tgt_width = $tgt_height = 0;
         $src_width = $src_height = 0;
         $previous_path = null;
         $path_infos = array();
         $images_types = ImageType::getImagesTypes('products', true);
         foreach ($images_types as $image_type) {
             if (ImageManager::resize($image_final, $image->getPathForCreation() . '-' . stripslashes($image_type['name']) . '.jpg', $image_type['width'], $image_type['height'], 'jpg', false, $error, $tgt_width, $tgt_height, 5, $src_width, $src_height)) {
                 if (is_file(_PS_TMP_IMG_DIR_ . 'product_mini_' . (int) $product->id . '.jpg')) {
                     unlink(_PS_TMP_IMG_DIR_ . 'product_mini_' . (int) $product->id . '.jpg');
                 }
                 if (is_file(_PS_TMP_IMG_DIR_ . 'product_mini_' . (int) $product->id . '_' . (int) Context::getContext()->shop->id . '.jpg')) {
                     unlink(_PS_TMP_IMG_DIR_ . 'product_mini_' . (int) $product->id . '_' . (int) Context::getContext()->shop->id . '.jpg');
                 }
             }
         }
开发者ID:abdoumej,项目名称:libsamy,代码行数:31,代码来源:import.php

示例8: createNewOrderStates

 public function createNewOrderStates()
 {
     $order_states = $this->getMediafinanzOrderStates();
     //check shop for custom order states
     foreach ($order_states as $order_state_key => $order_state) {
         $create_os = false;
         $create_os_id = 0;
         if ((int) Configuration::get($order_state_key) > 0) {
             $os = new OrderState((int) Configuration::get($order_state_key));
             if (!Validate::isLoadedObject($os)) {
                 $create_os = true;
                 $create_os_id = (int) Configuration::get($order_state_key);
             }
         } else {
             $create_os = true;
         }
         if ($create_os == true) {
             $os = new OrderState();
             if ($create_os_id > 0) {
                 $os->id = $create_os_id;
             }
             $langs = Language::getLanguages();
             foreach ($langs as $lang) {
                 $os->name[$lang['id_lang']] = $order_state['name'];
                 $os->template[$lang['id_lang']] = $order_state['template'];
             }
             $os->color = $order_state['color'];
             $os->send_email = $order_state['send_email'];
             $os->unremovable = 1;
             $os->hidden = 0;
             $os->logable = 0;
             $os->delivery = 0;
             $os->shipped = 0;
             $os->paid = 0;
             $os->pdf_invoice = 1;
             $os->module_name = $this->name;
             if ($os->add()) {
                 $source = dirname(__FILE__) . '/../../img/os/' . Configuration::get('PS_OS_CHEQUE') . '.gif';
                 $destination = dirname(__FILE__) . '/../../img/os/' . (int) $os->id . '.gif';
                 Tools::copy($source, $destination);
             }
             Configuration::updateValue($order_state_key, $os->id);
         }
     }
     return true;
 }
开发者ID:jBangiev,项目名称:mediafinanz,代码行数:46,代码来源:mediafinanz.php

示例9: copyFileToStorage

 /**
  * Copy a remote or local file to the local campaign storage
  * @param string $url
  * @param string $filename The name of the resulting file
  * @return mixed Null if fail or a string containing the path of the resulting image.
  */
 private function copyFileToStorage($url, $filename = null)
 {
     $dest = $this->module->getPreviewFolder();
     $dest .= $this->campaign_id . DIRECTORY_SEPARATOR;
     if (!Tools::file_exists_no_cache($dest)) {
         mkdir($dest, 0777, true);
         Tools::copy(_PS_MODULE_DIR_ . 'expressmailing/index.php', $dest . 'index.php');
     }
     if ($filename) {
         $dest .= (string) $filename;
     } else {
         $dest .= basename((string) $url);
     }
     $dest = urldecode($dest);
     $dest = str_replace(' ', '_', $dest);
     $dest = EMTools::removeAccents($dest);
     if (($pos = strpos($dest, '?')) !== false) {
         $dest = Tools::substr($dest, 0, $pos);
     }
     if (function_exists('curl_version')) {
         $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'Mozilla/5.0';
         $ch = curl_init((string) $url);
         curl_setopt($ch, CURLOPT_HEADER, 0);
         curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
         curl_setopt($ch, CURLOPT_CRLF, 1);
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
         $raw = curl_exec($ch);
         curl_close($ch);
         if (file_exists($dest)) {
             unlink($dest);
         }
         $fp = fopen($dest, 'x');
         fwrite($fp, $raw);
         fclose($fp);
         if (file_exists($dest)) {
             return $dest;
         }
     } else {
         if (Tools::copy((string) $url, $dest)) {
             return $dest;
         }
     }
     return null;
 }
开发者ID:Oldwo1f,项目名称:yakaboutique,代码行数:53,代码来源:adminmarketingestep3.php

示例10: installModuleTab

 public static function installModuleTab($module_name, $title, $class_sfx = '', $parent = '')
 {
     $class = 'Admin' . Tools::ucfirst($module_name) . Tools::ucfirst($class_sfx);
     @Tools::copy(_PS_MODULE_DIR_ . $module_name . '/logo.gif', _PS_IMG_DIR_ . 't/' . $class . '.gif');
     if ($parent == '') {
         $position = Tab::getCurrentTabId();
     } else {
         $position = Tab::getIdFromClassName($parent);
     }
     $tab1 = new Tab();
     $tab1->class_name = $class;
     $tab1->module = $module_name;
     $tab1->id_parent = call_user_func('int' . 'val', $position);
     $langs = Language::getLanguages(false);
     foreach ($langs as $l) {
         $tab1->name[$l['id_lang']] = $title;
     }
     if ($parent == -1) {
         $tab1->id_parent = -1;
         $id_tab1 = $tab1->add();
     } else {
         $id_tab1 = $tab1->add(true, false);
     }
     unset($id_tab1);
 }
开发者ID:pacxs,项目名称:pacxscom,代码行数:25,代码来源:LeoManagewidgetsInstall.php

示例11: makeBackup

 /**
  * Create Backup file of changing content
  *
  * @param  string $target patch to file
  * @return boolean - true if success
  */
 public function makeBackup($target = null)
 {
     if (empty($target)) {
         $target = $this->target;
     }
     $this->backup_time_stamp = time();
     $parent = $target;
     $children = $target . $this->backup_prefix . $this->backup_time_stamp;
     if (!Tools::copy($parent, $children)) {
         $this->error_msg[] = error_get_last();
         return false;
     } else {
         if (filesize($parent) === filesize($children)) {
             return true;
         } else {
             return false;
         }
     }
 }
开发者ID:uab-balticode,项目名称:dpd-shipping-module-prestashop-2,代码行数:25,代码来源:AdminOrdersController.php

示例12: copyImg

 /**
  * copyImg copy an image located in $url and save it in a path
  * according to $entity->$id_entity .
  * $id_image is used if we need to add a watermark
  *
  * @param int $id_entity id of product or category (set in entity)
  * @param int $id_image (default null) id of the image if watermark enabled.
  * @param string $url path or url to use
  * @param string entity 'products' or 'categories'
  * @return void
  */
 protected static function copyImg($id_entity, $id_image = null, $url, $entity = 'products')
 {
     $tmpfile = tempnam(_PS_TMP_IMG_DIR_, 'ps_import');
     $watermark_types = explode(',', Configuration::get('WATERMARK_TYPES'));
     switch ($entity) {
         default:
         case 'products':
             $image_obj = new Image($id_image);
             $path = $image_obj->getPathForCreation();
             break;
         case 'categories':
             $path = _PS_CAT_IMG_DIR_ . (int) $id_entity;
             break;
     }
     $url = str_replace(' ', '%20', trim($url));
     // Evaluate the memory required to resize the image: if it's too much, you can't resize it.
     if (!ImageManager::checkImageMemoryLimit($url)) {
         return false;
     }
     // 'file_exists' doesn't work on distant file, and getimagesize make the import slower.
     // Just hide the warning, the traitment will be the same.
     if (Tools::copy($url, $tmpfile)) {
         ImageManager::resize($tmpfile, $path . '.jpg');
         $images_types = ImageType::getImagesTypes($entity);
         foreach ($images_types as $image_type) {
             ImageManager::resize($tmpfile, $path . '-' . stripslashes($image_type['name']) . '.jpg', $image_type['width'], $image_type['height']);
         }
         if (in_array($image_type['id_image_type'], $watermark_types)) {
             Hook::exec('actionWatermark', array('id_image' => $id_image, 'id_product' => $id_entity));
         }
     } else {
         unlink($tmpfile);
         return false;
     }
     unlink($tmpfile);
     return true;
 }
开发者ID:rongandat,项目名称:vatfairfoot,代码行数:48,代码来源:AdminImportController.php

示例13: downloadLast

 /**
  * downloadLast download the last version of PrestaShop and save it in $dest/$filename
  *
  * @param string $dest directory where to save the file
  * @param string $filename new filename
  * @return boolean
  *
  * @TODO ftp if copy is not possible (safe_mode for example)
  */
 public function downloadLast($dest, $filename = 'prestashop.zip')
 {
     if (empty($this->link)) {
         $this->checkPSVersion();
     }
     $destPath = realpath($dest) . DIRECTORY_SEPARATOR . $filename;
     Tools::copy($this->link, $destPath);
     return is_file($destPath);
 }
开发者ID:prestashop,项目名称:autoupgrade,代码行数:18,代码来源:Upgrader.php

示例14: deployworker

 function deployworker($arg)
 {
     $id = $arg['id'];
     $rootdir = $arg['rootdir'];
     $dirs = $arg['dirs'];
     $remote = $arg['remote'];
     //! call rsync
     $files = [];
     if (substr($rootdir, -1) != "/") {
         $rootdir .= "/";
     }
     foreach ($dirs as $d) {
         $files[$rootdir . $d] = 1;
     }
     Core::$user->data['remote'] = $remote;
     $files = array_keys($files);
     $path = !empty($remote['path']) ? $remote['path'] : "/var/www/";
     if (!empty($arg['rsync'])) {
         $ret = Tools::ssh("rsync", $files, $path);
     } else {
         $ret = Tools::copy($files, $path);
     }
     //! update status
     DS::exec("UPDATE " . self::$_table . " SET console=?,syncd=CURRENT_TIMESTAMP WHERE id=?", [$id]);
 }
开发者ID:bztsrc,项目名称:phppe3,代码行数:25,代码来源:ClusterSrv.php

示例15: processImportTheme

 public function processImportTheme()
 {
     $this->display = 'importtheme';
     if ($this->context->mode == Context::MODE_HOST) {
         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') != '') {
             $uploader = new Uploader('themearchive');
             $uploader->setAcceptTypes(array('zip'));
             $uploader->setSavePath($sandbox);
             $file = $uploader->process(Theme::UPLOADED_THEME_DIR_NAME . '.zip');
             if ($file[0]['error'] === 0) {
                 if (Tools::ZipTest($sandbox . Theme::UPLOADED_THEME_DIR_NAME . '.zip')) {
                     $archive_uploaded = true;
                 } else {
                     $this->errors[] = $this->l('Zip file seems to be broken');
                 }
             } else {
                 $this->errors[] = $file[0]['error'];
             }
         } elseif (Tools::getValue('themearchiveUrl') != '') {
             if (!Validate::isModuleUrl($url = Tools::getValue('themearchiveUrl'), $this->errors)) {
                 $this->errors[] = $this->l('Only zip files are allowed');
             } elseif (!Tools::copy($url, $sandbox . Theme::UPLOADED_THEME_DIR_NAME . '.zip')) {
                 $this->errors[] = $this->l('Error during the file download');
             } elseif (Tools::ZipTest($sandbox . Theme::UPLOADED_THEME_DIR_NAME . '.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 . Theme::UPLOADED_THEME_DIR_NAME . '.zip')) {
                 $this->errors[] = $this->l('An error has occurred during the file copy.');
             } elseif (Tools::ZipTest($sandbox . Theme::UPLOADED_THEME_DIR_NAME . '.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 ($this->extractTheme($sandbox . Theme::UPLOADED_THEME_DIR_NAME . '.zip', $sandbox)) {
                 $this->installTheme(Theme::UPLOADED_THEME_DIR_NAME, $sandbox);
             }
         }
         Tools::deleteDirectory($sandbox);
         if (count($this->errors) > 0) {
             $this->display = 'importtheme';
         } else {
             Tools::redirectAdmin(Context::getContext()->link->getAdminLink('AdminThemes') . '&conf=18');
         }
     }
 }
开发者ID:NathanGiesbrecht,项目名称:PrestaShopAutomationFramework,代码行数:62,代码来源:AdminThemesController.php


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