-
Notifications
You must be signed in to change notification settings - Fork 0
/
form.php
115 lines (93 loc) · 3.24 KB
/
form.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
define( 'WP_USE_THEMES', true );
define( 'WP_ADMIN', true );
$dir = dirname( $_SERVER[ 'SCRIPT_FILENAME' ] );
require_once( substr( $dir, 0, strpos( $dir, '/wp-content' ) ) . '/wp-load.php' );
require_once( ABSPATH . 'wp-admin/includes/admin.php' );
wp_enqueue_script( 'plupload-all' );
wp_enqueue_script( 'filebox' );
wp_enqueue_style( 'media' );
wp_enqueue_style( 'filebox' );
function filebox_upload_form() {
global $filebox, $folder_id, $file_id;
$folder_id = array_key_exists( 'folder_id', $_GET ) ? $_GET[ 'folder_id' ] : 0;
$file_id = array_key_exists( 'file_id', $_GET ) ? $_GET[ 'file_id' ] : 0;
if( $filebox->is_allowed( $folder_id, null, true ) ) {
Filebox::get_template( 'filebox-upload-form' );
} else {
echo '<p>Not allowed</p>';
}
}
function filebox_file_form() {
global $filebox, $file, $file_id;
$folder_id = array_key_exists( 'folder_id', $_GET ) ? $_GET[ 'folder_id' ] : 0;
$file_id = array_key_exists( 'file_id', $_GET ) ? $_GET[ 'file_id' ] : 0;
$file = $filebox->get_file( $file_id );
if( $file && $filebox->is_allowed( $folder_id, null, true ) ) {
Filebox::get_template( 'filebox-file-form' );
} else {
echo '<p>Not allowed</p>';
}
}
function filebox_file_history() {
global $filebox, $file, $file_id, $history;
$folder_id = array_key_exists( 'folder_id', $_GET ) ? $_GET[ 'folder_id' ] : 0;
$file_id = array_key_exists( 'file_id', $_GET ) ? $_GET[ 'file_id' ] : 0;
$file = $filebox->get_file( $file_id );
$history = $filebox->history_file( array( 'file_id' => $file_id ), ARRAY_A );
if( $file && $filebox->is_allowed( $filebox->get_folder_by_file( $file_id ) ) ) {
Filebox::get_template( 'filebox-file-history' );
} else {
echo '<p>Not allowed</p>';
}
}
function filebox_folder_form() {
global $filebox, $folder, $folder_id, $folder_parent;
$folder_id = array_key_exists( 'folder_id', $_GET ) ? $_GET[ 'folder_id' ] : 0;
$folder_parent = array_key_exists( 'folder_parent', $_GET ) ? $_GET[ 'folder_parent' ] : 0;
if( $folder_id ) {
$folder = $filebox->get_folder( $folder_id );
}
if(
( $folder_id && $filebox->is_allowed( $folder_id, null, true ) )
|| ( $folder_parent && $filebox->is_allowed( $folder_parent ) )
) {
Filebox::get_template( 'filebox-folder-form' );
} else {
echo '<p>Not allowed</p>';
}
}
function filebox_move_form() {
global $filebox, $folder_list, $folder, $file, $folder_parent;
$folder_id = array_key_exists( 'folder_id', $_GET ) ? $_GET[ 'folder_id' ] : 0;
$folder = $filebox->get_folder( $folder_id );
$file_id = array_key_exists( 'file_id', $_GET ) ? $_GET[ 'file_id' ] : 0;
$folder_list = $filebox->get_all_folders( $filebox->get_group_by_folder( $folder_id ) );
if( $file_id ) {
$file = $filebox->get_file( $file_id );
}
if( $folder_id && $filebox->is_allowed( $folder_id, null, true ) ) {
Filebox::get_template( 'filebox-move-form' );
} else {
echo '<p>Not allowed</p>';
}
}
if( array_key_exists( 'form', $_GET ) ) {
switch( $_GET[ 'form' ] ) {
case 'upload':
wp_iframe( 'filebox_upload_form' );
break;
case 'file':
wp_iframe( 'filebox_file_form' );
break;
case 'history':
wp_iframe( 'filebox_file_history' );
break;
case 'folder':
wp_iframe( 'filebox_folder_form' );
break;
case 'move':
wp_iframe( 'filebox_move_form' );
break;
}
}