From ec9c05da249650be2acf05c20b00c3e1c64b9175 Mon Sep 17 00:00:00 2001 From: quix0r Date: Sat, 13 Oct 2012 23:43:42 +0000 Subject: [PATCH] More networks deactivated, isAdminsExpertSettingEnabled() introduced and some others for ext-network --- inc/extensions/ext-network.php | 10 ++-- inc/language/network_de.php | 2 + inc/libs/admins_functions.php | 5 ++ inc/libs/network_functions.php | 104 +++++++++++++++++++++++++-------- 4 files changed, 91 insertions(+), 30 deletions(-) diff --git a/inc/extensions/ext-network.php b/inc/extensions/ext-network.php index 92d02c42fb..8a38c4f69e 100644 --- a/inc/extensions/ext-network.php +++ b/inc/extensions/ext-network.php @@ -311,13 +311,13 @@ UNIQUE INDEX `provider_type` (`network_id`, `network_type_id`)", ('adcocktail', 'ADCocktail', 'http://www.adcocktail.com/?rid=2596', '|', '|', 'GET', 'WINDOWS-1252', 'N', 500, 'Y'), ('adpaid', 'AdPaid', 'http://www.adpaid.de?ref=1464', '|', '|', 'GET', 'ISO-8859-1', 'N', 0, 'N'), ('ads4', 'Ads4.de', 'http://www.ads4.de/?werber=Quix0r', '|', '|', 'GET', 'WINDOWS-1252', 'N', 96, 'Y'), -('ads4webbis', 'Ads4Webbis', 'http://www.ads4webbis.de?ref=835', '|', '|', 'GET', 'WINDOWS-1252', 'N', 200, 'Y'), +('ads4webbis', 'Ads4Webbis', 'http://www.ads4webbis.de?ref=835', '|', '|', 'GET', 'WINDOWS-1252', 'N', 200, 'N'), ('ads4world', 'Ads4World', 'http://www.ads4world.de?ref=252', '|', '|', 'GET', 'WINDOWS-1252', 'N', 0, 'N'), ('affiliblatt', 'Affiliblatt', 'http://www.affiliblatt.de/?sid=MTAzNQ==&site=home', '|', '|', 'GET', 'UTF-8', 'N', 0, 'Y'), ('allads4you', 'AllAds4You', 'http://www.allads4you.de?ref=1146', '|', '|', 'GET', 'ISO-8859-1', 'N', 150, 'Y'), -('alstermarketing', 'Alster-Marketing', 'http://www.alstermarketing.de?ref=1851', '|', '|', 'GET', 'ISO-8859-16', 'N', 350, 'Y'), +('alstermarketing', 'Alster-Marketing', 'http://www.alstermarketing.de?ref=1851', '|', '|', 'GET', 'ISO-8859-16', 'N', 350, 'N'), ('bonus', 'BonusSponsor', 'http://www.bonussponsor.de?ref=1286', '|', '|', 'GET', 'WINDOWS-1252', 'N', 150, 'Y'), -('fusion', 'Fusion-Ads', 'http://www.fusion-ads.de/?ref=84', '|', '|', 'GET', 'ISO-8859-1', 'N', 150, 'Y'), +('fusion', 'Fusion-Ads', 'http://www.fusion-ads.de/?ref=84', '|', '|', 'GET', 'ISO-8859-1', 'N', 150, 'N'), ('gigapromo', 'GigaPromo', 'http://www.gigapromo.de/index.php?ref=953', '|', '|', 'GET', 'WINDOWS-1252', 'N', 100, 'Y'), ('hpsponsor', 'HPSponsor', 'http://hpsponsor.at?ref=29', '|', '|', 'GET', 'WINDOWS-1252', 'N', 100, 'Y'), ('make-euros', 'Make-Euros.de', 'http://www.make-euros.de?ref=1184', '|', '|', 'GET', 'ISO-8859-1', 'Y', 150, 'N'), @@ -329,11 +329,11 @@ UNIQUE INDEX `provider_type` (`network_id`, `network_type_id`)", ('werbepartnercc', 'DerWerbepartner.cc', 'http://www.werbepartner.cc/sponsor/?ref=696', '|', '|', 'GET', 'WINDOWS-1252', 'N', 100, 'Y'), ('yoomedia', 'Yoo!Media', 'http://www.yoomedia.de?ref=1715', '|', '|', 'GET', 'WINDOWS-1252', 'N', 200, 'Y'), ('cityads', 'City-Ads', 'http://www.city-ads.de?ref=221', '|', '|', 'GET', 'WINDOWS-1252', 'N', 200, 'Y'), -('goldsponsor', 'Gold-Sponsor', 'http://www.gold-sponsor.de?ref=42', '|', '|', 'GET', 'WINDOWS-1252', 'N', 200, 'Y'), +('goldsponsor', 'Gold-Sponsor', 'http://www.gold-sponsor.de?ref=42', '|', '|', 'GET', 'WINDOWS-1252', 'N', 200, 'N'), ('doubleads', 'doubleads.de', 'http://www.doubleads.de?ref=1063', '|', '|', 'GET', 'ISO-8859-1','Y', 150, 'Y'), ('vipads', 'VIPads.de', 'http://vipads.de/index.php?seite=anmeldung&ref=Quix0r', '|', '|', 'GET', 'ISO-8859-1', 'N', 100, 'Y'), ('homeads', 'homeADS', 'http://www.homeads.de/?ref=1540', '|', '|', 'GET', 'WINDOWS-1252', 'N', 0, 'N'), -('fucoexsponsor', 'FuCoExSponsor.net', 'http://fucoexsponsor.net/index.php?seite=anmeldung&ref=Quix0r', '|', '|', 'GET', 'ISO-8859-1', 'N', 100, 'Y'), +('fucoexsponsor', 'FuCoExSponsor.net', 'http://fucoexsponsor.net/index.php?seite=anmeldung&ref=Quix0r', '|', '|', 'GET', 'ISO-8859-1', 'N', 100, 'N'), ('adconvention', 'AdConvention', 'http://www.adconvention.de?ref=233', '|', '|', 'GET', 'WINDOWS-1252', 'N', 300, 'Y'), ('ad-hit', 'Ad-Hit.de', 'http://www.ad-hit.de?ref=41', '|', '|', 'GET', 'WINDOWS-1252', 'N', 200, 'Y'), ('adcity', 'AdCity.eu', 'http://www.adcity.eu?ref=38', '|', '|', 'GET', 'WINDOWS-1252', 'N', 200, 'Y'), diff --git a/inc/language/network_de.php b/inc/language/network_de.php index 5010e530fb..bc056bb1a1 100644 --- a/inc/language/network_de.php +++ b/inc/language/network_de.php @@ -47,6 +47,7 @@ addMessages(array( // - Error messages 'ADMIN_NETWORK_NOT_ACTIVE' => "Das ausgewählte Netzwerk ist nicht aktiviert. Dies kann z.B. den Grund haben, dass die Webeseite nicht reagiert oder ein anderer Inhalt (Blog, geparkte Domain usw.) dort zu finden ist.", 'ADMIN_NETWORK_DO_404' => "Es wurde der Parameter 'do' nicht übermittelt.", + 'ADMIN_NETWORK_NOT_ACTIVE' => "Das ausgewähle Netzwerk ist nicht als aktiv markiert. Meistens steht dazu ein Hinweis im Forum.", 'ADMIN_NETWORK_FORM_NOT_SENT' => "Es wurde kein bekanntes Formular versendet.", 'ADMIN_NETWORK_NOTHING_FOUND' => "Es wurden keine Daten zum Editieren oder Löschen gefunden.", 'ADMIN_NETWORK_NOTHING_CHANGED' => "Es wurden keine Änderungen an den allgemeinen Daten ausgeführt.", @@ -274,6 +275,7 @@ addMessages(array( 'ADMIN_CONFIG_NETWORK_API_NOT_SAVED' => "API-Konfiguration NICHT gespeichert (keine Änderungen).", 'ADMIN_NETWORK_API_NOT_CONFIGURED' => "Konfiguration fehlt", 'ADMIN_NETWORK_API_CONFIGURED' => "Konfiguration vorhanden", + 'ADMIN_NETWORK_API_NOT_ACTIVE' => "Deaktiviert!", // Network types configuration 'ADMIN_CONFIG_NETWORK_HANDLER_TYPES_404' => "Es wurden keine Daten zur Werbenetzwerk-Id %s gefunden. Bitte benachrichtigen Sie das Entwickler-Team.", 'ADMIN_ADD_CONFIG_NETWORK_HANDLER_TYPE_404' => "Dieser Werbeart-Handler wurde noch nicht eingerichtet. {--ADMIN_ADD_CONFIG_NETWORK_HANDLER_TYPE_404_NOTICE--} Bitte richten Sie diesen als nächstes ein und führen Sie danach eine Testabfrage aus.", diff --git a/inc/libs/admins_functions.php b/inc/libs/admins_functions.php index f60eeac5f2..a3ff87855c 100644 --- a/inc/libs/admins_functions.php +++ b/inc/libs/admins_functions.php @@ -735,5 +735,10 @@ function isAdminsExpertWarningEnabled () { return (getAminsExpertWarning() == 'Y'); } +// Wrapper function to check whether expert setting is enabled +function isAdminsExpertSettingEnabled () { + return (getAminsExpertSettings() == 'Y'); +} + // [EOF] ?> diff --git a/inc/libs/network_functions.php b/inc/libs/network_functions.php index e90aa3b06a..0e184b9d39 100644 --- a/inc/libs/network_functions.php +++ b/inc/libs/network_functions.php @@ -115,18 +115,56 @@ function doAdminNetworkProcessForm () { // Checks whether the (short) network name is already used (valid) function isNetworkNameValid ($name) { - // Query for it - $result = SQL_QUERY_ESC("SELECT `network_id` FROM `{?_MYSQL_PREFIX?}_network_data` WHERE `network_short_name`='%s' LIMIT 1", - array($name), __FUNCTION__, __LINE__); + // Is there cache? + if (!isset($GLOBALS[__FUNCTION__][$name])) { + // Does it exist? + $GLOBALS[__FUNCTION__][$name] = (countSumTotalData($name, 'network_data', 'network_id', 'network_short_name', true) == 1); + } // END - if - // Does it exist? - $isValid = (SQL_NUMROWS($result) == 1); + // Return result + return $GLOBALS[__FUNCTION__][$name]; +} - // Free result - SQL_FREERESULT($result); +// Checks whether the (short) named network is activated +function isNetworkActiveByShortName ($name) { + // Is there cache? + if (!isset($GLOBALS[__FUNCTION__][$name])) { + // Does it exist? + $GLOBALS[__FUNCTION__][$name] = ((isNetworkNameValid($name)) && (countSumTotalData($name, 'network_data', 'network_id', 'network_short_name', true, " AND `network_active`='Y'") == 1)); + } // END - if // Return result - return $isValid; + return $GLOBALS[__FUNCTION__][$name]; +} + +// Checks whether the network by given id is activated +function isNetworkActiveById ($networkId) { + // Is there cache? + if (!isset($GLOBALS[__FUNCTION__][$networkId])) { + // Does it exist? + $GLOBALS[__FUNCTION__][$networkId] = (countSumTotalData(bigintval($networkId), 'network_data', 'network_id', 'network_id', true, " AND `network_active`='Y'") == 1); + } // END - if + + // Return result + return $GLOBALS[__FUNCTION__][$networkId]; +} + +// "Getter" for 'network_activated' column depending on current administrator's expert setting +function getNetworkActivatedColumn ($whereAnd = 'WHERE', $table = '') { + // Is there cache? + if (!isset($GLOBALS[__FUNCTION__][$whereAnd][$table])) { + // Default is exclude deactivated networks + $GLOBALS[__FUNCTION__][$whereAnd][$table] = ' ' . $whereAnd . ' ' . $table . "`network_active`='Y'"; + + // Is the export setting on? + if (isAdminsExpertSettingEnabled()) { + // Then allow all networks + $GLOBALS[__FUNCTION__][$whereAnd][$table] = ''; + } // END - if + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__][$whereAnd][$table]; } // Checks whether the given network type is already used (valid) @@ -213,7 +251,10 @@ function getNetworkDataById ($networkId, $column = '') { if ($networkId < 1) { // Not good, should be fixed reportBug(__FUNCTION__, __LINE__, 'Network id ' . $networkId . ' is smaller than 1.'); - } // END - if + } elseif ((!isNetworkActiveById($networkId)) && (!isAdminsExpertSettingEnabled())) { + // Do not load inactive network data + reportBug(__FUNCTION__, __LINE__, 'Network id ' . $networkId . ' is not active.'); + } // Set current network id setCurrentNetworkId($networkId); @@ -253,13 +294,16 @@ LIMIT 1', } // END - if // Return result - if (empty($column)) { + if ((empty($column)) && (isset($GLOBALS['network_data'][$networkId]))) { // Return array return $GLOBALS['network_data'][$networkId]; - } else { + } elseif (isset($GLOBALS['network_data'][$networkId][$column])) { // Return column return $GLOBALS['network_data'][$networkId][$column]; } + + // Return NULL + return NULL; } // "Getter" for a network's data by provided type id number @@ -268,7 +312,10 @@ function getNetworkDataByTypeId ($networkId, $column = '') { if ($networkId < 1) { // Not good, should be fixed reportBug(__FUNCTION__, __LINE__, 'Network type id ' . $networkId . ' is smaller than 1.'); - } // END - if + } elseif ((!isNetworkActiveById($networkId)) && (!isAdminsExpertSettingEnabled())) { + // Do not load inactive network data + reportBug(__FUNCTION__, __LINE__, 'Network id ' . $networkId . ' is not active.'); + } // Set current network id setCurrentNetworkId($networkId); @@ -279,7 +326,7 @@ function getNetworkDataByTypeId ($networkId, $column = '') { $GLOBALS['network_data'][$networkId] = array(); // Query for the network data - $result = SQL_QUERY_ESC("SELECT + $result = SQL_QUERY_ESC('SELECT d.`network_id`, d.`network_short_name`, d.`network_title`, @@ -303,7 +350,7 @@ ON d.`network_id`=t.`network_id` WHERE t.`network_type_id`=%s -LIMIT 1", +LIMIT 1', array(bigintval($networkId)), __FUNCTION__, __LINE__); // Is there an entry? @@ -511,16 +558,15 @@ function generateAdminNetworkList () { $content = ''; // Query for all networks - $result = SQL_QUERY("SELECT + $result = SQL_QUERY('SELECT `network_id`, `network_short_name`, `network_title` FROM `{?_MYSQL_PREFIX?}_network_data` -WHERE - `network_active`='Y' +' . getNetworkActivatedColumn() . ' ORDER BY - `network_short_name` ASC", __FUNCTION__, __LINE__); + `network_short_name` ASC', __FUNCTION__, __LINE__); // Are there entries? if (!SQL_HASZERONUMS($result)) { @@ -561,6 +607,7 @@ FROM `{?_MYSQL_PREFIX?}_network_types` WHERE `network_id`=%s + ' . getNetworkActivatedColumn('AND') . ' ORDER BY `network_type_handler` ASC', array( @@ -599,7 +646,7 @@ function generateAdminDistinctNetworkTypeList () { $content = ''; // Query all types of this network - $result = SQL_QUERY("SELECT + $result = SQL_QUERY('SELECT t.`network_type_id`, t.`network_type_handler`, d.`network_title` @@ -609,11 +656,10 @@ LEFT JOIN `{?_MYSQL_PREFIX?}_network_data` AS d ON t.`network_id`=d.`network_id` -WHERE - d.`network_active`='Y' +' . getNetworkActivatedColumn('WHERE', 'd') . ' ORDER BY d.`network_short_name` ASC, - t.`network_type_handler` ASC", __FUNCTION__, __LINE__); + t.`network_type_handler` ASC', __FUNCTION__, __LINE__); // Are there entries? if (!SQL_HASZERONUMS($result)) { @@ -646,6 +692,7 @@ ORDER BY function generateNetworkTypeOptions ($networkId) { // Is this an array, then we just came back from edit/delete actions if (is_array($networkId)) { + // Set it as empty string $networkId = ''; } // END - if @@ -659,7 +706,7 @@ function generateNetworkTypeOptions ($networkId) { $networkId, '', sprintf( - "WHERE `network_id`=%s", + "WHERE `network_id`=%s" . getNetworkActivatedColumn('AND'), bigintval(getRequestElement('network_id')) ), '', @@ -1015,7 +1062,10 @@ function translateNetworkApiConfiguredStatusById ($networkId) { $GLOBALS[__FUNCTION__][$networkId] = '{--ADMIN_NETWORK_API_NOT_CONFIGURED--}'; // So is it configured? - if (isNetworkApiConfigured($networkId)) { + if (!isNetworkActiveById($networkId)) { + // Network is not active + $GLOBALS[__FUNCTION__][$networkId] = '{--ADMIN_NETWORK_API_NOT_ACTIVE--}'; + } elseif (isNetworkApiConfigured($networkId)) { // Yes, it is $GLOBALS[__FUNCTION__][$networkId] = '{--ADMIN_NETWORK_API_CONFIGURED--}'; } // END - if @@ -1079,7 +1129,11 @@ function doAdminNetworkProcessAddNetwork () { // Already there loadTemplate('admin_settings_unsaved', false, '{%message,ADMIN_NETWORK_ALREADY_ADDED=' . postRequestElement('network_short_name') . '%}'); return false; - } // END - if + } elseif (!isNetworkActiveByShortName(postRequestElement('network_short_name'))) { + // Network is not active + loadTemplate('admin_settings_unsaved', false, '{%message,ADMIN_NETWORK_NOT_ACTIVE=' . postRequestElement('network_short_name') . '%}'); + return false; + } // Remove the 'ok' part unsetPostRequestElement('ok'); -- 2.39.2