Research Labs

2026-09-17 20:36 UTCopen field data · live

inc/db.php

Snapshot 2026.09.17-a2894de (current) · 21 lines · 807 bytes · tree · plain text

SHA-256 62d133f26334fc0d823f434c6b993f7be7a52f6ac3d2fa8686eb46c62e2b91db
Functions: db L4-L16 · log_activity L17-L21
1<?php
2require_once __DIR__.'/../config.php';
3require_once __DIR__.'/defaults.php';
4function db(): PDO {
5 static $pdo=null;
6 if($pdo===null){
7 try{
8 $pdo=new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8mb4',DB_USER,DB_PASS,
9 [PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION,PDO::ATTR_DEFAULT_FETCH_MODE=>PDO::FETCH_ASSOC]);
10 }catch(PDOException $e){
11 http_response_code(503);
12 die('Database connection failed. Check config.php credentials, then run diagnose.php for a full report.');
13 }
14 }
15 return $pdo;
16}
17function log_activity(string $actor,string $action,string $detail=''): void {
18 try{ db()->prepare('INSERT INTO activity_log(ts,actor,action,detail) VALUES(NOW(),?,?,?)')
19 ->execute([$actor,$action,mb_substr($detail,0,400)]); }catch(Throwable $e){}
20}
21

Lines can be cited as inc/db.php L120-L140, platform code 2026.09.17-a2894de; add #L120-L140 to this page's address to highlight them. Source shown for scrutiny of the research platform. All rights reserved. Not offered as installable software.