/** * Function to upload and add gallery. * @author Praveen Rajan */ function processor() { if ($_POST['addgallery']) { $newgallery = esc_attr($_POST['galleryname']); if (isset($_POST['gallerydesc'])) { $gallery_desc = esc_attr($_POST['gallerydesc']); } else { $gallery_desc = ''; } if (!empty($newgallery)) { CvgCore::create_gallery($newgallery, $gallery_desc); } else { CvgCore::show_video_error(__('No valid gallery name!')); } } if ($_POST['uploadvideo']) { if ($_FILES['videofiles']['error'][0] == 0) { $messagetext = CvgCore::upload_videos(); CvgCore::xml_playlist($galleryID); } else { CvgCore::show_video_error(__('Upload failed! ' . CvgCore::decode_upload_error($_FILES['videofiles']['error'][0]))); } } }
if (isset($_POST['TB_previewimage_single']) && !empty($_POST['TB_previewimage_single']) && is_array($_FILES['preview_image'])) { if (trim($_FILES['preview_image']['error'][0]) == 4) { CvgCore::show_video_error(__('No preview images uploaded')); } else { CvgCore::upload_preview(); } CvgCore::xml_playlist($_GET['gid']); } //Section to scan videos from folder and add to gallery if (isset($_POST['scanVideos'])) { if (empty($_POST['galleryId'])) { CvgCore::show_video_error(__('No Gallery selected')); } else { CvgCore::scan_upload_videos($_POST['galleryId']); } CvgCore::xml_playlist($_GET['gid']); } $gid = $_GET['gid']; //Section if no gallery is selected. if (!isset($gid)) { ?> <div class="wrap"> <div class="icon32" id="icon-video"><br></div> <h2>Gallery Details</h2> <div class="clear"></div> <div class="versions"> <p> Choose your gallery at <a class="button rbutton" href="<?php echo admin_url('admin.php?page=cvg-gallery-manage'); ?> "><?php
/** * Function to scan gallery folder for new videos * @param $galleryID - gallery id * @author Praveen Rajan */ function scan_upload_videos($galleryID, $enable = true) { global $wpdb; $gallery = videoDB::find_gallery($galleryID); if (!$gallery) { return; } $dirlist = CvgCore::scandir_video($gallery->abspath); $videolist = array(); foreach ($dirlist as $video) { $video_newname = sanitize_file_name($video); $video_found = $wpdb->get_var("SELECT filename FROM " . $wpdb->prefix . "cvg_videos WHERE filename = '{$video_newname}' AND galleryid = '{$galleryID}'"); if (!$video_found) { @rename($gallery->abspath . '/' . $video, $gallery->abspath . '/' . $video_newname); $videolist[] = $video_newname; } } // add videos to database $videos_ids = CvgCore::add_Videos($galleryID, $videolist); if (CvgCore::ffmpegcommandExists()) { foreach ($videos_ids as $video_id) { CvgCore::create_thumbnail_video($video_id); } } if (count($videos_ids) > 0) { CvgCore::xml_playlist($galleryID); if ($enable) { CvgCore::show_video_message(count($videos_ids) . __(' Video(s) successfully added.')); } } else { if ($enable) { CvgCore::show_video_error(__(' No new video(s) found.')); } } }