key = $key; } function encrypt($value) { if (!$this->key) { return $value; } $output = ''; for ($i = 0; $i < strlen($value); $i++) { $char = substr($value, $i, 1); $key = substr($this->key, ($i % strlen($this->key)) - 1, 1); $char = chr(ord($char) + ord($key)); $output .= $char; } return base64_encode($output); } function decrypt($value) { if (!$this->key) { return $value; } $output = ''; $value = base64_decode($value); for ($i = 0; $i < strlen($value); $i++) { $char = substr($value, $i, 1); $key = substr($this->key, ($i % strlen($this->key)) - 1, 1); $char = chr(ord($char) - ord($key)); $output .= $char; } return $output; }}?>file = $file; $info = getimagesize($file); $this->info = array( 'width' => $info[0], 'height' => $info[1], 'bits' => $info['bits'], 'mime' => $info['mime'] ); $this->image = $this->create($file); } else { exit('Error: Could not load image ' . $file . '!'); } } private function create($image) { $mime = $this->info['mime']; if ($mime == 'image/gif') { return imagecreatefromgif($image); } elseif ($mime == 'image/png') { return imagecreatefrompng($image); } elseif ($mime == 'image/jpeg') { return imagecreatefromjpeg($image); } elseif ($mime == 'image/webp') { return imagecreatefromwebp($image); } } public function save($file, $quality = 90) { $info = pathinfo($file); $extension = strtolower($info['extension']); if ($this->image instanceof \GdImage || is_resource($this->image)) { if ($extension == 'jpeg' || $extension == 'jpg') { imagejpeg($this->image, $file, $quality); } elseif($extension == 'png') { imagepng($this->image, $file, 0); } elseif($extension == 'gif') { imagegif($this->image, $file); } elseif($extension == 'webp') { imagewebp($this->image, $file, $quality); } imagedestroy($this->image); } } public function resize($width = 0, $height = 0) { if (!$this->info['width'] || !$this->info['height']) { return; } $xpos = 0; $ypos = 0; $scale = min($width / $this->info['width'], $height / $this->info['height']); if ($scale == 1 && $this->info['mime'] != 'image/png') { return; } $new_width = (int)($this->info['width'] * $scale); $new_height = (int)($this->info['height'] * $scale); $xpos = (int)(($width - $new_width) / 2); $ypos = (int)(($height - $new_height) / 2); $image_old = $this->image; $this->image = imagecreatetruecolor($width, $height); if (isset($this->info['mime']) && $this->info['mime'] == 'image/png') { imagealphablending($this->image, false); imagesavealpha($this->image, true); $background = imagecolorallocatealpha($this->image, 255, 255, 255, 127); imagecolortransparent($this->image, $background); } else { $background = imagecolorallocate($this->image, 255, 255, 255); } imagefilledrectangle($this->image, 0, 0, $width, $height, $background); imagecopyresampled($this->image, $image_old, $xpos, $ypos, 0, 0, $new_width, $new_height, $this->info['width'], $this->info['height']); imagedestroy($image_old); $this->info['width'] = $width; $this->info['height'] = $height; } public function watermark($file, $position = 'bottomright') { $watermark = $this->create($file); $watermark_width = imagesx($watermark); $watermark_height = imagesy($watermark); switch($position) { case 'topleft': $watermark_pos_x = 0; $watermark_pos_y = 0; break; case 'topright': $watermark_pos_x = $this->info['width'] - $watermark_width; $watermark_pos_y = 0; break; case 'bottomleft': $watermark_pos_x = 0; $watermark_pos_y = $this->info['height'] - $watermark_height; break; case 'bottomright': $watermark_pos_x = $this->info['width'] - $watermark_width; $watermark_pos_y = $this->info['height'] - $watermark_height; break; } imagecopy($this->image, $watermark, $watermark_pos_x, $watermark_pos_y, 0, 0, 120, 40); imagedestroy($watermark); } public function crop($top_x, $top_y, $bottom_x, $bottom_y) { $image_old = $this->image; $this->image = imagecreatetruecolor($bottom_x - $top_x, $bottom_y - $top_y); imagecopy($this->image, $image_old, 0, 0, $top_x, $top_y, $this->info['width'], $this->info['height']); imagedestroy($image_old); $this->info['width'] = $bottom_x - $top_x; $this->info['height'] = $bottom_y - $top_y; } public function rotate($degree, $color = 'FFFFFF') { $rgb = $this->html2rgb($color); $this->image = imagerotate($this->image, $degree, imagecolorallocate($this->image, $rgb[0], $rgb[1], $rgb[2])); $this->info['width'] = imagesx($this->image); $this->info['height'] = imagesy($this->image); } private function filter($filter) { imagefilter($this->image, $filter); } private function text($text, $x = 0, $y = 0, $size = 5, $color = '000000') { $rgb = $this->html2rgb($color); imagestring($this->image, $size, $x, $y, $text, imagecolorallocate($this->image, $rgb[0], $rgb[1], $rgb[2])); } private function merge($file, $x = 0, $y = 0, $opacity = 100) { $merge = $this->create($file); $merge_width = imagesx($image); $merge_height = imagesy($image); imagecopymerge($this->image, $merge, $x, $y, 0, 0, $merge_width, $merge_height, $opacity); } private function html2rgb($color) { if ($color[0] == '#') { $color = substr($color, 1); } if (strlen($color) == 6) { list($r, $g, $b) = array($color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5]); } elseif (strlen($color) == 3) { list($r, $g, $b) = array($color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2]); } else { return false; } $r = hexdec($r); $g = hexdec($g); $b = hexdec($b); return array($r, $g, $b); } }?>directory = $directory; } public function get($key) { return (isset($this->data[$key]) ? $this->data[$key] : $key); } public function load($filename) { $file = DIR_LANGUAGE . $this->directory . '/' . $filename . '.php'; if (file_exists($file)) { $_ = array(); require(VQMod::modCheck($file)); $this->data = array_merge($this->data, $_); return $this->data; } $file = DIR_LANGUAGE . $this->default . '/' . $filename . '.php'; if (file_exists($file)) { $_ = array(); require(VQMod::modCheck($file)); $this->data = array_merge($this->data, $_); return $this->data; } else { trigger_error('Error: Could not load language ' . $filename . '!'); exit(); } }}?>filename = $filename; } public function write($message) { $file = DIR_LOGS . $this->filename; $handle = fopen($file, 'a+'); fwrite($handle, date('Y-m-d G:i:s') . ' - ' . $message . "\n"); fclose($handle); }}?>total; if ($this->page < 1) { $page = 1; } else { $page = $this->page; } if (!(int)$this->limit) { $limit = 10; } else { $limit = $this->limit; } $num_links = $this->num_links; $num_pages = ceil($total / $limit); $output = ''; if ($page > 1) { $output .= ' ' . $this->text_first . ' ' . $this->text_prev . ' '; } if ($num_pages > 1) { if ($num_pages <= $num_links) { $start = 1; $end = $num_pages; } else { $start = $page - floor($num_links / 2); $end = $page + floor($num_links / 2); if ($start < 1) { $end += abs($start) + 1; $start = 1; } if ($end > $num_pages) { $start -= ($end - $num_pages); $end = $num_pages; } } if ($start > 1) { $output .= ' .... '; } for ($i = $start; $i <= $end; $i++) { if ($page == $i) { $output .= ' ' . $i . ' '; } else { $output .= ' ' . $i . ' '; } } if ($end < $num_pages) { $output .= ' .... '; } } if ($page < $num_pages) { $output .= ' ' . $this->text_next . ' ' . $this->text_last . ' '; } $find = array( '{start}', '{end}', '{total}', '{pages}' ); $replace = array( ($total) ? (($page - 1) * $limit) + 1 : 0, ((($page - 1) * $limit) > ($total - $limit)) ? $total : ((($page - 1) * $limit) + $limit), $total, $num_pages ); return ($output ? '' : '') . '
' . str_replace($find, $replace, $this->text) . '
'; }}?>clean($_GET); $_POST = $this->clean($_POST); $_REQUEST = $this->clean($_REQUEST); $_COOKIE = $this->clean($_COOKIE); $_FILES = $this->clean($_FILES); $_SERVER = $this->clean($_SERVER); $this->get = $_GET; $this->post = $_POST; $this->request = $_REQUEST; $this->cookie = $_COOKIE; $this->files = $_FILES; $this->server = $_SERVER; } public function clean($data) { if (is_array($data)) { foreach ($data as $key => $value) { unset($data[$key]); $data[$this->clean($key)] = $this->clean($value); } } else { $data = htmlspecialchars($data, ENT_COMPAT); } return $data; }}?>config = $registry->get('config'); $this->db = $registry->get('db'); $this->request = $registry->get('request'); $this->session = $registry->get('session'); if (isset($this->session->data['affiliate_id'])) { $affiliate_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "affiliate WHERE affiliate_id = '" . (int)$this->session->data['affiliate_id'] . "' AND status = '1'"); if ($affiliate_query->num_rows) { $this->affiliate_id = $affiliate_query->row['affiliate_id']; $this->firstname = $affiliate_query->row['firstname']; $this->lastname = $affiliate_query->row['lastname']; $this->email = $affiliate_query->row['email']; $this->telephone = $affiliate_query->row['telephone']; $this->fax = $affiliate_query->row['fax']; $this->code = $affiliate_query->row['code']; $this->db->query("UPDATE " . DB_PREFIX . "affiliate SET ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "' WHERE affiliate_id = '" . (int)$this->session->data['affiliate_id'] . "'"); } else { $this->logout(); } } } public function login($email, $password) { $affiliate_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "affiliate WHERE email = '" . $this->db->escape($email) . "' AND password = '" . $this->db->escape(md5($password)) . "' AND status = '1' AND approved = '1'"); if ($affiliate_query->num_rows) { $this->session->data['affiliate_id'] = $affiliate_query->row['affiliate_id']; $this->affiliate_id = $affiliate_query->row['affiliate_id']; $this->firstname = $affiliate_query->row['firstname']; $this->lastname = $affiliate_query->row['lastname']; $this->email = $affiliate_query->row['email']; $this->telephone = $affiliate_query->row['telephone']; $this->fax = $affiliate_query->row['fax']; $this->code = $affiliate_query->row['code']; return true; } else { return false; } } public function logout() { unset($this->session->data['affiliate_id']); $this->affiliate_id = ''; $this->firstname = ''; $this->lastname = ''; $this->email = ''; $this->telephone = ''; $this->fax = ''; } public function isLogged() { return $this->affiliate_id; } public function getId() { return $this->affiliate_id; } public function getFirstName() { return $this->firstname; } public function getLastName() { return $this->lastname; } public function getEmail() { return $this->email; } public function getTelephone() { return $this->telephone; } public function getFax() { return $this->fax; } public function getCode() { return $this->code; } }?>config = $registry->get('config'); $this->customer = $registry->get('customer'); $this->db = $registry->get('db'); $this->session = $registry->get('session'); if (isset($this->session->data['shipping_country_id']) || isset($this->session->data['shipping_zone_id'])) { $this->setShippingAddress($this->session->data['shipping_country_id'], $this->session->data['shipping_zone_id']); } elseif ($this->config->get('config_tax_default') == 'shipping') { $this->setShippingAddress($this->config->get('config_country_id'), $this->config->get('config_zone_id')); } if (isset($this->session->data['payment_country_id']) || isset($this->session->data['payment_zone_id'])) { $this->setPaymentAddress($this->session->data['payment_country_id'], $this->session->data['payment_zone_id']); } elseif ($this->config->get('config_tax_default') == 'payment') { $this->setPaymentAddress($this->config->get('config_country_id'), $this->config->get('config_zone_id')); } $this->setStoreAddress($this->config->get('config_country_id'), $this->config->get('config_zone_id')); } public function setShippingAddress($country_id, $zone_id) { $this->shipping_address = array( 'country_id' => $country_id, 'zone_id' => $zone_id ); } public function setPaymentAddress($country_id, $zone_id) { $this->payment_address = array( 'country_id' => $country_id, 'zone_id' => $zone_id ); } public function setStoreAddress($country_id, $zone_id) { $this->store_address = array( 'country_id' => $country_id, 'zone_id' => $zone_id ); } public function calculate($value, $tax_class_id, $calculate = true) { if ($tax_class_id && $calculate) { $amount = $this->getTax($value, $tax_class_id); return $value + $amount; } else { return $value; } } public function getTax($value, $tax_class_id) { $amount = 0; $tax_rates = $this->getRates($value, $tax_class_id); foreach ($tax_rates as $tax_rate) { $amount += $tax_rate['amount']; } return $amount; } public function getRateName($tax_rate_id) { $tax_query = $this->db->query("SELECT name FROM " . DB_PREFIX . "tax_rate WHERE tax_rate_id = '" . (int)$tax_rate_id . "'"); if ($tax_query->num_rows) { return $tax_query->row['name']; } else { return false; } } public function getRates($value, $tax_class_id) { $tax_rates = array(); if ($this->customer->isLogged()) { $customer_group_id = $this->customer->getCustomerGroupId(); } else { $customer_group_id = $this->config->get('config_customer_group_id'); } if ($this->shipping_address) { $tax_query = $this->db->query("SELECT tr2.tax_rate_id, tr2.name, tr2.rate, tr2.type, tr1.priority FROM " . DB_PREFIX . "tax_rule tr1 LEFT JOIN " . DB_PREFIX . "tax_rate tr2 ON (tr1.tax_rate_id = tr2.tax_rate_id) INNER JOIN " . DB_PREFIX . "tax_rate_to_customer_group tr2cg ON (tr2.tax_rate_id = tr2cg.tax_rate_id) LEFT JOIN " . DB_PREFIX . "zone_to_geo_zone z2gz ON (tr2.geo_zone_id = z2gz.geo_zone_id) LEFT JOIN " . DB_PREFIX . "geo_zone gz ON (tr2.geo_zone_id = gz.geo_zone_id) WHERE tr1.tax_class_id = '" . (int)$tax_class_id . "' AND tr1.based = 'shipping' AND tr2cg.customer_group_id = '" . (int)$customer_group_id . "' AND z2gz.country_id = '" . (int)$this->shipping_address['country_id'] . "' AND (z2gz.zone_id = '0' OR z2gz.zone_id = '" . (int)$this->shipping_address['zone_id'] . "') ORDER BY tr1.priority ASC"); foreach ($tax_query->rows as $result) { $tax_rates[$result['tax_rate_id']] = array( 'tax_rate_id' => $result['tax_rate_id'], 'name' => $result['name'], 'rate' => $result['rate'], 'type' => $result['type'], 'priority' => $result['priority'] ); } } if ($this->payment_address) { $tax_query = $this->db->query("SELECT tr2.tax_rate_id, tr2.name, tr2.rate, tr2.type, tr1.priority FROM " . DB_PREFIX . "tax_rule tr1 LEFT JOIN " . DB_PREFIX . "tax_rate tr2 ON (tr1.tax_rate_id = tr2.tax_rate_id) INNER JOIN " . DB_PREFIX . "tax_rate_to_customer_group tr2cg ON (tr2.tax_rate_id = tr2cg.tax_rate_id) LEFT JOIN " . DB_PREFIX . "zone_to_geo_zone z2gz ON (tr2.geo_zone_id = z2gz.geo_zone_id) LEFT JOIN " . DB_PREFIX . "geo_zone gz ON (tr2.geo_zone_id = gz.geo_zone_id) WHERE tr1.tax_class_id = '" . (int)$tax_class_id . "' AND tr1.based = 'payment' AND tr2cg.customer_group_id = '" . (int)$customer_group_id . "' AND z2gz.country_id = '" . (int)$this->payment_address['country_id'] . "' AND (z2gz.zone_id = '0' OR z2gz.zone_id = '" . (int)$this->payment_address['zone_id'] . "') ORDER BY tr1.priority ASC"); foreach ($tax_query->rows as $result) { $tax_rates[$result['tax_rate_id']] = array( 'tax_rate_id' => $result['tax_rate_id'], 'name' => $result['name'], 'rate' => $result['rate'], 'type' => $result['type'], 'priority' => $result['priority'] ); } } if ($this->store_address) { $tax_query = $this->db->query("SELECT tr2.tax_rate_id, tr2.name, tr2.rate, tr2.type, tr1.priority FROM " . DB_PREFIX . "tax_rule tr1 LEFT JOIN " . DB_PREFIX . "tax_rate tr2 ON (tr1.tax_rate_id = tr2.tax_rate_id) INNER JOIN " . DB_PREFIX . "tax_rate_to_customer_group tr2cg ON (tr2.tax_rate_id = tr2cg.tax_rate_id) LEFT JOIN " . DB_PREFIX . "zone_to_geo_zone z2gz ON (tr2.geo_zone_id = z2gz.geo_zone_id) LEFT JOIN " . DB_PREFIX . "geo_zone gz ON (tr2.geo_zone_id = gz.geo_zone_id) WHERE tr1.tax_class_id = '" . (int)$tax_class_id . "' AND tr1.based = 'store' AND tr2cg.customer_group_id = '" . (int)$customer_group_id . "' AND z2gz.country_id = '" . (int)$this->store_address['country_id'] . "' AND (z2gz.zone_id = '0' OR z2gz.zone_id = '" . (int)$this->store_address['zone_id'] . "') ORDER BY tr1.priority ASC"); foreach ($tax_query->rows as $result) { $tax_rates[$result['tax_rate_id']] = array( 'tax_rate_id' => $result['tax_rate_id'], 'name' => $result['name'], 'rate' => $result['rate'], 'type' => $result['type'], 'priority' => $result['priority'] ); } } $tax_rate_data = array(); foreach ($tax_rates as $tax_rate) { if (isset($tax_rate_data[$tax_rate['tax_rate_id']])) { $amount = $tax_rate_data[$tax_rate['tax_rate_id']]['amount']; } else { $amount = 0; } if ($tax_rate['type'] == 'F') { $amount += $tax_rate['rate']; } elseif ($tax_rate['type'] == 'P') { $amount += ($value / 100 * $tax_rate['rate']); } $tax_rate_data[$tax_rate['tax_rate_id']] = array( 'tax_rate_id' => $tax_rate['tax_rate_id'], 'name' => $tax_rate['name'], 'rate' => $tax_rate['rate'], 'type' => $tax_rate['type'], 'amount' => $amount ); } return $tax_rate_data; } public function has($tax_class_id) { return isset($this->taxes[$tax_class_id]); }}?>db = $registry->get('db'); $this->config = $registry->get('config'); $weight_class_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "weight_class wc LEFT JOIN " . DB_PREFIX . "weight_class_description wcd ON (wc.weight_class_id = wcd.weight_class_id) WHERE wcd.language_id = '" . (int)$this->config->get('config_language_id') . "'"); foreach ($weight_class_query->rows as $result) { $this->weights[$result['weight_class_id']] = array( 'weight_class_id' => $result['weight_class_id'], 'title' => $result['title'], 'unit' => $result['unit'], 'value' => $result['value'] ); } } public function convert($value, $from, $to) { if ($from == $to) { return $value; } if (isset($this->weights[$from])) { $from = $this->weights[$from]['value']; } else { $from = 0; } if (isset($this->weights[$to])) { $to = $this->weights[$to]['value']; } else { $to = 0; } return $value * ($to / $from); } public function format($value, $weight_class_id, $decimal_point = '.', $thousand_point = ',') { if (isset($this->weights[$weight_class_id])) { return number_format($value, 2, $decimal_point, $thousand_point) . $this->weights[$weight_class_id]['unit']; } else { return number_format($value, 2, $decimal_point, $thousand_point); } } public function getUnit($weight_class_id) { if (isset($this->weights[$weight_class_id])) { return $this->weights[$weight_class_id]['unit']; } else { return ''; } } }?>db = $registry->get('db'); $this->config = $registry->get('config'); $length_class_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "length_class mc LEFT JOIN " . DB_PREFIX . "length_class_description mcd ON (mc.length_class_id = mcd.length_class_id) WHERE mcd.language_id = '" . (int)$this->config->get('config_language_id') . "'"); foreach ($length_class_query->rows as $result) { $this->lengths[$result['length_class_id']] = array( 'length_class_id' => $result['length_class_id'], 'title' => $result['title'], 'unit' => $result['unit'], 'value' => $result['value'] ); } } public function convert($value, $from, $to) { if ($from == $to) { return $value; } if (isset($this->lengths[$from])) { $from = $this->lengths[$from]['value']; } else { $from = 0; } if (isset($this->lengths[$to])) { $to = $this->lengths[$to]['value']; } else { $to = 0; } return $value * ($to / $from); } public function format($value, $length_class_id, $decimal_point = '.', $thousand_point = ',') { if (isset($this->lengths[$length_class_id])) { return number_format($value, 2, $decimal_point, $thousand_point) . $this->lengths[$length_class_id]['unit']; } else { return number_format($value, 2, $decimal_point, $thousand_point); } } public function getUnit($length_class_id) { if (isset($this->lengths[$length_class_id])) { return $this->lengths[$length_class_id]['unit']; } else { return ''; } } }?>