file = $path; $dir = dirname($path); if (!is_dir($dir)) { mkdir($dir); } } /** * Create log record * * @param string $cmd command name * @param array $result command result * @param array $args command arguments from client * @param elFinder $elfinder elFinder instance * @param elFinderVolumeDriver $volume current volume driver instance * @return void|true * @author Dmitry (dio) Levashov **/ public function log($cmd, $result, $args, $elfinder, $volume) { $log = $cmd.' ['.date('d.m H:s')."]\n"; if (!empty($result['error'])) { $log .= "\tERROR: ".implode(' ', $result['error'])."\n"; } if (!empty($result['warning'])) { $log .= "\tWARNING: ".implode(' ', $result['warning'])."\n"; } if (!empty($result['removed'])) { foreach ($result['removed'] as $file) { // removed file contain additional field "realpath" $log .= "\tREMOVED: ".$file['realpath']."\n"; } } if (!empty($result['added'])) { foreach ($result['added'] as $file) { $log .= "\tADDED: ".$elfinder->realpath($file['hash'])."\n"; } } if (!empty($result['changed'])) { foreach ($result['changed'] as $file) { $log .= "\tCHANGED: ".$elfinder->realpath($file['hash'])."\n"; } } $this->write($log); } /** * Write log into file * * @param string $log log record * @return void * @author Dmitry (dio) Levashov **/ protected function write($log) { if (($fp = @fopen($this->file, 'a'))) { fwrite($fp, $log."\n"); fclose($fp); } } } // END class // Make logger instance $logger = new elFinderSimpleLogger('.log.txt'); // Documentation for connector options: // https://github.com/Studio-42/elFinder/wiki/Connector-configuration-options $opts = array( 'debug' => true, // enable debug mode 'roots' => array( // Items volume array( 'driver' => 'LocalFileSystem', // driver for accessing file system (REQUIRED) 'path' => '../files/', // path to files (REQUIRED) 'URL' => dirname($_SERVER['PHP_SELF']) . '/../files/', // URL to files (REQUIRED) 'trashHash' => 't1_Lw', // elFinder's hash of trash folder 'winHashFix' => DIRECTORY_SEPARATOR !== '/', // to make hash same to Linux one on windows too 'uploadDeny' => array('all'), // All Mimetypes not allowed to upload '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 'uploadOrder' => array('deny', 'allow'), // allowed Mimetype `image` and `text/plain` only 'accessControl' => 'access', // disable and hide dot starting files (OPTIONAL) 'attributes' => array( // additional thumbnail directories 'pattern' => '~^/\.tmb(?:Cloud|Netmount)$~', 'read' => false, 'write' => false, 'locked' => true, 'hidden' => true ), ), // Trash volume array( 'id' => '1', 'driver' => 'Trash', 'path' => '../files/.trash/', 'tmbURL' => dirname($_SERVER['PHP_SELF']) . '/../files/.trash/.tmb/', 'winHashFix' => DIRECTORY_SEPARATOR !== '/', // to make hash same to Linux one on windows too 'uploadDeny' => array('all'), // Recomend the same settings as the original volume that uses the trash 'uploadAllow' => array('image/x-ms-bmp', 'image/gif', 'image/jpeg', 'image/png', 'image/x-icon', 'text/plain'), // Same as above 'uploadOrder' => array('deny', 'allow'), // Same as above 'accessControl' => 'access', // Same as above ), ), // some bind functions 'bind' => array( // enable logger // '*' => array($logger, 'log'), 'mkdir mkfile rename duplicate upload rm paste' => array($logger, 'log'), // enable plugins 'archive.pre ls.pre mkdir.pre mkfile.pre rename.pre upload.pre' => array( 'Plugin.Normalizer.cmdPreprocess', 'Plugin.Sanitizer.cmdPreprocess' ), 'upload.presave' => array( 'Plugin.AutoRotate.onUpLoadPreSave', 'Plugin.AutoResize.onUpLoadPreSave', 'Plugin.Watermark.onUpLoadPreSave', 'Plugin.Normalizer.onUpLoadPreSave', 'Plugin.Sanitizer.onUpLoadPreSave', ), ), // volume options of netmount volumes 'optionsNetVolumes' => array( '*' => array( // "*" is all of netmount volumes 'tmbURL' => dirname($_SERVER['PHP_SELF']) . '/../files/.tmbNetmount/', 'tmbPath' => '../files/.tmbNetmount', 'tmbGcMaxlifeHour' => 1, // 1 hour 'tmbGcPercentage' => 10, // 10 execute / 100 tmb querys 'plugin' => array( 'AutoResize' => array( 'enable' => false ), 'Watermark' => array( 'enable' => false ), 'Normalizer' => array( 'enable' => false ), 'Sanitizer' => array( 'enable' => false ) ), ) ), ); // Extended other volume types // To get an access token or refresh token, see the elFinder wiki. // https://github.com/Studio-42/elFinder/wiki/How-to-get-OAuth-token // Thumbnail settings for cloud volumes $tmbConfig = array( 'tmbPath' => '../files/.tmbCloud', 'tmbURL' => dirname($_SERVER['PHP_SELF']) . '/../files/.tmbCloud/', 'tmbGcMaxlifeHour' => 2160, // 90 days 'tmbGcPercentage' => 5, // 5 execute / 100 tmb querys ); // MySQL config $mySqlConfig = array( 'path' => 1, 'host' => '127.0.0.1', 'user' => '', // @String DB user name 'pass' => '', // @String DB user password 'db' => '', // @String Database name 'uploadMaxSize' => '10M', // It should be less than "max_allowed_packet" value of MySQL setting ); // MySQL volume $opts['roots'][] = array_merge($tmbConfig, $mySqlConfig, array( 'driver' => 'MySQL', 'trashHash' => 'tm1_MQ', // set trash to MySQL trash (tm1_) 1 (MQ) 'files_table' => 'elfinder_file', )); // MySQL trash volume $opts['roots'][] = array_merge($tmbConfig, $mySqlConfig, array( 'id' => '1', // volume id became "tm1_" 'alias' => 'DB Trash', 'driver' => 'TrashMySQL', 'files_table' => 'elfinder_trash', )); // Volume group $opts['roots'][] = array( 'id' => '1', // volume id became "g1_" 'alias' => 'CloudVolumes', 'driver' => 'Group', 'rootCssClass' => 'elfinder-navbar-root-network' // set volume icon ); // FTP volume $opts['roots'][] = array_merge($tmbConfig, array( 'phash' => 'g1_Lw', // set parent to Volume group (g1_) root "/" (Lw) 'driver' => 'FTP', 'host' => 'ftp.jaist.ac.jp', 'user' => 'anonymous', 'path' => '/', 'owner' => false, )); // To enable the following cloud volumes, first complete the steps // for enabling each network-mounted volume described earlier in this file. // Box volume // Require constant "ELFINDER_BOX_CLIENTID" and "ELFINDER_BOX_CLIENTSECRET" $opts['roots'][] = array_merge($tmbConfig, array( 'phash' => 'g1_Lw', // set parent to Volume group (g1_) root "/" (Lw) 'driver' => 'Box', 'path' => '/', // or folder id as root 'accessToken' => '', // @JSON String access token including refresh token )); // Dropbox volume // Require constant "ELFINDER_DROPBOX_APPKEY" and "ELFINDER_DROPBOX_APPSECRET" $opts['roots'][] = array_merge($tmbConfig, array( 'phash' => 'g1_Lw', // set parent to Volume group (g1_) root "/" (Lw) 'driver' => 'Dropbox2', 'path' => '/', // or folder path as root 'access_token' => '', // @String your access token )); // GoogleDrive volume with refresh token // Require constant "ELFINDER_GOOGLEDRIVE_CLIENTID" and "ELFINDER_GOOGLEDRIVE_CLIENTSECRET" $opts['roots'][] = array_merge($tmbConfig, array( 'phash' => 'g1_Lw', // set parent to Volume group (g1_) root "/" (Lw) 'driver' => 'GoogleDrive', 'path' => '/', // or folder id as root 'refresh_token' => '', // @String your refresh token )); // GoogleDrive volume with service account // Require constant "ELFINDER_GOOGLEDRIVE_CLIENTID" and "ELFINDER_GOOGLEDRIVE_CLIENTSECRET" $opts['roots'][] = array_merge($tmbConfig, array( 'phash' => 'g1_Lw', // set parent to Volume group (g1_) root "/" (Lw) 'driver' => 'GoogleDrive', 'path' => '/', // or folder id as root 'serviceAccountConfigFile' => '', // @String path to config json file )); // OneDrive volume // Require constant "ELFINDER_ONEDRIVE_CLIENTID" and "ELFINDER_ONEDRIVE_CLIENTSECRET" $opts['roots'][] = array_merge($tmbConfig, array( 'phash' => 'g1_Lw', // set parent to Volume group (g1_) root "/" (Lw) 'driver' => 'OneDrive', 'path' => '/', // or folder id as root 'accessToken' => '', // @JSON String access token including refresh token )); // run elFinder $connector = new elFinderConnector(new elFinder($opts)); $connector->run();