// Process only POST requests and that at least 'level' is set
if ((getHttpRequestMethod() == 'POST') && (isPostRequestElementSet('level'))) {
// Okay, that is valid, now check that the requested level right is valid
- if (isAjaxRequestLevelValid()) {
+ if (isValidAjaxRequestLevel()) {
// Process the request
processAjaxRequest();
$status = 'failed';
// Check if account was found
- if ((isUserDataValid()) && (getUserData('status') == 'CONFIRMED')) {
+ if ((isValidUserData()) && (getUserData('status') == 'CONFIRMED')) {
/*
* Multiply configured values with 100000 and divide with 100000 so we can also handle small values
* If we need more number behind the decimal dot then we just need to increase all these three
}
// Is the data valid?
- if (!isUserDataValid()) {
+ if (!isValidUserData()) {
// Output message that the userid is not okay
displayMessage('{--DOUBLER_USERID_INVALID--}');
} // END - if
$probe_points = ((postRequestElement('points') >= getDoublerMin()) && (postRequestElement('points') <= getDoublerMax()));
// Check all together
- if ((isUserDataValid()) && (getUserData('password') == generateHash(postRequestElement('password'), substr(getUserData('password'), 0, -40))) && (getUserData('status') == 'CONFIRMED') && ($probe_points)) {
+ if ((isValidUserData()) && (getUserData('password') == generateHash(postRequestElement('password'), substr(getUserData('password'), 0, -40))) && (getUserData('status') == 'CONFIRMED') && ($probe_points)) {
// Nickname resolved to a unique userid or direct userid entered by the member
$GLOBALS['local_doubler_userid'] = getUserData('userid');
// Output header
loadIncludeOnce('inc/header.php');
-if (isUserDataValid()) {
+if (isValidUserData()) {
// Transfer userid/nickname to constant
$content['refid'] = getUserData('userid');
} else {
* Checks whether the AJAX access level was valid. This function doesn't need
* caching in $GLOBALS[__FUNCTION__] because it will be called only once.
*/
-function isAjaxRequestLevelValid () {
+function isValidAjaxRequestLevel () {
// By default nothing is valid
$isValid = FALSE;
if ($value == 'formmethodpost') {
// Use it
$data['__form_method'] = 'post';
- } elseif (($value == 'formmethodpost') && (!isSpider()) && (!isSessionValid())) {
+ } elseif (($value == 'formmethodpost') && (!isSpider()) && (!isValidSession())) {
// Then expand 'value' with session id
if (strpos($data['value'], '?') !== FALSE) {
// '?' is set
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'SQLs::count=' . countSqls());
// Are there entries?
- if (isSqlsValid()) {
+ if (ifSqlsRegistered()) {
// Run SQL commands...
runFilterChain('run_sqls');
} // END - if
// Count cache hits
incrementStatsEntry('cache_hits');
- } elseif ((!isCacheInstanceValid()) || (isset($GLOBALS['cache_array']['extension'])) || (!isHtmlOutputMode())) {
+ } elseif ((!isValidCacheInstance()) || (isset($GLOBALS['cache_array']['extension'])) || (!isHtmlOutputMode())) {
// Load from database
$result = sqlQueryEscaped("SELECT * FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1",
array($ext_name), __FUNCTION__, __LINE__);
// Adds a RENAME TABLE stament if 'from' table exist and 'to' table not
function addRenameTableSql ($fromTable, $toTable) {
// Make sure both are not the same
- assert($fromTable != $toTable);
+ assert($fromTable != $toTable, 'fromTable must be different to toTable (' . $fromTable . ')');
// Is renaming required?
if ((ifSqlTableExists($fromTable)) && (!ifSqlTableExists($toTable))) {
// Add ALTER TABLE `foo` ADD sql if not found
function addExtensionAddTableColumnSql ($tableName, $columnName, $columnSql) {
+ // Assert on all
+ assert((!empty($tableName)) && (!empty($columnName)) && (!empty($columnSql)), 'tableName=' . $tableName . ',columnName=' . $columnName . ',columnSql=' . $columnSql);
+ assert($columnName != $columnSql . ',columnName=' . $columnName . ' must be non-equal to columnSql');
+
// Is the column there?
if (!ifSqlTableColumnExists('{?_MYSQL_PREFIX?}_' . $tableName, $columnName, isInstaller())) {
+ // Debug message
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ',columnName=' . $columnName . ',columnSql=' . $columnSql);
+
// Then add it
addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_' . $tableName . '` ADD `' . $columnName . '` ' . $columnSql);
} elseif (isDebugModeEnabled()) {
// Add ALTER TABLE `foo` ADD INDEX sql if not found
function addExtensionAddTableIndexSql ($tableName, $indexName, $columnSql) {
+ // Assert on all
+ assert((!empty($tableName)) && (!empty($indexName)) && (!empty($columnSql)), 'tableName=' . $tableName . ',indexName=' . $indexName . ',columnSql=' . $columnSql);
+ assert(($indexName != $columnSql), 'indexName=' . $indexName . ' must be unequal to columnSql');
+
// Is the column there?
if (!ifSqlTableIndexExist('{?_MYSQL_PREFIX?}_' . $tableName, $indexName, isInstaller())) {
+ // Debug message
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ',indexName=' . $indexName . ',columnSql=' . $columnSql);
+
// Then add it
addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_' . $tableName . '` ADD INDEX `' . $indexName . '` ' . $columnSql);
} elseif (isDebugModeEnabled()) {
// Add ALTER TABLE `foo` ADD UNIQUE INDEX sql if not found
function addExtensionAddTableUniqueSql ($tableName, $indexName, $columnSql) {
+ // Assert on all
+ assert((!empty($tableName)) && (!empty($indexName)) && (!empty($columnSql)), 'tableName=' . $tableName . ',indexName=' . $indexName . ',columnSql=' . $columnSql);
+ assert($indexName != $columnSql, 'indexName=' . $indexName . ' must be unequal to columnSql');
+
// Is the column there?
if (!ifSqlTableIndexExist('{?_MYSQL_PREFIX?}_' . $tableName, $indexName, isInstaller())) {
+ // Debug message
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ',indexName=' . $indexName . ',columnSql=' . $columnSql);
+
// Then add it
addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_' . $tableName . '` ADD UNIQUE INDEX `' . $indexName . '` ' . $columnSql);
} elseif (isDebugModeEnabled()) {
// Add ALTER TABLE `foo` ADD FULLTEXT sql if not found
function addExtensionAddTableFulltextSql ($tableName, $indexName, $columnSql) {
+ // Assert on all
+ assert((!empty($tableName)) && (!empty($indexName)) && (!empty($columnSql)), 'tableName=' . $tableName . ',indexName=' . $indexName . ',columnSql=' . $columnSql);
+ assert($indexName != $columnSql, 'indexName=' . $indexName . ' must be unequal to columnSql');
+
// Is the column there and MyISAM engine? (InnoDB doesn't support FULLTEXT)
if ((getTableType() == 'MyISAM') && (!ifSqlTableIndexExist('{?_MYSQL_PREFIX?}_' . $tableName, $indexName, isInstaller()))) {
+ // Debug message
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ',indexName=' . $indexName . ',columnSql=' . $columnSql);
+
// Then add it
addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_' . $tableName . '` ADD FULLTEXT `' . $indexName . '` ' . $columnSql);
} elseif (isDebugModeEnabled()) {
// Add ALTER TABLE `foo` CHANGE sql if not found
function addExtensionChangeTableColumnSql ($tableName, $fromColumnName, $toColumnName, $columnSql) {
+ // Assert on all
+ assert((!empty($tableName)) && (!empty($fromColumnName)) && (!empty($toColumnName)) && (!empty($columnSql)), 'tableName=' . $tableName . ',fromColumnName=' . $fromColumnName . ',toColumnName=' . $toColumnName . ',columnSql=' . $columnSql . ' must not be empty.');
+ assert(($fromColumnName != $columnSql) && ($toColumnName != $columnSql), 'tableName=' . $tableName . ',fromColumnName=' . $fromColumnName . ',toColumnName=' . $toColumnName . ',columnSql=' . $columnSql . ' must not be equal.');
+
// Is the column there?
if ((ifSqlTableColumnExists('{?_MYSQL_PREFIX?}_' . $tableName, $fromColumnName)) && (($fromColumnName == $toColumnName) || (!ifSqlTableColumnExists('{?_MYSQL_PREFIX?}_' . $tableName, $toColumnName, isInstaller())))) {
+ // Debug message
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ',fromColumnName=' . $fromColumnName . ',toColumnName=' . $toColumnName . ',columnSql=' . $columnSql);
+
// Then add it
addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_' . $tableName . '` CHANGE `' . $fromColumnName . '` `' . $toColumnName . '` ' . $columnSql);
} elseif (isDebugModeEnabled()) {
// Add ALTER TABLE `foo` DROP sql if not found
function addExtensionDropTableColumnSql ($tableName, $columnName) {
+ // Assert on all
+ assert((!empty($tableName)) && (!empty($columnName)), 'tableName=' . $tableName . ',columnName=' . $columnName . ' must not be empty.');
+
// Is the column there?
if (ifSqlTableColumnExists('{?_MYSQL_PREFIX?}_' . $tableName, $columnName, isInstaller())) {
+ // Debug message
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ',columnName=' . $columnName);
+
// Then add it
addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_' . $tableName . '` DROP `' . $columnName . '`');
} elseif (isDebugModeEnabled()) {
// Add ALTER TABLE `foo` DROP INDEX sql if not found
function addExtensionDropTableIndexSql ($tableName, $indexName) {
+ // Assert on all
+ assert((!empty($tableName)) && (!empty($indexName)) . ',tableName=' . $tableName . ',indexName=' . $indexName . ' must not be empty.');
+
// Is the column there?
if (ifSqlTableColumnExists('{?_MYSQL_PREFIX?}_' . $tableName, $indexName, isInstaller())) {
+ // Debug message
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ',indexName=' . $indexName);
+
// Then add it
addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_' . $tableName . '` DROP INDEX `' . $indexName . '`');
} elseif (isDebugModeEnabled()) {
* extension registration queue.
*/
function registerExtensionPointsData ($subject, $columnName, $lockedMode, $paymentMethod) {
+ // Assert on all
+ assert((!empty($subject)) && (!empty($columnName)) && (!empty($lockedMode)) && (!empty($paymentMethod)), ',subject=' . $subject . ',columnName=' . $columnName . ',lockedMode=' . $lockedMode . ',paymentMethod=' . $paymentMethod . ' must not be empty.');
+ assert((in_array($lockedMode, array('LOCKED', 'UNLOCKED'))) && (in_array($paymentMethod, array('DIRECT', 'REFERRAL'))), ',subject=' . $subject . ',columnName=' . $columnName . ',lockedMode=' . $lockedMode . ',paymentMethod=' . $paymentMethod . ' must be valid.');
+
// Is the suffix '_ref' not set?
if (!ifSubjectHasReferralSuffix($subject)) {
// Register this first
addExtensionChangeTableColumnSql('user_data', 'login_bonus', 'login_bonus', 'FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000');
// For configuration, we need different entries
- addExtensionAddTableColumnSql('user_data', 'turbo_bonus', 'turbo_bonus', 'FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000');
- addExtensionAddTableColumnSql('user_data', 'login_bonus', 'login_bonus', 'FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000');
+ addConfigChangeSql('turbo_bonus', 'turbo_bonus', 'FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000');
+ addConfigChangeSql('login_bonus', 'login_bonus', 'FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000');
// Update notes (these will be set as task text!)
setExtensionUpdateNotes("5 Nachkommastellen implementiert");
addConfigAddSql('bonus_new_member_notify', "ENUM('Y','N') NOT NULL DEFAULT 'N'");
addConfigAddSql('bonus_notify_points', 'FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000');
addConfigAddSql('bonus_notify_wait', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 30');
- addExtensionAddTableColumnSql('user_data', 'bonus_ral_en_notify', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
- addExtensionAddTableColumnSql('user_data', 'bonus_ral_di_notify', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
- addExtensionAddTableColumnSql('user_data', 'bonus_ral_notify', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
+ addExtensionAddTableColumnSql('user_data', 'bonus_ralley_enable_notify', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
+ addExtensionAddTableColumnSql('user_data', 'bonus_ralley_disable_notify', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
+ addExtensionAddTableColumnSql('user_data', 'bonus_ralley_notify', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
// Update notes (these will be set as task text!)
setExtensionUpdateNotes("Optionale automatische Benachrichtigung über aktivierte und/oder deaktivierte Aktiv-Rallye einstellbar.");
case '0.9.2': // SQL queries for v0.9.2
addExtensionChangeTableColumnSql('user_data', 'bonus_ral_en_notify', 'bonus_ralley_enable_notify', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
addExtensionChangeTableColumnSql('user_data', 'bonus_ral_di_notify', 'bonus_ralley_disable_notify', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
- addExtensionChangeTableColumnSql('user_data', 'bonus_ral_notify', 'bonus_rallley_notify', 'INT(20)', 'UNSIGNED NOT NULL DEFAULT 0');
+ addExtensionChangeTableColumnSql('user_data', 'bonus_ral_notify', 'bonus_ralley_notify', 'INT(20)', 'UNSIGNED NOT NULL DEFAULT 0');
// Update notes
setExtensionUpdateNotes("Umbenannt nach neuer Konvention (bitte Einstellungen kontrollieren).");
// Filter for logging blacklisted email addresses, is being called from above filter
function FILTER_LOG_EMAIL_BLACKLISTED ($filerData) {
// Make sure, that required data is there
- assert((isset($filterData['init_done'])) && ($filterData['blacklisted'] == 'email'));
+ assert((isset($filterData['init_done'])) && ($filterData['blacklisted'] == 'email'), 'filterData[init] must be set, filterData[blacklisted]=' . $filterData['blacklisted']);
// @TODO Insert log entry
// Filter for logging blacklisted IP addresses, is being called from above filter
function FILTER_LOG_IP_BLACKLISTED ($filerData) {
// Make sure, that required data is there
- assert((isset($filterData['init_done'])) && ($filterData['blacklisted'] == 'ip'));
+ assert((isset($filterData['init_done'])) && ($filterData['blacklisted'] == 'ip'), 'filterData[init] must be set, filterData[blacklisted]=' . $filterData['blacklisted']);
// @TODO Insert log entry
// Filter for logging blacklisted URLs, is being called from above filter
function FILTER_LOG_URL_BLACKLISTED ($filerData) {
// Make sure, that required data is there
- assert((isset($filterData['init_done'])) && ($filterData['blacklisted'] == 'url'));
+ assert((isset($filterData['init_done'])) && ($filterData['blacklisted'] == 'url'), 'filterData[init] must be set, filterData[blacklisted]=' . $filterData['blacklisted']);
// @TODO Insert log entry
function FILTER_CACHE_DESTROY_ON_EXT_CHANGE ($filterData) {
// Return the data anyway if there is no cache extension
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!');
- if (!isCacheInstanceValid()) {
+ if (!isValidCacheInstance()) {
return FALSE;
} // END - if
function FILTER_CACHE_DESTROY_ON_ADMIN_CHANGE ($filterData) {
// Skip this step if the cache instance is not there
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!');
- if (!isCacheInstanceValid()) {
+ if (!isValidCacheInstance()) {
return FALSE;
} // END - if
function FILTER_CACHE_DESTROY_ALL ($filterData) {
// Skip this step if the cache instance is not there
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!');
- if (!isCacheInstanceValid()) {
+ if (!isValidCacheInstance()) {
return FALSE;
} // END - if
function FILTER_CACHE_DESTROY_FILTER ($filterData) {
// Skip this step if the cache instance is not there
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!');
- if ((!isCacheInstanceValid()) || ((isConfigEntrySet('update_filter_usage')) && (getConfig('update_filter_usage') != 'Y'))) {
+ if ((!isValidCacheInstance()) || ((isConfigEntrySet('update_filter_usage')) && (getConfig('update_filter_usage') != 'Y'))) {
return FALSE;
} // END - if
} // END - if
// Empty session?
- if (!isSessionValid()) {
+ if (!isValidSession()) {
// This is invalid here!
reportBug(__FUNCTION__, __LINE__, 'Invalid session.');
} // END - if
// Generic filter for updating referral counter of currently detected referral id
function FILTER_GENERIC_UPDATE_USER_REFERRAL ($filterData) {
// Make sure the referral id is detected
- assert(isReferralIdValid());
+ assert(isValidReferralId(), 'isValidReferralId()=false which is not expected.');
// Update ref counter, determineReferralId() must already be called before this filter is executed
sqlQuery('UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `ref_clicks`=`ref_clicks`+1 WHERE `userid`={%pipe,getReferralId%} LIMIT 1', __FUNCTION__, __LINE__);
// Filter for updating sub id records
function FILTER_UPDATE_USER_SUBID ($filterData) {
// Make sure the referral id is detected
- assert(isReferralIdValid());
+ assert(isValidReferralId(), 'isValidReferralId()=false which is not expected.');
// Get sub id and secure it
$subId = sqlEscapeString(getRequestElement('subid'));
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, '- Entered!');
// Is the array there?
- if ((isSqlsValid()) && ((!isset($filterData['dry_run'])) || ($filterData['dry_run'] == FALSE))) {
+ if ((ifSqlsRegistered()) && ((!isset($filterData['dry_run'])) || ($filterData['dry_run'] == FALSE))) {
// Run SQL commands
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, '- Found ' . countSqls() . ' queries to run.');
foreach (getSqls() as $mode => $sqls) {
// Filter for adding hidden session id
function FILTER_ADD_INPUT_HIDDEN_SESSION_ID ($filterData) {
// Is a spider detected?
- if ((!isSpider()) && (!isSessionValid()) && ($filterData['__form_method'] == 'get')) {
+ if ((!isSpider()) && (!isValidSession()) && ($filterData['__form_method'] == 'get')) {
// No, then add the hidden field
$filterData['__replacer'] .= '<input type="hidden" name="' . session_name() . '" value="' . session_id() . '" />';
} // END - if
$localAbc = array_diff($GLOBALS['_abc'], $exclude);
// $localAbc must have at least 10 entries
- assert(count($localAbc) >= 10);
+ assert(count($localAbc) >= 10, 'localAbc()=' . count($localAbc) . ' is to small.');
// Start creating password
$password = '';
} // END - if
// Make sure entries is not bool, then something went wrong
- assert(!is_bool($entries));
+ assert(!is_bool($entries), 'entries[]=bool which is not expected.');
} elseif (!empty($filterFunctions[$search])) {
// Debug mode enabled?
if (isDebugModeEnabled()) {
} // END - if
// Make sure entries is not bool, then something went wrong
- assert(!is_bool($entries));
+ assert(!is_bool($entries), 'entries[]=bool which is not expected.');
}
// Return value
//* 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)) {
// 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)) {
} // END - if
// Is there a valid session?
- if ((!isSessionValid()) && (!isSpider())) {
+ if ((!isValidSession()) && (!isSpider())) {
// Determine right separator
$separator = '&';
if (!isInString('?', $url)) {
// Delete rows by given id numbers
function memberDeleteEntriesConfirm ($tableName, $columns = array(), $filterFunctions = array(), $extraValues = array(), $deleteNow = array(FALSE), $idColumn = array('id'), $userIdColumn = array('userid'), $rawUserId = array('userid'), $cacheFiles = array(), $content = array()) {
// Do this only for members
- assert(isMember());
+ assert(isMember(), 'isMember()=false which is not expected.');
// $tableName must be an array
if ((!is_array($tableName)) || (count($tableName) != 1)) {
// @TODO cacheFiles is not yet supported
function memberListBuilder ($listType, $tableName, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $rawUserId = array('userid'), $content = array()) {
// Do this only for logged in member
- assert(isMember());
+ assert(isMember(), 'isMember()=false which is not expected.');
// Call inner (general) function
doGenericListBuilder('member', $listType, $tableName, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $rawUserId, $content);
// "Getter" for an array from given one but only one index of it
function getArrayFromArrayIndex ($array, $key) {
// Some simple validation
- assert(isset($array[0][$key]));
+ assert(isset($array[0][$key]), 'array[0][' . $key . '] is not set.');
// Init new array
$newArray = array();
} // END - if
// @TODO Rewrite this to a filter
-if ((isExtensionInstalledAndNewer('cache', '0.1.2')) && (isCacheInstanceValid())) {
+if ((isExtensionInstalledAndNewer('cache', '0.1.2')) && (isValidCacheInstance())) {
// Destroy some cache files
foreach (array('config', 'extension', 'filter', 'modules') as $cache) {
// Use rebuildCache()
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isChunked=' . intval($isChunked));
if ($isChunked === TRUE) {
// Make sure, that body is an array
- assert(is_array($body));
+ assert(is_array($body), 'body[]=' . gettype($body) . ' must be an array.');
// Good, we still have the HTTP headers in there, so we need to get rid
// of them temporarly
// Sponsor data found
$functionName = "getFetchedSponsorData('id', " . $data['matches'][4][$data['key']] . ", '" . $data['callback'] . "')";
}
- } elseif ((!empty($data['callback'])) && (isSponsorDataValid())) {
+ } elseif ((!empty($data['callback'])) && (isValidSponsorData())) {
// "Call-back" alias column for current logged in sponsor's data
$functionName = "getSponsorData('" . $data['callback'] . "')";
}
if (!isValidId($sponsor_id)) {
// Invalid, so abort here
reportBug(__FUNCTION__, __LINE__, 'Sponsor id ' . $sponsor_id . ' is invalid.');
- } elseif (isSponsorDataValid()) {
+ } elseif (isValidSponsorData()) {
// Use cache, so it is fine
return TRUE;
}
- } elseif (isSponsorDataValid()) {
+ } elseif (isValidSponsorData()) {
// Use cache, so it is fine
return TRUE;
}
} // END - if
// Found, but valid?
- $found = isSponsorDataValid();
+ $found = isValidSponsorData();
} // END - if
// Free memory
// Checks if the sponsor data is valid, this may indicate that the sponsor has logged
// in, but you should use isMember() if you want to find that out.
-function isSponsorDataValid () {
+function isValidSponsorData () {
// Sponsor id should not be zero so abort here
if (!isCurrentSponsorIdSet()) return FALSE;
);
// Should work
- assert(isValidId(getSqlInsertId()));
+ assert(isValidId(getSqlInsertId()), 'getSqlInsertId() is not valid id number.');
}
// Calculates transaction fee for sender amount
// "Getter" for CAPTCHA code from given transaction id
function getCaptchaCodeFromTransactionId ($transactionId) {
// Must be valid
- assert(isValidId($transactionId));
+ assert(isValidId($transactionId), 'transactionId=' . $transactionId . ' is not valid id number.');
// Default is NULL
$code = NULL;
), $allowed, '', FALSE);
// Should always work
- assert($updated === TRUE);
+ assert($updated === TRUE, 'Nothing has been updated which is not expected.');
} // END - if
} // END - if
);
// Should always work
- assert(sqlAffectedRows() == count($failedIds));
+ assert(sqlAffectedRows() == count($failedIds), 'sqlAffectedRows()=' . sqlAffectedRows() . ',failedIds()=' . count($failedIds));
} // END - if
// Return status
// Checks whether the given user has a fee exempt
function ifUserHasTransactionFeeExempt ($username) {
// Accept only valid ids
- assert(isValidId($username));
+ assert(isValidId($username), 'username=' . $username . ' which is not a valid id number.');
// Is there "cache"?
if (!isset($GLOBALS[__FUNCTION__][$username])) {
$GLOBALS[__FUNCTION__][$username] = FALSE;
// "Determine" it
- $GLOBALS[__FUNCTION__][$username] = (getTotalAmountByUserid($username) < getConfig('transaction_fee_exempt_amount'));
+ $GLOBALS[__FUNCTION__][$username] = (getTotalPoints($username) < getConfig('transaction_fee_exempt_amount'));
} // END - if
// Return cache
} // END - if
// Debug message
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',isUserDataValid()=' . intval(isUserDataValid()) . ',userStatus=' . getUserData('status') . ',errorCode=' . $errorCode . ',ext=' . $ext . ',isFound=' . intval($isFound));
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',isValidUserData()=' . intval(isValidUserData()) . ',userStatus=' . getUserData('status') . ',errorCode=' . $errorCode . ',ext=' . $ext . ',isFound=' . intval($isFound));
// Is there an entry?
- if (($errorCode == '0') && (isUserDataValid()) && (getUserData('status') == 'CONFIRMED') && (!empty($content['userid']))) {
+ if (($errorCode == '0') && (isValidUserData()) && (getUserData('status') == 'CONFIRMED') && (!empty($content['userid']))) {
// Check for old MD5 passwords
if ((strlen(getUserData('password')) == 32) && (md5($passwd) == getUserData('password'))) {
// Just set the hash to the password from DB... :)
// Wrong password!
$errorCode = getCode('WRONG_PASS');
}
- } elseif ((isUserDataValid()) && (getUserData('status') != 'CONFIRMED')) {
+ } elseif ((isValidUserData()) && (getUserData('status') != 'CONFIRMED')) {
// Create an error code from given status
$errorCode = generateErrorCodeFromUserStatus(getUserData('status'));
// Set userid in session
setSession('userid', getUserData('userid'));
- } elseif (!isUserDataValid()) {
+ } elseif (!isValidUserData()) {
// User id not found
$errorCode = getCode('WRONG_ID');
} else {
// Fix all together
$functionName = "getFetchedUserData('userid', " . $data['matches'][4][$data['key']] . ", '" . $data['callback'] . "')";
}
- } elseif ((!empty($data['callback'])) && (isUserDataValid())) {
+ } elseif ((!empty($data['callback'])) && (isValidUserData())) {
// "Call-back" alias column for current logged in user's data
$functionName = "getUserData('" . $data['callback'] . "')";
}
// Register an administrator account
function addAdminAccount ($adminLogin, $passHash, $adminEmail, $accessLevel = 'deny') {
// Only let valid data pass
- assert(in_array($accessLevel, array('allow', 'deny')));
+ assert(in_array($accessLevel, array('allow', 'deny')), 'accessLevel=' . $accessLevel . ', should be one of allow/deny.');
// Login does already exist
$ret = 'already';
// Function to register first admin
function registerFirstAdmin () {
// Make sure that no admin is registered
- assert(!isAdminRegistered());
+ assert(!isAdminRegistered(), 'isAdminRegistered()=false which is not expected.');
// Admin is not registered so we have to inform the user
if ((isFormSent('add_first_admin')) && ((!isPostRequestElementSet('admin_login')) || (!isPostRequestElementSet('admin_password1')) || (strlen(postRequestElement('admin_password1')) < getConfig('minium_admin_pass_length')) || (!isPostRequestElementSet('admin_password2')) || (strlen(postRequestElement('admin_password2')) < getConfig('minium_admin_pass_length')) || (postRequestElement('admin_password1') != postRequestElement('admin_password2')))) {
} // END - switch
// Is there an array?
- if ((getRequestElement('sub') != 'points') && (isSqlsValid())) {
+ if ((getRequestElement('sub') != 'points') && (ifSqlsRegistered())) {
// Default is failed-message
$message = '<span class="bad">{--SETTINGS_NOT_SAVED--}</span>';
}
// Make sure only valid id numbers can pass
- assert(isValidId($data['id']));
+ assert(isValidId($data['id']), 'data[id]=' . $data['id'] . ' is not a valid id number.');
// Id is received so we can redirect the user, used points will be added when he send's out the mail
$data['url'] = 'modules.php?module=frametester&order=' . bigintval($data['id']);
if ((isCurrentUserIdSet()) && (getCurrentUserId() != $value)) {
// Unset it
unsetCurrentUserId();
- } elseif (isUserDataValid()) {
+ } elseif (isValidUserData()) {
// Use cache, so it is fine
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'value=' . $value . ' is valid, using cache #1');
return TRUE;
} // END - if
- } elseif (isUserDataValid()) {
+ } elseif (isValidUserData()) {
// Using cache is fine
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'value=' . $value . ' is valid, using cache #2');
return TRUE;
} // END - if
// Found, but valid?
- $found = isUserDataValid();
+ $found = isValidUserData();
} // END - if
// Free memory
// Is update mode set?
if (!is_null($updateMode)) {
// Don't allow array as data here
- assert(!is_array($data));
+ assert(!is_array($data), 'data must not be an array.');
// Then use this on the column with this mode (mostly counters)
sqlQueryEscaped('UPDATE `{?_MYSQL_PREFIX?}_pool` SET `%s`=`%s`%s%s WHERE `id`=%s' . $whereSql . ' LIMIT 1',
}
// Checks if 'refid' is valid
-function isReferralIdValid () {
+function isValidReferralId () {
return ((isset($GLOBALS['__refid'])) && (isValidId(getReferralId())));
}
// Determines referral id and sets it
function determineReferralId () {
// Is it already detected?
- if (isReferralIdValid()) {
+ if (isValidReferralId()) {
// Do not determine it, just return it
return getReferralId();
} elseif ((!isHtmlOutputMode()) && (basename($_SERVER['PHP_SELF']) != 'ref.php')) {
}
// Check if refid is set
- if (isReferralIdValid()) {
+ if (isValidReferralId()) {
// This is fine...
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Using refid from GLOBALS (' . getReferralId() . ')');
} elseif (isPostRequestElementSet('refid')) {
// Set cookie
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Saving refid to session (' . getReferralId() . ') #1');
setSession('refid', getReferralId());
- } elseif ((!isReferralIdValid()) || (!fetchUserData(getReferralId()))) {
+ } elseif ((!isValidReferralId()) || (!fetchUserData(getReferralId()))) {
// Not valid!
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Not valid referral id (' . getReferralId() . '), setting NULL in session');
setReferralId(NULL);
// Destroys session and resets some "caches"
function destroySession () {
// Unset "cache"
- unset($GLOBALS['isSessionValid']);
+ unset($GLOBALS['isValidSession']);
// Destroy session
return session_destroy();
}
// Checks whether the session is valid
-function isSessionValid () {
+function isValidSession () {
// Is there cache?
if (!isset($GLOBALS[__FUNCTION__])) {
// Then determine it
} // END - if
// Is a session id there?
-if (!isSessionValid()) {
+if (!isValidSession()) {
// Start the session
$GLOBALS['valid_session'] = session_start();
- $GLOBALS['isSessionValid'] = TRUE;
+ $GLOBALS['isValidSession'] = TRUE;
} // END - if
// Load language file(s)
}
// Checks whether the SQLs array is filled
-function isSqlsValid () {
+function ifSqlsRegistered () {
//* DEBUG: */ debugOutput(__FUNCTION__ . ':' . intval(isSqlsInitialized()) . '/' . countSqls() . '/' . getCurrentExtensionName());
return (
(
// "Getter" for result from given table and field/type LIKEs
function sqlGetResultFromLikeColumnsType ($tableName, $field, $type) {
// The table should be there
- assert(ifSqlTableExists($tableName));
+ assert(ifSqlTableExists($tableName), 'tableName=' . $tableName . ' does not exist. field=' . $field . ',type=' . $type);
// Default no field set
$fieldSql = '';
}
// Checks whether the cache instance is valid
-function isCacheInstanceValid () {
+function isValidCacheInstance () {
// Is there cache?
if (!isset($GLOBALS[__FUNCTION__])) {
// Determine it
// Checks if the user data is valid, this may indicate that the user has logged
// in, but you should use isMember() if you want to find that out.
-function isUserDataValid () {
+function isValidUserData () {
// User id should not be zero so abort here
if (!isCurrentUserIdSet()) {
// Debug message, may be noisy
// Wrapper to check if the first element to be shifted is set to given value
function shift_array (&$array, $value, $key = '0') {
// Is the element set and value matches?
- assert(is_array($array));
- assert(isset($array[$key]));
- assert($array[$key] === $value);
+ assert(is_array($array), 'array[]=' . gettype($array), ',expected: array');
+ assert(isset($array[$key]), 'array[' . $key . '] not set.');
+ assert(($array[$key] === $value), ',array[' . $key . ']=' . $array[$key] . ',value=' . $value);
// Shift it
array_shift($array);
// Walk through all entries
foreach ($columns as $columnArray) {
// Must be an array
- assert(is_array($columnArray));
+ assert(is_array($columnArray), 'columnArray[]=' . gettype($columnArray) . ' must be an array.');
// Init SQL part
$sqlPart = '';
// Walk through whole array
foreach ($columns as $key => $columnArray) {
// Make sure the element is there
- assert(isset($columnArray[$childKey]));
+ assert(isset($columnArray[$childKey]), 'columnArray[' . $childKey . '] is not set.');
// Now is it what we are looking for?
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'value=' . $value . ',key=' . $key . ',childKey=' . $childKey . ',columnArray=' . $columnArray[$childKey]);
$url = 'modules.php?module=index';
// Check for determined referral id
-if ((isExtensionActive('user')) && (isReferralIdValid()) && (isValidId(determineReferralId()))) {
+if ((isExtensionActive('user')) && (isValidReferralId()) && (isValidId(determineReferralId()))) {
// Run filter chain for updating referral data
runFilterChain('update_referral_data');
$url = 'modules.php?module=index';
// Is there a referral id?
-if (isReferralIdValid()) {
+if (isValidReferralId()) {
// We have an refid here. So we simply add it
$url .= '&what=sponsor_reg&refid=' . determineReferralId();
} // END - if