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 * -------------------------------------------------------------------- *
14 * -------------------------------------------------------------------- *
15 * Copyright (c) 2003 - 2008 by Roland Haeder *
16 * For more information visit: http://www.mxchange.org *
18 * This program is free software; you can redistribute it and/or modify *
19 * it under the terms of the GNU General Public License as published by *
20 * the Free Software Foundation; either version 2 of the License, or *
21 * (at your option) any later version. *
23 * This program is distributed in the hope that it will be useful, *
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
26 * GNU General Public License for more details. *
28 * You should have received a copy of the GNU General Public License *
29 * along with this program; if not, write to the Free Software *
30 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
32 ************************************************************************/
34 // Some security stuff...
35 if (!defined('__SECURITY')) {
36 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
43 // Auto-set extension version
44 if (empty($EXT_VER)) $EXT_VER = $EXT_VERSION;
46 // Version history array (add more with , "0.1" and so on)
47 $EXT_VER_HISTORY = array("0.0");
49 switch ($EXT_LOAD_MODE)
51 case "register": // Do stuff when installtion is running (modules.php?module=admin&action=login is called)
52 // SQL commands to run (surfbar URLs)
53 $SQLs[] = "DROP TABLE IF EXISTS `"._MYSQL_PREFIX."_surfbar_urls`";
54 $SQLs[] = "CREATE TABLE `"._MYSQL_PREFIX."_surfbar_urls` (
55 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
56 `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
57 `url` VARCHAR(255) NOT NULL DEFAULT '',
58 `last_salt` VARCHAR( 255 ) NOT NULL DEFAULT '',
59 `reward` FLOAT(10,5) UNSIGNED NOT NULL DEFAULT '0.00000',
60 `costs` FLOAT(10,5) UNSIGNED NOT NULL DEFAULT '0.00000',
61 `views_total` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
62 `status` ENUM('PENDING','CONFIRMED','LOCKED') NOT NULL DEFAULT 'CONFIRMED',
63 `registered` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
64 `last_locked` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
65 `lock_reason` VARCHAR(255) NOT NULL DEFAULT '',
67 UNIQUE KEY `userid_url` (`userid`, `url`)
68 ) TYPE=MyISAM COMMENT='Surfbar URLs'";
71 $SQLs[] = "DROP TABLE IF EXISTS `"._MYSQL_PREFIX."_surfbar_locks`";
72 $SQLs[] = "CREATE TABLE `"._MYSQL_PREFIX."_surfbar_locks` (
73 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
74 `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
75 `url_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
76 `last_surfed` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
80 ) TYPE=MyISAM COMMENT='Surfbar reload locks'";
83 $SQLs[] = "DROP TABLE IF EXISTS `"._MYSQL_PREFIX."_surfbar_salts`";
84 $SQLs[] = "CREATE TABLE `"._MYSQL_PREFIX."_surfbar_salts` (
85 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
86 `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
87 `url_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
88 `last_salt` VARCHAR(255) NOT NULL DEFAULT '',
92 ) TYPE=MyISAM COMMENT='Surfbar last used salts'";
95 $SQLs[] = "DROP TABLE IF EXISTS `"._MYSQL_PREFIX."_surfbar_stats`";
96 $SQLs[] = "CREATE TABLE `"._MYSQL_PREFIX."_surfbar_stats` (
97 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
98 `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
99 `url_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
100 `count` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
101 `last_online` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
103 INDEX (`userid`,`url_id`)
104 ) TYPE=MyISAM COMMENT='Surfbar Statistics'";
107 $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `surfbar_pay_model` ENUM('STATIC','DYNAMIC') NOT NULL DEFAULT 'STATIC'";
108 $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `surfbar_static_reward` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.25000";
109 $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `surfbar_static_costs` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 1.00000";
110 $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `surfbar_static_time` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 60";
111 $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `surfbar_static_lock` SMALLINT(6) UNSIGNED NOT NULL DEFAULT ".(60*5)."";
112 $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `surfbar_dynamic_percent` FLOAT(10,5) UNSIGNED NOT NULL DEFAULT 10.00000";
113 $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `surfbar_max_order` INT(7) UNSIGNED NOT NULL DEFAULT 10";
114 $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `surfbar_restart_time` BIGINT(20) UNSIGNED NOT NULL DEFAULT ".(60*6)."";
115 $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `surfbar_autostart` ENUM('Y','N') NOT NULL DEFAULT 'Y'";
116 $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `surfbar_total_counter` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0";
117 $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `surfbar_daily_counter` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0";
118 $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `surfbar_yester_counter` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0";
119 $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `surfbar_weekly_counter` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0";
120 $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `surfbar_monthly_counter` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0";
121 $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `surfbar_stats_reload` BIGINT(20) UNSIGNED NOT NULL DEFAULT 30";
124 $SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_member_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('surfbar',NULL,'Surfbar','Y','Y',4)";
125 $SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_member_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('surfbar','surfbar_start','Surfbar starten','Y','Y',1)";
126 $SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_member_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('surfbar','surfbar_book','URL buchen','Y','Y',2)";
127 $SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_member_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('surfbar','surfbar_list','URL-Verwaltung','Y','Y',3)";
128 $SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_member_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('surfbar','surfbar_stats','URL-Statistiken','Y','Y',4)";
131 $SQLs[] = "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)";
132 $SQLs[] = "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)";
133 $SQLs[] = "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)";
134 $SQLs[] = "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)";
135 $SQLs[] = "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)";
136 $SQLs[] = "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)";
142 case "remove": // Do stuff when removing extension
143 // SQL commands to run
144 $SQLs[] = "DROP TABLE IF EXISTS `"._MYSQL_PREFIX."_surfbar_urls`";
145 $SQLs[] = "DROP TABLE IF EXISTS `"._MYSQL_PREFIX."_surfbar_locks`";
146 $SQLs[] = "DROP TABLE IF EXISTS `"._MYSQL_PREFIX."_surfbar_salts`";
147 $SQLs[] = "DROP TABLE IF EXISTS `"._MYSQL_PREFIX."_surfbar_stats`";
148 $SQLs[] = "DELETE LOW_PRIORITY FROM `"._MYSQL_PREFIX."_member_menu` WHERE `action`='surfbar' LIMIT 5";
149 $SQLs[] = "DELETE LOW_PRIORITY FROM `"._MYSQL_PREFIX."_admin_menu` WHERE action='surfbar' LIMIT 6";
152 case "activate": // Do stuff when admin activates this extension
153 // SQL commands to run
154 $SQLs[] = "UPDATE `"._MYSQL_PREFIX."_member_menu` SET `visible`='Y', `locked`='N' WHERE `action`='surfbar' LIMIT 3";
157 case "deactivate": // Do stuff when admin deactivates this extension
158 // SQL commands to run
159 $SQLs[] = "UPDATE `"._MYSQL_PREFIX."_member_menu` SET `locked`='Y' WHERE `action` = 'surfbar' LIMIT 3";
162 case "update": // Update an extension
165 case "0.0.1": // SQL queries for v0.0.1
168 // Update notes (these will be set as task text!)
174 default: // Do stuff when extension is loaded
178 // Language file prefix
179 $EXT_LANG_PREFIX = "surfbar";
181 // Extension is always active?
182 $EXT_ALWAYS_ACTIVE = "N";