PluginProbe ʕ •ᴥ•ʔ
Download Manager / 3.3.63
Download Manager v3.3.63
3.3.63 3.3.62 3.3.61 3.3.60 3.3.59 3.3.58 3.3.57 3.3.56 trunk 2.1.3 2.3.0 2.5.96 2.5.97 2.6.2 2.6.96 2.8.3 2.9.99 3.0.4 3.1.05 3.1.07 3.1.08 3.1.11 3.1.12 3.1.14 3.1.17 3.1.18 3.1.22 3.1.23 3.1.24 3.1.25 3.1.26 3.1.27 3.1.28 3.2.04 3.2.13 3.2.14 3.2.16 3.2.18 3.2.19 3.2.21 3.2.22 3.2.23 3.2.24 3.2.25 3.2.27 3.2.28 3.2.29 3.2.30 3.2.31 3.2.32 3.2.33 3.2.34 3.2.35 3.2.37 3.2.38 3.2.39 3.2.40 3.2.41 3.2.42 3.2.43 3.2.44 3.2.45 3.2.46 3.2.47 3.2.48 3.2.49 3.2.50 3.2.51 3.2.52 3.2.53 3.2.54 3.2.55 3.2.56 3.2.57 3.2.58 3.2.59 3.2.60 3.2.61 3.2.63 3.2.64 3.2.65 3.2.66 3.2.67 3.2.68 3.2.69 3.2.70 3.2.71 3.2.72 3.2.73 3.2.74 3.2.75 3.2.76 3.2.77 3.2.78 3.2.79 3.2.80 3.2.81 3.2.82 3.2.83 3.2.84 3.2.85 3.2.86 3.2.87 3.2.88 3.2.89 3.2.90 3.2.91 3.2.92 3.2.93 3.2.94 3.2.95 3.2.96 3.2.97 3.2.98 3.2.99 3.3.00 3.3.01 3.3.02 3.3.03 3.3.04 3.3.05 3.3.06 3.3.07 3.3.08 3.3.09 3.3.10 3.3.11 3.3.12 3.3.13 3.3.14 3.3.15 3.3.16 3.3.17 3.3.18 3.3.19 3.3.20 3.3.21 3.3.22 3.3.23 3.3.24 3.3.25 3.3.26 3.3.27 3.3.28 3.3.29 3.3.30 3.3.31 3.3.32 3.3.33 3.3.34 3.3.35 3.3.36 3.3.37 3.3.38 3.3.39 3.3.40 3.3.41 3.3.42 3.3.43 3.3.44 3.3.45 3.3.46 3.3.47 3.3.48 3.3.49 3.3.50 3.3.51 3.3.52 3.3.53 3.3.54 3.3.55
download-manager / src / __ / Installer.php
download-manager / src / __ Last commit date
HTML 1 year ago Jobs 1 day ago views 1 day ago ActivityReport.php 1 day ago Apply.php 6 months ago Cron.php 1 year ago CronJob.php 1 day ago CronJobs.php 1 day ago Crypt.php 2 months ago DownloadStats.php 5 months ago Email.php 1 day ago EmailCron.php 1 year ago FileSystem.php 1 year ago Installer.php 1 day ago Messages.php 1 year ago Query.php 5 months ago Session.php 1 week ago Settings.php 5 years ago SimpleMath.php 5 years ago TempStorage.php 1 week ago Template.php 5 months ago UI.php 7 months ago Updater.php 4 years ago UserAgent.php 2 years ago __.php 2 months ago __MailUI.php 3 years ago
Installer.php
228 lines
1 <?php
2
3 namespace WPDM\__;
4
5 // Exit if accessed directly
6 if (!defined('ABSPATH')) {
7 exit;
8 }
9
10 class Installer
11 {
12 /**
13 * @var float
14 */
15 private $dbVersion = 535.5;
16
17 function __construct()
18 {
19
20 }
21
22 /**
23 * @return float
24 */
25 public static function dbVersion(){
26 $inst = new Installer();
27 return $inst->dbVersion;
28 }
29
30 public static function dbUpdateRequired(){
31 return (Installer::dbVersion() !== (double)get_option('__wpdm_db_version'));
32 }
33
34 public static function init(){
35 self::updateDB();
36 }
37
38 public static function updateDB()
39 {
40
41 global $wpdb;
42
43 delete_option('wpdm_latest');
44
45 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
46
47 $sqls[] = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}ahm_download_stats` (
48 `id` bigint(20) NOT NULL AUTO_INCREMENT,
49 `pid` bigint(20) NOT NULL,
50 `uid` int(11) NOT NULL,
51 `oid` varchar(100) NOT NULL,
52 `year` int(4) NOT NULL,
53 `month` int(2) NOT NULL,
54 `day` int(2) NOT NULL,
55 `timestamp` int(11) NOT NULL,
56 `ip` varchar(255) NOT NULL,
57 `filename` text,
58 `agent` text,
59 PRIMARY KEY (`id`)
60 )";
61
62 $sqls[] = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}ahm_emails` (
63 `id` bigint(20) NOT NULL AUTO_INCREMENT,
64 `email` varchar(255) NOT NULL,
65 `pid` bigint(20) NOT NULL,
66 `date` int(11) NOT NULL,
67 `custom_data` text NOT NULL,
68 `request_status` INT( 1 ) NOT NULL,
69 PRIMARY KEY (`id`)
70 )";
71
72 $sqls[] = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}ahm_social_conns` (
73 `ID` bigint(20) NOT NULL AUTO_INCREMENT,
74 `pid` bigint(20) NOT NULL,
75 `email` varchar(200) NOT NULL,
76 `name` varchar(200) NOT NULL,
77 `user_data` text NOT NULL,
78 `access_token` text NOT NULL,
79 `refresh_token` text NOT NULL,
80 `source` varchar(200) NOT NULL,
81 `timestamp` int(11) NOT NULL,
82 `processed` tinyint(1) NOT NULL DEFAULT '0',
83 PRIMARY KEY (`ID`)
84 )";
85
86 $sqls[] = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}ahm_assets` (
87 `ID` bigint(20) NOT NULL AUTO_INCREMENT,
88 `path` text NOT NULL,
89 `owner` int(11) NOT NULL,
90 `activities` text NOT NULL,
91 `comments` text NOT NULL,
92 `access` text NOT NULL,
93 `metadata` text NOT NULL,
94 PRIMARY KEY (`ID`)
95 )";
96
97 $sqls[] = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}ahm_asset_links` (
98 `ID` bigint(20) NOT NULL AUTO_INCREMENT,
99 `asset_ID` bigint(20) NOT NULL,
100 `asset_key` varchar(255) NOT NULL,
101 `access` text NOT NULL,
102 `time` int(11) NOT NULL,
103 PRIMARY KEY (`ID`)
104 )";
105
106 $sqls[] = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}ahm_sessions` (
107 `ID` bigint(20) NOT NULL AUTO_INCREMENT,
108 `deviceID` varchar(255) NOT NULL,
109 `name` varchar(255) NOT NULL,
110 `value` text NOT NULL,
111 `lastAccess` int(11) NOT NULL,
112 `expire` int(11) NOT NULL,
113 PRIMARY KEY (`ID`),
114 KEY `name_device` (`name`(150),`deviceID`(40)),
115 KEY `expire` (`expire`)
116 )";
117
118 $sqls[] = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}ahm_user_download_counts` (
119 `ID` int(11) NOT NULL AUTO_INCREMENT,
120 `user` varchar(255) NOT NULL,
121 `package_id` int(11) NOT NULL,
122 `download_count` int(11) NOT NULL,
123 PRIMARY KEY (`ID`)
124 )";
125
126 $sqls[] = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}ahm_cron_jobs` (
127 `ID` int(11) NOT NULL AUTO_INCREMENT,
128 `code` varchar(255) NOT NULL,
129 `type` varchar(250) NOT NULL,
130 `data` json DEFAULT NULL,
131 `execute_at` int(11) NOT NULL,
132 `repeat_execution` int(11) NOT NULL DEFAULT '0',
133 `execution_count` int(11) NOT NULL DEFAULT '0',
134 `interval` int(11) NOT NULL DEFAULT '0',
135 `created_at` int(11) NOT NULL DEFAULT '0',
136 `created_by` int(11) NOT NULL DEFAULT '0',
137 PRIMARY KEY (`ID`),
138 UNIQUE KEY `code` (`code`)
139 ) ENGINE=InnoDB";
140
141 //$sqls[] = "ALTER TABLE `{$wpdb->prefix}ahm_cron_jobs` ADD UNIQUE KEY `code` (`code`);";
142
143 foreach ($sqls as $qry) {
144 $wpdb->query($qry);
145 }
146
147 $installer = new Installer();
148
149 $installer->addColumn('ahm_download_stats', 'version', 'varchar(255) NOT NULL');
150 $installer->addColumn('ahm_download_stats', 'agent', 'TEXT');
151 $installer->addColumn('ahm_download_stats', 'filename', 'TEXT');
152 $installer->changeColumn('ahm_download_stats', 'ip', 'ip', 'varchar(255) NOT NULL');
153 $installer->addColumn('ahm_emails', 'request_status', "INT(1) NOT NULL");
154 $installer->uniqueKey('ahm_asset_links', "asset_key");
155
156 // Index ahm_sessions for the hot lookup + cleanup paths (existing installs).
157 $installer->addColumn('ahm_sessions', 'lastAccess', 'int(11) NOT NULL DEFAULT 0');
158 $installer->addIndex('ahm_sessions', 'name_device', '`name`(150),`deviceID`(40)');
159 $installer->addIndex('ahm_sessions', 'expire', '`expire`');
160
161 // Cron Jobs table improvements
162 $installer->addColumn('ahm_cron_jobs', 'queue', "VARCHAR(64) NOT NULL DEFAULT 'default'");
163 $installer->addColumn('ahm_cron_jobs', 'priority', "TINYINT NOT NULL DEFAULT 5");
164 $installer->addColumn('ahm_cron_jobs', 'status', "VARCHAR(20) NOT NULL DEFAULT 'pending'");
165 $installer->addColumn('ahm_cron_jobs', 'attempts', "TINYINT NOT NULL DEFAULT 0");
166 $installer->addColumn('ahm_cron_jobs', 'max_attempts', "TINYINT NOT NULL DEFAULT 3");
167 $installer->addColumn('ahm_cron_jobs', 'started_at', "INT(11) NULL");
168 $installer->addColumn('ahm_cron_jobs', 'completed_at', "INT(11) NULL");
169 $installer->addColumn('ahm_cron_jobs', 'next_retry_at', "INT(11) NULL");
170 $installer->addColumn('ahm_cron_jobs', 'interval_seconds', "INT(11) NOT NULL DEFAULT 0");
171 $installer->addColumn('ahm_cron_jobs', 'error_message', "TEXT NULL");
172 $installer->addColumn('ahm_cron_jobs', 'locked_by', "VARCHAR(64) NULL");
173 $installer->addColumn('ahm_cron_jobs', 'locked_at', "INT(11) NULL");
174
175 $ach = get_option("__wpdm_activation_history", array());
176 $ach = maybe_unserialize($ach);
177 $ach[] = time();
178 update_option("__wpdm_activation_history", $ach, false);
179 update_option('__wpdm_db_version', $installer->dbVersion, false);
180 $__wpdm_ui_colors = get_option('__wpdm_ui_colors', false);
181 if(!$__wpdm_ui_colors)
182 update_option('__wpdm_ui_colors', 'a:18:{s:7:"primary";s:7:"#4a8eff";s:13:"primary_hover";s:7:"#5998ff";s:14:"primary_active";s:7:"#3281ff";s:9:"secondary";s:7:"#6c757d";s:15:"secondary_hover";s:7:"#6c757d";s:16:"secondary_active";s:7:"#6c757d";s:4:"info";s:7:"#2CA8FF";s:10:"info_hover";s:7:"#2CA8FF";s:11:"info_active";s:7:"#2CA8FF";s:7:"success";s:7:"#018e11";s:13:"success_hover";s:7:"#0aad01";s:14:"success_active";s:7:"#0c8c01";s:7:"warning";s:7:"#FFB236";s:13:"warning_hover";s:7:"#FFB236";s:14:"warning_active";s:7:"#FFB236";s:6:"danger";s:7:"#ff5062";s:12:"danger_hover";s:7:"#ff5062";s:13:"danger_active";s:7:"#ff5062";}', false);
183
184 }
185
186
187 function addColumn($table, $column, $type_n_default = 'TEXT NOT NULL')
188 {
189 global $wpdb;
190 $result = $wpdb->get_results("SHOW COLUMNS FROM `{$wpdb->prefix}{$table}` LIKE '$column'");
191 $exists = count($result) > 0;
192 if (!$exists)
193 $wpdb->query("ALTER TABLE `{$wpdb->prefix}{$table}` ADD `{$column}` {$type_n_default}");
194 }
195
196 function changeColumn($table, $column, $newName, $type_n_default = 'TEXT NOT NULL')
197 {
198 global $wpdb;
199 $result = $wpdb->get_results("SHOW COLUMNS FROM `{$wpdb->prefix}{$table}` LIKE '$newName'");
200 $exists = count($result) > 0;
201 if ($exists)
202 $wpdb->query("ALTER TABLE `{$wpdb->prefix}{$table}` CHANGE `{$column}` `{$newName}` {$type_n_default}");
203 }
204
205 function primaryKey($table, $column)
206 {
207 global $wpdb;
208 $wpdb->query("ALTER TABLE `{$wpdb->prefix}{$table}` ADD PRIMARY KEY(`{$column}`)");
209 }
210
211 function uniqueKey($table, $column)
212 {
213 global $wpdb;
214 $wpdb->query("ALTER TABLE `{$wpdb->prefix}{$table}` ADD UNIQUE(`{$column}`)");
215 }
216
217 function addIndex($table, $indexName, $columns)
218 {
219 global $wpdb;
220 $exists = $wpdb->get_results("SHOW INDEX FROM `{$wpdb->prefix}{$table}` WHERE Key_name = '{$indexName}'");
221 if (count($exists) === 0)
222 $wpdb->query("ALTER TABLE `{$wpdb->prefix}{$table}` ADD KEY `{$indexName}` ({$columns})");
223 }
224 }
225
226
227
228