From 6f9f29d5caee60a2cceae33a7a53e1b4c7319a0c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 13 Aug 2011 20:04:34 +0000 Subject: [PATCH] Fixes and cleanups --- inc/extensions-functions.php | 2 +- inc/extensions/ext-nickname.php | 2 +- inc/filters.php | 2 +- inc/functions.php | 2 ++ inc/libs/network_functions.php | 6 +++++ inc/loader/load-points_data.php | 4 +-- inc/module-functions.php | 2 +- inc/modules/admin/admin-inc.php | 6 ++--- inc/modules/admin/what-list_links.php | 5 +++- inc/modules/admin/what-list_primera.php | 18 +++++++++++--- inc/modules/admin/what-list_unconfirmed.php | 7 +++++- inc/modules/admin/what-list_wernis.php | 5 +++- inc/referral-functions.php | 8 +++--- inc/sql-functions.php | 27 ++++++++++++--------- theme/README.txt | 2 +- 15 files changed, 65 insertions(+), 33 deletions(-) diff --git a/inc/extensions-functions.php b/inc/extensions-functions.php index e7e6bce308..4dec81d05f 100644 --- a/inc/extensions-functions.php +++ b/inc/extensions-functions.php @@ -1314,7 +1314,7 @@ function isExtensionUpdateRunning ($ext_name, $ignoreDependencies = false) { $isRunning = false; // Walk through whole array - foreach ($GLOBALS['ext_running_updates'] as $ext1=>$depends) { + foreach ($GLOBALS['ext_running_updates'] as $ext1 => $depends) { // Is it found? //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext1=' . $ext1 . ',ext_name=' . $ext_name . ',depends=' . print_r($depends, true)); if (($ext1 == $ext_name) || ((in_array($ext_name, $depends)) && ($ignoreDependencies === false))) { diff --git a/inc/extensions/ext-nickname.php b/inc/extensions/ext-nickname.php index 1358ecf6f2..3f005580c8 100644 --- a/inc/extensions/ext-nickname.php +++ b/inc/extensions/ext-nickname.php @@ -128,7 +128,7 @@ switch (getExtensionMode()) { break; case '0.1.1': // SQL queries for v0.1.1 - addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` DROP nick_userid"); + addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` DROP `nick_userid`'); // Update notes (these will be set as task text!) setExtensionUpdateNotes("Auswahlfür Mitglied ob mit Nickname oder Mitglied-Id einloggen entfernt."); diff --git a/inc/filters.php b/inc/filters.php index aa3d7d3d94..92a0174bb5 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -256,7 +256,7 @@ function FILTER_RUN_SQLS ($filterData) { if ((isSqlsValid()) && ((!isset($filterData['dry_run'])) || ($filterData['dry_run'] == false))) { // Run SQL commands //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, '- Found ' . countSqls() . ' queries to run.'); - foreach (getSqls() as $mode=>$sqls) { + foreach (getSqls() as $mode => $sqls) { // Debug message //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'mode=' . $mode . ',count()=' . count($sqls)); diff --git a/inc/functions.php b/inc/functions.php index 28c3beea4c..546086cb96 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -698,6 +698,7 @@ function generateRandomCode ($length, $code, $userid, $extraData = '') { // Does only allow numbers function bigintval ($num, $castValue = true, $abortOnMismatch = true) { + //* DEBUG: */ debugOutput('[' . __FUNCTION__ . ':' . __LINE__ . '] ' . 'num=' . $num . ',castValue=' . intval($castValue) . ',abortOnMismatch=' . intval($abortOnMismatch) . ' - ENTERED!'); // Filter all numbers out $ret = preg_replace('/[^0123456789]/', '', $num); @@ -714,6 +715,7 @@ function bigintval ($num, $castValue = true, $abortOnMismatch = true) { } // END - if // Return result + //* DEBUG: */ debugOutput('[' . __FUNCTION__ . ':' . __LINE__ . '] ' . 'num=' . $num . ',castValue=' . intval($castValue) . ',abortOnMismatch=' . intval($abortOnMismatch) . ',ret=' . $ret . ' - EXIT!'); return $ret; } diff --git a/inc/libs/network_functions.php b/inc/libs/network_functions.php index 592ee41feb..57e512bbcb 100644 --- a/inc/libs/network_functions.php +++ b/inc/libs/network_functions.php @@ -1346,6 +1346,12 @@ function doAdminNetworkProcessNetworkApiConfig () { // Add id setPostRequestElement('network_id', bigintval(getRequestElement('network'))); + // Is network_api_referral_button set? + if (postRequestElement('network_api_referral_button') == '') { + // Remove empty value to get a NULL for an optional entry + unsetPostRequestElement('network_api_referral_button'); + } // END - if + // Is there already an entry? if (isNetworkApiConfigured(getRequestElement('network'))) { // Generate SQL query diff --git a/inc/loader/load-points_data.php b/inc/loader/load-points_data.php index eea02d507c..2033281d65 100644 --- a/inc/loader/load-points_data.php +++ b/inc/loader/load-points_data.php @@ -61,9 +61,9 @@ if (($GLOBALS['cache_instance']->loadCacheFile('points_data')) && ($GLOBALS['cac $pointsData = array(); // Rewrite all to subject - foreach ($GLOBALS['cache_array']['points_data']['subject'] as $key=>$subject) { + foreach ($GLOBALS['cache_array']['points_data']['subject'] as $key => $subject) { // Re-add key with subject - foreach ($GLOBALS['cache_array']['points_data'] as $key2=>$array) { + foreach ($GLOBALS['cache_array']['points_data'] as $key2 => $array) { // Is key2 not 'subject'? if ($key2 != 'subject') { // Then Add it diff --git a/inc/module-functions.php b/inc/module-functions.php index 37e4664655..8af427efc3 100644 --- a/inc/module-functions.php +++ b/inc/module-functions.php @@ -146,7 +146,7 @@ function isModuleRegistered ($module) { $data = SQL_FETCHARRAY($result); // Set all entries - foreach ($data as $key=>$value) { + foreach ($data as $key => $value) { $GLOBALS['cache_array']['modules'][$key][$module] = $value; } // END - foreach diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index 86de3a3778..85c2d67250 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -1298,7 +1298,7 @@ function adminAddEntries ($tableName, $columns = array(), $filterFunctions = arr $sqlValues = array(); // Add columns and values - foreach ($columns as $key=>$columnName) { + foreach ($columns as $key => $columnName) { // Copy entry to final arrays $sqlColumns[$key] = $columnName; $sqlValues[$key] = postRequestElement($columnName); @@ -1372,7 +1372,7 @@ function adminListEntries ($tableTemplate, $rowTemplate, $noEntryMessageId, $tab if (count($orderByColumns) > 0) { // Add them as well $SQL .= ' ORDER BY '; - foreach ($orderByColumns as $orderByColumn=>$array) { + foreach ($orderByColumns as $orderByColumn => $array) { // Get keys (table/alias) and values (sorting itself) $table = trim(implode('', array_keys($array))); $sorting = trim(implode('', array_keys($array))); @@ -1406,7 +1406,7 @@ function doAdminListEntries ($SQL, $tableTemplate, $noEntryMessageId, $rowTempla $OUT = ''; while ($content = SQL_FETCHARRAY($result)) { // "Translate" content - foreach ($callbackColumns as $columnName=>$callbackFunction) { + foreach ($callbackColumns as $columnName => $callbackFunction) { // Fill the callback arguments $args = array($content[$columnName]); diff --git a/inc/modules/admin/what-list_links.php b/inc/modules/admin/what-list_links.php index cc344e13c2..0acde7aa19 100644 --- a/inc/modules/admin/what-list_links.php +++ b/inc/modules/admin/what-list_links.php @@ -118,7 +118,10 @@ if (isGetRequestElementSet('userid')) { $content = SQL_FETCHARRAY($result_data); // Fix empty subject - if (empty($content['subject'])) $content['subject'] = '{--DEFAULT_SUBJECT_LINE--}'; + if (empty($content['subject'])) { + // The subject line is empty so we use the default + $content['subject'] = '{--DEFAULT_SUBJECT_LINE--}'; + } // END - if // Prepare data for the row template $content['link'] = $LINK; diff --git a/inc/modules/admin/what-list_primera.php b/inc/modules/admin/what-list_primera.php index 971e77ac39..502a07c846 100644 --- a/inc/modules/admin/what-list_primera.php +++ b/inc/modules/admin/what-list_primera.php @@ -44,13 +44,20 @@ if ((!defined('__SECURITY')) || (!isAdmin())) { addYouAreHereLink('admin', __FILE__); // Check for entries -$result = SQL_QUERY("SELECT - `id`,`userid`,`primera_account`,`primera_amount`,`primera_timestamp`,`primera_type`,`primera_api_message`,`primera_api_status` +$result = SQL_QUERY('SELECT + `id`, + `userid`, + `primera_account`, + `primera_amount`, + `primera_timestamp`, + `primera_type`, + `primera_api_message`, + `primera_api_status` FROM `{?_MYSQL_PREFIX?}_user_primera` ORDER BY `primera_timestamp` DESC, - `id` DESC", + `id` DESC', __FILE__, __LINE__); // Are there some entries to display? @@ -62,7 +69,10 @@ if (!SQL_HASZERONUMS($result)) { $content['primera_timestamp'] = generateDateTime($content['primera_timestamp'], 2); // Fix empty message and status - if (empty($content['primera_api_status'])) $content['primera_api_status'] = 'OK'; + if (empty($content['primera_api_status'])) { + // Needs to be fixed to 'OK' + $content['primera_api_status'] = 'OK'; + } // END - if // Append it and switch colors $OUT .= loadTemplate('admin_list_primera_row', true, $content); diff --git a/inc/modules/admin/what-list_unconfirmed.php b/inc/modules/admin/what-list_unconfirmed.php index c5903b53f4..0b9172531c 100644 --- a/inc/modules/admin/what-list_unconfirmed.php +++ b/inc/modules/admin/what-list_unconfirmed.php @@ -132,7 +132,12 @@ if (($listed === true) && (!empty($sql))) { // but it does only show unconfirmed mail links from existing user // accounts. So if you have delete one you did not see those links $result = SQL_QUERY_ESC("SELECT - l.`userid`, u.`status`, u.`surname`, u.`family`, u.`gender`, u.`email` + l.`userid`, + u.`status`, + u.`surname`, + u.`family`, + u.`gender`, + u.`email` FROM `{?_MYSQL_PREFIX?}_user_links` AS `l` LEFT JOIN diff --git a/inc/modules/admin/what-list_wernis.php b/inc/modules/admin/what-list_wernis.php index 838c5a815f..a2ea24fd7c 100644 --- a/inc/modules/admin/what-list_wernis.php +++ b/inc/modules/admin/what-list_wernis.php @@ -69,7 +69,10 @@ if (!SQL_HASZERONUMS($result)) { $content['wernis_timestamp'] = generateDateTime($content['wernis_timestamp'], 2); // Fix empty message and status - if (empty($content['wernis_api_status'])) $content['wernis_api_status'] = 'OK'; + if (empty($content['wernis_api_status'])) { + // Needs to be fixed to 'OK' + $content['wernis_api_status'] = 'OK'; + } // END - if // Append it and switch colors $OUT .= loadTemplate('admin_list_wernis_row', true, $content); diff --git a/inc/referral-functions.php b/inc/referral-functions.php index ee2b1a3be2..c66289a0e3 100644 --- a/inc/referral-functions.php +++ b/inc/referral-functions.php @@ -438,7 +438,7 @@ function getPointsDataArrayFromSubject ($subject) { $pointsData = SQL_FETCHARRAY($result); // Add all entries to our cache array - foreach ($pointsData as $key=>$value) { + foreach ($pointsData as $key => $value) { $GLOBALS['cache_array']['points_data'][$subject][$key] = $value; } // END - foreach } else { @@ -577,7 +577,7 @@ function addMissingReferralLevels ($userid) { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',count()=' . count($GLOBALS['referral_refid'][$userid])); // Now walk through the array, first levels - foreach ($GLOBALS['referral_refid'][$userid] as $level=>$levelArray) { + foreach ($GLOBALS['referral_refid'][$userid] as $level => $levelArray) { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ',count()=' . count($levelArray)); // Next are the users foreach ($levelArray as $refid) { @@ -586,7 +586,7 @@ function addMissingReferralLevels ($userid) { if (isset($GLOBALS['referral_refid'][$refid])) { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ',refid=' . makeNullToZero($refid) . ',count()=' . count($GLOBALS['referral_refid'][$refid])); // Okay, then walk through here, too - foreach ($GLOBALS['referral_refid'][$refid] as $refLevel=>$refArray) { + foreach ($GLOBALS['referral_refid'][$refid] as $refLevel => $refArray) { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ',refid=' . makeNullToZero($refid) . ',refLevel=' . $refLevel . ',count()=' . count($refArray)); // Also walk through this one foreach ($refArray as $refRefid) { @@ -629,7 +629,7 @@ function flushReferralTableToDatabase ($userid) { $executeSql = false; // Now walk through the array, first levels - foreach ($GLOBALS['referral_refid'][$userid] as $level=>$levelArray) { + foreach ($GLOBALS['referral_refid'][$userid] as $level => $levelArray) { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ',count()=' . count($levelArray)); // Next are the users foreach ($levelArray as $refid) { diff --git a/inc/sql-functions.php b/inc/sql-functions.php index 5ec4bee18c..75118871d7 100644 --- a/inc/sql-functions.php +++ b/inc/sql-functions.php @@ -141,10 +141,10 @@ function getUpdateSqlFromArray ($array, $tableName, $whereColumn, $whereData, $e // Handle one-dimensional data if (is_null($value)) { // NULL detected - $SQL .= '`' . $entry . '`=NULL, '; - } elseif ((bigintval($value, true, false) === $value) || ($value == 'NOW()') || (substr($value, 0, 1) == '`')) { + $SQL .= '`' . $entry . '`=NULL,'; + } elseif (('' . bigintval($value, true, false) . '' == '' . $value . '') || ($value == 'NOW()') || (substr($value, 0, 1) == '`')) { // No need for ticks (') - $SQL .= '`' . $entry . '`=' . $value . ', '; + $SQL .= '`' . $entry . '`=' . $value . ','; } else { // Strings need ticks (') around them $SQL .= '`' . $entry . "`='" . SQL_ESCAPE($value) . "', "; @@ -154,25 +154,25 @@ function getUpdateSqlFromArray ($array, $tableName, $whereColumn, $whereData, $e if (is_null($value[$multiDimId])) { // NULL detected $SQL .= '`' . $entry . '`=NULL, '; - } elseif ((bigintval($value[$multiDimId], true, false) === $value[$multiDimId]) || ($value[$multiDimId] == 'NOW()') || (substr($value[$multiDimId], 0, 1) == '`')) { + } elseif (('' . bigintval($value[$multiDimId], true, false) . '' == '' . $value[$multiDimId] . '') || ($value[$multiDimId] == 'NOW()') || (substr($value[$multiDimId], 0, 1) == '`')) { // No need for ticks (') - $SQL .= '`' . $entry . '`=' . $value[$multiDimId] . ', '; + $SQL .= '`' . $entry . '`=' . $value[$multiDimId] . ','; } else { // Strings need ticks (') around them - $SQL .= '`' . $entry . "`='" . SQL_ESCAPE($value[$multiDimId]) . "', "; + $SQL .= '`' . $entry . "`='" . SQL_ESCAPE($value[$multiDimId]) . "',"; } } } // END - foreach // Remove last 2 chars and finish query - $SQL = substr($SQL, 0, -2) . ' WHERE `' . $whereColumn . '`=' . $whereData . ' LIMIT 1'; + $SQL = substr($SQL, 0, -1) . ' WHERE `' . $whereColumn . '`=' . $whereData . ' LIMIT 1'; // Return SQL query return $SQL; } // "Getter" for an "INSERT INTO" SQL query -function getInsertSqlFromArray ($array, $tableName, $excludedFields = array('ok', 'add', 'do_edit')) { +function getInsertSqlFromArray ($array, $tableName) { // Init SQL $SQL = 'INSERT INTO `{?_MYSQL_PREFIX?}_' . $tableName . '` @@ -181,15 +181,18 @@ function getInsertSqlFromArray ($array, $tableName, $excludedFields = array('ok' ) VALUES ('; // Walk through all entries - foreach (postRequestArray() as $key=>$value) { + foreach (postRequestArray() as $key => $value) { + // Log debug message + /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ',key=' . $key . ',value=' . $value); + // Add all entries if (is_null($value)) { // Add NULL $SQL .= 'NULL,'; - } elseif ((bigintval($value, true, false) == $value)) { + } elseif ('' . bigintval($value, true, false) . '' == '' . $value . '') { // Number detected, no need for ticks (') $SQL .= bigintval($value) . ','; - } elseif ('' . (float)$value . '' == $value) { + } elseif ('' . (float) $value . '' == '' . $value . '') { // Float number detected $SQL .= sprintf('%01.5f', $value); } else { @@ -199,7 +202,7 @@ function getInsertSqlFromArray ($array, $tableName, $excludedFields = array('ok' } // END - foreach // Finish SQL query - $SQL .= ')'; + $SQL = substr($SQL, 0, -1) . ')'; // Return SQL query return $SQL; diff --git a/theme/README.txt b/theme/README.txt index b27ff83d5c..b986e67814 100644 --- a/theme/README.txt +++ b/theme/README.txt @@ -2,4 +2,4 @@ Please read these notes before creating your own design: -------------------------------------------------------- Design names all lower-case, a-z, numbers, dash and underscore. Spaces in the -name are not spported. +name are not spported and might fail. -- 2.30.2