本文整理汇总了PHP中utf8_strrpos函数的典型用法代码示例。如果您正苦于以下问题:PHP utf8_strrpos函数的具体用法?PHP utf8_strrpos怎么用?PHP utf8_strrpos使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了utf8_strrpos函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resize
public function resize($filename, $width, $height)
{
if (!file_exists(DIR_IMAGE . $filename) || !is_file(DIR_IMAGE . $filename)) {
return;
}
$info = pathinfo($filename);
$extension = $info['extension'];
$old_image = $filename;
$new_image = 'cache/' . utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '-' . $width . 'x' . $height . '.' . $extension;
if (!file_exists(DIR_IMAGE . $new_image) || filemtime(DIR_IMAGE . $old_image) > filemtime(DIR_IMAGE . $new_image)) {
$path = '';
$directories = explode('/', dirname(str_replace('../', '', $new_image)));
foreach ($directories as $directory) {
$path = $path . '/' . $directory;
if (!file_exists(DIR_IMAGE . $path)) {
@mkdir(DIR_IMAGE . $path, 0777);
}
}
$image = new Image(DIR_IMAGE . $old_image);
$image->resize($width, $height);
$image->save(DIR_IMAGE . $new_image);
}
if (isset($this->request->server['HTTPS']) && ($this->request->server['HTTPS'] == 'on' || $this->request->server['HTTPS'] == '1')) {
return HTTPS_CATALOG . 'image/' . $new_image;
} else {
return HTTP_CATALOG . 'image/' . $new_image;
}
}
示例2: cart
public function cart()
{
$this->load->model('tool/image');
$this->data['products'] = array();
foreach ($this->cart->getProducts() as $product) {
if ($product['image']) {
$image = $this->model_tool_image->resize($product['image'], $this->config->get('image_cart_width'), $this->config->get('image_cart_height'));
} else {
$image = '';
}
$option_data = array();
foreach ($product['option'] as $option) {
if ($option['type'] != 'file') {
$value = $option['option_value'];
} else {
$filename = $this->encryption->decrypt($option['option_value']);
$value = utf8_substr($filename, 0, utf8_strrpos($filename, '.'));
}
$option_data[] = array('name' => $option['name'], 'value' => utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value, 'type' => $option['type']);
}
$this->data['products'][] = array('product_id' => $product['product_id'], 'key' => $product['key'], 'thumb' => $image, 'name' => $product['name'], 'model' => $product['model'], 'option' => $option_data, 'quantity' => $product['quantity'], 'price' => $product['price'], 'total' => $product['total'], 'tax' => $product['tax_percentage'], 'href' => $this->url->link('product/product', 'product_id=' . $product['product_id']));
}
// Gift Voucher
if (!empty($this->session->data['vouchers'])) {
foreach ($this->session->data['vouchers'] as $key => $voucher) {
$this->data['products'][] = array('key' => $key, 'name' => $voucher['description'], 'price' => $voucher['amount'], 'amount' => 1, 'total' => $voucher['amount']);
}
}
$this->template = 'cart.tpl';
$this->response->setOutput($this->render());
}
示例3: resize
public function resize($filename, $width, $height)
{
if (!is_file(DIR_IMAGE . $filename)) {
return;
}
$extension = pathinfo($filename, PATHINFO_EXTENSION);
$old_image = $filename;
$new_image = 'cache/' . utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '-' . $width . 'x' . $height . '.' . $extension;
if (!is_file(DIR_IMAGE . $new_image) || filectime(DIR_IMAGE . $old_image) > filectime(DIR_IMAGE . $new_image)) {
$path = '';
$directories = explode('/', dirname(str_replace('../', '', $new_image)));
foreach ($directories as $directory) {
$path = $path . '/' . $directory;
if (!is_dir(DIR_IMAGE . $path)) {
@mkdir(DIR_IMAGE . $path, 0777);
}
}
list($width_orig, $height_orig) = getimagesize(DIR_IMAGE . $old_image);
if ($width_orig != $width || $height_orig != $height) {
$image = new Image(DIR_IMAGE . $old_image);
$image->resize($width, $height);
$image->save(DIR_IMAGE . $new_image);
} else {
copy(DIR_IMAGE . $old_image, DIR_IMAGE . $new_image);
}
}
if ($this->request->server['HTTPS']) {
return $this->config->get('config_ssl') . 'image/' . $new_image;
} else {
return $this->config->get('config_url') . 'image/' . $new_image;
}
}
示例4: resize
public function resize($filename, $width, $height)
{
if (!is_file(DIR_IMAGE . $filename) || substr(str_replace('\\', '/', realpath(DIR_IMAGE . $filename)), 0, strlen(DIR_IMAGE)) != DIR_IMAGE) {
return;
}
$extension = pathinfo($filename, PATHINFO_EXTENSION);
$image_old = $filename;
$image_new = 'cache/' . utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '-' . $width . 'x' . $height . '.' . $extension;
if (!is_file(DIR_IMAGE . $image_new) || filectime(DIR_IMAGE . $image_old) > filectime(DIR_IMAGE . $image_new)) {
list($width_orig, $height_orig, $image_type) = getimagesize(DIR_IMAGE . $image_old);
if (!in_array($image_type, array(IMAGETYPE_PNG, IMAGETYPE_JPEG, IMAGETYPE_GIF))) {
return DIR_IMAGE . $image_old;
}
$path = '';
$directories = explode('/', dirname($image_new));
foreach ($directories as $directory) {
$path = $path . '/' . $directory;
if (!is_dir(DIR_IMAGE . $path)) {
@mkdir(DIR_IMAGE . $path, 0777);
}
}
if ($width_orig != $width || $height_orig != $height) {
$image = new Image(DIR_IMAGE . $image_old);
$image->resize($width, $height);
$image->save(DIR_IMAGE . $image_new);
} else {
copy(DIR_IMAGE . $image_old, DIR_IMAGE . $image_new);
}
}
if ($this->request->server['HTTPS']) {
return HTTPS_CATALOG . 'image/' . $image_new;
} else {
return HTTP_CATALOG . 'image/' . $image_new;
}
}
示例5: resize
public function resize($filename, $width, $height)
{
if (!is_file(DIR_IMAGE . $filename) || substr(str_replace('\\', '/', realpath(DIR_IMAGE . $filename)), 0, strlen(DIR_IMAGE)) != DIR_IMAGE) {
return;
}
$extension = pathinfo($filename, PATHINFO_EXTENSION);
$old_image = $filename;
$new_image = 'cache/' . utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '-' . (int) $width . 'x' . (int) $height . '.' . $extension;
if (!is_file(DIR_IMAGE . $new_image) || filectime(DIR_IMAGE . $old_image) > filectime(DIR_IMAGE . $new_image)) {
$path = '';
$directories = explode('/', dirname($new_image));
foreach ($directories as $directory) {
$path = $path . '/' . $directory;
if (!is_dir(DIR_IMAGE . $path)) {
@mkdir(DIR_IMAGE . $path, 0777);
}
}
list($width_orig, $height_orig) = getimagesize(DIR_IMAGE . $old_image);
if ($width_orig != $width || $height_orig != $height) {
$image = new Image(DIR_IMAGE . $old_image);
$image->resize($width, $height);
$image->save(DIR_IMAGE . $new_image);
} else {
copy(DIR_IMAGE . $old_image, DIR_IMAGE . $new_image);
}
}
$new_image = str_replace(' ', '%20', $new_image);
if (isset($this->request->server['HTTPS']) && ($this->request->server['HTTPS'] == 'on' || $this->request->server['HTTPS'] == '1') || $this->request->server['HTTPS'] == '443') {
return $this->config->get('config_ssl') . 'image/' . $new_image;
} elseif (isset($this->request->server['HTTP_X_FORWARDED_PROTO']) && $this->request->server['HTTP_X_FORWARDED_PROTO'] == 'https') {
return $this->config->get('config_ssl') . 'image/' . $new_image;
} else {
return $this->config->get('config_url') . 'image/' . $new_image;
}
}
示例6: resize
/**
*
* @param filename string
* @param width
* @param height
* @param type char [default, w, h]
* default = scale with white space,
* w = fill according to width,
* h = fill according to height
*
*/
public function resize($filename, $width, $height, $type = "")
{
if (!file_exists(DIR_IMAGE . $filename) || !is_file(DIR_IMAGE . $filename)) {
return;
}
$info = pathinfo($filename);
$extension = $info['extension'];
$old_image = $filename;
$new_image = 'cache/' . utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '-' . $width . 'x' . $height . $type . '.' . $extension;
if (!file_exists(DIR_IMAGE . $new_image) || filemtime(DIR_IMAGE . $old_image) > filemtime(DIR_IMAGE . $new_image)) {
$path = '';
$directories = explode('/', dirname(str_replace('../', '', $new_image)));
foreach ($directories as $directory) {
$path = $path . '/' . $directory;
if (!file_exists(DIR_IMAGE . $path)) {
@mkdir(DIR_IMAGE . $path, 0777);
}
}
list($width_orig, $height_orig) = getimagesize(DIR_IMAGE . $old_image);
if ($width_orig != $width || $height_orig != $height) {
$image = new Image(DIR_IMAGE . $old_image);
$image->resize($width, $height, $type);
$image->save(DIR_IMAGE . $new_image);
} else {
copy(DIR_IMAGE . $old_image, DIR_IMAGE . $new_image);
}
}
if (isset($this->request->server['HTTPS']) && ($this->request->server['HTTPS'] == 'on' || $this->request->server['HTTPS'] == '1')) {
return (defined('HTTPS_STATIC_CDN') ? HTTPS_STATIC_CDN : $this->config->get('config_ssl')) . 'image/' . $new_image;
} else {
return (defined('HTTP_STATIC_CDN') ? HTTP_STATIC_CDN : $this->config->get('config_url')) . 'image/' . $new_image;
}
}
示例7: utf8_strrpos
function utf8_strrpos($string, $needle, $offset = NULL) {
if (is_null($offset)) {
$data = explode($needle, $string);
if (count($data) > 1) {
array_pop($data);
$string = join($needle, $data);
return utf8_strlen($string);
}
return false;
} else {
if (!is_int($offset)) {
trigger_error('utf8_strrpos expects parameter 3 to be long', E_USER_WARNING);
return false;
}
$string = utf8_substr($string, $offset);
if (false !== ($position = utf8_strrpos($string, $needle))) {
return $position + $offset;
}
return false;
}
}
示例8: resize
/**
*
* @param filename string
* @param width
* @param height
* @param type char [default, w, h]
* default = scale with white space,
* w = fill according to width,
* h = fill according to height
*
*/
public function resize($filename, $width, $height, $type = "")
{
if (!file_exists(DIR_IMAGE . $filename) || !is_file(DIR_IMAGE . $filename)) {
return;
}
$info = pathinfo($filename);
$extension = $info['extension'];
$old_image = $filename;
$new_image = 'cache/' . utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '-' . $width . 'x' . $height . $type . '.' . $extension;
if (!file_exists(DIR_IMAGE . $new_image) || filemtime(DIR_IMAGE . $old_image) > filemtime(DIR_IMAGE . $new_image)) {
$path = '';
$directories = explode('/', dirname(str_replace('../', '', $new_image)));
foreach ($directories as $directory) {
$path = $path . '/' . $directory;
if (!file_exists(DIR_IMAGE . $path)) {
@mkdir(DIR_IMAGE . $path, 0777);
}
}
list($width_orig, $height_orig) = getimagesize(DIR_IMAGE . $old_image);
if ($width_orig != $width || $height_orig != $height) {
$image = new Image(DIR_IMAGE . $old_image);
$image->resize($width, $height, $type);
$image->save(DIR_IMAGE . $new_image);
} else {
copy(DIR_IMAGE . $old_image, DIR_IMAGE . $new_image);
}
}
return $this->getImageUrl($new_image);
}
示例9: zula_strrpos
/**
* Unicode: Returns the position of the last occurrence of needle in haystack
*
* @param string haystack
* @param string needle
* @param int offset
* @return integer or false on failure
*/
function zula_strrpos($haystack, $needle, $offset = null)
{
if (UNICODE_MBSTRING === true) {
return $offset === null ? mb_strrpos($haystack, $needle) : mb_strrpos($haystack, $needle, $offset);
} else {
return $offset === null ? utf8_strrpos($haystack, $needle) : utf8_strrpos($haystack, $needle, $offset);
}
}
示例10: index
protected function index()
{
$this->language->load('payment/mvd_pp_standard');
$this->data['button_confirm'] = $this->language->get('button_confirm');
//$this->data['action'] = 'https://www.paypal.com/cgi-bin/webscr';
$this->data['action'] = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
$this->load->model('checkout/order');
$order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
if ($order_info) {
$this->load->model('checkout/order');
$mybankinfo = $this->model_checkout_order->PaymentGateway();
$this->data['business'] = $mybankinfo['paypal_email'];
$this->data['item_name'] = html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8');
$this->data['products'] = array();
foreach ($this->cart->getProducts() as $product) {
$option_data = array();
foreach ($product['option'] as $option) {
if ($option['type'] != 'file') {
$value = $option['option_value'];
} else {
$filename = $this->encryption->decrypt($option['option_value']);
$value = utf8_substr($filename, 0, utf8_strrpos($filename, '.'));
}
$option_data[] = array('name' => $option['name'], 'value' => utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value);
}
$this->data['products'][] = array('name' => $product['name'], 'model' => $product['model'], 'price' => $this->currency->format($product['price'], $order_info['currency_code'], false, false), 'quantity' => $product['quantity'], 'option' => $option_data, 'weight' => $product['weight']);
}
$this->data['discount_amount_cart'] = 0;
$total = $this->currency->format($order_info['total'] - $this->cart->getSubTotal(), $order_info['currency_code'], false, false);
if ($total > 0) {
$this->data['products'][] = array('name' => $this->language->get('text_total'), 'model' => '', 'price' => $total, 'quantity' => 1, 'option' => array(), 'weight' => 0);
} else {
$this->data['discount_amount_cart'] -= $total;
}
$this->data['currency_code'] = $order_info['currency_code'];
$this->data['first_name'] = html_entity_decode($order_info['payment_firstname'], ENT_QUOTES, 'UTF-8');
$this->data['last_name'] = html_entity_decode($order_info['payment_lastname'], ENT_QUOTES, 'UTF-8');
$this->data['address1'] = html_entity_decode($order_info['payment_address_1'], ENT_QUOTES, 'UTF-8');
$this->data['address2'] = html_entity_decode($order_info['payment_address_2'], ENT_QUOTES, 'UTF-8');
$this->data['city'] = html_entity_decode($order_info['payment_city'], ENT_QUOTES, 'UTF-8');
$this->data['zip'] = html_entity_decode($order_info['payment_postcode'], ENT_QUOTES, 'UTF-8');
$this->data['country'] = $order_info['payment_iso_code_2'];
$this->data['email'] = $order_info['email'];
$this->data['invoice'] = $this->session->data['order_id'] . ' - ' . html_entity_decode($order_info['payment_firstname'], ENT_QUOTES, 'UTF-8') . ' ' . html_entity_decode($order_info['payment_lastname'], ENT_QUOTES, 'UTF-8');
$this->data['lc'] = $this->session->data['language'];
$this->data['return'] = $this->url->link('checkout/success');
$this->data['notify_url'] = $this->url->link('payment/mvd_pp_standard/callback', '', 'SSL');
$this->data['cancel_return'] = $this->url->link('checkout/checkout', '', 'SSL');
$this->data['paymentaction'] = 'sale';
$this->data['custom'] = $this->session->data['order_id'];
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/mvd_pp_standard.tpl')) {
$this->template = $this->config->get('config_template') . '/template/payment/mvd_pp_standard.tpl';
} else {
$this->template = 'default/template/payment/mvd_pp_standard.tpl';
}
$this->render();
}
}
示例11: getTableData
public function getTableData()
{
$colMap = array('customer_name' => 'firstname', 'date_created' => 'o.date_added');
$sorts = array('order_id', 'customer_name', 'date_created', 'total_amount');
$filters = array_merge($sorts, array('products'));
list($sortCol, $sortDir) = $this->MsLoader->MsHelper->getSortParams($sorts, $colMap);
$filterParams = $this->MsLoader->MsHelper->getFilterParams($filters, $colMap);
$seller_id = $this->customer->getId();
$this->load->model('account/order');
$orders = $this->MsLoader->MsOrderData->getOrders(array('seller_id' => $seller_id, 'order_status' => $this->config->get('msconf_credit_order_statuses')), array('order_by' => $sortCol, 'order_way' => $sortDir, 'offset' => $this->request->get['iDisplayStart'], 'limit' => $this->request->get['iDisplayLength'], 'filters' => $filterParams), array('total_amount' => 1, 'products' => 1));
$total_orders = isset($orders[0]) ? $orders[0]['total_rows'] : 0;
$columns = array();
foreach ($orders as $order) {
$order_products = $this->MsLoader->MsOrderData->getOrderProducts(array('order_id' => $order['order_id'], 'seller_id' => $seller_id));
if ($this->config->get('msconf_hide_customer_email')) {
$customer_name = "{$order['firstname']} {$order['lastname']}";
} else {
$customer_name = "{$order['firstname']} {$order['lastname']} ({$order['email']})";
}
$products = "";
foreach ($order_products as $p) {
$products .= "<p style='text-align:left'>";
$products .= "<span class='name'>" . ($p['quantity'] > 1 ? "{$p['quantity']} x " : "") . "<a href='" . $this->url->link('product/product', 'product_id=' . $p['product_id'], 'SSL') . "'>{$p['name']}</a></span>";
$options = $this->model_account_order->getOrderOptions($order['order_id'], $p['order_product_id']);
foreach ($options as $option) {
if ($option['type'] != 'file') {
$value = $option['value'];
} else {
$value = utf8_substr($option['value'], 0, utf8_strrpos($option['value'], '.'));
}
$option['value'] = utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value;
$products .= "<br />";
$products .= "<small> - {$option['name']} : {$option['value']} </small>";
}
$products .= "<span class='total'>" . $this->currency->format($p['seller_net_amt'], $this->config->get('config_currency')) . "</span>";
$products .= "</p>";
}
$this->load->model('localisation/order_status');
$order_statuses = $this->model_localisation_order_status->getOrderStatuses();
$order_status_id = $this->model_localisation_order_status->getSuborderStatusId($order['order_id'], $this->customer->getId());
$order_status_name = '';
foreach ($order_statuses as $order_status) {
if ($order_status['order_status_id'] == $order_status_id) {
$order_status_name = $order_status['name'];
}
}
$columns[] = array_merge($order, array('order_id' => $order['order_id'], 'customer_name' => $customer_name, 'products' => $products, 'suborder_status' => $order_status_name, 'date_created' => date($this->language->get('date_format_short'), strtotime($order['date_added'])), 'total_amount' => $this->currency->format($order['total_amount'], $this->config->get('config_currency')), 'view_order' => '<a href="' . $this->url->link('seller/account-order/viewOrder', 'order_id=' . $order['order_id']) . '" class="ms-button ms-button-view"></a>'));
}
$this->response->setOutput(json_encode(array('iTotalRecords' => $total_orders, 'iTotalDisplayRecords' => $total_orders, 'aaData' => $columns)));
}
示例12: utf8_pathinfo
/**
* Returns information about a file path
*
* @author Lars Knickrehm <mail@lars-sh.de>
* @category Library
* @copyright Copyright © 2009 Lars Knickrehm
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License
* @link http://php.net/manual/function.pathinfo.php
* @package UTF-8
* @param string $path The path being checked.
* @return array The following associative array elements are returned: dirname, basename, extension (if any), and filename.
* @since Version 0.5.0
* @version 0.5.0
*/
function utf8_pathinfo($path)
{
$return['dirname'] = dirname($path);
$return['basename'] = utf8_basename($path);
$position = utf8_strrpos($return['basename'], '.');
if ($position !== false) {
$return['extension'] = utf8_substr($return['basename'], $position + 1);
$return['filename'] = $return['basename'];
$return['filename'] = utf8_substr($return['filename'], 0, $position);
} else {
$return['filename'] = $return['basename'];
}
return $return;
}
示例13: resizeme
public function resizeme($filename, $width, $height, $type = true, $copy = true)
{
if (!class_exists('PhpThumbFactory')) {
require_once DIR_SYSTEM . 'library/image/ThumbLib.php';
}
$ok = false;
if (!file_exists(DIR_IMAGE . $filename) || !is_file(DIR_IMAGE . $filename)) {
return $ok;
}
$info = pathinfo($filename);
$extension = $info['extension'];
$old_image = $filename;
$new_image = 'cache/' . utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '-' . $width . 'x' . $height . '.' . $extension;
if (!file_exists(DIR_IMAGE . $new_image) || filemtime(DIR_IMAGE . $old_image) > filemtime(DIR_IMAGE . $new_image)) {
$path = '';
$directories = explode('/', dirname(str_replace('../', '', $new_image)));
foreach ($directories as $directory) {
$path = $path . '/' . $directory;
if (!file_exists(DIR_IMAGE . $path)) {
@mkdir(DIR_IMAGE . $path, 0777);
}
}
list($width_orig, $height_orig) = getimagesize(DIR_IMAGE . $old_image);
if ($width_orig != $width || $height_orig != $height || !$copy) {
//********* code *************
$thumb = PhpThumbFactory::create(DIR_IMAGE . $old_image, array('resizeUp' => true));
if ($type) {
$ok = $thumb->adaptiveResize($width, $height)->save(DIR_IMAGE . $new_image);
} else {
//$ok = $thumb->resize($width, $height)->save(DIR_IMAGE . $new_image);
// opencart standart
$image = new Image(DIR_IMAGE . $old_image);
$image->resize($width, $height);
$image->save(DIR_IMAGE . $new_image);
$ok = true;
}
//********* code *************
} else {
$ok = copy(DIR_IMAGE . $old_image, DIR_IMAGE . $new_image);
}
if ($ok) {
return $this->getHttpImage() . $new_image;
} else {
return '';
}
} else {
return $this->getHttpImage() . $new_image;
}
}
示例14: utf8_basename
/**
* Returns filename component of path
*
* @author Lars Knickrehm <mail@lars-sh.de>
* @category Library
* @copyright Copyright © 2009 Lars Knickrehm
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License
* @link http://php.net/manual/function.basename.php
* @package UTF-8
* @param string $path A path. Both slash (/) and backslash (\) are used as directory separator character.
* @param string $suffix If the filename ends in suffix this will also be cut off.
* @return string Base name of the given path
* @since Version 0.5.0
* @version 0.5.0
*/
function utf8_basename($path, $suffix = '')
{
// Change backslash (\) to slash (/)
$path = utf8_trim(strtr($path, array('\\' => '/')), '/');
// Get basename
$i = utf8_strrpos($path, '/');
if ($i !== false) {
$path = utf8_substr($path, $i + 1);
}
// Handle suffix
if ($suffix !== '') {
$position = utf8_strrpos($path, $suffix);
if ($position !== false) {
$path = utf8_substr($path, 0, $position);
}
}
return $path;
}
示例15: resize
/**
*
* @param filename string
* @param width
* @param height
* @param type char [default, w, h]
* default = scale with white space,
* w = fill according to width,
* h = fill according to height
*
*/
public function resize($filename, $width, $height, $type = "h")
{
if (!file_exists(DIR_IMAGE . $filename) || !is_file(DIR_IMAGE . $filename)) {
return;
}
if (!$width) {
$width = 1;
}
if (!$height) {
$height = 1;
}
$info = pathinfo($filename);
$extension = $info['extension'];
$old_image = $filename;
$new_image = 'cache/' . utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '-' . $width . 'x' . $height . $type . '.' . $extension;
if (!file_exists(DIR_IMAGE . $new_image) || filemtime(DIR_IMAGE . $old_image) > filemtime(DIR_IMAGE . $new_image)) {
$path = '';
$directories = explode('/', dirname(str_replace('../', '', $new_image)));
foreach ($directories as $directory) {
$path = $path . '/' . $directory;
if (!file_exists(DIR_IMAGE . $path)) {
@mkdir(DIR_IMAGE . $path, 0777);
}
}
list($width_orig, $height_orig) = getimagesize(DIR_IMAGE . $old_image);
if ($width_orig != $width || $height_orig != $height) {
$image = new Image(DIR_IMAGE . $old_image);
$image->resize($width, $height, $type);
if ($width >= 500 || $height >= 500) {
$quality = 90;
} else {
$quality = 75;
}
$image->save(DIR_IMAGE . $new_image, $quality);
} else {
copy(DIR_IMAGE . $old_image, DIR_IMAGE . $new_image);
}
}
// Prevent cache-anti-refresh which could show old images
return $this->url->link('image/' . $new_image, filemtime(DIR_IMAGE . $new_image));
}