From f8a2f0c9d334d87fdaf8f010678ca5ad8b95211f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 22 Feb 2008 23:02:14 +0000 Subject: [PATCH 1/1] is_readable --- inc/functions.php | 58 +++++++++++++++-------------------------------- 1 file changed, 18 insertions(+), 40 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index f6fbbb1cc6..9a9ea0dfc8 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -674,8 +674,7 @@ function SET_LANGUAGE($lang) { set_session("mx_lang", $lang); } // -function LOAD_EMAIL_TEMPLATE($template, $content="", $UID="0") -{ +function LOAD_EMAIL_TEMPLATE($template, $content="", $UID="0") { global $DATA, $_CONFIG, $REPLACER; // Keept for backward-compatiblity (please replace these variables against our new {--CONST--} syntax!) @@ -696,21 +695,17 @@ function LOAD_EMAIL_TEMPLATE($template, $content="", $UID="0") } // Expiration in a nice output format - if ($_CONFIG['auto_purge'] == 0) - { + if ($_CONFIG['auto_purge'] == 0) { // Will never expire! $EXPIRATION = MAIL_WILL_NEVER_EXPIRE; - } - elseif (function_exists('CREATE_FANCY_TIME')) - { + } elseif (function_exists('CREATE_FANCY_TIME')) { // Create nice date string $EXPIRATION = CREATE_FANCY_TIME($_CONFIG['auto_purge']); - } - else - { + } else { // Display days only $EXPIRATION = round($_CONFIG['auto_purge']/60/60/24)." "._DAYS; } + switch ($template) { case "bonus-mail": // Load data for the bonus mail @@ -788,11 +783,11 @@ function LOAD_EMAIL_TEMPLATE($template, $content="", $UID="0") case "back-admin": case "back-member": - $points = TRANSLATE_COMMA($DATA[10]); + $points = TRANSLATE_COMMA($DATA[10]); break; case "add-points": - $points = bigintval($_POST['points']); + $points = bigintval($_POST['points']); break; case "guest_request_confirm": @@ -801,18 +796,14 @@ function LOAD_EMAIL_TEMPLATE($template, $content="", $UID="0") } // Load user's data - if ($UID > 0) - { - if (EXT_IS_ACTIVE("nickname")) - { + if ($UID > 0) { + if (EXT_IS_ACTIVE("nickname")) { // Load nickname $result = SQL_QUERY_ESC("SELECT surname, family, sex, email, nickname FROM "._MYSQL_PREFIX."_user_data WHERE userid=%d LIMIT 1", array(bigintval($UID)), __FILE__, __LINE__); list($surname, $family, $sex, $email, $nick) = SQL_FETCHROW($result); SQL_FREERESULT($result); - } - else - { + } else { // Load normal data $result = SQL_QUERY_ESC("SELECT surname, family, sex, email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%d LIMIT 1", array(bigintval($UID)), __FILE__, __LINE__); @@ -820,9 +811,7 @@ function LOAD_EMAIL_TEMPLATE($template, $content="", $UID="0") SQL_FREERESULT($result); $nick = "---"; } - } - else - { + } else { // Neutral sex and email address is default $sex = 'N'; $email = WEBMASTER; @@ -838,40 +827,29 @@ function LOAD_EMAIL_TEMPLATE($template, $content="", $UID="0") $BASE = PATH."templates/".GET_LANGUAGE()."/emails/"; // Check for admin/guest/member templates - if (strpos($template, "admin_") > -1) - { + if (strpos($template, "admin_") > -1) { // Admin template found $file = $BASE."admin/".$template.".tpl"; - } - elseif (strpos($template, "guest_") > -1) - { + } elseif (strpos($template, "guest_") > -1) { // Guest template found $file = $BASE."guest/".$template.".tpl"; - } - elseif (strpos($template, "member_") > -1) - { + } elseif (strpos($template, "member_") > -1) { // Member template found $file = $BASE."member/".$template.".tpl"; - } - else - { + } else { // Test for extension $test = substr($template, 0, strpos($template, "_")); - if (EXT_IS_ACTIVE($test)) - { + if (EXT_IS_ACTIVE($test)) { // Set extra path to extension's name $file = $BASE.$test."/".$template.".tpl"; - } - else - { + } else { // No special filename $file = $BASE.$template.".tpl"; } } // Does the special template exists? - if (!@file_exists($file)) - { + if ((!@file_exists($file)) || (!is_readable($file))) { // Reset to default template $file = $BASE.$template.".tpl"; } -- 2.30.2