X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Ffunctions.php;h=01dd840977e15583dbfaf171e096e672cf0d025f;hb=6ffe044cf1f0832d338cee1b026a3161a1e4c449;hp=f353494c6dfd451aeb50a8a1e3dffcfbb00861bd;hpb=8b3b0fae36adfa1ef72f436d107d11404b326ec5;p=mailer.git
diff --git a/inc/functions.php b/inc/functions.php
index f353494c6d..01dd840977 100644
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -48,7 +48,7 @@ function IS_INC_WRITEABLE($inc) {
} // END - if
// Test if we can append data
- $fp = @fopen($fqfn, 'a');
+ $fp = fopen($fqfn, 'a');
if ($inc == "dummy") {
// Remove dummy file
fclose($fp);
@@ -194,7 +194,7 @@ function getFatalArray () {
}
// 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);
@@ -207,7 +207,7 @@ function addFatalMessage ($message, $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
@@ -249,7 +249,7 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
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)) {
@@ -356,7 +356,7 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
// Add surrounding HTML comments to help finding bugs faster
$ret = "\n".$ret."\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 = "
".TEMPLATE_404."
(".basename($FQFN).")
@@ -404,7 +404,7 @@ function SEND_EMAIL($TO, $SUBJECT, $MSG, $HTML = "N", $FROM = "") {
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__."(".__LINE__."):numRows=".SQL_NUMROWS($result_email)."
\n";
// Does the user exist?
@@ -804,12 +804,12 @@ function LOAD_EMAIL_TEMPLATE($template, $content=array(), $UID="0") {
//* DEBUG: */ print __FUNCTION__."(".__LINE__."):NICKNAME!
\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__."(".__LINE__."):NO-NICK!
\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
@@ -925,6 +925,7 @@ function LOAD_URL ($URL, $addUrlData=true) {
// 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
@@ -1220,12 +1221,12 @@ function ADD_SELECTION ($type, $DEFAULT, $prefix="", $id="0") {
}
//
-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));
@@ -1233,7 +1234,7 @@ function TRANSLATE_YESNO($yn) {
}
// Return it
- return $yn;
+ return $translated;
}
//
@@ -1600,11 +1601,11 @@ function SEND_ADMIN_EMAILS_PRO ($subj, $template, $content, $UID) {
// 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();
@@ -1634,10 +1635,10 @@ function SEND_ADMIN_EMAILS_PRO ($subj, $template, $content, $UID) {
}
} 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__);
}
}
@@ -1977,7 +1978,7 @@ function VALIDATE_URL ($URL, $compile=true) {
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");
@@ -2014,13 +2015,6 @@ function MEMBER_ACTION_LINKS ($uid, $status = "") {
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)
@@ -2044,6 +2038,7 @@ function CREATE_EMAIL_LINK ($email, $table = "admins") {
// Return email link
return $EMAIL;
}
+
// Generate a hash for extra-security for all passwords
function generateHash ($plainText, $salt = "") {
global $_SERVER;
@@ -2094,7 +2089,8 @@ function generateHash ($plainText, $salt = "") {
// Return hash
return $salt.sha1($salt.$plainText);
}
-//
+
+// Scramble a string
function scrambleString($str) {
// Init
$scrambled = "";
@@ -2125,7 +2121,8 @@ function scrambleString($str) {
//* DEBUG: */ echo "***Scrambled=".$scrambled."***
";
return $scrambled;
}
-//
+
+// De-scramble a string scrambled by scrambleString()
function descrambleString($str) {
// Scramble only 40 chars long strings
if (strlen($str) != 40) return $str;
@@ -2148,7 +2145,8 @@ function descrambleString($str) {
//* DEBUG: */ echo "+++Original=".$orig."+++
";
return $orig;
}
-//
+
+// Generated a "string" for scrambling
function genScrambleString ($len) {
// Prepare array for the numbers
$scrambleNumbers = array();
@@ -2377,7 +2375,7 @@ function GET_CURR_THEME() {
// 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')));
@@ -2428,7 +2426,7 @@ function THEME_GET_ID ($name) {
} 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) {
@@ -2574,19 +2572,8 @@ function getActualVersion ($type = 0) {
// 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)) {
@@ -2602,12 +2589,12 @@ function LOAD_INC ($INC) {
// 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
}
@@ -2619,7 +2606,7 @@ function debug_get_printable_backtrace () {
// 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 .= "