]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/output_functions.php
Newer sponsor scripts found in backup\! :D :D
[mailer.git] / inc / libs / output_functions.php
index ab24e8fb3e4d0b3972af97ba10248ba35c93d52a..9b5be757323c57b63af559b145b69e3ac8d1aeca 100644 (file)
@@ -38,30 +38,26 @@ if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
        require($INC);
 }
 // Add HTML to the output stream
-class HTMLParser
-{
+class HTMLParser {
 
 // Initializer
-function HTMLParser()
-{
+function HTMLParser() {
 }
 
 // Add HTML-Code to buffer
-function add_html ($HTML, $NEW_LINE = true)
-{
+function add_html ($HTML, $NEW_LINE = true) {
        global $OUTPUT;
 }
+
 // Compiles HTML code
-function compile_html($code, $simple=false)
-{
+function compile_html($code, $simple=false) {
        global $SEC_CHARS;
 
        // Compile constants
        $code = str_replace('{--', '".', str_replace('--}', '."', $code));
 
        // Compile QUOT and other non-HTML codes
-       foreach ($SEC_CHARS['to'] as $k=>$from)
-       {
+       foreach ($SEC_CHARS['to'] as $k=>$from) {
                // Do the reversed thing as in inc/libs/security_functions.php
                $code = str_replace($from, $SEC_CHARS['from'][$k], $code);
        }
@@ -72,6 +68,7 @@ function compile_html($code, $simple=false)
        // Return compiled code
        return $code;
 }
+
 // Load a template file and return it's content (only it's name; do not use ' or ")
 function get_template ($template, $return=false, $content="")
 {
@@ -79,8 +76,7 @@ function get_template ($template, $return=false, $content="")
        global $DATA, $ACTION, $WHAT;
        $REFID = bigintval(get_session('refid'));
 
-       if ($template == "member_support_form")
-       {
+       if ($template == "member_support_form") {
                // Support request of a member
                $ID = bigintval($GLOBALS['userid']);
                $result = SQL_QUERY_ESC("SELECT sex, surname, family FROM "._MYSQL_PREFIX."_user_data WHERE userid='%s' LIMIT 1", array($ID), __FILE__, __LINE__);
@@ -94,56 +90,44 @@ function get_template ($template, $return=false, $content="")
        $MODE = "";
 
        // Check for admin/guest/member templates
-       if (strpos($template, "admin_") > -1)
-       {
+       if (strpos($template, "admin_") > -1) {
                // Admin template found
                $MODE = "admin/";
-       }
-        elseif (strpos($template, "guest_") > -1)
-       {
+       } elseif (strpos($template, "guest_") > -1) {
                // Guest template found
                $MODE = "guest/";
-       }
-        elseif (strpos($template, "member_") > -1)
-       {
+       } elseif (strpos($template, "member_") > -1) {
                // Member template found
                $MODE = "member/";
-       }
-        elseif (strpos($template, "install_") > -1)
-       {
+       } elseif (strpos($template, "install_") > -1) {
                // Installation template found
                $MODE = "install/";
-       }
-        elseif (strpos($template, "mailid_") > -1)
-       {
+       } elseif (strpos($template, "mailid_") > -1) {
                // Mail confirmation template found
                $MODE = "mailid/";
        }
 
        // Generate file name
        $file = $BASE.$MODE.$template.".tpl";
-       if ((!empty($HTTP_GET_VARS['what'])) && ((strpos($template, "_header") > 0) || (strpos($template, "_footer") > 0)) && (($MODE == "guest/") || ($MODE == "member/") || ($MODE == "admin/")))
-       {
+       if ((!empty($_GET['what'])) && ((strpos($template, "_header") > 0) || (strpos($template, "_footer") > 0)) && (($MODE == "guest/") || ($MODE == "member/") || ($MODE == "admin/"))) {
                // Select what depended header/footer template file for admin/guest/member area
-               $file2 = $BASE.$MODE.$template."_".$HTTP_GET_VARS['what'].".tpl";
+               $file2 = sprintf("%s%s%s_%s.tpl", $BASE, $MODE, $template, SQL_ESCAPE($_GET['what']));
 
                // Probe for it...
-               if (file_exists($file2)) $file = $file2;
+               if ((file_exists($file2)) && (is_readable($file2))) $file = $file2;
 
                // Remove variable from memory
                unset($file2);
        }
 
        // Does the special template exists?
-       if (!file_exists($file))
-       {
+       if ((!file_exists($file)) || (!is_readable($file))) {
                // Reset to default template
                $file = PATH."templates/".GET_LANGUAGE()."/html/".$template.".tpl";
        }
 
        // Now does the final template exists?
-       if (file_exists($file))
-       {
+       if ((file_exists($file)) && (is_readable($file))) {
                // The local file does exists so we load it. :)
                $tmpl_file = implode("", file($file));
                $tmpl_file = str_replace("'", '{QUOT}', $tmpl_file);
@@ -151,21 +135,17 @@ function get_template ($template, $return=false, $content="")
                // Compile and run code
                $ret = COMPILE_CODE(addslashes($tmpl_file), false, true);
                $ret = "<!-- Template ".$template." - Start -->\n".$ret."<!-- Template ".$template." - End -->\n";
-       }
-        elseif (IS_ADMIN())
-       {
+       } elseif (IS_ADMIN()) {
                // Only admins shall see this warning
                $ret = "<br /><SPAN class=\"guest_failed\">".TEMPLATE_404."</SPAN><br />
 (".basename($file).")
 <br /><br />";
        }
-       if ($return)
-       {
+
+       if ($return) {
                // Return the HTML code
                return $ret;
-       }
-        else
-       {
+       } else {
                // Output directly
                $this->add_html ($ret);
        }
@@ -173,5 +153,6 @@ function get_template ($template, $return=false, $content="")
 
        // END OF CLASS
 }
+
 //
 ?>