PluginProbe ʕ •ᴥ•ʔ
Advanced File Manager – Ultimate File Manager for WordPress And Document Library Solution / trunk
Advanced File Manager – Ultimate File Manager for WordPress And Document Library Solution vtrunk
trunk 4.1.5 4.1.6 5.0 5.2.13 5.2.14 5.3.0 5.3.1 5.3.2 5.3.3 5.3.4 5.3.5 5.3.6 5.4.0 5.4.1 5.4.10 5.4.11 5.4.12 5.4.2 5.4.3 5.4.4 5.4.5 5.4.6 5.4.7 5.4.8
file-manager-advanced / application / library / php / connector.maximal.php-dist
file-manager-advanced / application / library / php Last commit date
.tmp 10 months ago editors 1 month ago libs 7 years ago plugins 3 years ago resources 7 years ago MySQLStorage.sql 1 year ago autoload.php 10 months ago connector.maximal.php-dist 1 year ago connector.minimal.php-dist 1 year ago elFinder.class.php 1 month ago elFinderConnector.class.php 1 month ago elFinderFlysystemGoogleDriveNetmount.php 5 years ago elFinderPlugin.php 7 years ago elFinderSession.php 4 years ago elFinderSessionInterface.php 7 years ago elFinderVolumeBox.class.php 5 years ago elFinderVolumeDriver.class.php 1 month ago elFinderVolumeDropbox.class.php 1 year ago elFinderVolumeDropbox2.class.php 1 month ago elFinderVolumeFTP.class.php 5 years ago elFinderVolumeGoogleDrive.class.php 5 years ago elFinderVolumeGroup.class.php 7 years ago elFinderVolumeLocalFileSystem.class.php 2 years ago elFinderVolumeMySQL.class.php 10 months ago elFinderVolumeOneDrive.class.php 1 month ago elFinderVolumeSFTPphpseclib.class.php 1 month ago elFinderVolumeTrash.class.php 7 years ago elFinderVolumeTrashMySQL.class.php 7 years ago mime.types 3 years ago
connector.maximal.php-dist
450 lines
1 <?php
2
3 error_reporting(0); // Set E_ALL for debuging
4
5 // // Optional exec path settings (Default is called with command name only)
6 // define('ELFINDER_TAR_PATH', '/PATH/TO/tar');
7 // define('ELFINDER_GZIP_PATH', '/PATH/TO/gzip');
8 // define('ELFINDER_BZIP2_PATH', '/PATH/TO/bzip2');
9 // define('ELFINDER_XZ_PATH', '/PATH/TO/xz');
10 // define('ELFINDER_ZIP_PATH', '/PATH/TO/zip');
11 // define('ELFINDER_UNZIP_PATH', '/PATH/TO/unzip');
12 // define('ELFINDER_RAR_PATH', '/PATH/TO/rar');
13 // define('ELFINDER_UNRAR_PATH', '/PATH/TO/unrar');
14 // define('ELFINDER_7Z_PATH', '/PATH/TO/7za');
15 // define('ELFINDER_CONVERT_PATH', '/PATH/TO/convert');
16 // define('ELFINDER_IDENTIFY_PATH', '/PATH/TO/identify');
17 // define('ELFINDER_EXIFTRAN_PATH', '/PATH/TO/exiftran');
18 // define('ELFINDER_JPEGTRAN_PATH', '/PATH/TO/jpegtran');
19 // define('ELFINDER_FFMPEG_PATH', '/PATH/TO/ffmpeg');
20
21 // define('ELFINDER_CONNECTOR_URL', 'URL to this connector script'); // see elFinder::getConnectorUrl()
22
23 // define('ELFINDER_DEBUG_ERRORLEVEL', -1); // Error reporting level of debug mode
24
25 // // To Enable(true) handling of PostScript files by ImageMagick
26 // // It is disabled by default as a countermeasure
27 // // of Ghostscript multiple -dSAFER sandbox bypass vulnerabilities
28 // // see https://www.kb.cert.org/vuls/id/332928
29 // define('ELFINDER_IMAGEMAGICK_PS', true);
30 // ===============================================
31
32 // // load composer autoload before load elFinder autoload If you need composer
33 // // You need to run the composer command in the php directory.
34 is_readable('./vendor/autoload.php') && require './vendor/autoload.php';
35
36 // // elFinder autoload
37 require './autoload.php';
38 // ===============================================
39
40 // // Enable FTP connector netmount
41 elFinder::$netDrivers['ftp'] = 'FTP';
42 // ===============================================
43
44 // // Required for Dropbox network mount
45 // // Installation by composer
46 // // `composer require kunalvarma05/dropbox-php-sdk` on php directory
47 // // Enable network mount
48 // elFinder::$netDrivers['dropbox2'] = 'Dropbox2';
49 // // Dropbox2 Netmount driver need next two settings. You can get at https://www.dropbox.com/developers/apps
50 // // AND require register redirect url to "YOUR_CONNECTOR_URL?cmd=netmount&protocol=dropbox2&host=1"
51 // define('ELFINDER_DROPBOX_APPKEY', '');
52 // define('ELFINDER_DROPBOX_APPSECRET', '');
53 // ===============================================
54
55 // // Required for Google Drive network mount
56 // // Installation by composer
57 // // `composer require google/apiclient:^2.0` on php directory
58 // // Enable network mount
59 // elFinder::$netDrivers['googledrive'] = 'GoogleDrive';
60 // // GoogleDrive Netmount driver need next two settings. You can get at https://console.developers.google.com
61 // // AND require register redirect url to "YOUR_CONNECTOR_URL?cmd=netmount&protocol=googledrive&host=1"
62 // define('ELFINDER_GOOGLEDRIVE_CLIENTID', '');
63 // define('ELFINDER_GOOGLEDRIVE_CLIENTSECRET', '');
64 // // Required case when Google API is NOT added via composer
65 // define('ELFINDER_GOOGLEDRIVE_GOOGLEAPICLIENT', '/path/to/google-api-php-client/vendor/autoload.php');
66 // ===============================================
67
68 // // Required for Google Drive network mount with Flysystem
69 // // Installation by composer
70 // // `composer require nao-pon/flysystem-google-drive:~1.1 nao-pon/elfinder-flysystem-driver-ext` on php directory
71 // // Enable network mount
72 // elFinder::$netDrivers['googledrive'] = 'FlysystemGoogleDriveNetmount';
73 // // GoogleDrive Netmount driver need next two settings. You can get at https://console.developers.google.com
74 // // AND require register redirect url to "YOUR_CONNECTOR_URL?cmd=netmount&protocol=googledrive&host=1"
75 // define('ELFINDER_GOOGLEDRIVE_CLIENTID', '');
76 // define('ELFINDER_GOOGLEDRIVE_CLIENTSECRET', '');
77 // // And "php/.tmp" directory must exist and be writable by PHP.
78 // ===============================================
79
80 // // Required for One Drive network mount
81 // // * cURL PHP extension required
82 // // * HTTP server PATH_INFO supports required
83 // // Enable network mount
84 // elFinder::$netDrivers['onedrive'] = 'OneDrive';
85 // // OneDrive Netmount driver need next two settings. You can get at
86 // // https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredApps
87 // // AND require register redirect url to "YOUR_CONNECTOR_URL/netmount/onedrive/1"
88 // define('ELFINDER_ONEDRIVE_CLIENTID', '');
89 // define('ELFINDER_ONEDRIVE_CLIENTSECRET', '');
90 // ===============================================
91
92 // // Required for Box network mount
93 // // * cURL PHP extension required
94 // // Enable network mount
95 // elFinder::$netDrivers['box'] = 'Box';
96 // // Box Netmount driver need next two settings. You can get at https://developer.box.com
97 // // AND require register redirect url to "YOUR_CONNECTOR_URL?cmd=netmount&protocol=box&host=1"
98 // define('ELFINDER_BOX_CLIENTID', '');
99 // define('ELFINDER_BOX_CLIENTSECRET', '');
100 // ===============================================
101
102
103 // // Zoho Office Editor APIKey
104 // // https://www.zoho.com/docs/help/office-apis.html
105 // define('ELFINDER_ZOHO_OFFICE_APIKEY', '');
106 // ===============================================
107
108 // // Online converter (online-convert.com) APIKey
109 // // https://apiv2.online-convert.com/docs/getting_started/api_key.html
110 // define('ELFINDER_ONLINE_CONVERT_APIKEY', '');
111 // ===============================================
112
113 // // Zip Archive editor
114 // // Installation by composer
115 // // `composer require nao-pon/elfinder-flysystem-ziparchive-netmount` on php directory
116 // define('ELFINDER_DISABLE_ZIPEDITOR', false); // set `true` to disable zip editor
117 // ===============================================
118
119 /**
120 * Simple function to demonstrate how to control file access using "accessControl" callback.
121 * This method will disable accessing files/folders starting from '.' (dot)
122 *
123 * @param string $attr attribute name (read|write|locked|hidden)
124 * @param string $path absolute file path
125 * @param string $data value of volume option `accessControlData`
126 * @param object $volume elFinder volume driver object
127 * @param bool|null $isDir path is directory (true: directory, false: file, null: unknown)
128 * @param string $relpath file path relative to volume root directory started with directory separator
129 * @return bool|null
130 **/
131 function access($attr, $path, $data, $volume, $isDir, $relpath) {
132 $basename = basename($path);
133 return $basename[0] === '.' // if file/folder begins with '.' (dot)
134 && strlen($relpath) !== 1 // but with out volume root
135 ? !($attr == 'read' || $attr == 'write') // set read+write to false, other (locked+hidden) set to true
136 : null; // else elFinder decide it itself
137 }
138
139 /**
140 * Simple debug function
141 * Usage: debug($anyVal[, $anyVal2 ...]);
142 */
143 function debug() {
144 $arg = func_get_args();
145 ob_start();
146 foreach($arg as $v) {
147 var_dump($v);
148 }
149 $o = ob_get_contents();
150 ob_end_clean();
151 file_put_contents('.debug.txt', $o, FILE_APPEND);
152 }
153
154 /**
155 * Simple logger function.
156 * Demonstrate how to work with elFinder event api.
157 *
158 * @package elFinder
159 * @author Dmitry (dio) Levashov
160 **/
161 class elFinderSimpleLogger {
162
163 /**
164 * Log file path
165 *
166 * @var string
167 **/
168 protected $file = '';
169
170 /**
171 * constructor
172 *
173 * @return void
174 * @author Dmitry (dio) Levashov
175 **/
176 public function __construct($path)
177 {
178 $this->file = $path;
179 $dir = dirname($path);
180 if (!is_dir($dir)) {
181 mkdir($dir);
182 }
183 }
184
185 /**
186 * Create log record
187 *
188 * @param string $cmd command name
189 * @param array $result command result
190 * @param array $args command arguments from client
191 * @param elFinder $elfinder elFinder instance
192 * @param elFinderVolumeDriver $volume current volume driver instance
193 * @return void|true
194 * @author Dmitry (dio) Levashov
195 **/
196 public function log($cmd, $result, $args, $elfinder, $volume)
197 {
198 $log = $cmd.' ['.date('d.m H:s')."]\n";
199
200 if (!empty($result['error'])) {
201 $log .= "\tERROR: ".implode(' ', $result['error'])."\n";
202 }
203
204 if (!empty($result['warning'])) {
205 $log .= "\tWARNING: ".implode(' ', $result['warning'])."\n";
206 }
207
208 if (!empty($result['removed'])) {
209 foreach ($result['removed'] as $file) {
210 // removed file contain additional field "realpath"
211 $log .= "\tREMOVED: ".$file['realpath']."\n";
212 }
213 }
214
215 if (!empty($result['added'])) {
216 foreach ($result['added'] as $file) {
217 $log .= "\tADDED: ".$elfinder->realpath($file['hash'])."\n";
218 }
219 }
220
221 if (!empty($result['changed'])) {
222 foreach ($result['changed'] as $file) {
223 $log .= "\tCHANGED: ".$elfinder->realpath($file['hash'])."\n";
224 }
225 }
226
227 $this->write($log);
228 }
229
230 /**
231 * Write log into file
232 *
233 * @param string $log log record
234 * @return void
235 * @author Dmitry (dio) Levashov
236 **/
237 protected function write($log)
238 {
239
240 if (($fp = @fopen($this->file, 'a'))) {
241 fwrite($fp, $log."\n");
242 fclose($fp);
243 }
244 }
245
246 } // END class
247 // Make logger instance
248 $logger = new elFinderSimpleLogger('.log.txt');
249
250 // Documentation for connector options:
251 // https://github.com/Studio-42/elFinder/wiki/Connector-configuration-options
252 $opts = array(
253 'debug' => true, // enable debug mode
254 'roots' => array(
255 // Items volume
256 array(
257 'driver' => 'LocalFileSystem', // driver for accessing file system (REQUIRED)
258 'path' => '../files/', // path to files (REQUIRED)
259 'URL' => dirname($_SERVER['PHP_SELF']) . '/../files/', // URL to files (REQUIRED)
260 'trashHash' => 't1_Lw', // elFinder's hash of trash folder
261 'winHashFix' => DIRECTORY_SEPARATOR !== '/', // to make hash same to Linux one on windows too
262 'uploadDeny' => array('all'), // All Mimetypes not allowed to upload
263 'uploadAllow' => array('image/x-ms-bmp', 'image/gif', 'image/jpeg', 'image/png', 'image/x-icon', 'text/plain'), // Mimetype `image` and `text/plain` allowed to upload
264 'uploadOrder' => array('deny', 'allow'), // allowed Mimetype `image` and `text/plain` only
265 'accessControl' => 'access', // disable and hide dot starting files (OPTIONAL)
266 'attributes' => array( // additional thumbnail directories
267 'pattern' => '~^/\.tmb(?:Cloud|Netmount)$~',
268 'read' => false,
269 'write' => false,
270 'locked' => true,
271 'hidden' => true ),
272 ),
273 // Trash volume
274 array(
275 'id' => '1',
276 'driver' => 'Trash',
277 'path' => '../files/.trash/',
278 'tmbURL' => dirname($_SERVER['PHP_SELF']) . '/../files/.trash/.tmb/',
279 'winHashFix' => DIRECTORY_SEPARATOR !== '/', // to make hash same to Linux one on windows too
280 'uploadDeny' => array('all'), // Recomend the same settings as the original volume that uses the trash
281 'uploadAllow' => array('image/x-ms-bmp', 'image/gif', 'image/jpeg', 'image/png', 'image/x-icon', 'text/plain'), // Same as above
282 'uploadOrder' => array('deny', 'allow'), // Same as above
283 'accessControl' => 'access', // Same as above
284 ),
285 ),
286 // some bind functions
287 'bind' => array(
288 // enable logger
289 // '*' => array($logger, 'log'),
290 'mkdir mkfile rename duplicate upload rm paste' => array($logger, 'log'),
291 // enable plugins
292 'archive.pre ls.pre mkdir.pre mkfile.pre rename.pre upload.pre' => array(
293 'Plugin.Normalizer.cmdPreprocess',
294 'Plugin.Sanitizer.cmdPreprocess'
295 ),
296 'upload.presave' => array(
297 'Plugin.AutoRotate.onUpLoadPreSave',
298 'Plugin.AutoResize.onUpLoadPreSave',
299 'Plugin.Watermark.onUpLoadPreSave',
300 'Plugin.Normalizer.onUpLoadPreSave',
301 'Plugin.Sanitizer.onUpLoadPreSave',
302 ),
303 ),
304 // volume options of netmount volumes
305 'optionsNetVolumes' => array(
306 '*' => array( // "*" is all of netmount volumes
307 'tmbURL' => dirname($_SERVER['PHP_SELF']) . '/../files/.tmbNetmount/',
308 'tmbPath' => '../files/.tmbNetmount',
309 'tmbGcMaxlifeHour' => 1, // 1 hour
310 'tmbGcPercentage' => 10, // 10 execute / 100 tmb querys
311 'plugin' => array(
312 'AutoResize' => array(
313 'enable' => false
314 ),
315 'Watermark' => array(
316 'enable' => false
317 ),
318 'Normalizer' => array(
319 'enable' => false
320 ),
321 'Sanitizer' => array(
322 'enable' => false
323 )
324 ),
325 )
326 ),
327 );
328
329 // Extended other volume types
330 // To get an access token or refresh token, see the elFinder wiki.
331 // https://github.com/Studio-42/elFinder/wiki/How-to-get-OAuth-token
332
333 // Thumbnail settings for cloud volumes
334 $tmbConfig = array(
335 'tmbPath' => '../files/.tmbCloud',
336 'tmbURL' => dirname($_SERVER['PHP_SELF']) . '/../files/.tmbCloud/',
337 'tmbGcMaxlifeHour' => 2160, // 90 days
338 'tmbGcPercentage' => 5, // 5 execute / 100 tmb querys
339 );
340
341 // MySQL config
342 $mySqlConfig = array(
343 'path' => 1,
344 'host' => '127.0.0.1',
345 'user' => '', // @String DB user name
346 'pass' => '', // @String DB user password
347 'db' => '', // @String Database name
348 'uploadMaxSize' => '10M', // It should be less than "max_allowed_packet" value of MySQL setting
349 );
350 // MySQL volume
351 $opts['roots'][] = array_merge($tmbConfig, $mySqlConfig, array(
352 'driver' => 'MySQL',
353 'trashHash' => 'tm1_MQ', // set trash to MySQL trash (tm1_) 1 (MQ)
354 'files_table' => 'elfinder_file',
355 ));
356 // MySQL trash volume
357 $opts['roots'][] = array_merge($tmbConfig, $mySqlConfig, array(
358 'id' => '1', // volume id became "tm1_"
359 'alias' => 'DB Trash',
360 'driver' => 'TrashMySQL',
361 'files_table' => 'elfinder_trash',
362 ));
363
364 // Volume group
365 $opts['roots'][] = array(
366 'id' => '1', // volume id became "g1_"
367 'alias' => 'CloudVolumes',
368 'driver' => 'Group',
369 'rootCssClass' => 'elfinder-navbar-root-network' // set volume icon
370 );
371
372 // FTP volume
373 $opts['roots'][] = array_merge($tmbConfig, array(
374 'phash' => 'g1_Lw', // set parent to Volume group (g1_) root "/" (Lw)
375 'driver' => 'FTP',
376 'host' => 'ftp.jaist.ac.jp',
377 'user' => 'anonymous',
378 'path' => '/',
379 'owner' => false,
380 ));
381
382 // To enable the following cloud volumes, first complete the steps
383 // for enabling each network-mounted volume described earlier in this file.
384
385 // Box volume
386 // Require constant "ELFINDER_BOX_CLIENTID" and "ELFINDER_BOX_CLIENTSECRET"
387 $opts['roots'][] = array_merge($tmbConfig, array(
388 'phash' => 'g1_Lw', // set parent to Volume group (g1_) root "/" (Lw)
389 'driver' => 'Box',
390 'path' => '/', // or folder id as root
391 'accessToken' => '', // @JSON String access token including refresh token
392 ));
393
394 // Dropbox volume
395 // Require constant "ELFINDER_DROPBOX_APPKEY" and "ELFINDER_DROPBOX_APPSECRET"
396 $opts['roots'][] = array_merge($tmbConfig, array(
397 'phash' => 'g1_Lw', // set parent to Volume group (g1_) root "/" (Lw)
398 'driver' => 'Dropbox2',
399 'path' => '/', // or folder path as root
400 'access_token' => '', // @String your access token
401 ));
402
403 // GoogleDrive volume with refresh token
404 // Require constant "ELFINDER_GOOGLEDRIVE_CLIENTID" and "ELFINDER_GOOGLEDRIVE_CLIENTSECRET"
405 $opts['roots'][] = array_merge($tmbConfig, array(
406 'phash' => 'g1_Lw', // set parent to Volume group (g1_) root "/" (Lw)
407 'driver' => 'GoogleDrive',
408 'path' => '/', // or folder id as root
409 'refresh_token' => '', // @String your refresh token
410 ));
411
412 // GoogleDrive volume with service account
413 // Require constant "ELFINDER_GOOGLEDRIVE_CLIENTID" and "ELFINDER_GOOGLEDRIVE_CLIENTSECRET"
414 $opts['roots'][] = array_merge($tmbConfig, array(
415 'phash' => 'g1_Lw', // set parent to Volume group (g1_) root "/" (Lw)
416 'driver' => 'GoogleDrive',
417 'path' => '/', // or folder id as root
418 'serviceAccountConfigFile' => '', // @String path to config json file
419 ));
420
421 // OneDrive volume
422 // Require constant "ELFINDER_ONEDRIVE_CLIENTID" and "ELFINDER_ONEDRIVE_CLIENTSECRET"
423 $opts['roots'][] = array_merge($tmbConfig, array(
424 'phash' => 'g1_Lw', // set parent to Volume group (g1_) root "/" (Lw)
425 'driver' => 'OneDrive',
426 'path' => '/', // or folder id as root
427 'accessToken' => '', // @JSON String access token including refresh token
428 ));
429
430 // SFTP volume
431 // Require phpseclib 1 installed (http://phpseclib.sourceforge.net)
432 // pear install example:
433 //sudo pear channel-discover phpseclib.sourceforge.net
434 //sudo pear remote-list -c phpseclib
435 //sudo pear install phpseclib/Net_SFTP
436 /*$opts['roots'][] = array_merge($tmbConfig, array(
437 'phash' => 'g1_Lw', // set parent to Volume group (g1_) root "/" (Lw)
438 'driver' => 'SFTPphpseclib',
439 'host' => '127.0.0.1',
440 'path' => '/tmp', // or folder id as root
441 'user' => 'test', // @JSON String access token including refresh token
442 'pass' => 'test',
443 ));*/
444
445
446 // run elFinder
447 $connector = new elFinderConnector(new elFinder($opts));
448 $connector->run();
449
450