davadmin/admin/common.inc.php

75 lines
2.1 KiB
PHP
Raw Normal View History

2007-08-28 10:18:04 +02:00
<?php
/**
* Common code for WebDAVAdmin.
*
* @author Jan Dittberner <jan@dittberner.info>
* @version $Id$
* @license GPL
* @package WebDAVAdmin
*
* Copyright (c) 2007 Jan Dittberner
*
* This file is part of WebDAVAdmin.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/
/** Include configuration information. */
require_once('config.inc.php');
/** DAV administrator group name. */
define(ADMIN_GROUP, 'davadmin');
/** DAV administration application subdirectory. */
define(ADMIN_DIR, 'admin');
/** Include the Smarty template engine. */
require_once("smarty/libs/Smarty.class.php");
/** Global Smarty template engine instance. */
$smarty = new Smarty();
/** Handle invalid requests to the application. */
function invalidCall() {
header("Content-Type: text/plain; charset=UTF-8");
print("Ungültiger Aufruf!");
die();
}
/** Handle errors with an XML message. */
function errorAsXml($errormsg) {
header("Content-Type: text/xml; charset=UTF-8");
$GLOBALS['smarty']->assign("errormsg", $errormsg);
$GLOBALS['smarty']->display("error.xml");
die();
}
/** Handle errors with an HTML error page. */
function errorAsHtml($errormsg) {
header("Content-Type: text/html; charset=UTF-8");
$GLOBALS['smarty']->assign("errormsg", $errormsg);
$GLOBALS['smarty']->display("error.html");
die();
}
/**
* Handle a PDO statement error.
*
* @param PDOStatement $sth statement handle
*/
function statementErrorAsXml(&$sth) {
errorAsXml(utf8_encode(implode("\n", $sth->errorInfo())));
}
?>