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 * -------------------------------------------------------------------- *
14 * -------------------------------------------------------------------- *
15 * Copyright (c) 2003 - 2008 by Roland Haeder *
16 * For more information visit: http://www.mxchange.org *
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. *
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. *
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, *
32 ************************************************************************/
34 // Some security stuff...
35 if (!defined('__SECURITY')) {
36 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
41 EXT_SET_VERSION("0.1.6");
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"));
46 switch ($EXT_LOAD_MODE)
48 case "register": // Do stuff when installation is running (modules.php?module=admin&action=login is called)
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',
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");
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");
101 // --- MENU SYSTEMS ---
104 ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('doubler', NULL, '{!POINTS!}-Verdoppler','Einstellungen und Einträge auflisten.', 4)");
105 ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('doubler','list_doubler','Auflisten','Einträ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ühr usw. einstellen.', 2)");
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')");
112 ADD_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_member_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('main','doubler','Verdoppeln!','Y','Y',7)");
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");
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");
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");
137 case "update": // Update an extension
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!");
145 case "0.0.2": // SQL queries for v0.0.2
147 ADD_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD doubler_used FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
149 // Update notes (these will be set as task text!)
150 EXT_SET_UPDATE_NOTES("Gebühr wird vom Verdoppler-Pott abgezogen.");
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.");
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'");
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.");
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 übrige {!POINTS!} in Templates eingebunden. Auflistung in Admin-Bereich komplettiert.");
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'");
176 // Update notes (these will be set as task text!)
177 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!");
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ö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.");
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!");
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.");
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.");
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.");
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ür die Include-Befehle.");
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üpften Modules eingebunden.");
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");
218 // Update notes (these will be set as task text!)
219 EXT_SET_UPDATE_NOTES("Mitgliedsmenü komplett umgebaut.");
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.");
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.");
234 case "modify": // When the extension got modified
237 case "test": // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
240 default: // Do stuff when extension is loaded
241 if ((isResetModeEnabled()) && (getConfig('doubler_send_mode') == "RESET")) {
242 // So let's check for points
243 $INC_POOL[] = sprintf("%sinc/doubler_send.php", constant('PATH'));