function post_processor_images() { global $wpdb, $flag, $flagdb; do_action('flag_manage_post_processor_images'); // bulk update in a single gallery if (isset($_POST['bulkaction']) && isset($_POST['doaction'])) { check_admin_referer('flag_updategallery'); switch ($_POST['bulkaction']) { case 'no_action': break; case 'delete_images': if (is_array($_POST['doaction'])) { $delete_pic = false; foreach ($_POST['doaction'] as $imageID) { $image = $flagdb->find_image($imageID); if ($image) { if ($flag->options['deleteImg']) { @unlink($image->imagePath); @unlink($image->webimagePath); @unlink($image->thumbPath); } $delete_pic = flagdb::delete_image($image->pid); } } if ($delete_pic) { flagGallery::show_message(__('Pictures deleted successfully ', 'flash-album-gallery')); } } break; case 'import_meta': flagAdmin::do_ajax_operation('import_metadata', $_POST['doaction'], __('Import metadata', 'flash-album-gallery')); break; case 'copy_meta': flagAdmin::do_ajax_operation('copy_metadata', $_POST['doaction'], __('Copy metadata to image Description', 'flash-album-gallery')); break; case 'webview_images': flagAdmin::do_ajax_operation('webview_image', $_POST['doaction'], __('Creating images optimized for web', 'flash-album-gallery')); break; case 'reset_counters': if (is_array($_POST['doaction'])) { $images = $flagdb->find_images_in_list($_POST['doaction']); foreach ($images as $image) { $img_id = $image->pid; $wpdb->query("UPDATE {$wpdb->flagpictures} SET hitcounter = '0', total_votes = '0' WHERE pid = {$img_id}"); } } break; } } if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_ResizeImages'])) { check_admin_referer('flag_thickbox_form'); //save the new values for the next operation $flag->options['imgWidth'] = (int) $_POST['imgWidth']; $flag->options['imgHeight'] = (int) $_POST['imgHeight']; update_option('flag_options', $flag->options); $pic_ids = explode(',', $_POST['TB_imagelist']); flagAdmin::do_ajax_operation('resize_image', $pic_ids, __('Resize images', 'flash-album-gallery')); } if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_NewThumbnail'])) { check_admin_referer('flag_thickbox_form'); //save the new values for the next operation $flag->options['thumbWidth'] = (int) $_POST['thumbWidth']; $flag->options['thumbHeight'] = (int) $_POST['thumbHeight']; $flag->options['thumbFix'] = (bool) $_POST['thumbFix']; update_option('flag_options', $flag->options); $pic_ids = explode(',', $_POST['TB_imagelist']); flagAdmin::do_ajax_operation('create_thumbnail', $pic_ids, __('Create new thumbnails', 'flash-album-gallery')); } if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_SelectGallery'])) { check_admin_referer('flag_thickbox_form'); $pic_ids = explode(',', $_POST['TB_imagelist']); $pic_ids = array_filter($pic_ids, 'intval'); $dest_gid = (int) $_POST['dest_gid']; switch ($_POST['TB_bulkaction']) { case 'copy_to': // Copy images flagAdmin::copy_images($pic_ids, $dest_gid); break; case 'move_to': // Move images flagAdmin::move_images($pic_ids, $dest_gid); break; } } if (isset($_POST['updatepictures'])) { // Update pictures check_admin_referer('flag_updategallery'); $gallery_title = esc_html($_POST['title']); $gallery_path = esc_attr(str_replace('..', '', $_POST['path'])); $gallery_desc = esc_html($_POST['gallerydesc']); $gallery_preview = (int) $_POST['previewpic']; $wpdb->query("UPDATE {$wpdb->flaggallery} SET title= '{$gallery_title}', path= '{$gallery_path}', galdesc = '{$gallery_desc}', previewpic = '{$gallery_preview}' WHERE gid = '{$this->gid}'"); if (isset($_POST['author'])) { $gallery_author = (int) $_POST['author']; $wpdb->query("UPDATE {$wpdb->flaggallery} SET author = '{$gallery_author}' WHERE gid = '{$this->gid}'"); } $this->update_pictures(); //hook for other plugin to update the fields do_action('flag_update_gallery', $this->gid, $_POST); flagGallery::show_message(__('Update successful', "flash-album-gallery")); } if (isset($_POST['scanfolder'])) { // Rescan folder check_admin_referer('flag_updategallery'); $gallerypath = $wpdb->get_var("SELECT path FROM {$wpdb->flaggallery} WHERE gid = '{$this->gid}' "); flagAdmin::import_gallery($gallerypath); } }
/** * Function for uploading of images via the upload form * * @class flagAdmin * @return void */ static function upload_images() { global $wpdb; // WPMU action if (flagAdmin::check_quota()) { return; } // Images must be an array $imageslist = array(); // get selected gallery $galleryID = (int) $_POST['galleryselect']; if ($galleryID == 0) { flagGallery::show_error(__('No gallery selected !', 'flag')); return; } // get the path to the gallery $gallery = flagdb::find_gallery($galleryID); if (empty($gallery->path)) { flagGallery::show_error(__('Failure in database, no gallery path set !', 'flag')); return; } // read list of images $dirlist = flagAdmin::scandir(WINABSPATH . $gallery->path); $imagefiles = $_FILES['imagefiles']; if (is_array($imagefiles)) { foreach ($imagefiles['name'] as $key => $value) { // look only for uploded files if ($imagefiles['error'][$key] == 0) { $temp_file = $imagefiles['tmp_name'][$key]; //clean filename and extract extension $filepart = flagGallery::fileinfo($imagefiles['name'][$key]); $filename = $filepart['basename']; // check for allowed extension and if it's an image file $ext = array('jpg', 'png', 'gif'); if (!in_array($filepart['extension'], $ext) || !@getimagesize($temp_file)) { flagGallery::show_error('<strong>' . $imagefiles['name'][$key] . ' </strong>' . __('is no valid image file!', 'flag')); continue; } // check if this filename already exist in the folder $i = 0; while (in_array($filename, $dirlist)) { $filename = $filepart['filename'] . '_' . $i++ . '.' . $filepart['extension']; } $dest_file = $gallery->abspath . '/' . $filename; //check for folder permission if (!is_writeable($gallery->abspath)) { $message = sprintf(__('Unable to write to directory %s. Is this directory writable by the server?', 'flag'), $gallery->abspath); flagGallery::show_error($message); return; } // save temp file to gallery if (!@move_uploaded_file($temp_file, $dest_file)) { flagGallery::show_error(__('Error, the file could not moved to : ', 'flag') . $dest_file); flagAdmin::check_safemode($gallery->abspath); continue; } if (!flagAdmin::chmod($dest_file)) { flagGallery::show_error(__('Error, the file permissions could not set', 'flag')); continue; } // add to imagelist & dirlist $imageslist[] = $filename; $dirlist[] = $filename; } } } if (count($imageslist) > 0) { // add images to database $image_ids = flagAdmin::add_Images($galleryID, $imageslist); //create thumbnails flagAdmin::do_ajax_operation('create_thumbnail', $image_ids, __('Create new thumbnails', 'flag')); //add the preview image if needed flagAdmin::set_gallery_preview($galleryID); flagGallery::show_message(count($image_ids) . __(' Image(s) successfully added', 'flag')); } return; }