* -------------------------------------------------------------------- *
* Kurzbeschreibung : Viele Nicht-Datenbank-Funktionen *
* -------------------------------------------------------------------- *
- * $Revision:: $ *
- * $Date:: $ *
- * $Tag:: 0.2.1-FINAL $ *
- * $Author:: $ *
- * -------------------------------------------------------------------- *
* Copyright (c) 2003 - 2009 by Roland Haeder *
- * Copyright (c) 2009 - 2012 by Mailer Developer Team *
+ * Copyright (c) 2009 - 2013 by Mailer Developer Team *
* For more information visit: http://mxchange.org *
* *
* This program is free software; you can redistribute it and/or modify *
}
// Add a fatal error message to the queue array
-function addFatalMessage ($F, $L, $message, $extra = '') {
+function addFatalMessage ($file, $line, $message, $extra = '') {
if (is_array($extra)) {
// Multiple extras for a message with masks
$message = call_user_func_array('sprintf', $extra);
array_push($GLOBALS['fatal_messages'], $message);
// Log fatal messages away
- logDebugMessage($F, $L, 'Fatal error message: ' . compileCode($message));
+ logDebugMessage($file, $line, 'Fatal error message: ' . compileCode($message));
}
// Getter for total fatal message count
function generatePassword ($length = '0', $exclude = array()) {
// Auto-fix invalid length of zero
if ($length == '0') {
- $length = getPassLen();
+ $length = getMinPasswordLength();
} // END - if
// Exclude some entries
} // END - while
/*
- * When the size is below 40 we can also add additional security by
- * scrambling it. Otherwise the hash may corrupted..
+ * When the length of the password is below 40 characters additional
+ * security can be added by scrambling it. Otherwise the hash may
+ * corrupted.
*/
if (strlen($password) <= 40) {
// Also scramble the password
case '6': $ret = date('Ymd', $timeSecured); break;
case '7': $ret = date('Y-m-d H:i:s', $timeSecured); break; // Compatible with MySQL TIMESTAMP
default:
- logDebugMessage(__FUNCTION__, __LINE__, sprintf("Invalid date mode %s detected.", $mode));
+ logDebugMessage(__FUNCTION__, __LINE__, sprintf('Invalid date mode %s detected.', $mode));
break;
} // END - switch
break;
case '6': $ret = date('Ymd', $timeSecured); break;
case '7': $ret = date('Y-m-d H:i:s', $timeSecured); break; // Compatible with MySQL TIMESTAMP
default:
- logDebugMessage(__FUNCTION__, __LINE__, sprintf("Invalid date mode %s detected.", $mode));
+ logDebugMessage(__FUNCTION__, __LINE__, sprintf('Invalid date mode %s detected.', $mode));
break;
} // END - switch
} // END - switch
// Default
$GLOBALS[__FUNCTION__][$yn] = '??? (' . $yn . ')';
switch ($yn) {
- case 'Y': $GLOBALS[__FUNCTION__][$yn] = '{--YES--}'; break;
- case 'N': $GLOBALS[__FUNCTION__][$yn] = '{--NO--}'; break;
- default:
- // Log unknown value
- logDebugMessage(__FUNCTION__, __LINE__, sprintf("Unknown value %s. Expected: Y/N", $yn));
+ case 'Y': // Yes
+ $GLOBALS[__FUNCTION__][$yn] = '{--YES--}';
+ break;
+
+ case 'N': // No
+ $GLOBALS[__FUNCTION__][$yn] = '{--NO--}';
+ break;
+
+ default: // Log unknown value
+ logDebugMessage(__FUNCTION__, __LINE__, sprintf('Unknown value %s. Expected: Y/N', $yn));
break;
} // END - switch
} // END - if
// Default
$GLOBALS[__FUNCTION__][$status] = '??? (' . $status . ')';
switch ($status) {
- case 'Y': $GLOBALS[__FUNCTION__][$status] = '{--ACTIVATED--}'; break;
- case 'N': $GLOBALS[__FUNCTION__][$status] = '{--DEACTIVATED--}'; break;
- default:
- // Log unknown value
- logDebugMessage(__FUNCTION__, __LINE__, sprintf("Unknown value %s. Expected: Y/N", $status));
+ case 'Y': // Activated
+ $GLOBALS[__FUNCTION__][$status] = '{--ACTIVATED--}';
+ break;
+
+ case 'N': // Deactivated
+ $GLOBALS[__FUNCTION__][$status] = '{--DEACTIVATED--}';
+ break;
+
+ default: // Log unknown value
+ logDebugMessage(__FUNCTION__, __LINE__, sprintf('Unknown value %s. Expected: Y/N', $status));
break;
} // END - switch
} // END - if
default:
// Please report bugs on unknown genders
- reportBug(__FUNCTION__, __LINE__, sprintf("Unknown gender %s detected.", $gender));
+ reportBug(__FUNCTION__, __LINE__, sprintf('Unknown gender %s detected.', $gender));
break;
} // END - switch
case 'UNCONFIRMED':
case 'CONFIRMED':
case 'LOCKED':
- // Use generic function for all "normal" cases"
+ // Use generic function for all "normal" cases
$ret = translateGeneric('ACCOUNT_STATUS', $status);
break;
break;
default: // Please report all unknown status
- reportBug(__FUNCTION__, __LINE__, sprintf("Unknown status %s(%s) detected.", $status, gettype($status)));
+ reportBug(__FUNCTION__, __LINE__, sprintf('Unknown status %s(%s) detected.', $status, gettype($status)));
break;
} // END - switch
// Generates an URL for the frametester
function generateFrametesterUrl ($url) {
// Prepare frametester URL
- $frametesterUrl = sprintf("{%%url=modules.php?module=frametester&url=%s%%}",
+ $frametesterUrl = sprintf('{%%url=modules.php?module=frametester&url=%s%%}',
encodeString(compileUriCode($url))
);
sendRawRedirect(doFinalCompilation(str_replace('&', '&', $url), FALSE));
} else {
// Output error message
- loadInclude('inc/header.php');
+ loadPageHeader();
loadTemplate('redirect_url', FALSE, str_replace('&', '&', $url));
- loadInclude('inc/footer.php');
+ loadPageFooter();
}
// Shut the mailer down here
if (isConfigEntrySet('file_hash')) {
$keys .= getEncryptSeparator() . getFileHash();
} // END - if
- $keys .= getEncryptSeparator() . getDateFromRepository();
+
if (isConfigEntrySet('master_salt')) {
$keys .= getEncryptSeparator() . getMasterSalt();
} // END - if
// Creates a Uni* timestamp from given selection data and prefix
function createEpocheTimeFromSelections ($prefix, $postData) {
+ // Assert on typical array element (maybe all?)
+ assert(isset($postData[$prefix . '_ye']));
+
// Initial return value
$ret = '0';
// Is there a leap year?
$SWITCH = '0';
- $TEST = getYear() / 4;
- $M1 = getMonth();
+ $TEST = getYear() / 4;
+ $M1 = getMonth();
// If so and if current time is before 02/29 and estimated time is after 02/29 then add 86400 seconds (one day)
// 01 2 2 1 1 1 123 4 43 3 32 233 4 43 3 3210
// Return check result
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'email=' . $email . ',isValid=' . intval($GLOBALS[__FUNCTION__][$email]) . ' - EXIT!');
- return $GLOBALS[__FUNCTION__][$email];;
+ return $GLOBALS[__FUNCTION__][$email];
}
// Function taken from user comments on www.php.net / function isInStringIgnoreCase()
$server = $_SERVER['PHP_SELF'] . getEncryptSeparator() . detectUserAgent() . getEncryptSeparator() . getenv('SERVER_SOFTWARE') . getEncryptSeparator() . detectRealIpAddress() . getEncryptSeparator() . detectRemoteAddr();
// Build key string
- $keys = getSiteKey() . getEncryptSeparator() . getDateKey() . getEncryptSeparator() . getSecretKey() . getEncryptSeparator() . getFileHash() . getEncryptSeparator() . getDateFromRepository() . getEncryptSeparator() . getMasterSalt();
+ $keys = getSiteKey() . getEncryptSeparator() . getDateKey() . getEncryptSeparator() . getFileHash() . getEncryptSeparator() . getMasterSalt();
+
+ // Is the secret_key config entry set?
+ if (isConfigEntrySet('secret_key')) {
+ // Add it
+ $keys .= getEncryptSeparator() . getSecretKey();
+ } // END - if
// Additional data
$data = $plainText . getEncryptSeparator() . uniqid(mt_rand(), TRUE) . getEncryptSeparator() . time();
$scrambleNums = explode(':', genScrambleString(strlen($str)));
}
- // Compare both lengths and abort if different
- if (strlen($str) != count($scrambleNums)) {
- return $str;
- } // END - if
+ // Assert on both lengths
+ assert(strlen($str) == count($scrambleNums));
// Scramble string here
//* DEBUG: */ debugOutput('***Original=' . $str.'***<br />');
// So let's create the string for storing it in database
$scrambleString = implode(':', $scrambleNumbers);
+
+ // Return it
return $scrambleString;
}
// Default is hexadecimal of index if both are same
$mod = dechex($idx);
+
// Is part1 larger or part2 than its counter part?
if ($part1 > $part2) {
// part1 is larger
$mod = substr($mod, 0, 2);
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'idx=' . $idx . ',part1=' . $part1 . '/part2=' . $part2 . '/mod=' . $mod . '(' . strlen($mod) . ')');
- $mod = padLeftZero($mod);
+ $mod = padLeftZero($mod, 2);
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'mod(' . ($idx * 2) . ')=' . $mod . '*');
$start += 2;
$newHash .= $mod;
// Fix "deleted" cookies
function fixDeletedCookies ($cookies) {
// Is this an array with entries?
- if ((is_array($cookies)) && (count($cookies) > 0)) {
+ if (isFilledArray($cookies)) {
// Then check all cookies if they are marked as deleted!
foreach ($cookies as $cookieName) {
// Is the cookie set to "deleted"?
if (isExtensionActive('theme')) {
// Call inner method
$ret = getActualTheme();
- } elseif ((isPostRequestElementSet('theme')) && (isIncludeReadable(sprintf("theme/%s/theme.php", postRequestElement('theme'))))) {
+ } elseif ((isPostRequestElementSet('theme')) && (isThemeReadable(postRequestElement('theme')))) {
// Use value from POST data
$ret = postRequestElement('theme');
- } elseif ((isGetRequestElementSet('theme')) && (isIncludeReadable(sprintf("theme/%s/theme.php", getRequestElement('theme'))))) {
+ } elseif ((isGetRequestElementSet('theme')) && (isThemeReadable(getRequestElement('theme')))) {
// Use value from GET data
$ret = getRequestElement('theme');
- } elseif ((isMailerThemeSet()) && (isIncludeReadable(sprintf("theme/%s/theme.php", getMailerTheme())))) {
+ } elseif ((isMailerThemeSet()) && (isThemeReadable(getMailerTheme()))) {
// Use value from GET data
$ret = getMailerTheme();
}
$errorCode = getCode('ACCOUNT_UNKNOWN');
// Generate constant name
- $codeName = sprintf("ACCOUNT_%s", strtoupper($status));
+ $codeName = sprintf('ACCOUNT_%s', strtoupper($status));
// Is the constant there?
if (isCodeSet($codeName)) {
$errorCode = getCode($codeName);
} else {
// Unknown status
- logDebugMessage(__FUNCTION__, __LINE__, sprintf("Unknown error status %s detected.", $status));
+ logDebugMessage(__FUNCTION__, __LINE__, sprintf('Unknown error status %s detected.', $status));
}
// Return error code
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, sprintf("cache=%s, inc=%s, force=%s", $cache, $inc, intval($force)));
// Shall I remove the cache file?
- if ((isExtensionInstalled('cache')) && (isCacheInstanceValid()) && (isHtmlOutputMode())) {
+ if ((isExtensionInstalled('cache')) && (isValidCacheInstance()) && (isHtmlOutputMode())) {
// Rebuild cache only in HTML output-mode
+ // @TODO This should be rewritten not to load the cache file for just checking if it is there for save removal.
if ($GLOBALS['cache_instance']->loadCacheFile($cache)) {
// Destroy it
$GLOBALS['cache_instance']->removeCacheFile($force);
// Include file given?
if (!empty($inc)) {
// Construct FQFN
- $inc = sprintf("inc/loader/load-%s.php", $inc);
+ $inc = sprintf('inc/loader/load-%s.php', $inc);
// Is the include there?
if (isIncludeReadable($inc)) {
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'inc=' . $inc . ' - LOADED!');
loadInclude($inc);
} else {
- // Include not found
- logDebugMessage(__FUNCTION__, __LINE__, 'Include ' . $inc . ' not found. cache=' . $cache);
+ // Include not found, which needs now tracing
+ reportBug(__FUNCTION__, __LINE__, 'Include ' . $inc . ' not found. cache=' . $cache);
}
} // END - if
} // END - if
// Run filters (one always!)
runFilterChain('hourly');
+
+ // Do not update in hourly debug mode
+ if ((!isConfigEntrySet('DEBUG_HOURLY')) || (!isDebugHourlyEnabled())) {
+ // Update database
+ updateConfiguration('last_hourly', getHour());
+ } // END - if
}
// Enables the daily reset mode and runs it
// Run filters
runFilterChain('daily');
+
+ // Do not update in daily debug mode
+ if ((!isConfigEntrySet('DEBUG_DAILY')) || (!isDebugDailyEnabled())) {
+ // Update database
+ updateConfiguration('last_daily', getDay());
+ } // END - if
}
// Enables the weekly reset mode and runs it
// Run filters
runFilterChain('weekly');
+
+ // Do not update in weekly debug mode
+ if ((!isConfigEntrySet('DEBUG_WEEKLY')) || (!isDebugWeeklyEnabled())) {
+ // Update database
+ updateConfiguration('last_weekly', getWeek());
+ } // END - if
}
// Enables the monthly reset mode and runs it
// Run filters
runFilterChain('monthly');
+
+ // Do not update in monthly debug mode
+ if ((!isConfigEntrySet('DEBUG_MONTHLY')) || (!isDebugMonthlyEnabled())) {
+ // Update database
+ updateConfiguration('last_monthly', getMonth());
+ } // END - if
+}
+
+// Enables the yearly reset mode and runs it
+function doYearly () {
+ // Enable the reset mode
+ $GLOBALS['yearly_enabled'] = TRUE;
+
+ // Run filters
+ runFilterChain('yearly');
+
+ // Do not update in yearly debug mode
+ if ((!isConfigEntrySet('DEBUG_YEARLY')) || (!isDebugYearlyEnabled())) {
+ // Update database
+ updateConfiguration('last_yearly', getYear());
+ } // END - if
}
// Shuts down the mailer (e.g. closing database link, flushing output/filters, etc.)
runFilterChain('shutdown', NULL);
// Check if link is up
- if (SQL_IS_LINK_UP()) {
+ if (isSqlLinkUp()) {
// Close link
- SQL_CLOSE(__FUNCTION__, __LINE__);
- } elseif (!isInstallationPhase()) {
+ sqlCloseLink(__FUNCTION__, __LINE__);
+ } elseif (!isInstaller()) {
// No database link
reportBug(__FUNCTION__, __LINE__, 'Database link is already down, while shutdown is running.');
}
*
* @param $baseDir Relative base directory to PATH to scan from
* @param $prefix Prefix for all positive matches (which files should be found)
- * @param $fileIncludeDirs whether to include directories in the final output array
- * @param $addBaseDir whether to add $baseDir to all array entries
+ * @param $fileIncludeDirs Whether to include directories in the final output array
+ * @param $addBaseDir Whether to add $baseDir to all array entries
* @param $excludeArray Excluded files and directories, these must be full files names, e.g. 'what-' will exclude all files named 'what-' but won't exclude 'what-foo.php'
* @param $extension File extension for all positive matches
* @param $excludePattern Regular expression to exclude more files (preg_match())
- * @param $recursive whether to scan recursively
+ * @param $recursive Whether to scan recursively
* @param $suffix Suffix for positive matches ($extension will be appended, too)
+ * @param $withPrefixSuffix Whether to include prefix/suffix in found entries
* @return $foundMatches All found positive matches for above criteria
*/
-function getArrayFromDirectory ($baseDir, $prefix, $fileIncludeDirs = FALSE, $addBaseDir = TRUE, $excludeArray = array(), $extension = '.php', $excludePattern = '@(\.|\.\.)$@', $recursive = TRUE, $suffix = '') {
+function getArrayFromDirectory ($baseDir, $prefix, $fileIncludeDirs = FALSE, $addBaseDir = TRUE, $excludeArray = array(), $extension = '.php', $excludePattern = '@(\.|\.\.)$@', $recursive = TRUE, $suffix = '', $withPrefixSuffix = TRUE) {
// Add default entries we should always exclude
array_unshift($excludeArray, '.', '..', '.svn', '.htaccess');
if ($addBaseDir === TRUE) {
// With base path
array_push($foundMatches, $fileName);
+ } elseif (($withPrefixSuffix === FALSE) && (!empty($extension))) {
+ // No prefix/suffix
+ array_push($foundMatches, substr($baseFile, strlen($prefix), -strlen($suffix . $extension)));
} else {
// No base path
array_push($foundMatches, $baseFile);
// We found .php file but should not search for them, why?
reportBug(__FUNCTION__, __LINE__, 'We should find files with extension=' . $extension . ', but we found a PHP script. (baseFile=' . $baseFile . ')');
}
- } elseif ($fileExtension == $extension) {
+ } elseif ((($fileExtension == $extension) || (empty($extension))) && (isFileReadable($FQFN))) {
// Other, generic file found
- array_push($foundMatches, $fileName);
+ if ($addBaseDir === TRUE) {
+ // With base path
+ array_push($foundMatches, $fileName);
+ } elseif (($withPrefixSuffix === FALSE) && (!empty($extension))) {
+ // No prefix/suffix
+ array_push($foundMatches, substr($baseFile, strlen($prefix), -strlen($suffix . $extension)));
+ } else {
+ // No base path
+ array_push($foundMatches, $baseFile);
+ }
}
} // END - while
// Map only these, still lame code...
switch ($moduleName) {
case 'index': // 'index' is the guest's menu
- $moduleName = 'guest';
+ $moduleName = 'guest';
break;
case 'login': // ... and 'login' the member's menu
}
// Add SQL debug data to array for later output
-function addSqlToDebug ($result, $sqlString, $timing, $F, $L) {
+function addSqlToDebug ($result, $sqlString, $timing, $file, $line) {
// Is there cache?
if (!isset($GLOBALS['debug_sql_available'])) {
// Check it and cache it in $GLOBALS
$GLOBALS['debug_sql_available'] = ((isConfigurationLoaded()) && (isDisplayDebugSqlEnabled()));
} // END - if
-
+
// Don't execute anything here if we don't need or ext-other is missing
if ($GLOBALS['debug_sql_available'] === FALSE) {
return;
} // END - if
// Already executed?
- if (isset($GLOBALS['debug_sqls'][$F][$L][$sqlString])) {
+ if (isset($GLOBALS['debug_sqls'][$file][$line][$sqlString])) {
// Then abort here, we don't need to profile a query twice
return;
} // END - if
// Remeber this as profiled (or not, but we don't care here)
- $GLOBALS['debug_sqls'][$F][$L][$sqlString] = TRUE;
+ $GLOBALS['debug_sqls'][$file][$line][$sqlString] = TRUE;
// Generate record
$record = array(
- 'num_rows' => SQL_NUMROWS($result),
- 'affected' => SQL_AFFECTEDROWS(),
+ 'num_rows' => sqlNumRows($result),
+ 'affected' => sqlAffectedRows(),
'sql_str' => $sqlString,
'timing' => $timing,
- 'file' => basename($F),
- 'line' => $L
+ 'file' => basename($file),
+ 'line' => $line
);
// Add it
} // END - if
// Is there a valid session?
- if ((!isSessionValid()) && (!isSpider())) {
+ if ((!isValidSession()) && (!isSpider())) {
// Determine right separator
$separator = '&';
if (!isInString('?', $url)) {
return ((isInStringIgnoreCase('spider', $userAgent)) || (isInStringIgnoreCase('slurp', $userAgent)) || (isInStringIgnoreCase('bot', $userAgent)) || (isInStringIgnoreCase('archiver', $userAgent)));
}
-// Function to search for the last modified file
-function searchDirsRecursive ($dir, &$last_changed, $lookFor = 'Date') {
- // Get dir as array
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'dir=' . $dir);
- // Does it match what we are looking for? (We skip a lot files already!)
- // RegexPattern to exclude ., .., .revision, .svn, debug.log or .cache in the filenames
- $excludePattern = '@(\.revision|\.svn|debug\.log|\.cache|config\.php)$@';
-
- $ds = getArrayFromDirectory($dir, '', FALSE, TRUE, array(), '.php', $excludePattern);
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'count(ds)='.count($ds));
-
- // Walk through all entries
- foreach ($ds as $d) {
- // Generate proper FQFN
- $FQFN = str_replace('//', '/', getPath() . $dir . '/' . $d);
-
- // Is it a file and readable?
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'dir=' . $dir . ',d=' . $d);
- if (isFileReadable($FQFN)) {
- // $FQFN is a readable file so extract the requested data from it
- $check = extractRevisionInfoFromFile($FQFN, $lookFor);
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'File: ' . $d . ' found. check=' . $check);
-
- // Is the file more recent?
- if ((!isset($last_changed[$lookFor])) || ($last_changed[$lookFor] < $check)) {
- // This file is newer as the file before
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'NEWER!');
- $last_changed['path_name'] = $FQFN;
- $last_changed[$lookFor] = $check;
- } // END - if
- } else {
- // Not readable
- /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'File: ' . $d . ' not readable or directory.');
- }
- } // END - foreach
-}
-
// Handles the braces [] of a field (e.g. value of 'name' attribute)
function handleFieldWithBraces ($field) {
// Are there braces [] at the end?
// Converts a zero or NULL to word 'NULL'
function convertZeroToNull ($number) {
// Is it a valid username?
- if ((!is_null($number)) && (!empty($number)) && ($number > 0)) {
+ if (isValidNumber($number)) {
// Always secure it
$number = bigintval($number);
} else {
return $number;
}
+// Converts an empty string to NULL, else leaves it untouched
+function convertEmptyToNull ($str) {
+ // Is the string empty?
+ if (strlen($str) == 0) {
+ // Is really empty
+ $str = NULL;
+ } // END - if
+
+ // Return it
+ return $str;
+}
+
// Converts a NULL|empty string|< 1 to zero
function convertNullToZero ($number) {
// Is it a valid username?
- if ((is_null($number)) || (empty($number)) || ($number < 1)) {
+ if (!isValidNumber($number)) {
// Is not valid or zero
$number = '0';
} // END - if
// Is the mail type supported?
if (!empty($table)) {
// Query for the mail
- $result = SQL_QUERY_ESC("SELECT `id`, `%s` AS `mail_status` FROM `{?_MYSQL_PREFIX?}_%s` WHERE `id`=%s LIMIT 1",
+ $result = sqlQueryEscaped("SELECT `id`, `%s` AS `mail_status` FROM `{?_MYSQL_PREFIX?}_%s` WHERE `id`=%s LIMIT 1",
array(
$statusColumn,
$table,
), __FILE__, __LINE__);
// Is there one entry there?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load the entry
- $content = SQL_FETCHARRAY($result);
+ $content = sqlFetchArray($result);
// Add output and type
$content['type'] = $mailType;
} // END - if
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
// Return generated HTML code
doGenericAddEntries($tableName, $columns, $filterFunctions, $extraValues, $timeColumns, $columnIndex);
// Entry has been added?
- if ((!SQL_HASZEROAFFECTED()) && ($GLOBALS['__XML_PARSE_RESULT'] === TRUE)) {
+ if ((!ifSqlHasZeroAffectedRows()) && ($GLOBALS['__XML_PARSE_RESULT'] === TRUE)) {
// Display success message
displayMessage('{--MEMBER_ENTRY_ADDED--}');
} else {
displayMessage('{--MEMBER_ALL_ENTRIES_REMOVED--}');
} else {
// Some are still there :(
- displayMessage(sprintf(getMessage('MEMBER_SOME_ENTRIES_NOT_DELETED'), SQL_AFFECTEDROWS(), countPostSelection($idColumn[0])));
+ displayMessage(sprintf(getMessage('MEMBER_SOME_ENTRIES_NOT_DELETED'), sqlAffectedRows(), countPostSelection($idColumn[0])));
}
} else {
// List for deletion confirmation
/**
* Compress given data and encodes it into BASE64 to be stored in database with
- * SQL_QUERY_ESC()
+ * sqlQueryEscaped()
*
* @param $data Data to be compressed and encoded
* @return $data Compressed+encoded data
return $str;
}
+// Hash string with SHA256 and encode it to hex
+function hashSha256 ($str) {
+ /// Hash string
+ $hash = mhash(MHASH_SHA256, $str);
+
+ // Encode it to hexadecimal
+ $hex = '';
+ for ($i = 0; $i < strlen($hash); $i++) {
+ // Encode char to decimal, pad it with zero, add it
+ $hex .= padLeftZero(dechex(ord(substr($hash, $i, 1))), 2);
+ } // END - if
+
+ // Make sure 'length modulo 2' = 0
+ assert((strlen($hex) % 2) == 0);
+
+ // Return it
+ return $hex;
+}
+
// ----------------------------------------------------------------------------
// "Translatation" functions for points_data table
// ----------------------------------------------------------------------------
}
} // END - if
+// "Calculates" password strength
+function calculatePasswordStrength ($password, $configEntry = 'min_password_length') {
+ // Default score
+ $score = 1;
+
+ if ((strlen($password) < 1) || (strlen($password) < getConfig($configEntry))) {
+ // Is to weak
+ return 0;
+ } // END - if
+
+ // At least 8 chars long?
+ if (strlen($password) >= 8) {
+ // Add score
+ $score++;
+ } // END - if
+
+ // At least 10 chars long?
+ if (strlen($password) >= 10) {
+ // Add score
+ $score++;
+ } // END - if
+
+ // Lower and upper cases?
+ if ((preg_match('/[a-z]/', $password)) && (preg_match('/[A-Z]/', $password))) {
+ // Add score
+ $score++;
+ } // END - if
+
+ // Also numbers?
+ if (preg_match('/[0-9]/', $password)) {
+ // Add score
+ $score++;
+ } // END - if
+
+ // Special characters?
+ if (preg_match('/.[!,@,#,$,%,^,&,*,?,\/,_,~,+,-,(,)]/', $password)) {
+ // Add score
+ $score++;
+ } // END - if
+
+ // Return password score
+ return $score;
+}
+
+// "Translates" password strength/score
+function translatePasswordStrength ($strength) {
+ // Return it translated
+ return '{--PASSWORD_SCORE_' . bigintval($strength) . '--}';
+}
+
+// Checks whether given password is strong enough
+function isStrongPassword ($password) {
+ // Determine it
+ return (calculatePasswordStrength($password) >= getConfig('min_password_score'));
+}
+
+// "Getter" for base path from theme
+function getBasePathFromTheme ($theme) {
+ return sprintf('%stheme/%s/css/', getPath(), $theme);
+}
+
+// Wrapper to check whether given theme is readable
+function isThemeReadable ($theme) {
+ // Is there cache?
+ if (!isset($GLOBALS[__FUNCTION__][$theme])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__][$theme] = (isIncludeReadable(sprintf('theme/%s/theme.php', $theme)));
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__][$theme];
+}
+
+// Checks whether a given PHP extension is loaded or can be loaded at runtime
+//
+// Supported OS: Windows, Linux, (Mac?)
+function isPhpExtensionLoaded ($extension) {
+ // Is the extension loaded?
+ if (extension_loaded($extension)) {
+ // All fine
+ return TRUE;
+ } // END - if
+
+ // Try to load the extension
+ return loadLibrary($extension);
+}
+
+// Loads given library (aka. PHP extension)
+// Credits: shaunspiller at spammenot-gmail dot com ( http://de.php.net/dl#88566 )
+function loadLibrary ($n, $f = NULL) {
+ return extension_loaded($n) or dl(((PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '') . ($f ? $f : $n) . '.' . PHP_SHLIB_SUFFIX);
+}
+
+// "Translates" given PHP extension name into a readable version
+function translatePhpExtension ($extension) {
+ // Return the language element
+ return '{--PHP_EXTENSION_' . strtoupper($extension) . '--}';
+}
+
// [EOF]
?>