]> git.mxchange.org Git - mailer.git/blobdiff - inc/wrapper-functions.php
Extensions bitcoins/yacy added, new API functions for handling proxy/non-proxy added:
[mailer.git] / inc / wrapper-functions.php
index 1d49f0ac9b04d044e79f9205bb9de654cd3a6815..8758f853d6c910cc8bd6b1de640650ed4b017c11 100644 (file)
  * $Date::                                                            $ *
  * $Tag:: 0.2.1-FINAL                                                 $ *
  * $Author::                                                          $ *
- * Needs to be in all Files and every File needs "svn propset           *
- * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
+ * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
  * For more information visit: http://www.mxchange.org                  *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
@@ -196,10 +194,25 @@ function isDirectory ($FQFN) {
        return $GLOBALS[__FUNCTION__][$FQFN];
 }
 
+// "Getter" for the real remote IP number
+function detectRealIpAddress () {
+       // Get remote ip from environment
+       $remoteAddr = determineRealRemoteAddress();
+
+       // Is removeip installed?
+       if (isExtensionActive('removeip')) {
+               // Then anonymize it
+               $remoteAddr = getAnonymousRemoteAddress($remoteAddr);
+       } // END - if
+
+       // Return it
+       return $remoteAddr;
+}
+
 // "Getter" for remote IP number
 function detectRemoteAddr () {
        // Get remote ip from environment
-       $remoteAddr = determineRealRemoteAddress();
+       $remoteAddr = determineRealRemoteAddress(true);
 
        // Is removeip installed?
        if (isExtensionActive('removeip')) {
@@ -273,16 +286,38 @@ function detectServerName () {
        return (getenv('SERVER_NAME'));
 }
 
+// Removes any  existing www. from SERVER_NAME. This is very silly but enough
+// for our purpose here.
+function detectDomainName () {
+       // Do we have cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Get server name
+               $domainName = detectServerName();
+
+               // Is there any www. ?
+               if (substr($domainName, 0, 4) == 'www.') {
+                       // Remove it
+                       $domainName = substr($domainName, 4);
+               } // END - if
+
+               // Set cache
+               $GLOBALS[__FUNCTION__] = $domainName;
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
 // Check wether we are installing
 function isInstalling () {
        // Determine wether we are installing
-       if (!isset($GLOBALS[__FUNCTION__])) {
+       if (!isset($GLOBALS['mailer_installing'])) {
                // Check URL (css.php/js.php need this)
-               $GLOBALS[__FUNCTION__] = isGetRequestParameterSet('installing');
+               $GLOBALS['mailer_installing'] = isGetRequestParameterSet('installing');
        } // END - if
 
        // Return result
-       return $GLOBALS[__FUNCTION__];
+       return $GLOBALS['mailer_installing'];
 }
 
 // Check wether this script is installed
@@ -666,13 +701,13 @@ function enableBlockMode ($enabled = true) {
 // Checks wether block-mode is enabled
 function isBlockModeEnabled () {
        // Abort if not set
-       if (!isset($GLOBALS[__FUNCTION__])) {
+       if (!isset($GLOBALS['block_mode'])) {
                // Needs to be fixed
                debug_report_bug(__FUNCTION__, __LINE__, 'Block_mode is not set.');
        } // END - if
 
        // Return it
-       return $GLOBALS[__FUNCTION__];
+       return $GLOBALS['block_mode'];
 }
 
 // Wrapper function for addPointsThroughReferalSystem()
@@ -773,7 +808,7 @@ function isDemoModeActive () {
        // Is cache set?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Simply check it
-               $GLOBALS[__FUNCTION__] = ((isExtensionActive('demo')) && (getAdminLogin(getSession('admin_id')) == 'demo'));
+               $GLOBALS[__FUNCTION__] = ((isExtensionActive('demo')) && (getCurrentAdminLogin() == 'demo'));
        } // END - if
 
        // Return it
@@ -802,12 +837,75 @@ function setAdminHash ($adminId, $hash) {
        $GLOBALS['cache_array']['admin']['password'][$adminId] = $hash;
 }
 
+// Getter for current admin login
+function getCurrentAdminLogin () {
+       // Log debug message
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
+
+       // Do we have cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = getAdminLogin(getCurrentAdminId());
+       } // END - if
+
+       // Return it
+       return $GLOBALS[__FUNCTION__];
+}
+
+// Setter for admin id (and current)
+function setAdminId ($adminId) {
+       // Log debug message
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminId=' . $adminId);
+
+       // Set session
+       $status = setSession('admin_id', bigintval($adminId));
+
+       // Set current id
+       setCurrentAdminId($adminId);
+
+       // Return status
+       return $status;
+}
+
+// Setter for admin_last
+function setAdminLast ($adminLast) {
+       // Log debug message
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminLast=' . $adminLast);
+
+       // Set session
+       $status = setSession('admin_last', $adminLast);
+
+       // Return status
+       return $status;
+}
+
+// Setter for admin_md5
+function setAdminMd5 ($adminMd5) {
+       // Log debug message
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminMd5=' . $adminMd5);
+
+       // Set session
+       $status = setSession('admin_md5', $adminMd5);
+
+       // Return status
+       return $status;
+}
+
+// Getter for admin_md5
+function getAdminMd5 () {
+       // Log debug message
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
+
+       // Get session
+       return getSession('admin_md5');
+}
+
 // Init user data array
 function initUserData () {
        // User id should not be zero
        if (!isValidUserId(getCurrentUserId())) {
                // Should be always valid
-               debug_report_bug(__FUNCTION__, __LINE__, 'User id is zero.');
+               debug_report_bug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
        } // END - if
 
        // Init the user
@@ -819,7 +917,7 @@ function getUserData ($column) {
        // User id should not be zero
        if (!isValidUserId(getCurrentUserId())) {
                // Should be always valid
-               debug_report_bug(__FUNCTION__, __LINE__, 'User id is zero.');
+               debug_report_bug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . getCurrentUserId());
        } // END - if
 
        // Return the value
@@ -834,7 +932,7 @@ function getUserDataArray () {
        // Is the current userid valid?
        if (!isValidUserId($userid)) {
                // Should be always valid
-               debug_report_bug(__FUNCTION__, __LINE__, 'User id is invalid.');
+               debug_report_bug(__FUNCTION__, __LINE__, 'Current user id is invalid: ' . $userid);
        } // END - if
 
        // Get the whole array if found
@@ -947,6 +1045,13 @@ function setHttpStatus ($status) {
 
 // Getter for HTTP status
 function getHttpStatus () {
+       // Is the status set?
+       if (!isset($GLOBALS['http_status'])) {
+               // Abort here
+               debug_report_bug(__FUNCTION__, __LINE__, 'No HTTP status set!');
+       } // END - if
+
+       // Return it
        return $GLOBALS['http_status'];
 }
 
@@ -965,6 +1070,9 @@ function getHttpStatus () {
  * @access  private
  */
 function sendRawRedirect ($url) {
+       // Send helping header
+       setHttpStatus('302 Found');
+
        // always close the session
        session_write_close();
 
@@ -1102,8 +1210,11 @@ function getYear ($timestamp = null) {
 function getMonth ($timestamp = null) {
        // Is it cached?
        if (!isset($GLOBALS[__FUNCTION__][$timestamp])) {
-               // null is time()
-               if (is_null($timestamp)) $timestamp = time();
+               // If null is set, use time()
+               if (is_null($timestamp)) {
+                       // Use time() which is current timestamp
+                       $timestamp = time();
+               } // END - if
 
                // Then create it
                $GLOBALS[__FUNCTION__][$timestamp] = date('m', $timestamp);
@@ -1316,7 +1427,7 @@ function isRandomReferalIdEnabled () {
        // Do we have cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it
-               $GLOBALS[__FUNCTION__] = (getConfig('select_user_zero_refid') == 'Y');
+               $GLOBALS[__FUNCTION__] = ((isExtensionInstalledAndNewer('user', '0.3.4')) && (getConfig('select_user_zero_refid') == 'Y'));
        } // END - if
 
        // Return cache
@@ -1335,6 +1446,18 @@ function getDefaultLanguage () {
        return $GLOBALS[__FUNCTION__];
 }
 
+// "Getter" for default referal id
+function getDefRefid () {
+       // Do we have cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = getConfig('def_refid');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
 // "Getter" for path
 function getPath () {
        // Do we have cache?
@@ -1492,11 +1615,11 @@ function getTitle () {
 }
 
 // "Getter" for curr_svn_revision
-function getCurrSvnRevision () {
+function getCurrentRepositoryRevision () {
        // Do we have cache?
        if (!isset($GLOBALS[__FUNCTION__])) {
                // Determine it
-               $GLOBALS[__FUNCTION__] = getConfig('CURR_SVN_REVISION');
+               $GLOBALS[__FUNCTION__] = getConfig('CURRENT_REPOSITORY_REVISION');
        } // END - if
 
        // Return cache
@@ -1839,6 +1962,126 @@ function getOneDay () {
        return $GLOBALS[__FUNCTION__];
 }
 
+// "Getter" for activate_xchange
+function getActivateXchange () {
+       // Do we have cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = getConfig('activate_xchange');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for img_type
+function getImgType () {
+       // Do we have cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = getConfig('img_type');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for code_length
+function getCodeLength () {
+       // Do we have cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = getConfig('code_length');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for least_cats
+function getLeastCats () {
+       // Do we have cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = getConfig('least_cats');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for pass_len
+function getPassLen () {
+       // Do we have cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = getConfig('pass_len');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for admin_menu
+function getAdminMenu () {
+       // Do we have cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = getConfig('admin_menu');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for last_month
+function getLastMonth () {
+       // Do we have cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = getConfig('last_month');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for max_send
+function getMaxSend () {
+       // Do we have cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = getConfig('max_send');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for mails_page
+function getMailsPage () {
+       // Do we have cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = getConfig('mails_page');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for __DB_NAME
+function getDbName () {
+       // Do we have cache?
+       if (!isset($GLOBALS[__FUNCTION__])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__] = getConfig('__DB_NAME');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__];
+}
+
 // Checks wether proxy configuration is used
 function isProxyUsed () {
        // Do we have cache?
@@ -1941,5 +2184,45 @@ function isRawOutputMode () {
        return (getScriptOutputMode() == -1);
 }
 
+// Wrapper to generate a user email link
+function generateWrappedUserEmailLink ($email) {
+       // Just call the inner function
+       return generateEmailLink($email, 'user_data');
+}
+
+// Wrapper to check if user points are locked
+function ifUserPointsLocked ($userid) {
+       // Do we have cache?
+       if (!isset($GLOBALS[__FUNCTION__][$userid])) {
+               // Determine it
+               $GLOBALS[__FUNCTION__][$userid] = ((getFetchedUserData('userid', $userid, 'ref_payout') > 0) && (!isDirectPaymentEnabled()));
+       } // END - if
+
+       // Return cache
+       return $GLOBALS[__FUNCTION__][$userid];
+}
+
+// Appends a line to an existing file or creates it instantly with given content.
+// This function does always add a new-line character to every line.
+function appendLineToFile ($file, $line) {
+       $fp = fopen($file, 'a') or debug_report_bug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($file) . '!');
+       fwrite($fp, $line . "\n");
+       fclose($fp);
+}
+
+// Wrapper for changeDataInFile() but with full path added
+function changeDataInInclude ($FQFN, $comment, $prefix, $suffix, $DATA, $seek=0) {
+       // Add full path
+       $FQFN = getPath() . $FQFN;
+
+       // Call inner function
+       changeDataInFile($FQFN, $comment, $prefix, $suffix, $DATA, $seek);
+}
+
+// Shortens ucfirst(strtolower()) calls
+function firstCharUpperCase ($str) {
+       return ucfirst(strtolower($str));
+}
+
 // [EOF]
 ?>