2 /************************************************************************
3 * MXChange v0.2.1 Start: 02/03/2005 *
4 * ================ Last change: 02/03/2005 *
6 * -------------------------------------------------------------------- *
7 * File : ext-doubler.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Double points *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Punkte verdoppeln *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
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 *
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. *
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. *
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, *
37 ************************************************************************/
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
41 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
46 EXT_SET_VERSION('0.1.6');
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'));
51 switch ($EXT_LOAD_MODE)
53 case 'register': // Do stuff when installation is running (modules.php?module=admin&action=login is called)
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',
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");
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");
106 // --- MENU SYSTEMS ---
109 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('doubler', NULL, '{!POINTS!}-Verdoppler','Einstellungen und Einträge auflisten.', 4)");
110 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('doubler','list_doubler','Auflisten','Einträ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ühr usw. einstellen.', 2)");
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')");
117 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_member_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('main','doubler','Verdoppeln!','Y','Y',7)");
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'");
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");
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");
142 case 'update': // Update an extension
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!");
150 case '0.0.2': // SQL queries for v0.0.2
152 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_used FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
154 // Update notes (these will be set as task text!)
155 EXT_SET_UPDATE_NOTES("Gebühr wird vom Verdoppler-Pott abgezogen.");
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.");
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'");
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.");
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 übrige {!POINTS!} in Templates eingebunden. Auflistung in Admin-Bereich komplettiert.");
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'");
181 // Update notes (these will be set as task text!)
182 EXT_SET_UPDATE_NOTES("Gebü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 überflüssig geworden. Bitte löschen Sie dies!");
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ö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.");
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!");
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.");
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.");
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.");
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ür die Include-Befehle.");
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üpften Modules eingebunden.");
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");
223 // Update notes (these will be set as task text!)
224 EXT_SET_UPDATE_NOTES("Mitgliedsmenü komplett umgebaut.");
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.");
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.");
239 case 'modify': // When the extension got modified
242 case 'test': // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
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')));