From: Christian Weiske Date: Sun, 23 Mar 2014 12:34:16 +0000 (+0100) Subject: use central include file X-Git-Url: https://git.cweiske.de/stapibas.git/commitdiff_plain/536e6f9dd62dc02a94970e39783631e6b7e80615?hp=facbe390acb49ffa8ab225e8b4c382759fa0302d use central include file --- diff --git a/www/render.php b/www/render.php index e460b42..b844dbe 100644 --- a/www/render.php +++ b/www/render.php @@ -5,11 +5,7 @@ namespace stapibas; * * @param string $url URL to get content for */ -header('HTTP/1.0 500 Internal Server Error'); -header('Content-type: text/plain'); - -require_once __DIR__ . '/../data/config.php'; -require_once 'stapibas/autoloader.php'; +require_once 'www-header.php'; if (!isset($_GET['url'])) { header('HTTP/1.0 400 Bad Request'); diff --git a/www/request-feed-update.php b/www/request-feed-update.php index d82de07..4ca1b27 100644 --- a/www/request-feed-update.php +++ b/www/request-feed-update.php @@ -5,10 +5,7 @@ * * Has to be called via POST, url given in parameter "url". */ -header('HTTP/1.0 500 Internal Server Error'); -header('Content-type: text/plain'); - -require_once __DIR__ . '/../data/config.php'; +require_once 'www-header.php'; if (!isset($_POST['url'])) { header('HTTP/1.0 400 Bad Request'); @@ -28,7 +25,6 @@ if (filter_var($url, FILTER_VALIDATE_URL) === false) { } -$db = new PDO($dbdsn, $dbuser, $dbpass); $res = $db->query( 'SELECT f_id, f_needs_update FROM feeds WHERE f_url = ' . $db->quote($url) ); diff --git a/www/www-header.php b/www/www-header.php new file mode 100644 index 0000000..f42ebc7 --- /dev/null +++ b/www/www-header.php @@ -0,0 +1,11 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +?> diff --git a/www/xmlrpc.php b/www/xmlrpc.php index e5c2755..4b7ce04 100644 --- a/www/xmlrpc.php +++ b/www/xmlrpc.php @@ -3,14 +3,7 @@ namespace stapibas; /** * Simply stores all pingbacks in the database. */ -header('HTTP/1.0 500 Internal Server error'); -header('Content-type: text/plain'); - -require_once __DIR__ . '/../data/config.php'; -require_once 'stapibas/autoloader.php'; - -$db = new PDO($dbdsn, $dbuser, $dbpass); -$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +require_once 'www-header.php'; $s = new \PEAR2\Services\Linkback\Server(); $s->addCallback(new Linkback_DbStorage($db));