| 1 | <?php |
|---|
| 2 | /** |
|---|
| 3 | * Handling REST requests |
|---|
| 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 | */ |
|---|
| 37 | namespace OWR\REST; |
|---|
| 38 | |
|---|
| 39 | define('PATH', __DIR__.DIRECTORY_SEPARATOR); // define root path |
|---|
| 40 | define('HOME_PATH', PATH.'OWR'.DIRECTORY_SEPARATOR); // define home path |
|---|
| 41 | |
|---|
| 42 | if(!file_exists(HOME_PATH.'cfg.php')) |
|---|
| 43 | { // not installed |
|---|
| 44 | exit; |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | // include the config file |
|---|
| 48 | require HOME_PATH.'cfg.php'; |
|---|
| 49 | |
|---|
| 50 | use OWR\Exception, |
|---|
| 51 | OWR\Logs; |
|---|
| 52 | try |
|---|
| 53 | { |
|---|
| 54 | Controller::iGet()->execute(new Request)->renderPage(); |
|---|
| 55 | } |
|---|
| 56 | catch(Exception $e) |
|---|
| 57 | { |
|---|
| 58 | Logs::iGet()->log($e->getContent(), $e->getCode()); |
|---|
| 59 | Controller::iGet()->renderPage($e->getCode()); |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | exit; |
|---|