Added encryption stuff + rewrote sendWernisApiRequest() to handle the decryption.
[mailer.git] / inc / extensions / wernis / mode-update.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 07/31/2013 *
4  * ===================                          Last change: 07/31/2013 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : mode-update.php                                  *
8  * -------------------------------------------------------------------- *
9  * Short description : Wernis extension                                 *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Auszahlung-Erweiterung                           *
12  * -------------------------------------------------------------------- *
13  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
14  * Copyright (c) 2009 - 2015 by Mailer Developer Team                   *
15  * For more information visit: http://mxchange.org                      *
16  *                                                                      *
17  * This program is free software; you can redistribute it and/or modify *
18  * it under the terms of the GNU General Public License as published by *
19  * the Free Software Foundation; either version 2 of the License, or    *
20  * (at your option) any later version.                                  *
21  *                                                                      *
22  * This program is distributed in the hope that it will be useful,      *
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
25  * GNU General Public License for more details.                         *
26  *                                                                      *
27  * You should have received a copy of the GNU General Public License    *
28  * along with this program; if not, write to the Free Software          *
29  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
30  * MA  02110-1301  USA                                                  *
31  ************************************************************************/
32
33 // Some security stuff...
34 if (!defined('__SECURITY')) {
35         die();
36 } // END - if
37
38 // All updates
39 switch (getCurrentExtensionVersion()) {
40         case '0.0.1': // SQL queries for v0.0.1
41                 addConfigAddSql('wernis_payout_active', "ENUM ('Y','N') NOT NULL DEFAULT 'Y'");
42                 addConfigAddSql('wernis_withdraw_active', "ENUM ('Y','N') NOT NULL DEFAULT 'Y'");
43                 addConfigAddSql('wernis_payout_factor', 'FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 1.00000');
44                 addConfigAddSql('wernis_withdraw_factor', 'FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 1.00000');
45                 addConfigAddSql('wernis_payout_fee_percent', 'FLOAT(8,5) UNSIGNED NOT NULL DEFAULT 0.00000');
46                 addConfigAddSql('wernis_withdraw_fee_percent', 'FLOAT(8,5) UNSIGNED NOT NULL DEFAULT 0.00000');
47                 addConfigAddSql('wernis_payout_fee_fix', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
48                 addConfigAddSql('wernis_withdraw_fee_fix', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
49
50                 // Update notes (these will be set as task text!)
51                 setExtensionUpdateNotes("Ein-/Auszahlungsfunktion getrennt ein- und ausschaltbar, sowie mit Umrechungsfaktoren {?POINTS?}-&gt;Wernis versehen. Prozentualer Abzug als &quot;Betreibergeb&uuml;hr hinzugef&uuml;gt, was z.B. f&uuml;r Wechselstuben interessant ist.");
52                 break;
53
54         case '0.0.2': // SQL queries for v0.0.2
55                 addConfigAddSql('wernis_pass_md5', "VARCHAR(32) NOT NULL DEFAULT ''");
56
57                 // Update notes (these will be set as task text!)
58                 setExtensionUpdateNotes("Auszahlungsfunktion an die neue API 0.2-BETA angepasst. Demnach muss Ihr Wernis-Passwort beim Auszahlen benutzt werden und in Ihrem {?mt_word?} als MD5-Hash gespeichert werden.");
59                 break;
60
61         case '0.0.3': // SQL queries for v0.0.3
62                 addConfigAddSql('wernis_refid', 'INT(5) UNSIGNED ZEROFILL NOT NULL DEFAULT 00000');
63
64                 // Update notes (these will be set as task text!)
65                 setExtensionUpdateNotes("WDS66-Username muss nun eintragen werden (API-Anpassung).");
66                 break;
67
68         case '0.0.4': // SQL queries for v0.0.4
69                 // Register points data
70                 registerExtensionPointsData('wernis_withdraw', 'order_points', 'LOCKED', 'DIRECT');
71
72                 // Update notes
73                 setExtensionUpdateNotes("&Uuml;berweisungen vom Portal werden nun &uuml;ber die Tabelle <strong>{OPEN_CONFIG}_MYSQL_PREFIX{CLOSE_CONFIG}_points_data</strong> verwaltet.");
74                 break;
75
76         case '0.0.5': // SQL queries for v0.0.5
77                 addExtensionChangeTableColumnSql('user_wernis', 'wernis_type', 'wernis_type', "ENUM('WITHDRAW','PAYOUT','FAILED') NOT NULL DEFAULT 'FAILED'");
78
79                 // Update notes
80                 setExtensionUpdateNotes("IN/OUT ersetzt mit WITHDRAW/PAYOUT.");
81                 break;
82
83         case '0.0.6': // SQL queries for v0.0.6
84                 addExtensionChangeTableColumnSql('config', 'wernis_pass_md5', 'wernis_pass_md5', " VARCHAR(255) NOT NULL DEFAULT ''");
85
86                 // Update notes
87                 setExtensionUpdateNotes("Es wird seit API-Version 0.6-BETA SHA256 (hexadezimal kodiert) verwendet.");
88                 break;
89
90         case '0.0.7': // SQL queries for v0.0.7
91                 // This update depends on ext-register and ext-user
92                 addExtensionDependency('register');
93                 addExtensionDependency('user');
94
95                 // Add data to both tables
96                 addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_user_register_provider` (`provider_name`, `provider_extension`) VALUES ('wernis_user_registration', 'wernis')");
97                 addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_user_login_provider` (`provider_name`, `provider_extension`) VALUES ('wernis_user_login', 'wernis')");
98
99                 // Register all filters
100                 registerFilter(__FILE__, __LINE__, 'user_registration', 'WERNIS_USER_REGISTRATION', FALSE, TRUE, isExtensionDryRun());
101                 registerFilter(__FILE__, __LINE__, 'user_registration_done', 'WERNIS_USER_REGISTRATION_DONE', FALSE, TRUE, isExtensionDryRun());
102                 registerFilter(__FILE__, __LINE__, 'user_registration_failed', 'WERNIS_USER_REGISTRATION_FAILED', FALSE, TRUE, isExtensionDryRun());
103                 registerFilter(__FILE__, __LINE__, 'user_registration_form', 'WERNIS_USER_REGISTRATION_FORM', FALSE, TRUE, isExtensionDryRun());
104                 registerFilter(__FILE__, __LINE__, 'user_login', 'WERNIS_USER_LOGIN', FALSE, TRUE, isExtensionDryRun());
105                 registerFilter(__FILE__, __LINE__, 'check_user_registration', 'WERNIS_USER_REGISTRATION_CHECK', FALSE, TRUE, isExtensionDryRun());
106                 registerFilter(__FILE__, __LINE__, 'check_user_login', 'WERNIS_USER_LOGIN_CHECK', FALSE, TRUE, isExtensionDryRun());
107
108                 // Update notes
109                 setExtensionUpdateNotes("Anmeldung &uuml;rber WDS66 API angefangen: Filter registriert.");
110                 break;
111
112         case '0.0.8': // SQL queries for v0.0.8
113                 addConfigAddSql('wernis_base_url', "VARCHAR(255) NOT NULL DEFAULT 'http://www.wds66.com'");
114
115                 // SQL commands to run
116                 addDropTableSql('wernis_regs');
117                 addCreateTableSql('wernis_regs', "
118 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
119 `local_userid` BIGINT(20) UNSIGNED NULL DEFAULT NULL,
120 `wernis_userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
121 `api_auth_status` VARCHAR(255) NOT NULL DEFAULT 'UNKNOWN',
122 `api_auth_key` VARCHAR(255) NOT NULL DEFAULT 'INVALID',
123 `api_redirect_challenge` VARCHAR(255) NOT NULL DEFAULT 'INVALID',
124 `record_inserted` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
125 PRIMARY KEY (`id`),
126 INDEX (`wernis_userid`)",
127                         'Registrations (also pending) over WDS66 API');
128
129                 // Update notes (these will be set as task text!)
130                 setExtensionUpdateNotes("Basis-URL f&uuml;r alle Scripte (Referral-Link, auth.php-Umleitung usw. nicht aber API) und Tabelle f&uuml;r API-Aufrufe von auth.php hinzugef&uuml;gt.");
131                 break;
132
133         case '0.0.9': // SQL queries for v0.0.9
134                 // Register a filter
135                 registerFilter(__FILE__, __LINE__, 'pre_user_registration', 'PRE_USER_REGISTRATION_WERNIS', FALSE, TRUE, isExtensionDryRun());
136
137                 // Update notes (these will be set as task text!)
138                 setExtensionUpdateNotes("Basis-URL f&uuml;r alle Scripte (Referral-Link, auth.php-Umleitung usw. nicht aber API) und Tabelle f&uuml;r API-Aufrufe von auth.php hinzugef&uuml;gt.");
139                 break;
140
141         case '0.1.0': // SQL queries for v0.1.0
142                 addConfigAddSql('wernis_encryption_algorithm', "VARCHAR(10) NOT NULL DEFAULT 'NULL'");
143                 addConfigAddSql('wernis_encryption_mode', "VARCHAR(10) NOT NULL DEFAULT 'NULL'");
144                 addConfigAddSql('wernis_private_key',  "TINYTEXT NOT NULL");
145
146                 // Update notes (these will be set as task text!)
147                 setExtensionUpdateNotes("Daten f&uuml;r verschl&uuml;sselte &Uuml;bertragungen hinzugef&uuml;gt.");
148                 break;
149
150 } // END - switch
151
152 // [EOF]
153 ?>