226560cf2a580b4c747d4906f0f1dc974c743337
[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  * $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 - 2008 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         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
42         require($INC);
43 }
44
45 // Version number
46 EXT_SET_VERSION('0.1.6');
47
48 // Version history array (add more with , '0.1.0' and so on)
49 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'));
50
51 switch ($EXT_LOAD_MODE)
52 {
53         case 'register': // Do stuff when installation is running (modules.php?module=admin&action=login is called)
54                 // Doubler table
55                 ADD_EXT_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_doubler`");
56                 ADD_EXT_SQL("CREATE TABLE `{!_MYSQL_PREFIX!}_doubler` (
57 id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
58 userid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
59 refid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
60 points FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
61 remote_ip VARCHAR(15) NOT NULL DEFAULT '0.0.0.0',
62 timemark VARCHAR(10) NOT NULL DEFAULT '',
63 completed ENUM('Y','N') NOT NULL DEFAULT 'N',
64 is_ref ENUM('Y','N') NOT NULL DEFAULT 'N',
65 KEY(refid),
66 KEY(userid),
67 PRIMARY KEY(id)
68 )TYPE=MYISAM");
69
70                 //
71                 // --- SETTINGS ---
72                 //
73                 // Minimum points to double
74                 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_min FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 100.00000");
75                 // Maximum points to double
76                 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_max FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 10000.00000");
77                 // Points left on users account after doubling
78                 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_left BIGINT(20) UNSIGNED NOT NULL DEFAULT 1000");
79                 // Charge for doubling points which goes to the webmaster (shreddered in fact!)
80                 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_charge FLOAT(7,5) UNSIGNED NOT NULL DEFAULT 0.03000");
81                 // Referal percents
82                 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_ref FLOAT(7,5) UNSIGNED NOT NULL DEFAULT 0.02000");
83                 // Shall I use the jackpot to take points from? (Y/N, default=Y)
84                 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_jackpot ENUM('Y','N') NOT NULL DEFAULT 'Y'");
85                 // A user account to take points from (default: 0->none)
86                 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_uid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
87                 // Total payed out points from your doublers
88                 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_points FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
89                 // Sending mode of mails (immediately/daily reset)
90                 // --> This also means who fast the doubled points will be payed out!
91                 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_send_mode ENUM('DIRECT','RESET') NOT NULL DEFAULT 'DIRECT'");
92                 // Timeout for entries to be purged (default: one week)
93                 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_timeout BIGINT(20) UNSIGNED NOT NULL DEFAULT ".(getConfig('one_day')*7)."");
94                 // Number of newest entries to display
95                 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_display_new TINYINT(3) UNSIGNED NOT NULL DEFAULT 10");
96                 // Number of entries which will be payed out soon
97                 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_display_pay TINYINT(3) UNSIGNED NOT NULL DEFAULT 10");
98                 // Number of entries which are already payed out
99                 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_display_old TINYINT(3) UNSIGNED NOT NULL DEFAULT 10");
100                 // Points used by every member
101                 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_user_data` ADD doubler_points FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
102                 // Counter for usage of the doubler
103                 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_counter BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
104
105                 //
106                 // --- MENU SYSTEMS ---
107                 //
108                 // Admin menu
109                 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('doubler', NULL, '{!POINTS!}-Verdoppler','Einstellungen und Eintr&auml;ge auflisten.', 4)");
110                 ADD_EXT_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)");
111                 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('doubler','config_doubler','Einstellungen','Prozentuale Geb&uuml;hr usw. einstellen.', 2)");
112
113                 // Guest menu (informations / default doubler link)
114                 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_guest_menu` (`action`,`what`,`title`,`sort`,`visible`,`locked`) VALUES ('main','doubler','Verdoppeln!',3,'Y','Y')");
115
116                 // Member menu
117                 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_member_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('main','doubler','Verdoppeln!','Y','Y',7)");
118                 break;
119
120         case 'remove': // Do stuff when removing extension
121                 // SQL commands to run
122                 ADD_EXT_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_doubler`");
123                 ADD_EXT_SQL("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_admin_menu` WHERE `action`='doubler'");
124                 ADD_EXT_SQL("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_guest_menu` WHERE `what`='doubler'");
125                 ADD_EXT_SQL("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_member_menu` WHERE `what`='doubler'");
126                 break;
127
128         case 'activate': // Do stuff when admin activates this extension
129                 // SQL commands to run
130                 ADD_EXT_SQL("UPDATE `{!_MYSQL_PREFIX!}_member_menu` SET `visible`='Y', `locked`='N' WHERE `what`='doubler' LIMIT 1");
131                 ADD_EXT_SQL("UPDATE `{!_MYSQL_PREFIX!}_guest_menu` SET `visible`='Y', `locked`='N' WHERE `what`='doubler' LIMIT 1");
132                 ADD_EXT_SQL("UPDATE `{!_MYSQL_PREFIX!}_mod_reg` SET `locked`='N', `hidden`='N', `admin_only`='N', `mem_only`='N' WHERE `module`='doubler' LIMIT 1");
133                 break;
134
135         case 'deactivate': // Do stuff when admin deactivates this extension
136                 // SQL commands to run
137                 ADD_EXT_SQL("UPDATE `{!_MYSQL_PREFIX!}_member_menu` SET `visible`='N', `locked`='Y' WHERE `what`='doubler' LIMIT 1");
138                 ADD_EXT_SQL("UPDATE `{!_MYSQL_PREFIX!}_guest_menu` SET `visible`='N', `locked`='Y' WHERE `what`='doubler' LIMIT 1");
139                 ADD_EXT_SQL("UPDATE `{!_MYSQL_PREFIX!}_mod_reg` SET `locked`='Y' WHERE `module`='doubler' LIMIT 1");
140                 break;
141
142         case 'update': // Update an extension
143                 switch ($EXT_VER)
144                 {
145                         case '0.0.1': // SQL queries for v0.0.1
146                                 // Update notes (these will be set as task text!)
147                                 EXT_SET_UPDATE_NOTES("Problem mit User-ID behoben!");
148                                 break;
149
150                         case '0.0.2': // SQL queries for v0.0.2
151                                 // Total used points
152                                 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_used FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
153
154                                 // Update notes (these will be set as task text!)
155                                 EXT_SET_UPDATE_NOTES("Geb&uuml;hr wird vom Verdoppler-Pott abgezogen.");
156                                 break;
157
158                         case '0.0.3': // SQL queries for v0.0.3
159                                 // Update notes (these will be set as task text!)
160                                 EXT_SET_UPDATE_NOTES("Drei SQL-Fehler beseitigt.");
161                                 break;
162
163                         case '0.0.4': // SQL queries for v0.0.4
164                                 // Shall I use the doubler's account to take points from? (Y/N, default=Y)
165                                 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_own ENUM('Y','N') NOT NULL DEFAULT 'Y'");
166
167                                 // Update notes (these will be set as task text!)
168                                 EXT_SET_UPDATE_NOTES(POINTS."-Guthaben des Verdopplers kann optional nicht mit einbezogen werden.");
169                                 break;
170
171                                 case '0.0.5': // SQL queries for v0.0.5
172                                         // Update notes (these will be set as task text!)
173                                         EXT_SET_UPDATE_NOTES("Counter-Stand und noch zum Verdoppeln &uuml;brige {!POINTS!} in Templates eingebunden. Auflistung in Admin-Bereich komplettiert.");
174                                         break;
175
176                                 case '0.0.6': // SQL queries for v0.0.6
177                                         ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_max_sent TINYINT(3) UNSIGNED NOT NULL DEFAULT 1");
178                                         ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_group_sent TINYINT(3) UNSIGNED NOT NULL DEFAULT 1");
179                                         ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_sent_all ENUM('Y','N') NOT NULL DEFAULT 'Y'");
180
181                                         // Update notes (these will be set as task text!)
182                                         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!");
183                                         break;
184
185                                 case '0.0.7': // SQL queries for v0.0.7
186                                         // Update notes (these will be set as task text!)
187                                         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.");
188                                         break;
189
190                                 case '0.0.8': // SQL queries for v0.0.8
191                                         // Update notes (these will be set as task text!)
192                                         EXT_SET_UPDATE_NOTES("Bitte verschieben Sie die doubler-Templates (Ordner: {!PATH!}/templates/".getLanguage()."/html/) in den neuen Order doubler!");
193                                         break;
194
195                                 case '0.0.9': // SQL queries for v0.0.9
196                                         // Update notes (these will be set as task text!)
197                                         EXT_SET_UPDATE_NOTES("Abspeichern von Einstellungen repariert.");
198                                         break;
199
200                                 case '0.1.0': // SQL queries for v0.2.1
201                                         // Update notes (these will be set as task text!)
202                                         EXT_SET_UPDATE_NOTES("Vorbereitung auf die neue Mediendaten v0.0.4.");
203                                         break;
204
205                                 case '0.1.1': // SQL queries for v0.1.1
206                                         // Update notes (these will be set as task text!)
207                                         EXT_SET_UPDATE_NOTES("Zwei SQL-Fehler in <strong>inc/doubler_send.php</strong> beseitigt.");
208                                         break;
209
210                                 case '0.1.2': // SQL queries for v0.1.2
211                                         // Update notes (these will be set as task text!)
212                                         EXT_SET_UPDATE_NOTES("Sicherheitsupdate f&uuml;r die Include-Befehle.");
213                                         break;
214
215                                 case '0.1.3': // SQL queries for v0.1.3
216                                         // Update notes (these will be set as task text!)
217                                         EXT_SET_UPDATE_NOTES("De-/Aktivieren des mit dieser Erweiterung verkn&uuml;pften Modules eingebunden.");
218                                         break;
219
220                                 case '0.1.4': // SQL queries for v0.1.4
221                                         ADD_EXT_SQL("UPDATE `{!_MYSQL_PREFIX!}_member_menu` SET `action`='extras', `sort`='4' WHERE `what`='doubler' LIMIT 1");
222
223                                         // Update notes (these will be set as task text!)
224                                         EXT_SET_UPDATE_NOTES("Mitgliedsmen&uuml; komplett umgebaut.");
225                                         break;
226
227                                 case '0.1.5': // SQL queries for v0.1.5
228                                         // Update notes (these will be set as task text!)
229                                         EXT_SET_UPDATE_NOTES("Hash-Erstellung von <strong>md5()</strong> auf bessere Funktion <strong>generateHash()</strong> umgestellt.");
230                                         break;
231
232                                 case '0.1.6': // SQL queries for v0.1.6
233                                         // Update notes (these will be set as task text!)
234                                         EXT_SET_UPDATE_NOTES("Fehlerhinweis bei deaktivierter Erweiterung verbessert.");
235                                         break;
236                 }
237                 break;
238
239                                 case 'modify': // When the extension got modified
240                                         break;
241
242                                 case 'test': // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
243                                         break;
244
245                                 default: // Do stuff when extension is loaded
246                                         if ((isResetModeEnabled()) && (getConfig('doubler_send_mode') == "RESET")) {
247                                                 // So let's check for points
248                                                 ADD_INC_TO_POOL(sprintf("%sinc/doubler_send.php", constant('PATH')));
249                                         }
250                                         break;
251 }
252
253 //
254 ?>