PluginProbe ʕ •ᴥ•ʔ
Download Manager / 3.3.68
Download Manager v3.3.68
3.3.68 3.3.67 3.3.66 3.3.65 3.3.64 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 / __ / Apply.php
download-manager / src / __ Last commit date
HTML 1 year ago Jobs 1 month ago views 2 weeks ago ActivityReport.php 1 month ago Apply.php 2 weeks ago Cron.php 1 year ago CronJob.php 1 month ago CronJobs.php 1 month ago Crypt.php 4 months ago DownloadStats.php 7 months ago Email.php 1 month ago EmailCron.php 1 year ago FileSystem.php 1 year ago Installer.php 1 month ago Messages.php 1 year ago Query.php 7 months ago Session.php 2 months ago Settings.php 5 years ago SimpleMath.php 5 years ago TempStorage.php 2 months ago Template.php 7 months ago UI.php 1 month ago Updater.php 4 years ago UserAgent.php 2 years ago __.php 4 months ago __MailUI.php 3 years ago
Apply.php
723 lines
1 <?php
2
3 namespace WPDM\__;
4
5
6 class Apply
7 {
8
9 function __construct()
10 {
11
12
13
14
15
16 $this->adminActions();
17 $this->frontendActions();
18
19 }
20
21 function frontendActions()
22 {
23
24 add_filter('wpdm_custom_data', array($this, 'skipLocks'), 10, 2);
25 add_action("wp_ajax_nopriv_showLockOptions", array($this, 'showLockOptions'));
26 add_action("wp_ajax_showLockOptions", array($this, 'showLockOptions'));
27
28 add_action("wp_ajax_wpdm_generate_password", [$this, 'generatePassword']);
29 add_action("wp_ajax_wpdm-activate-shop", [$this, 'activatePremiumPackage']);
30
31 add_filter( 'wp_kses_allowed_html', [$this, 'allowStyleTagInKses'], 10, 2 );
32
33 if (is_admin()) return;
34
35 add_action("init", array($this, 'triggerDownload'), 9);
36 add_action('init', array($this, 'addWriteRules'), 0);
37
38
39 add_filter('widget_text', 'do_shortcode');
40
41 add_action('query_vars', array($this, 'dashboardPageVars'), 1);
42 add_action('request', array($this, 'rssFeed'));
43 add_filter('pre_get_posts', array($this, 'queryTag'));
44
45 add_filter('ajax_query_attachments_args', array($this, 'usersMediaQuery'));
46
47
48 add_action('wp_head', array($this, 'addGenerator'), 9999);
49 add_filter('post_comments_feed_link', array($this, 'removeCommentFeed'));
50
51 add_filter('the_excerpt_embed', array($this, 'oEmbed'));
52
53 add_action('wp_head', array($this, 'wpHead'), 999999);
54
55
56 }
57
58 function adminActions()
59 {
60 if (!is_admin()) return;
61 add_action('after_switch_theme', array($this, 'flashRules'));
62 add_action('save_post', array($this, 'dashboardPages'));
63 add_action('wp_ajax_clear_cache', array($this, 'clearCache'));
64 add_action('wp_ajax_clear_stats', array($this, 'clearStats'));
65 add_action('admin_head', array($this, 'uiColors'));
66
67 }
68
69 function authorPage($wp_query)
70 {
71 if ((int)$wp_query->is_author === 1 && ($ppid = WPDM()->setting->author_profile('int')) > 0 && $ppid === $wp_query->query_vars['page_id']) {
72 wpdmdd($ppid);
73 unset($wp_query->query['post_type']);
74 $pagename = get_pagename($ppid);
75 $wp_query->query = array('page' => '', 'pagename' => $pagename);
76 $wp_query->set('author_name', null);
77 $wp_query->set('pagename', $pagename);
78 $wp_query->is_archive = false;
79 $wp_query->is_post_type_archive = false;
80 $wp_query->queried_object_id = $ppid;
81 $wp_query->queried_object = get_post($ppid);
82 }
83 //wpdmdd($wp_query);
84 return $wp_query;
85 }
86
87 function skipLocks($data, $id)
88 {
89 global $current_user;
90 $skiplocks = maybe_unserialize(get_option('__wpdm_skip_locks', array()));
91 if (is_user_logged_in()) {
92 foreach ($skiplocks as $lock) {
93 unset($data[$lock . "_lock"]); // = 0;
94 }
95 }
96
97 return $data;
98 }
99
100 function docStream()
101 {
102 if (strstr($_SERVER['REQUEST_URI'], 'wpdm-doc-preview')) {
103 preg_match("/wpdm\-doc\-preview\/([0-9]+)/", $_SERVER['REQUEST_URI'], $mat);
104 $file_id = $mat[1];
105 $files = WPDM()->package->getFiles($file_id);
106 if (count($files) == 0) die('No file found!');
107 $sfile = '';
108 foreach ($files as $i => $sfile) {
109 $ifile = $sfile;
110 $sfile = explode(".", $sfile);
111 $fext = end($sfile);
112 if (in_array(end($sfile), array('pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx'))) {
113 $sfile = $ifile;
114 break;
115 }
116 }
117 if ($sfile == '') die('No supported document found!');
118 if (file_exists(UPLOAD_DIR . $sfile)) $sfile = UPLOAD_DIR . $sfile;
119 if (!file_exists($sfile)) die('No supported document found!');
120
121 if (strstr($sfile, '://')) header("location: {$sfile}");
122 else
123 FileSystem::downloadFile($sfile, basename($sfile));
124 die();
125 }
126 }
127
128 function addWriteRules()
129 {
130 global $wp_rewrite;
131 $udb_page_id = get_option('__wpdm_user_dashboard', 0);
132 if ($udb_page_id) {
133 $page_name = get_post_field("post_name", $udb_page_id);
134 add_rewrite_rule('^' . $page_name . '/(.+)/?', 'index.php?page_id=' . $udb_page_id . '&udb_page=$matches[1]', 'top');
135 //dd($wp_rewrite);
136 }
137 $adb_page_id = get_option('__wpdm_author_dashboard', 0);
138
139 if ($adb_page_id) {
140 $page_name = get_post_field("post_name", $adb_page_id);
141 add_rewrite_rule('^' . $page_name . '/(.+)/?', 'index.php?page_id=' . $adb_page_id . '&adb_page=$matches[1]', 'top');
142 }
143
144 $ap_page_id = get_option('__wpdm_author_profile', 0);
145
146 if ($ap_page_id) {
147 $page_name = get_post_field("post_name", $ap_page_id);
148 add_rewrite_rule('^' . $page_name . '/(.+)/?$', 'index.php?pagename=' . $page_name . '&profile=$matches[1]', 'top');
149 }
150
151 //wpdmdd($wp_rewrite);
152 //add_rewrite_rule('^wpdmdl/([0-9]+)/?', 'index.php?wpdmdl=$matches[1]', 'top');
153 //add_rewrite_rule('^wpdmdl/([0-9]+)/ind/([^\/]+)/?', 'index.php?wpdmdl=$matches[1]&ind=$matches[2]', 'top');
154 //if(is_404()) dd('404');
155 //$wp_rewrite->flush_rules();
156 //dd($wp_rewrite);
157 }
158
159 function flashRules()
160 {
161 $this->addWriteRules();
162 global $wp_rewrite;
163 $wp_rewrite->flush_rules();
164 }
165
166 function wpdmproTemplates($template){
167 $_template = basename($template);
168 $style_global = get_option('__wpdm_cpage_style', 'basic');
169 $style = get_term_meta(get_queried_object_id(), '__wpdm_style', true);
170 $style = in_array($style, ['basic', 'ltpl']) ? $style : $style_global;
171 if($style === 'ltpl' && (is_tax('wpdmcategory') || is_post_type_archive('wpdmpro'))){
172 $template = Template::locate("taxonomy-wpdmcategory.php", WPDM_TPL_FALLBACK, WPDM_TPL_FALLBACK);
173 }
174 /*if($_template !== 'single-wpdmpro.php' && is_singular('wpdmpro')){
175 $template = Template::locate("single-wpdmpro.php", WPDM_TPL_FALLBACK, WPDM_TPL_FALLBACK);
176 }*/
177 return $template;
178 }
179
180 function dashboardPages($post_id)
181 {
182 if (wp_is_post_revision($post_id)) return;
183 if (get_post_type($post_id) !== 'page') return;
184 $page_id = get_option('__wpdm_user_dashboard', 0);
185 $post = get_post($post_id);
186 $flush = 0;
187
188 //If no dashboard page is selected ( $page_id === 0 )
189 // And current page is dashboard shorotcode
190 if ((int)$page_id === 0 && has_shortcode($post->post_content, "wpdm_user_dashboard")) {
191 update_option('__wpdm_user_dashboard', $post_id);
192 $flush = 1;
193 }
194
195 $page_id = get_option('__wpdm_author_profile', 0);
196
197 if ((int)$page_id === 0 && has_shortcode($post->post_content, "wpdm_user_profile")) {
198 update_option('__wpdm_author_profile', $post_id);
199 $flush = 1;
200 }
201
202 if ($flush == 1) {
203 $this->addWriteRules();
204 global $wp_rewrite;
205 $wp_rewrite->flush_rules();
206 }
207
208 }
209
210 function dashboardPageVars($vars)
211 {
212 array_push($vars, 'udb_page', 'adb_page', 'page_id', 'wpdmdl', 'ind', 'profile', 'wpdm_asset_key');
213 return $vars;
214 }
215
216
217 /**
218 * @usage Process Download Request from lock options
219 */
220 function triggerDownload()
221 {
222
223 global $wpdb, $current_user, $wp_query;
224 if (preg_match("/\/wpdmdl\/([\d]+)-([^\/]+)\/(.+)/", $_SERVER['REQUEST_URI'])) {
225 $uri = trim(__::valueof($_SERVER, 'REQUEST_URI', ['validate' => 'txt']), '/');
226 $download_url_base = get_option('__wpdm_download_url_base', 'download');
227 $uri = explode("/" . $download_url_base . "/", $uri);
228 $parts = explode("/", $uri[1]);
229 $parts = explode("-", $parts[0]);
230 $_REQUEST['wpdmdl'] = $_GET['wpdmdl'] = (int)$parts[0];
231 $wp_query->query_vars['wpdmdl'] = (int)$parts[0];
232 $parts = json_decode(base64_decode($parts[1]));
233 if (is_array($parts)) {
234 foreach ($parts as $key => $val) {
235 $_REQUEST[$key] = $_GET[$key] = sanitize_text_field($val);
236 }
237 }
238 }
239
240 //Instant download link processing
241 if (isset($_GET['wpdmidl'])) {
242 $file = TempStorage::get("__wpdm_instant_download_" . wpdm_query_var('wpdmidl'));
243 if (!$file)
244 Messages::error(__("Download ID not found or expired", "download-manager"), 1);
245 if (!file_exists($file))
246 Messages::error(__("The file is already removed from the server!", "download-manager"), 1);
247
248 FileSystem::downloadFile($file, wpdm_basename($file));
249 die();
250 }
251
252 //Regular download processing
253 if (!isset($wp_query->query_vars['wpdmdl']) && !isset($_GET['wpdmdl'])) return;
254
255
256 $id = isset($_GET['wpdmdl']) ? (int)$_GET['wpdmdl'] : (int)$wp_query->query_vars['wpdmdl'];
257 if ($id <= 0) return;
258
259
260 //Master key validation
261 $masterKey = wpdm_query_var('masterkey');
262 $hasMasterKey = $masterKey !== '' ? true : false;
263 $isMasterKeyValid = WPDM()->package->validateMasterKey($id, $masterKey);
264 $isMaster = $hasMasterKey && $isMasterKeyValid;
265
266 //Temporary download key validation
267 $key = wpdm_query_var('_wpdmkey');
268 $key = $key == '' && array_key_exists('_wpdmkey', $wp_query->query_vars) ? $wp_query->query_vars['_wpdmkey'] : $key;
269 $key = preg_replace("/[^_a-z|A-Z|0-9]/i", "", $key);
270
271 $keyValid = 0;
272
273 if ($key) {
274 $keyValid = is_wpdmkey_valid($id, $key, true);
275
276 if ((int)$keyValid !== 1) {
277 Messages::error(__("&mdash; Invalid download link &mdash;", "download-manager"), 1);
278 }
279 }
280
281
282 if (WPDM()->package->isLocked($id) && !$keyValid && !$isMaster)
283 Messages::error(__("&mdash; You are not allowed to download &mdash;", "download-manager"), 1);
284
285
286 //$package = get_post($id, ARRAY_A);
287 $package = WPDM()->package->init($id);
288 $package = (array)$package;
289 $package['access'] = WPDM()->package->allowedRoles($id);
290
291 $package = apply_filters("wpdm_before_download", $package);
292
293 if ($isMaster || $keyValid) {
294 $package['access'] = array('guest');
295 }
296
297 if(!is_user_logged_in() && get_post_status($id) !== 'publish') {
298 Messages::error( __( '403 - Access Forbidden!', 'download-manager' ), 1 );
299 }
300
301 $matched = (is_array(@maybe_unserialize($package['access'])) && is_user_logged_in()) ? array_intersect($current_user->roles, @maybe_unserialize($package['access'])) : array();
302
303
304 if ((($id != '' && is_user_logged_in() && count($matched) < 1 && !@in_array('guest', $package['access'])) || (!is_user_logged_in() && !@in_array('guest', $package['access']) && $id != ''))) {
305 do_action("wpdm_download_permission_denied", $id);
306 wpdm_download_data("permission-denied.txt", __("You don't have permission to download this file", "download-manager"));
307 die();
308 } else {
309 if ($package['ID'] > 0) {
310
311 if ((int)$package['quota'] == 0 || $package['quota'] > $package['download_count']) {
312 $package['force_download'] = wpdm_query_var('_wpdmkey');
313 include(WPDM_BASE_DIR . "src/wpdm-start-download.php");
314 } else
315 wpdm_download_data("stock-limit-reached.txt", __("Stock Limit Reached", "download-manager"));
316
317 }
318
319 }
320 }
321
322
323 /**
324 * @usage Add with main RSS feed
325 * @param $query
326 * @return mixed
327 */
328 function rssFeed($query)
329 {
330 if (isset($query['feed']) && !isset($query['post_type']) && get_option('__wpdm_rss_feed_main', 0) == 1) {
331 $query['post_type'] = array('post', 'wpdmpro');
332 }
333 return $query;
334 }
335
336 /**
337 * @usage Schedule custom ping
338 * @param $post_id
339 */
340 function customPings($post_id)
341 {
342 wp_schedule_single_event(time() + 5000, 'do_pings', array($post_id));
343 }
344
345 /**
346 * @usage Allow access to server file browser for selected user roles
347 */
348 function sfbAccess()
349 {
350
351 global $wp_roles;
352 if (!is_array($wp_roles->roles)) return;
353 $roleids = array_keys($wp_roles->roles);
354 $roles = get_option('_wpdm_file_browser_access', array('administrator'));
355 $naroles = array_diff($roleids, $roles);
356 foreach ($roles as $role) {
357 $role = get_role($role);
358 if (is_object($role) && !is_wp_error($role))
359 $role->add_cap('access_server_browser');
360 }
361
362 foreach ($naroles as $role) {
363 $role = get_role($role);
364 if (is_object($role) && !is_wp_error($role) && in_array('access_server_browser', $role->capabilities)) {
365 $role->remove_cap('access_server_browser');
366 }
367 }
368
369 }
370
371 /**
372 * @usage Allow front-end users to access their own files only
373 * @param $query_params
374 * @return string
375 */
376 function usersMediaQuery($query_params)
377 {
378 global $current_user;
379
380 if (current_user_can('edit_posts')) return $query_params;
381
382 if (is_user_logged_in()) {
383 $query_params['author'] = $current_user->ID;
384 }
385 return $query_params;
386 }
387
388 /**
389 * @usage Add packages wth tag query
390 * @param $query
391 * @return mixed
392 */
393 function queryTag($query)
394 {
395
396 if ($query->is_tag() && $query->is_main_query()) {
397 $post_type = get_query_var('post_type');
398 if (!is_array($post_type))
399 $post_type = array('post', 'page', 'wpdmpro', 'nav_menu_item');
400 else
401 $post_type = array_merge($post_type, array('post', 'wpdmpro', 'nav_menu_item'));
402 $query->set('post_type', $post_type);
403 }
404 return $query;
405 }
406
407 /**
408 * Empty cache dir
409 */
410 function clearCache()
411 {
412 __::isAuthentic('ccnonce', WPDM_PRI_NONCE, 'manage_options');
413 FileSystem::deleteFiles(WPDM_CACHE_DIR, false);
414 FileSystem::deleteFiles(WPDM_CACHE_DIR . 'pdfthumbs/', false);
415 global $wpdb;
416 Session::reset();
417 TempStorage::clear();
418 die('ok');
419 }
420
421 /**
422 * Delete all download hostory
423 */
424 function clearStats()
425 {
426 __::isAuthentic('csnonce', WPDM_PRI_NONCE, 'manage_options');
427 global $wpdb;
428 $wpdb->query('truncate table ' . $wpdb->prefix . 'ahm_download_stats');
429 $wpdb->query('truncate table ' . $wpdb->prefix . 'ahm_user_download_counts');
430 $wpdb->query("delete from {$wpdb->prefix}postmeta where meta_key='__wpdmx_user_download_count'");
431 die('ok');
432 }
433
434
435 /**
436 * @usage Add generator tag
437 */
438 function addGenerator()
439 {
440 echo '<meta name="generator" content="WordPress Download Manager ' . WPDM_VERSION . '" />' . "\r\n";
441 }
442
443 function oEmbed($content)
444 {
445 if (get_post_type(get_the_ID()) !== 'wpdmpro') return $content;
446 if (function_exists('wpdmpp_effective_price') && wpdmpp_effective_price(get_the_ID()) > 0)
447 $template = '<table class="table table-bordered"><tbody><tr><td colspan="2">[excerpt_200]</td></tr><tr><td>[txt=Price]</td><td>[currency][effective_price]</td></tr><tr><td>[txt=Version]</td><td>[version]</td></tr><tr><td>[txt=Total Files]</td><td>[file_count]</td></tr><tr><td>[txt=File Size]</td><td>[file_size]</td></tr><tr><td>[txt=Create Date]</td><td>[create_date]</td></tr><tr><td>[txt=Last Updated]</td><td>[update_date]</td><tr><td colspan="2" style="text-align: right;border-bottom: 0"><a class="wpdmdlbtn" href="[page_url]" target="_parent">[txt=Buy Now]</a></td></tr></tbody></table><br/><style> .wpdmdlbtn {-moz-box-shadow:inset 0px 1px 0px 0px #9acc85;-webkit-box-shadow:inset 0px 1px 0px 0px #9acc85;box-shadow:inset 0px 1px 0px 0px #9acc85;background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #74ad5a), color-stop(1, #68a54b));background:-moz-linear-gradient(top, #74ad5a 5%, #68a54b 100%);background:-webkit-linear-gradient(top, #74ad5a 5%, #68a54b 100%);background:-o-linear-gradient(top, #74ad5a 5%, #68a54b 100%);background:-ms-linear-gradient(top, #74ad5a 5%, #68a54b 100%);background:linear-gradient(to bottom, #74ad5a 5%, #68a54b 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=\'#74ad5a\', endColorstr=\'#68a54b\',GradientType=0);background-color:#74ad5a;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;border:1px solid #3b6e22;display:inline-block;cursor:pointer;color:#ffffff !important; font-size:12px;font-weight:bold;padding:10px 20px;text-transform: uppercase;text-decoration:none !important;}.wpdmdlbtn:hover {background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #68a54b), color-stop(1, #74ad5a));background:-moz-linear-gradient(top, #68a54b 5%, #74ad5a 100%);background:-webkit-linear-gradient(top, #68a54b 5%, #74ad5a 100%);background:-o-linear-gradient(top, #68a54b 5%, #74ad5a 100%);background:-ms-linear-gradient(top, #68a54b 5%, #74ad5a 100%);background:linear-gradient(to bottom, #68a54b 5%, #74ad5a 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=\'#68a54b\', endColorstr=\'#74ad5a\',GradientType=0);background-color:#68a54b;}.wpdmdlbtn:active {position:relative;top:1px;} .table{width:100%;border: 1px solid #eeeeee;} .table td{ padding:10px;border-bottom:1px solid #eee;}</style>';
448 else
449 $template = '<table class="table table-bordered"><tbody><tr><td colspan="2">[excerpt_200]</td></tr><tr><td>[txt=Version]</td><td>[version]</td></tr><tr><td>[txt=Total Files]</td><td>[file_count]</td></tr><tr><td>[txt=File Size]</td><td>[file_size]</td></tr><tr><td>[txt=Create Date]</td><td>[create_date]</td></tr><tr><td>[txt=Last Updated]</td><td>[update_date]</td><tr><td colspan="2" style="text-align: right;border-bottom: 0"><a class="wpdmdlbtn" href="[page_url]" target="_parent">[txt=Download]</a></td></tr></tbody></table><br/><style> .wpdmdlbtn {-moz-box-shadow:inset 0px 1px 0px 0px #9acc85;-webkit-box-shadow:inset 0px 1px 0px 0px #9acc85;box-shadow:inset 0px 1px 0px 0px #9acc85;background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #74ad5a), color-stop(1, #68a54b));background:-moz-linear-gradient(top, #74ad5a 5%, #68a54b 100%);background:-webkit-linear-gradient(top, #74ad5a 5%, #68a54b 100%);background:-o-linear-gradient(top, #74ad5a 5%, #68a54b 100%);background:-ms-linear-gradient(top, #74ad5a 5%, #68a54b 100%);background:linear-gradient(to bottom, #74ad5a 5%, #68a54b 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=\'#74ad5a\', endColorstr=\'#68a54b\',GradientType=0);background-color:#74ad5a;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;border:1px solid #3b6e22;display:inline-block;cursor:pointer;color:#ffffff !important; font-size:12px;font-weight:bold;padding:10px 20px;text-transform: uppercase;text-decoration:none !important;}.wpdmdlbtn:hover {background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #68a54b), color-stop(1, #74ad5a));background:-moz-linear-gradient(top, #68a54b 5%, #74ad5a 100%);background:-webkit-linear-gradient(top, #68a54b 5%, #74ad5a 100%);background:-o-linear-gradient(top, #68a54b 5%, #74ad5a 100%);background:-ms-linear-gradient(top, #68a54b 5%, #74ad5a 100%);background:linear-gradient(to bottom, #68a54b 5%, #74ad5a 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=\'#68a54b\', endColorstr=\'#74ad5a\',GradientType=0);background-color:#68a54b;}.wpdmdlbtn:active {position:relative;top:1px;} .table{width:100%; border: 1px solid #eeeeee; } .table td{ padding:10px;border-bottom:1px solid #eee;}</style>';
450 return WPDM()->package->fetchTemplate($template, get_the_ID());
451 }
452
453 function showLockOptions()
454 {
455 if (!isset($_REQUEST['id'])) die('ID Missing!');
456 echo WPDM()->package->downloadLink(wpdm_query_var('id', 'int'), 1);
457 die();
458 }
459
460
461 function verifyEmail($errors, $sanitized_user_login, $user_email)
462 {
463 if (!$errors) $errors = new \WP_Error();
464 if (!wpdm_verify_email($user_email)) {
465 $emsg = get_option('__wpdm_blocked_domain_msg');
466 if (trim($emsg) === '') $emsg = __('Your email address is blocked!', 'download-manager');
467 $errors->add('blocked_email', $emsg);
468 }
469 return $errors;
470 }
471
472 function verifyLoginEmail($user, $user_login, $user_pass)
473 {
474
475 $user_email = null;
476 if(!is_email($user_login) && !$user) {
477 $_user = get_user_by('user_login', $user_login);
478 if($_user)
479 $user_email = $_user->user_email;
480 } else if(is_email($user_login))
481 $user_email = $user_login;
482 else if($user && isset($user->user_email))
483 $user_email = $user->user_email;
484
485 if (is_email($user_email) && !wpdm_verify_email($user_email)) {
486 $user = new \WP_Error();
487 $emsg = get_option('__wpdm_blocked_domain_msg');
488 if (trim($emsg) === '') $emsg = __('Your email address is blocked!', 'download-manager');
489 $user->add('blocked_email', $emsg);
490 }
491 return $user;
492 }
493
494
495 function validateLoginPage($content)
496 {
497 if (is_singular('page')) {
498 $id = get_option('__wpdm_login_url', 0);
499 if ($id > 0 && $id == get_the_ID()) {
500 if (!has_shortcode($content, 'wpdm_login_form') && !has_shortcode($content, 'wpdm_user_dashboard') && !has_shortcode($content, 'wpdm_author_dashboard')) {
501 $content = WPDM()->user->login->form();
502 }
503 }
504 }
505 return $content;
506
507 }
508
509 function removeCommentFeed($feed)
510 {
511 if (get_post_type() == 'wpdmpro' && get_option('__wpdm_has_archive', false) == false)
512 $feed = false;
513 return $feed;
514 }
515
516 function wpHead(){
517
518 self::googleFont();
519
520 }
521
522 static function googleFont()
523 {
524 $wpdmss = maybe_unserialize(get_option('__wpdm_disable_scripts', array()));
525 $uicolors = maybe_unserialize(get_option('__wpdm_ui_colors', array()));
526 //$ltemplates = maybe_unserialize(get_option("_fm_link_templates", true));
527 //$ptemplates = maybe_unserialize(get_option("_fm_page_templates", true));
528 $font = get_option( '__wpdm_google_font', 'Sen' );
529 $font = explode( ":", $font );
530 $font = str_replace("+", " ", $font[0]);
531 $font = $font ? "{$font}" : '';
532 $font = $font ? "{$font}" : '-apple-system';
533
534 $css = WPDM()->packageTemplate->getStyles('link');
535
536 ?>
537 <?php if ((int)get_option('__wpdm_enable_gf', 0) === 1 && get_option('__wpdm_google_font') !== '') { ?>
538 <link href="https://fonts.googleapis.com/css2?family=<?php echo get_option('__wpdm_google_font', 'Sen'); ?>"
539 rel="stylesheet">
540 <style>
541 .w3eden .fetfont,
542 .w3eden .btn,
543 .w3eden .btn.wpdm-front h3.title,
544 .w3eden .wpdm-social-lock-box .IN-widget a span:last-child,
545 .w3eden #xfilelist .panel-heading,
546 .w3eden .wpdm-frontend-tabs a,
547 .w3eden .alert:before,
548 .w3eden .panel .panel-heading,
549 .w3eden .discount-msg,
550 .w3eden .panel.dashboard-panel h3,
551 .w3eden #wpdm-dashboard-sidebar .list-group-item,
552 .w3eden #package-description .wp-switch-editor,
553 .w3eden .w3eden.author-dashbboard .nav.nav-tabs li a,
554 .w3eden .wpdm_cart thead th,
555 .w3eden #csp .list-group-item,
556 .w3eden .modal-title {
557 font-family: "<?php echo __::sanitize_var($font); ?>", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
558 text-transform: uppercase;
559 font-weight: 700;
560 }
561 .w3eden #csp .list-group-item {
562 text-transform: unset;
563 }
564
565
566 </style>
567 <?php } ?>
568 <style>
569 <?php
570 echo '/* WPDM Link Template Styles */';
571 echo wpdm_escs($css);
572 ?>
573 </style>
574 <?php
575 self::uiColors();
576
577 }
578
579 static function uiColors($override_option = true)
580 {
581
582 $wpdmss = maybe_unserialize(get_option('__wpdm_disable_scripts', array()));
583 if (is_array($wpdmss) && in_array('wpdm-front', $wpdmss) && !is_admin()) return;
584
585 $uicolors = maybe_unserialize(get_option('__wpdm_ui_colors', array()));
586 $primary = isset($uicolors['primary']) ? $uicolors['primary'] : '#4a8eff';
587 $secondary = isset($uicolors['secondary']) ? $uicolors['secondary'] : '#4a8eff';
588 $success = isset($uicolors['success']) ? $uicolors['success'] : '#18ce0f';
589 $info = isset($uicolors['info']) ? $uicolors['info'] : '#2CA8FF';
590 $warning = isset($uicolors['warning']) ? $uicolors['warning'] : '#f29e0f';
591 $danger = isset($uicolors['danger']) ? $uicolors['danger'] : '#ff5062';
592 $font = get_option( '__wpdm_google_font', 'Sen' );
593 $font = explode( ":", $font );
594 $font = $font[0];
595 $font = $font ? "{$font}" : '';
596 $font = $font ? "{$font}" : '-apple-system';
597 if (is_singular('wpdmpro'))
598 $ui_button = get_option('__wpdm_ui_download_button');
599 else
600 $ui_button = get_option('__wpdm_ui_download_button_sc');
601 $class = ".btn." . (isset($ui_button['color']) ? $ui_button['color'] : 'btn-primary') . (isset($ui_button['size']) && $ui_button['size'] != '' ? "." . $ui_button['size'] : '');
602
603 ?>
604 <style>
605
606 :root {
607 --color-primary: <?php echo esc_attr($primary); ?>;
608 --color-primary-rgb: <?php echo esc_attr(wpdm_hex2rgb($primary)); ?>;
609 --color-primary-hover: <?php echo esc_attr( isset($uicolors['primary'])?$uicolors['primary_hover']:'#4a8eff' ); ?>;
610 --color-primary-active: <?php echo esc_attr( isset($uicolors['primary'])?$uicolors['primary_active']:'#4a8eff' ); ?>;
611 --clr-sec: <?php echo $secondary; ?>;
612 --clr-sec-rgb: <?php echo wpdm_hex2rgb($secondary); ?>;
613 --clr-sec-hover: <?php echo isset($uicolors['secondary'])?$uicolors['secondary_hover']:'#4a8eff'; ?>;
614 --clr-sec-active: <?php echo isset($uicolors['secondary'])?$uicolors['secondary_active']:'#4a8eff'; ?>;
615 --color-secondary: <?php echo esc_attr( $secondary ); ?>;
616 --color-secondary-rgb: <?php echo esc_attr(wpdm_hex2rgb($secondary)); ?>;
617 --color-secondary-hover: <?php echo esc_attr( isset($uicolors['secondary'])?$uicolors['secondary_hover']:'#4a8eff' ); ?>;
618 --color-secondary-active: <?php echo esc_attr( isset($uicolors['secondary'])?$uicolors['secondary_active']:'#4a8eff' ); ?>;
619 --color-success: <?php echo esc_attr( $success ); ?>;
620 --color-success-rgb: <?php echo esc_attr(wpdm_hex2rgb($success)); ?>;
621 --color-success-hover: <?php echo esc_attr( isset($uicolors['success_hover'])?$uicolors['success_hover']:'#4a8eff' ); ?>;
622 --color-success-active: <?php echo esc_attr( isset($uicolors['success_active'])?$uicolors['success_active']:'#4a8eff' ); ?>;
623 --color-info: <?php echo esc_attr( $info ); ?>;
624 --color-info-rgb: <?php echo esc_attr(wpdm_hex2rgb($info)); ?>;
625 --color-info-hover: <?php echo esc_attr( isset($uicolors['info_hover'])?$uicolors['info_hover']:'#2CA8FF' ); ?>;
626 --color-info-active: <?php echo esc_attr( isset($uicolors['info_active'])?$uicolors['info_active']:'#2CA8FF' ); ?>;
627 --color-warning: <?php echo esc_attr( $warning ); ?>;
628 --color-warning-rgb: <?php echo esc_attr(wpdm_hex2rgb($warning)); ?>;
629 --color-warning-hover: <?php echo esc_attr( isset($uicolors['warning_hover'])?$uicolors['warning_hover']:'orange' ); ?>;
630 --color-warning-active: <?php echo esc_attr( isset($uicolors['warning_active'])?$uicolors['warning_active']:'orange' ); ?>;
631 --color-danger: <?php echo esc_attr( $danger ); ?>;
632 --color-danger-rgb: <?php echo esc_attr(wpdm_hex2rgb($danger)); ?>;
633 --color-danger-hover: <?php echo esc_attr( isset($uicolors['danger_hover'])?$uicolors['danger_hover']:'#ff5062' ); ?>;
634 --color-danger-active: <?php echo esc_attr( isset($uicolors['danger_active'])?$uicolors['danger_active']:'#ff5062' ); ?>;
635 --color-green: <?php echo esc_attr( isset($uicolors['green'])?$uicolors['green']:'#30b570' ); ?>;
636 --color-blue: <?php echo esc_attr( isset($uicolors['blue'])?$uicolors['blue']:'#0073ff' ); ?>;
637 --color-purple: <?php echo esc_attr( isset($uicolors['purple'])?$uicolors['purple']:'#8557D3' ); ?>;
638 --color-red: <?php echo esc_attr( isset($uicolors['red'])?$uicolors['red']:'#ff5062' ); ?>;
639 --color-muted: rgba(69, 89, 122, 0.6);
640 --wpdm-font: "<?php echo esc_attr( $font ); ?>", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
641 }
642
643 .wpdm-download-link<?php echo sanitize_text_field($class); ?> {
644 border-radius: <?php echo (int)( isset($ui_button['borderradius']) ? $ui_button['borderradius'] : 4 ); ?>px;
645 }
646
647
648 </style>
649 <?php
650
651 }
652
653
654
655 /**
656 * @usage Password generator
657 */
658 function generatePassword()
659 {
660 if (!current_user_can(WPDM_MENU_ACCESS_CAP) || !wpdm_is_ajax()) die();
661 include(Template::locate('generate-password.php', __DIR__.'/views'));
662 die();
663
664 }
665
666 /**
667 * Allow <style> tag in wp_kses_post filter.
668 *
669 * @param array $allowed_tags Allowed HTML tags and attributes.
670 * @param string $context The context for which to retrieve tags.
671 * @return array Modified allowed tags.
672 */
673 function allowStyleTagInKses( $allowed_tags, $context ) {
674 if ( 'post' !== $context ) {
675 return $allowed_tags;
676 }
677
678 $allowed_tags['style'] = array(
679 'type' => true,
680 'media' => true,
681 'nonce' => true,
682 'id' => true,
683 'class' => true,
684 );
685
686 return $allowed_tags;
687 }
688
689 /**
690 * @usage Active premium package add-on / shopping cart
691 */
692 function activatePremiumPackage()
693 {
694 __::isAuthentic('wpdmappnonce', WPDM_PRI_NONCE, WPDM_ADMIN_CAP);
695
696 if (current_user_can(WPDM_ADMIN_CAP)) {
697 include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
698 include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
699 $upgrader = new \Plugin_Upgrader(new \Plugin_Installer_Skin(compact('title', 'url', 'nonce', 'plugin', 'api')));
700 $downloadlink = 'https://downloads.wordpress.org/plugin/wpdm-premium-packages.zip';
701 ob_start();
702 echo "<div id='acto'>";
703 if (file_exists(dirname(dirname(__FILE__)) . '/wpdm-premium-packages/'))
704 $upgrader->upgrade($downloadlink);
705 else
706 $upgrader->install($downloadlink);
707 echo '</div><style>#acto .wrap { display: none; }</style>';
708 $data = ob_get_clean();
709 if (file_exists(dirname(WPDM_BASE_DIR) . '/wpdm-premium-packages/wpdm-premium-packages.php')) {
710 activate_plugin('wpdm-premium-packages/wpdm-premium-packages.php');
711 echo "Congratulation! Your Digital Store is Activated. <a href='' class='btn btn-warning'>Refresh The Page!</a>";
712 } else
713 echo "Automatic Installation Failed! Please <a href='".admin_url('plugin-install.php?tab=plugin-information&plugin=wpdm-premium-packages')."' target='_blank' class='btn btn-warning'>Download</a> and install manually";
714 die();
715 } else {
716 die("Only site admin is authorized to install add-on");
717 }
718 }
719
720
721 }
722
723