first commit

This commit is contained in:
Konstantin
2026-05-30 09:27:58 +03:00
commit de0344d218
2371 changed files with 661486 additions and 0 deletions
+60
View File
@@ -0,0 +1,60 @@
<?php
class ModelReportOnline extends Model {
public function getOnline($data = array()) {
$sql = "SELECT co.ip, co.customer_id, co.url, co.referer, co.date_added FROM " . DB_PREFIX . "customer_online co LEFT JOIN " . DB_PREFIX . "customer c ON (co.customer_id = c.customer_id)";
$implode = array();
if (!empty($data['filter_ip'])) {
$implode[] = "co.ip LIKE '" . $this->db->escape($data['filter_ip']) . "'";
}
if (!empty($data['filter_customer'])) {
$implode[] = "co.customer_id > 0 AND CONCAT(c.firstname, ' ', c.lastname) LIKE '" . $this->db->escape($data['filter_customer']) . "'";
}
if ($implode) {
$sql .= " WHERE " . implode(" AND ", $implode);
}
$sql .= " ORDER BY co.date_added DESC";
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;
}
public function getTotalOnline($data = array()) {
$sql = "SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "customer_online` co LEFT JOIN " . DB_PREFIX . "customer c ON (co.customer_id = c.customer_id)";
$implode = array();
if (!empty($data['filter_ip'])) {
$implode[] = "co.ip LIKE '" . $this->db->escape($data['filter_ip']) . "'";
}
if (!empty($data['filter_customer'])) {
$implode[] = "co.customer_id > 0 AND CONCAT(c.firstname, ' ', c.lastname) LIKE '" . $this->db->escape($data['filter_customer']) . "'";
}
if ($implode) {
$sql .= " WHERE " . implode(" AND ", $implode);
}
$query = $this->db->query($sql);
return $query->row['total'];
}
}
+30
View File
@@ -0,0 +1,30 @@
<?php
class ModelReportStatistics extends Model {
public function getStatistics() {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "statistics");
return $query->rows;
}
public function getValue($code) {
$query = $this->db->query("SELECT value FROM " . DB_PREFIX . "statistics WHERE `code` = '" . $this->db->escape($code) . "'");
if ($query->num_rows) {
return $query->row['value'];
} else {
return null;
}
}
public function addValue($code, $value) {
$this->db->query("UPDATE " . DB_PREFIX . "statistics SET `value` = (`value` + '" . (float)$value . "') WHERE `code` = '" . $this->db->escape($code) . "'");
}
public function editValue($code, $value) {
$this->db->query("UPDATE " . DB_PREFIX . "statistics SET `value` = '" . (float)$value . "' WHERE `code` = '" . $this->db->escape($code) . "'");
}
public function removeValue($code, $value) {
$this->db->query("UPDATE " . DB_PREFIX . "statistics SET `value` = (`value` - '" . (float)$value . "') WHERE `code` = '" . $this->db->escape($code) . "'");
}
}