* $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 *
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')) {
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
// Getter for 'output_mode' value
function getScriptOutputMode () {
- // Default is null
- $output_mode = null;
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Default is null
+ $output_mode = null;
- // Is the value set?
- if (isOutputModeSet(true)) {
- // Then use it
- $output_mode = $GLOBALS['output_mode'];
+ // Is the value set?
+ if (isOutputModeSet(true)) {
+ // Then use it
+ $output_mode = $GLOBALS['output_mode'];
+ } // END - if
+
+ // Store it in cache
+ $GLOBALS[__FUNCTION__] = $output_mode;
} // END - if
- // Return it
- return $output_mode;
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
}
// Setter for 'output_mode' value
// 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 not set.');
} // END - if
// Return it
}
// Return it
- //* DEBUG: */ debugOutput(__FUNCTION__.':'.$ext_name.'=>'.$version.':'.intval($GLOBALS[__FUNCTION__][$ext_name][$version]));
+ //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '=>' . $version . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$version]));
return $GLOBALS[__FUNCTION__][$ext_name][$version];
}
}
// Return it
- //* DEBUG: */ debugOutput(__FUNCTION__.':'.$ext_name.'<'.$version.':'.intval($GLOBALS[__FUNCTION__][$ext_name][$version]));
+ //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '<' . $version . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$version]));
return $GLOBALS[__FUNCTION__][$ext_name][$version];
}
// 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
$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
// 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
// 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
// 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'];
}
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);
// 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
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?
return $GLOBALS[__FUNCTION__];
}
+// "Getter" for SITE_KEY
+function getSiteKey () {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('SITE_KEY');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for DATE_KEY
+function getDayKey () {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('DATE_KEY');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
// "Getter" for master_salt
function getMasterSalt () {
// Do we have cache?
}
// "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
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 rand_no
+function getRandNo () {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('rand_no');
+ } // 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__];
+}
+
+// "Getter" for DOMAIN
+function getDomain () {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('DOMAIN');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for proxy_username
+function getProxyUsername () {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('proxy_username');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for proxy_password
+function getProxyPassword () {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('proxy_password');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for proxy_host
+function getProxyHost () {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('proxy_host');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for proxy_port
+function getProxyPort () {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('proxy_port');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for SMTP_HOSTNAME
+function getSmtpHostname () {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('SMTP_HOSTNAME');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for SMTP_USER
+function getSmtpUser () {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('SMTP_USER');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
+// "Getter" for SMTP_PASSWORD
+function getSmtpPassword() {
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__] = getConfig('SMTP_PASSWORD');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__];
+}
+
// Checks wether proxy configuration is used
function isProxyUsed () {
// Do we have cache?
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
+ return changeDataInFile($FQFN, $comment, $prefix, $suffix, $DATA, $seek);
+}
+
+// Shortens ucfirst(strtolower()) calls
+function firstCharUpperCase ($str) {
+ return ucfirst(strtolower($str));
+}
+
// [EOF]
?>