コード例 #1
0
ファイル: error-debug.php プロジェクト: kxopa/WebSite-PHP
 public function Load()
 {
     if (defined('SEND_ERROR_BY_MAIL') && SEND_ERROR_BY_MAIL == true && !isLocalDebug()) {
         if ($this->is_trace) {
             // standard msg "administrator is notified"
             parent::$PAGE_TITLE = __(ERROR) . " - " . __(SITE_NAME);
             $box_title = __(ERROR);
             $debug_msg = __(ERROR_DEBUG_MAIL_SENT);
         } else {
             // no trace in the debug information
             parent::$PAGE_TITLE = "Debug error - " . __(SITE_NAME);
             $box_title = "Debug error";
             $debug_msg = $_POST['debug'];
         }
     } else {
         parent::$PAGE_TITLE = "Debug error - " . __(SITE_NAME);
         $box_title = "Debug error";
         $debug_msg = $_POST['debug'];
     }
     $error_title_table = new Table();
     $error_title_table->addRowColumns(new Picture("wsp/img/warning.png", 48, 48, 0, "absmidlle"), " ", new Label(__(ERROR), true));
     $obj_error_msg = new Object($error_title_table, "<br/>");
     $debug_obj = new Object(utf8encode($debug_msg));
     $debug_obj->setAlign(Object::ALIGN_LEFT);
     $debug_obj->setWidth("80%");
     $obj_error_msg->add($debug_obj, "<br/><br/>");
     if ($GLOBALS['__AJAX_LOAD_PAGE__'] == false) {
         $obj_error_msg->add("<a href=\"" . $_GET['from_url'] . "\">Refresh this page</a>", "<br/><br/>");
     }
     $obj_error_msg->add("<b>Consult <a href=\"http://www.php.net\" target=\"_blank\">PHP</a> or <a href=\"http://www.website-php.com\" target=\"_blank\">WebSite-PHP</a> documentations.</b>", "<br/>");
     $obj_error_msg->add("<br/><br/>", "Go back to the main page", new Link(BASE_URL, Link::TARGET_NONE, __(SITE_NAME)));
     $this->render = new ErrorTemplate($obj_error_msg, $box_title);
     if (trim($_POST['debug']) != "") {
         $cache_filename = "";
         if (isset($_POST['cache_filename']) && trim($_POST['cache_filename']) != "") {
             $cache_filename = $this->getRealCacheFileName($_POST['cache_filename']);
             if (!file_exists($cache_filename)) {
                 $cache_filename = "";
             }
         }
         NewException::sendErrorByMail($_POST['debug'], $cache_filename);
     }
 }
コード例 #2
0
 /**
  * Method printStaticDebugMessage
  * @access static
  * @param string|object $debug_msg 
  * @since 1.0.59
  */
 public static function printStaticDebugMessage($debug_msg)
 {
     // print the debug
     $GLOBALS['__ERROR_DEBUG_PAGE__'] = true;
     if ($GLOBALS['__DEBUG_PAGE_IS_PRINTING__'] == false) {
         $GLOBALS['__DEBUG_PAGE_IS_PRINTING__'] = true;
         if (gettype($debug_msg) == "object") {
             if (get_class($debug_msg) == "NewException") {
                 $debug_msg = NewException::generateErrorMessage($debug_msg->code, $debug_msg->message, $debug_msg->file, $debug_msg->line);
             } else {
                 $debug_msg = echo_r($debug_msg);
             }
         }
         if ($GLOBALS['__AJAX_PAGE__'] == false || $GLOBALS['__AJAX_LOAD_PAGE__'] == true && $_GET['mime'] == "text/html") {
             $_POST['debug'] = $debug_msg;
             $_GET['p'] = "error-debug";
             try {
                 if (!defined('FORCE_SERVER_NAME') || FORCE_SERVER_NAME == "") {
                     if ($_SERVER['SERVER_PORT'] == 443) {
                         $from_url = "https://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
                     } else {
                         $port = "";
                         if ($_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != "") {
                             $port = ":" . $_SERVER['SERVER_PORT'];
                         }
                         $from_url = "http://" . $_SERVER['SERVER_NAME'] . $port . $_SERVER['REQUEST_URI'];
                     }
                 } else {
                     $from_url = "http://" . FORCE_SERVER_NAME . $_SERVER['REQUEST_URI'];
                 }
                 $_GET['from_url'] = $from_url;
                 require_once dirname(__FILE__) . "/../../pages/error/error-debug.php";
                 $debug_page = new ErrorDebug(self::$trace !== false ? true : false);
                 if (method_exists($debug_page, "InitializeComponent")) {
                     $debug_page->InitializeComponent();
                 }
                 if (method_exists($debug_page, "Load")) {
                     $debug_page->Load();
                 }
                 $debug_page->loadAllVariables();
                 $__PAGE_IS_INIT__ = true;
                 $debug_page->executeCallback();
                 if (method_exists($debug_page, "Loaded")) {
                     $debug_page->Loaded();
                 }
                 $http_type = "";
                 $split_request_uri = explode("\\?", $_SERVER['REQUEST_URI']);
                 if (!defined('FORCE_SERVER_NAME') || FORCE_SERVER_NAME == "") {
                     if ($_SERVER['SERVER_PORT'] == 443) {
                         $http_type = "https://";
                         $current_url = str_replace("//", "/", $_SERVER['SERVER_NAME'] . substr($split_request_uri[0], 0, strrpos($split_request_uri[0], "/")) . "/");
                     } else {
                         $port = "";
                         if ($_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != "") {
                             $port = ":" . $_SERVER['SERVER_PORT'];
                         }
                         $http_type = "http://";
                         $current_url = str_replace("//", "/", $_SERVER['SERVER_NAME'] . $port . substr($split_request_uri[0], 0, strrpos($split_request_uri[0], "/")) . "/");
                     }
                 } else {
                     $http_type = "http://";
                     $current_url = str_replace("//", "/", FORCE_SERVER_NAME . substr($split_request_uri[0], 0, strrpos($split_request_uri[0], "/")) . "/");
                 }
                 // define the base URL of the website
                 $my_base_url = "";
                 $array_cwd = explode('/', str_replace('\\', '/', getcwd()));
                 $wsp_folder_name = $array_cwd[sizeof($array_cwd) - 1];
                 // Detect base URL with the root folder of wsp
                 $array_current_url = explode('/', $current_url);
                 for ($i = sizeof($array_current_url) - 2; $i >= 0; $i--) {
                     if ($array_current_url[$i] == $wsp_folder_name) {
                         $my_base_url = $http_type;
                         for ($j = 0; $j <= $i; $j++) {
                             $my_base_url .= $array_current_url[$j] . "/";
                         }
                         break;
                     }
                 }
                 if ($my_base_url == "") {
                     if (!defined('FORCE_SERVER_NAME') || FORCE_SERVER_NAME == "") {
                         // If not find root folder then test if there is an alias
                         $array_script_name = explode('/', $_SERVER['SCRIPT_NAME']);
                         unset($array_script_name[sizeof($array_script_name) - 1]);
                         $alias_path = implode('/', $array_script_name);
                         if ($alias_path != "") {
                             // Alias detected
                             $my_base_url = $http_type . $array_current_url[0] . $alias_path . "/";
                         } else {
                             // No Alias detected
                             $my_base_url = $http_type . $array_current_url[0] . "/";
                         }
                     } else {
                         if (strtoupper(substr(FORCE_SERVER_NAME, 0, 7)) == "HTTP://" || strtoupper(substr(FORCE_SERVER_NAME, 0, 8)) == "HTTPS://") {
                             $my_base_url = FORCE_SERVER_NAME . "/";
                         } else {
                             $my_base_url = $http_type . FORCE_SERVER_NAME . "/";
                         }
                     }
                 }
                 $my_site_base_url = $my_base_url;
                 header("Content-Type: text/html");
                 echo "<html><head><title>Debug Error - " . utf8encode(SITE_NAME) . "</title>\n";
                 $jquery_style = "";
                 if (DEFINE_STYLE_JQUERY != "") {
                     $jquery_style = DEFINE_STYLE_JQUERY;
                 }
                 echo "<link type=\"text/css\" rel=\"StyleSheet\" href=\"" . $my_site_base_url . "combine-css/styles.php.css,angle.php.css,jquery" . JQUERY_UI_VERSION . "|" . $jquery_style . "|jquery-ui-" . JQUERY_UI_VERSION . ".custom.css";
                 if (trim(CssInclude::getInstance()->getCssConfigFile()) != "") {
                     echo "?conf_file=" . CssInclude::getInstance()->getCssConfigFile();
                 }
                 echo "\" media=\"screen\" />\n";
                 echo "<script type=\"text/javascript\" src=\"" . $my_site_base_url . "combine-js/jquery|jquery-" . JQUERY_VERSION . ".min.js,jquery|jquery-ui-" . JQUERY_UI_VERSION . ".custom.min.js,jquery.cookie.js,pngfix.js,utils.js\"></script>\n";
                 echo "<script type=\"text/javascript\" src=\"" . $my_site_base_url . "combine-js/jquery.backstretch.min.js,jquery.cookie.js\"></script>\n";
                 echo "<meta name=\"Robots\" content=\"noindex, nofollow\" />\n";
                 echo "<base href=\"" . $my_site_base_url . "\" />\n";
                 echo "</head><body>\n";
                 echo $debug_page->render();
                 if ($GLOBALS['__AJAX_LOAD_PAGE__'] == true && $GLOBALS['__AJAX_LOAD_PAGE_ID__'] != "") {
                     echo "<script type=\"text/javascript\">\n";
                     echo "lauchJavascriptPage_" . $GLOBALS['__AJAX_LOAD_PAGE_ID__'] . " = function() {\n";
                     echo "\t\$('#idLoadPageLoadingPicture" . $GLOBALS['__AJAX_LOAD_PAGE_ID__'] . "').attr('style', 'display:none;');\n";
                     echo "\t\$('#idLoadPageContent" . $GLOBALS['__AJAX_LOAD_PAGE_ID__'] . "').attr('style', 'display:block;');\n";
                     echo "};\n";
                     echo "\twaitForJsScripts(" . $GLOBALS['__AJAX_LOAD_PAGE_ID__'] . ");\n";
                     echo "\tLoadPngPicture();\n";
                     echo "</script>\n";
                 }
                 echo "</body></html>\n";
             } catch (Exception $e) {
                 echo $e->getMessage();
                 NewException::sendErrorByMail($debug_msg);
             }
         } else {
             header('HTTP/1.1 500 Internal Server Error');
             if (defined('SEND_ERROR_BY_MAIL') && SEND_ERROR_BY_MAIL == true && !isLocalDebug()) {
                 if (self::$trace !== false) {
                     // standard msg "administrator is notified"
                     echo __(ERROR_DEBUG_MAIL_SENT);
                 } else {
                     // no trace in the debug information
                     echo utf8encode($debug_msg);
                 }
             } else {
                 echo utf8encode($debug_msg);
             }
             NewException::sendErrorByMail($debug_msg);
             exit;
         }
     }
 }
コード例 #3
0
ファイル: utils.inc.php プロジェクト: kxopa/WebSite-PHP
function register_shutdown_handler()
{
    require_once dirname(__FILE__) . "/../class/NewException.class.php";
    NewException::redirectOnError("");
}