X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Ffunctions.php;h=dcdfdc6ea03845940ec3fa110573bb0b6d0564b3;hp=1465d609d15928ee16cb75884b8cba289ad061ec;hb=4001187f22197f55e5a1f211fc8defcc180f7c32;hpb=a47a9c49a7813304ac78deb3741bdd85e6d50912;ds=sidebyside diff --git a/inc/functions.php b/inc/functions.php index 1465d609d1..dcdfdc6ea0 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -38,25 +38,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 + return is_writeable($FQFN); } // Output HTML code directly or "render" it. You addionally switch the new-line character off @@ -375,7 +367,7 @@ 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 { @@ -540,7 +532,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 @@ -954,7 +946,7 @@ function LOAD_URL ($URL, $addUrlData=true) { LOAD_TEMPLATE("redirect_url", false, str_replace("&", "&", $URL)); LOAD_INC("inc/footer.php"); } - exit(); + exit; } // Wrapper for LOAD_URL but URL comes from a configuration entry @@ -1595,11 +1587,6 @@ function SEND_ADMIN_EMAILS_PRO ($subj, $template, $content, $UID) { // Load email template $msg = LOAD_EMAIL_TEMPLATE($template, $content, $UID); - if (EXT_VERSION_IS_OLDER("admins", "0.4.0")) { - // Older version detected! - return SEND_ADMIN_EMAILS($subj, $msg); - } // END - if - // 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), __FUNCTION__, __LINE__); @@ -1609,9 +1596,10 @@ function SEND_ADMIN_EMAILS_PRO ($subj, $template, $content, $UID) { array($template), __FUNCTION__, __LINE__); } else { // Load admin IDs... - $aids = array(); - while (list($aid) = SQL_FETCHROW($result)) { - $aids[] = $aid; + // @TODO This can be, somehow, rewritten + $adminIds = array(); + while ($content = SQL_FETCHARRAY($result)) { + $adminIds[] = $content['admin_id']; } // END - while // Free memory @@ -1621,7 +1609,7 @@ function SEND_ADMIN_EMAILS_PRO ($subj, $template, $content, $UID) { $result = false; // "implode" IDs and query string - $aid = implode(",", $aids); + $aid = implode(",", $adminIds); if ($aid == "-1") { if (EXT_IS_ACTIVE("events")) { // Add line to user events @@ -1636,16 +1624,18 @@ 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`", __FUNCTION__, __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), __FUNCTION__, __LINE__); + $result = SQL_QUERY_ESC("SELECT email FROM `{!_MYSQL_PREFIX!}_admins` WHERE id IN (%s) ORDER BY `id`", + array($aid), __FUNCTION__, __LINE__); } } // Load email addresses and send away - while (list($email) = SQL_FETCHROW($result)) { - SEND_EMAIL($email, $subj, $msg); + while ($content = SQL_FETCHARRAY($result)) { + SEND_EMAIL($content['email'], $subj, $msg); } // END - while // Free memory @@ -1727,7 +1717,7 @@ function ADD_EMAIL_NAV ($PAGES, $offset, $show_form, $colspan, $return=false) { // Load navigation template $OUT = LOAD_TEMPLATE("admin_email_nav_row", true); - if ($return) { + if ($return === true) { // Return generated HTML-Code return $OUT; } else { @@ -1898,7 +1888,7 @@ function SEND_RAW_REQUEST ($host, $request) { fputs($fp, $request); // Read response - while(!feof($fp)) { + while (!feof($fp)) { $response[] = trim(fgets($fp, 1024)); } // END - while @@ -1941,7 +1931,7 @@ function SEND_RAW_REQUEST ($host, $request) { } // Taken from www.php.net eregi() user comments -function VALIDATE_EMAIL($email) { +function VALIDATE_EMAIL ($email) { // Compile email $email = COMPILE_CODE($email); @@ -2926,12 +2916,12 @@ function changeDataInFile ($FQFN, $comment, $prefix, $suffix, $DATA, $seek=0) { return false; } // Send notification to admin -function SEND_ADMIN_NOTIFICATION($subject, $templateName, $content=array(), $uid="0") { +function SEND_ADMIN_NOTIFICATION ($subject, $templateName, $content=array(), $uid="0") { if (GET_EXT_VERSION("admins") >= "0.4.1") { // Send new way SEND_ADMIN_EMAILS_PRO($subject, $templateName, $content, $uid); } else { - // Send outdated way + // Send out out-dated way $msg = LOAD_EMAIL_TEMPLATE($templateName, $content, $uid); SEND_ADMIN_EMAILS($subject, $msg); } @@ -3090,13 +3080,13 @@ function HANDLE_EXTRA_VALUES ($filterFunction, $value, $extraValue) { } // Check if given FQFN is a readable file -function FILE_READABLE($fqfn) { +function FILE_READABLE ($FQFN) { // Check all... - return ((file_exists($fqfn)) && (is_file($fqfn)) && (is_readable($fqfn))); + return ((file_exists($FQFN)) && (is_file($FQFN)) && (is_readable($FQFN))); } // Converts timestamp selections into a timestamp -function CONVERT_SELECTIONS_TO_TIMESTAMP(&$POST, &$DATA, &$id, &$skip) { +function CONVERT_SELECTIONS_TO_TIMESTAMP (&$POST, &$DATA, &$id, &$skip) { // Init test variable $test2 = "";