diff options
-rwxr-xr-x | config/config.sample.php | 3 | ||||
-rw-r--r-- | core/css/styles.css | 3 | ||||
-rw-r--r-- | core/templates/exception.php | 30 | ||||
-rw-r--r-- | lib/exception.php | 74 |
4 files changed, 109 insertions, 1 deletions
diff --git a/config/config.sample.php b/config/config.sample.php index 199c9248c51..a5feff509ba 100755 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -19,6 +19,7 @@ $CONFIG = array( "knowledgebaseurl" => "", "appstoreenabled" => true, "appstoreurl" => "", -// "datadirectory" => "" +// "datadirectory" => "", +"sysinfoexception" => true ); ?> diff --git a/core/css/styles.css b/core/css/styles.css index f5a181c4529..6c00b571bab 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -131,3 +131,6 @@ li.error { width:640px; margin:4em auto; padding:1em 1em 1em 4em; background:#ff .separator { display: inline; border-left: 1px solid #d3d3d3; border-right: 1px solid #fff; height: 10px; width:0px; margin: 4px; } a.bookmarklet { background-color: #ddd; border:1px solid #ccc; padding: 5px;padding-top: 0px;padding-bottom: 2px; text-decoration: none; margin-top: 5px } + +.exception{color: #000000;} +.exception textarea{width:95%;height: 200px;background:#ffe;border:0;} diff --git a/core/templates/exception.php b/core/templates/exception.php new file mode 100644 index 00000000000..7f58ce252cf --- /dev/null +++ b/core/templates/exception.php @@ -0,0 +1,30 @@ +<ul> + <li class='error'> + <details> + <summary class="error">We're sorry, but something went terribly wrong.<br></summary> + <p class="exception"> + <?php + if($_['showsysinfo'] == true){ + echo 'If you would like to support ownCloud\'s developers and report this error in our <a href="http://bugs.owncloud.org">Bugtracker</a>, please copy the following informations into the description. <br><br><textarea readonly>'; + echo 'Message: ' . $_['message'] . "\n"; + echo 'Error Code: ' . $_['code'] . "\n"; + echo 'File: ' . $_['file'] . "\n"; + echo 'Line: ' . $_['line'] . "\n\n"; + echo 'PHP: ' . $_['sysinfo']['phpversion'] . "\n"; + echo 'OS: ' . $_['sysinfo']['os'] . "\n"; + echo 'OS Release: ' . $_['sysinfo']['osrelease'] . "\n"; + echo 'OS Arch.: ' . $_['sysinfo']['osarchitecture'] . "\n"; + echo 'PHP-Server-Interface: ' . $_['sysinfo']['phpserverinterface'] . "\n"; + echo 'Protocol: ' . $_['sysinfo']['serverprotocol'] . "\n"; + echo 'HTTPS: ' . $_['sysinfo']['https'] . "\n"; + echo 'Request Method: ' . $_['sysinfo']['requestmethod'] . "\n"; + echo 'Database: ' . $_['sysinfo']['database'] . "\n"; + echo '</textarea>'; + }else{ + echo 'Your administrator has disabled systeminformations.'; + } + ?> + </p> + </details> + </li> +</ul>
\ No newline at end of file diff --git a/lib/exception.php b/lib/exception.php new file mode 100644 index 00000000000..b4724e7c8c2 --- /dev/null +++ b/lib/exception.php @@ -0,0 +1,74 @@ +<?php +/** + * ownCloud + * + * @author Georg Ehrke + * @copyright 2012 georg@owncloud.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library 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 library. If not, see <http://www.gnu.org/licenses/>. + * + */ +class OC_Exception extends Exception{ + + function __construct($message = null, $code = 0, $file = null, $line = null){ + parent::__construct($message, $code); + if(!is_null($file)){ + $this->file = $file; + } + if(!is_null($line)){ + $this->line = $line; + } + $this->writelog(); + } + + private function writelog(){ + @OC_Log::write(OC_App::getCurrentApp(), $this->getMessage() . '-' . $this->getFile() . '-' . $this->getLine(), OC_Log::FATAL); + } + + private function generatesysinfo(){ + return array('phpversion' => PHP_VERSION, + 'os' => php_uname('s'), + 'osrelease' => php_uname('r'), + 'osarchitecture' => php_uname('m'), + 'phpserverinterface' => php_sapi_name(), + 'serverprotocol' => $_SERVER['SERVER_PROTOCOL'], + 'requestmethod' => $_SERVER['REQUEST_METHOD'], + 'https' => ($_SERVER['HTTPS']==''?'false':'true'), + 'database'=>(@OC_Config::getValue('dbtype')!=''?@OC_Config::getValue('dbtype'):'') + ); + } + + function __toString(){ + $tmpl = new OC_Template('core', 'exception', 'guest'); + $tmpl->assign('showsysinfo', true); + $tmpl->assign('message', $this->getMessage()); + $tmpl->assign('code', $this->getCode()); + $tmpl->assign('file', $this->getFile()); + $tmpl->assign('line', $this->getLine()); + $tmpl->assign('sysinfo', $this->generatesysinfo()); + $tmpl->printPage(); + } +} + +function oc_exceptionhandler($exception){ + throw new OC_Exception($exception->getMessage(), $exception->getCode(), $exception->getFile(), $exception->getLine()); + return true; +} + +function oc_errorhandler(){ + +} +set_exception_handler('oc_exceptionhandler'); +set_error_handler('oc_errorhandler'); +error_reporting(E_ERROR | E_WARNING | E_PARSE);
\ No newline at end of file |