Exemplo n.º 1
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;
         }
     }
 }