3e1b249ca704c2a10dd5917f18452d32bee3a464
[mailer.git] / inc / extensions / ext-doubler.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 02/03/2005 *
4  * ================                             Last change: 02/03/2005 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : ext-doubler.php                                  *
8  * -------------------------------------------------------------------- *
9  * Short description : Double points                                    *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Punkte verdoppeln                                *
12  * -------------------------------------------------------------------- *
13  *                                                                      *
14  * -------------------------------------------------------------------- *
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
16  * For more information visit: http://www.mxchange.org                  *
17  *                                                                      *
18  * This program is free software; you can redistribute it and/or modify *
19  * it under the terms of the GNU General Public License as published by *
20  * the Free Software Foundation; either version 2 of the License, or    *
21  * (at your option) any later version.                                  *
22  *                                                                      *
23  * This program is distributed in the hope that it will be useful,      *
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
26  * GNU General Public License for more details.                         *
27  *                                                                      *
28  * You should have received a copy of the GNU General Public License    *
29  * along with this program; if not, write to the Free Software          *
30  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
31  * MA  02110-1301  USA                                                  *
32  ************************************************************************/
33
34 // Some security stuff...
35 if (!defined('__SECURITY')) {
36         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
37         require($INC);
38 }
39
40 // Version number
41 EXT_SET_VERSION("0.1.6");
42
43 // Version history array (add more with , "0.1" and so on)
44 EXT_SET_VER_HISTORY(array("0.0", "0.0.1", "0.0.2", "0.0.3", "0.0.4", "0.0.5", "0.0.6", "0.0.7", "0.0.8", "0.0.9", "0.1.0", "0.1.1", "0.1.2", "0.1.3", "0.1.4", "0.1.5", "0.1.6"));
45
46 switch ($EXT_LOAD_MODE)
47 {
48 case "register": // Do stuff when installation is running (modules.php?module=admin&action=login is called)
49         // Doubler table
50         ADD_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_doubler`");
51         ADD_SQL("CREATE TABLE `{!_MYSQL_PREFIX!}_doubler` (
52 id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
53 userid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
54 refid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
55 points FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
56 remote_ip VARCHAR(15) NOT NULL DEFAULT '0.0.0.0',
57 timemark VARCHAR(10) NOT NULL DEFAULT '',
58 completed ENUM('Y','N') NOT NULL DEFAULT 'N',
59 is_ref ENUM('Y','N') NOT NULL DEFAULT 'N',
60 KEY(refid),
61 KEY(userid),
62 PRIMARY KEY(id)
63 )TYPE=MYISAM");
64
65         //
66         // --- SETTINGS ---
67         //
68         // Minimum points to double
69         ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_min FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 100.00000");
70         // Maximum points to double
71         ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_max FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 10000.00000");
72         // Points left on users account after doubling
73         ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_left BIGINT(20) UNSIGNED NOT NULL DEFAULT 1000");
74         // Charge for doubling points which goes to the webmaster (shreddered in fact!)
75         ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_charge FLOAT(7,5) UNSIGNED NOT NULL DEFAULT 0.03000");
76         // Referal percents
77         ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_ref FLOAT(7,5) UNSIGNED NOT NULL DEFAULT 0.02000");
78         // Shall I use the jackpot to take points from? (Y/N, default=Y)
79         ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_jackpot ENUM('Y','N') NOT NULL DEFAULT 'Y'");
80         // A user account to take points from (default: 0->none)
81         ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_uid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
82         // Total payed out points from your doublers
83         ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_points FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
84         // Sending mode of mails (immediately/daily reset)
85         // --> This also means who fast the doubled points will be payed out!
86         ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_send_mode ENUM('DIRECT','RESET') NOT NULL DEFAULT 'DIRECT'");
87         // Timeout for entries to be purged (default: one week)
88         ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_timeout BIGINT(20) UNSIGNED NOT NULL DEFAULT ".(getConfig('one_day')*7)."");
89         // Number of newest entries to display
90         ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_display_new TINYINT(3) UNSIGNED NOT NULL DEFAULT 10");
91         // Number of entries which will be payed out soon
92         ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_display_pay TINYINT(3) UNSIGNED NOT NULL DEFAULT 10");
93         // Number of entries which are already payed out
94         ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_display_old TINYINT(3) UNSIGNED NOT NULL DEFAULT 10");
95         // Points used by every member
96         ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_user_data` ADD doubler_points FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
97         // Counter for usage of the doubler
98         ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_counter BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
99
100         //
101         // --- MENU SYSTEMS ---
102         //
103         // Admin menu
104         ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('doubler', NULL, '{!POINTS!}-Verdoppler','Einstellungen und Eintr&auml;ge auflisten.', 4)");
105         ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('doubler','list_doubler','Auflisten','Eintr&auml;ge aus der Verdiensttabelle auflisten', 1)");
106         ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('doubler','config_doubler','Einstellungen','Prozentuale Geb&uuml;hr usw. einstellen.', 2)");
107
108         // Guest menu (informations / default doubler link)
109         ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_guest_menu` (`action`,`what`,`title`,`sort`,`visible`,`locked`) VALUES ('main','doubler','Verdoppeln!',3,'Y','Y')");
110
111         // Member menu
112         ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_member_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('main','doubler','Verdoppeln!','Y','Y',7)");
113         break;
114
115 case "remove": // Do stuff when removing extension
116         // SQL commands to run
117         ADD_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_doubler`");
118         ADD_SQL("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_admin_menu` WHERE `action`='doubler' LIMIT 3");
119         ADD_SQL("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_guest_menu` WHERE `what`='doubler' LIMIT 1");
120         ADD_SQL("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_member_menu` WHERE `what`='doubler' LIMIT 1");
121         break;
122
123 case "activate": // Do stuff when admin activates this extension
124         // SQL commands to run
125         ADD_SQL("UPDATE `{!_MYSQL_PREFIX!}_member_menu` SET `visible`='Y', `locked`='N' WHERE `what`='doubler' LIMIT 1");
126         ADD_SQL("UPDATE `{!_MYSQL_PREFIX!}_guest_menu` SET `visible`='Y', `locked`='N' WHERE `what`='doubler' LIMIT 1");
127         ADD_SQL("UPDATE `{!_MYSQL_PREFIX!}_mod_reg` SET `locked`='N', hidden='N', admin_only='N', mem_only='N' WHERE module='doubler' LIMIT 1");
128         break;
129
130 case "deactivate": // Do stuff when admin deactivates this extension
131         // SQL commands to run
132         ADD_SQL("UPDATE `{!_MYSQL_PREFIX!}_member_menu` SET `visible`='N', `locked`='Y' WHERE `what`='doubler' LIMIT 1");
133         ADD_SQL("UPDATE `{!_MYSQL_PREFIX!}_guest_menu` SET `visible`='N', `locked`='Y' WHERE `what`='doubler' LIMIT 1");
134         ADD_SQL("UPDATE `{!_MYSQL_PREFIX!}_mod_reg` SET `locked`='Y' WHERE module='doubler' LIMIT 1");
135         break;
136
137 case "update": // Update an extension
138         switch ($EXT_VER)
139         {
140         case "0.0.1": // SQL queries for v0.0.1
141                 // Update notes (these will be set as task text!)
142                 EXT_SET_UPDATE_NOTES("Problem mit User-ID behoben!");
143                 break;
144
145         case "0.0.2": // SQL queries for v0.0.2
146                 // Total used points
147                 ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_used FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
148
149                 // Update notes (these will be set as task text!)
150                 EXT_SET_UPDATE_NOTES("Geb&uuml;hr wird vom Verdoppler-Pott abgezogen.");
151                 break;
152
153         case "0.0.3": // SQL queries for v0.0.3
154                 // Update notes (these will be set as task text!)
155                 EXT_SET_UPDATE_NOTES("Drei SQL-Fehler beseitigt.");
156                 break;
157
158         case "0.0.4": // SQL queries for v0.0.4
159                 // Shall I use the doubler's account to take points from? (Y/N, default=Y)
160                 ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_own ENUM('Y','N') NOT NULL DEFAULT 'Y'");
161
162                 // Update notes (these will be set as task text!)
163                 EXT_SET_UPDATE_NOTES(POINTS."-Guthaben des Verdopplers kann optional nicht mit einbezogen werden.");
164                 break;
165
166         case "0.0.5": // SQL queries for v0.0.5
167                 // Update notes (these will be set as task text!)
168                 EXT_SET_UPDATE_NOTES("Counter-Stand und noch zum Verdoppeln &uuml;brige {!POINTS!} in Templates eingebunden. Auflistung in Admin-Bereich komplettiert.");
169                 break;
170
171         case "0.0.6": // SQL queries for v0.0.6
172                 ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_max_sent TINYINT(3) UNSIGNED NOT NULL DEFAULT 1");
173                 ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_group_sent TINYINT(3) UNSIGNED NOT NULL DEFAULT 1");
174                 ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_sent_all ENUM('Y','N') NOT NULL DEFAULT 'Y'");
175
176                 // Update notes (these will be set as task text!)
177                 EXT_SET_UPDATE_NOTES("Geb&uuml;hrenabzug wird beim Einzahlen abgezogen (wurde von Auszahlung abgezogen) und maximal bei Auszahlung zu kontrollierende Accounts einstellbar.<br />Template <u>admin_config_doubler_pro.tpl</u> ist &uuml;berfl&uuml;ssig geworden. Bitte l&ouml;schen Sie dies!");
178                 break;
179
180         case "0.0.7": // SQL queries for v0.0.7
181                 // Update notes (these will be set as task text!)
182                 EXT_SET_UPDATE_NOTES("W&ouml;rter <strong>Mailtausch</strong>, <strong>Mailtausches</strong> und <strong>Mailtauscher</strong> sind austauschbar.<br /><br />Minus-Guthaben des Verdoppler-Accounts repariert und Mitgliedsmail erweitert mit Transaktionsummer und IP-Nummer.");
183                 break;
184
185         case "0.0.8": // SQL queries for v0.0.8
186                 // Update notes (these will be set as task text!)
187                 EXT_SET_UPDATE_NOTES("Bitte verschieben Sie die doubler-Templates (Ordner: {!PATH!}/templates/".GET_LANGUAGE()."/html/) in den neuen Order doubler!");
188                 break;
189
190         case "0.0.9": // SQL queries for v0.0.9
191                 // Update notes (these will be set as task text!)
192                 EXT_SET_UPDATE_NOTES("Abspeichern von Einstellungen repariert.");
193                 break;
194
195         case "0.1.0": // SQL queries for v0.2.1
196                 // Update notes (these will be set as task text!)
197                 EXT_SET_UPDATE_NOTES("Vorbereitung auf die neue Mediendaten v0.0.4.");
198                 break;
199
200         case "0.1.1": // SQL queries for v0.1.1
201                 // Update notes (these will be set as task text!)
202                 EXT_SET_UPDATE_NOTES("Zwei SQL-Fehler in <strong>inc/doubler_send.php</strong> beseitigt.");
203                 break;
204
205         case "0.1.2": // SQL queries for v0.1.2
206                 // Update notes (these will be set as task text!)
207                 EXT_SET_UPDATE_NOTES("Sicherheitsupdate f&uuml;r die Include-Befehle.");
208                 break;
209
210         case "0.1.3": // SQL queries for v0.1.3
211                 // Update notes (these will be set as task text!)
212                 EXT_SET_UPDATE_NOTES("De-/Aktivieren des mit dieser Erweiterung verkn&uuml;pften Modules eingebunden.");
213                 break;
214
215         case "0.1.4": // SQL queries for v0.1.4
216                 ADD_SQL("UPDATE `{!_MYSQL_PREFIX!}_member_menu` SET `action`='extras', `sort`='4' WHERE `what`='doubler' LIMIT 1");
217
218                 // Update notes (these will be set as task text!)
219                 EXT_SET_UPDATE_NOTES("Mitgliedsmen&uuml; komplett umgebaut.");
220                 break;
221
222         case "0.1.5": // SQL queries for v0.1.5
223                 // Update notes (these will be set as task text!)
224                 EXT_SET_UPDATE_NOTES("Hash-Erstellung von <strong>md5()</strong> auf bessere Funktion <strong>generateHash()</strong> umgestellt.");
225                 break;
226
227         case "0.1.6": // SQL queries for v0.1.6
228                 // Update notes (these will be set as task text!)
229                 EXT_SET_UPDATE_NOTES("Fehlerhinweis bei deaktivierter Erweiterung verbessert.");
230                 break;
231         }
232         break;
233
234 case "test": // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
235         break;
236
237 default: // Do stuff when extension is loaded
238         if ((isResetModeEnabled()) && (getConfig('doubler_send_mode') == "RESET")) {
239                 // So let's check for points
240                 $INC_POOL[] = sprintf("%sinc/doubler_send.php", constant('PATH'));
241         }
242         break;
243 }
244
245 //
246 ?>