1
0
Fork 0
feedizer-php/htdocs/includes/init.inc.php
2015-11-13 23:51:46 +01:00

52 lines
1.5 KiB
PHP

<?php
define('BASE_PATH', realpath(dirname(__FILE__) . '/..') . '/');
set_include_path(get_include_path()
. PATH_SEPARATOR . BASE_PATH . 'includes'
. PATH_SEPARATOR . BASE_PATH . 'libraries'
);
require('config.inc.php');
// Versioning
define('VERSION', '0.0');
define('CRAWLER_VERSION', '0.2');
define('CRAWLER_LAST_UPDATED', filemtime(BASE_PATH . 'scripts/crawler.php'));
// For a better death!
function handle_exception($e) {
error_log('An exception occurred: ' . $e);
echo "An error occured: " . $e->getMessage() . "<br>\n<br>\n"
."Please notify the site administrator (webmaster at tigris dot fanir dot de) and include the information in the box below:<br>\n"
."<textarea style='width: 100%; max-width: 80em; height: 20em;' readonly>"
."Timestamp: " . strftime('%c') . "\n"
."\n"
."Code: " . $e->getCode() . "\n"
."Message: " . $e->getMessage() . "\n";
if ($e->getPrevious()) {
echo "\n"
."Previous exception:\n"
."Code: " . $e->getPrevious()->getCode() . "\n"
."Message: " . $e->getPrevious()->getMessage() . "\n";
}
echo "</textarea>";
exit($e->getCode());
}
set_exception_handler('handle_exception');
// Connect to DB
try {
$db = new PDO(DB_DSN, DB_USER, DB_PASS);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
throw new Exception('Cannot connect to database', 16, $e);
}
// Load database abstraction
require('database.inc.php');
// Load helper functions
require('helpers.inc.php');