2 /************************************************************************
3 * Mailer-Project 0.2.1-FINAL Start: 09/25/2004 *
4 * ========================== Last change: 09/25/2004 *
6 * -------------------------------------------------------------------- *
7 * File : ext-engine.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Game engine system *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Game-Engine System *
12 * -------------------------------------------------------------------- *
14 * -------------------------------------------------------------------- *
17 * $Tag:: 0.2.1-FINAL $ *
19 * -------------------------------------------------------------------- *
20 * Copyright (c) 2003 - 2009 by Roland Haeder *
21 * Copyright (c) 2009 - 2011 by Mailer Developer Team *
22 * For more information visit: http://www.mxchange.org *
24 * This program is free software; you can redistribute it and/or modify *
25 * it under the terms of the GNU General Public License as published by *
26 * the Free Software Foundation; either version 2 of the License, or *
27 * (at your option) any later version. *
29 * This program is distributed in the hope that it will be useful, *
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
32 * GNU General Public License for more details. *
34 * You should have received a copy of the GNU General Public License *
35 * along with this program; if not, write to the Free Software *
36 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
38 ************************************************************************/
40 // Some security stuff...
41 if (!defined('__SECURITY')) {
46 setThisExtensionVersion('0.0.0');
48 // Version history array (add more with , '0.1' and so on)
49 setExtensionVersionHistory(array('0.0.0'));
51 // This extension is in development (non-productive)
52 enableExtensionProductive(false);
54 switch (getExtensionMode()) {
55 case 'register': // Do stuff when installtion is running
56 // SQL commands to run
57 addConfigAddSql('engine_free_transfers', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
58 addConfigAddSql('engine_start_transfers', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 10000');
59 addConfigAddSql('engine_daily_transfers', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 100');
60 addConfigAddSql('engine_start_costs', 'FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 5.00000');
61 addConfigAddSql('engine_mode', "ENUM('SERVER','CLIENT') NOT NULL DEFAULT 'SERVER'");
62 addConfigAddSql('engine_always_free', "ENUM('Y','N') NOT NULL DEFAULT 'N'");
63 addConfigAddSql('engine_rates', 'LONGTEXT');
64 addConfigAddSql('engine_rate_multiOA', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 10000');
65 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_config` SET `engine_rates`='1:2:3:4:5:10:20:30:40:50:100:200:300:400:500:1000' WHERE `config`=0 LIMIT 1");
68 addDropTableSql('engine_accounts');
69 addCreateTableSql('engine_accounts', "
70 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
71 `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
72 `password` VARCHAR(255) NOT NULL DEFAULT '',
73 `status` ENUM('ACTIVE','LOCKED','UNCONFIRMED') NOT NULL DEFAULT 'UNCONFIRMED',
74 `query_amount` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
75 `query_free` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
76 `query_used` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
77 `created` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
78 `last_changed` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
81 'Accounts for the game engine');
84 addDropTableSql('engine_safe');
85 addCreateTableSql('engine_safe', "
86 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
87 `engine_userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
88 `password` VARCHAR(255) NOT NULL DEFAULT '',
89 `points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
90 INDEX (`engine_userid`),
92 'Safes for engine account');
95 addDropTableSql('engine_log');
96 addCreateTableSql('engine_log', "
97 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
98 `engine_userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
99 `cmd_type` VARCHAR(255) NOT NULL DEFAULT 'status',
100 `cmd_code` VARCHAR(255) NOT NULL DEFAULT 'status',
101 `log_level` TINYINT(4) UNSIGNED NOT NULL DEFAULT 0,
102 `points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
103 `reason` LONGTEXT NOT NULL,
104 `remote_addr` VARCHAR(15) NOT NULL DEFAULT '0.0.0.0',
105 `timemark` VARCHAR(10) NOT NULL DEFAULT '',
106 KEY (`engine_userid`),
108 'Logged engine account accesses');
111 addDropTableSql('engine_urls');
112 addCreateTableSql('engine_urls',"
113 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
114 `title` VARCHAR(255) NOT NULL DEFAULT '',
116 `var1` VARCHAR(20) NOT NULL DEFAULT 'userid',
117 `val1` VARCHAR(10) NOT NULL DEFAULT '%userid%',
118 `var2` VARCHAR(20) NOT NULL DEFAULT 'pass',
119 `val2` VARCHAR(10) NOT NULL DEFAULT '%pass%',
120 `var3` VARCHAR(20) NOT NULL DEFAULT 'cmd',
121 `val3` VARCHAR(10) NOT NULL DEFAULT '%cmd%',
122 `var4` VARCHAR(20) NOT NULL DEFAULT 'points',
123 `val4` VARCHAR(10) NOT NULL DEFAULT '%points%',
124 `var5` VARCHAR(20) NOT NULL DEFAULT 'reason',
125 `val5` VARCHAR(10) NOT NULL DEFAULT '%reason%',
130 addAdminMenuSql('engine', NULL, 'Game-Engine', 'Einstellungen an der Game-Engine (Export-Account) vornehmen, Export-URLs einstellen.', 8);
131 addAdminMenuSql('engine', 'config_engine', 'Einstellungen', 'Einstellungen an der Game-Engine (Export-Account) vornehmen.', 1);
132 addAdminMenuSql('engine', 'engine_urls', 'Export-URLs', 'Export-URLs hinzufügen, bearbeiten oder löschen.', 2);
133 addAdminMenuSql('engine', 'unlock_engine', 'Accounts freigeben', 'Geben Sie hier neu angemeldete Export-Account für die Game-Engine frei. Erst dann werden die von Ihnen eingestellten "Anfragen bei Freischaltung" aufgebucht.', 3);
134 addAdminMenuSql('engine', 'edit_engine', 'Accounts editieren', 'Editieren Sie hier bestehende Export-Accounts (derzeit nur das Engine-Passwort).', 4);
135 addAdminMenuSql('engine', 'lock_engine', 'Accounts ent-/sperren', 'Sperren Sie freigegebene Export-Accounts bei Regelverstoss, etc. oder entsperren Sie diese wieder.', 5);
136 addAdminMenuSql('engine', 'del_engine', 'Accounts löschen', 'Löschen Sie bestehende Export-Accounts, egal welcher Status sie haben.', 6);
137 addAdminMenuSql('engine', 'add_engine', 'Anfragen aufbuchen', 'Buchen Sie dem Export-Account weitere Anfragen auf (query_amount).', 7);
138 addAdminMenuSql('engine', 'sub_engine', 'Anfragen abziehen', 'Ziehen Sie dem Export-Account Anfragen ab (query_used).', 8);
141 addGuestMenuSql('main', 'engine', 'Export-Account', 'Y', 'Y', 10);
144 addMemberMenuSql('main', 'engine', 'Export-Account', 'Y', 'Y', 4);
147 case 'remove': // Do stuff when removing extension
148 // SQL commands to run
149 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='engine'");
150 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE `what`='engine' LIMIT 1");
151 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what`='engine' LIMIT 1");
152 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_mod_reg` WHERE `module` LIKE 'engine%'");
154 // Remove tables as well
155 addDropTableSql('engine_accounts');
156 addDropTableSql('engine_safe');
157 addDropTableSql('engine_log');
158 addDropTableSql('engine_urls');
161 case 'activate': // Do stuff when admin activates this extension
162 // SQL commands to run
163 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `visible`='Y', `locked`='N' WHERE `what`='engine' LIMIT 1");
164 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y', `locked`='N' WHERE `what`='engine' LIMIT 1");
165 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_mod_reg` SET `locked`='N', `hidden`='N', `admin_only`='N', `mem_only`='N' WHERE `module` LIKE 'engine%'");
168 case 'deactivate': // Do stuff when admin deactivates this extension
169 // SQL commands to run
170 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `visible`='Y', `locked`='Y' WHERE `what`='engine' LIMIT 1");
171 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y', `locked`='Y' WHERE `what`='engine' LIMIT 1");
172 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_mod_reg` SET `locked`='Y' WHERE `module` LIKE 'engine%'");
175 case 'update': // Update an extension
176 switch (getCurrentExtensionVersion()) {
177 case '0.0.1': // SQL queries for v0.0.1
180 // Update notes (these will be set as task text!)
181 setExtensionUpdateNotes('');
186 case 'modify': // When the extension got modified
189 case 'test': // For testing purposes
192 case 'init': // Do stuff when extension is initialized
195 default: // Unknown extension mode
196 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));