function Init() { global $langmessage, $dataDir, $page, $upload_extensions_allow, $upload_extensions_deny; $this->baseDir = $dataDir . '/data/_uploaded'; $this->thumbFolder = $dataDir . '/data/_uploaded/image/thumbnails'; $this->currentDir = $this->baseDir; $page->label = $langmessage['uploaded_files']; $this->AllowedExtensions = array('7z', 'aiff', 'asf', 'avi', 'bmp', 'bz', 'csv', 'doc', 'fla', 'flv', 'gif', 'gz', 'gzip', 'jpeg', 'jpg', 'mid', 'mov', 'mp3', 'mp4', 'mpc', 'mpeg', 'mpg', 'ods', 'odt', 'pdf', 'png', 'ppt', 'pxd', 'qt', 'ram', 'rar', 'rm', 'rmi', 'rmvb', 'rtf', 'sdc', 'sitd', 'swf', 'sxc', 'sxw', 'tar', 'tgz', 'tif', 'tiff', 'txt', 'vsd', 'wav', 'wma', 'wmv', 'xls', 'xml', 'zip'); if (is_array($upload_extensions_allow)) { $this->AllowedExtensions = array_merge($this->AllowedExtensions, $upload_extensions_allow); } if (is_array($upload_extensions_deny)) { $this->AllowedExtensions = array_diff($this->AllowedExtensions, $upload_extensions_deny); } $this->imgTypes = array('bmp' => 1, 'png' => 1, 'jpg' => 1, 'jpeg' => 1, 'gif' => 1, 'tiff' => 1, 'tif' => 1); //get the current path $parts = str_replace(array('\\', '//'), array('/', '/'), $page->title); $parts = trim($parts, '/'); $parts = explode('/', $parts); array_shift($parts); if (count($parts) > 0) { $this->subdir = '/' . implode('/', $parts); $this->subdir = gp_edit::CleanArg($this->subdir); } if (!empty($_REQUEST['dir'])) { $this->subdir .= gp_edit::CleanArg($_REQUEST['dir']); } $this->subdir = str_replace(array('\\', '//'), array('/', '/'), $this->subdir); if ($this->subdir == '/') { $this->subdir = false; } else { $this->currentDir .= $this->subdir; } //prompt to create the requested subdirectory if (!file_exists($this->currentDir)) { gpFiles::CheckDir($this->currentDir); } //is in thumbnail directory? if (strpos($this->currentDir, $this->thumbFolder) !== false) { $this->isThumbDir = true; } $this->currentDir_Thumb = $this->thumbFolder . $this->subdir; }
function AddonText() { global $langmessage, $config; $addon = gp_edit::CleanArg($_REQUEST['addon']); $texts = $this->GetAddonTexts($addon); //not set up correctly if ($texts === false) { $this->EditText(); return; } echo '<div class="inline_box" style="text-align:right">'; echo '<form action="' . common::GetUrl('Admin_Theme_Content') . '" method="post">'; echo '<input type="hidden" name="cmd" value="saveaddontext" />'; echo '<input type="hidden" name="return" value="" />'; //will be populated by javascript echo '<input type="hidden" name="addon" value="' . htmlspecialchars($addon) . '" />'; //will be populated by javascript $this->AddonTextFields($texts); echo ' <input type="submit" name="aaa" value="' . $langmessage['save'] . '" class="gpsubmit" />'; echo ' <input type="submit" name="cmd" value="' . $langmessage['cancel'] . '" class="admin_box_close gpcancel" />'; echo '</form>'; echo '</div>'; }
function GalleryImages() { global $page, $dataDir, $langmessage; includeFile('admin/admin_uploaded.php'); $page->ajaxReplace = array(); 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'; } $dir_piece = common::WinPath($dir_piece); $dir = $dataDir . '/data/_uploaded' . $dir_piece; $prev_piece = false; while ($dir_piece != '/' && !file_exists($dir)) { $prev_piece = $dir_piece; $dir = dirname($dir); $dir_piece = dirname($dir_piece); } //remember browse directory $this->meta_data['gallery_dir'] = $dir_piece; $this->SaveThis(); //new directory? if ($prev_piece) { $prev_piece = gp_edit::CleanArg($prev_piece); $dir_piece = $prev_piece; $dir = $dataDir . '/data/_uploaded' . $prev_piece; if (!gpFiles::CheckDir($dir)) { message($langmessage['OOPS']); $dir = dirname($dir); $dir_piece = dirname($prev_piece); } } admin_uploaded::InlineList($dir, $dir_piece); }
/** * @deprecated * Use gp_edit::CleanArg() instead */ function CleanArg($path) { includeFile('tool/editing.php'); return gp_edit::CleanArg($path); }
/** * Output a list a images in a director for use in inline editing * @static */ static function InlineList($dir_piece) { global $page, $langmessage, $dataDir; $page->ajaxReplace = array(); $dir_piece = common::WinPath($dir_piece); $dir = $dataDir . '/data/_uploaded' . $dir_piece; $prev_piece = false; while ($dir_piece != '/' && !file_exists($dir)) { $prev_piece = $dir_piece; $dir = common::DirName($dir); $dir_piece = common::DirName($dir_piece); } //new directory? if ($prev_piece) { $prev_piece = gp_edit::CleanArg($prev_piece); $dir_piece = $prev_piece; $dir = $dataDir . '/data/_uploaded' . $prev_piece; if (!gpFiles::CheckDir($dir)) { message($langmessage['OOPS']); $dir = common::DirName($dir); $dir_piece = common::DirName($prev_piece); } } //folder information $folders = $files = array(); $allFiles = gpFiles::ReadFolderAndFiles($dir); list($folders, $files) = $allFiles; //folder select ob_start(); echo '<div class="gp_edit_select ckeditor_control">'; echo '<a class="gp_selected_folder"><span class="folder"></span>'; if (strlen($dir_piece) > 23) { echo '...' . substr($dir_piece, -20); } else { echo $dir_piece; } echo '</a>'; echo '<div class="gp_edit_select_options">'; if ($dir_piece != '/') { $temp = common::DirName($dir_piece); echo '<a href="?cmd=new_dir&dir=' . rawurlencode($dir_piece) . '" class="gp_gallery_folder" data-cmd="gpabox"><span class="add"></span>' . $langmessage['create_dir'] . '</a>'; echo '<a class="gp_gallery_folder" data-cmd="gp_gallery_folder" data-arg="' . htmlspecialchars($temp) . '"><span class="folder"></span>../</a>'; } foreach ($folders as $folder) { if ($dir_piece == '/') { $sub_dir = '/' . $folder; } else { $sub_dir = $dir_piece . '/' . $folder; } $full_dir = $dataDir . '/data/_uploaded' . $sub_dir; $sub_files = scandir($full_dir); $count = 0; foreach ($sub_files as $file) { if (admin_uploaded::IsImg($file)) { $count++; } } echo '<a class="gp_gallery_folder" data-cmd="gp_gallery_folder" data-arg="' . htmlspecialchars($sub_dir) . '"><span class="folder"></span><span class="gp_count">' . $count . '</span>' . $folder . '</a>'; } echo '</div>'; echo '</div>'; $gp_option_area = ob_get_clean(); //available images ob_start(); $image_count = 0; foreach ($files as $file) { $img = admin_uploaded::ShowFile_Gallery($dir_piece, $file); if ($img) { echo $img; $image_count++; } } $gp_gallery_avail_imgs = ob_get_clean(); // Folder controls ob_start(); if ($image_count > 0) { echo '<a data-cmd="gp_gallery_add_all" class="ckeditor_control half_width add_all_images">' . $langmessage['Add All Images'] . '</a>'; } if ($dir_piece != '/') { echo '<form action="' . common::GetUrl('Admin_Uploaded') . '" method="post" enctype="multipart/form-data" class="gp_upload_form" id="gp_upload_form">'; admin_uploaded::Max_File_Size(); echo '<a class="ckeditor_control half_width">' . $langmessage['upload_files'] . '</a>'; echo '<div class="gp_object_wrapper">'; echo '<input type="file" name="userfiles[]" class="file" />'; echo '<input type="hidden" name="file_cmd" value="inline_upload" />'; echo '<input type="hidden" name="output" value="gallery" />'; echo '<input type="hidden" name="dir" value="' . $dir_piece . '" />'; echo '</div>'; echo '</form>'; } $folder_options = ob_get_clean(); //send content according to request $cmd = common::GetCommand(); switch ($cmd) { case 'gallery_folder': $page->ajaxReplace[] = array('inner', '#gp_option_area', $gp_option_area); $page->ajaxReplace[] = array('inner', '#gp_gallery_avail_imgs', $gp_gallery_avail_imgs); break; default: $content = '<div id="gp_option_area">' . $gp_option_area . '</div>' . '<div id="gp_gallery_avail_imgs">' . $gp_gallery_avail_imgs . '</div>'; $page->ajaxReplace[] = array('inner', '#gp_image_area', $content); break; } $page->ajaxReplace[] = array('inner', '#gp_folder_options', $folder_options); $page->ajaxReplace[] = array('gp_gallery_images', '', ''); //tell the script the images have been loaded }