]> git.mxchange.org Git - mailer.git/blobdiff - inc/wrapper-functions.php
New extension added, more EL-rewrites, naming-convention applied:
[mailer.git] / inc / wrapper-functions.php
index 8877bcc150e85ff0c92416d0088ac8b35e44235e..8e7ae4c14e8c415e0d501d64beb44129b1d0a966 100644 (file)
@@ -117,7 +117,7 @@ function writeToFile ($FQFN, $content, $aquireLock = false) {
 // Clears the output buffer. This function does *NOT* backup sent content.
 function clearOutputBuffer () {
        // Trigger an error on failure
-       if (!ob_end_clean()) {
+       if ((ob_get_length() > 0) && (!ob_end_clean())) {
                // Failed!
                debug_report_bug(__FUNCTION__.': Failed to clean output buffer.');
        } // END - if
@@ -151,7 +151,7 @@ function merge_array ($array1, $array2) {
        // Are both an array?
        if ((!is_array($array1)) && (!is_array($array2))) {
                // Both are not arrays
-               debug_report_bug(__FUNCTION__ . ': No arrays provided!');
+               debug_report_bug(__FUNCTION__, __LINE__, 'No arrays provided!');
        } elseif (!is_array($array1)) {
                // Left one is not an array
                debug_report_bug(__FILE__, __LINE__, sprintf("array1 is not an array. array != %s", gettype($array1)));
@@ -661,7 +661,7 @@ function isOutputModeSet ($strict =  false) {
        // Should we abort here?
        if (($strict === true) && ($isset === false)) {
                // Output backtrace
-               debug_report_bug(__FUNCTION__, __LINE__, 'output_mode is empty.');
+               debug_report_bug(__FUNCTION__, __LINE__, 'Output_mode is empty.');
        } // END - if
 
        // Return it
@@ -678,7 +678,7 @@ function isBlockModeEnabled () {
        // Abort if not set
        if (!isset($GLOBALS['block_mode'])) {
                // Needs to be fixed
-               debug_report_bug(__FUNCTION__ . ': block_mode is not set.');
+               debug_report_bug(__FUNCTION__, __LINE__, 'Block_mode is not set.');
        } // END - if
 
        // Return it
@@ -697,7 +697,7 @@ function addPointsDirectly ($subject, $userid, $points) {
 // Wrapper function to redirect from member-only modules to index
 function redirectToIndexMemberOnlyModule () {
        // Do the redirect here
-       redirectToUrl('modules.php?module=index&code=' . getCode('MODULE_MEM_ONLY') . '&mod=' . getModule());
+       redirectToUrl('modules.php?module=index&code=' . getCode('MODULE_MEMBER_ONLY') . '&mod=' . getModule());
 }
 
 // Wrapper function to redirect to current URL
@@ -722,7 +722,7 @@ function isExtensionInstalledAndNewer ($ext_name, $version) {
        }
 
        // Return it
-       //* DEBUG: */ print __FUNCTION__.':'.$ext_name.'=&gt;'.$version.':'.intval($GLOBALS['ext_installed_newer'][$ext_name][$version]).'<br />';
+       //* DEBUG: */ debugOutput(__FUNCTION__.':'.$ext_name.'=&gt;'.$version.':'.intval($GLOBALS['ext_installed_newer'][$ext_name][$version]));
        return $GLOBALS['ext_installed_newer'][$ext_name][$version];
 }
 
@@ -737,7 +737,7 @@ function isExtensionInstalledAndOlder ($ext_name, $version) {
        }
 
        // Return it
-       //* DEBUG: */ print __FUNCTION__.':'.$ext_name.'&lt;'.$version.':'.intval($GLOBALS['ext_installed_older'][$ext_name][$version]).'<br />';
+       //* DEBUG: */ debugOutput(__FUNCTION__.':'.$ext_name.'&lt;'.$version.':'.intval($GLOBALS['ext_installed_older'][$ext_name][$version]));
        return $GLOBALS['ext_installed_older'][$ext_name][$version];
 }
 
@@ -956,5 +956,110 @@ function getHttpStatus () {
        return $GLOBALS['http_status'];
 }
 
+// Setter for 'is_template_html'
+function enableTemplateHtml ($enable = true) {
+       $GLOBALS['is_template_html'] = (bool) $enable;
+}
+
+// Checks wether the template is HTML or not by previously set flag
+// Default: true
+function isTemplateHtml () {
+       // Is the output_mode other than 0 (HTML), then no comments are enabled
+       if (getOutputMode() != 0) {
+               // No HTML
+               return false;
+       } else {
+               // Maybe HTML?
+               return $GLOBALS['is_template_html'];
+       }
+}
+
+/**
+ * Send a HTTP redirect to the browser. This function was taken from DokuWiki
+ * (GNU GPL 2; http://www.dokuwiki.org) and modified to fit into mailer project.
+ *
+ * ----------------------------------------------------------------------------
+ * If you want to redirect, please use redirectToUrl(); instead
+ * ----------------------------------------------------------------------------
+ *
+ * Works arround Microsoft IIS cookie sending bug. Does exit the script.
+ *
+ * @link    http://support.microsoft.com/kb/q176113/
+ * @author  Andreas Gohr <andi@splitbrain.org>
+ * @access  private
+ */
+function sendRawRedirect ($url) {
+       // always close the session
+       session_write_close();
+
+       // Revert entity &amp;
+       $url = str_replace('&amp;', '&', $url);
+
+       // check if running on IIS < 6 with CGI-PHP
+       if ((isset($_SERVER['SERVER_SOFTWARE'])) && (isset($_SERVER['GATEWAY_INTERFACE'])) &&
+               (strpos($_SERVER['GATEWAY_INTERFACE'],'CGI') !== false) &&
+               (preg_match('|^Microsoft-IIS/(\d)\.\d$|', trim($_SERVER['SERVER_SOFTWARE']), $matches)) &&
+               ($matches[1] < 6)) {
+               // Send the IIS header
+               sendHeader('Refresh: 0;url=' . $url);
+       } else {
+               // Send generic header
+               sendHeader('Location: ' . $url);
+       }
+
+       // Shutdown here
+       shutdown();
+}
+
+// Determines the country of the given user id
+function determineCountry ($userid) {
+       // Default is 'invalid'
+       $country = 'invalid';
+
+       // Is extension country active?
+       if (isExtensionActive('country')) {
+               // Determine the right country code through the country id
+               $id = getUserData('country_code');
+
+               // Then handle it over
+               $country = generateCountryInfo($id);
+       } else {
+               // Get raw code from user data
+               $country = getUserData('country');
+       }
+
+       // Return it
+       return $country;
+}
+
+// "Getter" for total confirmed user accounts
+function getTotalConfirmedUser () {
+       // Is it cached?
+       if (!isset($GLOBALS['total_confirmed_users'])) {
+               // Then do it
+               $GLOBALS['total_confirmed_users'] = countSumTotalData('CONFIRMED', 'user_data', 'userid', 'status', true);
+       } // END - if
+
+       // Return cached value
+       return $GLOBALS['total_confirmed_users'];
+}
+
+// Wrapper for writing debug informations to the browser
+function debugOutput ($message) {
+       outputHtml('<div class="debug_message">' . $message . '</div>');
+}
+
+// Is given userid valid?
+function isValidUserId ($userid) {
+       // Do we have cache?
+       if (!isset($GLOBALS['is_valid_userid'][$userid])) {
+               // Check it out
+               $GLOBALS['is_valid_userid'][$userid] = ((!is_null($userid)) && (!empty($userid)) && ($userid > 0));
+       } // END - if
+
+       // Return cache
+       return $GLOBALS['is_valid_userid'][$userid];
+}
+
 // [EOF]
 ?>