本文整理汇总了PHP中OrderDetail::incrementDownload方法的典型用法代码示例。如果您正苦于以下问题:PHP OrderDetail::incrementDownload方法的具体用法?PHP OrderDetail::incrementDownload怎么用?PHP OrderDetail::incrementDownload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OrderDetail
的用法示例。
在下文中一共展示了OrderDetail::incrementDownload方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
if (isset($this->context->employee) && $this->context->employee->isLoggedBack() && Tools::getValue('file')) {
// Admin can directly access to file
$filename = Tools::getValue('file');
if (!Validate::isSha1($filename)) {
die(Tools::displayError());
}
$file = _PS_DOWNLOAD_DIR_ . strval(preg_replace('/\\.{2,}/', '.', $filename));
$filename = ProductDownload::getFilenameFromFilename(Tools::getValue('file'));
if (empty($filename)) {
$newFileName = Tools::getValue('filename');
if (!empty($newFileName)) {
$filename = Tools::getValue('filename');
} else {
$filename = 'file';
}
}
if (!file_exists($file)) {
Tools::redirect('index.php');
}
} else {
if (!($key = Tools::getValue('key'))) {
$this->displayCustomError('Invalid key.');
}
Tools::setCookieLanguage();
if (!$this->context->customer->isLogged() && !Tools::getValue('secure_key') && !Tools::getValue('id_order')) {
Tools::redirect('index.php?controller=authentication&back=get-file.php&key=' . $key);
} else {
if (!$this->context->customer->isLogged() && Tools::getValue('secure_key') && Tools::getValue('id_order')) {
$order = new Order((int) Tools::getValue('id_order'));
if (!Validate::isLoadedObject($order)) {
$this->displayCustomError('Invalid key.');
}
if ($order->secure_key != Tools::getValue('secure_key')) {
$this->displayCustomError('Invalid key.');
}
}
}
/* Key format: <sha1-filename>-<hashOrder> */
$tmp = explode('-', $key);
if (count($tmp) != 2) {
$this->displayCustomError('Invalid key.');
}
$filename = $tmp[0];
$hash = $tmp[1];
if (!($info = OrderDetail::getDownloadFromHash($hash))) {
$this->displayCustomError('This product does not exist in our store.');
}
/* Product no more present in catalog */
if (!isset($info['id_product_download']) || empty($info['id_product_download'])) {
$this->displayCustomError('This product has been deleted.');
}
if (!file_exists(_PS_DOWNLOAD_DIR_ . $filename)) {
$this->displayCustomError('This file no longer exists.');
}
if (isset($info['product_quantity_refunded']) && isset($info['product_quantity_return']) && ($info['product_quantity_refunded'] > 0 || $info['product_quantity_return'] > 0)) {
$this->displayCustomError('This product has been refunded.');
}
$now = time();
$product_deadline = strtotime($info['download_deadline']);
if ($now > $product_deadline && $info['download_deadline'] != '0000-00-00 00:00:00') {
$this->displayCustomError('The product deadline is in the past.');
}
$customer_deadline = strtotime($info['date_expiration']);
if ($now > $customer_deadline && $info['date_expiration'] != '0000-00-00 00:00:00') {
$this->displayCustomError('Expiration date has passed, you cannot download this product');
}
if ($info['download_nb'] >= $info['nb_downloadable'] && $info['nb_downloadable']) {
$this->displayCustomError('You have reached the maximum number of allowed downloads.');
}
/* Access is authorized -> increment download value for the customer */
OrderDetail::incrementDownload($info['id_order_detail']);
$file = _PS_DOWNLOAD_DIR_ . $info['filename'];
$filename = $info['display_filename'];
}
/* Detect mime content type */
$mimeType = false;
if (function_exists('finfo_open')) {
$finfo = @finfo_open(FILEINFO_MIME);
$mimeType = @finfo_file($finfo, $file);
@finfo_close($finfo);
} else {
if (function_exists('mime_content_type')) {
$mimeType = @mime_content_type($file);
} else {
if (function_exists('exec')) {
$mimeType = trim(@exec('file -b --mime-type ' . escapeshellarg($file)));
if (!$mimeType) {
$mimeType = trim(@exec('file --mime ' . escapeshellarg($file)));
}
if (!$mimeType) {
$mimeType = trim(@exec('file -bi ' . escapeshellarg($file)));
}
}
}
}
if (empty($mimeType)) {
$bName = basename($filename);
$bName = explode('.', $bName);
//.........这里部分代码省略.........
示例2: displayError
displayError('This file no longer exists.');
}
$now = time();
$product_deadline = strtotime($info['download_deadline']);
if ($now > $product_deadline and $info['download_deadline'] != '0000-00-00 00:00:00') {
displayError('The product deadline is in the past.');
}
$customer_deadline = strtotime($info['date_expiration']);
if ($now > $customer_deadline and $info['date_expiration'] != '0000-00-00 00:00:00') {
displayError('Expiration date exceeded');
}
if ($info['download_nb'] >= $info['nb_downloadable'] and $info['nb_downloadable']) {
displayError('You have reached the maximum number of allowed downloads.');
}
/* Access is authorized -> increment download value for the customer */
OrderDetail::incrementDownload($info['id_order_detail']);
$file = _PS_DOWNLOAD_DIR_ . $info['physically_filename'];
$filename = $info['display_filename'];
}
/* Detect mime content type */
$mimeType = false;
if (function_exists('finfo_open')) {
$finfo = @finfo_open(FILEINFO_MIME);
$mimeType = @finfo_file($finfo, $file);
@finfo_close($finfo);
} elseif (function_exists('mime_content_type')) {
$mimeType = @mime_content_type($file);
} elseif (function_exists('exec')) {
$mimeType = trim(@exec('file -b --mime-type ' . escapeshellarg($file)));
if (!$mimeType) {
$mimeType = trim(@exec('file --mime ' . escapeshellarg($file)));