2 // Copyright (c) 2008, u6k.yu1@gmail.com
\r
3 // All rights reserved.
\r
5 // Redistribution and use in source and binary forms, with or without
\r
6 // modification, are permitted provided that the following conditions are met:
\r
7 // * Redistributions of source code must retain the above copyright
\r
8 // notice, this list of conditions and the following disclaimer.
\r
9 // * Redistributions in binary form must reproduce the above copyright
\r
10 // notice, this list of conditions and the following disclaimer in the
\r
11 // documentation and/or other materials provided with the distribution.
\r
12 // * Neither the name of the u6k nor the
\r
13 // names of its contributors may be used to endorse or promote products
\r
14 // derived from this software without specific prior written permission.
\r
16 // THIS SOFTWARE IS PROVIDED BY u6k.yu1@gmail.com ``AS IS'' AND ANY
\r
17 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
\r
18 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
\r
19 // DISCLAIMED. IN NO EVENT SHALL u6k.yu1@gmail.com BE LIABLE FOR ANY
\r
20 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
\r
21 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
\r
22 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
\r
23 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
\r
24 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
\r
25 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
27 require_once("PEAR.php");
\r
29 require_once("exception.php");
\r
34 function error_handler($errno, $errstr) {
\r
35 throw new PHPException($errstr, $errno);
\r
37 set_error_handler("error_handler", E_ALL);
\r
39 function pear_error_handler($err) {
\r
40 throw new PEARException($err->getMessage(), $err->getCode());
\r
42 PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, "pear_error_handler");
\r
44 class ArgumentException extends Exception {
\r
47 class SQLException extends Exception {
\r
50 class PEARException extends Exception {
\r
53 class PHPException extends Exception {
\r
59 function output_content_type() {
\r
60 if (stripos($_SERVER["HTTP_USER_AGENT"], "MSIE") === FALSE) {
\r
61 header("Content-Type: application/xhtml+xml");
\r
63 header("Content-Type: text/html; charset=UTF-8");
\r