From 0b4295f06d24d1a828d675854b7e973f10604abc Mon Sep 17 00:00:00 2001 From: quix0r Date: Wed, 28 Nov 2012 17:40:12 +0000 Subject: [PATCH] Swapped out more HTML to templates (see ticket #68) --- .gitattributes | 2 ++ inc/email-functions.php | 18 +++++++++++------- inc/filters.php | 2 +- inc/functions.php | 16 ++++++++++------ inc/language/de.php | 6 ++++++ inc/modules/admin/overview-inc.php | 2 +- inc/modules/admin/what-config_register.php | 8 ++++++-- inc/modules/admin/what-extensions.php | 8 ++++++-- inc/modules/admin/what-send_coupon.php | 6 +++--- inc/modules/guest/what-stats.php | 19 ++++++++++--------- inc/modules/guest/what-wernis_portal.php | 7 +++---- inc/modules/member/what-order.php | 2 +- inc/modules/sponsor/account.php | 2 +- inc/mysql-manager.php | 2 +- inc/purge/purge-inact.php | 7 +++++-- inc/template-functions.php | 4 ++-- templates/de/html/display_email.tpl | 6 ++++++ templates/de/html/guest/guest_wernis_news.tpl | 3 +++ 18 files changed, 78 insertions(+), 42 deletions(-) create mode 100644 templates/de/html/display_email.tpl create mode 100644 templates/de/html/guest/guest_wernis_news.tpl diff --git a/.gitattributes b/.gitattributes index 662e05498a..a1d804a5dc 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1679,6 +1679,7 @@ templates/de/html/birthday/birthday_msg.tpl svneol=native#text/plain templates/de/html/copyright.tpl svneol=native#text/plain templates/de/html/copyright_backlink.tpl svneol=native#text/plain templates/de/html/css_inline.tpl svneol=native#text/plain +templates/de/html/display_email.tpl svneol=native#text/plain templates/de/html/doubler/.htaccess svneol=native#text/plain templates/de/html/doubler/doubler_banner.tpl svneol=native#text/plain templates/de/html/doubler/doubler_footer.tpl svneol=native#text/plain @@ -1835,6 +1836,7 @@ templates/de/html/guest/guest_top10_empty5.tpl svneol=native#text/plain templates/de/html/guest/guest_top10_row_earner.tpl svneol=native#text/plain templates/de/html/guest/guest_top10_row_login.tpl svneol=native#text/plain templates/de/html/guest/guest_top10_row_refs.tpl svneol=native#text/plain +templates/de/html/guest/guest_wernis_news.tpl svneol=native#text/plain templates/de/html/impressum.tpl svneol=native#text/plain templates/de/html/index.tpl svneol=native#text/plain templates/de/html/index_forward.tpl svneol=native#text/plain diff --git a/inc/email-functions.php b/inc/email-functions.php index 4a2fc72ba3..e477edac1b 100644 --- a/inc/email-functions.php +++ b/inc/email-functions.php @@ -82,13 +82,17 @@ function sendEmail ($toEmail, $subject, $message, $isHtml = 'N', $mailHeader = ' // Debug mode enabled? if (isDebugModeEnabled()) { - // In debug mode we want to display the mail instead of sending it away so we can debug this part - outputHtml('
-Headers : ' . htmlentities(trim($mailHeader)) . '
-To      : ' . htmlentities($toEmail) . '
-Subject : ' . htmlentities($subject) . '
-Message(' . strlen($message) . ') : ' . htmlentities($message) . '
-
'); + // Init content array + $content = array( + 'headers' => htmlentities(trim($mailHeader)), + 'to' => htmlentities($toEmail), + 'subject' => htmlentities($subject), + 'message' => htmlentities($message), + 'length' => strlen($message) + ); + + // In debug mode display the mail instead of sending it away so it can be debugged + loadTemplate('display_email', FALSE, $content); // This is always fine return TRUE; diff --git a/inc/filters.php b/inc/filters.php index 0c6b498021..ce8f99fcd8 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -673,7 +673,7 @@ function FILTER_REMOVE_EXTENSION () { // Filter for flushing the output function FILTER_FLUSH_OUTPUT () { // Simple, he? - outputHtml(''); + outputHtml(); } // Prepares an SQL statement part for HTML mail and/or holiday dependency diff --git a/inc/functions.php b/inc/functions.php index 1935e2a8cc..f5aa6344ab 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1209,7 +1209,7 @@ function isUrlValidSimple ($url) { // Wtites data to a config.php-style file // @TODO Rewrite this function to use readFromFile() and writeToFile() -function changeDataInFile ($FQFN, $comment, $prefix, $suffix, $inserted, $seek=0) { +function changeDataInFile ($FQFN, $comment, $prefix, $suffix, $inserted, $seek = 0) { // Initialize some variables $done = FALSE; $seek++; @@ -1237,7 +1237,7 @@ function changeDataInFile ($FQFN, $comment, $prefix, $suffix, $inserted, $seek=0 // Start reading while (!feof($fp)) { // Read from source file - $line = fgets ($fp, 1024); + $line = fgets($fp, 1024); if (isInString($search, $line)) { $next = '0'; @@ -1268,18 +1268,22 @@ function changeDataInFile ($FQFN, $comment, $prefix, $suffix, $inserted, $seek=0 fclose($fp); if (($done === TRUE) && ($found === TRUE)) { - // Copy back tmp file and delete tmp :-) + // Copy back temporary->FQFN file and ... copyFileVerified($tmp, $FQFN, 0644); + + // ... delete temporay file :-) return removeFile($tmp); } elseif ($found === FALSE) { - outputHtml('CHANGE: 404!'); + // Entry not found + logDebugMessage(__FUNCTION__, __LINE__, 'File ' . basename($FQFN) . ' cannot be changed: comment=' . $comment . ',prefix=' . $prefix . ',inserted=' . $inserted . ',seek=' . $seek . ' - 404!'); } else { - outputHtml('TMP: UNDONE!'); + // Temporary file not fully written + logDebugMessage(__FUNCTION__, __LINE__, 'File ' . basename($FQFN) . ' cannot be changed: comment=' . $comment . ',prefix=' . $prefix . ',inserted=' . $inserted . ',seek=' . $seek . ' - Temporary file unfinished!'); } } } else { // File not found, not readable or writeable - reportBug(__FUNCTION__, __LINE__, 'File not readable/writeable. file=' . basename($FQFN)); + reportBug(__FUNCTION__, __LINE__, 'File not readable/writeable. file=' . basename($FQFN) . ',comment=' . $comment . ',prefix=' . $prefix . ',inserted=' . $inserted . ',seek=' . $seek); } // An error was detected! diff --git a/inc/language/de.php b/inc/language/de.php index b919fecf88..ac297af6a6 100644 --- a/inc/language/de.php +++ b/inc/language/de.php @@ -1397,6 +1397,12 @@ addMessages(array( 'ADMIN_USER_AMOUNT_PERCENTS' => "Prozentualer Anteil", 'ADMIN_TOTAL_POINTS_AMOUNT' => "Gesamtanzahl {?POINTS?}", 'ADMIN_LIST_USER_AMOUNTS_NOTICE' => "Diese Auflistung zeigt das Gesamtguthaben aller Mitglieder einzelnt und in der Gesamtsumme an. Dabei ist der Abzug bereits mit eingerechnet.", + + // Displaying email if in debug mode + 'EMAIL_DISPLAY_HEADERS' => "Kopfzeilen:", + 'EMAIL_DISPLAY_TO_ADDRESS' => "An:", + 'EMAIL_DISPLAY_SUBJECT_LINE' => "Betreffzeile:", + 'EMAIL_DISPLAY_MESSAGE_LENGTH' => "Nachricht(Länge):", )); // Description of all months diff --git a/inc/modules/admin/overview-inc.php b/inc/modules/admin/overview-inc.php index 19cb263f5b..13a66c760d 100644 --- a/inc/modules/admin/overview-inc.php +++ b/inc/modules/admin/overview-inc.php @@ -91,7 +91,7 @@ function outputStandardOverview (&$result_tasks) { } // END - if if (isset($GLOBALS['cache_array']['always_active'][$ext_name])) { - // Maybe we want to keept the current extension active? + // Shall the current extension kept activated? if (($GLOBALS['cache_array']['always_active'][$ext_name] == 'Y') && (!isExtensionActive($ext_name))) { // Reactivate this extension! doActivateExtension($ext_name); diff --git a/inc/modules/admin/what-config_register.php b/inc/modules/admin/what-config_register.php index eec09e7723..bd94bfd0c7 100644 --- a/inc/modules/admin/what-config_register.php +++ b/inc/modules/admin/what-config_register.php @@ -43,7 +43,7 @@ if ((!defined('__SECURITY')) || (!isAdmin())) { // Add description as navigation point addYouAreHereLink('admin', __FILE__); -// Do we want to save changes? +// Save changes? if (isFormSent('save_config')) { // Begin counting $count = 0; @@ -52,7 +52,11 @@ if (isFormSent('save_config')) { foreach (postRequestElement('sel') as $id => $value) { // Update database SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_must_register` SET `field_required`='%s' WHERE `id`=%s AND `field_required` != '%s' LIMIT 1", - array($value, bigintval($id), $value),__FILE__, __LINE__); + array( + $value, + bigintval($id), + $value + ),__FILE__, __LINE__); // Get affected rows $count += SQL_AFFECTEDROWS(); diff --git a/inc/modules/admin/what-extensions.php b/inc/modules/admin/what-extensions.php index 52e243e51d..c787c6bb35 100644 --- a/inc/modules/admin/what-extensions.php +++ b/inc/modules/admin/what-extensions.php @@ -43,7 +43,7 @@ if ((!defined('__SECURITY')) || (!isAdmin())) { // Add description as navigation point addYouAreHereLink('admin', __FILE__); -// Normally we want the overview of all registered extensions +// By default generate overview of all installed extensions $do = 'overview'; if (isGetRequestElementSet('register_ext')) { @@ -73,7 +73,11 @@ if (isGetRequestElementSet('register_ext')) { // Update database SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET `ext_active`='%s' WHERE `id`=%s AND `ext_active`='%s' LIMIT 1", - array($active, bigintval($ext_id), $ext_active), __FILE__, __LINE__); + array( + $active, + bigintval($ext_id), + $ext_active + ), __FILE__, __LINE__); // Run embeded SQL commands doExtensionSqls($ext_id, getExtensionMode()); diff --git a/inc/modules/admin/what-send_coupon.php b/inc/modules/admin/what-send_coupon.php index 65995d8c68..5d8ec24a82 100644 --- a/inc/modules/admin/what-send_coupon.php +++ b/inc/modules/admin/what-send_coupon.php @@ -99,9 +99,9 @@ ORDER BY // Look for a unique id while (!$isUnique) { /* - * Add a coupon for this user, first we need to create a - * table-unique "id". The function generatePassword() can do - * this job for us but we want to exclude some characters. + * Add a coupon for this user, first generate a + * "table-unique" id number. generatePassword() can do this + * but with some characters excluded. */ $couponCode = generatePassword(30, array('-', '+', '_', '/', '.')); diff --git a/inc/modules/guest/what-stats.php b/inc/modules/guest/what-stats.php index f53674e51a..b341e0ecd4 100644 --- a/inc/modules/guest/what-stats.php +++ b/inc/modules/guest/what-stats.php @@ -49,15 +49,16 @@ if ((!isExtensionActive('user')) && (!isAdmin())) { return; } // END - if -// Determine which stats we want and set mode and title for the link below stats block -if (!isGetRequestElementSet('do')) { - setGetRequestElement('do', strtolower(getConfig('guest_stats'))); -} // END - if +// Default mode is from config +$do = getConfig('guest_stats'); -// Set config temporarily -setConfigEntry('guest_stats', strtoupper(getRequestElement('do'))); +// Determine which stats are wanted and set mode and title for the link below stats block +if (isGetRequestElementSet('do')) { + // Use it from get value + $do = getRequestElement('do'); +} // END - if -switch (getRequestElement('do')) { +switch ($do) { case 'members' : $lmode = 'modules'; break; @@ -72,7 +73,7 @@ switch (getRequestElement('do')) { default: // Unsupported mode - reportBug(__FILE__, __LINE__, sprintf("Unsupported mode %s detected.", getRequestElement('do'))); + reportBug(__FILE__, __LINE__, sprintf("Unsupported mode %s detected.", SQL_ESCAPE($do))); break; } // END - switch @@ -80,7 +81,7 @@ switch (getRequestElement('do')) { $ltitle = '{--GUEST_STATS_' . strtoupper($lmode) . '--}'; // @TODO This can be rewritten in a dynamic include -switch (getConfig('guest_stats')) { +switch (strtoupper($do)) { case 'MEMBERS': // Statistics about your members // Only males / females $male = countSumTotalData('M', 'user_data', 'userid', 'gender', TRUE, runFilterChain('user_exclusion_sql', " AND `status`='CONFIRMED'")); diff --git a/inc/modules/guest/what-wernis_portal.php b/inc/modules/guest/what-wernis_portal.php index 45558fa73c..273dd23362 100644 --- a/inc/modules/guest/what-wernis_portal.php +++ b/inc/modules/guest/what-wernis_portal.php @@ -51,7 +51,7 @@ if ((!isExtensionActive('wernis')) && (!isAdmin())) { return; } // END - if -outputHtml('
'); +// Init PDF/RDF parser class $rdf = new fase4_rdf(); $rdf->_use_nl2br = FALSE; $rdf->use_dynamic_display(FALSE); @@ -81,9 +81,8 @@ if (isProxyUsed()) { $rdf->parse_RDF('http://www.wds66.com/rss.xml'); -// Fix to avoid 'headers already sent' bug. Thanks to Profi-Concept -outputHtml($rdf->finish(TRUE)); -outputHtml('
'); +// Load template +loadTemplate('guest_wernis_news', FALSE, $rdf->finish(TRUE)); // [EOF] ?> diff --git a/inc/modules/member/what-order.php b/inc/modules/member/what-order.php index 0078fc0a25..f4799ce3be 100644 --- a/inc/modules/member/what-order.php +++ b/inc/modules/member/what-order.php @@ -674,7 +674,7 @@ LIMIT 1", // Default is no ZIP code $content['zip_content'] = ''; - // Do we want ZIP code or not? + // Is sending to ZIP code enabled? (logged-in admin can always send to it) if ((isOrderMultiPageEnabled()) || (isAdmin())) { // Yes if (postRequestElement('zip') > 0) { diff --git a/inc/modules/sponsor/account.php b/inc/modules/sponsor/account.php index 85d03fa713..9be23f33a8 100644 --- a/inc/modules/sponsor/account.php +++ b/inc/modules/sponsor/account.php @@ -94,7 +94,7 @@ if (SQL_NUMROWS($result) == 1) { // Default is we don't want to change password! $PASS_AND = ''; $PASS_DATA = ''; - // Check if we want to change password or not + // Check if the sponsor wants to change his/her password if ((postRequestElement('pass1') == postRequestElement('pass2')) && (isPostRequestElementSet('pass1')) && (postRequestElement('pass1') != postRequestElement('pass_old'))) { // Change current password $PASS_AND = ",`password`='%s'"; diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 69b023ff4c..b22cde7b39 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -1773,7 +1773,7 @@ function reduceRecipientReceivedMails ($column, $id, $count) { // Now load all userids for one big query! $userids = array(); while ($data = SQL_FETCHARRAY($result)) { - // By default we want to reduce and have no mails found + // By default reduce and found no emails $num = 0; // We must now look if he has already confirmed this mail, so might sound double, but it may resolve problems diff --git a/inc/purge/purge-inact.php b/inc/purge/purge-inact.php index da6b87a34e..8004c7995f 100644 --- a/inc/purge/purge-inact.php +++ b/inc/purge/purge-inact.php @@ -120,8 +120,11 @@ ORDER BY // Free memory SQL_FREERESULT($result_inactive); - // Now let's have a look for inactive accounts we want to delete we newly use the same exclude list - // here for e.g. excluding holiday users + /* + * Now let's have a look for inactive accounts for deletion. Use the newly + * added exclude list here for e.g. excluding holiday users, test users et + * cetera. + */ $result_inactive = SQL_QUERY("SELECT `userid`, `email`, diff --git a/inc/template-functions.php b/inc/template-functions.php index a4c4d6f0a9..fe01016b23 100644 --- a/inc/template-functions.php +++ b/inc/template-functions.php @@ -93,7 +93,7 @@ function getColorSwitchCode ($template) { } // Output HTML code directly or 'render' it. You addionally switch the new-line character off -function outputHtml ($htmlCode, $newLine = TRUE) { +function outputHtml ($htmlCode = NULL, $newLine = TRUE) { // Init output if (!isset($GLOBALS['__output'])) { $GLOBALS['__output'] = ''; @@ -101,7 +101,7 @@ function outputHtml ($htmlCode, $newLine = TRUE) { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'getOutputMode()=' . getOutputMode() . ',htmlCode(length)=' . strlen($htmlCode) . ',output(length)=' . strlen($GLOBALS['__output'])); // Is there HTML-Code here? - if (!empty($htmlCode)) { + if ((!is_null($htmlCode)) && (!empty($htmlCode))) { // Yes, so we handle it as you have configured switch (getOutputMode()) { case 'render': diff --git a/templates/de/html/display_email.tpl b/templates/de/html/display_email.tpl new file mode 100644 index 0000000000..8f54321eaf --- /dev/null +++ b/templates/de/html/display_email.tpl @@ -0,0 +1,6 @@ +
+	{--EMAIL_DISPLAY_HEADERS--} $content[headers]
+	{--EMAIL_DISPLAY_TO_ADDRESS--} $content[to]
+	{--EMAIL_DISPLAY_SUBJECT_LINE--} $content[subject]
+	{--EMAIL_DISPLAY_MESSAGE_LENGTH--}($content[length]) $content[message]
+
diff --git a/templates/de/html/guest/guest_wernis_news.tpl b/templates/de/html/guest/guest_wernis_news.tpl new file mode 100644 index 0000000000..4dec46ef1d --- /dev/null +++ b/templates/de/html/guest/guest_wernis_news.tpl @@ -0,0 +1,3 @@ +
+$content +
-- 2.39.5