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 - 2009 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')) {
45 setThisExtensionVersion('0.1.6');
47 // Version history array (add more with , '0.1.0' and so on)
48 setExtensionVersionHistory(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 switch (getExtensionMode()) {
51 case 'register': // Do stuff when installation is running (modules.php?module=admin is called)
53 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_doubler`");
54 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_doubler` (
55 id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
56 userid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
57 refid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
58 points FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
59 remote_ip VARCHAR(15) NOT NULL DEFAULT '0.0.0.0',
60 timemark VARCHAR(10) NOT NULL DEFAULT '',
61 completed ENUM('Y','N') NOT NULL DEFAULT 'N',
62 is_ref ENUM('Y','N') NOT NULL DEFAULT 'N',
71 // Minimum points to double
72 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_min FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 100.00000");
73 // Maximum points to double
74 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_max FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 10000.00000");
75 // Points left on users account after doubling
76 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_left BIGINT(20) UNSIGNED NOT NULL DEFAULT 1000");
77 // Charge for doubling points which goes to the webmaster (shreddered in fact!)
78 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_charge FLOAT(7,5) UNSIGNED NOT NULL DEFAULT 0.03000");
80 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_ref FLOAT(7,5) UNSIGNED NOT NULL DEFAULT 0.02000");
81 // Shall I use the jackpot to take points from? (Y/N, default=Y)
82 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_jackpot ENUM('Y','N') NOT NULL DEFAULT 'Y'");
83 // A user account to take points from (default: 0->none)
84 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_userid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
85 // Total payed out points from your doublers
86 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_points FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
87 // Sending mode of mails (immediately/daily reset)
88 // --> This also means who fast the doubled points will be payed out!
89 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_send_mode ENUM('DIRECT','RESET') NOT NULL DEFAULT 'DIRECT'");
90 // Timeout for entries to be purged (default: one week)
91 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_timeout BIGINT(20) UNSIGNED NOT NULL DEFAULT ".(getConfig('ONE_DAY')*7)."");
92 // Number of newest entries to display
93 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_display_new TINYINT(3) UNSIGNED NOT NULL DEFAULT 10");
94 // Number of entries which will be payed out soon
95 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_display_pay TINYINT(3) UNSIGNED NOT NULL DEFAULT 10");
96 // Number of entries which are already payed out
97 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_display_old TINYINT(3) UNSIGNED NOT NULL DEFAULT 10");
98 // Points used by every member
99 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD doubler_points FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
100 // Counter for usage of the doubler
101 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_counter BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
104 // --- MENU SYSTEMS ---
107 addAdminMenuSql('doubler', NULL, '{OPEN_CONFIG}POINTS{CLOSE_CONFIG}-Verdoppler','Einstellungen und Einträge auflisten.', 4);
108 addAdminMenuSql('doubler','list_doubler','Auflisten','Einträge aus der Verdiensttabelle auflisten', 1);
109 addAdminMenuSql('doubler','config_doubler','Einstellungen','Prozentuale Gebühr usw. einstellen.', 2);
111 // Guest menu (informations / default doubler link)
112 addGuestMenuSql('main','doubler','Verdoppeln!','N','Y',3);
115 addMemberMenuSql('main','doubler','Verdoppeln!','N','Y',7);
118 case 'remove': // Do stuff when removing extension
119 // SQL commands to run
120 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_doubler`");
121 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='doubler'");
122 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE `what`='doubler'");
123 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what`='doubler'");
126 case 'activate': // Do stuff when admin activates this extension
127 // SQL commands to run
128 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y', `locked`='N' WHERE `what`='doubler' LIMIT 1");
129 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `visible`='Y', `locked`='N' WHERE `what`='doubler' LIMIT 1");
130 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_mod_reg` SET `locked`='N', `hidden`='N', `admin_only`='N', `mem_only`='N' WHERE `module`='doubler' LIMIT 1");
133 case 'deactivate': // Do stuff when admin deactivates this extension
134 // SQL commands to run
135 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='N', `locked`='Y' WHERE `what`='doubler' LIMIT 1");
136 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `visible`='N', `locked`='Y' WHERE `what`='doubler' LIMIT 1");
137 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_mod_reg` SET `locked`='Y' WHERE `module`='doubler' LIMIT 1");
140 case 'update': // Update an extension
141 switch (getCurrentExtensionVersion()) {
142 case '0.0.1': // SQL queries for v0.0.1
143 // Update notes (these will be set as task text!)
144 setExtensionUpdateNotes("Problem mit User-ID behoben!");
147 case '0.0.2': // SQL queries for v0.0.2
149 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_used FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
151 // Update notes (these will be set as task text!)
152 setExtensionUpdateNotes("Gebühr wird vom Verdoppler-Pott abgezogen.");
155 case '0.0.3': // SQL queries for v0.0.3
156 // Update notes (these will be set as task text!)
157 setExtensionUpdateNotes("Drei SQL-Fehler beseitigt.");
160 case '0.0.4': // SQL queries for v0.0.4
161 // Shall I use the doubler's account to take points from? (Y/N, default=Y)
162 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_own ENUM('Y','N') NOT NULL DEFAULT 'Y'");
164 // Update notes (these will be set as task text!)
165 setExtensionUpdateNotes("{?POINTS?}-Guthaben des Verdopplers kann optional nicht mit einbezogen werden.");
168 case '0.0.5': // SQL queries for v0.0.5
169 // Update notes (these will be set as task text!)
170 setExtensionUpdateNotes("Counter-Stand und noch zum Verdoppeln übrige {?POINTS?} in Templates eingebunden. Auflistung in Admin-Bereich komplettiert.");
173 case '0.0.6': // SQL queries for v0.0.6
174 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_max_sent TINYINT(3) UNSIGNED NOT NULL DEFAULT 1");
175 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_group_sent TINYINT(3) UNSIGNED NOT NULL DEFAULT 1");
176 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_sent_all ENUM('Y','N') NOT NULL DEFAULT 'Y'");
178 // Update notes (these will be set as task text!)
179 setExtensionUpdateNotes("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!");
182 case '0.0.7': // SQL queries for v0.0.7
183 // Update notes (these will be set as task text!)
184 setExtensionUpdateNotes("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.");
187 case '0.0.8': // SQL queries for v0.0.8
188 // Update notes (these will be set as task text!)
189 setExtensionUpdateNotes("Bitte verschieben Sie die doubler-Templates (Ordner: {?PATH?}/templates/".getLanguage()."/html/) in den neuen Order doubler!");
192 case '0.0.9': // SQL queries for v0.0.9
193 // Update notes (these will be set as task text!)
194 setExtensionUpdateNotes("Abspeichern von Einstellungen repariert.");
197 case '0.1.0': // SQL queries for v0.2.1
198 // Update notes (these will be set as task text!)
199 setExtensionUpdateNotes("Vorbereitung auf die neue Mediendaten v0.0.4.");
202 case '0.1.1': // SQL queries for v0.1.1
203 // Update notes (these will be set as task text!)
204 setExtensionUpdateNotes("Zwei SQL-Fehler in <strong>inc/doubler_send.php</strong> beseitigt.");
207 case '0.1.2': // SQL queries for v0.1.2
208 // Update notes (these will be set as task text!)
209 setExtensionUpdateNotes("Sicherheitsupdate für die Include-Befehle.");
212 case '0.1.3': // SQL queries for v0.1.3
213 // Update notes (these will be set as task text!)
214 setExtensionUpdateNotes("De-/Aktivieren des mit dieser Erweiterung verknüpften Modules eingebunden.");
217 case '0.1.4': // SQL queries for v0.1.4
218 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `action`='extras', `sort`=4 WHERE `what`='doubler' LIMIT 1");
220 // Update notes (these will be set as task text!)
221 setExtensionUpdateNotes("Mitgliedsmenü komplett umgebaut.");
224 case '0.1.5': // SQL queries for v0.1.5
225 // Update notes (these will be set as task text!)
226 setExtensionUpdateNotes("Hash-Erstellung von <strong>md5()</strong> auf bessere Funktion <strong>generateHash()</strong> umgestellt.");
229 case '0.1.6': // SQL queries for v0.1.6
230 // Update notes (these will be set as task text!)
231 setExtensionUpdateNotes("Fehlerhinweis bei deaktivierter Erweiterung verbessert.");
236 case 'modify': // When the extension got modified
239 case 'test': // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
242 case 'init': // Do stuff when extension is initialized
245 default: // Unknown extension mode
246 DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown extension mode %s detected.", getExtensionMode()));