All non-productive extensions marked as 'non-productive', a warning will be issued...
[mailer.git] / inc / extensions / ext-network.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 12/18/2008 *
4  * ================                             Last change: 11/01/2009 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : ext-network.php                                  *
8  * -------------------------------------------------------------------- *
9  * Short description : Generic (sponsor) network connection extension   *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Allgemeine Sponsorennetzwerk-Erweiterung         *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * Needs to be in all Files and every File needs "svn propset           *
18  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
19  * -------------------------------------------------------------------- *
20  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
21  * For more information visit: http://www.mxchange.org                  *
22  *                                                                      *
23  * This program is free software; you can redistribute it and/or modify *
24  * it under the terms of the GNU General Public License as published by *
25  * the Free Software Foundation; either version 2 of the License, or    *
26  * (at your option) any later version.                                  *
27  *                                                                      *
28  * This program is distributed in the hope that it will be useful,      *
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
31  * GNU General Public License for more details.                         *
32  *                                                                      *
33  * You should have received a copy of the GNU General Public License    *
34  * along with this program; if not, write to the Free Software          *
35  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
36  * MA  02110-1301  USA                                                  *
37  ************************************************************************/
38
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
41         die();
42 } // END - if
43
44 // Version number
45 setThisExtensionVersion('0.0');
46
47 // Version history array (add more with , '0.1.0' and so on)
48 setExtensionVersionHistory(array('0.0'));
49
50 // This extension is in development (non-productive)
51 enableExtensionProductive(false);
52
53 switch (getExtensionMode()) {
54         case 'register': // Do stuff when installation is running (modules.php?module=admin is called)
55                 // Main table which hold
56                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_network_data`");
57                 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_network_data` (
58 `network_id` BIGINT(20) NOT NULL AUTO_INCREMENT,
59 `network_short_name` VARCHAR(50) NOT NULL DEFAULT '',
60 `network_title` VARCHAR(255) NOT NULL DEFAULT '',
61 `network_reflink` VARCHAR(255) NOT NULL DEFAULT '',
62 `network_data_seperator CHAR(4) NOT NULL DEFAULT '|',
63 `network_row_seperator CHAR(4) NOT NULL DEFAULT '|',
64 `network_request_type` ENUM('GET','POST') NOT NULL DEFAULT 'GET',
65 `network_charset` VARCHAR(20) NOT NULL DEFAULT 'ISO-8859-1',
66 UNIQUE (`network_short_name`),
67 PRIMARY KEY (`network_id`)
68 ) TYPE={?_TABLE_TYPE?} COMMENT='Network data'");
69
70                 // Types the network provider is supporting (e.g. Forced-Banner and so on)
71                 // @TODO network_type_name is an internal name and needs documentation
72                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_network_types`");
73                 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_network_types` (
74 `network_type_id` BIGINT(20) NOT NULL AUTO_INCREMENT,
75 `network_id` BIGINT(20) NOT NULL DEFAULT 0,
76 `network_type_name` VARCHAR(255) NOT NULL DEFAULT '',
77 `network_type_title` VARCHAR(255) NOT NULL DEFAULT '',
78 `network_type_request_url` VARCHAR(255) NOT NULL DEFAULT '',
79 `network_type_click_url` VARCHAR(255) NOT NULL DEFAULT '',
80 `network_type_banner_url` VARCHAR(255) NOT NULL DEFAULT '',
81 UNIQUE `provider_type` (`network_id`,`network_type_name`),
82 PRIMARY KEY (`network_type_id`)
83 ) TYPE={?_TABLE_TYPE?} COMMENT='Types provideable by networks. ONLY FILL OUT WITH PROPER IDEA!'");
84
85                 // HTTP parameters (names) for URLs
86                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_network_request_params`");
87                 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_network_request_params` (
88 `network_type_id` BIGINT(20) NOT NULL DEFAULT 0,
89 `request_param_max_reload_time` VARCHAR(10) NOT NULL DEFAULT 'reload',
90 `request_param_min_waiting_time` VARCHAR(10) NOT NULL DEFAULT 'ma',
91 `request_param_min_remain_clicks` VARCHAR(10) NOT NULL DEFAULT 'uebrig',
92 `request_param_min_payment` VARCHAR(10) NOT NULL DEFAULT 'verguetung',
93 `request_param_allow_erotic` VARCHAR(10) NOT NULL DEFAULT 'erotik',
94 PRIMARY KEY (`network_type_id`)
95 ) TYPE={?_TABLE_TYPE?} COMMENT='Request parameters for GET/POST request ONLY FILL OUT WITH PROPER IDEA!'");
96
97                 // Error status codes
98                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_network_type_errors`");
99                 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_network_type_codes` (
100 `network_type_code_id` BIGINT(20) NOT NULL AUTO_INCREMENT,
101 `network_type_id` BIGINT(20) NOT NULL DEFAULT 0,
102 `network_type_code_value` VARCHAR(50) NOT NULL DEFAULT '',
103 `network_type_code_type` VARCHAR(100) NOT NULL DEFAULT 'INVALID_TYPE',
104 UNIQUE `code_type` (`network_type_code_value`,`network_type_id`),
105 INDEX (`network_type_id`),
106 PRIMARY KEY (`network_type_code_id`)
107 ) TYPE={?_TABLE_TYPE?} COMMENT='Error codes for all types'");
108
109                 // Code types (internal table)
110                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_network_codes`");
111                 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_network_codes` (
112 `network_code_id` BIGINT(20) NOT NULL AUTO_INCREMENT,
113 `network_code` VARCHAR(100) NOT NULL DEFAULT 'INVALID_CODE',
114 UNIQUE (`network_code`),
115 PRIMARY KEY (`network_code_id`)
116 ) TYPE={?_TABLE_TYPE?} COMMENT='Error types, generic data, DO NOT ALTER!'");
117
118                 // Data from the webmaster (you!)
119                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_network_config`");
120                 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_network_config` (
121 `network_id` BIGINT(20) NOT NULL DEFAULT 0,
122 `network_affiliate_id` BIGINT(20) NOT NULL DEFAULT 0,
123 `network_api_password` VARCHAR(255) NOT NULL DEFAULT '',
124 `network_site_id` BIGINT(20) NOT NULL DEFAULT 0,
125 UNIQUE `network_affiliate` (`network_id`,`network_affiliate_id`),
126 UNIQUE `affiliate_site` (`network_affiliate_id`,`network_site_id`),
127 PRIMARY KEY (`network_id`)
128 ) TYPE={?_TABLE_TYPE?} COMMENT='Configuration data from the webmaster (you!)'");
129
130                 // Configuration data for e.g. reload-time
131                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_network_types_config`");
132                 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_network_types_config` (
133 `network_data_id` BIGINT(20) NOT NULL AUTO_INCREMENT,
134 `network_id` BIGINT(20) NOT NULL DEFAULT 0,
135 `network_type_id` BIGINT(20) NOT NULL DEFAULT 0,
136 `max_reload_time` BIGINT(20) NOT NULL DEFAULT 0,
137 `min_waiting_time` BIGINT(20) NOT NULL DEFAULT 0,
138 `min_remain_clicks` BIGINT(20) NOT NULL DEFAULT 0,
139 `min_payment` BIGINT(20) NOT NULL DEFAULT 0,
140 `allow_erotic` VARCHAR(10) NOT NULL DEFAULT '',
141 INDEX `network_affiliate` (`network_id`,`network_affiliate_id`),
142 PRIMARY KEY (`network_data_id`)
143 ) TYPE={?_TABLE_TYPE?} COMMENT='Configuration data for every type (e.g. reload-time)'");
144
145                 // Insert error code types
146                 // - Affiliate id or interface password wrong
147                 addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_network_codes` (`network_code`) VALUES ('AFF_ID_PASS_WRONG')");
148                 // - Webmaster's site id is not assigned (invalid, different affiliate id)
149                 addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_network_codes` (`network_code`) VALUES ('SITE_ID_NOT_ASSIGNED')");
150                 // - Webmaster's site id is locked
151                 addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_network_codes` (`network_code`) VALUES ('SITE_ID_LOCKED')");
152                 // - General error in interface data
153                 addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_network_codes` (`network_code`) VALUES ('INTERFACE_DATA_ERROR')");
154                 // - Request amount depleted
155                 addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_network_codes` (`network_code`) VALUES ('REQUESTS_DEPLETED')");
156                 // - No campaigns found for given criteria (but maybe there are with more widen criteria)
157                 addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_network_codes` (`network_code`) VALUES ('NO_CAMPAIGNS_FOUND')");
158                 // - No campaigns found with allowed interface output (but there are maybe non-interface campaigns)
159                 addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_network_codes` (`network_code`) VALUES ('NO_CAMPAIGNS_FOUND_INTERFACE')");
160                 // - Webmaster's site id is not unlocked for choosen type
161                 addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_network_codes` (`network_code`) VALUES ('SITE_ID_NOT_ALLOWED_TYPE')");
162                 // - Request parameters incomplete
163                 addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_network_codes` (`network_code`) VALUES ('REQUEST_PARAMS_INCOMPLETE')");
164
165                 // Admin menu entries
166                 addAdminMenuSql('network',NULL,'Sponsorennetzwerke','Verwalten Sie hier Sponsorennetzwerke (API-Anbindung), versenden Sie deren Mails, oder &uuml;bernehmen Sie deren Textlinks und vieles mehr. <strong>VORSICHT:</strong> Das Einrichten von weiteren Sponsorennetzwerken ist nicht leicht, daf&uuml;r aber sehr flexibel! Sollte ein Netzwerk fehlen, so melden Sie dies bitte <a href="http://forum.mxchange.org/topic-462.html" target="_blank" title="Direktlink zum Forum">im Forum</a>!',4);
167                 addAdminMenuSql('network','config_network','API-Daten','Stellen Sie Ihre Affiliate- Webseiten-Id und API-Passwort ein. Diese erhalten Sie zu &uuml;ber 99% aus dem jeweiligen Zugangsbereich des Anbieters. Sollten Sie bei einem Netzwerk noch nicht angemeldet sein, verwenden Sie bitte meinen Referal-Link.',1);
168                 addAdminMenuSql('network','config_network_types','Werbearten','Stellen Sie hier Reload-Zeiten, Mindestauffenthalt und so weiter pro Werbeart und Sponsorennetzwerk ein. Es werden sonst Standart-Werte (Mimimumwerte: 0, Maximumwerte: sehr gross, Erotik: aus) angenommen, die Sie meistens nicht wollen.',2);
169                 addAdminMenuSql('network','list_networks','Auflisten/Verwalten','<strong>Experten-Einstellungen!</strong> Hier &auml;ndern Sie die Einstellungen an den Grunddaten (Stammdaten) des jeweiligen Sponsorennetzwerks ab. Sie sollten hier generell nichts einstellen und <a href="http://forum.mxchange.org/forum-43.html" target="_blank" title="Direktlink zum Forum">im Forum</a> um Hilfe fragen, wenn Sie selber ein Sponsorennetzwerk einrichten m&ouml;chten.',3);
170                 addAdminMenuSql('network','list_network_types','Werbearten verwalten','<strong>Experten-Einstellungen!</strong> Hier &auml;ndern Sie die Einstellungen zu den Werbearten pro Sponsorennetzwerken. Sie sollten hier generell nichts einstellen und <a href="http://forum.mxchange.org/forum-43.html" target="_blank" title="Direktlink zum Forum">im Forum</a> um Hilfe fragen, wenn Sie selber ein Sponsorennetzwerk einrichten m&ouml;chten.',4);
171                 addAdminMenuSql('network','list_network_params','Abfrageparameter','<strong>Experten-Einstellungen!</strong> Hier stellen Sie die Abfrageparameter (wie sie genannt werden m&uuml;ssen, um das API-Script korrekt aufrufen zu k&ouml;nnen) ein, pro Sponsorennetzwerk. Sie sollten hier generell nichts einstellen und <a href="http://forum.mxchange.org/forum-43.html" target="_blank" title="Direktlink zum Forum">im Forum</a> um Hilfe fragen, wenn Sie selber ein Sponsorennetzwerk einrichten m&ouml;chten.',5);
172                 addAdminMenuSql('network','list_network_code_types','','<strong>Experten-Einstellungen!</strong> Hier stellen Sie die R&uuml;ckgabewerte ein, die im Falle eines Fehlers pro API-Script kommen k&ouml;nnen. Sie sollten hier generell nichts einstellen und <a href="http://forum.mxchange.org/forum-43.html" target="_blank" title="Direktlink zum Forum">im Forum</a> um Hilfe fragen, wenn Sie selber ein Sponsorennetzwerk einrichten m&ouml;chten.',7);
173                 addAdminMenuSql('network','list_network_codes','Fehlercodes einstellen','<strong>Experten-Einstellungen!</strong> Hier stellen Sie die Namen von Fehlercodes ein, die Scripte zur&uuml;ckliefern k&ouml;nnen. <strong>Dies sind INTERNE Daten und sollten nur vom MXChange-Entwicklerteam angepasst werden.</strong> Stellen Sie an diesen Einstellungen bitte nichts um. Sie sollten hier generell nichts einstellen und <a href="http://forum.mxchange.org/forum-43.html" target="_blank" title="Direktlink zum Forum">im Forum</a> um Hilfe fragen, wenn Sie selber ein Sponsorennetzwerk einrichten m&ouml;chten.',7);
174                 break;
175
176         case 'remove': // Do stuff when removing extension
177                 // SQL commands to run
178                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_network_data`");
179                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_network_types`");
180                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_network_request_params`");
181                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_network_type_errors`");
182                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_network_config`");
183                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_network_types_config`");
184
185                 // Admin menu
186                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='network'");
187                 break;
188
189         case 'activate': // Do stuff when admin activates this extension
190                 // SQL commands to run
191                 break;
192
193         case 'deactivate': // Do stuff when admin deactivates this extension
194                 // SQL commands to run
195                 break;
196
197         case 'update': // Update an extension
198                 switch (getCurrentExtensionVersion()) {
199                         case '0.0.1': // SQL queries for v0.0.1
200                                 addExtensionSql('');
201
202                                 // Update notes (these will be set as task text!)
203                                 setExtensionUpdateNotes('');
204                                 break;
205                 } // END - switch
206                 break;
207
208         case 'modify': // When the extension got modified
209                 break;
210
211         case 'test': // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
212                 break;
213
214         case 'init': // Do stuff when extension is initialized
215                 break;
216
217         default: // Unknown extension mode
218                 DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown extension mode %s detected.", getExtensionMode()));
219                 break;
220 } // END - switch
221
222 // [EOF]
223 ?>