mirror of
https://github.com/YGGverse/YGGo.git
synced 2025-01-24 13:34:25 +00:00
add connection exceptions
This commit is contained in:
parent
142d496108
commit
de28d85a71
@ -26,7 +26,16 @@ require_once(__DIR__ . '/../config/app.php');
|
||||
require_once(__DIR__ . '/../library/mysql.php');
|
||||
|
||||
// Connect database
|
||||
$db = new MySQL(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
|
||||
try {
|
||||
|
||||
$db = new MySQL(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
|
||||
|
||||
} catch(Exception $e) {
|
||||
|
||||
var_dump($e);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
// Reset banned hosts
|
||||
$hostsBansRemoved = $db->resetBannedHostPages(time() - CLEAN_HOST_PAGE_BAN_SECONDS_OFFSET);
|
||||
|
@ -1048,4 +1048,4 @@ echo 'HTTP Requests total size: ' . $httpRequestsSizeTotal . PHP_EOL;
|
||||
echo 'HTTP Download total size: ' . $httpDownloadSizeTotal . PHP_EOL;
|
||||
echo 'HTTP Requests total time: ' . $httpRequestsTimeTotal . PHP_EOL . PHP_EOL;
|
||||
|
||||
echo 'Total time: ' . $executionTimeTotal . PHP_EOL . PHP_EOL;
|
||||
echo 'Total time: ' . $executionTimeTotal . PHP_EOL . PHP_EOL;
|
@ -19,12 +19,29 @@ if (API_ENABLED) {
|
||||
|
||||
if (API_SEARCH_ENABLED) {
|
||||
|
||||
// Connect database
|
||||
$db = new MySQL(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
|
||||
|
||||
// Connect Sphinx search server
|
||||
$sphinx = new SphinxQL(SPHINX_HOST, SPHINX_PORT);
|
||||
try {
|
||||
|
||||
$sphinx = new SphinxQL(SPHINX_HOST, SPHINX_PORT);
|
||||
|
||||
} catch(Exception $e) {
|
||||
|
||||
var_dump($e);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
// Connect database
|
||||
try {
|
||||
|
||||
$db = new MySQL(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
|
||||
|
||||
} catch(Exception $e) {
|
||||
|
||||
var_dump($e);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
// Filter request data
|
||||
$type = !empty($_GET['type']) ? Filter::url($_GET['type']) : 'text';
|
||||
@ -77,7 +94,16 @@ if (API_ENABLED) {
|
||||
if (API_HOSTS_ENABLED) {
|
||||
|
||||
// Connect database
|
||||
$db = new MySQL(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
|
||||
try {
|
||||
|
||||
$db = new MySQL(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
|
||||
|
||||
} catch(Exception $e) {
|
||||
|
||||
var_dump($e);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
$response = [
|
||||
'status' => true,
|
||||
|
@ -44,8 +44,16 @@ switch ($type) {
|
||||
case 'snap':
|
||||
|
||||
// Connect database
|
||||
$db = new MySQL(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
|
||||
try {
|
||||
|
||||
$db = new MySQL(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
|
||||
|
||||
} catch(Exception $e) {
|
||||
|
||||
var_dump($e);
|
||||
|
||||
exit;
|
||||
}
|
||||
// Init request
|
||||
$crc32ip = crc32(!empty($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '');
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user