function CreateDBConnection() { global $DATABASE; try { return new PDO($DATABASE['connection'], $DATABASE['username'], $DATABASE['password'], array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); } catch (Exception $e) { if (SHOW_ERRORS) { echo 'Failed to connect to the database, please ensure the DB is running and the connection settings are correct.'; die; } else { ErrorPage(500); } } }
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; echo "<response>\n"; echo "<statusCode>400</statusCode>\n"; echo "<statusText>{$error}</statusText>\n"; echo "</response>\n"; } elseif ($json) { if (!strlen($error)) { $error = 'Your test request was intercepted by our spam filters (or because we need to talk to you about how you are submitting tests)'; } $ret = array(); $ret['statusCode'] = 400; $ret['statusText'] = $error; header("Content-type: application/json"); echo json_encode($ret); } elseif (strlen($error)) { ErrorPage($error); } else { include 'blocked.php'; } } } /** * Update the given location into the Test variable. This is needed for * submitting multiple-locations tests in one-shot. * This also involves updating the locationText, browser and connectivity * values that are applicable for the new location. * * @param mixed $test * @param mixed $new_location */ function UpdateLocation(&$test, &$locations, $new_location)
// page body require TEMPLATEROOT . 'body.php'; // page modal if (file_exists(MODALROOT . $target['source'] . EXT)) { require MODALROOT . $target['source'] . EXT; } // page view require VIEWROOT . $target['source'] . EXT; // get page output $page = ob_get_clean(); // page title if (!isset($title) && isset($target['title'])) { $title = $target['title']; } // page header require TEMPLATEROOT . 'header.php'; // page echo $page; // page footer require TEMPLATEROOT . 'footer.php'; } catch (Exception $e) { if (SHOW_ERRORS) { ob_get_clean(); echo $e->getMessage(); die; } else { ErrorPage(500); } } } }