| Server IP : 104.21.21.239 / Your IP : 216.73.216.11 Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.5 System : Linux ip-172-31-69-123.ec2.internal 6.1.176-223.369.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jul 24 13:34:27 UTC 2026 x86_64 User : ec2-user ( 1000) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/home2/cgny/cron/ |
Upload File : |
<?php
function cgny_db_connect(): mysqli
{
static $mysqli = null;
if ($mysqli instanceof mysqli) {
return $mysqli;
}
$iniPath = __DIR__ . '/db.ini';
if (!is_readable($iniPath)) {
throw new RuntimeException('Missing db.ini at ' . $iniPath);
}
$cfg = parse_ini_file($iniPath, false, INI_SCANNER_RAW);
if ($cfg === false) {
throw new RuntimeException('Unable to parse db.ini');
}
foreach (['host', 'database', 'user', 'password'] as $key) {
if (empty($cfg[$key])) {
throw new RuntimeException('db.ini missing required key: ' . $key);
}
}
$port = isset($cfg['port']) ? (int) $cfg['port'] : 3306;
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$mysqli = new mysqli($cfg['host'], $cfg['user'], $cfg['password'], $cfg['database'], $port);
$mysqli->set_charset('utf8mb4');
return $mysqli;
}
function cgny_cron_log(string $script, string $message): void
{
$logDir = __DIR__ . '/logs';
if (!is_dir($logDir)) {
mkdir($logDir, 0750, true);
}
$line = date('Y-m-d H:i:s') . ' [' . $script . '] ' . $message . PHP_EOL;
file_put_contents($logDir . '/' . $script . '.log', $line, FILE_APPEND | LOCK_EX);
}