uawdijnntqw1x1x1
IP : 52.14.45.84
Hostname : ns1.eurodns.top
Kernel : Linux ns1.eurodns.top 4.18.0-553.5.1.lve.1.el7h.x86_64 #1 SMP Fri Jun 14 14:24:52 UTC 2024 x86_64
Disable Function : mail,sendmail,exec,passthru,shell_exec,system,popen,curl_multi_exec,show_source,eval,open_base
OS : Linux
PATH:
/
home
/
sudancam
/
public_html
/
..
/
.trash
/
install
/
..
/
catalog.1
/
model
/
account
/
address.php
/
/
<?php namespace Opencart\Catalog\Model\Account; class Address extends \Opencart\System\Engine\Model { public function addAddress(int $customer_id, array $data): int { $this->db->query("INSERT INTO `" . DB_PREFIX . "address` SET `customer_id` = '" . (int)$customer_id . "', `firstname` = '" . $this->db->escape((string)$data['firstname']) . "', `lastname` = '" . $this->db->escape((string)$data['lastname']) . "', `company` = '" . $this->db->escape((string)$data['company']) . "', `address_1` = '" . $this->db->escape((string)$data['address_1']) . "', `address_2` = '" . $this->db->escape((string)$data['address_2']) . "', `postcode` = '" . $this->db->escape((string)$data['postcode']) . "', `city` = '" . $this->db->escape((string)$data['city']) . "', `zone_id` = '" . (int)$data['zone_id'] . "', `country_id` = '" . (int)$data['country_id'] . "', `custom_field` = '" . $this->db->escape(isset($data['custom_field']) ? json_encode($data['custom_field']) : '') . "', `default` = '" . (isset($data['default']) ? (int)$data['default'] : 0) . "'"); $address_id = $this->db->getLastId(); if (!empty($data['default'])) { $this->db->query("UPDATE `" . DB_PREFIX . "address` SET `default` = '0' WHERE `address_id` != '" . (int)$address_id . "' AND `customer_id` = '" . (int)$this->customer->getId() . "'"); } return $address_id; } public function editAddress(int $address_id, array $data): void { $this->db->query("UPDATE `" . DB_PREFIX . "address` SET `firstname` = '" . $this->db->escape((string)$data['firstname']) . "', `lastname` = '" . $this->db->escape((string)$data['lastname']) . "', `company` = '" . $this->db->escape((string)$data['company']) . "', `address_1` = '" . $this->db->escape((string)$data['address_1']) . "', `address_2` = '" . $this->db->escape((string)$data['address_2']) . "', `postcode` = '" . $this->db->escape((string)$data['postcode']) . "', `city` = '" . $this->db->escape((string)$data['city']) . "', `zone_id` = '" . (int)$data['zone_id'] . "', `country_id` = '" . (int)$data['country_id'] . "', `custom_field` = '" . $this->db->escape(isset($data['custom_field']) ? json_encode($data['custom_field']) : '') . "', `default` = '" . (isset($data['default']) ? (int)$data['default'] : 0) . "' WHERE `address_id` = '" . (int)$address_id . "' AND `customer_id` = '" . (int)$this->customer->getId() . "'"); if (!empty($data['default'])) { $this->db->query("UPDATE `" . DB_PREFIX . "address` SET `default` = '0' WHERE `address_id` != '" . (int)$address_id . "' AND `customer_id` = '" . (int)$this->customer->getId() . "'"); } } public function deleteAddress(int $address_id): void { $this->db->query("DELETE FROM `" . DB_PREFIX . "address` WHERE `address_id` = '" . (int)$address_id . "' AND `customer_id` = '" . (int)$this->customer->getId() . "'"); } public function getAddress(int $address_id): array { $address_query = $this->db->query("SELECT DISTINCT * FROM `" . DB_PREFIX . "address` WHERE `address_id` = '" . (int)$address_id . "' AND `customer_id` = '" . (int)$this->customer->getId() . "'"); if ($address_query->num_rows) { $this->load->model('localisation/country'); $country_info = $this->model_localisation_country->getCountry($address_query->row['country_id']); if ($country_info) { $country = $country_info['name']; $iso_code_2 = $country_info['iso_code_2']; $iso_code_3 = $country_info['iso_code_3']; $address_format = $country_info['address_format']; } else { $country = ''; $iso_code_2 = ''; $iso_code_3 = ''; $address_format = ''; } $this->load->model('localisation/zone'); $zone_info = $this->model_localisation_zone->getZone($address_query->row['zone_id']); if ($zone_info) { $zone = $zone_info['name']; $zone_code = $zone_info['code']; } else { $zone = ''; $zone_code = ''; } $find = [ '{firstname}', '{lastname}', '{company}', '{address_1}', '{address_2}', '{city}', '{postcode}', '{zone}', '{zone_code}', '{country}' ]; $replace = [ 'firstname' => $address_query->row['firstname'], 'lastname' => $address_query->row['lastname'], 'company' => $address_query->row['company'], 'address_1' => $address_query->row['address_1'], 'address_2' => $address_query->row['address_2'], 'city' => $address_query->row['city'], 'postcode' => $address_query->row['postcode'], 'zone' => $zone, 'zone_code' => $zone_code, 'country' => $country ]; $address_format = str_replace(["\r\n", "\r", "\n"], '<br />', preg_replace(["/\s\s+/", "/\r\r+/", "/\n\n+/"], '<br />', trim(str_replace($find, $replace, $address_format)))); return [ 'address_id' => $address_query->row['address_id'], 'firstname' => $address_query->row['firstname'], 'lastname' => $address_query->row['lastname'], 'company' => $address_query->row['company'], 'address_1' => $address_query->row['address_1'], 'address_2' => $address_query->row['address_2'], 'postcode' => $address_query->row['postcode'], 'city' => $address_query->row['city'], 'zone_id' => $address_query->row['zone_id'], 'zone' => $zone, 'zone_code' => $zone_code, 'country_id' => $address_query->row['country_id'], 'country' => $country, 'iso_code_2' => $iso_code_2, 'iso_code_3' => $iso_code_3, 'address_format' => $address_format, 'custom_field' => json_decode($address_query->row['custom_field'], true), 'default' => $address_query->row['default'] ]; } else { return []; } } public function getAddresses(): array { $address_data = []; $query = $this->db->query("SELECT `address_id` FROM `" . DB_PREFIX . "address` WHERE `customer_id` = '" . (int)$this->customer->getId() . "'"); foreach ($query->rows as $result) { $address_info = $this->getAddress($result['address_id']); if ($address_info) { $address_data[$result['address_id']] = $address_info; } } return $address_data; } public function getTotalAddresses(): int { $query = $this->db->query("SELECT COUNT(*) AS `total` FROM `" . DB_PREFIX . "address` WHERE `customer_id` = '" . (int)$this->customer->getId() . "'"); return $query->row['total']; } }
/home/sudancam/public_html/../.trash/install/../catalog.1/model/account/address.php