Exemplo n.º 1
0
function rename_check($event, $args, $finder)
{
    $name = $args['name'];
    if (gp_restrict_uploads && !\gp\admin\Content\Uploaded::AllowedExtension($name)) {
        return false;
    }
    $args['name'] = $name;
    return $args;
}
Exemplo n.º 2
0
 function __construct($args)
 {
     parent::__construct($args);
     $_REQUEST += array('gpreq' => 'body');
     //force showing only the body as a complete html document
     $this->page->get_theme_css = false;
     $this->page->head .= '<style type="text/css">';
     $this->page->head .= 'html,body{padding:0;margin:0 !important;background-color:#ededed !important;background-image:none !important;border:0 none !important;}';
     $this->page->head .= '#gp_admin_html{padding:5px 0 !important;}';
     $this->page->head .= '</style>';
     $this->Finder();
 }
Exemplo n.º 3
0
 public function GalleryImages()
 {
     $_GET += array('dir' => '/headers');
     \gp\admin\Content\Uploaded::InlineList($_GET['dir']);
 }
Exemplo n.º 4
0
 public function GalleryImages()
 {
     if (isset($_GET['dir'])) {
         $dir_piece = $_GET['dir'];
     } elseif (isset($this->meta_data['gallery_dir'])) {
         $dir_piece = $this->meta_data['gallery_dir'];
     } else {
         $dir_piece = '/image';
     }
     //remember browse directory
     $this->meta_data['gallery_dir'] = $dir_piece;
     $this->SaveThis(false);
     \gp\admin\Content\Uploaded::InlineList($dir_piece);
 }
Exemplo n.º 5
0
 /**
  * Add an uploaded plugin
  *
  */
 function UploadPlugin()
 {
     global $langmessage, $dataDir;
     $archive = $this->UploadedArchive();
     if (!$archive) {
         return false;
     }
     // get plugin name and check file types
     $list = $archive->ListFiles();
     $plugin_name = '';
     $remove_path = '';
     foreach ($list as $file) {
         //don't check extensions on folder
         if ($file['size'] == 0) {
             continue;
         }
         //check extension
         if (!\gp\admin\Content\Uploaded::AllowedExtension($file['name'], false)) {
             msg($langmessage['OOPS'] . ' (File type not allowed:' . htmlspecialchars($file['name']) . ')');
             return false;
         }
         //plugin name
         if (strpos($file['name'], 'plugin.js') !== false) {
             $new_plugin_name = $this->FindPluginName($archive, $file['name']);
             if (!$new_plugin_name) {
                 continue;
             }
             //use the most relevant plugin name
             $new_path = dirname($file['name']);
             if (!$plugin_name || strlen($new_path) < strlen($remove_path)) {
                 $plugin_name = $new_plugin_name;
                 $remove_path = $new_path;
             }
         }
     }
     if (!$this->CanUpload($plugin_name)) {
         return;
     }
     //extract to temporary location
     $extract_temp = $dataDir . \gp\tool\FileSystem::TempFile('/data/_temp/' . $plugin_name);
     if (!$archive->extractTo($extract_temp)) {
         \gp\tool\Files::RmAll($extract_temp);
         msg($langmessage['OOPS'] . ' (Couldn\'t extract to temp location)');
         return false;
     }
     //move to _ckeditor folder
     $destination = $dataDir . '/data/_ckeditor/' . $plugin_name;
     $rename_from = $extract_temp . '/' . ltrim($remove_path, '/');
     if (!\gp\tool\Files::Replace($rename_from, $destination)) {
         msg($langmessage['OOPS'] . ' (Not replaced)');
         return false;
     }
     // save configuration
     if (!array_key_exists($plugin_name, $this->cke_config['plugins'])) {
         $this->cke_config['plugins'][$plugin_name] = array('installed' => time());
     }
     $this->cke_config['plugins'][$plugin_name]['updated'] = time();
     $this->SaveConfig();
     msg($langmessage['SAVED']);
 }
Exemplo n.º 6
0
 /**
  * Get the posted content for an image area
  *
  */
 public static function SectionFromPost_Image(&$section, $dest_dir = '/data/_resized/img_type/')
 {
     global $page, $dataDir, $dirPrefix, $langmessage;
     $page->ajaxReplace = array();
     //source file
     if (!empty($_REQUEST['file'])) {
         $source_file_rel = $_REQUEST['file'];
     }
     if (!empty($_REQUEST['src'])) {
         $source_file_rel = rawurldecode($_REQUEST['src']);
         if (!empty($dirPrefix)) {
             $len = strlen($dirPrefix);
             $source_file_rel = substr($source_file_rel, $len);
         }
     }
     $source_file_rel = '/' . ltrim($source_file_rel, '/');
     $source_file_full = $dataDir . $source_file_rel;
     if (!file_exists($source_file_full)) {
         msg($langmessage['OOPS'] . ' (Source file not found)');
         return false;
     }
     $src_img = \gp\tool\Image::getSrcImg($source_file_full);
     if (!$src_img) {
         msg($langmessage['OOPS'] . ' (Couldn\'t create image [1])');
         return false;
     }
     //size and position variables
     $orig_w = imagesx($src_img);
     $orig_h = imagesy($src_img);
     $posx = self::ReqNumeric('posx', 0);
     $posy = self::ReqNumeric('posy', 0);
     $width = self::ReqNumeric('width', $orig_w);
     $height = self::ReqNumeric('height', $orig_h);
     //check to see if the image needs to be resized
     if ($posx == 0 && $posy == 0 && $width == $orig_w && $height == $orig_h) {
         $section['attributes']['src'] = $source_file_rel;
         $section['attributes']['height'] = $height;
         $section['attributes']['width'] = $width;
         $section['orig_src'] = $_REQUEST['src'];
         $section['posx'] = 0;
         $section['posy'] = 0;
         return true;
     }
     //destination file
     $name = basename($source_file_rel);
     $parts = explode('.', $name);
     //remove the time portion of the filename
     if (count($parts) > 1) {
         $time_part = array_pop($parts);
         if (!ctype_digit($time_part)) {
             $parts[] = $time_part;
         }
     }
     $name = implode('.', $parts);
     $time = self::ReqTime();
     $dest_img_rel = $dest_dir . $name . '.' . $time . '.png';
     $dest_img_full = $dataDir . $dest_img_rel;
     //make sure the folder exists
     if (!\gp\tool\Files::CheckDir(dirname($dest_img_full))) {
         msg($langmessage['OOPS'] . ' (Couldn\'t create directory)');
         return false;
     }
     if (!\gp\tool\Image::createImg($src_img, $dest_img_full, $posx, $posy, 0, 0, $orig_w, $orig_h, $orig_w, $orig_h, $width, $height)) {
         msg($langmessage['OOPS'] . ' (Couldn\'t create image [2])');
         return false;
     }
     $section['attributes']['src'] = $dest_img_rel;
     $section['attributes']['height'] = $height;
     $section['attributes']['width'] = $width;
     $section['orig_src'] = $_REQUEST['src'];
     $section['posx'] = $posx;
     $section['posy'] = $posy;
     \gp\admin\Content\Uploaded::CreateThumbnail($dest_img_full);
     return true;
 }