secured privacy
This commit is contained in:
1 parent
bb8a2fe7c9
commit
19fe6d30f4
10 files changed
+1666
-1305
No files matched your search
+40
-11
@@ -1,17 +1,46 @@
|
||||
<?php
|
||||
$host = "sql207.infinityfree.com";
|
||||
$ngalan = "if0_41132991";
|
||||
$sikreto = "j4kklvOrKqiZkG";
|
||||
$deytabeys = "if0_41132991_portfolio";
|
||||
// $host = "127.0.0.1";
|
||||
// $ngalan = "root";
|
||||
// $sikreto = "";
|
||||
// $deytabeys = "porfoliowai";
|
||||
|
||||
/**
|
||||
* Load environment variables from a .env file.
|
||||
* PHP 7.x compatible — no str_starts_with().
|
||||
*/
|
||||
function loadEnv($path) {
|
||||
if (!file_exists($path)) {
|
||||
return;
|
||||
}
|
||||
$lines = file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||
if ($lines === false) return;
|
||||
foreach ($lines as $line) {
|
||||
$line = trim($line);
|
||||
if ($line === '' || $line[0] === '#') {
|
||||
continue;
|
||||
}
|
||||
$parts = explode('=', $line, 2);
|
||||
if (count($parts) < 2) continue;
|
||||
$key = trim($parts[0]);
|
||||
$value = trim($parts[1]);
|
||||
if (!array_key_exists($key, $_ENV)) {
|
||||
$_ENV[$key] = $value;
|
||||
putenv("$key=$value");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Try project root .env — works both locally and on InfinityFree
|
||||
$envPath = __DIR__ . '/../.env';
|
||||
loadEnv($envPath);
|
||||
|
||||
$host = getenv('DB_HOST') ?: ($_ENV['DB_HOST'] ?? '');
|
||||
$ngalan = getenv('DB_USER') ?: ($_ENV['DB_USER'] ?? '');
|
||||
$sikreto = getenv('DB_PASS') ?: ($_ENV['DB_PASS'] ?? '');
|
||||
$deytabeys = getenv('DB_NAME') ?: ($_ENV['DB_NAME'] ?? '');
|
||||
|
||||
if (empty($host) || empty($ngalan)) {
|
||||
die('<p style="color:red;font-family:monospace;padding:20px">DB config missing. Please create a .env file from .env.example</p>');
|
||||
}
|
||||
|
||||
$mysqli = new mysqli($host, $ngalan, $sikreto, $deytabeys);
|
||||
|
||||
if ($mysqli->connect_error) {
|
||||
die("Connection failed: " . $mysqli->connect_error);
|
||||
die('<p style="color:red;font-family:monospace;padding:20px">Connection failed: ' . htmlspecialchars($mysqli->connect_error) . '</p>');
|
||||
}
|
||||
echo "<script>console.log('Yung database mo ay gumagana langya ka!');</script>";
|
||||
?>
|
||||
Reference in new issue
Block a user