Code restructure push
This commit is contained in:
27
src/config/connection.php
Normal file
27
src/config/connection.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
// Disable mysqli exceptions so we can handle connection errors gracefully
|
||||
mysqli_report(MYSQLI_REPORT_OFF);
|
||||
|
||||
$dbhost = $_ENV['DB_HOST'];
|
||||
$dbuser = $_ENV['DB_USER'];
|
||||
$dbpass = $_ENV['DB_PASS'];
|
||||
$dbname = $_ENV['DB_NAME'];
|
||||
$salt = $_ENV['SALT'];
|
||||
|
||||
// echo "hello. ". $dbhost;
|
||||
|
||||
if(!$conn = @mysqli_connect($dbhost, $dbuser, $dbpass, $dbname)){
|
||||
// Log the error to file instead of stderr (no red output)
|
||||
@error_log("Database Connection Error: " . mysqli_connect_error(), 3, dirname(__DIR__) . "/logs/db_errors.log");
|
||||
$conn = null;
|
||||
$db = null;
|
||||
} else {
|
||||
date_default_timezone_set('Africa/Johannesburg');
|
||||
|
||||
// Initialize DatabaseService for modern queries
|
||||
require_once(__DIR__ . '/../../classes/DatabaseService.php');
|
||||
$db = new DatabaseService($conn);
|
||||
}
|
||||
|
||||
|
||||
6
src/config/env.php
Normal file
6
src/config/env.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/../../');
|
||||
$dotenv->load();
|
||||
|
||||
2804
src/config/functions.php
Normal file
2804
src/config/functions.php
Normal file
File diff suppressed because it is too large
Load Diff
20
src/config/run_migration.php
Normal file
20
src/config/run_migration.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
require 'env.php';
|
||||
require 'connection.php';
|
||||
|
||||
$conn = openDatabaseConnection();
|
||||
|
||||
if (!$conn) {
|
||||
die('Database connection failed');
|
||||
}
|
||||
|
||||
$sql = file_get_contents('migrations/001_phase1_security_schema.sql');
|
||||
|
||||
if ($conn->multi_query($sql)) {
|
||||
echo "✓ Migration executed successfully\n";
|
||||
} else {
|
||||
echo "✗ Migration error: " . $conn->error . "\n";
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
?>
|
||||
15
src/config/session.php
Normal file
15
src/config/session.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
function Message(){
|
||||
if(isset($_SESSION["message"])){
|
||||
$output="<div class=\"message\">";
|
||||
$output .= htmlentities($_SESSION['message']);
|
||||
$output .="</div>";
|
||||
$_SESSION['message']=null;
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user