X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Ffunctions.php;h=67a149808f6a231ce91a6d12910edd2bc2bf5900;hp=66324337f68d134e09d79940aba79f6620e04568;hb=4bbd0f6ac8e11a702e000ffdfbd868a4e8a06ba3;hpb=0b0f1ec06f8dda4617f231a208ee30204e041e07 diff --git a/inc/functions.php b/inc/functions.php index 66324337f6..67a149808f 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -38,7 +38,7 @@ if (!defined('__SECURITY')) { } // Check if our config file is writeable or not -function is_INCWritable($inc) { +function IS_INC_WRITEABLE($inc) { // Generate FQFN $fqfn = sprintf("%sinc/%s.php", PATH, $inc); @@ -233,8 +233,16 @@ function LOAD_TEMPLATE($template, $return=false, $content=array()) { $template = strtolower($template); // Count the template load - if (!isset($_CONFIG['num_templates'])) $_CONFIG['num_templates'] = 0; - $_CONFIG['num_templates']++; + if (getConfig('num_templates') == null) { + $_CONFIG['num_templates'] = 1; + } else { + $_CONFIG['num_templates']++; + } + + // Prepare IP number and User Agent + $REMOTE_ADDR = GET_REMOTE_ADDR(); + if (!defined('REMOTE_ADDR')) define('REMOTE_ADDR', $REMOTE_ADDR); + $HTTP_USER_AGENT = GET_USER_AGENT(); // Init some data $ret = ""; @@ -243,13 +251,13 @@ function LOAD_TEMPLATE($template, $return=false, $content=array()) { // @DEPRECATED Try to rewrite the if() condition 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", + $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__); // Is content an array? if (is_array($content)) { // Merge data - $content = array_merge($content, SQL_FETCHARRAY($result)); + $content = merge_array($content, SQL_FETCHARRAY($result)); // Translate gender $content['gender'] = TRANSLATE_GENDER($content['gender']); @@ -334,7 +342,7 @@ function LOAD_TEMPLATE($template, $return=false, $content=array()) { $tmpl_file = implode("", file($file)); // Replace ' to our own chars to preventing them being quoted - while (strpos($tmpl_file, "\'") !== false) { $tmpl_file = str_replace("\'", '{QUOT}', $tmpl_file); } + while (strpos($tmpl_file, "'") !== false) { $tmpl_file = str_replace("'", '{QUOT}', $tmpl_file); } // Do we have to compile the code? $ret = ""; @@ -397,7 +405,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)), __FILE__, __LINE__); //* DEBUG: */ print __FUNCTION__."(".__LINE__."):numRows=".SQL_NUMROWS($result_email)."
\n"; // Does the user exist? @@ -450,15 +458,12 @@ function SEND_EMAIL($TO, $SUBJECT, $MSG, $HTML = "N", $FROM = "") { if (empty($HTML)) $HTML = "N"; if (isBooleanConstantAndTrue('DEBUG_MODE')) { // In debug mode we want to display the mail instead of sending it away so we can debug this part - echo "
+		print("
 ".htmlentities(trim($FROM))."
 To      : ".$TO."
 Subject : ".$SUBJECT."
 Message : ".$MSG."
-
\n"; - - // Log the mail away - if (defined('DEBUG_MAIL')) DEBUG_LOG(__FUNCTION__, __LINE__, "to={$TO},subject={$SUBJECT},msg={$MSG}"); +
\n"); } elseif (($HTML == "Y") && (EXT_IS_ACTIVE("html_mail"))) { // Send mail as HTML away SEND_HTML_EMAIL($TO, $SUBJECT, $MSG, $FROM); @@ -527,7 +532,7 @@ function SEND_RAW_EMAIL ($to, $subject, $msg, $from) { // Generate a password in a specified length or use default password length function GEN_PASS($LEN = 0) { global $_CONFIG; - if ($LEN == 0) $LEN = $_CONFIG['pass_len']; + if ($LEN == 0) $LEN = getConfig('pass_len'); // Initialize array with all allowed chars $ABC = explode(",", "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,0,1,2,3,4,5,6,7,8,9,-,+,_,/"); @@ -594,10 +599,10 @@ function TRANSLATE_COMMA ($dotted, $cut=true, $max=0) { global $_CONFIG; // Default is 3 you can change this in admin area "Misc -> Misc Options" - if (empty($_CONFIG['max_comma'])) $_CONFIG['max_comma'] = "3"; + if (getConfig('max_comma') == null) $_CONFIG['max_comma'] = "3"; // Use from config is default - $maxComma = $_CONFIG['max_comma']; + $maxComma = getConfig('max_comma'); // Use from parameter? if ($max > 0) $maxComma = $max; @@ -774,7 +779,7 @@ function LOAD_EMAIL_TEMPLATE($template, $content=array(), $UID="0") { // Is the admin logged in? if (IS_ADMIN()) { // Get admin id - $aid = GET_ADMIN_ID(get_session('admin_login')); + $aid = GET_CURRENT_ADMIN_ID(); // Load Admin data $ADMIN = GET_ADMIN_EMAIL($aid); @@ -784,15 +789,15 @@ function LOAD_EMAIL_TEMPLATE($template, $content=array(), $UID="0") { $email = WEBMASTER; // Expiration in a nice output format - if ($_CONFIG['auto_purge'] == 0) { + if (getConfig('auto_purge') == 0) { // Will never expire! $EXPIRATION = MAIL_WILL_NEVER_EXPIRE; } elseif (function_exists('CREATE_FANCY_TIME')) { // Create nice date string - $EXPIRATION = CREATE_FANCY_TIME($_CONFIG['auto_purge']); + $EXPIRATION = CREATE_FANCY_TIME(getConfig('auto_purge')); } else { // Display days only - $EXPIRATION = round($_CONFIG['auto_purge']/60/60/24)." "._DAYS; + $EXPIRATION = round(getConfig('auto_purge')/60/60/24)." "._DAYS; } // Is content an array? @@ -802,28 +807,25 @@ function LOAD_EMAIL_TEMPLATE($template, $content=array(), $UID="0") { } // END - if // Load user's data - //* DEBUG: */ print __FUNCTION__."(".__LINE__."):UID={$UID},template={$template}
\n"; - if ($UID > 0) { + //* DEBUG: */ print __FUNCTION__."(".__LINE__."):UID={$UID},template={$template},content[]=".gettype($content)."
\n"; + if (($UID > 0) && (is_array($content))) { + // If nickname extension is installed, fetch nickname as well if (EXT_IS_ACTIVE("nickname")) { //* 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", + $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__); } 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", + $result = SQL_QUERY_ESC("SELECT surname, family, gender, email FROM `"._MYSQL_PREFIX."_user_data` WHERE userid=%s LIMIT 1", array(bigintval($UID)), __FILE__, __LINE__); } - // Is content an array? - //* DEBUG: */ print __FUNCTION__."(".__LINE__."):content[]=".gettype($content)."
\n"; - if (is_array($content)) { - // Fetch and migrate data - //* DEBUG: */ print __FUNCTION__."(".__LINE__."):content()=".count($content)." - PRE
\n"; - $content = array_merge($content, SQL_FETCHARRAY($result)); - //* DEBUG: */ print __FUNCTION__."(".__LINE__."):content()=".count($content)." - AFTER
\n"; - } // END - if + // Fetch and merge data + //* DEBUG: */ print __FUNCTION__."(".__LINE__."):content()=".count($content)." - PRE
\n"; + $content = merge_array($content, SQL_FETCHARRAY($result)); + //* DEBUG: */ print __FUNCTION__."(".__LINE__."):content()=".count($content)." - AFTER
\n"; // Free result SQL_FREERESULT($result); @@ -833,7 +835,7 @@ function LOAD_EMAIL_TEMPLATE($template, $content=array(), $UID="0") { if (isset($content['gender'])) $content['gender'] = TRANSLATE_GENDER($content['gender']); // Overwrite email from data if present - if (isset($content['email'])) $email = $content['email']; + if (isset($content['email'])) $email = $content['email']; // Store email for some functions in global data array $DATA['email'] = $email; @@ -998,7 +1000,7 @@ function COMPILE_CODE($code, $simple = false, $constants = true, $full = true) { } // END - foreach // But shall I keep simple quotes for later use? - if ($simple) $code = str_replace("\'", '{QUOT}', $code); + if ($simple) $code = str_replace("'", '{QUOT}', $code); // Find $content[bla][blub] entries @preg_match_all('/\$(content|DATA)((\[([a-zA-Z0-9-_]+)\])*)/', $code, $matches); @@ -1139,8 +1141,20 @@ function ADD_SELECTION($type, $DEFAULT, $prefix="", $id="0") { // Get current year $YEAR = date('Y', time()); + // Use configured min age or fixed? + if (GET_EXT_VERSION("other") >= "0.2.1") { + // Configured + $startYear = $YEAR - getConfig('min_age'); + } else { + // Fixed 16 years + $startYear = $YEAR - 16; + } + + // Calculate earliest year (100 years old people can still enter Internet???) + $minYear = $YEAR - 100; + // Check if the default value is larger than minimum and bigger than actual year - if (($DEFAULT > 1930) && ($DEFAULT >= $YEAR)) { + if (($DEFAULT > $minYear) && ($DEFAULT >= $YEAR)) { for ($idx = $YEAR; $idx < ($YEAR + 11); $idx++) { $OUT .= "\n"; } } else { // Get current year and subtract the configured minimum age - $OUT .= "\n"; - $YEAR = date('Y', time()) - $_CONFIG['min_age']; - for ($idx = 1930; $idx <= $YEAR; $idx++) - { + $OUT .= "\n"; + // Calculate earliest year depending on extension version + if (GET_EXT_VERSION("other") >= "0.2.1") { + // Use configured minimum age + $YEAR = date('Y', time()) - getConfig('min_age'); + } else { + // Use fixed 16 years age + $YEAR = date('Y', time()) - 16; + } + + // Construct year selection list + for ($idx = $minYear; $idx <= $YEAR; $idx++) { $OUT .= "