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 * -------------------------------------------------------------------- *
15 * Copyright (c) 2003 - 2009 by Roland Haeder *
16 * Copyright (c) 2009 - 2011 by Mailer Developer Team *
17 * For more information visit: http://www.mxchange.org *
19 * This program is free software; you can redistribute it and/or modify *
20 * it under the terms of the GNU General Public License as published by *
21 * the Free Software Foundation; either version 2 of the License, or *
22 * (at your option) any later version. *
24 * This program is distributed in the hope that it will be useful, *
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
27 * GNU General Public License for more details. *
29 * You should have received a copy of the GNU General Public License *
30 * along with this program; if not, write to the Free Software *
31 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
33 ************************************************************************/
35 // Some security stuff...
36 if (!defined('__SECURITY')) {
41 setThisExtensionVersion('0.0.0');
43 // Version history array (add more with , '0.1' and so on)
44 setExtensionVersionHistory(array('0.0.0'));
46 // This extension is in development (non-productive)
47 enableExtensionProductive(false);
49 switch (getExtensionMode()) {
50 case 'register': // Do stuff when installtion is running
51 // SQL commands to run
52 addConfigAddSql('engine_free_transfers', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
53 addConfigAddSql('engine_start_transfers', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 10000');
54 addConfigAddSql('engine_daily_transfers', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 100');
55 addConfigAddSql('engine_start_costs', 'FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 5.00000');
56 addConfigAddSql('engine_mode', "ENUM('SERVER','CLIENT') NOT NULL DEFAULT 'SERVER'");
57 addConfigAddSql('engine_always_free', "ENUM('Y','N') NOT NULL DEFAULT 'N'");
58 addConfigAddSql('engine_rates', 'LONGTEXT');
59 addConfigAddSql('engine_rate_multiOA', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 10000');
60 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");
63 addDropTableSql('engine_accounts');
64 addCreateTableSql('engine_accounts', "
65 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
66 `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
67 `password` VARCHAR(255) NOT NULL DEFAULT '',
68 `status` ENUM('ACTIVE','LOCKED','UNCONFIRMED') NOT NULL DEFAULT 'UNCONFIRMED',
69 `query_amount` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
70 `query_free` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
71 `query_used` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
72 `created` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
73 `last_changed` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
76 'Accounts for the game engine');
79 addDropTableSql('engine_safe');
80 addCreateTableSql('engine_safe', "
81 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
82 `engine_userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
83 `password` VARCHAR(255) NOT NULL DEFAULT '',
84 `points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
85 INDEX (`engine_userid`),
87 'Safes for engine account');
90 addDropTableSql('engine_log');
91 addCreateTableSql('engine_log', "
92 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
93 `engine_userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
94 `cmd_type` VARCHAR(255) NOT NULL DEFAULT 'status',
95 `cmd_code` VARCHAR(255) NOT NULL DEFAULT 'status',
96 `log_level` TINYINT(4) UNSIGNED NOT NULL DEFAULT 0,
97 `points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
98 `reason` LONGTEXT NOT NULL,
99 `remote_addr` VARCHAR(15) NOT NULL DEFAULT '0.0.0.0',
100 `timemark` VARCHAR(10) NOT NULL DEFAULT '',
101 KEY (`engine_userid`),
103 'Logged engine account accesses');
106 addDropTableSql('engine_urls');
107 addCreateTableSql('engine_urls',"
108 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
109 `title` VARCHAR(255) NOT NULL DEFAULT '',
111 `var1` VARCHAR(20) NOT NULL DEFAULT 'userid',
112 `val1` VARCHAR(10) NOT NULL DEFAULT '%userid%',
113 `var2` VARCHAR(20) NOT NULL DEFAULT 'pass',
114 `val2` VARCHAR(10) NOT NULL DEFAULT '%pass%',
115 `var3` VARCHAR(20) NOT NULL DEFAULT 'cmd',
116 `val3` VARCHAR(10) NOT NULL DEFAULT '%cmd%',
117 `var4` VARCHAR(20) NOT NULL DEFAULT 'points',
118 `val4` VARCHAR(10) NOT NULL DEFAULT '%points%',
119 `var5` VARCHAR(20) NOT NULL DEFAULT 'reason',
120 `val5` VARCHAR(10) NOT NULL DEFAULT '%reason%',
125 addAdminMenuSql('engine', NULL, 'Game-Engine', 'Einstellungen an der Game-Engine (Export-Account) vornehmen, Export-URLs einstellen.', 8);
126 addAdminMenuSql('engine', 'config_engine', 'Einstellungen', 'Einstellungen an der Game-Engine (Export-Account) vornehmen.', 1);
127 addAdminMenuSql('engine', 'engine_urls', 'Export-URLs', 'Export-URLs hinzufügen, bearbeiten oder löschen.', 2);
128 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);
129 addAdminMenuSql('engine', 'edit_engine', 'Accounts editieren', 'Editieren Sie hier bestehende Export-Accounts (derzeit nur das Engine-Passwort).', 4);
130 addAdminMenuSql('engine', 'lock_engine', 'Accounts ent-/sperren', 'Sperren Sie freigegebene Export-Accounts bei Regelverstoss, etc. oder entsperren Sie diese wieder.', 5);
131 addAdminMenuSql('engine', 'del_engine', 'Accounts löschen', 'Löschen Sie bestehende Export-Accounts, egal welcher Status sie haben.', 6);
132 addAdminMenuSql('engine', 'add_engine', 'Anfragen aufbuchen', 'Buchen Sie dem Export-Account weitere Anfragen auf (query_amount).', 7);
133 addAdminMenuSql('engine', 'sub_engine', 'Anfragen abziehen', 'Ziehen Sie dem Export-Account Anfragen ab (query_used).', 8);
136 addGuestMenuSql('main', 'engine', 'Export-Account', 'Y', 'Y', 10);
139 addMemberMenuSql('main', 'engine', 'Export-Account', 'Y', 'Y', 4);
142 case 'remove': // Do stuff when removing extension
143 // SQL commands to run
144 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='engine'");
145 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE `what`='engine' LIMIT 1");
146 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what`='engine' LIMIT 1");
147 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_mod_reg` WHERE `module` LIKE 'engine%'");
149 // Remove tables as well
150 addDropTableSql('engine_accounts');
151 addDropTableSql('engine_safe');
152 addDropTableSql('engine_log');
153 addDropTableSql('engine_urls');
156 case 'activate': // Do stuff when admin activates this extension
157 // SQL commands to run
158 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `visible`='Y', `locked`='N' WHERE `what`='engine' LIMIT 1");
159 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y', `locked`='N' WHERE `what`='engine' LIMIT 1");
160 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_mod_reg` SET `locked`='N', `hidden`='N', `admin_only`='N', `mem_only`='N' WHERE `module` LIKE 'engine%'");
163 case 'deactivate': // Do stuff when admin deactivates this extension
164 // SQL commands to run
165 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `visible`='Y', `locked`='Y' WHERE `what`='engine' LIMIT 1");
166 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y', `locked`='Y' WHERE `what`='engine' LIMIT 1");
167 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_mod_reg` SET `locked`='Y' WHERE `module` LIKE 'engine%'");
170 case 'update': // Update an extension
171 switch (getCurrentExtensionVersion()) {
172 case '0.0.1': // SQL queries for v0.0.1
175 // Update notes (these will be set as task text!)
176 setExtensionUpdateNotes('');
181 case 'modify': // When the extension got modified
184 case 'test': // For testing purposes
187 case 'init': // Do stuff when extension is initialized
190 default: // Unknown extension mode
191 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));