]> git.mxchange.org Git - mailer.git/blobdiff - inc/functions.php
__ACL_ALLOW rewritten to and @TODO finished
[mailer.git] / inc / functions.php
index 7d96a7ed02e20f7a8627474bd08c1c7a6bafe269..af966907f678950999a0501f479ee3d47b96c567 100644 (file)
@@ -48,7 +48,7 @@ function IS_INC_WRITEABLE($inc) {
        } // END - if
 
        // Test if we can append data
-       $fp = @fopen($fqfn, 'a');
+       $fp = fopen($fqfn, 'a');
        if ($inc == "dummy") {
                // Remove dummy file
                fclose($fp);
@@ -194,7 +194,7 @@ function getFatalArray () {
 }
 
 // Add a fatal error message to the queue array
-function addFatalMessage ($message, $extra="") {
+function addFatalMessage ($F, $L, $message, $extra="") {
        if (is_array($extra)) {
                // Multiple extras for a message with masks
                $message = call_user_func_array('sprintf', $extra);
@@ -207,7 +207,7 @@ function addFatalMessage ($message, $extra="") {
        $GLOBALS['fatal_messages'][] = $message;
 
        // Log fatal messages away
-       DEBUG_LOG(__FUNCTION__, __LINE__, " message={$message}");
+       DEBUG_LOG($F, $L, " message={$message}");
 }
 
 // Getter for total fatal message count
@@ -249,7 +249,7 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
        if ($template == "member_support_form") {
                // Support request of a member
                $result = SQL_QUERY_ESC("SELECT userid, gender, surname, family, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
-                       array($GLOBALS['userid']), __FILE__, __LINE__);
+                       array($GLOBALS['userid']), __FUNCTION__, __LINE__);
 
                // Is content an array?
                if (is_array($content)) {
@@ -404,7 +404,7 @@ function SEND_EMAIL($TO, $SUBJECT, $MSG, $HTML = "N", $FROM = "") {
                        return;
                } else {
                        // Load email address
-                       $result_email = SQL_QUERY_ESC("SELECT email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1", array(bigintval($TO)), __FILE__, __LINE__);
+                       $result_email = SQL_QUERY_ESC("SELECT email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1", array(bigintval($TO)), __FUNCTION__, __LINE__);
                        //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):numRows=".SQL_NUMROWS($result_email)."<br />\n";
 
                        // Does the user exist?
@@ -804,12 +804,12 @@ function LOAD_EMAIL_TEMPLATE($template, $content=array(), $UID="0") {
                        //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):NICKNAME!<br />\n";
                        // Load nickname
                        $result = SQL_QUERY_ESC("SELECT surname, family, gender, email, nickname FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
-                               array(bigintval($UID)), __FILE__, __LINE__);
+                               array(bigintval($UID)), __FUNCTION__, __LINE__);
                } else {
                        //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):NO-NICK!<br />\n";
                        /// Load normal data
                        $result = SQL_QUERY_ESC("SELECT surname, family, gender, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
-                               array(bigintval($UID)), __FILE__, __LINE__);
+                               array(bigintval($UID)), __FUNCTION__, __LINE__);
                }
 
                // Fetch and merge data
@@ -925,7 +925,7 @@ function LOAD_URL ($URL, $addUrlData=true) {
 
        // Get output buffer
        //* DEBUG: */ debug_report_bug(sprintf("%s[%s:] URL=%s", __FUNCTION__, __LINE__, $URL));
-       DEBUG_LOG(__FUNCTION__, __LINE__, $URL);
+       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, $URL);
        $OUTPUT = ob_get_contents();
 
        // Clear it only if there is content
@@ -1221,12 +1221,12 @@ function ADD_SELECTION ($type, $DEFAULT, $prefix="", $id="0") {
 }
 
 //
-function TRANSLATE_YESNO($yn) {
+function TRANSLATE_YESNO ($yn) {
        // Default
-       $yn = "??? (".$yn.")";
+       $translated = "??? (".$yn.")";
        switch ($yn) {
-               case "Y": $yn = getMessage('YES'); break;
-               case "N": $yn = getMessage('NO'); break;
+               case "Y": $translated = getMessage('YES'); break;
+               case "N": $translated = getMessage('NO'); break;
                default:
                        // Log unknown value
                        DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Unknown value %s. Expected Y/N!", $yn));
@@ -1234,7 +1234,7 @@ function TRANSLATE_YESNO($yn) {
        }
 
        // Return it
-       return $yn;
+       return $translated;
 }
 
 //
@@ -1601,11 +1601,11 @@ function SEND_ADMIN_EMAILS_PRO ($subj, $template, $content, $UID) {
 
        // Check which admin shall receive this mail
        $result = SQL_QUERY_ESC("SELECT DISTINCT admin_id FROM `{!_MYSQL_PREFIX!}_admins_mails` WHERE mail_template='%s' ORDER BY admin_id",
-               array($template), __FILE__, __LINE__);
+               array($template), __FUNCTION__, __LINE__);
        if (SQL_NUMROWS($result) == 0) {
                // Create new entry (to all admins)
                SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_admins_mails` (admin_id, mail_template) VALUES (0, '%s')",
-                       array($template), __FILE__, __LINE__);
+                       array($template), __FUNCTION__, __LINE__);
        } else {
                // Load admin IDs...
                $aids = array();
@@ -1635,10 +1635,10 @@ function SEND_ADMIN_EMAILS_PRO ($subj, $template, $content, $UID) {
                        }
                } elseif ($aid == "0") {
                        // Select all email adresses
-                       $result = SQL_QUERY("SELECT email FROM `{!_MYSQL_PREFIX!}_admins` ORDER BY `id`", __FILE__, __LINE__);
+                       $result = SQL_QUERY("SELECT email FROM `{!_MYSQL_PREFIX!}_admins` ORDER BY `id`", __FUNCTION__, __LINE__);
                } else {
                        // If Admin-ID is not "to-all" select
-                       $result = SQL_QUERY_ESC("SELECT email FROM `{!_MYSQL_PREFIX!}_admins` WHERE id IN (%s) ORDER BY `id`", array($aid), __FILE__, __LINE__);
+                       $result = SQL_QUERY_ESC("SELECT email FROM `{!_MYSQL_PREFIX!}_admins` WHERE id IN (%s) ORDER BY `id`", array($aid), __FUNCTION__, __LINE__);
                }
        }
 
@@ -2429,7 +2429,7 @@ function THEME_GET_ID ($name) {
        } elseif (GET_EXT_VERSION("cache") != "0.1.8") {
                // Check if current theme is already imported or not
                $result = SQL_QUERY_ESC("SELECT id FROM `{!_MYSQL_PREFIX!}_themes` WHERE theme_path='%s' LIMIT 1",
-                       array($name), __FILE__, __LINE__);
+                       array($name), __FUNCTION__, __LINE__);
 
                // Entry found?
                if (SQL_NUMROWS($result) == 1) {
@@ -2575,19 +2575,8 @@ function getActualVersion ($type = 0) {
 
 // Loads an include file and logs any missing files for debug purposes
 function LOAD_INC ($INC) {
-       // Get constant path
-       $PATH = constant('PATH');
-
-       // Use the include file name directly
-       // @TODO Try to find all locations where an FQFN is given to these two
-       // @TODO functions and avoid it.
-       $FQFN = $INC;
-
-       // Check if PATH is in $INC
-       if (substr($INC, 0, $PATH) != $PATH) {
-               // Add it. This is why we need a trailing slash in config.php
-               $FQFN = $PATH . $INC;
-       } // END - if
+       // Add the path. This is why we need a trailing slash in config.php
+       $FQFN = constant('PATH') . $INC;
 
        // Is the include file there?
        if (!FILE_READABLE($FQFN)) {
@@ -2603,12 +2592,12 @@ function LOAD_INC ($INC) {
 // Loads an include file once
 function LOAD_INC_ONCE ($INC) {
        // Is it not loaded?
-       if (!isset($GLOBALS['cache_array']['load_once'][$INC])) {
+       if (!isset($GLOBALS['load_once'][$INC])) {
                // Then try to load it
                LOAD_INC($INC);
 
                // And mark it as loaded
-               $GLOBALS['cache_array']['load_once'][$INC] = "loaded";
+               $GLOBALS['load_once'][$INC] = "loaded";
        } // END - if
 }
 
@@ -2620,7 +2609,7 @@ function debug_get_printable_backtrace () {
        // Get and prepare backtrace for output
        $backtraceArray = debug_backtrace();
        foreach ($backtraceArray as $key => $trace) {
-               if (!isset($trace['file'])) $trace['file'] = __FILE__;
+               if (!isset($trace['file'])) $trace['file'] = __FUNCTION__;
                if (!isset($trace['line'])) $trace['line'] = __LINE__;
                if (!isset($trace['args'])) $trace['args'] = array();
                $backtrace .= "<li class=\"debug_list\"><span class=\"backtrace_file\">".basename($trace['file'])."</span>:".$trace['line'].", <span class=\"backtrace_function\">".$trace['function']."(".count($trace['args']).")</span></li>\n";
@@ -2715,7 +2704,7 @@ function REDIRCT_ON_UNINSTALLED_EXTENSION ($ext_name) {
 // Generate a "link" for the given admin id (aid)
 function GENERATE_AID_LINK ($aid) {
        // No assigned admin is default
-       $admin = "<div class=\"admin_note\">{--ADMIN_NO_ADMIN_ASSIGNED--}</div>";
+       $admin = "<span class=\"admin_note\">{--ADMIN_NO_ADMIN_ASSIGNED--}</span>";
 
        // Zero? = Not assigned
        if ($aid == "0") {
@@ -2882,12 +2871,12 @@ function changeDataInFile ($FQFN, $comment, $prefix, $suffix, $DATA, $seek=0) {
                $tmp = $FQFN.".tmp";
 
                // Open the source file
-               $fp = @fopen($FQFN, 'r') or OUTPUT_HTML("<strong>READ:</strong> ".$FQFN."<br />");
+               $fp = fopen($FQFN, 'r') or OUTPUT_HTML("<strong>READ:</strong> ".$FQFN."<br />");
 
                // Is the resource valid?
                if (is_resource($fp)) {
                        // Open temporary file
-                       $fp_tmp = @fopen($tmp, 'w') or OUTPUT_HTML("<strong>WRITE:</strong> ".$tmp."<br />");
+                       $fp_tmp = fopen($tmp, 'w') or OUTPUT_HTML("<strong>WRITE:</strong> ".$tmp."<br />");
 
                        // Is the resource again valid?
                        if (is_resource($fp_tmp)) {
@@ -2922,8 +2911,8 @@ function changeDataInFile ($FQFN, $comment, $prefix, $suffix, $DATA, $seek=0) {
 
                        if (($done) && ($found)) {
                                // Copy back tmp file and delete tmp :-)
-                               @copy($tmp, $FQFN);
-                               @unlink($tmp);
+                               copy($tmp, $FQFN);
+                               return unlink($tmp);
                        } elseif (!$found) {
                                OUTPUT_HTML("<strong>CHANGE:</strong> 404!");
                        } else {
@@ -2934,6 +2923,9 @@ function changeDataInFile ($FQFN, $comment, $prefix, $suffix, $DATA, $seek=0) {
                // File not found, not readable or writeable
                OUTPUT_HTML("<strong>404:</strong> ".$FQFN."<br />");
        }
+
+       // An error was detected!
+       return false;
 }
 // Send notification to admin
 function SEND_ADMIN_NOTIFICATION($subject, $templateName, $content=array(), $uid="0") {