WordPress Download Manager - Version 2.6.2

Version Description

  • Fixed an issue with categroy short-code pagination
Download this release

Release Info

Developer codename065
Plugin Icon 128x128 WordPress Download Manager
Version 2.6.2
Comparing to
See all releases

Code changes from version 2.5.97 to 2.6.2

download-manager.php CHANGED
@@ -1,1044 +1,1054 @@
1
- <?php
2
- /*
3
- Plugin Name: Download Manager
4
- Plugin URI: http://www.wpdownloadmanager.com/
5
- Description: Manage, track and control file download from your wordpress site
6
- Author: Shaon
7
- Version: 2.5.97
8
- Author URI: http://www.wpdownloadmanager.com/
9
- */
10
-
11
- error_reporting(0);
12
-
13
- $d = str_replace('\\','/',dirname(__FILE__));
14
- $d = explode("/", $d);
15
- array_pop($d);
16
- array_pop($d);
17
- $d = implode('/', $d);
18
-
19
- define('UPLOAD_DIR',$d.'/uploads/download-manager-files/');
20
- define('UPLOAD_BASE',$d.'/uploads/');
21
-
22
- function wpdm_process(){
23
- if(!isset($_GET['wpdmact'])) return;
24
- if($_GET['wpdmact']=='process')
25
- include("process.php");
26
- }
27
-
28
- include(dirname(__FILE__)."/functions.php");
29
- include(dirname(__FILE__)."/class.wpdmpagination.php");
30
- include(dirname(__FILE__)."/wpdm-server-file-browser.php");
31
- include(dirname(__FILE__)."/wpdm-free-mce-button.php");
32
-
33
- if(!$_POST) $_SESSION['download'] = 0;
34
-
35
- function wpdm_download_info(){
36
- include("download.php");
37
- }
38
-
39
- function wpdm_free_install(){
40
- global $wpdb;
41
-
42
- $sql = "CREATE TABLE IF NOT EXISTS `ahm_files` (
43
- `id` int(11) NOT NULL AUTO_INCREMENT,
44
- `title` varchar(255) NOT NULL,
45
- `description` text NOT NULL,
46
- `category` text NOT NULL,
47
- `file` varchar(255) NOT NULL,
48
- `password` varchar(40) NOT NULL,
49
- `download_count` int(11) NOT NULL,
50
- `access` enum('guest','member') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
51
- `show_counter` tinyint(1) NOT NULL,
52
- `quota` INT NOT NULL,
53
- `link_label` varchar(255) NOT NULL,
54
- `icon` VARCHAR( 256 ) NOT NULL,
55
- PRIMARY KEY (`id`)
56
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8";
57
-
58
- require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
59
-
60
- $wpdb->query($sql);
61
- $tmpdata = $wpdb->get_results("SHOW COLUMNS FROM ahm_files");
62
- foreach($tmpdata as $d){
63
- $fields[] = $d->Field;
64
- }
65
- if(!in_array('icon',$fields))
66
- $wpdb->query("ALTER TABLE `ahm_files` ADD `icon` VARCHAR( 255 ) NOT NULL");
67
-
68
- update_option('wpdm_access_level','publish_posts');
69
- wpdm_create_dir();
70
-
71
- }
72
-
73
- function wpdm_top_packages($show=5, $show_count=true){
74
- global $wpdb;
75
-
76
- $data = $wpdb->get_results("select * from ahm_files order by download_count desc limit 0, $show",ARRAY_A);
77
- foreach($data as $d){
78
- $d['title'] = stripcslashes($d['title']);
79
- $key = $d['id'];
80
- if($show_count) $sc = "<br/><i>$d[download_count] downloads</i>";
81
- $url = home_url("/?download={$d[id]}");
82
- echo "<li><div class='wpdm_link'><a class='wpdm-popup' title='$d[title]' href='$url'>{$d[title]}</a> $sc</div></li>\r\n";
83
- }
84
- }
85
-
86
- function wpdm_new_packages($show=5, $show_count=true){
87
- global $wpdb;
88
-
89
- $data = $wpdb->get_results("select * from ahm_files order by id desc limit 0, $show",ARRAY_A);
90
- foreach($data as $d){
91
- $key = $d['id'];
92
- $d['title'] = stripcslashes($d['title']);
93
- $d['icon'] = $d['icon']?$d['icon']:'file_extension_'.end(explode('.',$d['file'])).'.png';
94
- if($show_count) $sc = "<br/><i>$d[download_count] downloads</i>";
95
- $url = home_url("/?download={$d[id]}");
96
- echo "<li><div class='wpdm_link'><img src='".plugins_url('download-manager/icon/'.$d['icon'])."' style='border:0px;box-shadow:none;float:left;margin-right:5px;margin-top:5px;'><a style='line-height:normal;' class='wpdm-popup' title='$d[title]' href='$url'>{$d[title]}</a> $sc</div><div style='clear:both;margin-bottom:5px'></div></li>\r\n";
97
- }
98
- }
99
-
100
- function wpdm_import_download_monitor(){
101
- global $wpdb;
102
- $data = $wpdb->get_results("select * from {$wpdb->prefix}download_monitor_files");
103
- if($data){
104
- foreach($data as $d){
105
- $tdata = $wpdb->get_results("select t.name from {$wpdb->prefix}download_monitor_taxonomies t,{$wpdb->prefix}download_monitor_relationships r where t.taxonomy='category' and t.id=r.taxonomy_id and r.download_id={$d->id}");
106
- $ct = array();
107
- foreach($tdata as $c){
108
- $ctu = strtolower(preg_replace("/([^a-zA-Z0-9\-]+)/","-", $c->name));
109
- $ct[] = $ctu;
110
- $allc["$ctu"] = array('title'=>$c->name);
111
- }
112
- $wpdm = array(
113
- 'title'=>$d->title,
114
- 'description'=>$d->file_description,
115
- 'file'=>$d->filename,
116
- 'password'=>'',
117
- 'download_count'=>$d->hits,
118
- 'access'=> ($d->member?'member':'guest'),
119
- 'show_counter'=>'1',
120
- 'quota'=>'0',
121
- 'category' => serialize($ct),
122
- 'link_label'=>'Download'
123
- );
124
- $wpdb->insert('ahm_files', $wpdm);
125
- }
126
- $tpldata = maybe_unserialize(get_option('_fm_categories'));
127
- if(!$tpldata) $tpldata = array();
128
- $tpldata = $tpldata + $allc;
129
- update_option('_fm_categories',@serialize($tpldata));
130
- }
131
- echo "
132
- <script>
133
- location.href='admin.php?page=file-manager';
134
- </script>
135
- ";
136
- die();
137
-
138
-
139
- }
140
-
141
- function wpdm_all_packages($params = array()){
142
- @extract($params);
143
- global $wpdb, $current_user;
144
- ob_start();
145
- include("wpdm-all-downloads.php");
146
- $data = ob_get_contents();
147
- ob_clean();
148
- return $data;
149
- }
150
-
151
- function wpdm_downloadable_nsc($params){
152
- global $wpdb;
153
- extract($params);
154
-
155
- $home = home_url('/');
156
- $password_field = '';
157
- $bg = '';
158
-
159
- $sap = count($_GET)>0?'&':'?';
160
-
161
- $data = $wpdb->get_row("select * from ahm_files where id='$id'",ARRAY_A);
162
- $data['title'] = stripcslashes($data['title']);
163
- $data['description'] = stripcslashes($data['description']);
164
- if($title=='true') $title = "<h3>".$data['title']."</h3>";
165
- else $title = '';
166
- if($desc=='true') $desc = wpautop($data['description'])."</br>";
167
- else $desc = '';
168
- $desc = stripslashes($desc);
169
- if($data['show_counter']!=0) $hc= 'has-counter';
170
- if($template=='') $template = 'wpdm-only-button';
171
- else $template = "wpdm-{$template}";
172
- $wpdm_login_msg = get_option('wpdm_login_msg')?get_option('wpdm_login_msg'):'Login Required';
173
- $link_label = $data['link_label']?$data['link_label']:'Download';
174
- if($data['access']=='member'&&!is_user_logged_in()){
175
- $url = get_option('siteurl')."/wp-login.php?redirect_to=".$_SERVER['REQUEST_URI'];
176
- $uuid = uniqid();
177
- /*$args = array(
178
- 'echo' => false,
179
- 'redirect' => $_SERVER['REQUEST_URI'],
180
- 'form_id' => 'loginform_'.$id,
181
- 'label_username' => __( 'Username' ),
182
- 'label_password' => __( 'Password' ),
183
- 'label_remember' => __( 'Remember Me' ),
184
- 'label_log_in' => __( 'Log In' ),
185
- 'id_username' => 'user_login',
186
- 'id_password' => 'user_pass',
187
- 'id_remember' => 'rememberme_'.$id,
188
- 'id_submit' => 'wp-submit_'.$id,
189
- 'remember' => true,
190
- 'value_username' => NULL,
191
- 'value_remember' => false );
192
- $loginform = "<div id='wpdm-login-form' class='wpdm-login-form'>".wp_login_form( $args ).'</div>';*/
193
-
194
- //"<div class=passit>Login Required<br/><input placeholder='Username' type=text id='username_{$id}' size=15 class='inf' /> <input placeholder='Password' class='inf' type=password id='password_{$id}' size=15 /><span class='perror'></span></div>";
195
- if($data['icon']!='') $bg = "background-image: url(".plugins_url()."/download-manager/icon/{$data[icon]});";
196
-
197
- $html = "<div id='wpdm_file_{$id}' class='wpdm_file $template'>{$title}<div class='cont'>{$desc}{$loginform}<div class='btn_outer'><div class='btn_outer_c' style='{$bg}'><a class='btn_left $classrel $hc login-please' rel='{$id}' title='{$data[title]}' href='$url' >$link_label</a>";
198
- //if($data['show_counter']!=0)
199
- //$html .= "<span class='btn_right counter'>$data[download_count] downloads</span>";
200
- //else
201
- $html .= "<span class='btn_right counter'>Login Required</span>";
202
- $html .= "</div></div><div class='clear'></div></div></div>";
203
- }
204
- else {
205
- if($data['icon']!='') $bg = "background-image: url(\"".plugins_url()."/download-manager/icon/{$data[icon]}\");";
206
- if($data['password']=='') { $url = home_url('/?wpdmact=process&did='.base64_encode($id.'.hotlink')); $classrel = ""; }
207
- else { $classrel='haspass'; /*$url = home_url('/?download='.$id);*/ $url = home_url('/'); $password_field = "<div class=passit>Enter password<br/><input type=password id='pass_{$id}' size=15 /><span class='perror'></span></div>"; }
208
- $html = "<div id='wpdm_file_{$id}' class='wpdm_file $template'>{$title}<div class='cont'>{$desc}{$password_field}<div class='btn_outer'><div class='btn_outer_c' style='{$bg}'><a class='btn_left $classrel $hc' rel='{$id}' title='{$data['title']}' href='$url' >$link_label</a>";
209
- if($data['show_counter']!=0)
210
- $html .= "<span class='btn_right counter'>$data[download_count] downloads</span>";
211
- else
212
- $html .= "<span class='btn_right'>&nbsp;</span>";
213
- $html .= "</div></div><div class='clear'></div></div></div>";
214
- }
215
- return $html;
216
- }
217
-
218
- function wpdm_downloadable($content){
219
- global $wpdb;
220
-
221
- preg_match_all("/\{filelink\=([^\}]+)\}/", $content, $matches);
222
-
223
- $home = home_url('/');
224
-
225
- $sap = count($_GET)>0?'&':'?';
226
- for($i=0;$i<count($matches[1]);$i++){
227
- $id = $matches[1][$i];
228
- $data = $wpdb->get_row("select * from ahm_files where id='$id'",ARRAY_A);
229
- $data['title'] = stripcslashes($data['title']);
230
- $wpdm_login_msg = get_option('wpdm_login_msg')?get_option('wpdm_login_msg'):'Login Required';
231
- $link_label = $data['link_label']?$data['link_label']:'Download';
232
- if($data['access']=='member'&&!is_user_logged_in())
233
- $matches[1][$i] = "<a href='".get_option('siteurl')."/wp-login.php?redirect_to=".$_SERVER['REQUEST_URI']."' style=\"background:url('".get_option('siteurl')."/wp-content/plugins/download-manager/l24.png') no-repeat;padding:3px 12px 12px 28px;font:bold 10pt verdana;\">".$wpdm_login_msg."</a>";
234
- else {
235
- if($data['password']=='') { $url = home_url('/?wpdmact=process&did='.base64_encode($id.'.hotlink')); $classrel = ""; }
236
- else { $url = home_url('/?download='.$id); $classrel = " class='wpdm-popup' rel='colorbox' "; }
237
- $matches[1][$i] = "<a $classrel title='{$data[title]}' href='$url' style=\"background:url('".get_option('siteurl')."/wp-content/plugins/download-manager/icon/download.png') no-repeat;padding:3px 12px 12px 28px;font:bold 10pt verdana;\">$link_label</a>";
238
- if($data['show_counter']!=0)
239
- $matches[1][$i] .= "<br><small style='margin-left:30px;'>Downloaded $data[download_count] times</small>";
240
- }
241
- }
242
-
243
- preg_match_all("/\{wpdm_category\=([^\}]+)\}/", $content, $cmatches);
244
- for($i=0;$i<count($cmatches[1]);$i++){
245
- $cmatches[1][$i] = wpdm_embed_category($cmatches[1][$i]);
246
- }
247
- $content = str_replace($cmatches[0],$cmatches[1], $content);
248
- return str_replace($matches[0],$matches[1], $content);
249
-
250
- }
251
-
252
- function wpdm_cblist_categories($parent="", $level = 0, $sel = array()){
253
- $cats = maybe_unserialize(get_option('_fm_categories'));
254
- if(is_array($cats)){
255
- //if($parent!='') echo "<ul>";
256
- foreach($cats as $id=>$cat){
257
- $pres = str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", $level);
258
- if($cat['parent']==$parent){
259
- if(in_array($id,$sel))
260
- $checked = 'checked=checked';
261
- else
262
- $checked = '';
263
- echo "<li style='line-height:16px'><label><input type='checkbox' name='file[category][]' value='$id' $checked /> $cat[title]</label>";
264
- echo "<ul style='margin:0px;margin-left:20px;padding:0px;'>";
265
- wpdm_cblist_categories($id,$level+1, $sel);
266
- echo "</ul>";
267
- echo "</li>\n";
268
- }
269
- }
270
- //if($parent!='') echo "</ul>";
271
- }
272
- }
273
-
274
- function wpdm_dropdown_categories($parent="", $level = 0, $sel='',$cid='',$class=array()){
275
- $cats = maybe_unserialize(get_option('_fm_categories'));
276
- if(!is_array($cats)) $cats = array();
277
- foreach($cats as $id=>$cat){
278
- $pres = str_repeat("&mdash;", $level);
279
- array_push($class,$parent);
280
- if($parent=='') $class = array();
281
- $class = array_unique($class);
282
- $cssclass = implode(" ",$class);
283
- if($cat['parent']==$parent){
284
- if($sel==$id)
285
- echo "<option class='level_{$level} $id $cssclass' selected=selected value='$id'>{$pres} $cat[title]</option>\n";
286
- else
287
- echo "<option class='level_{$level} $id $cssclass' value='$id'>{$pres} $cat[title]</option>\n";
288
- wpdm_dropdown_categories($id,$level+1, $sel, $cid, $class);}
289
- }
290
-
291
- }
292
-
293
- function wpdm_tree(){
294
- $treejs = plugins_url().'/download-manager/js/jqueryFileTree.js';
295
- $treecss = plugins_url().'/download-manager/css/jqueryFileTree.css';
296
- $siteurl = site_url();
297
- $data = <<<TREE
298
- <script language="JavaScript" src="{$treejs}"></script>
299
- <link rel="stylesheet" href="{$treecss}" />
300
- <div id="tree"></div>
301
- <script language="JavaScript">
302
- <!--
303
- jQuery(document).ready( function() {
304
- jQuery('#tree').fileTree({
305
- script: '{$siteurl}/?task=wpdm_tree',
306
- expandSpeed: 1000,
307
- collapseSpeed: 1000,
308
- multiFolder: false
309
- }, function(file) {
310
- //alert(file);
311
- //var sfilename = file.split('/');
312
- //var filename = sfilename[sfilename.length-1];
313
- tb_show(jQuery(this).html(),'{$siteurl}/?download='+file+'&modal=1&width=600&height=400');
314
-
315
- });
316
-
317
-
318
- });
319
- //-->
320
- </script>
321
- TREE;
322
-
323
- return $data;
324
- }
325
-
326
- function wpdm_embed_tree(){
327
- if(!isset($_GET['task'])||$_GET['task']!='wpdm_tree') return;
328
- global $wpdb;
329
- $cats = maybe_unserialize(get_option('_fm_categories'));
330
- if(!is_array($cats)) $cats = array();
331
-
332
-
333
-
334
-
335
- echo "<ul class=\"jqueryFileTree\" style=\"display: none;\">";
336
- // All Cats
337
- $_POST['dir'] = $_POST['dir']=='/'?'':$_POST['dir'];
338
- foreach( $cats as $id=>$file ) {
339
- if($file['parent']==$_POST['dir'])
340
- echo "<li class=\"directory collapsed\"><a href=\"#\" rel=\"" . $id . "\">" . htmlentities(stripcslashes($file['title'])) . "</a></li>";
341
- }
342
-
343
- // All files
344
-
345
-
346
- if($_POST['dir'])
347
- $ndata = $wpdb->get_results("select * from ahm_files where category like '%\"{$_POST['dir']}\"%'",ARRAY_A);
348
- else
349
- $ndata = $wpdb->get_results("select * from ahm_files where category = 'N;'",ARRAY_A);
350
-
351
- $sap = '?'; //count($_GET)>0?'&':'?';
352
-
353
- foreach($ndata as $data){
354
- $html = '';
355
- $data['title'] = stripcslashes($data['title']);
356
- $link_label = $data['title']?$data['title']:'Download';
357
- $data['page_link'] = "<a class='wpdm-popup' href='' rel='{$data['id']}'>$link_label</a>";
358
- if(isset($data['preview'])&&$data['preview']!='')
359
- $data['thumb'] = "<img class='wpdm_icon' align='left' src='".plugins_url()."/{$data['preview']}' />";
360
- else
361
- $data['thumb'] = '';
362
- if(isset($data['icon'])&&$data['icon']!='')
363
- $data['icon'] = "<img class='wpdm_icon' align='left' src='".plugins_url()."/{$data['icon']}' />";
364
- else
365
- $data['icon'] = '';
366
-
367
-
368
- if($data['show_counter']==1){
369
- $counter = "{$data['download_count']} downloads<br/>";
370
- $data['counter'] = $counter;
371
- }
372
- $ext = end(explode(".", $data['file']));
373
- //foreach( $data as $ind=>$val ) $reps["[".$ind."]"] = $val;
374
- //$repeater = stripslashes( strtr( $category['template_repeater'], $reps ));
375
- $template = "<li class=\"wpdm_clink file ext_$ext\">$data[page_link]</li>";
376
- if($data['access']=='member'&&!is_user_logged_in())
377
- $template = "<li class=\"file ext_$ext\"><a href='".get_option('siteurl')."/wp-login.php?redirect_to=".$_SERVER['REQUEST_URI']."' >{$data['title']}<small> (login to download)</small></a></li>";
378
- $html .= $template;
379
-
380
-
381
-
382
- echo $html;
383
-
384
-
385
-
386
-
387
-
388
-
389
-
390
- }
391
- echo "</ul>";
392
- die();
393
-
394
-
395
- }
396
-
397
- function wpdm_admin_options(){
398
-
399
- if(!file_exists(UPLOAD_DIR)&&$_GET[task]!='wpdm_create_dir'){
400
-
401
- echo "
402
- <div id=\"warning\" class=\"error fade\"><p>
403
- Automatic dir creation failed! [ <a href='admin.php?page=file-manager&task=CreateDir&re=1'>Try again to create dir automatically</a> ]<br><br>
404
- Please create dir <strong>" . UPLOAD_DIR . "</strong> manualy and set permision to <strong>777</strong><br><br>
405
- Otherwise you will not be able to upload files.</p></div>";
406
- }
407
-
408
- if(isset($_GET['success'])&&$_GET['success']==1){
409
- echo "
410
- <div id=\"message\" class=\"updated fade\"><p>
411
- Congratulation! Plugin is ready to use now.
412
- </div>
413
- ";
414
- }
415
-
416
-
417
- if(!file_exists(UPLOAD_DIR.'.htaccess'))
418
- wpdm_set_htaccess();
419
-
420
- if(isset($_GET['task'])&&$_GET['task']!=''&&function_exists($_GET['task']))
421
- return call_user_func($_GET['task']);
422
- else
423
- include('wpdm-list-files.php');
424
- }
425
-
426
- function wpdm_delete_file(){
427
- global $wpdb;
428
- if(is_array($_GET[id])){
429
- foreach($_GET[id] as $id){
430
- $qry[] = "id='".(int)$id."'";
431
- }
432
- $cond = implode(" and ", $qry);
433
- } else
434
- $cond = "id='".(int)$_GET[id]."'";
435
- $wpdb->query("delete from ahm_files where ". $cond);
436
- echo "<script>
437
- location.href='admin.php?page=file-manager';
438
- </script>";
439
- die();
440
- }
441
-
442
- function wpdm_create_dir(){
443
- if(!file_exists(UPLOAD_BASE)){
444
- @mkdir(UPLOAD_BASE,0777);
445
- }
446
- @chmod(UPLOAD_BASE,0777);
447
- @mkdir(UPLOAD_DIR,0777);
448
- @chmod(UPLOAD_DIR,0777);
449
- @chmod(dir(__FILE__).'/cache/',0777);
450
- wpdm_set_htaccess();
451
- if(isset($_GET['re'])&&$_GET['re']==1) {
452
- if(file_exists(UPLOAD_DIR)) $s=1;
453
- else $s = 0;
454
- echo "<script>
455
- location.href='{$_SERVER[HTTP_REFERER]}&success={$s}';
456
- </script>";
457
- die();
458
- }
459
- }
460
-
461
- function wpdm_settings(){
462
- if(isset($_POST['access'])){
463
-
464
- update_option('wpdm_access_level',$_POST['access']);
465
- update_option('wpdm_login_msg',$_POST['wpdm_login_msg']);
466
- update_option('wpdm_show_cinfo',$_POST['wpdm_show_cinfo']);
467
- }
468
- if(is_uploaded_file($_FILES['icon']['tmp_name'])){
469
- ///print_r(dirname(__FILE__).'/icon/download.png');
470
- move_uploaded_file($_FILES['icon']['tmp_name'],dirname(__FILE__).'/icon/download.png');
471
- }
472
- $access = get_option('wpdm_access_level');
473
- $wpdm_show_cinfo = get_option('wpdm_show_cinfo');
474
- include('wpdm-settings.php');
475
- }
476
-
477
- function wpdm_add_new_file(){
478
- global $wpdb;
479
-
480
- if(isset($_POST['file'])){
481
- extract($_POST);
482
-
483
-
484
- $file['show_counter'] = 0;
485
- $file['quota'] = $file['quota']?$file['quota']:0;
486
- $file['category'] = serialize($file['category']);
487
- $wpdb->insert("ahm_files", $file);
488
- if(!$wpdb->insert_id){
489
- $wpdb->show_errors();
490
- $wpdb->print_error();
491
- die();
492
- }
493
- die('Created!');
494
-
495
- }
496
-
497
- if(!file_exists(UPLOAD_DIR)){
498
-
499
- echo "
500
- <div id=\"warning\" class=\"error fade\"><p>
501
- Automatic dir creation failed! [ <a href='admin.php?page=file-manager&task=wpdm_create_dir&re=1'>Try again to create dir automatically</a> ]<br><br>
502
- Please create dir <strong>" . UPLOAD_DIR . "</strong> manualy and set permision to <strong>777</strong><br><br>
503
- Otherwise you will not be able to upload files.
504
- </p></div>";
505
- }
506
-
507
- if($_GET['success']==1){
508
- echo "
509
- <div id=\"message\" class=\"updated fade\"><p>
510
- Congratulation! Plugin is ready to use now.
511
- </div>
512
- ";
513
- }
514
-
515
-
516
- include('wpdm-add-new-file.php');
517
- }
518
-
519
- function wpdm_edit_file(){
520
- global $wpdb;
521
- if($_POST['file']&&$_POST['id']){
522
- extract($_POST);
523
-
524
-
525
- $file['category'] = serialize($file['category']);
526
-
527
- $wpdb->update("ahm_files", $file, array("id"=>$_POST['id']));
528
-
529
- die('Updated!');
530
-
531
- }
532
- $id = intval($_GET[id]);
533
- $file = $wpdb->get_row("select * from ahm_files where id='$id'",ARRAY_A);
534
-
535
- include('wpdm-add-new-file.php');
536
- }
537
-
538
- function wpdm_categories(){
539
- $cid = addslashes($_GET['cid']);
540
- if($_GET['task']=='DeleteCategory'){
541
- $tpldata = maybe_unserialize(get_option('_fm_categories'));
542
- unset($tpldata[$cid]);
543
- update_option('_fm_categories',@serialize($tpldata));
544
- echo "<script>
545
- location.href='{$_SERVER[HTTP_REFERER]}';
546
- </script>";
547
- die();
548
- }
549
- if($_POST['cat']){
550
- $tpldata = maybe_unserialize(get_option('_fm_categories'));
551
- if(!is_array($tpldata)) $tpldata =array();
552
- $_POST['cat']['title'] = esc_attr($_POST['cat']['title']);
553
- $_POST['cat']['content'] = esc_attr($_POST['cat']['content']);
554
- $tcid = $_POST['cid']?$_POST['cid']:trim(strtolower(preg_replace("/([^a-zA-Z0-9\-]+)/","-", $_POST['cat']['title'])),"-");
555
- if($tcid=='') $tcid = uniqid();
556
- $tcid = $tcid=='-'?uniqid():$tcid;
557
- $cid = $tcid;
558
- while(array_key_exists($cid, $tpldata)&&$_POST['cid']==''){
559
- $cid = $tcid."-".(++$postfx);
560
- }
561
-
562
- if($_POST['cat']['title']!=''){
563
- $tpldata[$cid] = $_POST['cat'];
564
- update_option('_fm_categories',@serialize($tpldata)); }
565
- echo "<script>
566
- location.href='{$_SERVER[HTTP_REFERER]}';
567
- </script>";
568
- die();
569
- }
570
- include("wpdm-categories.php");
571
- }
572
-
573
- function wpdm_cat_dropdown_tree($parent="", $level = 0){
574
- $cats = maybe_unserialize(get_option('_fm_categories'));
575
- foreach($cats as $id=>$cat){
576
- $pres = str_repeat("&mdash;", $level);
577
- if($cat['parent']==$parent){
578
- echo "<option value='$id'>{$pres} $cat[title]</option>\n";
579
- wpdm_cat_dropdown_tree($id,$level+1);}
580
- }
581
- }
582
-
583
- function wpdm_embed_category($id){
584
- global $wpdb, $current_user, $post, $wp_query;
585
- $postlink = get_permalink($post->ID);
586
- get_currentuserinfo();
587
-
588
- $user = new WP_User(null);
589
- $categories = maybe_unserialize(get_option("_fm_categories",true));
590
- $category = $categories[$id];
591
- $total = $wpdb->get_var("select count(*) from ahm_files where category like '%\"$id\"%'");
592
-
593
- $item_per_page = 10;
594
- $pages = ceil($total/$item_per_page);
595
- $page = $_GET['cp']?$_GET['cp']:1;
596
- $start = ($page-1)*$item_per_page;
597
- $pag = new wpdmpagination();
598
- $pag->items($total);
599
- $pag->limit($item_per_page);
600
- $pag->currentPage($page);
601
- $plink = $url = preg_replace("/[\?|\&]+cp=[0-9]+/","",$_SERVER['REQUEST_URI']);
602
- $url = strpos($url,'?')?$url.'&':$url.'?';
603
- $pag->urlTemplate($url."cp=[%PAGENO%]");
604
-
605
- $ndata = $wpdb->get_results("select * from ahm_files where category like '%\"$id\"%' limit $start, $item_per_page",ARRAY_A);
606
-
607
-
608
- $sap = strpos($plink,'?')>0?'&':'?';
609
- $html = '';
610
- foreach($ndata as $data){
611
-
612
- $link_label = $data['title']?stripcslashes($data['title']):'Download';
613
- $data['page_link'] = "<a class='wpdm-popup' href='{$postlink}{$sap}download={$data['id']}'>$link_label</a>";
614
- //if($data['password']=='') { $data['page_link'] = "<a href='".home_url('/?wpdmact=process&did='.base64_encode($id.'.hotlink'))."'>{$link_label}</a>"; }
615
- if($data['password']=='') {
616
- $url = home_url('/?wpdmact=process&did='.base64_encode($data['id'].'.hotlink'));
617
- $data['page_link'] = "<a href='{$url}'>$link_label</a>";
618
- }
619
- if($data['icon']!='') $bg = "background-image: url(\"".plugins_url()."/download-manager/icon/{$data[icon]}\");";
620
-
621
- if($data['show_counter']==1){
622
- $counter = "{$data[download_count]} downloads<br/>";
623
- $data['counter'] = $counter;
624
- }
625
-
626
- //foreach( $data as $ind=>$val ) $reps["[".$ind."]"] = $val;
627
- //$repeater = stripslashes( strtr( $category['template_repeater'], $reps ));
628
- $template = "<li><div class='wpdm_clink' style='{$bg}'><b>$data[page_link]</b><br/><small>$data[counter]</small></div></li>";
629
- if($data['access']=='member'&&!is_user_logged_in())
630
- $template = "<li><div class='wpdm_clink' style='{$bg}'><a href='".get_option('siteurl')."/wp-login.php?redirect_to=".$_SERVER['REQUEST_URI']."' >$data[title]</a></b><br/><small>login to download</small></div></li>";
631
- $html .= $template;
632
-
633
-
634
- END;
635
-
636
-
637
-
638
-
639
-
640
-
641
-
642
- }
643
-
644
- if(get_option('wpdm_show_cinfo','no')=='yes') $html = "<h3>{$category['title']}</h3>".wpautop($category['content']).$html;
645
-
646
- return "<ul class='wpdm-category $id'>".$html."</ul><div style='clear:both'></div>".$pag->show()."<div style='clear:both'></div>";
647
- }
648
-
649
- function wpdm_embed_category_sc($params){
650
- global $wpdb, $current_user, $post, $wp_query;
651
- extract($params);
652
- $postlink = get_permalink($post->ID);
653
- get_currentuserinfo();
654
-
655
- $user = new WP_User(null);
656
- $categories = maybe_unserialize(get_option("_fm_categories",true));
657
- $category = $categories[$id];
658
- $order = isset($order) && $order!="" ? $order: "desc";
659
-
660
- $order_query = isset($order_field) && $order_field != '' ? "order by $order_field $order" : "order by id DESC";
661
- $total = $wpdb->get_var("select count(*) from ahm_files where category like '%\"$id\"% $order_query'");
662
-
663
- $item_per_page = 10;
664
- $pages = ceil($total/$item_per_page);
665
- $page = $_GET['cp']?$_GET['cp']:1;
666
- $start = ($page-1)*$item_per_page;
667
- $pag = new wpdmpagination();
668
- $pag->items($total);
669
- $pag->limit($item_per_page);
670
- $pag->currentPage($page);
671
- $plink = $url = preg_replace("/[\?|\&]+cp=[0-9]+/","",$_SERVER['REQUEST_URI']);
672
- $url = strpos($url,'?')?$url.'&':$url.'?';
673
- $pag->urlTemplate($url."cp=[%PAGENO%]");
674
-
675
- $ndata = $wpdb->get_results("select * from ahm_files where category like '%\"$id\"%' $order_query limit $start, $item_per_page",ARRAY_A);
676
-
677
-
678
-
679
- $sap = strpos($plink,'?')>0?'&':'?';
680
- $html = '';
681
- foreach($ndata as $data){
682
-
683
- $link_label = $data['title']?stripcslashes($data['title']):'Download';
684
- $data['page_link'] = "<a class='wpdm-popup' href='{$postlink}{$sap}download={$data['id']}'>$link_label</a>";
685
- //if($data['password']=='') { $data['page_link'] = "<a href='".home_url('/?wpdmact=process&did='.base64_encode($id.'.hotlink'))."'>{$link_label}</a>"; }
686
- if($data['password']=='') {
687
- $url = home_url('/?wpdmact=process&did='.base64_encode($data['id'].'.hotlink'));
688
- $data['page_link'] = "<a href='{$url}'>$link_label</a>";
689
- }
690
- if($data['icon']!='') $bg = "background-image: url(\"".plugins_url()."/download-manager/icon/{$data[icon]}\");";
691
-
692
- if($data['show_counter']==1){
693
- $counter = "{$data[download_count]} downloads<br/>";
694
- $data['counter'] = $counter;
695
- }
696
-
697
- //foreach( $data as $ind=>$val ) $reps["[".$ind."]"] = $val;
698
- //$repeater = stripslashes( strtr( $category['template_repeater'], $reps ));
699
- $template = "<li><div class='wpdm_clink' style='{$bg}'><b>$data[page_link]</b><br/><small>$data[counter]</small></div></li>";
700
- if($data['access']=='member'&&!is_user_logged_in())
701
- $template = "<li><div class='wpdm_clink' style='{$bg}'><a href='".get_option('siteurl')."/wp-login.php?redirect_to=".$_SERVER['REQUEST_URI']."' >$data[title]</a></b><br/><small>login to download</small></div></li>";
702
- $html .= $template;
703
-
704
-
705
- END;
706
-
707
-
708
-
709
-
710
-
711
-
712
-
713
- }
714
-
715
- if(get_option('wpdm_show_cinfo','no')=='yes') $html = "<h3>{$category['title']}</h3>".wpautop($category['content']).$html;
716
-
717
- return "<ul class='wpdm-category $id'>".$html."</ul><div style='clear:both'></div>".$pag->show()."<div style='clear:both'></div>";
718
- }
719
-
720
-
721
- function wpdm_tinymce()
722
- {
723
- wp_enqueue_script('common');
724
- wp_enqueue_script('jquery-color');
725
- wp_admin_css('thickbox');
726
- wp_print_scripts('post');
727
- wp_print_scripts('media-upload');
728
- wp_print_scripts('jquery');
729
- wp_print_scripts('jquery-ui-core');
730
- wp_print_scripts('jquery-ui-tabs');
731
- wp_print_scripts('tiny_mce');
732
- wp_print_scripts('editor');
733
- wp_print_scripts('editor-functions');
734
- add_thickbox();
735
- //wp_tiny_mce();
736
- //wp_admin_css();
737
- wp_enqueue_script('utils');
738
- do_action("admin_print_styles-post-php");
739
- do_action('admin_print_styles');
740
- remove_all_filters('mce_external_plugins');
741
- }
742
-
743
- function wpdm_set_htaccess(){
744
- $cont = 'RewriteEngine On
745
- <Files *>
746
- Deny from all
747
- </Files>
748
- ';
749
- @file_put_contents(UPLOAD_DIR.'.htaccess',$cont);
750
- }
751
-
752
-
753
- function wpdm_front_js(){
754
- ?>
755
- <script language="JavaScript">
756
- <!--
757
- jQuery(function(){
758
-
759
- jQuery('.wpdm-popup').click(function(){
760
- tb_show(jQuery(this).html(),this.href+'&modal=1&width=600&height=400');
761
- return false;
762
- });
763
-
764
- jQuery('.haspass').click(function(){
765
- var url = jQuery(this).attr('href');
766
- var id = jQuery(this).attr('rel');
767
- var password = jQuery('#pass_'+id).val();
768
- jQuery.post('<?php echo home_url('/'); ?>',{download:id,password:password},function(res){
769
-
770
- if(res=='error') {
771
-
772
- jQuery('#wpdm_file_'+id+' .perror').html('Wrong Password');
773
- setTimeout("jQuery('#wpdm_file_"+id+" .perror').html('');",3000);
774
- return false;
775
- } else {
776
- location.href = '<?php echo home_url('/?wpdmact=process&did='); ?>'+res;
777
- }
778
- //if(res.url!='undefined') location.href=res.url;
779
-
780
- });
781
-
782
- return false;
783
- });
784
- })
785
- //-->
786
- </script>
787
- <?php
788
- }
789
-
790
- function wpdm_copyold(){
791
- global $wpdb;
792
- $ids = get_option('wpdmc2p_ids',true);
793
- if($_POST['task']=='wpdm_copy_files'){
794
- if(!is_array($ids)) $ids = array();
795
- if(!is_array($_POST[id])) $_POST[id] = array();
796
- foreach($_POST[id] as $fid){
797
- //if(!in_array($fid, $ids)){
798
- $file = $wpdb->get_row("select * from ahm_files where id='$fid'", ARRAY_A);
799
- unset($file[id]);
800
- //print_r($file);
801
- //$wpdb->show_errors();
802
- $wpdb->insert("ahm_files",$file);
803
- //$wpdb->print_error();die() ;
804
- //}
805
- }
806
- if(is_array($ids))
807
- $ids = array_unique(array_merge($ids, $_POST['id']));
808
- else
809
- $ids = $_POST['id'];
810
- /*foreach($_POST as $optn=>$optv){
811
- update_option($optn, $optv);
812
- } */
813
-
814
- update_option('wpdmc2p_ids',$ids);
815
- die('Copied successfully');
816
- }
817
-
818
- $res = mysql_query("select * from ahm_files");
819
-
820
- ?>
821
-
822
-
823
- <div class="wrap">
824
- <div class="icon32" id="icon-upload"><br></div>
825
-
826
- <h2>Copy from Download Manager</h2> <br>
827
-
828
- <div class="clear"></div>
829
- <form action="" method="post">
830
- <input type="hidden" name="task" value="wpdm_copy_files" />
831
-
832
- <table cellspacing="0" class="widefat fixed">
833
- <thead>
834
- <tr>
835
- <th style="" class="manage-column column-cb check-column" id="cb" scope="col"><input class="call m" type="checkbox"></th>
836
- <th style="" class="manage-column column-media" id="media" scope="col">File</th>
837
- <th style="" class="manage-column column-parent" id="parent" scope="col">Copied</th>
838
- </tr>
839
- </thead>
840
-
841
- <tfoot>
842
- <tr>
843
- <th style="" class="manage-column column-cb check-column" id="cb" scope="col"><input class="call m" type="checkbox"></th>
844
- <th style="" class="manage-column column-media" id="media" scope="col">File</th>
845
- <th style="" class="manage-column column-parent" id="parent" scope="col">Copied</th>
846
- </tr>
847
- </tfoot>
848
-
849
- <tbody class="list:post" id="the-list">
850
- <?php while($media = mysql_fetch_assoc($res)) { $media['copied'] = @in_array($media[id],$ids)?'Yes':'No'; ?>
851
- <tr valign="top" class="alternate author-self status-inherit" id="post-8">
852
-
853
- <th class="check-column" scope="row"><input type="checkbox" value="<?php echo $media[id];?>" class="m" name="id[]"></th>
854
-
855
- <td class="media column-media">
856
- <strong><a title="Edit" href="admin.php?page=file-manager&task=EditFile&id=<?php echo $media['id']?>"><?php echo $media['title']?></a></strong>
857
- </td>
858
- <td class="parent column-parent"><b><?php echo $media['copied']; ?></b></td>
859
-
860
- </tr>
861
- <?php } ?>
862
- </tbody>
863
- </table>
864
- <br>
865
-
866
- <input type="submit" value="Copy Selected Files" class="button-primary">
867
- </form>
868
- <script language="JavaScript">
869
- <!--
870
- jQuery('.call').click(function(){
871
- if(this.checked)
872
- jQuery('.m').attr('checked','checked');
873
- else
874
- jQuery('.m').removeAttr('checked');
875
- });
876
- //-->
877
- </script>
878
- </div>
879
- <?php
880
- }
881
-
882
- function wpdm_hotlink($params){
883
- global $wpdb;
884
- extract($params);
885
- if($id=='') return;
886
- $data = $wpdb->get_row("select * from ahm_files where id='$id'",ARRAY_A);
887
- if($data['id']=='') return;
888
- $data['link_label'] = stripcslashes($data['link_label']);
889
- $link_label = $link_label?$link_label:$data['link_label'];
890
- $url = home_url('/?wpdmact=process&did='.base64_encode($id.'.hotlink'));
891
- return "<a href='$url'>$link_label</a>";
892
-
893
- }
894
-
895
- function delete_all_cats(){
896
- if(!isset($_GET['page'])) return;
897
- if($_GET['page']=='file-manager/categories'&&$_GET['task']=='delete-all'){
898
- delete_option('_fm_categories');
899
- header('location: '.$_SERVER['HTTP_REFERER']);
900
- die();
901
- }
902
- }
903
-
904
- function wpdm_save_file(){
905
- global $wpdb;
906
- if(isset($_POST['id'])&&isset($_POST['wpdmtask'])&&$_POST['wpdmtask']=='update'){
907
- extract($_POST);
908
-
909
-
910
- $file['category'] = serialize($file['category']);
911
-
912
- $wpdb->update("ahm_files", $file, array("id"=>$_POST['id']));
913
-
914
- die('updated');
915
-
916
- }
917
-
918
- if($_POST['wpdmtask']=='create'){
919
- extract($_POST);
920
-
921
- $file['show_counter'] = 0;
922
- $file['quota'] = $file['quota']?$file['quota']:0;
923
- $file['category'] = serialize($file['category']);
924
- $file['title'] = esc_attr($file['title']);
925
- $id = $wpdb->insert("ahm_files", $file);
926
- if(!$wpdb->insert_id){
927
- $wpdb->show_errors();
928
- $wpdb->print_error();
929
- die();
930
- }
931
- echo $wpdb->insert_id;
932
- die();
933
- }
934
- }
935
-
936
-
937
- // handle uploaded file here
938
- function wpdm_check_upload(){
939
- check_ajax_referer('photo-upload');
940
- if(file_exists(UPLOAD_DIR.$_FILES['async-upload']['name']))
941
- $filename = time().'wpdm_'.$_FILES['async-upload']['name'];
942
- else
943
- $filename = $_FILES['async-upload']['name'];
944
- move_uploaded_file($_FILES['async-upload']['tmp_name'],UPLOAD_DIR.$filename);
945
- $filesize = number_format(filesize(UPLOAD_DIR.'/'.$filename)/1025,2);
946
- echo $filename."|||".$filesize;
947
- exit;
948
- }
949
-
950
- function wpdm_delete__file(){
951
- global $wpdb;
952
- $id = intval($_REQUEST['file']);
953
- $data = $wpdb->get_row("select * from ahm_files where id='$id'",ARRAY_A);
954
- if(file_exists(UPLOAD_DIR.'/'.$data['file']))
955
- @unlink(UPLOAD_DIR.'/'.$data['file']);
956
- else if(file_exists($data['file']))
957
- @unlink($data['file']);
958
- unset($data['file']);
959
- $wpdb->query("update ahm_files set `file`='' where id='$id'");
960
- die('ok');
961
- }
962
-
963
-
964
- function wpdm_help(){
965
- ?>
966
- <div class="wrap">
967
- <div class="icon32" id="icon-index"><br></div>
968
- <h2>Help</h2> <br>
969
-
970
- If you have anything to ask or if anything not clear please search or ask here:
971
- <br/>
972
- <strong><a href="http://www.wpdownloadmanager.com/support/forum/download-manager-free/" target="_blank">http://www.wpdownloadmanager.com/support/forum/download-manager-free/</a></strong>
973
-
974
-
975
-
976
- <?php
977
- }
978
-
979
-
980
-
981
- function wpdm_menu(){
982
- //echo get_option('wpdm_access_level','manage_options');die();
983
- add_menu_page("File Manager","File Manager",get_option('wpdm_access_level','manage_options'),'file-manager','wpdm_admin_options',plugins_url('download-manager/img/donwloadmanager-16.png'));
984
- add_submenu_page( 'file-manager', 'File Manager', 'Manage', get_option('wpdm_access_level','manage_options'), 'file-manager', 'wpdm_admin_options');
985
- add_submenu_page( 'file-manager', 'Add New File &lsaquo; File Manager', 'Add New File', get_option('wpdm_access_level','manage_options'), 'file-manager/add-new-file', 'wpdm_add_new_file');
986
- add_submenu_page( 'file-manager', 'Categories &lsaquo; File Manager', 'Categories', get_option('wpdm_access_level','manage_options'), 'file-manager/categories', 'wpdm_categories');
987
- add_submenu_page( 'file-manager', 'Settings &lsaquo; File Manager', 'Settings', get_option('wpdm_access_level','manage_options'), 'file-manager/settings', 'wpdm_settings');
988
- add_submenu_page( 'file-manager', 'Help &lsaquo; File Manager', 'Help', get_option('wpdm_access_level','manage_options'), 'file-manager/help', 'wpdm_help');
989
-
990
- }
991
-
992
-
993
- function wpdm_admin_enque_scripts(){
994
- wp_enqueue_style('icons',plugins_url().'/download-manager/css/icons.css');
995
- wp_enqueue_script('jquery');
996
- wp_enqueue_script('jquery-form');
997
- wp_enqueue_script('plupload-all');
998
- wp_enqueue_script('file-tree-js',plugins_url().'/download-manager/js/jqueryFileTree.js',array('jquery'));
999
- wp_enqueue_script('chosen-jquery',plugins_url().'/download-manager/js/chosen.jquery.min.js',array('jquery'));
1000
- wp_enqueue_style('chosen-css',plugins_url().'/download-manager/css/chosen.css');
1001
-
1002
- }
1003
-
1004
- function wpdm_enque_scripts(){
1005
- wp_enqueue_script('jquery');
1006
- wp_enqueue_script('thickbox');
1007
- wp_enqueue_style('thickbox');
1008
- wp_enqueue_style('wpdm-front',plugins_url().'/download-manager/css/front.css');
1009
- }
1010
-
1011
-
1012
- add_action("admin_menu","wpdm_menu");
1013
- add_action("init","delete_all_cats");
1014
-
1015
- add_action('admin_enqueue_scripts','wpdm_admin_enque_scripts');
1016
- add_action('wp_enqueue_scripts','wpdm_enque_scripts');
1017
- add_action('wp_head','wpdm_front_js');
1018
-
1019
- if(isset($_GET['page'])&&$_GET['page']=='file-manager/add-new-file')
1020
- add_filter('admin_head','wpdm_tinymce');
1021
-
1022
- add_action("wp","wpdm_download_info");
1023
-
1024
- add_filter( 'the_content', 'wpdm_downloadable');
1025
-
1026
- add_shortcode('wpdm_all_packages','wpdm_all_packages');
1027
- add_shortcode('wpdm_hotlink','wpdm_hotlink');
1028
- add_shortcode('wpdm_file','wpdm_downloadable_nsc');
1029
- add_shortcode('wpdm_tree','wpdm_tree');
1030
- add_shortcode('wpdm_category','wpdm_embed_category_sc');
1031
-
1032
- add_action('init','wpdm_embed_tree');
1033
- add_action('init','wpdm_process');
1034
- add_action('wp_ajax_file_upload','wpdm_check_upload');
1035
- add_action('wp_ajax_delete_file','wpdm_delete__file');
1036
- add_action('wp_ajax_save_wpdm_file','wpdm_save_file');
1037
-
1038
-
1039
- add_action("init","wpdm_file_browser");
1040
- add_action("init","wpdm_dir_tree");
1041
-
1042
- include("wpdm-widgets.php");
1043
-
1044
- register_activation_hook(__FILE__,'wpdm_free_install');
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Download Manager
4
+ Plugin URI: http://www.wpdownloadmanager.com/
5
+ Description: Manage, track and control file download from your wordpress site
6
+ Author: Shaon
7
+ Version: 2.6.2
8
+ Author URI: http://www.wpdownloadmanager.com/
9
+ */
10
+
11
+ error_reporting(0);
12
+
13
+ $d = str_replace('\\','/',dirname(__FILE__));
14
+ $d = explode("/", $d);
15
+ array_pop($d);
16
+ array_pop($d);
17
+ $d = implode('/', $d);
18
+
19
+ define('UPLOAD_DIR',$d.'/uploads/download-manager-files/');
20
+ define('UPLOAD_BASE',$d.'/uploads/');
21
+
22
+ function wpdm_process(){
23
+ if(!isset($_GET['wpdmact'])) return;
24
+ if($_GET['wpdmact']=='process')
25
+ include("process.php");
26
+ }
27
+
28
+ include(dirname(__FILE__)."/functions.php");
29
+ include(dirname(__FILE__)."/class.wpdmpagination.php");
30
+ include(dirname(__FILE__)."/wpdm-server-file-browser.php");
31
+ include(dirname(__FILE__)."/wpdm-free-mce-button.php");
32
+
33
+ if(!$_POST) $_SESSION['download'] = 0;
34
+
35
+ function wpdm_download_info(){
36
+ include("download.php");
37
+ }
38
+
39
+ function wpdm_free_install(){
40
+ global $wpdb;
41
+
42
+ $sql = "CREATE TABLE IF NOT EXISTS `ahm_files` (
43
+ `id` int(11) NOT NULL AUTO_INCREMENT,
44
+ `title` varchar(255) NOT NULL,
45
+ `description` text NOT NULL,
46
+ `category` text NOT NULL,
47
+ `file` varchar(255) NOT NULL,
48
+ `password` varchar(40) NOT NULL,
49
+ `download_count` int(11) NOT NULL,
50
+ `access` enum('guest','member') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
51
+ `show_counter` tinyint(1) NOT NULL,
52
+ `quota` INT NOT NULL,
53
+ `link_label` varchar(255) NOT NULL,
54
+ `icon` VARCHAR( 256 ) NOT NULL,
55
+ PRIMARY KEY (`id`)
56
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8";
57
+
58
+ require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
59
+
60
+ $wpdb->query($sql);
61
+ $tmpdata = $wpdb->get_results("SHOW COLUMNS FROM ahm_files");
62
+ foreach($tmpdata as $d){
63
+ $fields[] = $d->Field;
64
+ }
65
+ if(!in_array('icon',$fields))
66
+ $wpdb->query("ALTER TABLE `ahm_files` ADD `icon` VARCHAR( 255 ) NOT NULL");
67
+
68
+ update_option('wpdm_access_level','publish_posts');
69
+ delete_option('wpdm_first_install');
70
+ $tf = $wpdb->get_var("select count(*) from `ahm_files`");
71
+ if($tf==0){
72
+ update_option('wpdm_install_time',time());
73
+ update_option('wpdm_first_install',1);
74
+ }
75
+ wpdm_create_dir();
76
+
77
+ }
78
+
79
+ function wpdm_top_packages($show=5, $show_count=true){
80
+ global $wpdb;
81
+
82
+ $data = $wpdb->get_results("select * from ahm_files order by download_count desc limit 0, $show",ARRAY_A);
83
+ foreach($data as $d){
84
+ $d['title'] = stripcslashes($d['title']);
85
+ $key = $d['id'];
86
+ if($show_count) $sc = "<br/><i>$d[download_count] downloads</i>";
87
+ $url = home_url("/?download={$d[id]}");
88
+ echo "<li><div class='wpdm_link'><a class='wpdm-popup' title='$d[title]' href='$url'>{$d[title]}</a> $sc</div></li>\r\n";
89
+ }
90
+ }
91
+
92
+ function wpdm_new_packages($show=5, $show_count=true){
93
+ global $wpdb;
94
+
95
+ $data = $wpdb->get_results("select * from ahm_files order by id desc limit 0, $show",ARRAY_A);
96
+ foreach($data as $d){
97
+ $key = $d['id'];
98
+ $d['title'] = stripcslashes($d['title']);
99
+ $d['icon'] = $d['icon']?$d['icon']:'file_extension_'.end(explode('.',$d['file'])).'.png';
100
+ if($show_count) $sc = "<br/><i>$d[download_count] downloads</i>";
101
+ $url = home_url("/?download={$d[id]}");
102
+ echo "<li><div class='wpdm_link'><img src='".plugins_url('download-manager/icon/'.$d['icon'])."' style='border:0px;box-shadow:none;float:left;margin-right:5px;margin-top:5px;'><a style='line-height:normal;' class='wpdm-popup' title='$d[title]' href='$url'>{$d[title]}</a> $sc</div><div style='clear:both;margin-bottom:5px'></div></li>\r\n";
103
+ }
104
+ }
105
+
106
+ function wpdm_import_download_monitor(){
107
+ global $wpdb;
108
+ $data = $wpdb->get_results("select * from {$wpdb->prefix}download_monitor_files");
109
+ if($data){
110
+ foreach($data as $d){
111
+ $tdata = $wpdb->get_results("select t.name from {$wpdb->prefix}download_monitor_taxonomies t,{$wpdb->prefix}download_monitor_relationships r where t.taxonomy='category' and t.id=r.taxonomy_id and r.download_id={$d->id}");
112
+ $ct = array();
113
+ foreach($tdata as $c){
114
+ $ctu = strtolower(preg_replace("/([^a-zA-Z0-9\-]+)/","-", $c->name));
115
+ $ct[] = $ctu;
116
+ $allc["$ctu"] = array('title'=>$c->name);
117
+ }
118
+ $wpdm = array(
119
+ 'title'=>$d->title,
120
+ 'description'=>$d->file_description,
121
+ 'file'=>$d->filename,
122
+ 'password'=>'',
123
+ 'download_count'=>$d->hits,
124
+ 'access'=> ($d->member?'member':'guest'),
125
+ 'show_counter'=>'1',
126
+ 'quota'=>'0',
127
+ 'category' => serialize($ct),
128
+ 'link_label'=>'Download'
129
+ );
130
+ $wpdb->insert('ahm_files', $wpdm);
131
+ }
132
+ $tpldata = maybe_unserialize(get_option('_fm_categories'));
133
+ if(!$tpldata) $tpldata = array();
134
+ $tpldata = $tpldata + $allc;
135
+ update_option('_fm_categories',@serialize($tpldata));
136
+ }
137
+ echo "
138
+ <script>
139
+ location.href='admin.php?page=file-manager';
140
+ </script>
141
+ ";
142
+ die();
143
+
144
+
145
+ }
146
+
147
+ function wpdm_all_packages($params = array()){
148
+ @extract($params);
149
+ global $wpdb, $current_user;
150
+ ob_start();
151
+ include("wpdm-all-downloads.php");
152
+ $data = ob_get_contents();
153
+ ob_clean();
154
+ return $data;
155
+ }
156
+
157
+ function wpdm_downloadable_nsc($params){
158
+ global $wpdb;
159
+ extract($params);
160
+
161
+ $home = home_url('/');
162
+ $password_field = '';
163
+ $bg = '';
164
+
165
+ $sap = count($_GET)>0?'&':'?';
166
+
167
+ $data = $wpdb->get_row("select * from ahm_files where id='$id'",ARRAY_A);
168
+ $data['title'] = stripcslashes($data['title']);
169
+ $data['description'] = stripcslashes($data['description']);
170
+ if($title=='true') $title = "<h3>".$data['title']."</h3>";
171
+ else $title = '';
172
+ if($desc=='true') $desc = wpautop($data['description'])."</br>";
173
+ else $desc = '';
174
+ $desc = stripslashes($desc);
175
+ if($data['show_counter']!=0) $hc= 'has-counter';
176
+ if($template=='') $template = 'wpdm-only-button';
177
+ else $template = "wpdm-{$template}";
178
+ $wpdm_login_msg = get_option('wpdm_login_msg')?get_option('wpdm_login_msg'):'Login Required';
179
+ $link_label = $data['link_label']?$data['link_label']:'Download';
180
+ if($data['access']=='member'&&!is_user_logged_in()){
181
+ $url = get_option('siteurl')."/wp-login.php?redirect_to=".$_SERVER['REQUEST_URI'];
182
+ $uuid = uniqid();
183
+ /*$args = array(
184
+ 'echo' => false,
185
+ 'redirect' => $_SERVER['REQUEST_URI'],
186
+ 'form_id' => 'loginform_'.$id,
187
+ 'label_username' => __( 'Username' ),
188
+ 'label_password' => __( 'Password' ),
189
+ 'label_remember' => __( 'Remember Me' ),
190
+ 'label_log_in' => __( 'Log In' ),
191
+ 'id_username' => 'user_login',
192
+ 'id_password' => 'user_pass',
193
+ 'id_remember' => 'rememberme_'.$id,
194
+ 'id_submit' => 'wp-submit_'.$id,
195
+ 'remember' => true,
196
+ 'value_username' => NULL,
197
+ 'value_remember' => false );
198
+ $loginform = "<div id='wpdm-login-form' class='wpdm-login-form'>".wp_login_form( $args ).'</div>';*/
199
+
200
+ //"<div class=passit>Login Required<br/><input placeholder='Username' type=text id='username_{$id}' size=15 class='inf' /> <input placeholder='Password' class='inf' type=password id='password_{$id}' size=15 /><span class='perror'></span></div>";
201
+ if($data['icon']!='') $bg = "background-image: url(".plugins_url()."/download-manager/icon/{$data[icon]});";
202
+
203
+ $html = "<div id='wpdm_file_{$id}' class='wpdm_file $template'>{$title}<div class='cont'>{$desc}{$loginform}<div class='btn_outer'><div class='btn_outer_c' style='{$bg}'><a class='btn_left $classrel $hc login-please' rel='{$id}' title='{$data[title]}' href='$url' >$link_label</a>";
204
+ //if($data['show_counter']!=0)
205
+ //$html .= "<span class='btn_right counter'>$data[download_count] downloads</span>";
206
+ //else
207
+ $html .= "<span class='btn_right counter'>Login Required</span>";
208
+ $html .= "</div></div><div class='clear'></div></div></div>";
209
+ }
210
+ else {
211
+ if($data['icon']!='') $bg = "background-image: url(\"".plugins_url()."/download-manager/icon/{$data[icon]}\");";
212
+ if($data['password']=='') { $url = home_url('/?wpdmact=process&did='.base64_encode($id.'.hotlink')); $classrel = ""; }
213
+ else { $classrel='haspass'; /*$url = home_url('/?download='.$id);*/ $url = home_url('/'); $password_field = "<div class=passit>Enter password<br/><input type=password id='pass_{$id}' size=15 /><span class='perror'></span></div>"; }
214
+ $html = "<div id='wpdm_file_{$id}' class='wpdm_file $template'>{$title}<div class='cont'>{$desc}{$password_field}<div class='btn_outer'><div class='btn_outer_c' style='{$bg}'><a class='btn_left $classrel $hc' rel='{$id}' title='{$data['title']}' href='$url' >$link_label</a>";
215
+ if($data['show_counter']!=0)
216
+ $html .= "<span class='btn_right counter'>$data[download_count] downloads</span>";
217
+ else
218
+ $html .= "<span class='btn_right'>&nbsp;</span>";
219
+ $html .= "</div></div><div class='clear'></div></div></div>";
220
+ }
221
+ return $html;
222
+ }
223
+
224
+ function wpdm_downloadable($content){
225
+ global $wpdb;
226
+
227
+ preg_match_all("/\{filelink\=([^\}]+)\}/", $content, $matches);
228
+
229
+ $home = home_url('/');
230
+
231
+ $sap = count($_GET)>0?'&':'?';
232
+ for($i=0;$i<count($matches[1]);$i++){
233
+ $id = $matches[1][$i];
234
+ $data = $wpdb->get_row("select * from ahm_files where id='$id'",ARRAY_A);
235
+ $data['title'] = stripcslashes($data['title']);
236
+ $wpdm_login_msg = get_option('wpdm_login_msg')?get_option('wpdm_login_msg'):'Login Required';
237
+ $link_label = $data['link_label']?$data['link_label']:'Download';
238
+ if($data['access']=='member'&&!is_user_logged_in())
239
+ $matches[1][$i] = "<a href='".get_option('siteurl')."/wp-login.php?redirect_to=".$_SERVER['REQUEST_URI']."' style=\"background:url('".get_option('siteurl')."/wp-content/plugins/download-manager/l24.png') no-repeat;padding:3px 12px 12px 28px;font:bold 10pt verdana;\">".$wpdm_login_msg."</a>";
240
+ else {
241
+ if($data['password']=='') { $url = home_url('/?wpdmact=process&did='.base64_encode($id.'.hotlink')); $classrel = ""; }
242
+ else { $url = home_url('/?download='.$id); $classrel = " class='wpdm-popup' rel='colorbox' "; }
243
+ $matches[1][$i] = "<a $classrel title='{$data[title]}' href='$url' style=\"background:url('".get_option('siteurl')."/wp-content/plugins/download-manager/icon/download.png') no-repeat;padding:3px 12px 12px 28px;font:bold 10pt verdana;\">$link_label</a>";
244
+ if($data['show_counter']!=0)
245
+ $matches[1][$i] .= "<br><small style='margin-left:30px;'>Downloaded $data[download_count] times</small>";
246
+ }
247
+ }
248
+
249
+ preg_match_all("/\{wpdm_category\=([^\}]+)\}/", $content, $cmatches);
250
+ for($i=0;$i<count($cmatches[1]);$i++){
251
+ $cmatches[1][$i] = wpdm_embed_category($cmatches[1][$i]);
252
+ }
253
+ $content = str_replace($cmatches[0],$cmatches[1], $content);
254
+ return str_replace($matches[0],$matches[1], $content);
255
+
256
+ }
257
+
258
+ function wpdm_cblist_categories($parent="", $level = 0, $sel = array()){
259
+ $cats = maybe_unserialize(get_option('_fm_categories'));
260
+ if(is_array($cats)){
261
+ //if($parent!='') echo "<ul>";
262
+ foreach($cats as $id=>$cat){
263
+ $pres = str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", $level);
264
+ if($cat['parent']==$parent){
265
+ if(in_array($id,$sel))
266
+ $checked = 'checked=checked';
267
+ else
268
+ $checked = '';
269
+ echo "<li style='line-height:16px'><label><input type='checkbox' name='file[category][]' value='$id' $checked /> $cat[title]</label>";
270
+ echo "<ul style='margin:0px;margin-left:20px;padding:0px;'>";
271
+ wpdm_cblist_categories($id,$level+1, $sel);
272
+ echo "</ul>";
273
+ echo "</li>\n";
274
+ }
275
+ }
276
+ //if($parent!='') echo "</ul>";
277
+ }
278
+ }
279
+
280
+ function wpdm_dropdown_categories($parent="", $level = 0, $sel='',$cid='',$class=array()){
281
+ $cats = maybe_unserialize(get_option('_fm_categories'));
282
+ if(!is_array($cats)) $cats = array();
283
+ foreach($cats as $id=>$cat){
284
+ $pres = str_repeat("&mdash;", $level);
285
+ array_push($class,$parent);
286
+ if($parent=='') $class = array();
287
+ $class = array_unique($class);
288
+ $cssclass = implode(" ",$class);
289
+ if($cat['parent']==$parent){
290
+ if($sel==$id)
291
+ echo "<option class='level_{$level} $id $cssclass' selected=selected value='$id'>{$pres} $cat[title]</option>\n";
292
+ else
293
+ echo "<option class='level_{$level} $id $cssclass' value='$id'>{$pres} $cat[title]</option>\n";
294
+ wpdm_dropdown_categories($id,$level+1, $sel, $cid, $class);}
295
+ }
296
+
297
+ }
298
+
299
+ function wpdm_tree(){
300
+ $treejs = plugins_url().'/download-manager/js/jqueryFileTree.js';
301
+ $treecss = plugins_url().'/download-manager/css/jqueryFileTree.css';
302
+ $siteurl = site_url();
303
+ $data = <<<TREE
304
+ <script language="JavaScript" src="{$treejs}"></script>
305
+ <link rel="stylesheet" href="{$treecss}" />
306
+ <div id="tree"></div>
307
+ <script language="JavaScript">
308
+ <!--
309
+ jQuery(document).ready( function() {
310
+ jQuery('#tree').fileTree({
311
+ script: '{$siteurl}/?task=wpdm_tree',
312
+ expandSpeed: 1000,
313
+ collapseSpeed: 1000,
314
+ multiFolder: false
315
+ }, function(file) {
316
+ //alert(file);
317
+ //var sfilename = file.split('/');
318
+ //var filename = sfilename[sfilename.length-1];
319
+ tb_show(jQuery(this).html(),'{$siteurl}/?download='+file+'&modal=1&width=600&height=400');
320
+
321
+ });
322
+
323
+
324
+ });
325
+ //-->
326
+ </script>
327
+ TREE;
328
+
329
+ return $data;
330
+ }
331
+
332
+ function wpdm_embed_tree(){
333
+ if(!isset($_GET['task'])||$_GET['task']!='wpdm_tree') return;
334
+ global $wpdb;
335
+ $cats = maybe_unserialize(get_option('_fm_categories'));
336
+ if(!is_array($cats)) $cats = array();
337
+
338
+
339
+
340
+
341
+ echo "<ul class=\"jqueryFileTree\" style=\"display: none;\">";
342
+ // All Cats
343
+ $_POST['dir'] = $_POST['dir']=='/'?'':$_POST['dir'];
344
+ foreach( $cats as $id=>$file ) {
345
+ if($file['parent']==$_POST['dir'])
346
+ echo "<li class=\"directory collapsed\"><a href=\"#\" rel=\"" . $id . "\">" . htmlentities(stripcslashes($file['title'])) . "</a></li>";
347
+ }
348
+
349
+ // All files
350
+
351
+
352
+ if($_POST['dir'])
353
+ $ndata = $wpdb->get_results("select * from ahm_files where category like '%\"{$_POST['dir']}\"%'",ARRAY_A);
354
+ else
355
+ $ndata = $wpdb->get_results("select * from ahm_files where category = 'N;'",ARRAY_A);
356
+
357
+ $sap = '?'; //count($_GET)>0?'&':'?';
358
+
359
+ foreach($ndata as $data){
360
+ $html = '';
361
+ $data['title'] = stripcslashes($data['title']);
362
+ $link_label = $data['title']?$data['title']:'Download';
363
+ $data['page_link'] = "<a class='wpdm-popup' href='' rel='{$data['id']}'>$link_label</a>";
364
+ if(isset($data['preview'])&&$data['preview']!='')
365
+ $data['thumb'] = "<img class='wpdm_icon' align='left' src='".plugins_url()."/{$data['preview']}' />";
366
+ else
367
+ $data['thumb'] = '';
368
+ if(isset($data['icon'])&&$data['icon']!='')
369
+ $data['icon'] = "<img class='wpdm_icon' align='left' src='".plugins_url()."/{$data['icon']}' />";
370
+ else
371
+ $data['icon'] = '';
372
+
373
+
374
+ if($data['show_counter']==1){
375
+ $counter = "{$data['download_count']} downloads<br/>";
376
+ $data['counter'] = $counter;
377
+ }
378
+ $ext = end(explode(".", $data['file']));
379
+ //foreach( $data as $ind=>$val ) $reps["[".$ind."]"] = $val;
380
+ //$repeater = stripslashes( strtr( $category['template_repeater'], $reps ));
381
+ $template = "<li class=\"wpdm_clink file ext_$ext\">$data[page_link]</li>";
382
+ if($data['access']=='member'&&!is_user_logged_in())
383
+ $template = "<li class=\"file ext_$ext\"><a href='".get_option('siteurl')."/wp-login.php?redirect_to=".$_SERVER['REQUEST_URI']."' >{$data['title']}<small> (login to download)</small></a></li>";
384
+ $html .= $template;
385
+
386
+
387
+
388
+ echo $html;
389
+
390
+
391
+
392
+
393
+
394
+
395
+
396
+ }
397
+ echo "</ul>";
398
+ die();
399
+
400
+
401
+ }
402
+
403
+ function wpdm_admin_options(){
404
+
405
+ if(!file_exists(UPLOAD_DIR)&&$_GET[task]!='wpdm_create_dir'){
406
+
407
+ echo "
408
+ <div id=\"warning\" class=\"error fade\"><p>
409
+ Automatic dir creation failed! [ <a href='admin.php?page=file-manager&task=CreateDir&re=1'>Try again to create dir automatically</a> ]<br><br>
410
+ Please create dir <strong>" . UPLOAD_DIR . "</strong> manualy and set permision to <strong>777</strong><br><br>
411
+ Otherwise you will not be able to upload files.</p></div>";
412
+ }
413
+
414
+ if(isset($_GET['success'])&&$_GET['success']==1){
415
+ echo "
416
+ <div id=\"message\" class=\"updated fade\"><p>
417
+ Congratulation! Plugin is ready to use now.
418
+ </div>
419
+ ";
420
+ }
421
+
422
+
423
+ if(!file_exists(UPLOAD_DIR.'.htaccess'))
424
+ wpdm_set_htaccess();
425
+
426
+ if(isset($_GET['task'])&&$_GET['task']!=''&&function_exists($_GET['task']))
427
+ return call_user_func($_GET['task']);
428
+ else
429
+ include('wpdm-list-files.php');
430
+ }
431
+
432
+ function wpdm_delete_file(){
433
+ global $wpdb;
434
+ if(isset($_GET['task']) && $_GET['task'] == 'DeleteFile' && is_admin()){
435
+ if(is_array($_GET['id'])){
436
+ foreach($_GET['id'] as $id){
437
+ $qry[] = "id='".(int)$id."'";
438
+ }
439
+ $cond = implode(" or ", $qry);
440
+ } else
441
+ $cond = "id='".(int)$_GET['id']."'";
442
+
443
+ $wpdb->query("delete from ahm_files where ". $cond);
444
+ wp_redirect('admin.php?page=file-manager');
445
+ die();
446
+ }
447
+ }
448
+
449
+ function wpdm_create_dir(){
450
+ if(!file_exists(UPLOAD_BASE)){
451
+ @mkdir(UPLOAD_BASE,0777);
452
+ }
453
+ @chmod(UPLOAD_BASE,0777);
454
+ @mkdir(UPLOAD_DIR,0777);
455
+ @chmod(UPLOAD_DIR,0777);
456
+ @chmod(dir(__FILE__).'/cache/',0777);
457
+ wpdm_set_htaccess();
458
+ if(isset($_GET['re'])&&$_GET['re']==1) {
459
+ if(file_exists(UPLOAD_DIR)) $s=1;
460
+ else $s = 0;
461
+ echo "<script>
462
+ location.href='{$_SERVER[HTTP_REFERER]}&success={$s}';
463
+ </script>";
464
+ die();
465
+ }
466
+ }
467
+
468
+ function wpdm_settings(){
469
+ if(isset($_POST['access'])){
470
+
471
+ update_option('wpdm_access_level',$_POST['access']);
472
+ update_option('wpdm_login_msg',$_POST['wpdm_login_msg']);
473
+ update_option('wpdm_show_cinfo',$_POST['wpdm_show_cinfo']);
474
+ update_option('_wpdm_file_browser_root',$_POST['_wpdm_file_browser_root']);
475
+
476
+ }
477
+ if(is_uploaded_file($_FILES['icon']['tmp_name'])){
478
+ ///print_r(dirname(__FILE__).'/icon/download.png');
479
+ move_uploaded_file($_FILES['icon']['tmp_name'],dirname(__FILE__).'/icon/download.png');
480
+ }
481
+ $access = get_option('wpdm_access_level');
482
+ $wpdm_show_cinfo = get_option('wpdm_show_cinfo');
483
+ include('wpdm-settings.php');
484
+ }
485
+
486
+ function wpdm_add_new_file(){
487
+ global $wpdb;
488
+
489
+ if(isset($_POST['file'])){
490
+ extract($_POST);
491
+
492
+ $file['show_counter'] = isset($file['show_counter'])?$file['show_counter']:0;
493
+ $file['quota'] = $file['quota']?$file['quota']:0;
494
+ $file['category'] = serialize($file['category']);
495
+ $wpdb->insert("ahm_files", $file);
496
+ if(!$wpdb->insert_id){
497
+ $wpdb->show_errors();
498
+ $wpdb->print_error();
499
+ die();
500
+ }
501
+ die('Created!');
502
+
503
+ }
504
+
505
+ if(!file_exists(UPLOAD_DIR)){
506
+
507
+ echo "
508
+ <div id=\"warning\" class=\"error fade\"><p>
509
+ Automatic dir creation failed! [ <a href='admin.php?page=file-manager&task=wpdm_create_dir&re=1'>Try again to create dir automatically</a> ]<br><br>
510
+ Please create dir <strong>" . UPLOAD_DIR . "</strong> manualy and set permision to <strong>777</strong><br><br>
511
+ Otherwise you will not be able to upload files.
512
+ </p></div>";
513
+ }
514
+
515
+ if($_GET['success']==1){
516
+ echo "
517
+ <div id=\"message\" class=\"updated fade\"><p>
518
+ Congratulation! Plugin is ready to use now.
519
+ </div>
520
+ ";
521
+ }
522
+
523
+
524
+ include('wpdm-add-new-file.php');
525
+ }
526
+
527
+ function wpdm_edit_file(){
528
+ global $wpdb;
529
+ if($_POST['file']&&$_POST['id']){
530
+ extract($_POST);
531
+
532
+
533
+ $file['category'] = serialize($file['category']);
534
+
535
+ $wpdb->update("ahm_files", $file, array("id"=>$_POST['id']));
536
+
537
+ die('Updated!');
538
+
539
+ }
540
+ $id = intval($_GET[id]);
541
+ $file = $wpdb->get_row("select * from ahm_files where id='$id'",ARRAY_A);
542
+
543
+ include('wpdm-add-new-file.php');
544
+ }
545
+
546
+ function wpdm_categories(){
547
+ $cid = addslashes($_GET['cid']);
548
+ if($_GET['task']=='DeleteCategory'){
549
+ $tpldata = maybe_unserialize(get_option('_fm_categories'));
550
+ unset($tpldata[$cid]);
551
+ update_option('_fm_categories',@serialize($tpldata));
552
+ echo "<script>
553
+ location.href='{$_SERVER[HTTP_REFERER]}';
554
+ </script>";
555
+ die();
556
+ }
557
+ if($_POST['cat']){
558
+ $tpldata = maybe_unserialize(get_option('_fm_categories'));
559
+ if(!is_array($tpldata)) $tpldata =array();
560
+ $_POST['cat']['title'] = esc_attr($_POST['cat']['title']);
561
+ $_POST['cat']['content'] = esc_attr($_POST['cat']['content']);
562
+ $tcid = $_POST['cid']?$_POST['cid']:trim(strtolower(preg_replace("/([^a-zA-Z0-9\-]+)/","-", $_POST['cat']['title'])),"-");
563
+ if($tcid=='') $tcid = uniqid();
564
+ $tcid = $tcid=='-'?uniqid():$tcid;
565
+ $cid = $tcid;
566
+ while(array_key_exists($cid, $tpldata)&&$_POST['cid']==''){
567
+ $cid = $tcid."-".(++$postfx);
568
+ }
569
+
570
+ if($_POST['cat']['title']!=''){
571
+ $tpldata[$cid] = $_POST['cat'];
572
+ update_option('_fm_categories',@serialize($tpldata)); }
573
+ echo "<script>
574
+ location.href='{$_SERVER[HTTP_REFERER]}';
575
+ </script>";
576
+ die();
577
+ }
578
+ include("wpdm-categories.php");
579
+ }
580
+
581
+ function wpdm_cat_dropdown_tree($parent="", $level = 0){
582
+ $cats = maybe_unserialize(get_option('_fm_categories'));
583
+ foreach($cats as $id=>$cat){
584
+ $pres = str_repeat("&mdash;", $level);
585
+ if($cat['parent']==$parent){
586
+ echo "<option value='$id'>{$pres} $cat[title]</option>\n";
587
+ wpdm_cat_dropdown_tree($id,$level+1);}
588
+ }
589
+ }
590
+
591
+ function wpdm_embed_category($id){
592
+ global $wpdb, $current_user, $post, $wp_query;
593
+ $postlink = get_permalink($post->ID);
594
+ get_currentuserinfo();
595
+
596
+ $user = new WP_User(null);
597
+ $categories = maybe_unserialize(get_option("_fm_categories",true));
598
+ $category = $categories[$id];
599
+ $total = $wpdb->get_var("select count(*) from ahm_files where category like '%\"$id\"%'");
600
+
601
+ $item_per_page = 10;
602
+ $pages = ceil($total/$item_per_page);
603
+ $page = $_GET['cp']?$_GET['cp']:1;
604
+ $start = ($page-1)*$item_per_page;
605
+ $pag = new wpdmpagination();
606
+ $pag->items($total);
607
+ $pag->limit($item_per_page);
608
+ $pag->currentPage($page);
609
+ $plink = $url = preg_replace("/[\?|\&]+cp=[0-9]+/","",$_SERVER['REQUEST_URI']);
610
+ $url = strpos($url,'?')?$url.'&':$url.'?';
611
+ $pag->urlTemplate($url."cp=[%PAGENO%]");
612
+
613
+ $ndata = $wpdb->get_results("select * from ahm_files where category like '%\"$id\"%' limit $start, $item_per_page",ARRAY_A);
614
+
615
+
616
+ $sap = strpos($plink,'?')>0?'&':'?';
617
+ $html = '';
618
+ foreach($ndata as $data){
619
+
620
+ $link_label = $data['title']?stripcslashes($data['title']):'Download';
621
+ $data['page_link'] = "<a class='wpdm-popup' href='{$postlink}{$sap}download={$data['id']}'>$link_label</a>";
622
+ //if($data['password']=='') { $data['page_link'] = "<a href='".home_url('/?wpdmact=process&did='.base64_encode($id.'.hotlink'))."'>{$link_label}</a>"; }
623
+ if($data['password']=='') {
624
+ $url = home_url('/?wpdmact=process&did='.base64_encode($data['id'].'.hotlink'));
625
+ $data['page_link'] = "<a href='{$url}'>$link_label</a>";
626
+ }
627
+ if($data['icon']!='') $bg = "background-image: url(\"".plugins_url()."/download-manager/icon/{$data[icon]}\");";
628
+
629
+ if($data['show_counter']==1){
630
+ $counter = "{$data[download_count]} downloads<br/>";
631
+ $data['counter'] = $counter;
632
+ }
633
+
634
+ //foreach( $data as $ind=>$val ) $reps["[".$ind."]"] = $val;
635
+ //$repeater = stripslashes( strtr( $category['template_repeater'], $reps ));
636
+ $template = "<li><div class='wpdm_clink' style='{$bg}'><b>$data[page_link]</b><br/><small>$data[counter]</small></div></li>";
637
+ if($data['access']=='member'&&!is_user_logged_in())
638
+ $template = "<li><div class='wpdm_clink' style='{$bg}'><a href='".get_option('siteurl')."/wp-login.php?redirect_to=".$_SERVER['REQUEST_URI']."' >$data[title]</a></b><br/><small>login to download</small></div></li>";
639
+ $html .= $template;
640
+
641
+
642
+ END;
643
+
644
+
645
+
646
+
647
+
648
+
649
+
650
+ }
651
+
652
+ if(get_option('wpdm_show_cinfo','no')=='yes') $html = "<h3>{$category['title']}</h3>".wpautop($category['content']).$html;
653
+
654
+ return "<ul class='wpdm-category $id'>".$html."</ul><div style='clear:both'></div>".$pag->show()."<div style='clear:both'></div>";
655
+ }
656
+
657
+ function wpdm_embed_category_sc($params){
658
+ global $wpdb, $current_user, $post, $wp_query;
659
+ extract($params);
660
+ $postlink = get_permalink($post->ID);
661
+ get_currentuserinfo();
662
+
663
+ $user = new WP_User(null);
664
+ $categories = maybe_unserialize(get_option("_fm_categories",true));
665
+ $category = $categories[$id];
666
+ $order = isset($order) && $order!="" ? $order: "desc";
667
+
668
+ $order_query = isset($order_field) && $order_field != '' ? "order by $order_field $order" : "order by id DESC";
669
+ $total = $wpdb->get_var("select count(*) from ahm_files where category like '%\"$id\"%'");
670
+
671
+ $items_per_page = isset($items_per_page)?$items_per_page:10;
672
+ $pages = ceil($total/$items_per_page);
673
+ $page = $_GET['cp']?$_GET['cp']:1;
674
+ $start = ($page-1)*$items_per_page;
675
+ $pag = new wpdmpagination();
676
+ $pag->items($total);
677
+ $pag->limit($items_per_page);
678
+ $pag->currentPage($page);
679
+ $plink = $url = preg_replace("/[\?|\&]+cp=[0-9]+/","",$_SERVER['REQUEST_URI']);
680
+ $url = strpos($url,'?')?$url.'&':$url.'?';
681
+ $pag->urlTemplate($url."cp=[%PAGENO%]");
682
+
683
+ $ndata = $wpdb->get_results("select * from ahm_files where category like '%\"$id\"%' $order_query limit $start, $items_per_page",ARRAY_A);
684
+
685
+
686
+
687
+ $sap = strpos($plink,'?')>0?'&':'?';
688
+ $html = '';
689
+ foreach($ndata as $data){
690
+
691
+ $link_label = $data['title']?stripcslashes($data['title']):'Download';
692
+ $data['page_link'] = "<a class='wpdm-popup' href='{$postlink}{$sap}download={$data['id']}'>$link_label</a>";
693
+ //if($data['password']=='') { $data['page_link'] = "<a href='".home_url('/?wpdmact=process&did='.base64_encode($id.'.hotlink'))."'>{$link_label}</a>"; }
694
+ if($data['password']=='') {
695
+ $url = home_url('/?wpdmact=process&did='.base64_encode($data['id'].'.hotlink'));
696
+ $data['page_link'] = "<a href='{$url}'>$link_label</a>";
697
+ }
698
+ if($data['icon']!='') $bg = "background-image: url(\"".plugins_url()."/download-manager/icon/{$data[icon]}\");";
699
+
700
+ if($data['show_counter']==1){
701
+ $counter = "{$data[download_count]} downloads<br/>";
702
+ $data['counter'] = $counter;
703
+ }
704
+
705
+ //foreach( $data as $ind=>$val ) $reps["[".$ind."]"] = $val;
706
+ //$repeater = stripslashes( strtr( $category['template_repeater'], $reps ));
707
+ $template = "<li><div class='wpdm_clink' style='{$bg}'><b>$data[page_link]</b><br/><small>$data[counter]</small></div></li>";
708
+ if($data['access']=='member'&&!is_user_logged_in())
709
+ $template = "<li><div class='wpdm_clink' style='{$bg}'><a href='".get_option('siteurl')."/wp-login.php?redirect_to=".$_SERVER['REQUEST_URI']."' >$data[title]</a></b><br/><small>login to download</small></div></li>";
710
+ $html .= $template;
711
+
712
+
713
+ END;
714
+
715
+
716
+
717
+
718
+
719
+
720
+
721
+ }
722
+
723
+ if(get_option('wpdm_show_cinfo','no')=='yes') $html = "<h3>{$category['title']}</h3>".wpautop($category['content']).$html;
724
+
725
+ return "<ul class='wpdm-category $id'>".$html."</ul><div style='clear:both'></div>".$pag->show()."<div style='clear:both'></div>";
726
+ }
727
+
728
+
729
+ function wpdm_tinymce()
730
+ {
731
+ wp_enqueue_script('common');
732
+ wp_enqueue_script('jquery-color');
733
+ wp_admin_css('thickbox');
734
+ wp_print_scripts('post');
735
+ wp_print_scripts('media-upload');
736
+ wp_print_scripts('jquery');
737
+ wp_print_scripts('jquery-ui-core');
738
+ wp_print_scripts('jquery-ui-tabs');
739
+ wp_print_scripts('tiny_mce');
740
+ wp_print_scripts('editor');
741
+ wp_print_scripts('editor-functions');
742
+ add_thickbox();
743
+ //wp_tiny_mce();
744
+ //wp_admin_css();
745
+ wp_enqueue_script('utils');
746
+ do_action("admin_print_styles-post-php");
747
+ do_action('admin_print_styles');
748
+ remove_all_filters('mce_external_plugins');
749
+ }
750
+
751
+ function wpdm_set_htaccess(){
752
+ $cont = 'RewriteEngine On
753
+ <Files *>
754
+ Deny from all
755
+ </Files>
756
+ ';
757
+ @file_put_contents(UPLOAD_DIR.'.htaccess',$cont);
758
+ }
759
+
760
+
761
+ function wpdm_front_js(){
762
+ ?>
763
+ <script language="JavaScript">
764
+ <!--
765
+ jQuery(function(){
766
+
767
+ jQuery('.wpdm-popup').click(function(){
768
+ tb_show(jQuery(this).html(),this.href+'&modal=1&width=600&height=400');
769
+ return false;
770
+ });
771
+
772
+ jQuery('.haspass').click(function(){
773
+ var url = jQuery(this).attr('href');
774
+ var id = jQuery(this).attr('rel');
775
+ var password = jQuery('#pass_'+id).val();
776
+ jQuery.post('<?php echo home_url('/'); ?>',{download:id,password:password},function(res){
777
+
778
+ if(res=='error') {
779
+
780
+ jQuery('#wpdm_file_'+id+' .perror').html('Wrong Password');
781
+ setTimeout("jQuery('#wpdm_file_"+id+" .perror').html('');",3000);
782
+ return false;
783
+ } else {
784
+ location.href = '<?php echo home_url('/?wpdmact=process&did='); ?>'+res;
785
+ }
786
+ //if(res.url!='undefined') location.href=res.url;
787
+
788
+ });
789
+
790
+ return false;
791
+ });
792
+ })
793
+ //-->
794
+ </script>
795
+ <?php
796
+ }
797
+
798
+ function wpdm_copyold(){
799
+ global $wpdb;
800
+ $ids = get_option('wpdmc2p_ids',true);
801
+ if($_POST['task']=='wpdm_copy_files'){
802
+ if(!is_array($ids)) $ids = array();
803
+ if(!is_array($_POST[id])) $_POST[id] = array();
804
+ foreach($_POST[id] as $fid){
805
+ //if(!in_array($fid, $ids)){
806
+ $file = $wpdb->get_row("select * from ahm_files where id='$fid'", ARRAY_A);
807
+ unset($file[id]);
808
+ //print_r($file);
809
+ //$wpdb->show_errors();
810
+ $wpdb->insert("ahm_files",$file);
811
+ //$wpdb->print_error();die() ;
812
+ //}
813
+ }
814
+ if(is_array($ids))
815
+ $ids = array_unique(array_merge($ids, $_POST['id']));
816
+ else
817
+ $ids = $_POST['id'];
818
+ /*foreach($_POST as $optn=>$optv){
819
+ update_option($optn, $optv);
820
+ } */
821
+
822
+ update_option('wpdmc2p_ids',$ids);
823
+ die('Copied successfully');
824
+ }
825
+
826
+ $res = mysql_query("select * from ahm_files");
827
+
828
+ ?>
829
+
830
+
831
+ <div class="wrap">
832
+ <div class="icon32" id="icon-upload"><br></div>
833
+
834
+ <h2>Copy from Download Manager</h2> <br>
835
+
836
+ <div class="clear"></div>
837
+ <form action="" method="post">
838
+ <input type="hidden" name="task" value="wpdm_copy_files" />
839
+
840
+ <table cellspacing="0" class="widefat fixed">
841
+ <thead>
842
+ <tr>
843
+ <th style="" class="manage-column column-cb check-column" id="cb" scope="col"><input class="call m" type="checkbox"></th>
844
+ <th style="" class="manage-column column-media" id="media" scope="col">File</th>
845
+ <th style="" class="manage-column column-parent" id="parent" scope="col">Copied</th>
846
+ </tr>
847
+ </thead>
848
+
849
+ <tfoot>
850
+ <tr>
851
+ <th style="" class="manage-column column-cb check-column" id="cb" scope="col"><input class="call m" type="checkbox"></th>
852
+ <th style="" class="manage-column column-media" id="media" scope="col">File</th>
853
+ <th style="" class="manage-column column-parent" id="parent" scope="col">Copied</th>
854
+ </tr>
855
+ </tfoot>
856
+
857
+ <tbody class="list:post" id="the-list">
858
+ <?php while($media = mysql_fetch_assoc($res)) { $media['copied'] = @in_array($media[id],$ids)?'Yes':'No'; ?>
859
+ <tr valign="top" class="alternate author-self status-inherit" id="post-8">
860
+
861
+ <th class="check-column" scope="row"><input type="checkbox" value="<?php echo $media[id];?>" class="m" name="id[]"></th>
862
+
863
+ <td class="media column-media">
864
+ <strong><a title="Edit" href="admin.php?page=file-manager&task=EditFile&id=<?php echo $media['id']?>"><?php echo $media['title']?></a></strong>
865
+ </td>
866
+ <td class="parent column-parent"><b><?php echo $media['copied']; ?></b></td>
867
+
868
+ </tr>
869
+ <?php } ?>
870
+ </tbody>
871
+ </table>
872
+ <br>
873
+
874
+ <input type="submit" value="Copy Selected Files" class="button-primary">
875
+ </form>
876
+ <script language="JavaScript">
877
+ <!--
878
+ jQuery('.call').click(function(){
879
+ if(this.checked)
880
+ jQuery('.m').attr('checked','checked');
881
+ else
882
+ jQuery('.m').removeAttr('checked');
883
+ });
884
+ //-->
885
+ </script>
886
+ </div>
887
+ <?php
888
+ }
889
+
890
+ function wpdm_hotlink($params){
891
+ global $wpdb;
892
+ extract($params);
893
+ if($id=='') return;
894
+ $data = $wpdb->get_row("select * from ahm_files where id='$id'",ARRAY_A);
895
+ if($data['id']=='') return;
896
+ $data['link_label'] = stripcslashes($data['link_label']);
897
+ $link_label = $link_label?$link_label:$data['link_label'];
898
+ $url = home_url('/?wpdmact=process&did='.base64_encode($id.'.hotlink'));
899
+ return "<a href='$url'>$link_label</a>";
900
+
901
+ }
902
+
903
+ function delete_all_cats(){
904
+ if(!isset($_GET['page'])) return;
905
+ if($_GET['page']=='file-manager/categories'&&$_GET['task']=='delete-all'){
906
+ delete_option('_fm_categories');
907
+ header('location: '.$_SERVER['HTTP_REFERER']);
908
+ die();
909
+ }
910
+ }
911
+
912
+ function wpdm_save_file(){
913
+ global $wpdb;
914
+ if(isset($_POST['id'])&&isset($_POST['wpdmtask'])&&$_POST['wpdmtask']=='update'){
915
+ extract($_POST);
916
+
917
+
918
+ $file['category'] = serialize($file['category']);
919
+
920
+ $wpdb->update("ahm_files", $file, array("id"=>$_POST['id']));
921
+
922
+ die('updated');
923
+
924
+ }
925
+
926
+ if($_POST['wpdmtask']=='create'){
927
+ extract($_POST);
928
+
929
+ $file['show_counter'] = isset($file['show_counter'])?$file['show_counter']:0;
930
+ $file['quota'] = $file['quota']?$file['quota']:0;
931
+ $file['category'] = serialize($file['category']);
932
+ $file['title'] = esc_attr($file['title']);
933
+ $id = $wpdb->insert("ahm_files", $file);
934
+ if(!$wpdb->insert_id){
935
+ $wpdb->show_errors();
936
+ $wpdb->print_error();
937
+ die();
938
+ }
939
+ echo $wpdb->insert_id;
940
+ die();
941
+ }
942
+ }
943
+
944
+
945
+ // handle uploaded file here
946
+ function wpdm_check_upload(){
947
+ check_ajax_referer('photo-upload');
948
+ if(file_exists(UPLOAD_DIR.$_FILES['async-upload']['name']))
949
+ $filename = time().'wpdm_'.$_FILES['async-upload']['name'];
950
+ else
951
+ $filename = $_FILES['async-upload']['name'];
952
+ move_uploaded_file($_FILES['async-upload']['tmp_name'],UPLOAD_DIR.$filename);
953
+ $filesize = number_format(filesize(UPLOAD_DIR.'/'.$filename)/1025,2);
954
+ echo $filename."|||".$filesize;
955
+ exit;
956
+ }
957
+
958
+ function wpdm_delete__file(){
959
+ global $wpdb;
960
+ $id = intval($_REQUEST['file']);
961
+ $data = $wpdb->get_row("select * from ahm_files where id='$id'",ARRAY_A);
962
+ if(file_exists(UPLOAD_DIR.'/'.$data['file']))
963
+ @unlink(UPLOAD_DIR.'/'.$data['file']);
964
+ else if(file_exists($data['file']))
965
+ @unlink($data['file']);
966
+ unset($data['file']);
967
+ $wpdb->query("update ahm_files set `file`='' where id='$id'");
968
+ die('ok');
969
+ }
970
+
971
+
972
+
973
+ function wpdm_help(){
974
+ ?>
975
+ <div class="wrap">
976
+ <div class="icon32" id="icon-index"><br></div>
977
+ <h2>Help</h2> <br>
978
+
979
+ If you have anything to ask or if anything not clear please search or ask here:
980
+ <br/>
981
+ <strong><a href="http://www.wpdownloadmanager.com/support/forum/download-manager-free/" target="_blank">http://www.wpdownloadmanager.com/support/forum/download-manager-free/</a></strong>
982
+
983
+
984
+
985
+ <?php
986
+ }
987
+
988
+
989
+
990
+ function wpdm_menu(){
991
+ //echo get_option('wpdm_access_level','manage_options');die();
992
+ add_menu_page("File Manager","File Manager",get_option('wpdm_access_level','manage_options'),'file-manager','wpdm_admin_options',plugins_url('download-manager/img/donwloadmanager-16.png'));
993
+ add_submenu_page( 'file-manager', 'File Manager', 'Manage', get_option('wpdm_access_level','manage_options'), 'file-manager', 'wpdm_admin_options');
994
+ add_submenu_page( 'file-manager', 'Add New File &lsaquo; File Manager', 'Add New File', get_option('wpdm_access_level','manage_options'), 'file-manager/add-new-file', 'wpdm_add_new_file');
995
+ add_submenu_page( 'file-manager', 'Categories &lsaquo; File Manager', 'Categories', get_option('wpdm_access_level','manage_options'), 'file-manager/categories', 'wpdm_categories');
996
+ add_submenu_page( 'file-manager', 'Settings &lsaquo; File Manager', 'Settings', get_option('wpdm_access_level','manage_options'), 'file-manager/settings', 'wpdm_settings');
997
+ add_submenu_page( 'file-manager', 'Help &lsaquo; File Manager', 'Help', get_option('wpdm_access_level','manage_options'), 'file-manager/help', 'wpdm_help');
998
+
999
+ }
1000
+
1001
+
1002
+ function wpdm_admin_enque_scripts(){
1003
+ wp_enqueue_style('icons',plugins_url().'/download-manager/css/icons.css');
1004
+ wp_enqueue_script('jquery');
1005
+ wp_enqueue_script('jquery-form');
1006
+ wp_enqueue_script('plupload-all');
1007
+ wp_enqueue_script('file-tree-js',plugins_url().'/download-manager/js/jqueryFileTree.js',array('jquery'));
1008
+ wp_enqueue_script('chosen-jquery',plugins_url().'/download-manager/js/chosen.jquery.min.js',array('jquery'));
1009
+ wp_enqueue_style('chosen-css',plugins_url().'/download-manager/css/chosen.css');
1010
+
1011
+ }
1012
+
1013
+ function wpdm_enque_scripts(){
1014
+ wp_enqueue_script('jquery');
1015
+ wp_enqueue_script('thickbox');
1016
+ wp_enqueue_style('thickbox');
1017
+ wp_enqueue_style('wpdm-front',plugins_url().'/download-manager/css/front.css');
1018
+ }
1019
+
1020
+
1021
+ add_action("admin_menu","wpdm_menu");
1022
+ add_action("init","delete_all_cats");
1023
+ add_action("init","wpdm_delete_file");
1024
+
1025
+ add_action('admin_enqueue_scripts','wpdm_admin_enque_scripts');
1026
+ add_action('wp_enqueue_scripts','wpdm_enque_scripts');
1027
+ add_action('wp_head','wpdm_front_js');
1028
+
1029
+ if(isset($_GET['page'])&&$_GET['page']=='file-manager/add-new-file')
1030
+ add_filter('admin_head','wpdm_tinymce');
1031
+
1032
+ add_action("wp","wpdm_download_info");
1033
+
1034
+ add_filter( 'the_content', 'wpdm_downloadable');
1035
+
1036
+ add_shortcode('wpdm_all_packages','wpdm_all_packages');
1037
+ add_shortcode('wpdm_hotlink','wpdm_hotlink');
1038
+ add_shortcode('wpdm_file','wpdm_downloadable_nsc');
1039
+ add_shortcode('wpdm_tree','wpdm_tree');
1040
+ add_shortcode('wpdm_category','wpdm_embed_category_sc');
1041
+
1042
+ add_action('init','wpdm_embed_tree');
1043
+ add_action('init','wpdm_process');
1044
+ add_action('wp_ajax_file_upload','wpdm_check_upload');
1045
+ add_action('wp_ajax_delete_file','wpdm_delete__file');
1046
+ add_action('wp_ajax_save_wpdm_file','wpdm_save_file');
1047
+
1048
+
1049
+ add_action("init","wpdm_file_browser");
1050
+ add_action("init","wpdm_dir_tree");
1051
+
1052
+ include("wpdm-widgets.php");
1053
+
1054
+ register_activation_hook(__FILE__,'wpdm_free_install');
fm-settings.php CHANGED
@@ -38,7 +38,14 @@ input{
38
  <input type="text" name="wpdm_login_msg" value="<?php echo get_option('wpdm_login_msg',true); ?>" size="40">
39
  </td>
40
  </tr>
41
-
 
 
 
 
 
 
 
42
 
43
  <tr>
44
  <td>Download Link Icon:</td>
38
  <input type="text" name="wpdm_login_msg" value="<?php echo get_option('wpdm_login_msg',true); ?>" size="40">
39
  </td>
40
  </tr>
41
+ <?php if(current_user_can("manage_options")){ ?>
42
+ <tr>
43
+ <td>Server File Borwser Rooe:</td>
44
+ <td>
45
+ <input type="text" name="_wpdm_file_browser_root" value="<?php echo get_option('_wpdm_file_browser_root',$_SERVER['DOCUMENT_ROOT']); ?>" size="90">
46
+ </td>
47
+ </tr>
48
+ <?php } ?>
49
 
50
  <tr>
51
  <td>Download Link Icon:</td>
functions.php CHANGED
@@ -84,6 +84,8 @@
84
  if(function_exists('curl_init')){
85
  $ch=curl_init();
86
  curl_setopt($ch,CURLOPT_URL,'http://wpdownloadmanager.com/notice.php');
 
 
87
  curl_exec($ch);
88
  curl_close($ch);
89
  } else
@@ -144,6 +146,30 @@
144
  include("messages.php");
145
  return $msgs[$key]?$msgs[$key]:$key;
146
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
 
148
  function wpdm_skip_ngg_resource_manager($r){
149
  return false;
84
  if(function_exists('curl_init')){
85
  $ch=curl_init();
86
  curl_setopt($ch,CURLOPT_URL,'http://wpdownloadmanager.com/notice.php');
87
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,2);
88
+ curl_setopt($ch,CURLOPT_TIMEOUT,3);
89
  curl_exec($ch);
90
  curl_close($ch);
91
  } else
146
  include("messages.php");
147
  return $msgs[$key]?$msgs[$key]:$key;
148
  }
149
+
150
+ global $pagenow;
151
+
152
+ function wpdm_update_notice($plugin_data, $r){
153
+ if(function_exists('curl_init')){
154
+ $ch=curl_init();
155
+ curl_setopt($ch,CURLOPT_URL,"http://www.wpdownloadmanager.com/wp-content/update-notice.txt");
156
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,2);
157
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
158
+ curl_setopt($ch,CURLOPT_TIMEOUT,3);
159
+ $data = curl_exec($ch);
160
+ curl_close($ch);
161
+ }
162
+ echo "<hr/><a href='http://www.wpdownloadmanager.com/wp-content/update-notice.txt' target='_blank'><strong style='color: #b92b35;'>Must Read Before Update</strong></a><hr/>";
163
+ echo "<div style='color: #D86038'>".$data."</div>";
164
+ }
165
+
166
+ if ( 'plugins.php' === $pagenow )
167
+ {
168
+
169
+ $hook = "in_plugin_update_message-download-manager/download-manager.php";
170
+
171
+ add_action( $hook, 'wpdm_update_notice', 20, 2 );
172
+ }
173
 
174
  function wpdm_skip_ngg_resource_manager($r){
175
  return false;
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: codename065, shahriar0822
3
  Donate link:
4
  Tags: file management plugin, downloads, document management plugin, download manager, file manager, download monitor, download counter, password protection, download tracker, download protection
5
  Requires at least: 3.4
6
- Tested up to: 3.8
7
  License: GPLv2 or later
8
 
9
 
@@ -15,8 +15,6 @@ This is a Files and Document Management plugin which will help you to manage, tr
15
  WordPress Download Manager is a Files and Document Management plugin for your WordPress Site. WordPress Download Manager plugin will help you to manage, track and control file downloads from your WordPress site. You can set password and set access level any of your downloadable files from your WordPress site.
16
  You can add/embed downloadable files anywhere in the post just pasting the embed code inside your post content using WordPress Download Manager.
17
 
18
- `"Download Monitor" to "Download Manager" Files Importer Integrated. Import all download monitor files in a single click`
19
-
20
  = Features =
21
  * Drag and Drop File Upload
22
  * Control who can access to download
@@ -63,6 +61,22 @@ You can add/embed downloadable files anywhere in the post just pasting the embed
63
 
64
  == Changelog ==
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  = 2.5.97 =
67
  * Updates file missing code
68
  * Fixed redirection issue after creating new package
3
  Donate link:
4
  Tags: file management plugin, downloads, document management plugin, download manager, file manager, download monitor, download counter, password protection, download tracker, download protection
5
  Requires at least: 3.4
6
+ Tested up to: 3.9
7
  License: GPLv2 or later
8
 
9
 
15
  WordPress Download Manager is a Files and Document Management plugin for your WordPress Site. WordPress Download Manager plugin will help you to manage, track and control file downloads from your WordPress site. You can set password and set access level any of your downloadable files from your WordPress site.
16
  You can add/embed downloadable files anywhere in the post just pasting the embed code inside your post content using WordPress Download Manager.
17
 
 
 
18
  = Features =
19
  * Drag and Drop File Upload
20
  * Control who can access to download
61
 
62
  == Changelog ==
63
 
64
+ = 2.6.2 =
65
+ * Fixed an issue with categroy short-code pagination
66
+
67
+ = 2.6.1 =
68
+ * Compatibility release for WordPress 3.9
69
+
70
+ = 2.6.0 =
71
+ * Added new option for setting up server file browser base dir.
72
+
73
+ = 2.5.99 =
74
+ * Fixed issue with multiple package delete
75
+ * Fixed issue with show/hide counter
76
+
77
+ = 2.5.98 =
78
+ * added "items_per_page" parameter with category short-code
79
+
80
  = 2.5.97 =
81
  * Updates file missing code
82
  * Fixed redirection issue after creating new package
wpdm-add-new-file.php CHANGED
@@ -393,10 +393,10 @@ jQuery('#dcf').click(function(){
393
  <div class="postbox " id="action">
394
  <h3><span>My Other Items</span></h3>
395
  <div class="inside">
396
- <a href="http://wpeden.com/wordpress/themes/" style="width:97%;overflow:hidden;margin:5px;background: #fafafa;border: 1px solid #ccc;display: block;float: left;text-align: center;-webkit-border-radius: 6px;-moz-border-radius: 6px;border-radius: 6px;" ><h3 style="margin: 0px;background: #ccc;-webkit-border-top-left-radius: 5px;-webkit-border-top-right-radius: 5px;-moz-border-radius-topleft: 5px;-moz-border-radius-topright: 5px;border-top-left-radius: 5px;border-top-right-radius: 5px;padding:5px;text-decoration: none;color:#333">Pro Level Themes for Free</h3><span style="display: block;padding: 10px;font-size:14pt;font-family:'Segoe UI Light';line-height: 1.5;color:#008000"><img style="max-width: 100%;height:auto;" src="<?php echo plugins_url('download-manager/images/theme.png'); ?>" /></span></a>
397
- <a href="http://www.wpdownloadmanager.com/" style="width:97%;overflow:hidden;margin:5px;background: #fafafa;border: 1px solid #ccc;display: block;float: left;text-align: center;-webkit-border-radius: 6px;-moz-border-radius: 6px;border-radius: 6px;" ><h3 style="margin: 0px;background: #ccc;-webkit-border-top-left-radius: 5px;-webkit-border-top-right-radius: 5px;-moz-border-radius-topleft: 5px;-moz-border-radius-topright: 5px;border-top-left-radius: 5px;border-top-right-radius: 5px;padding:5px;text-decoration: none;color:#333">WordPress Download Manager Pro</h3><img style="max-width: 100%;height:auto;" src="<?php echo plugins_url('download-manager/images/wpdm.png'); ?>" /></a>
398
- <a href="http://www.wpmarketplaceplugin.com/" style="width:97%;overflow:hidden;margin:5px;background: #fafafa;border: 1px solid #ccc;display: block;float: left;text-align: center;-webkit-border-radius: 6px;-moz-border-radius: 6px;border-radius: 6px;" ><h3 style="margin: 0px;background: #ccc;-webkit-border-top-left-radius: 5px;-webkit-border-top-right-radius: 5px;-moz-border-radius-topleft: 5px;-moz-border-radius-topright: 5px;border-top-left-radius: 5px;border-top-right-radius: 5px;padding:5px;text-decoration: none;color:#333">WordPress Marketplace Plugin</h3><img style="max-width: 100%;height:auto;" vspace="12" src="<?php echo plugins_url('download-manager/images/wpmp.png'); ?>" /></a>
399
- <a href="http://wpeden.com/" style="width:97%;overflow:hidden;margin:5px;background: #fafafa;border: 1px solid #ccc;display: block;float: left;text-align: center;-webkit-border-radius: 6px;-moz-border-radius: 6px;border-radius: 6px;" ><h3 style="margin: 0px;background: #ccc;-webkit-border-top-left-radius: 5px;-webkit-border-top-right-radius: 5px;-moz-border-radius-topleft: 5px;-moz-border-radius-topright: 5px;border-top-left-radius: 5px;border-top-right-radius: 5px;padding:5px;text-decoration: none;color:#333">WordPress Themes & Plugins Collection</h3><img style="max-width: 100%;height:auto;" src="<?php echo plugins_url('download-manager/images/wpeden.png'); ?>" /></a>
400
 
401
  <div style="clear: both;"></div>
402
  </div>
393
  <div class="postbox " id="action">
394
  <h3><span>My Other Items</span></h3>
395
  <div class="inside">
396
+ <a href="http://wpeden.com/wpeden-club/" style="text-decoration:none !important;width:97%;overflow:hidden;margin:5px;background: #fafafa;border: 1px solid #ccc;display: block;float: left;text-align: center;-webkit-border-radius: 6px;-moz-border-radius: 6px;border-radius: 6px;" ><h3 style="margin: 0px;background: #ccc;-webkit-border-top-left-radius: 5px;-webkit-border-top-right-radius: 5px;-moz-border-radius-topleft: 5px;-moz-border-radius-topright: 5px;border-top-left-radius: 5px;border-top-right-radius: 5px;padding:5px;text-decoration: none;color:#333">WP Eden Club</h3><span style="display: block;padding: 10px;font-size:14pt;;line-height: 1.5;color:#008000;font-weight: 900">60+ themes and plugins only for $55. Just Check The List. You will be impressed, 100% guarenteed!</span></a>
397
+ <a href="http://www.wpdownloadmanager.com/" style="text-decoration:none !important;width:97%;overflow:hidden;margin:5px;background: #fafafa;border: 1px solid #ccc;display: block;float: left;text-align: center;-webkit-border-radius: 6px;-moz-border-radius: 6px;border-radius: 6px;" ><h3 style="margin: 0px;background: #ccc;-webkit-border-top-left-radius: 5px;-webkit-border-top-right-radius: 5px;-moz-border-radius-topleft: 5px;-moz-border-radius-topright: 5px;border-top-left-radius: 5px;border-top-right-radius: 5px;padding:5px;text-decoration: none;color:#333">WordPress Download Manager Pro</h3><img style="max-width: 100%;height:auto;" src="<?php echo plugins_url('download-manager/images/wpdm.png'); ?>" /></a>
398
+ <a href="http://www.wpmarketplaceplugin.com/" style="text-decoration:none !important;width:97%;overflow:hidden;margin:5px;background: #fafafa;border: 1px solid #ccc;display: block;float: left;text-align: center;-webkit-border-radius: 6px;-moz-border-radius: 6px;border-radius: 6px;" ><h3 style="margin: 0px;background: #ccc;-webkit-border-top-left-radius: 5px;-webkit-border-top-right-radius: 5px;-moz-border-radius-topleft: 5px;-moz-border-radius-topright: 5px;border-top-left-radius: 5px;border-top-right-radius: 5px;padding:5px;text-decoration: none;color:#333">WordPress Marketplace Plugin</h3><img style="max-width: 100%;height:auto;" vspace="12" src="<?php echo plugins_url('download-manager/images/wpmp.png'); ?>" /></a>
399
+ <a href="http://wpeden.com/" style="text-decoration:none !important;width:97%;overflow:hidden;margin:5px;background: #fafafa;border: 1px solid #ccc;display: block;float: left;text-align: center;-webkit-border-radius: 6px;-moz-border-radius: 6px;border-radius: 6px;" ><h3 style="margin: 0px;background: #ccc;-webkit-border-top-left-radius: 5px;-webkit-border-top-right-radius: 5px;-moz-border-radius-topleft: 5px;-moz-border-radius-topright: 5px;border-top-left-radius: 5px;border-top-right-radius: 5px;padding:5px;text-decoration: none;color:#333">WordPress Themes & Plugins Collection</h3><img style="max-width: 100%;height:auto;" src="<?php echo plugins_url('download-manager/images/wpeden.png'); ?>" /></a>
400
 
401
  <div style="clear: both;"></div>
402
  </div>
wpdm-list-files.php CHANGED
@@ -111,7 +111,7 @@ $row = $wpdb->get_row("select count(*) as total from ahm_files $cond",ARRAY_A);
111
  ?>
112
  <tr valign="top" class="alternate author-self status-inherit" id="post-8">
113
 
114
- <th class="check-column" scope="row"><input type="checkbox" value="8" name="id[]"></th>
115
  <td class="column-icon media-icon">
116
  <a title="Edit" href="admin.php?page=file-manager&task=EditFile&id=<?php echo $media['id']?>">
117
  <img title="<?php echo end(explode(".",$media['file']))?> file" alt="<?php echo end(explode(".",$media['file']))?> file" class="attachment-80x60" src="../wp-content/plugins/download-manager/file-type-icons/<?php echo $icon; ?>">
111
  ?>
112
  <tr valign="top" class="alternate author-self status-inherit" id="post-8">
113
 
114
+ <th class="check-column" scope="row"><input type="checkbox" value="<?php echo $media['id']?>" name="id[]"></th>
115
  <td class="column-icon media-icon">
116
  <a title="Edit" href="admin.php?page=file-manager&task=EditFile&id=<?php echo $media['id']?>">
117
  <img title="<?php echo end(explode(".",$media['file']))?> file" alt="<?php echo end(explode(".",$media['file']))?> file" class="attachment-80x60" src="../wp-content/plugins/download-manager/file-type-icons/<?php echo $icon; ?>">
wpdm-settings.php CHANGED
@@ -44,6 +44,15 @@ input{
44
  </td>
45
  </tr>
46
 
 
 
 
 
 
 
 
 
 
47
 
48
  <tr>
49
  <td>Download Link Icon:</td>
44
  </td>
45
  </tr>
46
 
47
+ <?php if(current_user_can("manage_options")){ ?>
48
+ <tr>
49
+ <td>Server File Borwser Rooe:</td>
50
+ <td>
51
+ <input type="text" name="_wpdm_file_browser_root" value="<?php echo get_option('_wpdm_file_browser_root',$_SERVER['DOCUMENT_ROOT']); ?>" size="90">
52
+ </td>
53
+ </tr>
54
+ <?php } ?>
55
+
56
 
57
  <tr>
58
  <td>Download Link Icon:</td>