X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=inc%2Ffunctions.php;h=28748b0e569b1c1118ecf8c35d5d86e92110b472;hb=2eef921aeac777e1306bea94f498f1618f02832b;hp=e779bae69271a9e53f4a732f5eb7e9f254b7adbb;hpb=9b87babf90b27658be4a1cef2c0465e2ce9ed681;p=mailer.git diff --git a/inc/functions.php b/inc/functions.php index e779bae692..28748b0e56 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -10,7 +10,12 @@ * -------------------------------------------------------------------- * * Kurzbeschreibung : Viele Nicht-MySQL-Funktionen (auch Dateizugriff) * * -------------------------------------------------------------------- * - * * + * $Revision:: $ * + * $Date:: $ * + * $Tag:: 0.2.1-FINAL $ * + * $Author:: $ * + * Needs to be in all Files and every File needs "svn propset * + * svn:keywords Date Revision" (autoprobset!) at least!!!!!! * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2008 by Roland Haeder * * For more information visit: http://www.mxchange.org * @@ -30,7 +35,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * * MA 02110-1301 USA * ************************************************************************/ - // Some security stuff... if (!defined('__SECURITY')) { $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4)."/security.php"; @@ -38,25 +42,17 @@ if (!defined('__SECURITY')) { } // Check if our config file is writeable or not -function IS_INC_WRITEABLE($inc) { +function IS_INC_WRITEABLE ($inc) { // Generate FQFN - $fqfn = sprintf("%sinc/%s.php", constant('PATH'), $inc); + $FQFN = sprintf("%sinc/%s.php", constant('PATH'), $inc); // Abort by simple test - if ((FILE_READABLE($fqfn)) && (!is_writeable($fqfn))) { + if ((FILE_READABLE($FQFN)) && (!is_writeable($FQFN))) { return false; } // END - if - // Test if we can append data - $fp = fopen($fqfn, 'a'); - if ($inc == "dummy") { - // Remove dummy file - fclose($fp); - return unlink($fqfn); - } else { - // Close all other files - return fclose($fp); - } + // Test write-access on directory + return is_writeable(dirname($FQFN)); } // Output HTML code directly or "render" it. You addionally switch the new-line character off @@ -101,7 +97,7 @@ function OUTPUT_HTML ($HTML, $newLine = true) { mxchange_die("{--FATAL_ERROR--}: {--LANG_NO_RENDER_DIRECT--}"); break; } - } elseif ((constant('_OB_CACHING') == "on") && ($GLOBALS['footer_sent'] == 1)) { + } elseif ((constant('_OB_CACHING') == "on") && (isset($GLOBALS['footer_sent'])) && ($GLOBALS['footer_sent'] == 1)) { // Headers already sent? if (headers_sent()) { // Log this error @@ -195,6 +191,7 @@ function getFatalArray () { // Add a fatal error message to the queue array function addFatalMessage ($F, $L, $message, $extra="") { + debug_report_bug($message); if (is_array($extra)) { // Multiple extras for a message with masks $message = call_user_func_array('sprintf', $extra); @@ -249,7 +246,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']), __FUNCTION__, __LINE__); + array(getUserId()), __FUNCTION__, __LINE__); // Is content an array? if (is_array($content)) { @@ -375,14 +372,14 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) { // Do we have some content to output or return? if (!empty($ret)) { // Not empty so let's put it out! ;) - if ($return) { + if ($return === true) { // Return the HTML code return $ret; } else { // Output direct OUTPUT_HTML($ret); } - } elseif (isBooleanConstantAndTrue('DEBUG_MODE')) { + } elseif (isDebugModeEnabled()) { // Warning, empty output! return "E:".$template."
\n"; } @@ -435,7 +432,7 @@ function SEND_EMAIL($TO, $SUBJECT, $MSG, $HTML = "N", $FROM = "") { // Append header $FROM .= LOAD_EMAIL_TEMPLATE("header"); } - } elseif (isBooleanConstantAndTrue('DEBUG_MODE')) { + } elseif (isDebugModeEnabled()) { if (empty($FROM)) { // Load email header template $FROM = LOAD_EMAIL_TEMPLATE("header"); @@ -455,7 +452,7 @@ function SEND_EMAIL($TO, $SUBJECT, $MSG, $HTML = "N", $FROM = "") { // Fix HTML parameter (default is no!) if (empty($HTML)) $HTML = "N"; - if (isBooleanConstantAndTrue('DEBUG_MODE')) { + if (isDebugModeEnabled()) { // In debug mode we want to display the mail instead of sending it away so we can debug this part print("
 ".htmlentities(trim($FROM))."
@@ -476,9 +473,10 @@ Message : ".$MSG."
 }
 
 // Check if legacy or PHPMailer command
+// @TODO Rewrite this to an extension 'smtp'
 // @private
 function CHECK_PHPMAILER_USAGE() {
-	return ((defined('SMTP_HOSTNAME')) && (defined('SMTP_USER')) && (defined('SMTP_PASSWORD')) && (SMTP_HOSTNAME != "") && (SMTP_USER != ""));
+	return ((defined('SMTP_HOSTNAME')) && (defined('SMTP_USER')) && (defined('SMTP_PASSWORD')) && (constant('SMTP_HOSTNAME') != "") && (constant('SMTP_USER') != ""));
 }
 
 /*
@@ -539,7 +537,7 @@ function GEN_PASS ($LEN = 0) {
 	// Start creating password
 	$PASS = "";
 	for ($i = 0; $i < $LEN; $i++) {
-		$PASS .= $ABC[mt_rand(0, sizeof($ABC) -1)];
+		$PASS .= $ABC[mt_rand(0, count($ABC) -1)];
 	} // END - for
 
 	// When the size is below 40 we can also add additional security by scrambling it
@@ -664,8 +662,7 @@ function TRANSLATE_GENDER ($gender) {
 //
 function FRAMETESTER ($URL) {
 	// Prepare frametester URL
-	$frametesterUrl = sprintf("%s/modules.php?module=frametester&url=%s",
-		URL,
+	$frametesterUrl = sprintf("{!URL!}/modules.php?module=frametester&url=%s",
 		encodeString(compileUriCode($URL))
 	);
 	return $frametesterUrl;
@@ -675,8 +672,8 @@ function FRAMETESTER ($URL) {
 function SELECTION_COUNT ($array) {
 	$ret = 0;
 	if (is_array($array)) {
-		foreach ($array as $key => $sel) {
-			if (!empty($sel)) $ret++;
+		foreach ($array as $key => $selected) {
+			if (!empty($selected)) $ret++;
 		}
 	}
 	return $ret;
@@ -702,7 +699,7 @@ function TRANSLATE_STATUS ($status) {
 
 	default:
 		DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Unknown status %s detected.", $status));
-		$ret = sprintf(getMessage('UNKNOWN_STATUS"'), $status);
+		$ret = sprintf(getMessage('UNKNOWN_STATUS'), $status);
 		break;
 	}
 
@@ -881,7 +878,7 @@ function LOAD_EMAIL_TEMPLATE($template, $content=array(), $UID="0") {
 

"; // Debug mode not active? Then remove the HTML tags - if (!isBooleanConstantAndTrue('DEBUG_MODE')) $newContent = strip_tags($newContent); + if (!isDebugModeEnabled()) $newContent = strip_tags($newContent); } else { // No template name supplied! $newContent = getMessage('NO_TEMPLATE_SUPPLIED'); @@ -953,7 +950,7 @@ function LOAD_URL ($URL, $addUrlData=true) { LOAD_TEMPLATE("redirect_url", false, str_replace("&", "&", $URL)); LOAD_INC("inc/footer.php"); } - exit(); + shutdown(); } // Wrapper for LOAD_URL but URL comes from a configuration entry @@ -1107,7 +1104,6 @@ function array_pk_sort (&$array, $a_sort, $primary_key = 0, $order = -1, $nums = // function ADD_SELECTION ($type, $DEFAULT, $prefix="", $id="0") { - global $MONTH_DESCR; $OUT = ""; if ($type == "yn") { @@ -1132,7 +1128,7 @@ function ADD_SELECTION ($type, $DEFAULT, $prefix="", $id="0") { break; case "month": // Month - foreach ($MONTH_DESCR as $month => $descr) { + foreach ($GLOBALS['month_descr'] as $month => $descr) { $OUT .= "