コード例 #1
0
 function display($tpl = null)
 {
     global $mainframe;
     //Load pane behavior
     jimport('joomla.html.pane');
     //initialise variables
     $editor =& JFactory::getEditor();
     $document =& JFactory::getDocument();
     $user =& JFactory::getUser();
     $pane =& JPane::getInstance('sliders');
     $c = jomtube_configs::get_instance();
     $this->assignRef('c', $c);
     //get vars
     $cid = JRequest::getVar('cid');
     //create the toolbar
     if ($cid) {
         JToolBarHelper::title(JText::_('EDIT VIDEO'), 'jomtube-videos');
     } else {
         JToolBarHelper::title(JText::_('ADD VIDEO'), 'jomtube-videos');
     }
     JToolBarHelper::apply();
     JToolBarHelper::spacer();
     JToolBarHelper::save();
     JToolBarHelper::spacer();
     JToolBarHelper::cancel();
     //Get data from the model
     $model =& $this->getModel();
     $row =& $this->get('Data');
     if ($row->id != 0 && $row->video_type != 'local' && $row->video_type != null) {
         $r = new JApplication();
         $r->redirect('index.php?option=com_jomtube&controller=videos&task=applylink&cid=' . $row->id);
         $ispublished = JHTML::_('select.genericlist', $yesno, 'published', '', 'value', 'text', $row->published == '' ? 1 : $row->published);
         $isdownloadable = JHTML::_('select.genericlist', $yesno, 'downloadable', '', 'value', 'text', $row->downloadable == '' ? 1 : $row->downloadable);
         $isfeatured = JHTML::_('select.genericlist', $yesno, 'featured', '', 'value', 'text', $row->featured);
     }
     $yesno[] = JHTML::_('select.option', 0, 'No');
     $yesno[] = JHTML::_('select.option', 1, 'Yes');
     //get video list in local directory
     if (JRequest::getVar('category_id', '') != '') {
         $row->directory =& $this->get('CatDirectory');
         $selectedCat = JRequest::getVar('category_id', '');
     } else {
         $selectedCat = $row->id ? $row->category_id : '';
     }
     $currentdir = JPATH_SITE . (@$row->directory == '' ? '/jomtubefiles' : $row->directory);
     $dir = @opendir($currentdir);
     $videos = array();
     while ($file = @readdir($dir)) {
         if ($file != "." and $file != "..") {
             $vidfile = $file;
             $thumbdir = "_thumbs";
             $displaydir = "_display";
             if ($vidfile != $thumbdir || $vidfile != $displaydir) {
                 if (!is_dir($vidfile)) {
                     $ext = JTHelper::getFileExt($vidfile);
                     if (!$c->use_ffmpeg && $ext != 'flv') {
                         continue;
                     }
                     $list_file[] = $vidfile;
                     //JHTML::_('select.option', $vidfile);
                 }
             }
         }
         //if
     }
     @closedir($dir);
     @sort($list_file);
     if (is_array($list_file)) {
         foreach ($list_file as $file) {
             $videos[] = JHTML::_('select.option', $file);
         }
     }
     $videolist = JHTML::_('select.genericlist', $videos, 'video_url', 'id="localvideolist" class="inputbox" style="width:326px;font-size:10px;" size="7" onchange="selectthisvideo()"', 'value', 'text', $row->id ? $row->video_url : '');
     $this->assignRef('category_dir', $currentdir);
     $thumbdir = "_thumbs";
     $current_dir = $currentdir . "/" . $thumbdir;
     $dir = @opendir($current_dir);
     $thumbs = array();
     $thumb_file = array();
     while ($file = @readdir($dir)) {
         if ($file != "." and $file != "..") {
             $thumbfile = $file;
             $thumb_file[] = $thumbfile;
         }
     }
     @closedir($dir);
     if (is_array($thumb_file)) {
         sort($thumb_file);
         foreach ($thumb_file as $file) {
             $thumbs[] = JHTML::_('select.option', $thumbfile, $file);
         }
     }
     //******************************************
     $thumblist = JHTML::_('select.genericlist', $thumbs, 'video_thumb', 'id="localthumblist" class="inputbox" style="width:326px; font-size:10px;" size="7" onchange="selectthisthumb()"', 'value', 'text', $row->id ? $row->video_thumb : '');
     //get parent option
     $categories =& $this->get('ParentOption');
     $parentOptions[] = JHTML::_('select.option', '', '-Select Parent-');
     foreach ($categories as $category) {
         $category_name = str_repeat(' ', 4 * substr_count($category->family_id, "/")) . "+" . $category->category_name;
         $parentOptions[] = JHTML::_('select.option', $category->id, $category_name);
     }
     $parentSelect = JHTML::_('select.genericlist', $parentOptions, 'category_id', 'id="catid" class="inputbox" size="1"  onchange="selectCategory()"', 'value', 'text', $selectedCat);
     //clean data
     JFilterOutput::objectHTMLSafe($row, ENT_QUOTES, 'catdescription');
     //assign data to template
     $this->assignRef('row', $row);
     $this->assignRef('editor', $editor);
     $this->assignRef('parentSelect', $parentSelect);
     $this->assignRef('pane', $pane);
     $this->assignRef('ispublished', $ispublished);
     $this->assignRef('isdownloadable', $isdownloadable);
     $this->assignRef('isfeatured', $isfeatured);
     $this->assignRef('localvideolist', $videolist);
     $this->assignRef('localthumblist', $thumblist);
     //assign data to template
     $this->assignRef('lists', $lists);
     $this->assignRef('my', $my =& JFactory::getUser());
     parent::display($tpl);
 }
コード例 #2
0
			<td width="7"><?php 
    echo $checked;
    ?>
</td>
			<td align="left">
				<a href="<?php 
    echo $link;
    ?>
"><?php 
    echo $row->category_name;
    ?>
</a>
			</td>
			<td>
			     <?php 
    JTHelper::showLocalThumbnail("{$row->directory}/_thumbs/{$row->thumbnail}");
    ?>
			</td>
			<td>
				<?php 
    echo $row->parent_category;
    ?>
			</td>
			<td>
        <?php 
    echo $row->directory;
    ?>
			</td>
			<td align="center"><?php 
    echo $row->id;
    ?>
コード例 #3
0
 function uploadbatch($data)
 {
     $db =& JFactory::getDBO();
     $counter = 0;
     $upload_batch_dir = JPATH_SITE . "/jomtubefiles/_batch_upload/";
     $c = jomtube_configs::get_instance();
     //get category directory
     $query = 'SELECT id, directory FROM #__jomtube_categories WHERE id = \'' . $_POST['category_id'] . '\'';
     $db->setQuery($query);
     $category = $db->loadObject();
     $path_file = JPATH_SITE . $category->directory . '/';
     $path_thumb = JPATH_SITE . $category->directory . '/_thumbs/';
     $path_display = JPATH_SITE . $category->directory . '/_display/';
     if (!is_dir($path_display)) {
         $oldumask = umask(0);
         @mkdir($path_display, 0755);
         umask($oldumask);
     }
     //get video from upload batch dir
     $dir = opendir($upload_batch_dir);
     $counter = 0;
     if ($category) {
         while ($file = readdir($dir)) {
             if ($file != "." and $file != "..") {
                 $vidfile = $file;
                 if (!is_dir($vidfile)) {
                     //move file to the proper category directory
                     if (copy($upload_batch_dir . $vidfile, $path_file . $vidfile)) {
                         unlink($upload_batch_dir . $vidfile);
                         //delete original file
                         //Capitalize the first letter
                         $video_title = str_replace('_', ' ', $vidfile);
                         //remove extension of file
                         $video_title = explode('.', $video_title);
                         $video_title = $video_title[0];
                         $video_title = ucwords($video_title);
                         $_POST['video_title'] = $_POST['video_desc'] = $video_title;
                         $_POST['video_url'] = $vidfile;
                         //get video duration
                         if ($c->use_php_ffmpeg) {
                             //use php-ffmpeg
                             $sec = JTHelper::getMovieDuration($path_file . $vidfile);
                             $duration = JTHelper::sec2hms($sec);
                             //covert to 00:00:00 i.e. hrs:min:sec*/
                         } else {
                             //not use php-ffmpeg
                             $sec = 6;
                             $duration = '';
                         }
                         //get the middle of the movie (time; 00:00:00 format) for thumbnail
                         if ($c->use_ffmpeg) {
                             //use ffmpeg
                             $sec2 = $sec / 2;
                             $sec2 = @round($sec2);
                             if ($sec < 20) {
                                 $thumb_position = 5;
                             } else {
                                 $thumb_position = JTHelper::sec2hms($sec2);
                             }
                             //convert video to flv or mp4
                             if ($c->h264_convert2mp4) {
                                 $path_new = $path_file . $vidfile . '.mp4';
                                 JTHelper::movieToMp4H264_alduccino($path_file . $vidfile, $path_new, $c);
                                 //update video_url
                                 $_POST['video_url'] = $_POST['video_url'] . '.mp4';
                             } else {
                                 $path_new = $path_file . $vidfile . '.flv';
                                 $ext = JTHelper::getFileExt($vidfile);
                                 if ($ext != 'flv') {
                                     JTHelper::movieToFlv($path_file . $vidfile, $path_new, $c);
                                     //update video_url
                                     $_POST['video_url'] = $_POST['video_url'] . '.flv';
                                 }
                             }
                             $_POST['duration'] = $duration;
                             //create thumb
                             JTHelper::flvToThumbnail($path_file . $_POST['video_url'], $path_thumb . $_POST['video_url'] . '.jpg', 120, 90, $thumb_position, $c);
                             //create display image
                             JTHelper::flvToThumbnail($path_file . $_POST['video_url'], $path_display . $_POST['video_url'] . '.jpg', 470, 320, $thumb_position, $c);
                             $_POST['video_thumb'] = $_POST['video_url'] . '.jpg';
                             $this->store($_POST, 1);
                             $counter++;
                         } else {
                             // not use ffmpeg
                         }
                     }
                 }
             }
             //if
         }
         closedir($dir);
     }
     //var_dump($counter); exit();
     return $counter;
 }
コード例 #4
0
 function uploadvideo()
 {
     $post = $_POST;
     //get category directory
     $categories_model = $this->getModel('categories');
     $category_directory = $categories_model->getCategoryDirectory($post['category_id']);
     $category_path = JPATH_SITE . $category_directory;
     //var_dump($category_path); exit();
     $c = jomtube_configs::get_instance();
     if ($c->uploader_type == "flashupload") {
         // ###########################################################
         // ###### USE FLASHUPLOADER PROGRESS
         // ###########################################################
         // === Instantiate the class
         $solmetraUploader = new SolmetraUploader('../administrator/components/com_jomtube/assets/lib/FlashUploader/', 'upload.php', 'administrator/components/com_jomtube/assets/lib/FlashUploader/config.php');
         // === Gather uploaded files
         // Flash Uploader populates PHP's own $_FILE global variable
         // with the information about uploaded files
         $solmetraUploader->gatherUploadedFiles();
         if (isset($_FILES) && sizeof($_FILES)) {
             //                echo '<h2>Uploaded files</h2>';
             //                echo '<pre class="info">';
             //                print_r($_FILES);
             //                echo '</pre>';
             $file_info = $_FILES['file'];
             //remove space
             $file_name = JTHelper::removeSpaceFileName($file_info['name']);
             $file_name = JTHelper::vietDecode($file_name);
             //check duplicate
             JTHelper::getNoDuplicateFileName($category_path, $file_name, 'flv');
             $tmp_name = $file_info['tmp_name'];
             if (!JFolder::exists($category_path)) {
                 JFolder::create($category_path, 775);
             }
             @copy($tmp_name, $category_path . '/' . $file_name);
             @unlink($tmp_name);
             $post['video_url'] = $file_name;
             $post['catdir'] = $category_path;
         }
     } else {
         if ($c->uploader_type == "normal") {
             // ###########################################################
             // ###### USE NORMAL UPLOAD
             // ###########################################################
             $file_info = $_FILES['file'];
             //print_r($file_info);
             //die();
             //remove space
             //$file_name = JTHelper::removeSpaceFileName($file_info['name']);
             //$file_name = JTHelper::vietDecode($file_name);
             $file_name = JTHelper::cGenRandomFilename(category_path, $file_info['name'], '');
             //echo $file_name;
             //$post['filename_random'] = $file_name;
             //check duplicate
             //JTHelper::getNoDuplicateFileName($category_path, $file_name, 'flv');
             $tmp_name = $file_info['tmp_name'];
             if (!JFolder::exists($category_path)) {
                 JFolder::create($category_path, 775);
             }
             if (move_uploaded_file($tmp_name, $category_path . '/' . $file_name)) {
                 $post['video_url'] = $file_name;
                 $post['catdir'] = $category_path;
             }
         }
     }
     // ###########################################################
     // ###### upload thumbnail if user dose not use ffmpeg
     // ###########################################################
     if (!$c->use_ffmpeg) {
         $thumb_file_tmp = $_FILES['thumbnail']['tmp_name'];
         $thumb_file = $_FILES['thumbnail']['name'];
         if (move_uploaded_file($thumb_file_tmp, $category_path . '/' . $thumb_file)) {
             $post['video_thumb'] = $thumb_file;
         }
     }
     //Store video info
     $model = $this->getModel('video');
     if ($returnid = $model->store($post, 0)) {
         $msg = JText::_('VIDEO SAVED');
         $link = JRoute::_('index.php?option=com_jomtube&view=video&id=' . $returnid);
         $cache =& JFactory::getCache('com_jomtube');
         $cache->clean();
     } else {
         $msg = '';
         $link = JRoute::_('index.php?view=videos');
     }
     $this->setRedirect($link, $msg);
 }
コード例 #5
0
 function getVideoInfo($videoFile, $c, $cmdOut = '')
 {
     $ffmpeg_path = $c->ffmpeg_path;
     $data = array();
     if (!is_file($videoFile) && empty($cmdOut)) {
         return $data;
     }
     if (!$cmdOut) {
         //$cmd	= $this->converter . ' -v 10 -i ' . $videoFile . ' 2>&1';
         // Some FFmpeg version only accept -v value from -2 to 2
         $cmd = "{$ffmpeg_path}" . ' -i ' . $videoFile . ' 2>&1';
         $cmdOut = shell_exec($cmd);
     }
     if (!$cmdOut) {
         return $data;
     }
     preg_match_all('/Duration: (.*)/', $cmdOut, $matches);
     if (count($matches) > 0 && isset($matches[1][0])) {
         $parts = explode(', ', trim($matches[1][0]));
         $data['bitrate'] = intval(ltrim($parts[2], 'bitrate: '));
         $data['duration']['hms'] = substr($parts[0], 0, 8);
         $data['duration']['exact'] = $parts[0];
         $data['duration']['sec'] = $videoFrame = JTHelper::cFormatDuration($data['duration']['hms'], 'seconds');
         $data['duration']['excess'] = intval(substr($parts[0], 9));
     } else {
         if ($this->debug) {
             echo '<pre>FFmpeg failed to read video\'s duration</pre>';
             echo '<pre>' . $cmd . '<pre>';
             echo '<pre>' . $cmdOut . '</pre>';
         }
         return false;
     }
     $file_size = filesize($videoFile);
     $duration_in_sec = $file_size * 8 / ($data['bitrate'] * 1000);
     //echo $duration_in_sec;
     $duration = JTHelper::sec2hms($duration_in_sec);
     //echo $duration;
     $data['duration']['hms'] = $duration;
     $data['duration']['exact'] = $duration;
     $data['duration']['sec'] = round($duration_in_sec);
     $data['duration']['excess'] = intval(substr($duration, 9));
     //echo '<pre>';print_r($data);print_r($cmdOut);die();
     preg_match('/Stream(.*): Video: (.*)/', $cmdOut, $matches);
     if (count($matches) > 0 && isset($matches[0]) && isset($matches[2])) {
         $data['video'] = array();
         preg_match('/([0-9]{1,5})x([0-9]{1,5})/', $matches[2], $dimensions_matches);
         $data['video']['width'] = floatval($dimensions_matches[1]);
         $data['video']['height'] = floatval($dimensions_matches[2]);
         preg_match('/([0-9\\.]+) (fps|tb)/', $matches[0], $fps_matches);
         if (isset($fps_matches[1])) {
             $data['video']['frame_rate'] = floatval($fps_matches[1]);
         }
         preg_match('/\\[PAR ([0-9\\:\\.]+) DAR ([0-9\\:\\.]+)\\]/', $matches[0], $ratio_matches);
         if (count($ratio_matches)) {
             $data['video']['pixel_aspect_ratio'] = $ratio_matches[1];
             $data['video']['display_aspect_ratio'] = $ratio_matches[2];
         }
         if (!empty($data['duration']) && !empty($data['video'])) {
             $data['video']['frame_count'] = ceil($data['duration']['sec'] * $data['video']['frame_rate']);
             $data['frames'] = array();
             $data['frames']['total'] = $data['video']['frame_count'];
             $data['frames']['excess'] = ceil($data['video']['frame_rate'] * ($data['duration']['excess'] / 10));
             $data['frames']['exact'] = $data['duration']['hms'] . '.' . $data['frames']['excess'];
         }
         $parts = explode(',', $matches[2]);
         $other_parts = array($dimensions_matches[0], $fps_matches[0]);
         $formats = array();
         foreach ($parts as $key => $part) {
             $part = trim($part);
             if (!in_array($part, $other_parts)) {
                 array_push($formats, $part);
             }
         }
         $data['video']['pixel_format'] = $formats[1];
         $data['video']['codec'] = $formats[0];
     }
     return $data;
 }
コード例 #6
0
 /**
  * Enter description here...
  *
  * @param unknown_type $data
  * @param unknown_type $type
  * $type = 0: batchupload, = 1: add remote video, =2: upload from local
  *  @return unknown
  */
 function store($data, $type = 0)
 {
     $row =& $this->getTable('jomtube_videos', '');
     $user =& JFactory::getUser();
     // bind it to the table
     if (!$row->bind($data)) {
         JError::raiseError(500, $this->_db->getErrorMsg());
         return false;
     }
     // Make sure the data is valid
     if (!$row->check()) {
         $this->setError($row->getError());
         return false;
     }
     if ($this->checkDuplicateRemoteVideo($row->remote_id) > 0) {
         return 1;
     }
     //var_dump($row); exit();
     if ($type == 0) {
         //batchupload
         // ###########################################################
         // ###### CONVERT VIDEO TO FLV OR MP4-H264
         // ###########################################################
         //get all settings
         $path_original = $data['catdir'] . '/' . $row->video_url;
         $c = jomtube_configs::get_instance();
         if ($c->use_ffmpeg) {
             $path_parts = pathinfo($row->video_url);
             if ($c->h264_convert2mp4) {
                 $path_new = $data['catdir'] . DS . $path_parts['filename'] . '.mp4';
                 JTHelper::movieToMp4H264_alduccino($path_original, $path_new, $c);
                 //update video_url
                 $row->video_url = $path_parts['filename'] . '.mp4';
             } else {
                 $path_new = $data['catdir'] . DS . $path_parts['filename'] . '.flv';
                 //echo $path_original;echo '<br>';
                 //echo $path_new;echo '<br>';
                 JTHelper::movieToFlv($path_original, $path_new, $c);
                 //update video_url
                 $row->video_url = $path_parts['filename'] . '.flv';
             }
             //delete original file
             if ($c->delete_orignial_file) {
                 @unlink($path_original);
             }
         }
         // ###########################################################
         // ###### CREATE THUMBNAIL FROM FLV OR MP4
         // ###########################################################
         $flv_path = $data['catdir'] . '/' . $row->video_url;
         $thumb_path = $data['catdir'] . '/_thumbs/' . $row->video_url . '.jpg';
         $display_path = $data['catdir'] . '/_display/' . $row->video_url . '.jpg';
         //get movie duration
         //$file_name = $data['filename_random'];
         //echo $file_name;echo '<pre>';echo $flv_path;
         //$path_temp = $data['catdir'] . '/' . $file_name;
         $videoInfo = JTHelper::getVideoInfo($flv_path, $c);
         //print_r($videoInfo);die();
         /*if ($c->use_php_ffmpeg) {//use php-ffmpeg
               $sec = JTHelper::getMovieDuration($flv_path);
               $duration = JTHelper::sec2hms($sec); //covert to 00:00:00 i.e. hrs:min:sec
           } else {//not use php-ffmpeg
               $sec = 6;
               $duration = '';
           }*/
         $row->duration = $videoInfo['duration']['hms'];
         $display_folder = $data['catdir'] . '/_display/';
         $thumbs_folder = $data['catdir'] . '/_thumbs/';
         if (!is_dir($display_folder)) {
             JFolder::create($display_folder, 775);
             //$oldumask=umask(0);
             // @mkdir ($display_path, 0755);
             //umask($oldumask);
         }
         if (!is_dir($thumbs_folder)) {
             JFolder::create($thumbs_folder, 775);
             //$oldumask=umask(0);
             // @mkdir ($display_path, 0755);
             //umask($oldumask);
         }
         //get the middle of the movie (time; 00:00:00 format) for thumbnail
         if ($c->use_ffmpeg) {
             //use ffmpeg
             $sec2 = $sec / 2;
             $sec2 = @round($sec2);
             $thumb_position = JTHelper::sec2hms($sec2);
             JTHelper::flvToThumbnail($flv_path, $thumb_path, 120, 90, $thumb_position, $c);
             JTHelper::flvToThumbnail($flv_path, $display_path, $c->video_player_width, $c->video_player_height, $thumb_position, $c);
             $row->video_thumb = $row->video_url . '.jpg';
         } else {
             // not use ffmpeg
             $orignial_thumb = $data['catdir'] . '/' . $row->video_thumb;
             JTHelper::SizeImage(120, 90, $orignial_thumb, $thumb_path);
             JTHelper::SizeImage($c->video_player_width, $c->video_player_height, $orignial_thumb, $display_path);
             $row->video_thumb = $row->video_url . '.jpg';
             if (file_exists($orignial_thumb)) {
                 unlink($orignial_thumb);
             }
         }
     }
     $row->user_id = $user->id;
     // Store it in the db
     //var_dump($row); exit();
     if (!$row->store()) {
         JError::raiseError(500, $this->_db->getErrorMsg());
         return false;
     }
     return $row->id;
 }
コード例 #7
0
			<?php 
echo JHTML::_('form.token');
?>
    		<input type="hidden" name="option" value="com_jomtube" />
    		<input type="hidden" id="task" name="task" value="applylink" />
			</form>
		</div>

	    <!--############## CUSTOM DISCLAIMER MODULE POSITION ###########-->
	    <div>
	          <?php 
$jomtube_addvideo_disclaimer_modules =& JModuleHelper::getModules('addvideo_disclaimer');
foreach ($jomtube_addvideo_disclaimer_modules as $addvideo_disclaimer_module) {
    echo "<div id=\"disclaimer-module\">";
    echo JModuleHelper::renderModule($addvideo_disclaimer_module);
    echo "</div>";
}
?>
	    </div>
	    <!--############## CUSTOM DISCLAIMER MODULE POSITION END ###########-->

	</div>

<!--############ RIGHT COLUMN ###########-->
    <?php 
JTHelper::loadCustomVerticalModule('jomtube_addvideo_right', $this->c->addvideo_column_right_width, 'right');
?>

</div>
コード例 #8
0
	    <div>
	          <?php 
$jomtube_upload_disclaimer_modules =& JModuleHelper::getModules('upload_disclaimer');
foreach ($jomtube_upload_disclaimer_modules as $upload_disclaimer_module) {
    echo "<div id=\"disclaimer-module\">";
    echo JModuleHelper::renderModule($upload_disclaimer_module);
    echo "</div>";
}
?>
	    </div>
	    <!--############## CUSTOM DISCLAIMER MODULE POSITION END ###########-->

	</div>
<!--############ RIGHT COLUMN ###########-->
    <?php 
JTHelper::loadCustomVerticalModule('jomtube_upload_right', $this->c->upload_column_right_width, 'right');
?>

    <?php 
echo JHTML::_('form.token');
?>
    <input type="hidden" name="date_updated" value="<?php 
echo date("Y-m-d");
?>
"/>
    <input type="hidden" name="date_added" value="<?php 
echo date("Y-m-d");
?>
"/>
    <input type="hidden" name="video_type" value="local"/>
    <input type="hidden" name="option" value="com_jomtube" />