Example #1
0
 /**
  *  Performs actions after changes are made to files in elFinder
  *
  */
 static function FinderChange($cmd, $result, $args, $elfinder)
 {
     global $dataDir, $config;
     includeFile('image.php');
     gp_resized::SetIndex();
     $base_dir = $dataDir . '/data/_uploaded';
     $thumb_dir = $dataDir . '/data/_uploaded/image/thumbnails';
     admin_uploaded::SetRealPath($result, $elfinder);
     switch ($cmd) {
         case 'rename':
             admin_uploaded::RenameResized($result['removed'][0], $result['added'][0]);
             break;
         case 'rm':
             admin_uploaded::RemoveResized($result['removed']);
             break;
         case 'paste':
             admin_uploaded::MoveResized($result['removed'], $result['added']);
             break;
             //check the image size
         //check the image size
         case 'upload':
             admin_uploaded::MaxSize($result['added']);
             break;
     }
     //removed files first
     //	- Remove associated thumbnail
     if (isset($result['removed']) && count($result['removed']) > 0) {
         foreach ($result['removed'] as $removed) {
             $removed_path = $removed['realpath'];
             $thumb_path = str_replace($base_dir, $thumb_dir, $removed_path) . '.jpg';
             if (file_exists($thumb_path)) {
                 unlink($thumb_path);
             }
         }
     }
     //addded files
     if (isset($result['added']) && count($result['added']) > 0) {
         foreach ($result['added'] as $added) {
             $added_path = $added['realpath'];
             $thumb_path = str_replace($base_dir, $thumb_dir, $added_path) . '.jpg';
             gpFiles::CheckDir($thumb_dir);
             thumbnail::createSquare($added_path, $thumb_path, $config['maxthumbsize']);
             gpPlugin::Action('FileUploaded', $added_path);
         }
     }
     //changed files (resized)
     if (isset($result['changed']) && count($result['changed']) > 0) {
         foreach ($result['changed'] as $changed) {
             $changed_path = $changed['realpath'];
             $thumb_path = str_replace($base_dir, $thumb_dir, $changed_path) . '.jpg';
             gpFiles::CheckDir($thumb_dir);
             thumbnail::createSquare($changed_path, $thumb_path, $config['maxthumbsize']);
         }
     }
     gp_resized::SaveIndex();
     //debug
     /*
     $log_file = $dataDir.'/data/_temp/finder_log-all_vars.txt';
     $data = get_defined_vars();
     $content = print_r($data,true);
     gpFiles::Save($log_file,$content);
     */
 }
Example #2
0
 /**
  * Create a thumbnail for the image at the path given by $original
  *
  */
 static function CreateThumbnail($original)
 {
     global $config, $dataDir;
     $prefix = $dataDir . '/data/_uploaded';
     $thumb_prefix = $dataDir . '/data/_uploaded/image/thumbnails';
     if (strpos($original, $thumb_prefix) !== false) {
         return;
     }
     if (strpos($original, $prefix) !== 0) {
         return;
     }
     $len = strlen($prefix);
     $thumb_path = substr($original, $len);
     $thumb_path = $thumb_prefix . $thumb_path;
     $thumb_dir = common::DirName($thumb_path);
     $thumb_path = $thumb_dir . '/' . basename($thumb_path) . '.jpg';
     gpFiles::CheckDir($thumb_dir);
     thumbnail::createSquare($original, $thumb_path, $config['maxthumbsize']);
 }