} // END - if
// Test if we can append data
- $fp = @fopen($fqfn, 'a');
+ $fp = fopen($fqfn, 'a');
if ($inc == "dummy") {
// Remove dummy file
fclose($fp);
}
// Add a fatal error message to the queue array
-function addFatalMessage ($message, $extra="") {
+function addFatalMessage ($F, $L, $message, $extra="") {
if (is_array($extra)) {
// Multiple extras for a message with masks
$message = call_user_func_array('sprintf', $extra);
$GLOBALS['fatal_messages'][] = $message;
// Log fatal messages away
- DEBUG_LOG(__FUNCTION__, __LINE__, " message={$message}");
+ DEBUG_LOG($F, $L, " message={$message}");
}
// Getter for total fatal message count
if ($template == "member_support_form") {
// Support request of a member
$result = SQL_QUERY_ESC("SELECT userid, gender, surname, family, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array($GLOBALS['userid']), __FILE__, __LINE__);
+ array($GLOBALS['userid']), __FUNCTION__, __LINE__);
// Is content an array?
if (is_array($content)) {
// Add surrounding HTML comments to help finding bugs faster
$ret = "<!-- Template ".$template." - Start -->\n".$ret."<!-- Template ".$template." - End -->\n";
- } elseif ((IS_ADMIN()) || ((isInstalling()) && (!isBooleanConstantAndTrue('mxchange_installed')))) {
+ } elseif ((IS_ADMIN()) || ((isInstalling()) && (!isInstalled()))) {
// Only admins shall see this warning or when installation mode is active
$ret = "<br /><span class=\"guest_failed\">".TEMPLATE_404."</span><br />
(".basename($FQFN).")<br />
return;
} else {
// Load email address
- $result_email = SQL_QUERY_ESC("SELECT email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1", array(bigintval($TO)), __FILE__, __LINE__);
+ $result_email = SQL_QUERY_ESC("SELECT email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1", array(bigintval($TO)), __FUNCTION__, __LINE__);
//* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):numRows=".SQL_NUMROWS($result_email)."<br />\n";
// Does the user exist?
//* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):NICKNAME!<br />\n";
// Load nickname
$result = SQL_QUERY_ESC("SELECT surname, family, gender, email, nickname FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array(bigintval($UID)), __FILE__, __LINE__);
+ array(bigintval($UID)), __FUNCTION__, __LINE__);
} else {
//* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):NO-NICK!<br />\n";
/// Load normal data
$result = SQL_QUERY_ESC("SELECT surname, family, gender, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array(bigintval($UID)), __FILE__, __LINE__);
+ array(bigintval($UID)), __FUNCTION__, __LINE__);
}
// Fetch and merge data
// Get output buffer
//* DEBUG: */ debug_report_bug(sprintf("%s[%s:] URL=%s", __FUNCTION__, __LINE__, $URL));
+ //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, $URL);
$OUTPUT = ob_get_contents();
// Clear it only if there is content
}
//
-function TRANSLATE_YESNO($yn) {
+function TRANSLATE_YESNO ($yn) {
// Default
- $yn = "??? (".$yn.")";
+ $translated = "??? (".$yn.")";
switch ($yn) {
- case "Y": $yn = getMessage('YES'); break;
- case "N": $yn = getMessage('NO'); break;
+ case "Y": $translated = getMessage('YES'); break;
+ case "N": $translated = getMessage('NO'); break;
default:
// Log unknown value
DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Unknown value %s. Expected Y/N!", $yn));
}
// Return it
- return $yn;
+ return $translated;
}
//
// Check which admin shall receive this mail
$result = SQL_QUERY_ESC("SELECT DISTINCT admin_id FROM `{!_MYSQL_PREFIX!}_admins_mails` WHERE mail_template='%s' ORDER BY admin_id",
- array($template), __FILE__, __LINE__);
+ array($template), __FUNCTION__, __LINE__);
if (SQL_NUMROWS($result) == 0) {
// Create new entry (to all admins)
SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_admins_mails` (admin_id, mail_template) VALUES (0, '%s')",
- array($template), __FILE__, __LINE__);
+ array($template), __FUNCTION__, __LINE__);
} else {
// Load admin IDs...
$aids = array();
}
} elseif ($aid == "0") {
// Select all email adresses
- $result = SQL_QUERY("SELECT email FROM `{!_MYSQL_PREFIX!}_admins` ORDER BY `id`", __FILE__, __LINE__);
+ $result = SQL_QUERY("SELECT email FROM `{!_MYSQL_PREFIX!}_admins` ORDER BY `id`", __FUNCTION__, __LINE__);
} else {
// If Admin-ID is not "to-all" select
- $result = SQL_QUERY_ESC("SELECT email FROM `{!_MYSQL_PREFIX!}_admins` WHERE id IN (%s) ORDER BY `id`", array($aid), __FILE__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT email FROM `{!_MYSQL_PREFIX!}_admins` WHERE id IN (%s) ORDER BY `id`", array($aid), __FUNCTION__, __LINE__);
}
}
return isUrlValid($URL);
}
-//
+// Generate a list of administrative links to a given userid
function MEMBER_ACTION_LINKS ($uid, $status = "") {
// Define all main targets
$TARGETS = array("del_user", "edit_user", "lock_user", "add_points", "sub_points");
return $OUT;
}
-// Function for backward-compatiblity
-// @TODO Can this function be deprecated?
-function ADD_CATEGORY_TABLE ($MODE, $return=false) {
- // Load it from the register extension
- return REGISTER_ADD_CATEGORY_TABLE ($MODE, $return);
-}
-
// Generate an email link
function CREATE_EMAIL_LINK ($email, $table = "admins") {
// Default email link (INSECURE! Spammer can read this by harvester programs)
// Return email link
return $EMAIL;
}
+
// Generate a hash for extra-security for all passwords
function generateHash ($plainText, $salt = "") {
global $_SERVER;
// Return hash
return $salt.sha1($salt.$plainText);
}
-//
+
+// Scramble a string
function scrambleString($str) {
// Init
$scrambled = "";
//* DEBUG: */ echo "***Scrambled=".$scrambled."***<br />";
return $scrambled;
}
-//
+
+// De-scramble a string scrambled by scrambleString()
function descrambleString($str) {
// Scramble only 40 chars long strings
if (strlen($str) != 40) return $str;
//* DEBUG: */ echo "+++Original=".$orig."+++<br />";
return $orig;
}
-//
+
+// Generated a "string" for scrambling
function genScrambleString ($len) {
// Prepare array for the numbers
$scrambleNumbers = array();
// Fix it to default
$ret = "default";
} // END - if
- } elseif ((!isBooleanConstantAndTrue('mxchange_installed')) && ((isInstalling()) || ($GLOBALS['output_mode'] == true)) && ((REQUEST_ISSET_GET(('theme'))) || (REQUEST_ISSET_POST(('theme'))))) {
+ } elseif ((!isInstalled()) && ((isInstalling()) || ($GLOBALS['output_mode'] == true)) && ((REQUEST_ISSET_GET(('theme'))) || (REQUEST_ISSET_POST(('theme'))))) {
// Prepare FQFN for checking
$theme = sprintf("%stheme/%s/theme.php", constant('PATH'), REQUEST_GET(('theme')));
} elseif (GET_EXT_VERSION("cache") != "0.1.8") {
// Check if current theme is already imported or not
$result = SQL_QUERY_ESC("SELECT id FROM `{!_MYSQL_PREFIX!}_themes` WHERE theme_path='%s' LIMIT 1",
- array($name), __FILE__, __LINE__);
+ array($name), __FUNCTION__, __LINE__);
// Entry found?
if (SQL_NUMROWS($result) == 1) {
// Loads an include file and logs any missing files for debug purposes
function LOAD_INC ($INC) {
- // Get constant path
- $PATH = constant('PATH');
-
- // Use the include file name directly
- // @TODO Try to find all locations where an FQFN is given to these two
- // @TODO functions and avoid it.
- $FQFN = $INC;
-
- // Check if PATH is in $INC
- if (substr($INC, 0, $PATH) != $PATH) {
- // Add it. This is why we need a trailing slash in config.php
- $FQFN = $PATH . $INC;
- } // END - if
+ // Add the path. This is why we need a trailing slash in config.php
+ $FQFN = constant('PATH') . $INC;
// Is the include file there?
if (!FILE_READABLE($FQFN)) {
// Loads an include file once
function LOAD_INC_ONCE ($INC) {
// Is it not loaded?
- if (!isset($GLOBALS['cache_array']['load_once'][$INC])) {
+ if (!isset($GLOBALS['load_once'][$INC])) {
// Then try to load it
LOAD_INC($INC);
// And mark it as loaded
- $GLOBALS['cache_array']['load_once'][$INC] = "loaded";
+ $GLOBALS['load_once'][$INC] = "loaded";
} // END - if
}
// Get and prepare backtrace for output
$backtraceArray = debug_backtrace();
foreach ($backtraceArray as $key => $trace) {
- if (!isset($trace['file'])) $trace['file'] = __FILE__;
+ if (!isset($trace['file'])) $trace['file'] = __FUNCTION__;
if (!isset($trace['line'])) $trace['line'] = __LINE__;
if (!isset($trace['args'])) $trace['args'] = array();
$backtrace .= "<li class=\"debug_list\"><span class=\"backtrace_file\">".basename($trace['file'])."</span>:".$trace['line'].", <span class=\"backtrace_function\">".$trace['function']."(".count($trace['args']).")</span></li>\n";
// Generate a "link" for the given admin id (aid)
function GENERATE_AID_LINK ($aid) {
// No assigned admin is default
- $admin = "<div class=\"admin_note\">{--ADMIN_NO_ADMIN_ASSIGNED--}</div>";
+ $admin = "<span class=\"admin_note\">{--ADMIN_NO_ADMIN_ASSIGNED--}</span>";
// Zero? = Not assigned
if ($aid == "0") {
$tmp = $FQFN.".tmp";
// Open the source file
- $fp = @fopen($FQFN, 'r') or OUTPUT_HTML("<strong>READ:</strong> ".$FQFN."<br />");
+ $fp = fopen($FQFN, 'r') or OUTPUT_HTML("<strong>READ:</strong> ".$FQFN."<br />");
// Is the resource valid?
if (is_resource($fp)) {
// Open temporary file
- $fp_tmp = @fopen($tmp, 'w') or OUTPUT_HTML("<strong>WRITE:</strong> ".$tmp."<br />");
+ $fp_tmp = fopen($tmp, 'w') or OUTPUT_HTML("<strong>WRITE:</strong> ".$tmp."<br />");
// Is the resource again valid?
if (is_resource($fp_tmp)) {
if (($done) && ($found)) {
// Copy back tmp file and delete tmp :-)
- @copy($tmp, $FQFN);
- @unlink($tmp);
+ copy($tmp, $FQFN);
+ return unlink($tmp);
} elseif (!$found) {
OUTPUT_HTML("<strong>CHANGE:</strong> 404!");
} else {
// File not found, not readable or writeable
OUTPUT_HTML("<strong>404:</strong> ".$FQFN."<br />");
}
+
+ // An error was detected!
+ return false;
}
// Send notification to admin
function SEND_ADMIN_NOTIFICATION($subject, $templateName, $content=array(), $uid="0") {
$INCs = array();
// Open directory
- $dirPointer = opendir($baseDir) or mxchange_die("Cannot read ".basename($baseDir)." path!");
+ $dirPointer = opendir(constant('PATH') . $baseDir) or mxchange_die("Cannot read ".basename($baseDir)." path!");
// Read all entries
while ($baseFile = readdir($dirPointer)) {
// Load file only if extension is active
- // Make full path
- $FQFN = $baseDir.$baseFile;
+ $INC = $baseDir.$baseFile;
+ $FQFN = constant('PATH') . $INC;
// Is this a valid reset file?
//* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):baseDir={$baseDir},prefix={$prefix},baseFile={$baseFile}<br />\n";
// Is the extension valid and active?
if (($extId > 0) && (EXT_IS_ACTIVE($extName))) {
// Then add this file
- $INCs[] = $FQFN;
+ $INCs[] = $INC;
} elseif ($extId == 0) {
// Add non-extension files as well
- $INCs[] = $FQFN;
+ $INCs[] = $INC;
}
} // END - if
} // END - while
} // END - if
// Get more daily reset scripts
- $INC_POOL = GET_DIR_AS_ARRAY(constant('PATH')."inc/reset/", "reset_");
+ $INC_POOL = GET_DIR_AS_ARRAY("inc/reset/", "reset_");
// Update database
if (!defined('DEBUG_RESET')) UPDATE_CONFIG("last_update", time());
// Has it changed?
if (getConfig('last_week') != $currWeek) {
// Include weekly reset scripts
- $INC_POOL = merge_array($INC_POOL, GET_DIR_AS_ARRAY(constant('PATH')."inc/weekly/", "weekly_"));
+ $INC_POOL = merge_array($INC_POOL, GET_DIR_AS_ARRAY("inc/weekly/", "weekly_"));
// Update config
if (!defined('DEBUG_WEEKLY')) UPDATE_CONFIG("last_week", $currWeek);
// Has it changed?
if (getConfig('last_month') != $currMonth) {
// Include monthly reset scripts
- $INC_POOL = merge_array($INC_POOL, GET_DIR_AS_ARRAY(constant('PATH')."inc/monthly/", "monthly_"));
+ $INC_POOL = merge_array($INC_POOL, GET_DIR_AS_ARRAY("inc/monthly/", "monthly_"));
// Update config
if (!defined('DEBUG_MONTHLY')) UPDATE_CONFIG("last_month", $currMonth);
return (isset($GLOBALS['mxchange_installing']));
}
+// Check wether this script is installed
+function isInstalled () {
+ return isBooleanConstantAndTrue('mxchange_installed');
+}
+
+// Check wether an admin is registered
+function isAdminRegistered () {
+ return isBooleanConstantAndTrue('admin_registered');
+}
+
//////////////////////////////////////////////////
// AUTOMATICALLY RE-GENERATED MISSING FUNCTIONS //
//////////////////////////////////////////////////