0
|
1 |
<?php |
|
2 |
/* |
|
3 |
Plugin Name: WP-FileManager |
|
4 |
Plugin URI: http://blog.anantshri.info/projects/wp-filemanager/ |
|
5 |
Description: FileManager for WordPress allows you to easily change, delete, organize and upload files. |
|
6 |
Version: 1.4.0 |
|
7 |
Author: Anant Shrivastava, Johannes Ries |
|
8 |
Author URI: http://anantshri.info |
|
9 |
*/ |
|
10 |
/* |
|
11 |
Todo list for PHPFM: |
|
12 |
------------------------------------------------------------------------------------- |
|
13 |
|
|
14 |
- find work-around for permissions on GNU/Linux & UNIX systems. |
|
15 |
- make a login system where each user has his/hers own home directory and permissions. |
|
16 |
- some kind of logging system. |
|
17 |
- make an install script which makes it easier to install PHPFM. |
|
18 |
- add dos2unix or viceversa support |
|
19 |
- make hidden files unaccessible by the script (again). |
|
20 |
- index with thumbnails of all images in the current directory (uncertain). |
|
21 |
- make it possible to change permissions (chmod) on files and directories. |
|
22 |
- make it so you can compress a directory and download it. |
|
23 |
- do so you can see the full size of a directory (including sub-directories) and how |
|
24 |
many files that are in the directory. |
|
25 |
- templates for new (created) files. For instance PHP, HTML etc. |
|
26 |
- unix style permissions (e.g. -rw-rw-rw-) |
|
27 |
- too long directory- and filenames are shortened so they do not ruin the design. |
|
28 |
- templates for PHPFM. Change the look of PHPFM easily! (not provisional) |
|
29 |
- more languages. |
|
30 |
- add some nifty DHTML? |
|
31 |
- add the drive browser again? |
|
32 |
- PDF viewer and text/PHP viewer with highlighting. |
|
33 |
*/ |
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
/* DO NOT EDIT ANYTHING BELOW THIS LINE */ |
|
39 |
if ( ! defined( 'ABSPATH' ) ) |
|
40 |
die(); |
|
41 |
function get_list_ext($lst_type) |
|
42 |
{ |
|
43 |
if (get_option($lst_type) != "") |
|
44 |
{ |
|
45 |
$ext_list = get_option($lst_type); |
|
46 |
} |
|
47 |
else |
|
48 |
{ |
|
49 |
$ext_list = get_option( $lst_type . '_default'); |
|
50 |
} |
|
51 |
return $ext_list; |
|
52 |
} |
|
53 |
function fm_post_add_options() { |
|
54 |
add_menu_page('FileManager', 'FileManager', 8, 'wp-filemanager/fm.php'); |
|
55 |
add_submenu_page('wp-filemanager/fm.php','FileManager','Configuration',8,'wpfileman', 'wpfileman_options_admin'); |
|
56 |
} |
|
57 |
function wpfileman_options_admin() |
|
58 |
{ |
|
59 |
// echo "options panel for wordpress file man"; |
|
60 |
include_once('conf/config.inc.php'); |
|
61 |
include_once('wp_filemanager_admin.php'); |
|
62 |
} |
|
63 |
add_action('admin_menu', 'fm_post_add_options'); |
|
64 |
//add_action('admin_menu', 'wpfileman_admin'); |
|
65 |
if ($_GET['action'] == 'edit') |
|
66 |
{ |
|
67 |
// wp_enqueue_script('codepress'); |
|
68 |
wp_enqueue_script('jquery'); |
|
69 |
} |
|
70 |
function wp_fileman_rename_file() |
|
71 |
{ |
|
72 |
include(WP_CONTENT_DIR . "/plugins/wp-filemanager/incl/rename.inc.php"); |
|
73 |
exit(); |
|
74 |
} |
|
75 |
add_action('wp_ajax_rename', 'rename_file'); |
|
76 |
add_action("admin_print_scripts",'js_libs'); |
|
77 |
add_action("admin_print_styles", 'style_libs'); |
|
78 |
function js_libs() { |
|
79 |
wp_enqueue_script('jquery'); |
|
80 |
wp_enqueue_script('thickbox'); |
|
81 |
} |
|
82 |
function style_libs() { |
|
83 |
wp_enqueue_style('thickbox'); |
|
84 |
} |
|
85 |
function wpfileman_download_page(){ |
|
86 |
global $pagenow; |
|
87 |
// header("Anant: Hello"); |
|
88 |
include_once('conf/config.inc.php'); |
|
89 |
//http://localhost/wordpress/wp-admin/admin.php?page=wp-filemanager%2Ffm.php&path=test_create%2F&filename=testme.txt&action=download |
|
90 |
$page = (isset($_GET['page']) ? $_GET['page'] : false); |
|
91 |
$action = (isset($_GET['action']) ? $_GET['action'] : false); |
|
92 |
$filename=(isset($_GET['filename']) ? $_GET['filename'] : false); |
|
93 |
$wp_fileman_path=(isset($_GET['path']) ? $_GET['path'] : false); |
|
94 |
//header("Anant: Hello"); |
|
95 |
if($pagenow=='admin.php' && $page=='wp-filemanager/fm.php' && $action=='download' ) |
|
96 |
{ |
|
97 |
//header("Anant: Hello"); |
|
98 |
if (is_file($home_directory.$wp_fileman_path.$filename)) |
|
99 |
{ |
|
100 |
$fullpath = $home_directory.$wp_fileman_path.$filename; |
|
101 |
} |
|
102 |
//header("Anant2: Hello"); |
|
103 |
//wp_redirect('http://google.com'); |
|
104 |
global $MIMEtypes; |
|
105 |
$mime=""; |
|
106 |
if (!empty($MIMEtypes)) |
|
107 |
{//reset($MIMEtypes); |
|
108 |
$extension = strtolower(substr(strrchr($filename, "."),1)); |
|
109 |
if ($extension == "") |
|
110 |
$mime="Unknown/Unknown"; |
|
111 |
while (list($mimetype, $file_extensions) = each($MIMEtypes)) |
|
112 |
foreach (explode(" ", $file_extensions) as $file_extension) |
|
113 |
if ($extension == $file_extension) |
|
114 |
$mime=$mimetype; |
|
115 |
} |
|
116 |
header("Content-Type: ".$mime); |
|
117 |
header("Content-Length: ".filesize($fullpath)); |
|
118 |
header("Content-Disposition: attachment; filename=$filename"); |
|
119 |
readfile($fullpath); |
|
120 |
} |
|
121 |
} |
|
122 |
add_action('admin_init', 'wpfileman_download_page'); |
|
123 |
/**/ |
|
124 |
?> |