HEX
Server: nginx/1.28.1
System: Linux 10-41-63-61 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64
User: www (1001)
PHP: 7.4.33
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/www.zqgwfu.top/admin/model/localisation/calling_code.php
<?php
class ModelLocalisationCallingCode extends Model {
	public function addCallingCode($data) {
		$this->db->query("INSERT INTO " . DB_PREFIX . "calling_code SET name = '" . $this->db->escape((string)$data['name']) . "', code = '" . $this->db->escape((string)$data['code']) . "', sort_order = '" . (int)$data['sort_order'] . "', status = '" . (int)$data['status'] . "', date_modified = '" . date('Y-m-d H:i:s') . "', date_added = '" . date('Y-m-d H:i:s') . "'");

		$this->cache->delete('calling_code');
		
		return $this->db->getLastId();
	}

	public function editCallingCode($calling_code_id, $data) {
		$this->db->query("UPDATE " . DB_PREFIX . "calling_code SET name = '" . $this->db->escape((string)$data['name']) . "', code = '" . $this->db->escape((string)$data['code']) . "', sort_order = '" . (int)$data['sort_order'] . "', status = '" . (int)$data['status'] . "', date_modified = '" . date('Y-m-d H:i:s') . "' WHERE calling_code_id = '" . (int)$calling_code_id . "'");

		$this->cache->delete('calling_code');
	}

	public function deleteCallingCode($calling_code_id) {
		$this->db->query("DELETE FROM " . DB_PREFIX . "calling_code WHERE calling_code_id = '" . (int)$calling_code_id . "'");

		$this->cache->delete('calling_code');
	}

	public function getCallingCode($calling_code_id) {
		$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "calling_code WHERE calling_code_id = '" . (int)$calling_code_id . "'");

		return $query->row;
	}

	public function getCallingCodes($data = array()) {
		if ($data) {
			$sql = "SELECT * FROM " . DB_PREFIX . "calling_code";

			$sort_data = array(
				'name',
				'code',
				'sort_order'
			);

			if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
				$sql .= " ORDER BY " . $data['sort'];
			} else {
				$sql .= " ORDER BY name";
			}

			if (isset($data['order']) && ($data['order'] == 'DESC')) {
				$sql .= " DESC";
			} else {
				$sql .= " ASC";
			}

			if (isset($data['start']) || isset($data['limit'])) {
				if ($data['start'] < 0) {
					$data['start'] = 0;
				}

				if ($data['limit'] < 1) {
					$data['limit'] = 20;
				}

				$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
			}

			$query = $this->db->query($sql);

			return $query->rows;
		} else {
			$calling_code_data = $this->cache->get('calling_code.admin');

			if (!$calling_code_data) {
				$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "calling_code ORDER BY sort_order, name ASC");

				$calling_code_data = $query->rows;

				$this->cache->set('calling_code.admin', $calling_code_data);
			}

			return $calling_code_data;
		}
	}

	public function getTotalCallingCodes() {
		$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "calling_code");

		return $query->row['total'];
	}
}