- Fix storage permissions to use 'www' user instead of 'www-data' - Fix UserModel getAllForAdmin query to avoid placeholders in LIMIT/OFFSET - Import missing modules: Advertising, Dashboard, Analytics - Update deploy script to copy files to public directory
523 lines
22 KiB
PHP
523 lines
22 KiB
PHP
<?php
|
|
namespace App\Modules\Advertising\Models;
|
|
|
|
use App\Core\DatabaseManager;
|
|
|
|
class TrackingModel
|
|
{
|
|
private DatabaseManager $db;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->db = DatabaseManager::getInstance();
|
|
}
|
|
|
|
/**
|
|
* Find tracker by ID
|
|
*/
|
|
public function find(int $id): ?array
|
|
{
|
|
$result = $this->db->fetch("
|
|
SELECT
|
|
t.id AS tracker_id,
|
|
t.cuid AS tracker_cuid,
|
|
t.name AS tracker_name,
|
|
t.tracking_url AS tracking_url,
|
|
t.final_tracking_url AS final_tracking_url,
|
|
t.tracking_params AS tracking_params,
|
|
t.tracking_type AS tracking_type,
|
|
t.is_active AS tracker_status,
|
|
t.created_at AS created_date,
|
|
t.updated_at AS updated_date,
|
|
|
|
f.name AS format_name,
|
|
b.name AS brand_name,
|
|
lt.name AS landing_type_name,
|
|
c.name AS creative_name
|
|
FROM
|
|
advertising_trackers t
|
|
LEFT JOIN
|
|
advertising_formats f ON t.format_id = f.id
|
|
LEFT JOIN
|
|
advertising_brands b ON t.brand_id = b.id
|
|
LEFT JOIN
|
|
advertising_brand_landing_types lt ON t.landing_type_id = lt.id
|
|
LEFT JOIN
|
|
advertising_creatives c ON t.creative_id = c.id
|
|
WHERE
|
|
t.id = ? AND t.is_active = 1
|
|
", [$id]);
|
|
|
|
if ($result && $result['tracking_params']) {
|
|
$result['tracking_params'] = json_decode($result['tracking_params'], true) ?: [];
|
|
}
|
|
|
|
return $result ?: null;
|
|
}
|
|
|
|
public function recordView(int $trackerId, int $creativeId, array $data): bool
|
|
{
|
|
$sql = "INSERT INTO advertising_events (
|
|
tracker_id, creative_id, event_type, session_id, ip_address, ip_long,
|
|
user_agent, referer, event_data, country_code, country_name, region_code,
|
|
region_name, city, latitude, longitude, device_type, browser, browser_version,
|
|
platform, screen_width, screen_height, timestamp
|
|
) VALUES (
|
|
:tracker_id, :creative_id, 'view', :session_id, :ip_address, :ip_long,
|
|
:user_agent, :referer, :event_data, :country_code, :country_name, :region_code,
|
|
:region_name, :city, :latitude, :longitude, :device_type, :browser, :browser_version,
|
|
:platform, :screen_width, :screen_height, NOW()
|
|
)";
|
|
|
|
return $this->db->query($sql, [
|
|
':tracker_id' => $trackerId,
|
|
':creative_id' => $creativeId,
|
|
':session_id' => $data['session_id'] ?? '',
|
|
':ip_address' => $data['ip_address'] ?? '',
|
|
':ip_long' => ip2long($data['ip_address'] ?? '') ?: 0,
|
|
':user_agent' => $data['user_agent'] ?? null,
|
|
':referer' => $data['referer'] ?? null,
|
|
':event_data' => json_encode($data['event_data'] ?? []),
|
|
':country_code' => $data['country_code'] ?? null,
|
|
':country_name' => $data['country_name'] ?? null,
|
|
':region_code' => $data['region_code'] ?? null,
|
|
':region_name' => $data['region_name'] ?? null,
|
|
':city' => $data['city'] ?? null,
|
|
':latitude' => $data['latitude'] ?? null,
|
|
':longitude' => $data['longitude'] ?? null,
|
|
':device_type' => $data['device_type'] ?? 'desktop',
|
|
':browser' => $data['browser'] ?? null,
|
|
':browser_version' => $data['browser_version'] ?? null,
|
|
':platform' => $data['platform'] ?? null,
|
|
':screen_width' => $data['screen_width'] ?? null,
|
|
':screen_height' => $data['screen_height'] ?? null
|
|
]) > 0;
|
|
}
|
|
|
|
public function recordClick(int $trackerId, int $creativeId, array $data): bool
|
|
{
|
|
$eventData = [
|
|
'click_x' => $data['click_x'] ?? null,
|
|
'click_y' => $data['click_y'] ?? null,
|
|
'click_position' => $data['click_position'] ?? null
|
|
];
|
|
|
|
$sql = "INSERT INTO advertising_events (
|
|
tracker_id, creative_id, event_type, session_id, ip_address, ip_long,
|
|
user_agent, referer, event_data, country_code, country_name, region_code,
|
|
region_name, city, latitude, longitude, device_type, browser, browser_version,
|
|
platform, screen_width, screen_height, timestamp
|
|
) VALUES (
|
|
:tracker_id, :creative_id, 'click', :session_id, :ip_address, :ip_long,
|
|
:user_agent, :referer, :event_data, :country_code, :country_name, :region_code,
|
|
:region_name, :city, :latitude, :longitude, :device_type, :browser, :browser_version,
|
|
:platform, :screen_width, :screen_height, NOW()
|
|
)";
|
|
|
|
return $this->db->query($sql, [
|
|
':tracker_id' => $trackerId,
|
|
':creative_id' => $creativeId,
|
|
':session_id' => $data['session_id'] ?? '',
|
|
':ip_address' => $data['ip_address'] ?? '',
|
|
':ip_long' => ip2long($data['ip_address'] ?? '') ?: 0,
|
|
':user_agent' => $data['user_agent'] ?? null,
|
|
':referer' => $data['referer'] ?? null,
|
|
':event_data' => json_encode($eventData),
|
|
':country_code' => $data['country_code'] ?? null,
|
|
':country_name' => $data['country_name'] ?? null,
|
|
':region_code' => $data['region_code'] ?? null,
|
|
':region_name' => $data['region_name'] ?? null,
|
|
':city' => $data['city'] ?? null,
|
|
':latitude' => $data['latitude'] ?? null,
|
|
':longitude' => $data['longitude'] ?? null,
|
|
':device_type' => $data['device_type'] ?? 'desktop',
|
|
':browser' => $data['browser'] ?? null,
|
|
':browser_version' => $data['browser_version'] ?? null,
|
|
':platform' => $data['platform'] ?? null,
|
|
':screen_width' => $data['screen_width'] ?? null,
|
|
':screen_height' => $data['screen_height'] ?? null
|
|
]) > 0;
|
|
}
|
|
|
|
public function recordRegister(int $trackerId, int $creativeId, array $data): bool
|
|
{
|
|
$eventData = [
|
|
'registration_data' => $data['registration_data'] ?? [],
|
|
'form_data' => $data['form_data'] ?? []
|
|
];
|
|
|
|
$sql = "INSERT INTO advertising_events (
|
|
tracker_id, creative_id, event_type, session_id, ip_address, ip_long,
|
|
user_agent, referer, event_data, country_code, country_name, region_code,
|
|
region_name, city, latitude, longitude, device_type, browser, browser_version,
|
|
platform, screen_width, screen_height, timestamp
|
|
) VALUES (
|
|
:tracker_id, :creative_id, 'register', :session_id, :ip_address, :ip_long,
|
|
:user_agent, :referer, :event_data, :country_code, :country_name, :region_code,
|
|
:region_name, :city, :latitude, :longitude, :device_type, :browser, :browser_version,
|
|
:platform, :screen_width, :screen_height, NOW()
|
|
)";
|
|
|
|
return $this->db->query($sql, [
|
|
':tracker_id' => $trackerId,
|
|
':creative_id' => $creativeId,
|
|
':session_id' => $data['session_id'] ?? '',
|
|
':ip_address' => $data['ip_address'] ?? '',
|
|
':ip_long' => ip2long($data['ip_address'] ?? '') ?: 0,
|
|
':user_agent' => $data['user_agent'] ?? null,
|
|
':referer' => $data['referer'] ?? null,
|
|
':event_data' => json_encode($eventData),
|
|
':country_code' => $data['country_code'] ?? null,
|
|
':country_name' => $data['country_name'] ?? null,
|
|
':region_code' => $data['region_code'] ?? null,
|
|
':region_name' => $data['region_name'] ?? null,
|
|
':city' => $data['city'] ?? null,
|
|
':latitude' => $data['latitude'] ?? null,
|
|
':longitude' => $data['longitude'] ?? null,
|
|
':device_type' => $data['device_type'] ?? 'desktop',
|
|
':browser' => $data['browser'] ?? null,
|
|
':browser_version' => $data['browser_version'] ?? null,
|
|
':platform' => $data['platform'] ?? null,
|
|
':screen_width' => $data['screen_width'] ?? null,
|
|
':screen_height' => $data['screen_height'] ?? null
|
|
]) > 0;
|
|
}
|
|
|
|
public function getEventStats(int $campaignId, ?string $startDate = null, ?string $endDate = null): array
|
|
{
|
|
$sql = "SELECT
|
|
DATE(e.timestamp) as date,
|
|
COUNT(DISTINCT CASE WHEN e.event_type = 'view' THEN e.id END) as views,
|
|
COUNT(DISTINCT CASE WHEN e.event_type = 'click' THEN e.id END) as clicks,
|
|
COUNT(DISTINCT CASE WHEN e.event_type = 'register' THEN e.id END) as registers,
|
|
ROUND(COUNT(DISTINCT CASE WHEN e.event_type = 'click' THEN e.id END) * 100.0 /
|
|
NULLIF(COUNT(DISTINCT CASE WHEN e.event_type = 'view' THEN e.id END), 0), 4) as ctr
|
|
FROM advertising_events e
|
|
JOIN advertising_trackers t ON e.tracker_id = t.id
|
|
JOIN advertising_formats f ON t.format_id = f.id
|
|
WHERE f.campaign_id = :campaign_id";
|
|
|
|
$params = [':campaign_id' => $campaignId];
|
|
|
|
if ($startDate) {
|
|
$sql .= " AND DATE(e.timestamp) >= :start_date";
|
|
$params[':start_date'] = $startDate;
|
|
}
|
|
|
|
if ($endDate) {
|
|
$sql .= " AND DATE(e.timestamp) <= :end_date";
|
|
$params[':end_date'] = $endDate;
|
|
}
|
|
|
|
$sql .= " GROUP BY DATE(e.timestamp) ORDER BY date DESC";
|
|
|
|
return $this->db->fetchAll($sql, $params) ?: [];
|
|
}
|
|
|
|
public function getGeoStats(int $campaignId, ?string $startDate = null, ?string $endDate = null): array
|
|
{
|
|
$sql = "SELECT
|
|
e.country_code,
|
|
e.country_code as country_name,
|
|
COUNT(DISTINCT CASE WHEN e.event_type = 'view' THEN e.id END) as views,
|
|
COUNT(DISTINCT CASE WHEN e.event_type = 'click' THEN e.id END) as clicks,
|
|
COUNT(DISTINCT CASE WHEN e.event_type = 'register' THEN e.id END) as registers,
|
|
ROUND(COUNT(DISTINCT CASE WHEN e.event_type = 'click' THEN e.id END) * 100.0 /
|
|
NULLIF(COUNT(DISTINCT CASE WHEN e.event_type = 'view' THEN e.id END), 0), 4) as ctr
|
|
FROM advertising_events e
|
|
JOIN advertising_trackers t ON e.tracker_id = t.id
|
|
JOIN advertising_formats f ON t.format_id = f.id
|
|
WHERE f.campaign_id = :campaign_id AND e.country_code IS NOT NULL";
|
|
|
|
$params = [':campaign_id' => $campaignId];
|
|
|
|
if ($startDate) {
|
|
$sql .= " AND DATE(e.timestamp) >= :start_date";
|
|
$params[':start_date'] = $startDate;
|
|
}
|
|
|
|
if ($endDate) {
|
|
$sql .= " AND DATE(e.timestamp) <= :end_date";
|
|
$params[':end_date'] = $endDate;
|
|
}
|
|
|
|
$sql .= " GROUP BY e.country_code ORDER BY views DESC";
|
|
|
|
return $this->db->fetchAll($sql, $params) ?: [];
|
|
}
|
|
|
|
public function getDeviceStats(int $campaignId, ?string $startDate = null, ?string $endDate = null): array
|
|
{
|
|
$sql = "SELECT
|
|
e.device_type,
|
|
COUNT(DISTINCT CASE WHEN e.event_type = 'view' THEN e.id END) as views,
|
|
COUNT(DISTINCT CASE WHEN e.event_type = 'click' THEN e.id END) as clicks,
|
|
COUNT(DISTINCT CASE WHEN e.event_type = 'register' THEN e.id END) as registers,
|
|
ROUND(COUNT(DISTINCT CASE WHEN e.event_type = 'click' THEN e.id END) * 100.0 /
|
|
NULLIF(COUNT(DISTINCT CASE WHEN e.event_type = 'view' THEN e.id END), 0), 4) as ctr
|
|
FROM advertising_events e
|
|
JOIN advertising_trackers t ON e.tracker_id = t.id
|
|
JOIN advertising_formats f ON t.format_id = f.id
|
|
WHERE f.campaign_id = :campaign_id";
|
|
|
|
$params = [':campaign_id' => $campaignId];
|
|
|
|
if ($startDate) {
|
|
$sql .= " AND DATE(e.timestamp) >= :start_date";
|
|
$params[':start_date'] = $startDate;
|
|
}
|
|
|
|
if ($endDate) {
|
|
$sql .= " AND DATE(e.timestamp) <= :end_date";
|
|
$params[':end_date'] = $endDate;
|
|
}
|
|
|
|
$sql .= " GROUP BY e.device_type ORDER BY views DESC";
|
|
|
|
return $this->db->fetchAll($sql, $params) ?: [];
|
|
}
|
|
|
|
public function detectFraud(string $ipAddress, int $threshold = 5, int $timeWindow = 60): bool
|
|
{
|
|
$sql = "SELECT COUNT(*) as count FROM advertising_events
|
|
WHERE ip_address = :ip_address
|
|
AND event_type = 'click'
|
|
AND timestamp >= DATE_SUB(NOW(), INTERVAL :time_window SECOND)";
|
|
|
|
$result = $this->db->fetch($sql, [
|
|
':ip_address' => $ipAddress,
|
|
':time_window' => $timeWindow
|
|
]);
|
|
|
|
return (int) ($result['count'] ?? 0) > $threshold;
|
|
}
|
|
|
|
public function recordFraudDetection(string $ipAddress, string $fraudType, string $reason, float $confidence = 0.0): bool
|
|
{
|
|
$sql = "INSERT INTO advertising_fraud_detection (
|
|
ip_address, ip_long, fraud_type, detection_reason, confidence_score
|
|
) VALUES (
|
|
:ip_address, :ip_long, :fraud_type, :detection_reason, :confidence_score
|
|
)";
|
|
|
|
return $this->db->query($sql, [
|
|
':ip_address' => $ipAddress,
|
|
':ip_long' => ip2long($ipAddress) ?: 0,
|
|
':fraud_type' => $fraudType,
|
|
':detection_reason' => $reason,
|
|
':confidence_score' => $confidence
|
|
]) > 0;
|
|
}
|
|
|
|
public function isIpBlocked(string $ipAddress): bool
|
|
{
|
|
$sql = "SELECT COUNT(*) as count FROM advertising_fraud_detection
|
|
WHERE ip_address = :ip_address AND is_blocked = 1";
|
|
|
|
$result = $this->db->fetch($sql, [':ip_address' => $ipAddress]);
|
|
return (int) ($result['count'] ?? 0) > 0;
|
|
}
|
|
|
|
public function isAppBlocked(string $userAgent, string $referer = ''): bool
|
|
{
|
|
// Lista de apps bloqueados
|
|
$blockedApps = [
|
|
'FBAN', 'FBAV', 'FB_IAB', 'FB4A', 'FBIOS', 'FacebookApp',
|
|
'Instagram', 'TikTok', 'TwitterAndroid', 'TwitteriPhone',
|
|
'LinkedInApp', 'WhatsApp', 'Telegram', 'Snapchat'
|
|
];
|
|
|
|
$userAgentUpper = strtoupper($userAgent);
|
|
|
|
foreach ($blockedApps as $app) {
|
|
if (strpos($userAgentUpper, strtoupper($app)) !== false) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public function isBotTraffic(string $userAgent): bool
|
|
{
|
|
$botPatterns = [
|
|
'googlebot', 'bingbot', 'yandex', 'baiduspider', 'facebookexternalhit',
|
|
'twitterbot', 'linkedinbot', 'whatsapp', 'telegrambot', 'slackbot',
|
|
'bot', 'crawler', 'spider', 'scraper', 'curl', 'wget', 'python',
|
|
'java', 'php', 'node', 'axios', 'fetch', 'http'
|
|
];
|
|
|
|
$userAgentLower = strtolower($userAgent);
|
|
|
|
foreach ($botPatterns as $pattern) {
|
|
if (strpos($userAgentLower, $pattern) !== false) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public function analyzeTrafficSource(string $userAgent, string $referer = ''): array
|
|
{
|
|
$analysis = [
|
|
'is_app' => false,
|
|
'is_bot' => false,
|
|
'is_mobile' => false,
|
|
'browser' => 'unknown',
|
|
'platform' => 'unknown',
|
|
'app_name' => null,
|
|
'risk_score' => 0.0
|
|
];
|
|
|
|
// Detectar se é app
|
|
if ($this->isAppBlocked($userAgent, $referer)) {
|
|
$analysis['is_app'] = true;
|
|
$analysis['risk_score'] += 0.3;
|
|
|
|
// Identificar app específico
|
|
if (preg_match('/FBAN|FBAV|FB_IAB|FB4A|FBIOS|FacebookApp/i', $userAgent)) {
|
|
$analysis['app_name'] = 'Facebook';
|
|
} elseif (preg_match('/Instagram/i', $userAgent)) {
|
|
$analysis['app_name'] = 'Instagram';
|
|
} elseif (preg_match('/TikTok/i', $userAgent)) {
|
|
$analysis['app_name'] = 'TikTok';
|
|
} elseif (preg_match('/TwitterAndroid|TwitteriPhone/i', $userAgent)) {
|
|
$analysis['app_name'] = 'Twitter';
|
|
} elseif (preg_match('/LinkedInApp/i', $userAgent)) {
|
|
$analysis['app_name'] = 'LinkedIn';
|
|
} elseif (preg_match('/WhatsApp/i', $userAgent)) {
|
|
$analysis['app_name'] = 'WhatsApp';
|
|
}
|
|
}
|
|
|
|
// Detectar se é bot
|
|
if ($this->isBotTraffic($userAgent)) {
|
|
$analysis['is_bot'] = true;
|
|
$analysis['risk_score'] += 0.5;
|
|
}
|
|
|
|
// Detectar mobile
|
|
if (preg_match('/Mobile|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i', $userAgent)) {
|
|
$analysis['is_mobile'] = true;
|
|
}
|
|
|
|
// Detectar browser
|
|
if (preg_match('/Chrome/i', $userAgent)) {
|
|
$analysis['browser'] = 'Chrome';
|
|
} elseif (preg_match('/Firefox/i', $userAgent)) {
|
|
$analysis['browser'] = 'Firefox';
|
|
} elseif (preg_match('/Safari/i', $userAgent)) {
|
|
$analysis['browser'] = 'Safari';
|
|
} elseif (preg_match('/Edge/i', $userAgent)) {
|
|
$analysis['browser'] = 'Edge';
|
|
}
|
|
|
|
// Detectar platform
|
|
if (preg_match('/Windows/i', $userAgent)) {
|
|
$analysis['platform'] = 'Windows';
|
|
} elseif (preg_match('/Mac OS X/i', $userAgent)) {
|
|
$analysis['platform'] = 'macOS';
|
|
} elseif (preg_match('/Linux/i', $userAgent)) {
|
|
$analysis['platform'] = 'Linux';
|
|
} elseif (preg_match('/Android/i', $userAgent)) {
|
|
$analysis['platform'] = 'Android';
|
|
} elseif (preg_match('/iOS|iPhone|iPad/i', $userAgent)) {
|
|
$analysis['platform'] = 'iOS';
|
|
}
|
|
|
|
return $analysis;
|
|
}
|
|
|
|
public function recordTrafficAnalysis(array $analysis, string $sessionId, string $ipAddress, string $userAgent, string $referer = '', string $blockedReason = ''): bool
|
|
{
|
|
$sql = "INSERT INTO advertising_traffic_analysis (
|
|
session_id, ip_address, ip_long, user_agent, referer, is_app, is_bot,
|
|
is_mobile, app_name, browser, platform, risk_score, blocked_reason, is_blocked
|
|
) VALUES (
|
|
:session_id, :ip_address, :ip_long, :user_agent, :referer, :is_app, :is_bot,
|
|
:is_mobile, :app_name, :browser, :platform, :risk_score, :blocked_reason, :is_blocked
|
|
)";
|
|
|
|
return $this->db->query($sql, [
|
|
':session_id' => $sessionId,
|
|
':ip_address' => $ipAddress,
|
|
':ip_long' => ip2long($ipAddress) ?: 0,
|
|
':user_agent' => $userAgent,
|
|
':referer' => $referer,
|
|
':is_app' => $analysis['is_app'],
|
|
':is_bot' => $analysis['is_bot'],
|
|
':is_mobile' => $analysis['is_mobile'],
|
|
':app_name' => $analysis['app_name'],
|
|
':browser' => $analysis['browser'],
|
|
':platform' => $analysis['platform'],
|
|
':risk_score' => $analysis['risk_score'],
|
|
':blocked_reason' => $blockedReason,
|
|
':is_blocked' => !empty($blockedReason)
|
|
]) > 0;
|
|
}
|
|
|
|
public function getTrafficStats(?string $startDate = null, ?string $endDate = null): array
|
|
{
|
|
$sql = "SELECT
|
|
COUNT(*) as total_requests,
|
|
COUNT(CASE WHEN is_blocked = 1 THEN 1 END) as blocked_requests,
|
|
COUNT(CASE WHEN is_app = 1 THEN 1 END) as app_requests,
|
|
COUNT(CASE WHEN is_bot = 1 THEN 1 END) as bot_requests,
|
|
COUNT(CASE WHEN is_mobile = 1 THEN 1 END) as mobile_requests,
|
|
AVG(risk_score) as avg_risk_score,
|
|
app_name,
|
|
COUNT(CASE WHEN app_name IS NOT NULL THEN 1 END) as app_count
|
|
FROM advertising_traffic_analysis
|
|
WHERE 1=1";
|
|
|
|
$params = [];
|
|
|
|
if ($startDate) {
|
|
$sql .= " AND DATE(created_at) >= :start_date";
|
|
$params[':start_date'] = $startDate;
|
|
}
|
|
|
|
if ($endDate) {
|
|
$sql .= " AND DATE(created_at) <= :end_date";
|
|
$params[':end_date'] = $endDate;
|
|
}
|
|
|
|
$sql .= " GROUP BY app_name ORDER BY app_count DESC";
|
|
|
|
return $this->db->fetchAll($sql, $params) ?: [];
|
|
}
|
|
|
|
public function getBlockedAppsStats(): array
|
|
{
|
|
$sql = "SELECT
|
|
app_name,
|
|
COUNT(*) as blocked_count,
|
|
COUNT(DISTINCT ip_address) as unique_ips,
|
|
AVG(risk_score) as avg_risk_score,
|
|
MAX(created_at) as last_blocked
|
|
FROM advertising_traffic_analysis
|
|
WHERE is_blocked = 1 AND app_name IS NOT NULL
|
|
GROUP BY app_name
|
|
ORDER BY blocked_count DESC";
|
|
|
|
return $this->db->fetchAll($sql) ?: [];
|
|
}
|
|
|
|
public function getTodayViewsCount(): int
|
|
{
|
|
$sql = "SELECT COUNT(*) as count FROM advertising_events
|
|
WHERE event_type = 'view' AND DATE(timestamp) = CURDATE()";
|
|
$result = $this->db->fetch($sql);
|
|
return (int) ($result['count'] ?? 0);
|
|
}
|
|
|
|
public function getTodayClicksCount(): int
|
|
{
|
|
$sql = "SELECT COUNT(*) as count FROM advertising_events
|
|
WHERE event_type = 'click' AND DATE(timestamp) = CURDATE()";
|
|
$result = $this->db->fetch($sql);
|
|
return (int) ($result['count'] ?? 0);
|
|
}
|
|
}
|