1
+ <?php require_once ("../../../../../wp-load.php " );
2
+ include_once ('../../url_path_config.php ' );
3
+ $ hostPath = rtrim (ABSPATH ,'/ ' );
4
+ $ current_user = wp_get_current_user ();
5
+ $ user = $ current_user ->user_login ;
6
+ if (!empty ($ _FILES ) and $ _REQUEST ['upload ' ]=='ok ' )
7
+ {
8
+ $ valnum = str_split ('ABCDEFGHIJKLMNOPQRSTUVWXYZ '
9
+ .'abcdefghijklmnopqrstuvwxyz '
10
+ .'0123456789 ' ); // and any other characters
11
+ //shuffle($seed);
12
+ $ rand = '' ;
13
+ foreach (array_rand ($ valnum , 10 ) as $ k ) $ rand .= $ valnum [$ k ];
14
+ $ n = 0 ;
15
+ $ s = 0 ;
16
+ foreach ($ _FILES ['files ' ]['name ' ] as $ val )
17
+ {
18
+ $ s ++;
19
+ $ filesName = str_replace (" " ,"- " ,$ _FILES ['files ' ]['name ' ][$ n ]);
20
+ $ files = explode (". " ,$ filesName );
21
+ $ File_Ext = substr ($ _FILES ['files ' ]['name ' ][$ n ], strrpos ($ _FILES ['files ' ]['name ' ][$ n ],'. ' ));
22
+ if ($ File_Ext ==".pdf " )
23
+ {
24
+ $ fileName = $ files [0 ].'- ' .$ s .time ().$ File_Ext ;
25
+ $ path = trim (zPDFpopupViewer_UPLOADS_PATH.$ fileName );
26
+ move_uploaded_file ($ _FILES ['files ' ]['tmp_name ' ][$ n ],$ path );
27
+
28
+ global $ wpdb ;
29
+ $ table = $ wpdb ->prefix . "pdffiles " ;
30
+ $ data = array (
31
+ 'filename ' =>trim ($ fileName ),
32
+ 'file_token ' =>trim ($ rand ),
33
+ 'date ' =>date ('y-m-d ' ),
34
+ 'user ' =>trim ($ user ),
35
+ );
36
+ $ wpdb ->insert ($ table , $ data );
37
+ echo '<div class="alert alert-success"><i class="fa fa-thumbs-up"></i> Uploaded seccessfully</div>|^***^|1|^***^| ' ;
38
+ }
39
+ else
40
+ {
41
+ echo '<div class="alert alert-danger"><i class="fa fa-explanation-circle"></i> Extension not good <strong>Please try again.</strong></div>|^***^|2|^***^| ' ;
42
+ exit ();
43
+ }
44
+ $ n ++;
45
+ }
46
+ }
47
+ if (isset ($ _REQUEST ['delete ' ]) and $ _REQUEST ['delete ' ]=='ok ' ){
48
+ extract ($ _REQUEST );
49
+ global $ wpdb ;
50
+ $ table = $ wpdb ->prefix . "pdffiles " ;
51
+ $ getData = $ wpdb ->get_results ('SELECT * FROM ' .$ table .' WHERE 1 AND id= ' .$ id .'' );
52
+ if (count ($ getData )>0 ){
53
+ unlink (zPDFpopupViewer_UPLOADS_PATH.$ getData [0 ]->filename );
54
+ $ where = array ('id ' =>$ id );
55
+ $ wpdb ->delete ( $ table , $ where );
56
+ echo '<div class="alert alert-success"><i class="fa fa-thumbs-up"></i> Deleted Successfully.</div>|^***^| ' .$ id .'|^***^| ' ;
57
+ }else {
58
+ echo '<div class="alert alert-danger"><i class="fa fa-explanation-circle"></i> There is some thing wrong <strong>Please try again.</strong></div>|^***^|0|^***^| ' ;
59
+ }
60
+ }
61
+
62
+ if (isset ($ _REQUEST ['advSettings ' ]) and $ _REQUEST ['advSettings ' ]=='ok ' ){
63
+ extract ($ _REQUEST );
64
+ global $ wpdb ;
65
+ $ advTable = $ wpdb ->prefix . "pdffiles_advance_settings " ;
66
+ $ getData = $ wpdb ->get_results ('SELECT * FROM ' .$ advTable .'' );
67
+ if (count ($ getData )>0 ){
68
+ $ advData = array (
69
+ 'maxSize ' => $ maxSize ,
70
+ 'parallelUpload ' => $ parallelUpload ,
71
+ 'extnAllows ' => trim (strtolower ($ extnAllows )),
72
+ 'btnName ' => trim ($ btnName ),
73
+ 'btnTitle ' => trim ($ btnTitle ),
74
+ 'btnClass ' => trim ($ btnClass ),
75
+ 'ajaxStatus ' => $ ajaxStatus ,
76
+ 'windowTarget ' => trim ($ windowTarget ),
77
+ );
78
+ $ wpdb ->update ($ advTable , $ advData , array ('id ' =>1 ), $ format = null , $ where_format = null );
79
+ echo '<div class="alert alert-success"><i class="fa fa-thumbs-up"></i> Settings save successfully.</div>|^***^|1|^***^| ' ;
80
+ }else {
81
+ echo '<div class="alert alert-danger"><i class="fa fa-explanation-circle"></i> There is some thing wrong <strong>Please try again.</strong></div>|^***^|0|^***^| ' ;
82
+ }
83
+ }
0 commit comments