Replace the short open tags and the removed functions (mcrypt, mysql_error, salt-less crypt). Decode the reCAPTCHA reply as JSON, turn off mysqli exceptions, drop stripslashes(), and default missing input values. Fix the misplaced continue in prune_images().
33 lines
874 B
PHP
33 lines
874 B
PHP
<?php
|
|
require_once(__DIR__ . '/config.lib.php');
|
|
global $db;
|
|
function open_db($state) {
|
|
global $db;
|
|
if ($state == 'open') {
|
|
if (!$db) {
|
|
$hostname = config('DB_HOST', 'localhost');
|
|
$view_user = config('DB_USER');
|
|
$view_pass = config('DB_PASS');
|
|
$db_name = config('DB_NAME');
|
|
// PHP 8.1+ throws exceptions by default; keep the old return-value checks working
|
|
mysqli_report(MYSQLI_REPORT_OFF);
|
|
$db = new mysqli($hostname, $view_user, $view_pass, $db_name);
|
|
if ($db->connect_error) {
|
|
die ("Unable to connect to database");
|
|
die ('Connect Error (' . $db->connect_errno . ') ' . $db->connect_error);
|
|
}
|
|
return TRUE;
|
|
} else
|
|
return FALSE;
|
|
}
|
|
else if ($state == 'close') {
|
|
if ($db) {
|
|
$db->close();
|
|
$db = NULL;
|
|
return TRUE;
|
|
} else
|
|
return FALSE;
|
|
}
|
|
}
|
|
?>
|