source: index.php @ 91feee

Revision 91feee, 1.8 KB checked in by pierre-alain <pierre-alain@…>, 7 years ago (diff)

catching eventual errors while trying to intercept it !

  • Property mode set to 100644
Line 
1<?php
2/**
3 * Front door of the application
4 * Get the request and call the controller
5 *
6 * PHP 5
7 *
8 * OWR - OpenWebReader
9 *
10 * Copyright (c) 2009, Pierre-Alain Mignot
11 *
12 * Home page: http://openwebreader.org
13 *
14 * E-Mail: contact@openwebreader.org
15 *
16 * All Rights Reserved
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
22 *
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26 * GNU General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 *
32 * @author Pierre-Alain Mignot <contact@openwebreader.org>
33 * @copyright Copyright (c) 2009, Pierre-Alain Mignot
34 * @licence http://www.gnu.org/copyleft/gpl.html
35 * @package OWR
36 */
37namespace OWR;
38
39define('PATH', __DIR__.DIRECTORY_SEPARATOR); // define root path
40define('HOME_PATH', PATH.'OWR'.DIRECTORY_SEPARATOR); // define home path
41
42if(!file_exists(HOME_PATH.'cfg.php'))
43{ // not installed
44    header('Location: ./install/install.php');
45    exit;
46}
47
48// include the config file
49require HOME_PATH.'cfg.php';
50
51if(CLI) exit;
52
53try
54{
55    Controller::iGet()->execute(new Request)->renderPage();
56}
57catch(Exception $e)
58{
59    try
60    {
61        Logs::iGet()->log($e->getContent(), $e->getCode());
62        Controller::iGet()->renderPage($e->getCode());
63    }
64    catch(Exception $e)
65    {
66        if(!headers_sent())
67            header('HTTP/1.1 500 Internal error');
68
69        echo $e->getContent();
70    }
71}
72
73exit;
Note: See TracBrowser for help on using the repository browser.