本文整理汇总了PHP中ProductDownload::getNewFilename方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductDownload::getNewFilename方法的具体用法?PHP ProductDownload::getNewFilename怎么用?PHP ProductDownload::getNewFilename使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProductDownload
的用法示例。
在下文中一共展示了ProductDownload::getNewFilename方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateDownloadProduct
/**
* Update product download
*
* @param object $product Product
*/
public function updateDownloadProduct($product)
{
/* add or update a virtual product */
if (Tools::getValue('is_virtual_good') == 'true') {
if (!Tools::getValue('virtual_product_name')) {
$this->_errors[] = $this->l('the field') . ' <b>' . $this->l('display filename') . '</b> ' . $this->l('is required');
return false;
}
if (!Tools::getValue('virtual_product_nb_days')) {
$this->_errors[] = $this->l('the field') . ' <b>' . $this->l('number of days') . '</b> ' . $this->l('is required');
return false;
}
if (Tools::getValue('virtual_product_expiration_date') and !Validate::isDate(Tools::getValue('virtual_product_expiration_date'))) {
$this->_errors[] = $this->l('the field') . ' <b>' . $this->l('expiration date') . '</b> ' . $this->l('is not valid');
return false;
}
// The oos behavior MUST be "Deny orders" for virtual products
if (Tools::getValue('out_of_stock') != 0) {
$this->_errors[] = $this->l('The "when out of stock" behavior selection must be "deny order" for virtual products');
return false;
}
$download = new ProductDownload(Tools::getValue('virtual_product_id'));
$download->id_product = $product->id;
$download->display_filename = Tools::getValue('virtual_product_name');
$download->physically_filename = Tools::getValue('virtual_product_filename') ? Tools::getValue('virtual_product_filename') : $download->getNewFilename();
$download->date_deposit = date('Y-m-d H:i:s');
$download->date_expiration = Tools::getValue('virtual_product_expiration_date') ? Tools::getValue('virtual_product_expiration_date') . ' 23:59:59' : '';
$download->nb_days_accessible = Tools::getValue('virtual_product_nb_days');
$download->nb_downloadable = Tools::getValue('virtual_product_nb_downloable');
$download->active = 1;
if ($download->save()) {
return true;
}
} else {
/* unactive download product if checkbox not checked */
if ($id_product_download = ProductDownload::getIdFromIdProduct($product->id)) {
$productDownload = new ProductDownload($id_product_download);
$productDownload->date_expiration = date('Y-m-d H:i:s', time() - 1);
$productDownload->active = 0;
return $productDownload->save();
}
}
return false;
}
示例2: productImportOne
//.........这里部分代码省略.........
$product->id = (int) $datas['id_product'];
$product->date_add = pSQL($datas['date_add']);
$res = $validateOnly || $product->update();
} elseif ($productExistsInDatabase) {
$datas = Db::getInstance()->getRow('
SELECT product_shop.`date_add`
FROM `' . _DB_PREFIX_ . 'product` p
' . Shop::addSqlAssociation('product', 'p') . '
WHERE p.`id_product` = ' . (int) $product->id, false);
$product->date_add = pSQL($datas['date_add']);
$res = $validateOnly || $product->update();
}
// If no id_product or update failed
$product->force_id = (bool) $force_ids;
if (!$res) {
if (isset($product->date_add) && $product->date_add != '') {
$res = $validateOnly || $product->add(false);
} else {
$res = $validateOnly || $product->add();
}
}
if (!$validateOnly) {
if ($product->getType() == Product::PTYPE_VIRTUAL) {
StockAvailable::setProductOutOfStock((int) $product->id, 1);
} else {
StockAvailable::setProductOutOfStock((int) $product->id, (int) $product->out_of_stock);
}
if ($product_download_id = ProductDownload::getIdFromIdProduct((int) $product->id)) {
$product_download = new ProductDownload($product_download_id);
$product_download->delete(true);
}
if ($product->getType() == Product::PTYPE_VIRTUAL) {
$product_download = new ProductDownload();
$product_download->filename = ProductDownload::getNewFilename();
Tools::copy($info['file_url'], _PS_DOWNLOAD_DIR_ . $product_download->filename);
$product_download->id_product = (int) $product->id;
$product_download->nb_downloadable = (int) $info['nb_downloadable'];
$product_download->date_expiration = $info['date_expiration'];
$product_download->nb_days_accessible = (int) $info['nb_days_accessible'];
$product_download->display_filename = basename($info['file_url']);
$product_download->add();
}
}
}
$shops = array();
$product_shop = explode($this->multiple_value_separator, $product->shop);
foreach ($product_shop as $shop) {
if (empty($shop)) {
continue;
}
$shop = trim($shop);
if (!empty($shop) && !is_numeric($shop)) {
$shop = Shop::getIdByName($shop);
}
if (in_array($shop, $shop_ids)) {
$shops[] = $shop;
} else {
$this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Shop is not valid'));
}
}
if (empty($shops)) {
$shops = Shop::getContextListShopID();
}
// If both failed, mysql error
if (!$res) {
$this->errors[] = sprintf($this->trans('%1$s (ID: %2$s) cannot be saved', array(), 'Admin.Parameters.Notification'), isset($info['name']) && !empty($info['name']) ? Tools::safeOutput($info['name']) : 'No Name', isset($info['id']) && !empty($info['id']) ? Tools::safeOutput($info['id']) : 'No ID');
示例3: updateDownloadProduct
/**
* Update product download
*
* @param object $product Product
* @return bool
*/
public function updateDownloadProduct($product, $edit = 0)
{
$is_virtual_file = (int) Tools::getValue('is_virtual_file');
// add or update a virtual product
if (Tools::getValue('is_virtual_good') == 'true') {
$product->setDefaultAttribute(0);
//reset cache_default_attribute
if (Tools::getValue('virtual_product_expiration_date') && !Validate::isDate(Tools::getValue('virtual_product_expiration_date') && !empty($is_virtual_file))) {
if (!Tools::getValue('virtual_product_expiration_date')) {
$this->errors[] = Tools::displayError('The expiration-date attribute is required.');
return false;
}
}
// Trick's
if ($edit == 1) {
$id_product_download = (int) ProductDownload::getIdFromIdProduct((int) $product->id);
if (!$id_product_download) {
$id_product_download = (int) Tools::getValue('virtual_product_id');
}
} else {
$id_product_download = Tools::getValue('virtual_product_id');
}
$is_shareable = Tools::getValue('virtual_product_is_shareable');
$virtual_product_name = Tools::getValue('virtual_product_name');
$virtual_product_filename = Tools::getValue('virtual_product_filename');
$virtual_product_nb_days = Tools::getValue('virtual_product_nb_days');
$virtual_product_nb_downloable = Tools::getValue('virtual_product_nb_downloable');
$virtual_product_expiration_date = Tools::getValue('virtual_product_expiration_date');
if ($virtual_product_filename) {
$filename = $virtual_product_filename;
} else {
$filename = ProductDownload::getNewFilename();
}
$download = new ProductDownload((int) $id_product_download);
$download->id_product = (int) $product->id;
$download->display_filename = $virtual_product_name;
$download->filename = $filename;
$download->date_add = date('Y-m-d H:i:s');
$download->date_expiration = $virtual_product_expiration_date ? $virtual_product_expiration_date . ' 23:59:59' : '';
$download->nb_days_accessible = (int) $virtual_product_nb_days;
$download->nb_downloadable = (int) $virtual_product_nb_downloable;
$download->active = 1;
$download->is_shareable = (int) $is_shareable;
if ($download->save()) {
return true;
}
} else {
/* unactive download product if checkbox not checked */
if ($edit == 1) {
$id_product_download = (int) ProductDownload::getIdFromIdProduct((int) $product->id);
if (!$id_product_download) {
$id_product_download = (int) Tools::getValue('virtual_product_id');
}
} else {
$id_product_download = ProductDownload::getIdFromIdProduct($product->id);
}
if (!empty($id_product_download)) {
$product_download = new ProductDownload((int) $id_product_download);
$product_download->date_expiration = date('Y-m-d H:i:s', time() - 1);
$product_download->active = 0;
return $product_download->save();
}
}
return false;
}
示例4: duplicateDownload
public static function duplicateDownload($id_product_old, $id_product_new)
{
$sql = 'SELECT `display_filename`, `filename`, `date_add`, `date_expiration`, `nb_days_accessible`, `nb_downloadable`, `active`, `is_shareable`
FROM `' . _DB_PREFIX_ . 'product_download`
WHERE `id_product` = ' . (int) $id_product_old;
$results = Db::getInstance()->executeS($sql);
if (!$results) {
return true;
}
$data = array();
foreach ($results as $row) {
$new_filename = ProductDownload::getNewFilename();
copy(_PS_DOWNLOAD_DIR_ . $row['filename'], _PS_DOWNLOAD_DIR_ . $new_filename);
$data[] = array('id_product' => (int) $id_product_new, 'display_filename' => pSQL($row['display_filename']), 'filename' => pSQL($new_filename), 'date_expiration' => pSQL($row['date_expiration']), 'nb_days_accessible' => (int) $row['nb_days_accessible'], 'nb_downloadable' => (int) $row['nb_downloadable'], 'active' => (int) $row['active'], 'is_shareable' => (int) $row['is_shareable'], 'date_add' => date('Y-m-d H:i:s'));
}
return Db::getInstance()->insert('product_download', $data);
}
示例5: define
<?php
define('PS_ADMIN_DIR', getcwd());
include PS_ADMIN_DIR . '/../config/config.inc.php';
if (!class_exists('Cookie')) {
exit;
}
$cookie = new Cookie('psAdmin', substr($_SERVER['SCRIPT_NAME'], strlen(__PS_BASE_URI__), -10));
if (!$cookie->isLoggedBack()) {
die;
}
if (isset($_FILES['virtual_product_file']) and is_uploaded_file($_FILES['virtual_product_file']['tmp_name']) and (isset($_FILES['virtual_product_file']['error']) and !$_FILES['virtual_product_file']['error']) or !empty($_FILES['virtual_product_file']['tmp_name']) and $_FILES['virtual_product_file']['tmp_name'] != 'none') {
$filename = $_FILES['virtual_product_file']['name'];
$file = $_FILES['virtual_product_file']['tmp_name'];
$newfilename = ProductDownload::getNewFilename();
if (!copy($file, _PS_DOWNLOAD_DIR_ . $newfilename)) {
header('HTTP/1.1 500 Error');
echo '<return result="error" msg="no rights" filename="' . $filename . '" />';
}
@unlink($file);
header('HTTP/1.1 200 OK');
echo '<return result="success" msg="' . $newfilename . '" filename="' . $filename . '" />';
} else {
header('HTTP/1.1 500 Error');
echo '<return result="error" msg="big error" filename="' . ProductDownload::getNewFilename() . '" />';
}
示例6: getNewFilename
/**
* Return a sha1 filename
*
* @return string Sha1 unique filename
*/
public static function getNewFilename()
{
$ret = sha1(microtime());
if (file_exists(_PS_DOWNLOAD_DIR_ . $ret)) {
$ret = ProductDownload::getNewFilename();
}
return $ret;
}
示例7: dirname
/// This source file is subject to the Software License Agreement that is bundled with this
/// package in the file license.txt, or you can get it here
/// http://addons-modules.com/store/en/content/3-terms-and-conditions-of-use
///
/// @copyright 2009-2012 Addons-Modules.com
///
*/
${"GLOBALS"}["ehlrhvdb"] = "newfilename";
${"GLOBALS"}["jwxvtcivdngx"] = "file";
${"GLOBALS"}["pcopxkfgk"] = "filename";
include dirname(__FILE__) . "/config/config.inc.php";
if (!isset(Context::getContext()->customer) || !Context::getContext()->customer->id || !Context::getContext()->customer->isLogged()) {
die(Tools::displayError("Permission Denied"));
}
if (isset($_FILES["virtual_product_file_attribute"]) && is_uploaded_file($_FILES["virtual_product_file_attribute"]["tmp_name"]) && (isset($_FILES["virtual_product_file_attribute"]["error"]) && !$_FILES["virtual_product_file_attribute"]["error"]) || !empty($_FILES["virtual_product_file_attribute"]["tmp_name"]) && $_FILES["virtual_product_file_attribute"]["tmp_name"] != "none") {
${${"GLOBALS"}["pcopxkfgk"]} = $_FILES["virtual_product_file_attribute"]["name"];
${"GLOBALS"}["uyfemhd"] = "newfilename";
${"GLOBALS"}["dyqkzhiilxah"] = "file";
${${"GLOBALS"}["jwxvtcivdngx"]} = $_FILES["virtual_product_file_attribute"]["tmp_name"];
${${"GLOBALS"}["uyfemhd"]} = ProductDownload::getNewFilename();
if (!copy(${${"GLOBALS"}["dyqkzhiilxah"]}, _PS_DOWNLOAD_DIR_ . ${${"GLOBALS"}["ehlrhvdb"]})) {
header("HTTP/1.1 500 Error");
echo "<return result=\"error\" msg=\"No permissions to write in the download folder\" filename=\"" . Tools::safeOutput(${${"GLOBALS"}["pcopxkfgk"]}) . "\" />";
}
@unlink(${${"GLOBALS"}["jwxvtcivdngx"]});
header("HTTP/1.1 200 OK");
echo "<return result=\"success\" msg=\"" . Tools::safeOutput(${${"GLOBALS"}["ehlrhvdb"]}) . "\" filename=\"" . Tools::safeOutput(${${"GLOBALS"}["pcopxkfgk"]}) . "\" />";
} else {
header("HTTP/1.1 500 Error");
echo "<return result=\"error\" msg=\"Unknown error\" filename=\"" . Tools::safeOutput(ProductDownload::getNewFilename()) . "\" />";
}
示例8: updateDownloadProduct
public function updateDownloadProduct($product, $edit = 0)
{
$bqhdst = "is_virtual_file";
${$bqhdst} = (int) Tools::getValue("is_virtual_file");
if (Tools::getValue("is_virtual_good") == "true") {
if (Tools::getValue("virtual_product_expiration_date") && !Validate::isDate(Tools::getValue("virtual_product_expiration_date") && !empty(${${"GLOBALS"}["ofnqhqwloxy"]}))) {
if (!Tools::getValue("virtual_product_expiration_date")) {
$this->errors[] = Tools::displayError("This field expiration date attribute is required.");
return false;
}
}
${"GLOBALS"}["sawwdmhhhf"] = "is_shareable";
$pvfvdbstogj = "download";
if (${${"GLOBALS"}["pjupudkhthj"]} == 1) {
${${"GLOBALS"}["oketuohcmb"]} = (int) ProductDownload::getIdFromIdProduct((int) $product->id);
$yduygdht = "id_product_download";
if (!${${"GLOBALS"}["oketuohcmb"]}) {
${$yduygdht} = (int) Tools::getValue("virtual_product_id");
}
} else {
${${"GLOBALS"}["oketuohcmb"]} = Tools::getValue("virtual_product_id");
}
$mpudnceviio = "virtual_product_expiration_date";
$njckiqo = "filename";
${"GLOBALS"}["kvmjgmdvfpxk"] = "virtual_product_expiration_date";
${${"GLOBALS"}["sawwdmhhhf"]} = Tools::getValue("virtual_product_is_shareable");
${"GLOBALS"}["qgipvncl"] = "virtual_product_filename";
${${"GLOBALS"}["dfdmmppxadnp"]} = Tools::getValue("virtual_product_name");
${${"GLOBALS"}["qgipvncl"]} = Tools::getValue("virtual_product_filename");
${${"GLOBALS"}["xpylkyaysxls"]} = Tools::getValue("virtual_product_nb_days");
$dtltqsd = "virtual_product_filename";
$cbycann = "virtual_product_filename";
${${"GLOBALS"}["ebothfnmt"]} = Tools::getValue("virtual_product_nb_downloable");
${${"GLOBALS"}["bktmulsvfp"]} = Tools::getValue("virtual_product_expiration_date");
if (${$cbycann}) {
${${"GLOBALS"}["letornu"]} = ${$dtltqsd};
} else {
${${"GLOBALS"}["letornu"]} = ProductDownload::getNewFilename();
}
${$pvfvdbstogj} = new ProductDownload((int) ${${"GLOBALS"}["oketuohcmb"]});
$download->id_product = (int) $product->id;
$download->display_filename = ${${"GLOBALS"}["dfdmmppxadnp"]};
$download->filename = ${$njckiqo};
$download->date_add = date("Y-m-d H:i:s");
$vcyhlrvrm = "is_shareable";
$download->date_expiration = ${${"GLOBALS"}["kvmjgmdvfpxk"]} ? ${$mpudnceviio} . " 23:59:59" : "";
$download->nb_days_accessible = (int) ${${"GLOBALS"}["xpylkyaysxls"]};
$download->nb_downloadable = (int) ${${"GLOBALS"}["ebothfnmt"]};
$download->active = 1;
$download->is_shareable = (int) ${$vcyhlrvrm};
if ($download->save()) {
return true;
}
} else {
${"GLOBALS"}["eycluxdax"] = "id_product_download";
${"GLOBALS"}["ikiqrzgois"] = "edit";
if (${${"GLOBALS"}["ikiqrzgois"]} == 1) {
$kmioedds = "id_product_download";
${$kmioedds} = (int) ProductDownload::getIdFromIdProduct((int) $product->id);
if (!${${"GLOBALS"}["oketuohcmb"]}) {
${${"GLOBALS"}["oketuohcmb"]} = (int) Tools::getValue("virtual_product_id");
}
} else {
${${"GLOBALS"}["eycluxdax"]} = ProductDownload::getIdFromIdProduct($product->id);
}
if (!empty(${${"GLOBALS"}["oketuohcmb"]})) {
$ykdgublwd = "product_download";
${$ykdgublwd} = new ProductDownload((int) ${${"GLOBALS"}["oketuohcmb"]});
$product_download->date_expiration = date("Y-m-d H:i:s", time() - 1);
$product_download->active = 0;
return $product_download->save();
}
}
return false;
}
示例9: define
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
define('_PS_ADMIN_DIR_', getcwd());
include _PS_ADMIN_DIR_ . '/../config/config.inc.php';
if (!isset(Context::getContext()->employee) || !Context::getContext()->employee->isLoggedBack()) {
die;
}
if (isset($_FILES['virtual_product_file_attribute']) && is_uploaded_file($_FILES['virtual_product_file_attribute']['tmp_name']) && (isset($_FILES['virtual_product_file_attribute']['error']) && !$_FILES['virtual_product_file_attribute']['error']) || !empty($_FILES['virtual_product_file_attribute']['tmp_name']) && $_FILES['virtual_product_file_attribute']['tmp_name'] != 'none') {
$filename = $_FILES['virtual_product_file_attribute']['name'];
$file = $_FILES['virtual_product_file_attribute']['tmp_name'];
$newfilename = ProductDownload::getNewFilename();
if (!copy($file, _PS_DOWNLOAD_DIR_ . $newfilename)) {
header('HTTP/1.1 500 Error');
echo '<return result="error" msg="No permissions to write in the download folder" filename="' . Tools::safeOutput($filename) . '" />';
}
@unlink($file);
header('HTTP/1.1 200 OK');
echo '<return result="success" msg="' . Tools::safeOutput($newfilename) . '" filename="' . Tools::safeOutput($filename) . '" />';
} else {
header('HTTP/1.1 500 Error');
echo '<return result="error" msg="Unknown error" filename="' . Tools::safeOutput(ProductDownload::getNewFilename()) . '" />';
}
示例10: define
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2012 PrestaShop SA
* @version Release: $Revision: 6844 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
define('_PS_ADMIN_DIR_', getcwd());
include _PS_ADMIN_DIR_ . '/../config/config.inc.php';
if (!isset(Context::getContext()->employee) || !Context::getContext()->employee->isLoggedBack()) {
die;
}
if (isset($_FILES['virtual_product_file']) and is_uploaded_file($_FILES['virtual_product_file']['tmp_name']) and (isset($_FILES['virtual_product_file']['error']) and !$_FILES['virtual_product_file']['error']) or !empty($_FILES['virtual_product_file']['tmp_name']) and $_FILES['virtual_product_file']['tmp_name'] != 'none') {
$filename = $_FILES['virtual_product_file']['name'];
$file = $_FILES['virtual_product_file']['tmp_name'];
$newfilename = ProductDownload::getNewFilename();
if (!copy($file, _PS_DOWNLOAD_DIR_ . $newfilename)) {
header('HTTP/1.1 500 Error');
echo '<return result="error" msg="No permissions to write in the download folder" filename="' . Tools::safeOutput($filename) . '" />';
}
@unlink($file);
header('HTTP/1.1 200 OK');
echo '<return result="success" msg="' . Tools::safeOutput($newfilename) . '" filename="' . Tools::safeOutput($filename) . '" />';
} else {
header('HTTP/1.1 500 Error');
echo '<return result="error" msg="Could not upload file" filename="' . Tools::safeOutput(ProductDownload::getNewFilename()) . '" />';
}