2 /************************************************************************
3 * MXChange v0.2.1 Start: 08/28/2008 *
4 * ================ Last change: 08/28/2008 *
6 * -------------------------------------------------------------------- *
7 * File : ext-surfbar.php *
8 * -------------------------------------------------------------------- *
9 * Short description : A surfbar for your members *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Eine Surfbar fuer Ihre Mitglieder *
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 - 2008 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')) {
41 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
46 EXT_SET_VERSION('0.0');
48 // Version history array (add more with , '0.1.0' and so on)
49 EXT_SET_VER_HISTORY(array('0.0'));
51 switch ($EXT_LOAD_MODE)
53 case 'register': // Do stuff when installation is running (modules.php?module=admin is called)
54 // SQL commands to run (surfbar URLs)
55 ADD_EXT_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_surfbar_urls`");
56 ADD_EXT_SQL("CREATE TABLE `{!_MYSQL_PREFIX!}_surfbar_urls` (
57 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
58 `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
59 `url` VARCHAR(255) NOT NULL DEFAULT '',
60 `last_salt` VARCHAR(255) NOT NULL DEFAULT '',
61 `views_total` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
62 `views_max` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
63 `views_allowed` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
64 `status` ENUM('PENDING','ACTIVE','LOCKED','STOPPED','REJECTED','DELETED','MIGRATED','DEPLETED') NOT NULL DEFAULT 'PENDING',
65 `registered` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
66 `last_locked` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
67 `lock_reason` VARCHAR(255) NOT NULL DEFAULT '',
68 `reject_reason` VARCHAR(255) NOT NULL DEFAULT '',
69 `fixed_reload` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
71 UNIQUE KEY `userid_url` (`userid`,`url`),
72 INDEX `status_userid` (`status`,`userid`)
73 ) TYPE={!_TABLE_TYPE!} COMMENT='Surfbar URLs'");
76 ADD_EXT_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_surfbar_locks`");
77 ADD_EXT_SQL("CREATE TABLE `{!_MYSQL_PREFIX!}_surfbar_locks` (
78 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
79 `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
80 `url_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
81 `last_surfed` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
83 UNIQUE KEY `userid_url` (`userid`,`url_id`),
85 ) TYPE={!_TABLE_TYPE!} COMMENT='Surfbar reload locks'");
88 ADD_EXT_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_surfbar_salts`");
89 ADD_EXT_SQL("CREATE TABLE `{!_MYSQL_PREFIX!}_surfbar_salts` (
90 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
91 `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
92 `url_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
93 `last_salt` VARCHAR(255) NOT NULL DEFAULT '',
95 UNIQUE KEY `userid_url` (`userid`,`url_id`),
97 ) TYPE={!_TABLE_TYPE!} COMMENT='Surfbar last used salts'");
100 ADD_EXT_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_surfbar_stats`");
101 ADD_EXT_SQL("CREATE TABLE `{!_MYSQL_PREFIX!}_surfbar_stats` (
102 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
103 `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
104 `url_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
105 `count` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
106 `last_online` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
108 UNIQUE KEY `userid_url` (`userid`,`url_id`),
110 ) TYPE={!_TABLE_TYPE!} COMMENT='Surfbar Statistics'");
112 // Member actions pending on status
113 ADD_EXT_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_surfbar_actions`");
114 ADD_EXT_SQL("CREATE TABLE `{!_MYSQL_PREFIX!}_surfbar_actions` (
115 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
116 `status` ENUM('PENDING','ACTIVE','LOCKED','STOPPED','REJECTED','DELETED','MIGRATED','DEPLETED') NULL DEFAULT NULL,
117 `action` ENUM('EDIT','DELETE','PAUSE','UNPAUSE','FRAMETEST','RETREAT','RESUBMIT','BOOKNOW') NULL DEFAULT NULL,
118 `new_status` ENUM('PENDING','ACTIVE','LOCKED','STOPPED','REJECTED','DELETED','MIGRATED','DEPLETED') NULL DEFAULT NULL,
120 UNIQUE KEY `status_action` (`status`,`action`)
121 ) TYPE={!_TABLE_TYPE!} COMMENT='Surfbar Member Actions'");
124 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_surfbar_actions` (`status`,`action`,`new_status`) VALUES ('PENDING','RETREAT','DELETED')");
125 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_surfbar_actions` (`status`,`action`,`new_status`) VALUES ('PENDING','FRAMETEST',NULL)");
126 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_surfbar_actions` (`status`,`action`,`new_status`) VALUES ('PENDING','EDIT',NULL)");
127 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_surfbar_actions` (`status`,`action`,`new_status`) VALUES ('ACTIVE','EDIT','PENDING')");
128 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_surfbar_actions` (`status`,`action`,`new_status`) VALUES ('ACTIVE','DELETE','DELETED')");
129 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_surfbar_actions` (`status`,`action`,`new_status`) VALUES ('ACTIVE','PAUSE','STOPPED')");
130 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_surfbar_actions` (`status`,`action`,`new_status`) VALUES ('ACTIVE','FRAMETEST',NULL)");
131 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_surfbar_actions` (`status`,`action`,`new_status`) VALUES ('LOCKED','DELETE','DELETED')");
132 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_surfbar_actions` (`status`,`action`,`new_status`) VALUES ('LOCKED','FRAMETEST',NULL)");
133 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_surfbar_actions` (`status`,`action`,`new_status`) VALUES ('LOCKED','RESUBMIT','PENDING')");
134 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_surfbar_actions` (`status`,`action`,`new_status`) VALUES ('STOPPED','EDIT','PENDING')");
135 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_surfbar_actions` (`status`,`action`,`new_status`) VALUES ('STOPPED','DELETE','DELETED')");
136 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_surfbar_actions` (`status`,`action`,`new_status`) VALUES ('STOPPED','UNPAUSE','PENDING')");
137 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_surfbar_actions` (`status`,`action`,`new_status`) VALUES ('DEPLETED','EDIT','PENDING')");
138 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_surfbar_actions` (`status`,`action`,`new_status`) VALUES ('DEPLETED','DELETE','DELETED')");
139 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_surfbar_actions` (`status`,`action`,`new_status`) VALUES ('REJECTED','EDIT','PENDING')");
140 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_surfbar_actions` (`status`,`action`,`new_status`) VALUES ('REJECTED','DELETE','DELETED')");
141 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_surfbar_actions` (`status`,`action`,`new_status`) VALUES ('REJECTED','FRAMETEST',NULL)");
142 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_surfbar_actions` (`status`,`action`,`new_status`) VALUES ('REJECTED','RESUBMIT','PENDING')");
143 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_surfbar_actions` (`status`,`action`,`new_status`) VALUES ('MIGRATED','EDIT','MIGRATED')");
144 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_surfbar_actions` (`status`,`action`,`new_status`) VALUES ('MIGRATED','DELETE','DELETED')");
145 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_surfbar_actions` (`status`,`action`,`new_status`) VALUES ('MIGRATED','FRAMETEST',NULL)");
146 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_surfbar_actions` (`status`,`action`,`new_status`) VALUES ('MIGRATED','BOOKNOW','PENDING')");
149 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `surfbar_pay_model` ENUM('STATIC','DYNAMIC') NOT NULL DEFAULT 'STATIC'");
150 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `surfbar_static_reward` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.25000");
151 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `surfbar_static_costs` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 1.00000");
152 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `surfbar_static_time` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 60");
153 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `surfbar_static_lock` SMALLINT(6) UNSIGNED NOT NULL DEFAULT ".(60*5)."");
154 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `surfbar_dynamic_percent` FLOAT(10,5) UNSIGNED NOT NULL DEFAULT 10.00000");
155 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `surfbar_max_order` INT(7) UNSIGNED NOT NULL DEFAULT 10");
156 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `surfbar_restart_time` BIGINT(20) UNSIGNED NOT NULL DEFAULT ".(60*6)."");
157 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `surfbar_autostart` ENUM('Y','N') NOT NULL DEFAULT 'Y'");
158 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `surfbar_migrate_urls` ENUM('Y','N') NOT NULL DEFAULT 'Y'");
159 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `surfbar_total_counter` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
160 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `surfbar_daily_counter` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
161 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `surfbar_yester_counter` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
162 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `surfbar_weekly_counter` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
163 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `surfbar_monthly_counter` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
164 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `surfbar_stats_reload` BIGINT(20) UNSIGNED NOT NULL DEFAULT 30");
165 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `surfbar_purge_deleted` BIGINT(20) UNSIGNED NOT NULL DEFAULT ".(getConfig('one_day')*7)."");
166 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `surfbar_purge_migrated` BIGINT(20) UNSIGNED NOT NULL DEFAULT ".(getConfig('one_day')*3)."");
167 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `surfbar_pause_mode` ENUM('INTERNAL','EXERNAL') NOT NULL DEFAULT 'INTERNAL'");
168 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `surfbar_pause_url` VARCHAR(255) NOT NULL DEFAULT ''");
169 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `surfbar_notify_limits` ENUM('Y','N') NOT NULL DEFAULT 'Y'");
170 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `surfbar_notify_admin_unlock` ENUM('Y','N') NOT NULL DEFAULT 'Y'");
171 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `surfbar_warn_low_points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 100");
172 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `surfbar_low_interval` BIGINT(20) UNSIGNED NOT NULL DEFAULT ".getConfig('one_day')."");
173 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `surfbar_migrate_order` ENUM('Y','N') NOT NULL DEFAULT 'Y'");
174 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `surfbar_notification_mode` ENUM('INSTANT','RESET') NOT NULL DEFAULT 'INSTANT'");
175 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_config` ADD `surfbar_guest_login_form` ENUM('Y','N') NOT NULL DEFAULT 'Y'");
178 ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_user_data` ADD `surfbar_low_notified` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00'");
181 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_member_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('surfbar',NULL,'Surfbar','Y','Y',4)");
182 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_member_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('surfbar','surfbar_start','Surfbar starten','Y','Y',1)");
183 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_member_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('surfbar','surfbar_book','URL buchen','Y','Y',2)");
184 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_member_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('surfbar','surfbar_list','URL-Verwaltung','Y','Y',3)");
185 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_member_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('surfbar','surfbar_stats','URL-Statistiken','Y','Y',4)");
188 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('surfbar',NULL,'Surfbar','URLs in der Surfbar verwalten, Einstellungen ändern und vieles mehr.',7)");
189 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('surfbar','add_surfbar_url','URL hinzufügen','Fügen Sie URLs z.B. von Werbenetzwerken hinzu, oder Ihre eigenen Projekte. <strong>Vorsicht!</strong> Ihnen muss es auch gestattet sein, URLs aus dem Werbenetzwerk in die Surfbar einzufügen.',1)");
190 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('surfbar','list_surfbar_urls','URLs verwalten','Verwalten Sie hier alle in der Surfbar befindlichen URLs mit nur wenigen Klicks.',2)");
191 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('surfbar','unlock_surfbar_urls','Wartende URLs freigeben','Geben Sie hier nur direkt in der Surfbar gebuchte URLs frei.',3)");
192 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('surfbar','config_surfbar','Einstellungen','Einstellungen an der Surfbar ändern, wie Festvergütung, prozentuale Ref-Vergütung und vieles mehr.',4)");
193 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('surfbar','surfbar_stats','Statistiken','Detailierte Statistiken zu einer ausgewählten URL anzeigen.',5)");
194 ADD_EXT_SQL("INSERT INTO `{!_MYSQL_PREFIX!}_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('surfbar','list_surfbar_actions','Mitgliederaktionen','Listet alle Mitgliederaktionen auf.',6)");
197 case 'remove': // Do stuff when removing extension
198 // SQL commands to run
199 ADD_EXT_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_surfbar_actions`");
200 ADD_EXT_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_surfbar_locks`");
201 ADD_EXT_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_surfbar_salts`");
202 ADD_EXT_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_surfbar_stats`");
203 ADD_EXT_SQL("DROP TABLE IF EXISTS `{!_MYSQL_PREFIX!}_surfbar_urls`");
204 ADD_EXT_SQL("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_member_menu` WHERE `action`='surfbar'");
205 ADD_EXT_SQL("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_admin_menu` WHERE `action`='surfbar'");
208 case 'activate': // Do stuff when admin activates this extension
209 // SQL commands to run
210 ADD_EXT_SQL("UPDATE `{!_MYSQL_PREFIX!}_member_menu` SET `visible`='Y', `locked`='N' WHERE `action`='surfbar' LIMIT 5");
211 ADD_EXT_SQL("UPDATE `{!_MYSQL_PREFIX!}_mod_reg` SET `locked`='N', `hidden`='N', `admin_only`='N', `mem_only`='Y' WHERE `module`='surfbar' LIMIT 1");
214 case 'deactivate': // Do stuff when admin deactivates this extension
215 // SQL commands to run
216 ADD_EXT_SQL("UPDATE `{!_MYSQL_PREFIX!}_member_menu` SET `visible`='N', `locked`='Y' WHERE `action` = 'surfbar' LIMIT 5");
217 ADD_EXT_SQL("UPDATE `{!_MYSQL_PREFIX!}_mod_reg` SET `locked`='Y' WHERE `module`='surfbar' LIMIT 1");
220 case 'update': // Update an extension
222 case '0.0.1': // SQL queries for v0.0.1
225 // Update notes (these will be set as task text!)
226 EXT_SET_UPDATE_NOTES('');
231 case 'modify': // When the extension got modified
234 case 'test': // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
237 default: // Do stuff when extension is loaded
238 // @TODO Set some constants we need???
239 define('edit', 'edit');