if (!isFileReadable($FQFN)) {
// This should not happen
reportBug(__FUNCTION__, __LINE__, 'File ' . basename($FQFN) . ' is not readable!');
- } elseif (!isset($GLOBALS['file_content'][$FQFN])) {
- // Load the file
- if (function_exists('file_get_contents')) {
- // Use new function
- $GLOBALS['file_content'][$FQFN] = file_get_contents($FQFN);
- } else {
- // Fall-back to implode-file chain
- $GLOBALS['file_content'][$FQFN] = implode('', file($FQFN));
- }
} // END - if
+ // Load the file
+ if (function_exists('file_get_contents')) {
+ // Use new function
+ $fileContent = file_get_contents($FQFN);
+ } else {
+ // Fall-back to implode-file chain
+ $fileContent = implode('', file($FQFN));
+ }
+
// Return the content
- return $GLOBALS['file_content'][$FQFN];
+ return $fileContent;
}
// Writes content to a file
// Is the file writeable?
if ((isFileReadable($FQFN)) && (!is_writeable($FQFN)) && (!changeMode($FQFN, 0644))) {
// Not writeable!
- logDebugMessage(__FUNCTION__, __LINE__, sprintf("File %s not writeable.", basename($FQFN)));
+ logDebugMessage(__FUNCTION__, __LINE__, sprintf("File %s not writeable or cannot change CHMOD to 0644.", basename($FQFN)));
// Failed! :(
return FALSE;
// By default all is failed...
$GLOBALS['file_readable'][$FQFN] = FALSE;
- unset($GLOBALS['file_content'][$FQFN]);
$return = FALSE;
// Is the function there?
}
} else {
// Write it with fopen
- $fp = fopen($FQFN, 'w') or reportBug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($FQFN) . '!');
+ $fp = fopen($FQFN, 'w')
+ or reportBug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($FQFN) . '!');
// Aquire a lock?
if ($aquireLock === TRUE) {
if ($return !== FALSE) {
// Mark it as readable
$GLOBALS['file_readable'][$FQFN] = TRUE;
-
- // Remember content in cache
- $GLOBALS['file_content'][$FQFN] = $content;
} // END - if
// Return status
if (isset($GLOBALS[__FUNCTION__])) {
// This function is called twice
reportBug(__FUNCTION__, __LINE__, 'Double call of ' . __FUNCTION__ . ' may cause more trouble.');
- } // END - if
-
- // Trigger an error on failure
- if ((ob_get_length() > 0) && (!ob_end_clean())) {
+ } elseif ((ob_get_length() > 0) && (!ob_end_clean())) {
// Failed!
reportBug(__FUNCTION__, __LINE__, 'Failed to clean output buffer.');
} // END - if
return $GLOBALS[__FUNCTION__];
}
+// Checks whether debugging of build mails is enabled
+function isDebugBuildMailsEnabled () {
+ // Is cache set?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // Simply check it
+ $GLOBALS[__FUNCTION__] = ((isConfigEntrySet('DEBUG_BUILD_MAILS')) && (getConfig('DEBUG_BUILD_MAILS') == 'Y'));
+ } // END - if
+
+ // Return it
+ return $GLOBALS[__FUNCTION__];
+}
+
// Checks whether the cache instance is valid
function isCacheInstanceValid () {
// Is there cache?
}
// Checks whether what is set and optionally aborts on miss
-function isWhatSet ($strict = false) {
+function isWhatSet ($strict = FALSE) {
// Check for it
$isset = (isset($GLOBALS['__what']) && (!empty($GLOBALS['__what'])));
}
// Checks whether action is set and optionally aborts on miss
-function isActionSet ($strict = false) {
+function isActionSet ($strict = FALSE) {
// Check for it
$isset = ((isset($GLOBALS['__action'])) && (!empty($GLOBALS['__action'])));
}
// Checks whether module is set and optionally aborts on miss
-function isModuleSet ($strict = false) {
+function isModuleSet ($strict = FALSE) {
// Check for it
$isset = ((isset($GLOBALS['__module'])) && (!empty($GLOBALS['__module'])));
}
// Checks whether output_mode is set and optionally aborts on miss
-function isOutputModeSet ($strict = false) {
+function isOutputModeSet ($strict = FALSE) {
// Check for it
$isset = (isset($GLOBALS['__output_mode']));
}
// Wrapper function for checking if extension is installed and newer or same version
-function isExtensionInstalledAndNewer ($ext_name, $version) {
+function isExtensionInstalledAndNewer ($ext_name, $ext_ver) {
// Is an cache entry found?
- if (!isset($GLOBALS[__FUNCTION__][$ext_name][$version])) {
+ if (!isset($GLOBALS[__FUNCTION__][$ext_name][$ext_ver])) {
// Determine it
- $GLOBALS[__FUNCTION__][$ext_name][$version] = ((isExtensionInstalled($ext_name)) && (getExtensionVersion($ext_name) >= $version));
+ $GLOBALS[__FUNCTION__][$ext_name][$ext_ver] = ((isExtensionInstalled($ext_name)) && (version_compare(getExtensionVersion($ext_name), $ext_ver, '>=') === TRUE));
} else {
// Cache hits should be incremented twice
incrementStatsEntry('cache_hits', 2);
}
// Return it
- //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '=>' . $version . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$version]));
- return $GLOBALS[__FUNCTION__][$ext_name][$version];
+ //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '=>' . $ext_ver . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$ext_ver]));
+ return $GLOBALS[__FUNCTION__][$ext_name][$ext_ver];
}
// Wrapper function for checking if extension is installed and older than given version
-function isExtensionInstalledAndOlder ($ext_name, $version) {
+function isExtensionInstalledAndOlder ($ext_name, $ext_ver) {
// Is an cache entry found?
- if (!isset($GLOBALS[__FUNCTION__][$ext_name][$version])) {
+ if (!isset($GLOBALS[__FUNCTION__][$ext_name][$ext_ver])) {
// Determine it
- $GLOBALS[__FUNCTION__][$ext_name][$version] = ((isExtensionInstalled($ext_name)) && (isExtensionOlder($ext_name, $version)));
+ $GLOBALS[__FUNCTION__][$ext_name][$ext_ver] = ((isExtensionInstalled($ext_name)) && (version_compare(getExtensionVersion($ext_name), $ext_ver, '<') === TRUE));
} else {
// Cache hits should be incremented twice
incrementStatsEntry('cache_hits', 2);
}
// Return it
- //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '<' . $version . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$version]));
- return $GLOBALS[__FUNCTION__][$ext_name][$version];
+ //* DEBUG: */ debugOutput(__FUNCTION__ . ':' . $ext_name . '<' . $ext_ver . ':' . intval($GLOBALS[__FUNCTION__][$ext_name][$ext_ver]));
+ return $GLOBALS[__FUNCTION__][$ext_name][$ext_ver];
}
// Set username
// Is there cache?
if (!isset($GLOBALS[__FUNCTION__][$userid])) {
// Check it out
- $GLOBALS[__FUNCTION__][$userid] = ((!is_null($userid)) && (!empty($userid)) && ($userid > 0));
+ $GLOBALS[__FUNCTION__][$userid] = ((!is_null($userid)) && (!empty($userid)) && ($userid != 'NULL') && ($userid > 0));
} // END - if
// Return cache
// Return cache
return $GLOBALS[__FUNCTION__];
}
-
-// "Getter" for auto_purge
-function getAutoPurge () {
- // Is there cache?
- if (!isset($GLOBALS[__FUNCTION__])) {
- // Determine it
- $GLOBALS[__FUNCTION__] = getConfig('auto_purge');
- } // END - if
-
- // Return cache
- return $GLOBALS[__FUNCTION__];
-}
-
-// "Getter" for bonus_userid
-function getBonusUserid () {
- // Is there cache?
- if (!isset($GLOBALS[__FUNCTION__])) {
- // Determine it
- $GLOBALS[__FUNCTION__] = getConfig('bonus_userid');
- } // END - if
-
- // Return cache
- return $GLOBALS[__FUNCTION__];
-}
-
-// "Getter" for ap_inactive_time
-function getApInactiveTime () {
- // Is there cache?
- if (!isset($GLOBALS[__FUNCTION__])) {
- // Determine it
- $GLOBALS[__FUNCTION__] = getConfig('ap_inactive_time');
- } // END - if
-
- // Return cache
- return $GLOBALS[__FUNCTION__];
-}
-
-// "Getter" for ap_dm_timeout
-function getApDmTimeout () {
- // Is there cache?
- if (!isset($GLOBALS[__FUNCTION__])) {
- // Determine it
- $GLOBALS[__FUNCTION__] = getConfig('ap_dm_timeout');
- } // END - if
-
- // Return cache
- return $GLOBALS[__FUNCTION__];
-}
-
-// "Getter" for ap_tasks_time
-function getApTasksTime () {
- // Is there cache?
- if (!isset($GLOBALS[__FUNCTION__])) {
- // Determine it
- $GLOBALS[__FUNCTION__] = getConfig('ap_tasks_time');
- } // END - if
-
- // Return cache
- return $GLOBALS[__FUNCTION__];
-}
-
-// "Getter" for ap_unconfirmed_time
-function getApUnconfirmedTime () {
- // Is there cache?
- if (!isset($GLOBALS[__FUNCTION__])) {
- // Determine it
- $GLOBALS[__FUNCTION__] = getConfig('ap_unconfirmed_time');
- } // END - if
-
- // Return cache
- return $GLOBALS[__FUNCTION__];
-}
-
// "Getter" for points
function getPoints () {
// Is there cache?
return $GLOBALS[__FUNCTION__];
}
+// Getter for 'ap_server_name_since'
+function getApServerNameSince () {
+ // Is the cache entry set?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // No, so determine it
+ $GLOBALS[__FUNCTION__] = getConfig('ap_server_name_since');
+ } // END - if
+
+ // Return cached entry
+ return $GLOBALS[__FUNCTION__];
+}
+
+// Getter for 'ap_server_name'
+function getApServerName () {
+ // Is the cache entry set?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // No, so determine it
+ $GLOBALS[__FUNCTION__] = getConfig('ap_server_name');
+ } // END - if
+
+ // Return cached entry
+ return $GLOBALS[__FUNCTION__];
+}
+
+// Checks whether 'ap_server_name' is 'Y'
+function isApServerNameEnabled () {
+ // Is the cache entry set?
+ if (!isset($GLOBALS[__FUNCTION__])) {
+ // No, so determine it
+ $GLOBALS[__FUNCTION__] = (getApServerName() == 'Y');
+ } // END - if
+
+ // Return cached entry
+ return $GLOBALS[__FUNCTION__];
+}
+
// Getter for 'admin_menu_javascript'
function getAdminMenuJavascript () {
// Is the cache entry set?
// This function does always add a new-line character to every line.
function appendLineToFile ($file, $line) {
$fp = fopen($file, 'a') or reportBug(__FUNCTION__, __LINE__, 'Cannot write to file ' . basename($file) . '!');
- fwrite($fp, $line . chr(10));
+ fwrite($fp, $line . PHP_EOL);
fclose($fp);
}