45fa47f6cf8936e3a6e146e99a333c6a3e78c8b9
[mailer.git] / 0.2.1 / inc / extensions / ext-transfer.php
1 <?php\r
2 /************************************************************************\r
3  * MXChange v0.2.1                                    Start: 10/07/2004 *\r
4  * ================                             Last change: 07/08/2007 *\r
5  *                                                                      *\r
6  * -------------------------------------------------------------------- *\r
7  * File              : ext-transfer.php                                 *\r
8  * -------------------------------------------------------------------- *\r
9  * Short description : Point transfers between members                  *\r
10  * -------------------------------------------------------------------- *\r
11  * Kurzbeschreibung  : Punktetransfers zwischen Mitgliedern             *\r
12  * -------------------------------------------------------------------- *\r
13  *                                                                      *\r
14  * -------------------------------------------------------------------- *\r
15  * Copyright (c) 2003 - 2007 by Roland Haeder                           *\r
16  * For more information visit: http://www.mxchange.org                  *\r
17  *                                                                      *\r
18  * This program is free software; you can redistribute it and/or modify *\r
19  * it under the terms of the GNU General Public License as published by *\r
20  * the Free Software Foundation; either version 2 of the License, or    *\r
21  * (at your option) any later version.                                  *\r
22  *                                                                      *\r
23  * This program is distributed in the hope that it will be useful,      *\r
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *\r
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *\r
26  * GNU General Public License for more details.                         *\r
27  *                                                                      *\r
28  * You should have received a copy of the GNU General Public License    *\r
29  * along with this program; if not, write to the Free Software          *\r
30  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *\r
31  * MA  02110-1301  USA                                                  *\r
32  ************************************************************************/\r
33 \r
34 // Some security stuff...\r
35 if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])))\r
36 {\r
37         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4)."/security.php";\r
38         require($INC);\r
39 }\r
40 \r
41 // Version number\r
42 $EXT_VERSION = "0.2.9";\r
43 \r
44 // Auto-set extension version\r
45 if (empty($EXT_VER)) $EXT_VER = $EXT_VERSION;\r
46 \r
47 // Version history array (add more with , "0.1" and so on)\r
48 $EXT_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", "0.1.7", "0.1.8", "0.1.9", "0.2.0", "0.2.1", "0.2.2", "0.2.3", "0.2.4", "0.2.5", "0.2.6", "0.2.7", "0.2.8", "0.2.9");\r
49 \r
50 switch ($EXT_LOAD_MODE)\r
51 {\r
52 case "register": // Do stuff when installtion is running\r
53         // SQL commands to run\r
54         $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_user_transfers_in";\r
55         $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_user_transfers_out";\r
56 \r
57         // Transfer from a member\r
58         $SQLs[] = "CREATE TABLE "._MYSQL_PREFIX."_user_transfers_in (\r
59 id bigint(20) not null auto_increment,\r
60 userid bigint(20) not null default '0',\r
61 from_uid bigint(20) not null default '0',\r
62 points bigint(20) not null default '0',\r
63 reason varchar(255) not null default '',\r
64 time_trans varchar(14) not null default '0',\r
65 trans_id varchar(12) not null default '',\r
66 KEY (userid),\r
67 KEY (from_uid),\r
68 PRIMARY KEY(id)\r
69 ) Type=MyISAM";\r
70 \r
71         // Transfers to a member\r
72         $SQLs[] = "CREATE TABLE "._MYSQL_PREFIX."_user_transfers_out (\r
73 id bigint(20) not null auto_increment,\r
74 userid bigint(20) not null default '0',\r
75 to_uid bigint(20) not null default '0',\r
76 points bigint(20) not null default '0',\r
77 reason varchar(255) not null default '',\r
78 time_trans varchar(14) not null default '0',\r
79 trans_id varchar(12) not null default '',\r
80 KEY (userid),\r
81 KEY (to_uid),\r
82 PRIMARY KEY(id)\r
83 ) Type=MyISAM";\r
84 \r
85         // Admin menu\r
86         $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('transfer', '', '{!POINTS!}-Transfer', 'Verwalten Sie hier die {!POINTS!}-Transaktionen zwischen Ihren Mitgliedern.', 7)";\r
87         $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('transfer', 'list_transfer', 'Auflisten', 'Hier bekommen Sie alle ein- und ausgehende Transaktionen aufgelistet.', 1)";\r
88         $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('transfer', 'config_transfer', 'Einstellungen', 'Stellen Sie ein, wie viele Transaktionen aufgelistet werden sollen und wie alt diese werden d&uuml;rfen. Die evtl. installierte autopurge-Erweiterung kann dann automatisch die veralteten Transktionen l&ouml;schen.', 2)";\r
89         $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (action, what, title, descr, sort) VALUES ('transfer', 'del_transfer', 'Manuell l&ouml;schen', 'Hier k&ouml;nnen Sie - abgesehen von der automatischen L&ouml;schung - Transaktionen selber l&ouml;schen. Bitte beachten Sie, dass immer aus- und eingehende Transaktionen gleichzeitig gel&ouml;scht werden.', 3)";\r
90 \r
91         // Member menu\r
92         $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_member_menu (action, what, title, visible, locked, sort) VALUES ('main', 'transfer', '{!POINTS!}-Transfer', 'Y', 'Y', 5)";\r
93 \r
94         // Add config values\r
95         $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD transfer_max bigint(20) not null default '50'";\r
96         $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD transfer_age bigint(20) not null default '".(ONE_DAY*28)."'";\r
97         $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD transfer_timeout bigint(20) not null default '".ONE_DAY."'";\r
98         $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD transfer_balance bigint(20) not null default '100'";\r
99         $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD transfer_code bigint(20) not null default '5'";\r
100 \r
101         // Add row(s) to user's data\r
102         $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data ADD opt_in enum('Y', 'N') not null default 'N'";\r
103         break;\r
104 \r
105 case "remove": // Do stuff when removing extension\r
106         // SQL commands to run\r
107         $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_user_transfers_in";\r
108         $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_user_transfers_out";\r
109         $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_admin_menu WHERE action='transfer' LIMIT 4";\r
110         $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_member_menu WHERE what='transfer' LIMIT 1";\r
111         $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config DROP transfer_max";\r
112         $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config DROP transfer_age";\r
113         $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config DROP transfer_timeout";\r
114         $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config DROP transfer_balance";\r
115         $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config DROP transfer_code";\r
116         $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data DROP opt_in";\r
117         break;\r
118 \r
119 case "activate": // Do stuff when admin activates this extension\r
120         // SQL commands to run\r
121         $SQLs[] = "UPDATE "._MYSQL_PREFIX."_member_menu SET visible='Y', locked='N' WHERE what='transfer' LIMIT 1";\r
122         break;\r
123 \r
124 case "deactivate": // Do stuff when admin deactivates this extension\r
125         // SQL commands to run\r
126         $SQLs[] = "UPDATE "._MYSQL_PREFIX."_member_menu SET visible='Y', locked='Y' WHERE what='transfer' LIMIT 1";\r
127         break;\r
128 \r
129 case "update": // Update an extension\r
130         switch ($EXT_VER)\r
131         {\r
132         case "0.0.2": // SQL queries for v0.0.2\r
133                 // Update notes (these will be set as task text!)\r
134                 $UPDATE_NOTES = "Fehler <FONT class=\"admin_failed\">Warning: Missing argument 2 for create_timestamp_from_selections() in ".PATH."inc/libs/pro_functions.php on line 227</FONT> behoben.";\r
135                 break;\r
136 \r
137         case "0.0.3": // SQL queries for v0.0.3\r
138                 // Update notes (these will be set as task text!)\r
139                 $UPDATE_NOTES = "&Uuml;berfl&uuml;ssige unset()-Anweisungen aus der what-config_transfer.php entfernt. Dies wird bereits von der eigenen Funktion ADMIN_SAVE_SETTINGS() erledigt.";\r
140                 break;\r
141 \r
142         case "0.0.3": // SQL queries for v0.0.3\r
143                 // Update notes (these will be set as task text!)\r
144                 $UPDATE_NOTES = "Fehlende Abfrage im Mitlieder-Modul, on Erweiterung auch aktiviert ist.";\r
145                 break;\r
146 \r
147         case "0.0.5": // SQL queries for v0.0.5\r
148                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD ap_transfer enum('Y', 'N') not null default 'Y'";\r
149 \r
150                 // Update notes (these will be set as task text!)\r
151                 $UPDATE_NOTES = "Link <I>Auflisten</LI> im Admin-Bereich hatte das eingeloggte Mitglied und nicht den eingeloggten Admin abgefragt. Automatisches L&ouml;schen von veraltete Eintr&auml;gen kann unabh&auml;ngig von der autopurge-Erweiterung de-/aktiviert werden. Bitte aktualisieren Sie auch die beiden Admin-Templates!";\r
152                 break;\r
153 \r
154         case "0.0.6": // SQL queries for v0.0.6\r
155                 // Update notes (these will be set as task text!)\r
156                 $UPDATE_NOTES = "Wegen des Theme-Supportes hat sich die URL zur CSS-Datei ge&auml;ndert.";\r
157                 break;\r
158 \r
159         case "0.0.7": // SQL queries for v0.0.7\r
160                 // Update notes (these will be set as task text!)\r
161                 $UPDATE_NOTES = "Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.";\r
162                 break;\r
163 \r
164         case "0.0.8": // SQL queries for v0.0.8\r
165                 // Update notes (these will be set as task text!)\r
166                 $UPDATE_NOTES = "Problem mit E in Transaktionsnummer beseitigt.";\r
167                 break;\r
168 \r
169         case "0.0.9": // SQL queries for v0.0.9\r
170                 // Update notes (these will be set as task text!)\r
171                 $UPDATE_NOTES = "Problem mit Speicherung der Einstellungen beseitigt.";\r
172                 break;\r
173 \r
174         case "0.1.0": // SQL queries for v0.1.0\r
175                 // Update notes (these will be set as task text!)\r
176                 $UPDATE_NOTES = "Men&uuml;punkte im Gast-/Mitgliedsbereich k&ouml;nnen nicht mehr aufgerufen werden, wenn die Erweiterung deaktiviert ist.";\r
177                 break;\r
178 \r
179         case "0.1.1": // SQL queries for v0.1.1\r
180                 // Update notes (these will be set as task text!)\r
181                 $UPDATE_NOTES = "Design &quot;Solid-Business&quot; eingebaut.";\r
182                 break;\r
183 \r
184         case "0.1.2": // SQL queries for v0.1.2\r
185                 // Update notes (these will be set as task text!)\r
186                 $UPDATE_NOTES = "Seit <A href=\"".SERVER_URL."/patches/340-Gast_Mitgliedsmenue_Deaktivieren.zip\">Patch 340</A> &uuml;berfl&uuml;ssige HTML-Tags entfernt.";\r
187                 break;\r
188 \r
189         case "0.1.3": // SQL queries for v0.1.3\r
190                 // Update notes (these will be set as task text!)\r
191                 $UPDATE_NOTES = "IP-Nummer und Browserbezeichnung wird in Admin-Mails eingesetzt.";\r
192                 break;\r
193 \r
194         case "0.1.4": // SQL queries for v0.1.4\r
195                 // Update notes (these will be set as task text!)\r
196                 $UPDATE_NOTES = "Link zum Mitgliedsprofil in Funktion <U>ADMIN_USER_PROFILE_LINK()</U> ausgelagert.";\r
197                 break;\r
198 \r
199         case "0.1.5": // SQL queries for v0.1.5\r
200                 // Update notes (these will be set as task text!)\r
201                 $UPDATE_NOTES = "Template <u>admin_config_transfer_pro.tpl</u> ist &uuml;berfl&uuml;ssig geworden. Bitte l&ouml;schen Sie dies!";\r
202                 break;\r
203 \r
204         case "0.1.6": // SQL queries for v0.1.6\r
205                 // Update notes (these will be set as task text!)\r
206                 $UPDATE_NOTES = "W&ouml;rter <STRONG>Mailtausch</STRONG>, <STRONG>Mailtausches</STRONG> und <STRONG>Mailtauscher</STRONG> sind austauschbar.";\r
207                 break;\r
208 \r
209         case "0.1.7": // SQL queries for v0.1.7\r
210                 // Update notes (these will be set as task text!)\r
211                 $UPDATE_NOTES = "Wort <STRONG>Punkte</STRONG> dynamisiert.";\r
212                 break;\r
213 \r
214         case "0.1.8": // SQL queries for v0.1.8\r
215                 // Update notes (these will be set as task text!)\r
216                 $UPDATE_NOTES = "HTML-Code ausgelagert in Templates und SQL-Anweisungen abgesichert.";\r
217                 break;\r
218 \r
219         case "0.1.9": // SQL queries for v0.1.9\r
220                 // Update notes (these will be set as task text!)\r
221                 $UPDATE_NOTES = "Parser-Error im Mitgliedsbereich beseitigt.";\r
222                 break;\r
223 \r
224         case "0.2.0": // SQL queries for v0.2.0\r
225                 // Update notes (these will be set as task text!)\r
226                 $UPDATE_NOTES = "Abspeichern von Einstellungen repariert.";\r
227                 break;\r
228 \r
229         case "0.2.1": // SQL queries for v0.2.1\r
230                 // Update notes (these will be set as task text!)\r
231                 $UPDATE_NOTES = "Durchf&uuml;hrung des Transfers korregiert.";\r
232                 break;\r
233 \r
234         case "0.2.2": // SQL queries for v0.2.2\r
235                 // Update notes (these will be set as task text!)\r
236                 $UPDATE_NOTES = "Sicherheitsupdate f&uuml;r die Include-Befehle.";\r
237                 break;\r
238 \r
239         case "0.2.3": // SQL queries for v0.2.3\r
240                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu_las (la_id, la_action, la_what) VALUES ('member', '', 'list_transfer')";\r
241                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu_las (la_id, la_action, la_what) VALUES ('member', '', 'del_transfer')";\r
242                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu_las (la_id, la_action, la_what) VALUES ('config', '', 'config_transfer')";\r
243 \r
244                 // Depends on sql_patches (or you have to execute these both SQL statements by phpMyAdmin\r
245                 $EXT_UPDATE_DEPENDS = "sql_patches";\r
246 \r
247                 // Update notes (these will be set as task text!)\r
248                 $UPDATE_NOTES = "Erweiterung in's neue Men&uuml;system integriert.";\r
249                 break;\r
250 \r
251         case "0.2.4": // SQL queries for v0.2.4\r
252                 // Update notes (these will be set as task text!)\r
253                 $UPDATE_NOTES = "<STRONG>Touring-Code wiederholen</STRONG> nach <STRONG>Touring-Code eingeben</STRONG> hin ge&auml;ndert.";\r
254                 break;\r
255 \r
256         case "0.2.5": // SQL queries for v0.2.5\r
257                 $SQLs[] = "UPDATE "._MYSQL_PREFIX."_member_menu SET action='extras', sort='5' WHERE what='transfer' LIMIT 1";\r
258 \r
259                 // Update notes (these will be set as task text!)\r
260                 $UPDATE_NOTES = "Mitgliedsmen&uuml; komplett ge&auml;ndert.";\r
261                 break;\r
262 \r
263         case "0.2.6": // SQL queries for v0.2.6\r
264                 // Update notes (these will be set as task text!)\r
265                 $UPDATE_NOTES = "Hash-Erstellung von <STRONG>md5()</STRONG> auf bessere Funktion <STRONG>generateHash()</STRONG> umgestellt.";\r
266                 break;\r
267 \r
268         case "0.2.7": // SQL queries for v0.2.7\r
269                 // Update notes (these will be set as task text!)\r
270                 $UPDATE_NOTES = "Die ".POINTS." k&ouml;nnen nun wieder wie gewohnt transferiert werden. Der Grund f&uuml;r <em>".TRANSFER_INVALID_PASSWORD."</em> war, dass der Cookie-Hash ein anderer ist, als der in der Datenbank... :-/";\r
271                 break;\r
272 \r
273         case "0.2.8": // SQL queries for v0.2.8\r
274                 // Update notes (these will be set as task text!)\r
275                 $UPDATE_NOTES = "Fehlermeldung <em>Notice: Undefined index: to_uid in ".PATH."/inc/modules/member/what-transfer.php on line 301</em> gefixt. Danke an <a href=\"http://forum.mxchange.org/profile-8.html\" target=\"_blank\" title=\"Forumprofil von Piter01\">Piter01</a>.";\r
276                 break;\r
277 \r
278         case "0.2.9": // SQL queries for v0.2.9\r
279                 // Update notes (these will be set as task text!)\r
280                 $UPDATE_NOTES = "Fehlerhinweis bei deaktivierter Erweiterung verbessert.";\r
281                 break;\r
282         }\r
283         break;\r
284 \r
285 default: // Do stuff when extension is loaded\r
286         $DUMMY = LOAD_CONFIG("0");\r
287         // Maximum of listed transfers for out- and in-transfers\r
288         $CONFIG['transfer_max']     = $DUMMY['transfer_max'];\r
289         // Age in seconds\r
290         $CONFIG['transfer_age']     = $DUMMY['transfer_age'];\r
291         // Lock timeout for member settings\r
292         $CONFIG['transfer_timeout'] = $DUMMY['transfer_timeout'];\r
293         // Balance after points transfer\r
294         $CONFIG['transfer_balance'] = $DUMMY['transfer_balance'];\r
295         // Length of touring code\r
296         $CONFIG['transfer_code']    = $DUMMY['transfer_code'];\r
297         // Length of touring code\r
298         $CONFIG['ap_transfer']      = $DUMMY['ap_transfer'];\r
299         unset($DUMMY);\r
300 \r
301         if ((defined('__DAILY_RESET')) && ($CONFIG['ap_transfer'] == "Y"))\r
302         {\r
303                 // Automatically remove outdated or not displayed transactions\r
304                 TRANSFER_AUTPPURGE($CONFIG['transfer_max'], $CONFIG['transfer_age']);\r
305         }\r
306         break;\r
307 }\r
308 // Language file prefix\r
309 $EXT_LANG_PREFIX = "transfer";\r
310 \r
311 // Extension is always active?\r
312 $EXT_ALWAYS_ACTIVE = "N";\r
313 \r
314 //\r
315 ?>\r