OSDN Git Service

exception.php内で定義していた例外クラスをcommon.phpに移動し、exception.phpは削除しました。今のところ、必要無いので。
[hirameki-note/repo.git] / hirameki-note / src / main / php / common / common.php
1 <?php\r
2         // Copyright (c) 2008, u6k.yu1@gmail.com\r
3         // All rights reserved.\r
4         // \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
15         // \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
26         \r
27         require_once("PEAR.php");\r
28         \r
29         require_once("exception.php");\r
30         \r
31         /*\r
32          * エラー処理。\r
33          */\r
34         function error_handler($errno, $errstr) {\r
35                 throw new PHPException($errstr, $errno);\r
36         }\r
37         set_error_handler("error_handler", E_ALL);\r
38         \r
39         function pear_error_handler($err) {\r
40                 throw new PEARException($err->getMessage(), $err->getCode());\r
41         }\r
42         PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, "pear_error_handler");\r
43         \r
44         class ArgumentException extends Exception {\r
45         }\r
46         \r
47         class SQLException extends Exception {\r
48         }\r
49         \r
50         class PEARException extends Exception {\r
51         }\r
52         \r
53         class PHPException extends Exception {\r
54         }\r
55         \r
56         /*\r
57          * HTTP関連処理。\r
58          */\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
62                 } else {\r
63                         header("Content-Type: text/html; charset=UTF-8");\r
64                 }\r
65         }\r
66 ?>\r