X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=0.2.1%2Finc%2Ffunctions.php;h=6bc73d52d580545f67a7a42af3ae2634fdbff03a;hp=7ae88126bafa4fa7e8b006aec8ab610150fc99e9;hb=985d79f06163e5957c3f40b5a71ce85be9048f8e;hpb=4d62ab22b0616cabb713929f8b661b5470b6018c diff --git a/0.2.1/inc/functions.php b/0.2.1/inc/functions.php index 7ae88126ba..6bc73d52d5 100644 --- a/0.2.1/inc/functions.php +++ b/0.2.1/inc/functions.php @@ -34,7 +34,7 @@ // Some security stuff... if (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) { - $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4)."/security.php"; + $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php"; require($INC); } @@ -61,6 +61,7 @@ function is_SQLWriteable($sql) $fp = @fopen(PATH.$sql.".sql", 'a'); return @fclose($fp); } + // Open a table (you may want to add some header stuff here) function OPEN_TABLE($PERCENT = "", $CLASS = "", $ALIGN="left", $VALIGN="", $td_only=false) { @@ -98,6 +99,7 @@ function CLOSE_TABLE($ADD="") if (!empty($ADD)) OUTPUT_HTML ($ADD); OUTPUT_HTML (""); } + // Output HTML code directly or "render" it. You addionally switch the new-line character off function OUTPUT_HTML ($HTML, $NEW_LINE = true) { // Some global variables @@ -179,6 +181,7 @@ function OUTPUT_HTML ($HTML, $NEW_LINE = true) { flush(); } } + // Add a fatal error message to the queue array function ADD_FATAL ($message, $extra="") { @@ -191,6 +194,7 @@ function ADD_FATAL ($message, $extra="") $FATAL[] = sprintf($message, $extra); } } + // Load a template file and return it's content (only it's name; do not use ' or ") function LOAD_TEMPLATE($template, $return=false, $content="") { @@ -347,7 +351,8 @@ function LOAD_TEMPLATE($template, $return=false, $content="") return "E:".$template."
\n"; } } -// + +// Send mail out to an email address function SEND_EMAIL($TO, $SUBJECT, $MSG, $HTML="N", $FROM="") { // Compile subject line (for POINTS constant etc.) @@ -417,9 +422,10 @@ function SEND_EMAIL($TO, $SUBJECT, $MSG, $HTML="N", $FROM="") function CHECK_PHPMAILER_USAGE() { return (((defined('SMTP_HOSTNAME')) && (defined('SMTP_USER')) && (defined('SMTP_PASSWORD'))) || ((SMTP_HOSTNAME != "") && (SMTP_USER != ""))); } - -// Send a raw email -// @private + +/* + * Send out a raw email with PHPMailer class or legacy mail() command + */ function SEND_RAW_EMAIL ($to, $subject, $msg, $from) { // Shall we use PHPMailer class or legacy mode? if (CHECK_PHPMAILER_USAGE()) { @@ -458,28 +464,31 @@ function SEND_RAW_EMAIL ($to, $subject, $msg, $from) { } } // -function GEN_PASS($LEN="x") -{ + +// Generate a password in a specified length or use default password length +function GEN_PASS($LEN = 0) { global $CONFIG; - if ($LEN == "x") $LEN = $CONFIG['pass_len']; + if ($LEN == 0) $LEN = $CONFIG['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,-,+,_,/"); + // Initialize randomizer mt_srand((double) microtime() * 1000000); // Start creating password $PASS = ""; - for ($i = 0; $i < $LEN; $i++) - { + for ($i = 0; $i < $LEN; $i++) { $PASS .= $ABC[mt_rand(0, sizeof($ABC) -1)]; } // When the size is below 40 we can also add additional security by scrambling it - if (strlen($PASS) <= 40) - { + if (strlen($PASS) <= 40) { // Also scramble the password $PASS = scrambleString($PASS); - } + } + + // Return the password return $PASS; } // @@ -964,27 +973,21 @@ function MAKE_TIME($H, $M, $S, $stamp) return mktime($H, $M, $S, $MONTH, $DAY, $YEAR); } // -function LOAD_URL($URL) -{ +function LOAD_URL($URL) { // Add some data to URL if cookies are not accepted if ((!defined('__COOKIES')) || (!__COOKIES)) $URL = ADD_URL_DATA($URL); // Probe for bot from search engine - if ((eregi("spider", getenv('HTTP_USER_AGENT'))) || (eregi("bot", getenv('HTTP_USER_AGENT'))) || (eregi("spider", getenv('HTTP_USER_AGENT')))) - { + if ((eregi("spider", getenv('HTTP_USER_AGENT'))) || (eregi("bot", getenv('HTTP_USER_AGENT'))) || (eregi("spider", getenv('HTTP_USER_AGENT')))) { // Search engine bot detected so let's rewrite many chars for the link $URL = htmlentities(strip_tags($URL), ENT_QUOTES); // Output new location link as anchor OUTPUT_HTML ("".$URL."\n"); - } - elseif (!headers_sent()) - { + } elseif (!headers_sent()) { // Load URL when headers are not sent @header ("Location: ".str_replace("&", "&", $URL)); - } - else - { + } else { // Output error message include(PATH."inc/header.php"); OUTPUT_HTML (LOAD_URL_ERROR_1.$URL.LOAD_URL_ERROR_2);