PluginProbe ʕ •ᴥ•ʔ
Download Manager / trunk
Download Manager vtrunk
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 views 5 months ago Apply.php 6 months ago Cron.php 1 year ago CronJob.php 8 months ago CronJobs.php 2 months ago Crypt.php 2 months ago DownloadStats.php 5 months ago Email.php 1 week ago EmailCron.php 1 year ago FileSystem.php 1 year ago Installer.php 3 days ago Messages.php 1 year ago Query.php 4 months ago Session.php 3 days ago Settings.php 5 years ago SimpleMath.php 5 years ago TempStorage.php 3 days ago Template.php 5 months ago UI.php 6 months ago Updater.php 4 years ago UserAgent.php 2 years ago __.php 2 months ago __MailUI.php 3 years ago
Installer.php
214 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.4;
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 $ach = get_option("__wpdm_activation_history", array());
162 $ach = maybe_unserialize($ach);
163 $ach[] = time();
164 update_option("__wpdm_activation_history", $ach, false);
165 update_option('__wpdm_db_version', $installer->dbVersion, false);
166 $__wpdm_ui_colors = get_option('__wpdm_ui_colors', false);
167 if(!$__wpdm_ui_colors)
168 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);
169
170 }
171
172
173 function addColumn($table, $column, $type_n_default = 'TEXT NOT NULL')
174 {
175 global $wpdb;
176 $result = $wpdb->get_results("SHOW COLUMNS FROM `{$wpdb->prefix}{$table}` LIKE '$column'");
177 $exists = count($result) > 0;
178 if (!$exists)
179 $wpdb->query("ALTER TABLE `{$wpdb->prefix}{$table}` ADD `{$column}` {$type_n_default}");
180 }
181
182 function changeColumn($table, $column, $newName, $type_n_default = 'TEXT NOT NULL')
183 {
184 global $wpdb;
185 $result = $wpdb->get_results("SHOW COLUMNS FROM `{$wpdb->prefix}{$table}` LIKE '$newName'");
186 $exists = count($result) > 0;
187 if ($exists)
188 $wpdb->query("ALTER TABLE `{$wpdb->prefix}{$table}` CHANGE `{$column}` `{$newName}` {$type_n_default}");
189 }
190
191 function primaryKey($table, $column)
192 {
193 global $wpdb;
194 $wpdb->query("ALTER TABLE `{$wpdb->prefix}{$table}` ADD PRIMARY KEY(`{$column}`)");
195 }
196
197 function uniqueKey($table, $column)
198 {
199 global $wpdb;
200 $wpdb->query("ALTER TABLE `{$wpdb->prefix}{$table}` ADD UNIQUE(`{$column}`)");
201 }
202
203 function addIndex($table, $indexName, $columns)
204 {
205 global $wpdb;
206 $exists = $wpdb->get_results("SHOW INDEX FROM `{$wpdb->prefix}{$table}` WHERE Key_name = '{$indexName}'");
207 if (count($exists) === 0)
208 $wpdb->query("ALTER TABLE `{$wpdb->prefix}{$table}` ADD KEY `{$indexName}` ({$columns})");
209 }
210 }
211
212
213
214