From 7610d8baf42c19171389680fdefe5cd02e8ccda2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 3 Oct 2012 16:30:34 +0000 Subject: [PATCH] Template renamed, some minor improvements --- .gitattributes | 1 + inc/language/de.php | 2 +- inc/mysql-manager.php | 62 ++++++++++++++------------ inc/template-functions.php | 2 +- mailid.php | 2 +- mailid_top.php | 56 ++++++++++++----------- templates/de/html/app_die_message.tpl | 9 +--- templates/de/html/app_exit_message.tpl | 8 ++++ 8 files changed, 76 insertions(+), 66 deletions(-) create mode 100644 templates/de/html/app_exit_message.tpl diff --git a/.gitattributes b/.gitattributes index ebe31109b0..3caecbf54c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1657,6 +1657,7 @@ templates/de/html/admin/admin_yoomedia_error.tpl svneol=native#text/plain templates/de/html/agb.tpl svneol=native#text/plain templates/de/html/ajax_test_passed.tpl svneol=native#text/plain templates/de/html/app_die_message.tpl svneol=native#text/plain +templates/de/html/app_exit_message.tpl svneol=native#text/plain templates/de/html/beg/.htaccess svneol=native#text/plain templates/de/html/beg/beg_banner.tpl svneol=native#text/plain templates/de/html/beg/beg_done.tpl svneol=native#text/plain diff --git a/inc/language/de.php b/inc/language/de.php index 47198036b3..ac2b3118ac 100644 --- a/inc/language/de.php +++ b/inc/language/de.php @@ -947,7 +947,7 @@ addMessages(array( 'EMAIL_DELETE_COUNT' => "Buchungseinträge gelöscht", 'MAILER_HAS_DIED' => "{?TITLE?} ist in Script/Funktion %s, Zeile %s mit folgender Meldung abgebrochen: %s", 'ADMIN_CONFIG_POINTS_TITLE' => "Einstellungen für {?POINTS?}", - 'APP_DIE_TITLE' => "Bug im Script erkannt.", + 'APPLICATION_DIED_TITLE' => "Bug im Script erkannt.", 'ADMIN_CONTACT_LINK_TITLE' => "Kontakt zum Administrator", 'ADMIN_MAIL_NOTHING_DELETED' => "Die Mail mit der Id %s weisst keine Mitglieder auf.", diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index d97d33d37f..129b7c6ae1 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -423,7 +423,7 @@ function isMember () { // Init user data array initUserData(); - // Fix "deleted" cookies first + // Fix "deleted" cookies fixDeletedCookies(array('userid', 'u_hash')); // Are cookies set and can the member data be loaded? @@ -1312,18 +1312,18 @@ function getAdminMenuMode ($adminId) { } // Generates an option list from various parameters -function generateOptions ($table, $id, $name, $default = '', $special = '', $whereStatement = '', $disabled = array(), $callback = '') { +function generateOptions ($table, $key, $value, $default = '', $extra = '', $whereStatement = '', $disabled = array(), $callback = '') { $ret = ''; if ($table == '/ARRAY/') { // Selection from array - if ((is_array($id)) && (is_array($name)) && ((count($id)) == (count($name)) || (!empty($callback)))) { + if ((is_array($key)) && (is_array($value)) && ((count($key)) == (count($value)) || (!empty($callback)))) { // Both are arrays - foreach ($id as $idx => $value) { - $ret .= ''; } // END - foreach } else { // Problem in request - reportBug(__FUNCTION__, __LINE__, 'Not all are arrays: id[' . count($id) . ']=' . gettype($id) . ',name[' . count($name) . ']=' . gettype($name) . ',callback=' . $callback); + reportBug(__FUNCTION__, __LINE__, 'Not all are arrays: key[' . count($key) . ']=' . gettype($key) . ',value[' . count($value) . ']=' . gettype($value) . ',callback=' . $callback); } } else { - // Data from database - $SPEC = ',`' . $id . '`'; - if (!empty($special)) { - $SPEC = ',`' . $special . '` AS `special`'; + /////////////////////// + // Data from database / + /////////////////////// + + // Init extra column (if requested) + $extraColumn = ''; + if (!empty($extra)) { + $extraColumn = ',`' . $extra . '` AS `extra`'; } // END - if - // Query the database - $result = SQL_QUERY_ESC("SELECT `%s` AS `id`,`%s` AS `name`".$SPEC." FROM `{?_MYSQL_PREFIX?}_%s` ".$whereStatement." ORDER BY `%s` ASC", + // Run SQL query + $result = SQL_QUERY_ESC("SELECT `%s` AS `key`,`%s` AS `value`" . $extraColumn . " FROM `{?_MYSQL_PREFIX?}_%s` " . $whereStatement . " ORDER BY `%s` ASC", array( - $id, - $name, + $key, + $value, $table, - $name + $value ), __FUNCTION__, __LINE__); // Do we have rows? if (!SQL_HASZERONUMS($result)) { // Found data so add them as OPTION lines while ($content = SQL_FETCHARRAY($result)) { - // Is special set? - if (!isset($content['special'])) { + // Is extra set? + if (!isset($content['extra'])) { // Set it to empty - $content['special'] = ''; + $content['extra'] = ''; } // END - if - $ret .= ''; } // END - while } else { // No data found diff --git a/inc/template-functions.php b/inc/template-functions.php index 93eacf3606..495cccb345 100644 --- a/inc/template-functions.php +++ b/inc/template-functions.php @@ -1197,7 +1197,7 @@ function app_exit ($F, $L, $message) { ); // Load the message template - loadTemplate('app_die_message', false, $message); + loadTemplate('app_exit_message', false, $message); // Load footer loadIncludeOnce('inc/footer.php'); diff --git a/mailid.php b/mailid.php index 5413d03bc0..fc7e64ae70 100644 --- a/mailid.php +++ b/mailid.php @@ -208,7 +208,7 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr $errorCode = getCode('POSSIBLE_INVALID'); } } else { - $errorCode = getCode('ACCOUNT_' . getUserData('status')); + $errorCode = getCode('ACCOUNT_' . strtoupper(getUserData('status'))); } } else { $errorCode = getCode('USER_404'); diff --git a/mailid_top.php b/mailid_top.php index 1d12575417..ca8c3a5741 100644 --- a/mailid_top.php +++ b/mailid_top.php @@ -87,54 +87,58 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr // Maybe he wants to confirm an email? if ($mailId > 0) { - $result_main = SQL_QUERY_ESC("SELECT `id`,`link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `stats_id`=%s AND `userid`=%s LIMIT 1", + $result_main = SQL_QUERY_ESC("SELECT `id` AS `link_id`, `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `stats_id`=%s AND `userid`=%s LIMIT 1", array($mailId, $userId), __FILE__, __LINE__); $type = 'mailid'; $urlId = $mailId; } elseif ($bonusId > 0) { - $result_main = SQL_QUERY_ESC("SELECT `id`,`link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `bonus_id`=%s AND `userid`=%s LIMIT 1", + $result_main = SQL_QUERY_ESC("SELECT `id` AS `link_id`, `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `bonus_id`=%s AND `userid`=%s LIMIT 1", array($bonusId, $userId), __FILE__, __LINE__); $type = 'bonusid'; $urlId = $bonusId; + } else { + // Not detected + reportBug(__FILE__, __LINE__, 'Whether bonusid or mailid was set. This is a strange bug.'); } + // Is an entry found? if (SQL_NUMROWS($result_main) == 1) { // Is the stats id valid? - list($lid, $ltype) = SQL_FETCHROW($result_main); + $data = SQL_FETCHARRAY($result_main); // Init result here with invalid to avoid possible missing variable $result_mailid = false; - // @TODO Rewrite this to a filter - switch ($ltype) { + // @TODO Rewrite this to a filter/function + switch ($data['link_type']) { case 'NORMAL': - $result_mailid = SQL_QUERY_ESC("SELECT `pool_id`,`userid`,`id` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `id`=%s LIMIT 1", - array($mailId), __FILE__, __LINE__); + $result_mailid = SQL_QUERY_ESC("SELECT `pool_id`, `userid` AS `sender` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `id`=%s LIMIT 1", + array($urlId), __FILE__, __LINE__); break; case 'BONUS': - $result_mailid = SQL_QUERY_ESC("SELECT `id`,`id`,`is_notify` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1", - array($bonusId), __FILE__, __LINE__); + $result_mailid = SQL_QUERY_ESC("SELECT `is_notify` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1", + array($urlId), __FILE__, __LINE__); break; default: // Unknown type - reportBug(__FILE__, __LINE__, 'Unknown mail type ' . $ltype . ' detected.'); + reportBug(__FILE__, __LINE__, 'Unknown mail type ' . $data['link_type'] . ' detected.'); break; - } + } // END - switch // Entry found? if (SQL_NUMROWS($result_mailid) == 1) { // Load data - list($pool, $sender, $notify) = SQL_FETCHROW($result_mailid); + $data = merge_array($data, SQL_FETCHARRAY($result_mailid)); // Correct notification switch in non-bonus mails - if (!in_array($notify, array('Y', 'N'))) { - $notify = 'N'; + if ((!isset($data['is_notify'])) || (!in_array($data['is_notify'], array('Y', 'N')))) { + $data['is_notify'] = 'N'; } // END - if // Set sender to 0 when we have a bonus mail - if ($ltype == 'BONUS') { - $sender = '0'; + if ($data['link_type'] == 'BONUS') { + $data['sender'] = '0'; } // END - if // Is the user id valid? @@ -143,10 +147,10 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr if (getUserData('status') == 'CONFIRMED') { // User has confirmed his account so we can procede... // @TODO Rewrite this to a filter - switch ($ltype) { + switch ($data['link_type']) { case 'NORMAL': $result = SQL_QUERY_ESC("SELECT `payment_id` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `pool_id`=%s LIMIT 1", - array(bigintval($pool)), __FILE__, __LINE__); + array(bigintval($data['pool_id'])), __FILE__, __LINE__); // Entry found? if (SQL_NUMROWS($result) == 1) { @@ -162,7 +166,7 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr case 'BONUS': $result = SQL_QUERY_ESC("SELECT `time`,`points` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1", - array(bigintval($pool)), __FILE__, __LINE__); + array(bigintval($data['pool_id'])), __FILE__, __LINE__); // Entry found? if (SQL_NUMROWS($result) == 1) { @@ -175,7 +179,7 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr break; default: // Unknown type - reportBug(__FILE__, __LINE__, 'Unknown mail type ' . $ltype . ' detected.'); + reportBug(__FILE__, __LINE__, 'Unknown mail type ' . $data['link_type'] . ' detected.'); break; } // END - switch @@ -197,7 +201,7 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr // Count clicks // @TODO Rewrite this to a filter - switch ($ltype) { + switch ($data['link_type']) { case 'NORMAL': SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_stats` SET `clicks`=`clicks`+1 WHERE `id`=%s LIMIT 1", array($mailId), __FILE__, __LINE__); @@ -223,7 +227,7 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr break; default: // Unknown type - reportBug(__FILE__, __LINE__, 'Unknown mail type ' . $ltype . ' detected.'); + reportBug(__FILE__, __LINE__, 'Unknown mail type ' . $data['link_type'] . ' detected.'); break; } // END - switch @@ -273,7 +277,7 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr // Shall I add bonus points for "turbo clickers" ? if (isExtensionInstalledAndNewer('bonus', '0.2.2')) { // Is an active-rallye running and this is not a notification mail? - if ((isBonusRallyeActive()) && ($notify != 'Y')) { + if ((isBonusRallyeActive()) && ($data['is_notify'] != 'Y')) { // Shall I exclude the webmaster's own userid from the active-rallye? if ((((getBonusUserid() == $userId) && (getConfig('bonus_include_own') == 'Y')) || (getBonusUserid() != $userId)) && (getDefRefid() != $userId)) { // Add points and remember ranking are done in this function.... @@ -303,10 +307,10 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr // Load template loadTemplate($template, false, $content); - } elseif (isValidUserId($sender)) { + } elseif (isValidUserId($data['sender'])) { // Wrong image code! So add points to sender's account initReferralSystem(); - addPointsThroughReferralSystem('mailid_payback', $sender, $payment); + addPointsThroughReferralSystem('mailid_payback', $data['sender'], $payment); // Add payment points $content['points'] = $payment; @@ -323,7 +327,7 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr // Remove link from table SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `id`=%s LIMIT 1", - array(bigintval($lid)), __FILE__, __LINE__); + array(bigintval($data['link_id'])), __FILE__, __LINE__); break; case 'img': diff --git a/templates/de/html/app_die_message.tpl b/templates/de/html/app_die_message.tpl index 4c277c75d9..11f5d85d80 100644 --- a/templates/de/html/app_die_message.tpl +++ b/templates/de/html/app_die_message.tpl @@ -1,8 +1 @@ -
-
- {--APP_DIE_TITLE--} -
-
- $content -
-
+ diff --git a/templates/de/html/app_exit_message.tpl b/templates/de/html/app_exit_message.tpl new file mode 100644 index 0000000000..3617496d3e --- /dev/null +++ b/templates/de/html/app_exit_message.tpl @@ -0,0 +1,8 @@ +
+
+ {--APPLICATION_DIED_TITLE--} +
+
+ $content +
+
-- 2.39.2