array_push($GLOBALS['fatal_messages'], $message);
// Log fatal messages away
- logDebugMessage($F, $L, 'Fatal error message: ' . $message);
+ logDebugMessage($F, $L, 'Fatal error message: ' . compileCode($message));
}
// Getter for total fatal message count
// Init count
$count = '0';
- // Do we have at least the first entry?
+ // Is there at least the first entry?
if (!empty($GLOBALS['fatal_messages'][0])) {
// Get total count
$count = count($GLOBALS['fatal_messages']);
}
// Generates an URL for the dereferer
-function generateDerefererUrl ($url) {
+function generateDereferrerUrl ($url) {
// Don't de-refer our own links!
if (substr($url, 0, strlen(getUrl())) != getUrl()) {
// Encode URL
// Default 'rel' value is external, nofollow is evil from Google and hurts the Internet
$rel = ' rel="external"';
- // Do we have internal or external URL?
+ // Is there internal or external URL?
if (substr($url, 0, strlen(getUrl())) == getUrl()) {
// Own (=internal) URL
$rel = '';
// Initial return value
$ret = '0';
- // Do we have a leap year?
+ // Is there a leap year?
$SWITCH = '0';
$TEST = getYear() / 4;
$M1 = getMonth();
} // END - if
} // END - foreach
- // Do we have something there?
+ // Is something there?
if (strlen($ret) > 0) {
// Remove leading commata and space
$ret = substr($ret, 2);
}
} // END - if
- // Do we miss an arry element here?
+ // Is an arry element missing here?
if (!isConfigEntrySet('file_hash')) {
// Stop here
reportBug(__FUNCTION__, __LINE__, 'Missing file_hash in ' . __FUNCTION__ . '.');
// The default theme is 'default'... ;-)
$ret = 'default';
- // Do we have ext-theme installed and active or is 'theme' in URL or POST data?
+ // Is there ext-theme installed and active or is 'theme' in URL or POST data?
if (isExtensionActive('theme')) {
// Call inner method
$ret = getActualTheme();
// Default is the value itself
$ret = $value;
- // Do we have a special filter function?
+ // Is there a special filter function?
if (!empty($filterFunction)) {
// Does the filter function exist?
if (function_exists($filterFunction)) {
- // Do we have extra parameters here?
+ // Is there extra parameters here?
if (!empty($extraValue)) {
// Put both parameters in one new array by default
$args = array($value, $extraValue);
// Add SQL debug data to array for later output
function addSqlToDebug ($result, $sqlString, $timing, $F, $L) {
- // Do we have cache?
+ // Is there cache?
if (!isset($GLOBALS['debug_sql_available'])) {
// Check it and cache it in $GLOBALS
$GLOBALS['debug_sql_available'] = ((isConfigurationLoaded()) && (isDisplayDebugSqlEnabled()));
// Encodes an URL for adding session id, etc.
function encodeUrl ($url, $outputMode = '0') {
- // Do we have already have a PHPSESSID inside or view.php is called? Then abort here
+ // Is there already have a PHPSESSID inside or view.php is called? Then abort here
if ((isInStringIgnoreCase(session_name(), $url)) || (isRawOutputMode())) {
// Raw output mode detected or session_name() found in URL
return $url;
} // END - if
- // Do we have a valid session?
+ // Is there a valid session?
if (((!isset($GLOBALS['valid_session'])) || ($GLOBALS['valid_session'] === false) || (!isset($_COOKIE[session_name()]))) && (isSpider() === false)) {
// Determine right separator
$separator = '&';
$url = '{?URL?}/' . $url;
} // END - if
- // Do we have to decode entities?
+ // Is there to decode entities?
if ((!isHtmlOutputMode()) || ($outputMode != '0')) {
// Decode them for e.g. JavaScript parts
$url = decodeEntities($url);
// Capitalizes a string with underscores, e.g.: some_foo_string will become SomeFooString
// Note: This function is cached
function capitalizeUnderscoreString ($str) {
- // Do we have cache?
+ // Is there cache?
if (!isset($GLOBALS[__FUNCTION__][$str])) {
// Init target string
$capitalized = '';
bigintval($mailId)
), __FILE__, __LINE__);
- // Do we have one entry there?
+ // Is there one entry there?
if (SQL_NUMROWS($result) == 1) {
// Load the entry
$content = SQL_FETCHARRAY($result);
// Now check all entries
foreach ($needles as $key => $needle) {
- // Do we have found a partial string?
+ // Is there found a partial string?
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'heystack='.$heystack.',key='.$key.',needle='.$needle.',offset='.$offset);
if (strpos($heystack, $needle, $offset) !== false) {
// Add the found key
// Debug message (to measure how often this function is called)
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'str=' . $str);
- // Do we have cache?
+ // Is there cache?
if (!isset($GLOBALS[__FUNCTION__][$str])) {
// Trim it lower-case for validation
$strTrimmed = trim(strtolower($str));
reportBug(__FUNCTION__, __LINE__, 'varString=' . $varString . ' - No dollar sign detected, will not parse it.');
} // END - if
- // Do we have cache?
+ // Is there cache?
if (!isset($GLOBALS[__FUNCTION__][$varString])) {
// Snap them in, if [,] are there
$GLOBALS[__FUNCTION__][$varString] = str_replace(array('[', ']'), array("['", "']"), $varString);
return $subject;
}
+// Adds a given entry to the database
+function memberAddEntries ($tableName, $columns = array(), $filterFunctions = array(), $extraValues = array(), $timeColumns = array(), $columnIndex = NULL) {
+ // Is it a member?
+ if (!isMember()) {
+ // Then abort here
+ return false;
+ } // END - if
+
+ // Set POST data generic userid
+ setPostRequestElement('userid', getMemberId());
+
+ // Call inner function
+ doGenericAddEntries($tableName, $columns, $filterFunctions, $extraValues, $timeColumns, $columnIndex);
+
+ // Entry has been added?
+ if ((!SQL_HASZEROAFFECTED()) && ($GLOBALS['__XML_PARSE_RESULT'] === true)) {
+ // Display success message
+ displayMessage('{--MEMBER_ENTRY_ADDED--}');
+ } else {
+ // Display failed message
+ displayMessage('{--MEMBER_ENTRY_NOT_ADDED--}');
+ }
+}
+
+// Edit rows by given id numbers
+function memberEditEntriesConfirm ($tableName, $columns = array(), $filterFunctions = array(), $extraValues = array(), $timeColumns = array(), $editNow = array(false), $idColumn = array('id'), $userIdColumn = array('userid'), $rawUserId = array('userid'), $cacheFiles = array()) {
+ // $tableName must be an array
+ if ((!is_array($tableName)) || (count($tableName) != 1)) {
+ // No tableName specified
+ reportBug(__FUNCTION__, __LINE__, 'tableName is not given. Please fix your XML,tableName[]=' . gettype($tableName) . '!=array: userIdColumn=' . $userIdColumn);
+ } elseif (!is_array($idColumn)) {
+ // $idColumn is no array
+ reportBug(__FUNCTION__, __LINE__, 'idColumn[]=' . gettype($idColumn) . '!=array: userIdColumn=' . $userIdColumn);
+ } elseif (!is_array($userIdColumn)) {
+ // $userIdColumn is no array
+ reportBug(__FUNCTION__, __LINE__, 'userIdColumn[]=' . gettype($userIdColumn) . '!=array: userIdColumn=' . $userIdColumn);
+ } elseif (!is_array($editNow)) {
+ // $editNow is no array
+ reportBug(__FUNCTION__, __LINE__, 'editNow[]=' . gettype($editNow) . '!=array: userIdColumn=' . $userIdColumn);
+ } // END - if
+
+ // Shall we change here or list for editing?
+ if ($editNow[0] === true) {
+ // Add generic userid field
+ setPostRequestElement('userid', getMemberId());
+
+ // Call generic change method
+ $affected = doGenericEditEntriesConfirm($tableName, $columns, $filterFunctions, $extraValues, $timeColumns, $editNow, $idColumn, $userIdColumn, $rawUserId, $cacheFiles);
+
+ // Was this fine?
+ if ($affected == countPostSelection($idColumn[0])) {
+ // All deleted
+ displayMessage('{--MEMBER_ALL_ENTRIES_EDITED--}');
+ } else {
+ // Some are still there :(
+ displayMessage(sprintf(getMessage('MEMBER_SOME_ENTRIES_NOT_EDITED'), $affected, countPostSelection($idColumn[0])));
+ }
+ } else {
+ // List for editing
+ memberListBuilder('edit', $tableName, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn);
+ }
+}
+
+// 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()) {
+ // Do this only for members
+ assert(isMember());
+
+ // $tableName must be an array
+ if ((!is_array($tableName)) || (count($tableName) != 1)) {
+ // No tableName specified
+ reportBug(__FUNCTION__, __LINE__, 'tableName is not given. Please fix your XML,tableName[]=' . gettype($tableName) . '!=array: userIdColumn=' . $userIdColumn);
+ } elseif (!is_array($idColumn)) {
+ // $idColumn is no array
+ reportBug(__FUNCTION__, __LINE__, 'idColumn[]=' . gettype($idColumn) . '!=array: userIdColumn=' . $userIdColumn);
+ } elseif (!is_array($userIdColumn)) {
+ // $userIdColumn is no array
+ reportBug(__FUNCTION__, __LINE__, 'userIdColumn[]=' . gettype($userIdColumn) . '!=array: userIdColumn=' . $userIdColumn);
+ } elseif (!is_array($deleteNow)) {
+ // $deleteNow is no array
+ reportBug(__FUNCTION__, __LINE__, 'deleteNow[]=' . gettype($deleteNow) . '!=array: userIdColumn=' . $userIdColumn);
+ } // END - if
+
+ // Shall we delete here or list for deletion?
+ if ($deleteNow[0] === true) {
+ // Add generic userid field
+ setPostRequestElement('userid', getMemberId());
+
+ // Call generic function
+ $affected = doGenericDeleteEntriesConfirm($tableName, $columns, $filterFunctions, $extraValues, $deleteNow, $idColumn, $userIdColumn, $rawUserId, $cacheFiles);
+
+ // Was this fine?
+ if ($affected == countPostSelection($idColumn[0])) {
+ // All deleted
+ displayMessage('{--MEMBER_ALL_ENTRIES_REMOVED--}');
+ } else {
+ // Some are still there :(
+ displayMessage(sprintf(getMessage('MEMBER_SOME_ENTRIES_NOT_DELETED'), SQL_AFFECTEDROWS(), countPostSelection($idColumn[0])));
+ }
+ } else {
+ // List for deletion confirmation
+ memberListBuilder('delete', $tableName, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn);
+ }
+}
+
+// Build a special template list
+function memberListBuilder ($listType, $tableName, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $rawUserId = array('userid')) {
+ // Do this only for logged in member
+ assert(isMember());
+
+ // Call inner (general) function
+ doGenericListBuilder('member', $listType, $tableName, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $rawUserId);
+}
+
+// Checks whether given address is IPv4
+function isIp4AddressValid ($address) {
+ // Is there cache?
+ if (!isset($GLOBALS[__FUNCTION__][$address])) {
+ // Determine it ...
+ $GLOBALS[__FUNCTION__][$address] = preg_match('/((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9]))/', $address);
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__][$address];
+}
+
+// ----------------------------------------------------------------------------
+// "Translatation" functions for points_data table
+// ----------------------------------------------------------------------------
+
// Translates generically some data into a target string
function translateGeneric ($messagePrefix, $data) {
// Is the method null or empty?
return $return;
}
-// Translates task type to a human-readable version
-function translateTaskType ($taskType) {
- // Return it
- return translateGeneric('ADMIN_TASK_TYPE', $taskType);
-}
-
-// ----------------------------------------------------------------------------
-// "Translatation" functions for points_data table
-// ----------------------------------------------------------------------------
-
// Translates points subject to human-readable
function translatePointsSubject ($subject) {
// Remove any :x
return translateGeneric('POINTS_NOTIFY_RECIPIENT', $notifyRecipient);
}
+// Translates task type to a human-readable version
+function translateTaskType ($taskType) {
+ // Return it
+ return translateGeneric('ADMIN_TASK_TYPE', $taskType);
+}
+
//-----------------------------------------------------------------------------
// Automatically re-created functions, all taken from user comments on www.php.net
//-----------------------------------------------------------------------------