| 
									
										
										
										
											2009-01-22 03:33:12 -08:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Error action. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * PHP version 5 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @category Action | 
					
						
							| 
									
										
										
										
											2009-08-25 18:12:20 -04:00
										 |  |  |  * @package  StatusNet | 
					
						
							| 
									
										
										
										
											2009-08-25 18:19:04 -04:00
										 |  |  |  * @author   Evan Prodromou <evan@status.net> | 
					
						
							|  |  |  |  * @author   Zach Copley <zach@status.net> | 
					
						
							| 
									
										
										
										
											2009-01-22 03:33:12 -08:00
										 |  |  |  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 | 
					
						
							| 
									
										
										
										
											2009-08-25 18:16:46 -04:00
										 |  |  |  * @link     http://status.net/ | 
					
						
							| 
									
										
										
										
											2009-01-22 03:33:12 -08:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2009-08-25 18:14:12 -04:00
										 |  |  |  * StatusNet - the distributed open-source microblogging tool | 
					
						
							| 
									
										
										
										
											2009-08-25 18:12:20 -04:00
										 |  |  |  * Copyright (C) 2008, 2009, StatusNet, Inc. | 
					
						
							| 
									
										
										
										
											2009-01-22 03:33:12 -08:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This program is free software: you can redistribute it and/or modify | 
					
						
							|  |  |  |  * it under the terms of the GNU Affero General Public License as published by | 
					
						
							|  |  |  |  * the Free Software Foundation, either version 3 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 Affero General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU Affero General Public License | 
					
						
							|  |  |  |  * along with this program.  If not, see <http://www.gnu.org/licenses/>. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-26 10:41:36 -04:00
										 |  |  | if (!defined('STATUSNET') && !defined('LACONICA')) { | 
					
						
							| 
									
										
										
										
											2009-01-22 03:33:12 -08:00
										 |  |  |     exit(1); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-06 19:06:57 -07:00
										 |  |  | require_once INSTALLDIR . '/lib/info.php'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-22 03:33:12 -08:00
										 |  |  | /** | 
					
						
							|  |  |  |  * Base class for displaying HTTP errors | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @category Action | 
					
						
							| 
									
										
										
										
											2009-08-25 18:12:20 -04:00
										 |  |  |  * @package  StatusNet | 
					
						
							| 
									
										
										
										
											2009-08-25 18:19:04 -04:00
										 |  |  |  * @author   Zach Copley <zach@status.net> | 
					
						
							| 
									
										
										
										
											2009-01-22 03:33:12 -08:00
										 |  |  |  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 | 
					
						
							| 
									
										
										
										
											2009-08-25 18:16:46 -04:00
										 |  |  |  * @link     http://status.net/ | 
					
						
							| 
									
										
										
										
											2009-01-22 03:33:12 -08:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2010-10-06 19:06:57 -07:00
										 |  |  | class ErrorAction extends InfoAction | 
					
						
							| 
									
										
										
										
											2009-01-22 03:33:12 -08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-09-29 17:43:45 -04:00
										 |  |  |     static $status = array(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-22 03:33:12 -08:00
										 |  |  |     var $code    = null; | 
					
						
							|  |  |  |     var $message = null; | 
					
						
							|  |  |  |     var $default = null; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-05 01:03:04 -05:00
										 |  |  |     function __construct($message, $code, $output='php://output', $indent=null) | 
					
						
							| 
									
										
										
										
											2009-01-22 03:33:12 -08:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2010-10-06 19:06:57 -07:00
										 |  |  |         parent::__construct(null, $message, $output, $indent); | 
					
						
							| 
									
										
										
										
											2009-01-22 03:33:12 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         $this->code = $code; | 
					
						
							|  |  |  |         $this->message = $message; | 
					
						
							| 
									
										
										
										
											2010-02-08 11:06:03 -08:00
										 |  |  |         $this->minimal = StatusNet::isApi(); | 
					
						
							| 
									
										
										
										
											2009-01-22 03:33:12 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // XXX: hack alert: usually we aren't going to
 | 
					
						
							|  |  |  |         // call this page directly, but because it's
 | 
					
						
							|  |  |  |         // an action it needs an args array anyway
 | 
					
						
							|  |  |  |         $this->prepare($_REQUEST); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-14 08:04:03 -07:00
										 |  |  |     function showPage() | 
					
						
							| 
									
										
										
										
											2009-01-22 03:33:12 -08:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2010-02-08 11:06:03 -08:00
										 |  |  |         if ($this->minimal) { | 
					
						
							|  |  |  |             // Even more minimal -- we're in a machine API
 | 
					
						
							|  |  |  |             // and don't want to flood the output.
 | 
					
						
							|  |  |  |             $this->extraHeaders(); | 
					
						
							|  |  |  |             $this->showContent(); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             parent::showPage(); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2009-08-14 08:04:03 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-09 20:01:46 +01:00
										 |  |  |         // We don't want to have any more output after this
 | 
					
						
							| 
									
										
										
										
											2009-01-22 03:33:12 -08:00
										 |  |  |         exit(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-06 19:06:57 -07:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Display content. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return nothing | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     function showContent() | 
					
						
							| 
									
										
										
										
											2009-01-22 03:33:12 -08:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2010-10-06 19:06:57 -07:00
										 |  |  |         $this->element('div', array('class' => 'error'), $this->message); | 
					
						
							| 
									
										
										
										
											2009-01-22 03:33:12 -08:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |