/** * CONVERT VIDEOS TO FLV FORMAT * @param database A database connector object */ function inject($path_flv) { defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR); defined('CONVERTPATH') ? null : define('CONVERTPATH', dirname(__FILE__)); if(substr(PHP_OS, 0, 3) == "WIN") { defined('JPATH_SITE') ? null : define('JPATH_SITE', str_replace("\components\com_hwdvideoshare\converters", "", CONVERTPATH) ); } else { defined('JPATH_SITE') ? null : define('JPATH_SITE', str_replace("/components/com_hwdvideoshare/converters", "", CONVERTPATH) ); } // get hwdVideoShare general settings include_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'config.hwdvideoshare.php'); $c = hwd_vs_Config::get_instance(); // get hwdVideoShare server settings include_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'serverconfig.hwdvideoshare.php'); $s = hwd_vs_SConfig::get_instance(); $result = array(); if(substr(PHP_OS, 0, 3) != "WIN") { $cmd_input = $s->flvtool2path.' -U '.$path_flv; } else { $cmd_input = $s->flvtool2path.' -U "'.$path_flv.'"'; } @exec("$sharedlib $cmd_input 2>&1", $cmd_output); $result[0] = 0; // result of flvtool2 execution $result[1] = null; // ? $result[2] = $cmd_input; // input of flvtool2 execution $result[3] = $cmd_output; // output of flvtool2 execution $result[4] = ''; // holder for output text if(empty($cmd_output)) { $result[0] = 1; } $result = hwd_vs_InjectMetaData::generateOutput($result); return $result; }
/** * show general settings */ function checkWget02Execution() { global $mosConfig_live_site; $s = hwd_vs_SConfig::get_instance(); $filename = JPATH_SITE."/cache/check_wget2.file"; if (file_exists($filename)) { unlink($filename); } if(substr(PHP_OS, 0, 3) != "WIN") { @exec("env -i $s->wgetpath -O - -q ".JURI::root()."components/com_hwdvideoshare/converters/ac/check_wget2.php >/dev/null &"); } else { @exec("$s->wgetpath \"".JURI::root()."components/com_hwdvideoshare/converters/ac/check_wget.php\" NUL"); } usleep(800000); if (file_exists($filename)) { unlink($filename); return true; } else { return false; } }
/** * show server settings */ function showlayoutsettings(&$gtree) { global $smartyvs; $s = hwd_vs_SConfig::get_instance(); $c = hwd_vs_Config::get_instance(); hwdvsInitialise::language('settings'); require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'views'.DS.'layoutsettings.php'); hwdvids_HTML_settings::showlayoutsettings($gtree); return; }
/** * CONVERT VIDEOS TO FLV FORMAT * @param database A database connector object */ function draw($path_base, $path_new, $filename_noext, $filename_ext, $thumb_position, $full_position = "0:00:00") { defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR); defined('CONVERTPATH') ? null : define('CONVERTPATH', dirname(__FILE__)); $cmd_sinput = ''; $cmd_soutput = ''; $cmd_linput = ''; $cmd_loutput = ''; $cmd_dinput = ''; $cmd_doutput = ''; if(substr(PHP_OS, 0, 3) == "WIN") { defined('JPATH_SITE') ? null : define('JPATH_SITE', str_replace("\components\com_hwdvideoshare\converters", "", CONVERTPATH) ); } else { defined('JPATH_SITE') ? null : define('JPATH_SITE', str_replace("/components/com_hwdvideoshare/converters", "", CONVERTPATH) ); } // get joomla configuration include_once(JPATH_SITE.DS.'configuration.php'); // get hwdVideoShare general settings include_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'config.hwdvideoshare.php'); $c = hwd_vs_Config::get_instance(); // get hwdVideoShare server settings include_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'serverconfig.hwdvideoshare.php'); $s = hwd_vs_SConfig::get_instance(); // shared library $sharedlib = null; if ($c->sharedlibrarypath !== "") { $sharedlib = "export LD_LIBRARY_PATH=$c->sharedlibrarypath;"; } $path_sthumb = $path_base.DS.'thumbs'.DS.'temp_'.$filename_noext.'.jpg'; $path_lthumb = $path_base.DS.'thumbs'.DS.'temp_l_'.$filename_noext.'.jpg'; $path_dthumb = $path_base.DS.'thumbs'.DS.'temp_'.$filename_noext.'.gif'; $path_sthumb_orig = $path_base.DS.'thumbs'.DS.$filename_noext.'.jpg'; $path_lthumb_orig = $path_base.DS.'thumbs'.DS.'l_'.$filename_noext.'.jpg'; $path_dthumb_orig = $path_base.DS.'thumbs'.DS.$filename_noext.'.gif'; $path_seqthumb_orig = $path_base.DS.'thumbs'.DS.$filename_noext; $nthumbwidth = intval($c->con_thumb_n); $nwtype = gettype($nthumbwidth/2); if($nwtype !== "integer"){ $nthumbwidth = intval($nthumbwidth+1); } $nthumbheight = intval($c->con_thumb_n*$c->tar_fb); $nhtype = gettype($nthumbheight/2); if($nhtype !== "integer"){ $nthumbheight = intval($nthumbheight+1); } $lthumbwidth = intval($c->con_thumb_l); $lwtype = gettype($lthumbwidth/2); if($lwtype !== "integer"){ $lthumbwidth = intval($lthumbwidth+1); } $lthumbheight = intval($c->con_thumb_l*$c->var_fb); $lttype = gettype($lthumbheight/2); if($lttype !== "integer"){ $lthumbheight = intval($lthumbheight+1); } if(substr(PHP_OS, 0, 3) == "WIN") { $path_cmd_new = '"'.$path_new.'"'; $path_cmd_sthumb = '"'.$path_sthumb.'"'; $path_cmd_lthumb = '"'.$path_lthumb.'"'; $path_cmd_dthumb = '"'.$path_dthumb.'"'; $path_cmd_seqthumb = '"'.$path_seqthumb_orig.'"'; } else { $path_cmd_new = $path_new; $path_cmd_sthumb = $path_sthumb; $path_cmd_lthumb = $path_lthumb; $path_cmd_dthumb = $path_dthumb; $path_cmd_seqthumb = $path_seqthumb_orig; } //Static clearstatcache(); if ( @!file_exists($path_sthumb) || (@filesize($path_sthumb) == 0) ) { $cmd_sinput = "$s->ffmpegpath -y -i $path_cmd_new -ss $thumb_position -t 00:00:01 -s ".$nthumbwidth."x".$nthumbheight." -r 1 -f mjpeg $path_cmd_sthumb"; @exec("$sharedlib $cmd_sinput 2>&1", $cmd_soutput); } clearstatcache(); if ( @!file_exists($path_sthumb) || (@filesize($path_sthumb) == 0) ) { $cmd_sinput = "$s->ffmpegpath -y -i $path_cmd_new -ss $thumb_position -t 00:00:01 -s ".$nthumbwidth."x".$nthumbheight." -r 1 -f image2 $path_cmd_sthumb"; @exec("$sharedlib $cmd_sinput 2>&1", $cmd_soutput); } clearstatcache(); if ( !file_exists($path_sthumb) || (filesize($path_sthumb) == 0) ) { $cmd_sinput = "$s->ffmpegpath -ss $thumb_position -t 00:00:01 -i $path_cmd_new -an -r 1 -y -s ".$nthumbwidth."x".$nthumbheight." ".$path_cmd_sthumb.""; @exec("$sharedlib $cmd_sinput 2>&1", $cmd_soutput); } clearstatcache(); if ( !file_exists($path_sthumb) || (filesize($path_sthumb) == 0) ) { $thumb_position = "0:00:01"; $cmd_sinput = "$s->ffmpegpath -y -i $path_cmd_new -ss $thumb_position -t 00:00:01 -s ".$nthumbwidth."x".$nthumbheight." -r 1 -f mjpeg $path_cmd_sthumb"; @exec("$sharedlib $cmd_sinput 2>&1", $cmd_soutput); } clearstatcache(); if ( @!file_exists($path_sthumb) || (@filesize($path_sthumb) == 0) ) { $thumb_position = "0:00:01"; $cmd_sinput = "$s->ffmpegpath -y -i $path_cmd_new -ss $thumb_position -t 00:00:01 -s ".$nthumbwidth."x".$nthumbheight." -r 1 -f image2 $path_cmd_sthumb"; @exec("$sharedlib $cmd_sinput 2>&1", $cmd_soutput); } clearstatcache(); if ( @!file_exists($path_sthumb) || (@filesize($path_sthumb) == 0) ) { $thumb_position = "0:00:01"; $cmd_sinput = "$s->ffmpegpath -y -ss $thumb_position -t 00:00:01 -i $path_cmd_new -an -r 1 -y -s ".$nthumbwidth."x".$nthumbheight." ".$path_cmd_sthumb.""; @exec("$sharedlib $cmd_sinput 2>&1", $cmd_soutput); } //Large clearstatcache(); if ( @!file_exists($path_lthumb) || (@filesize($path_lthumb) == 0) ) { $cmd_linput = "$s->ffmpegpath -y -i $path_cmd_new -ss $thumb_position -t 00:00:01 -s ".$lthumbwidth."x".$lthumbheight." -r 1 -f mjpeg $path_cmd_lthumb"; @exec("$sharedlib $cmd_linput 2>&1", $cmd_soutput); } clearstatcache(); if ( @!file_exists($path_lthumb) || (@filesize($path_lthumb) == 0) ) { $cmd_linput = "$s->ffmpegpath -y -i $path_cmd_new -ss $thumb_position -t 00:00:01 -s ".$lthumbwidth."x".$lthumbheight." -r 1 -f image2 $path_cmd_lthumb"; @exec("$sharedlib $cmd_linput 2>&1", $cmd_soutput); } clearstatcache(); if ( !file_exists($path_lthumb) || (filesize($path_lthumb) == 0) ) { $cmd_linput = "$s->ffmpegpath -ss $thumb_position -t 00:00:01 -i $path_cmd_new -an -r 1 -y -s ".$lthumbwidth."x".$lthumbheight." ".$path_cmd_lthumb.""; @exec("$sharedlib $cmd_linput 2>&1", $cmd_soutput); } clearstatcache(); if ( !file_exists($path_lthumb) || (filesize($path_lthumb) == 0) ) { $thumb_position = "0:00:01"; $cmd_linput = "$s->ffmpegpath -y -i $path_cmd_new -ss $thumb_position -t 00:00:01 -s ".$lthumbwidth."x".$lthumbheight." -r 1 -f mjpeg $path_cmd_lthumb"; @exec("$sharedlib $cmd_linput 2>&1", $cmd_soutput); } clearstatcache(); if ( @!file_exists($path_lthumb) || (@filesize($path_lthumb) == 0) ) { $thumb_position = "0:00:01"; $cmd_linput = "$s->ffmpegpath -y -i $path_cmd_new -ss $thumb_position -t 00:00:01 -s ".$lthumbwidth."x".$lthumbheight." -r 1 -f image2 $path_cmd_lthumb"; @exec("$sharedlib $cmd_linput 2>&1", $cmd_soutput); } clearstatcache(); if ( @!file_exists($path_lthumb) || (@filesize($path_lthumb) == 0) ) { $thumb_position = "0:00:01"; $cmd_linput = "$s->ffmpegpath -y -ss $thumb_position -t 00:00:01 -i $path_cmd_new -an -r 1 -y -s ".$lthumbwidth."x".$lthumbheight." ".$path_cmd_lthumb.""; @exec("$sharedlib $cmd_linput 2>&1", $cmd_soutput); } //Dynamic if ( @!file_exists($path_dthumb) || (@filesize($path_dthumb) == 0) ) { if (function_exists('imagecreatefromjpeg')) { $cmd_dinput = "$s->ffmpegpath -i $path_cmd_new -an -r 0.2 -t 45 -y -s ".$nthumbwidth."x".$nthumbheight." ".$path_cmd_seqthumb."_%d.jpg"; @exec("$sharedlib $cmd_dinput 2>&1", $cmd_doutput); include_once JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'libraries'.DS.'GIFEncoder.class.php'; $frames = null; $time = null; for($i=1;$i<9;$i++){ if (file_exists($path_seqthumb_orig.'_'.$i.'.jpg')) { $imgname = $path_seqthumb_orig.'_'.$i.'.jpg'; $im = @imagecreatefromjpeg($imgname); /* Attempt to open */ imagegif($im, $path_seqthumb_orig.'_'.$i.'.gif'); $frames[] = $path_seqthumb_orig.'_'.$i.'.gif'; $time[] = 100; } } if (is_array($frames)) { $gif = new GIFEncoder ( $frames, // frames array $time, // elapsed time array 0, // loops (0 = infinite) 2, // disposal 0, 0, 0, // rgb of transparency "url" // source type ); $fh = fopen($path_dthumb, 'w') or die("can't open file"); fwrite($fh, $gif->GetAnimation()); fclose($fh); @imagedestroy($im); } for($i=1;$i<9;$i++){ @unlink($path_seqthumb_orig.'_'.$i.'.gif'); @unlink($path_seqthumb_orig.'_'.$i.'.jpg'); } } else { $cmd_dinput = "Could not use image manupulation functions. Check the GD image library has been installed"; $cmd_doutput = ""; } } $result = array(); $result[0] = 0; $result[1] = 0; $result[2] = $cmd_sinput; $result[3] = $cmd_soutput; $result[4] = $cmd_dinput; $result[5] = $cmd_doutput; $result[6] = 0; $result[7] = $cmd_linput; $result[8] = $cmd_loutput; if(file_exists($path_sthumb) && (filesize($path_sthumb) > 0)) { @unlink($path_sthumb_orig); if (!@rename($path_sthumb, $path_sthumb_orig)) { @copy($path_sthumb, $path_sthumb_orig); } if(file_exists($path_sthumb_orig) && (filesize($path_sthumb_orig) > 0)) { $result[0] = 1; @unlink($path_sthumb); } } if(file_exists($path_dthumb) && (filesize($path_dthumb) > 0)) { @unlink($path_dthumb_orig); if (!@rename($path_dthumb, $path_dthumb_orig)) { @copy($path_dthumb, $path_dthumb_orig); } if(file_exists($path_dthumb_orig) && (filesize($path_dthumb_orig) > 0)) { $result[1] = 1; @unlink($path_dthumb); } } if(file_exists($path_lthumb) && (filesize($path_lthumb) > 0)) { @unlink($path_lthumb_orig); if (!@rename($path_lthumb, $path_lthumb_orig)) { @copy($path_lthumb, $path_lthumb_orig); } if(file_exists($path_lthumb_orig) && (filesize($path_lthumb_orig) > 0)) { $result[6] = 1; @unlink($path_lthumb); } } $result = hwd_vs_GenerateThumbnail::generateOutput($result); return $result; }
/** * CONVERT VIDEOS TO FLV FORMAT * @param database A database connector object */ function move($path_mp4) { defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR); defined('CONVERTPATH') ? null : define('CONVERTPATH', dirname(__FILE__)); if(substr(PHP_OS, 0, 3) == "WIN") { defined('JPATH_SITE') ? null : define('JPATH_SITE', str_replace("\components\com_hwdvideoshare\converters", "", CONVERTPATH) ); } else { defined('JPATH_SITE') ? null : define('JPATH_SITE', str_replace("/components/com_hwdvideoshare/converters", "", CONVERTPATH) ); } // get hwdVideoShare server settings include_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'serverconfig.hwdvideoshare.php'); $s = hwd_vs_SConfig::get_instance(); $path_mp4_temp = $path_mp4.".temp"; if(substr(PHP_OS, 0, 3) == "WIN") { $path_cmd_mp4 = '"'.$path_mp4.'"'; $path_cmd_mp4_temp = '"'.$path_mp4_temp.'"'; } else { $path_cmd_mp4 = $path_mp4; $path_cmd_mp4_temp = $path_mp4_temp; } $cmd_input = "$s->qtfaststart $path_cmd_mp4 $path_cmd_mp4_temp"; @exec("$sharedlib $cmd_input 2>&1", $cmd_output); $result = array(); $result[0] = 0; $result[1] = $cmd_input; $result[2] = $cmd_output; if(file_exists($path_mp4_temp) && (filesize($path_mp4_temp) > 0)) { @unlink($path_mp4); @rename($path_mp4_temp, $path_mp4); if(file_exists($path_mp4) && (filesize($path_mp4) > 0)) { @unlink($path_mp4_temp); } $check_string = implode(",", $cmd_output); if (strpos($check_string, "writing moov atom") === false) { $result[0] = 0; } else { $result[0] = 1; } } $result = hwd_vs_MoovAtom::generateOutput($result); return $result; }
/** * CONVERT VIDEOS TO FLV FORMAT * @param database A database connector object */ function generateCalculatedAspect($path_original) { $c = hwd_vs_Config::get_instance(); $s = hwd_vs_SConfig::get_instance(); $cmd_input_info = "$s->ffmpegpath -i $path_original"; @exec("$sharedlib $cmd_input_info 2>&1", $cmd_output_info); $info_data = implode($cmd_output_info); preg_match('/DAR ([^\]]+)/', $info_data, $match); if (isset($match[1])) { $dar_elements = explode(":", $match[1]); $calculatedAspect = intval($dar_elements[0])/intval($dar_elements[1]); return $calculatedAspect; } else { return false; } }
header('Content-type: text/html; charset=utf-8'); include_once(JPATH_SITE.DS.'components'.DS.'com_hwdvideoshare'.DS.'converters'.DS.'__ConversionTools.php'); include_once(JPATH_SITE.DS.'components'.DS.'com_hwdvideoshare'.DS.'converters'.DS.'__ConvertVideo.php'); include_once(JPATH_SITE.DS.'components'.DS.'com_hwdvideoshare'.DS.'converters'.DS.'__ExtractDuration.php'); include_once(JPATH_SITE.DS.'components'.DS.'com_hwdvideoshare'.DS.'converters'.DS.'__GenerateThumbnail.php'); include_once(JPATH_SITE.DS.'components'.DS.'com_hwdvideoshare'.DS.'converters'.DS.'__InjectMetaData.php'); include_once(JPATH_SITE.DS.'components'.DS.'com_hwdvideoshare'.DS.'converters'.DS.'__MoveMoovAtom.php'); include_once(JPATH_SITE.DS.'components'.DS.'com_hwdvideoshare'.DS.'converters'.DS.'__UpdateDatabase.php'); include_once(JPATH_SITE.DS.'configuration.php'); include_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'config.hwdvideoshare.php'); include_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'serverconfig.hwdvideoshare.php'); $c = hwd_vs_Config::get_instance(); $s = hwd_vs_SConfig::get_instance(); $row = new JConfig; $batch = rand(100, 999); $path_base = JPATH_SITE.DS.'hwdvideos'; $output = ''; $output.= "<html><head><link type=\"text/css\" rel=\"stylesheet\" href=\"../../../administrator/components/com_hwdvideoshare/assets/css/converter.css\" /></head><body>"; if (is_callable('exec') && function_exists('exec')) { // continue } else { $output.= "You must enable the exec() function before you can convert videos.<br /><br />"; $output.= "<img src=\"../../../components/com_hwdvideoshare/assets/images/icons/delete.png\" border=\"0\" alt=\"\" title=\"\" style=\"padding:1px 5px;vertical-align:bottom;\" />The exec() function <font color=\"red\"><b>is not available</b></font><br /><br />"; $output.= "</body></html>"; echo $output; exit;
/** * Outputs frontpage HTML * * @return Nothing */ function uploadConfirmPhp() { global $database, $my, $acl, $mosConfig_absolute_path, $mosConfig_mailfrom, $mosConfig_fromname, $mosConfig_live_site, $Itemid, $mosConfig_sitename; $c = hwd_vs_Config::get_instance(); $db = & JFactory::getDBO(); $my = & JFactory::getUser(); $acl= & JFactory::getACL(); // get server configuration data require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'serverconfig.hwdvideoshare.php'); $s = hwd_vs_SConfig::get_instance(); $file_name0= (isset($_FILES['upfile_0']['tmp_name']) ? $_FILES['upfile_0']['tmp_name'] : ""); $file_name = (isset($_FILES['upfile_0']['name']) ? $_FILES['upfile_0']['name'] : ""); $file_size = (isset($_FILES['upfile_0']['size']) ? $_FILES['upfile_0']['size'] : ""); if (!isset($_FILES['upfile_0']['error'])) { hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_PHPUPLD_ERR00, "exclamation.png", 0); return; } else if ($_FILES['upfile_0']['error'] == 8) { hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_PHPUPLD_ERR08, "exclamation.png", 0); return; } else if ($_FILES['upfile_0']['error'] == 7) { hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_PHPUPLD_ERR07, "exclamation.png", 0); return; } else if ($_FILES['upfile_0']['error'] == 6) { hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_PHPUPLD_ERR06, "exclamation.png", 0); return; } else if ($_FILES['upfile_0']['error'] == 5) { hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_PHPUPLD_ERR05, "exclamation.png", 0); return; } else if ($_FILES['upfile_0']['error'] == 4) { hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_PHPUPLD_ERR04, "exclamation.png", 0); return; } else if ($_FILES['upfile_0']['error'] == 3) { hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_PHPUPLD_ERR03, "exclamation.png", 0); return; } else if ($_FILES['upfile_0']['error'] == 2) { hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_PHPUPLD_ERR02, "exclamation.png", 0); return; } else if ($_FILES['upfile_0']['error'] == 1) { hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_PHPUPLD_ERR01, "exclamation.png", 0); return; } else if ($_FILES['upfile_0']['error'] == 0) { $title = hwd_vs_tools::generatePostTitle(); $description = hwd_vs_tools::generatePostDescription(); $tags = hwd_vs_tools::generatePostTags(); $category_id = JRequest::getInt( 'category_id', 0, 'post' ); $public_private = JRequest::getWord( 'public_private' ); $allow_comments = JRequest::getInt( 'allow_comments', 0, 'post' ); $allow_embedding = JRequest::getInt( 'allow_embedding', 0, 'post' ); $allow_ratings = JRequest::getInt( 'allow_ratings', 0, 'post' ); $checkform = hwd_vs_tools::checkFormComplete($title, $description, $category_id, $tags, $public_private, $allow_comments, $allow_embedding, $allow_ratings); if (!$checkform) { return; } $row = new hwdvids_video($db); if (!empty($file_name)) { // generate random filename $file_video_id = hwd_vs_tools::generateNewVideoid(); // get extension and create new random filename $file_ext = substr($file_name, strrpos($file_name, '.') + 1); $file_ext = strtolower($file_ext); $file_video_name = $file_video_id.".".$file_ext; } if (empty($file_video_name)) { hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ERROR_UPLDERR01, "exclamation.png", 0); return; } $sizelimit = $c->maxupld*1024*1024; //size limit in mb if ($file_size > $sizelimit) { hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ERROR_UPLDERR02." ".$c->maxupld."MB.", "exclamation.png", 0); return; } $filename = split("\.", $file_video_name); if (eregi("[^0-9a-zA-Z_]", $filename[0])) { hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ERROR_UPLDERR03, "exclamation.png", 0); return; } if ($c->requiredins == 1) { $_POST['video_id'] = $file_video_name; $oformats = explode(",", $c->oformats); // check file extensions if (($c->ft_mpg == "on" && $file_ext == "mpg") || ($c->ft_mpeg == "on" && $file_ext == "mpeg") || ($c->ft_avi == "on" && $file_ext == "avi") || ($c->ft_divx == "on" && $file_ext == "divx") || ($c->ft_mp4 == "on" && $file_ext == "mp4") || ($c->ft_flv == "on" && $file_ext == "flv") || ($c->ft_wmv == "on" && $file_ext == "wmv") || ($c->ft_rm == "on" && $file_ext == "rm") || ($c->ft_mov == "on" && $file_ext == "mov") || ($c->ft_moov == "on" && $file_ext == "moov") || ($c->ft_asf == "on" && $file_ext == "asf") || ($c->ft_swf == "on" && $file_ext == "swf") || ($c->ft_vob == "on" && $file_ext == "vob")) { // format matches a main allowed format } else if (in_array($file_ext, $oformats )) { // format matches an allowed extra format } else { hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ERROR_UPLDERR04, "exclamation.png", 0); return; } // move to uploaded file directory $base_Dir = JPATH_SITE.DS.'hwdvideos'.DS.'uploads'.DS.'originals'.DS; if (file_exists($base_Dir.$file_video_name)) { hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ERROR_UPLDERR05, "exclamation.png", 0); return; } if (!move_uploaded_file ($_FILES['upfile_0']['tmp_name'],$base_Dir.$file_video_name)) { hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ERROR_UPLDERR06, "exclamation.png", 0); return; } // check if we are reprocessing if ($c->reconvertflv == 0) { if ($file_ext == "flv") { $_POST['approved'] = "queuedforthumbnail"; } else if ($file_ext == "swf") { $_POST['approved'] = "queuedforswf"; } else if ($file_ext == "mp4") { $_POST['approved'] = "queuedformp4"; } else { $_POST['approved'] = "queuedforconversion"; } } else { if ($file_ext == "swf") { $_POST['approved'] = "queuedforswf"; } else if ($file_ext == "mp4") { $_POST['approved'] = "queuedformp4"; } else { $_POST['approved'] = "queuedforconversion"; } } } else if ($c->requiredins == 0) { $_POST['video_id'] = $file_video_id; if ($file_ext !== "flv" && $file_ext !== "mp4" && $file_ext !== "swf") { hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ERROR_UPLDERR04, "exclamation.png", 0); return; } $base_Dir = JPATH_SITE.DS.'hwdvideos'.DS.'uploads'.DS; if (file_exists($base_Dir.$file_video_name)) { hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ERROR_UPLDERR05, "exclamation.png", 0); return; } if (!move_uploaded_file ($_FILES['upfile_0']['tmp_name'],$base_Dir.$file_video_id.".".strtolower($file_ext)) || !JPath::setPermissions($base_Dir.$file_video_name)) { hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ERROR_UPLDERR06, "exclamation.png", 0); return; } if ($c->aav == 1) { $_POST['approved'] = "yes"; } else { $_POST['approved'] = "pending"; } } //check if already exists $db->SetQuery( 'SELECT count(*)' . ' FROM #__hwdvidsvideos' . ' WHERE video_id = "'.$file_video_id.'"' ); $duplicatecount = $db->loadResult(); if ($duplicatecount > 0) { hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ALERT_DUPLICATE, "exclamation.png", 0); return; } $ext = strrchr($file_name, '.'); if ($ext == ".swf") { $_POST['video_type'] = "swf"; } else if ($file_ext == "mp4") { $_POST['video_type'] = "mp4"; } else { $_POST['video_type'] = "local"; } $password = Jrequest::getVar( 'hwdvspassword', '' ); if (!empty($password)) { $_POST['password'] = $password; } $_POST['title'] = $title; $_POST['description'] = $description; $_POST['category_id'] = $category_id; $_POST['tags'] = $tags; $_POST['public_private'] = $public_private; $_POST['allow_comments'] = $allow_comments; $_POST['allow_embedding'] = $allow_embedding; $_POST['allow_ratings'] = $allow_ratings; $_POST['date_uploaded'] = date('Y-m-d H:i:s'); $_POST['user_id'] = $my->id; $_POST['published'] = "1"; if(empty($_POST['video_id'])) { hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ERROR_UPLDERR01, "exclamation.png", 0); return; } // bind it to the table if (!$row->bind($_POST)) { echo "<script type=\"text/javascript\">alert('".$row->getError()."');window.history.go(-1);</script>\n"; exit(); } // store it in the db if (!$row->store()) { echo "<script type=\"text/javascript\">alert('".$row->getError()."');window.history.go(-1);</script>\n"; exit(); } } include_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'helpers'.DS.'events.php'); $params->title = $title; $params->id = $row->id; $params->category_id = $row->category_id; $params->type = $row->video_type; $params->user_id = $row->user_id; hwdvsEvent::onAfterVideoUpload($params); hwd_vs_html::uploadConfirm($title, $row); }
/** * CONVERT VIDEOS TO FLV FORMAT * @param database A database connector object */ function extract($path_new, $output) { defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR); defined('CONVERTPATH') ? null : define('CONVERTPATH', dirname(__FILE__)); if(substr(PHP_OS, 0, 3) == "WIN") { defined('JPATH_SITE') ? null : define('JPATH_SITE', str_replace("\components\com_hwdvideoshare\converters", "", CONVERTPATH) ); } else { defined('JPATH_SITE') ? null : define('JPATH_SITE', str_replace("/components/com_hwdvideoshare/converters", "", CONVERTPATH) ); } // get hwdVideoShare general settings include_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'config.hwdvideoshare.php'); $c = hwd_vs_Config::get_instance(); // get hwdVideoShare server settings include_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'serverconfig.hwdvideoshare.php'); $s = hwd_vs_SConfig::get_instance(); $result = array(); $full_sec = ''; $half_sec = ''; $extension = "ffmpeg"; $extension_soname = $extension . "." . PHP_SHLIB_SUFFIX; $extension_fullname = PHP_EXTENSION_DIR . "/" . $extension_soname; // Try to load extension // If extension is not loaded, don't try! Instead, grep for duration from shell output. if(extension_loaded($extension)) { $video_info = @new ffmpeg_movie($path_new); //duration of new flv file. if ($video_info) { $full_sec = $video_info->getDuration(); // Gets the duration in secs. } } if(empty($full_sec) && $c->encoder == "MENCODER" && !empty($output)) { if (preg_match('/Video stream:.*bytes..(.*?).sec/', $output, $regs)) { $full_sec = $regs[1]; } } if(empty($full_sec)) { $cmd_input_ffmpeg = "$s->ffmpegpath -i $path_new"; @exec("$sharedlib $cmd_input_ffmpeg 2>&1", $cmd_output_ffmpeg); $cmd_output_ffmpeg = implode($cmd_output_ffmpeg); if (@preg_match('/Duration:.(.*?),.start/', $cmd_output_ffmpeg, $regs)) { $full_sec = hwd_vs_ConverterTools::hms2sec($regs[1]); } } if ($full_sec == "" || !is_numeric($full_sec)) { $full_sec = 2; } //get the middle of the movie (time; 00:00:00 format) for thumbnail $half_sec = $full_sec / 2; $half_sec = @round($half_sec); $result = array(); $result[0] = hwd_vs_ConverterTools::sec2hms($full_sec); // result of full duration $result[1] = hwd_vs_ConverterTools::sec2hms($half_sec); // result of mid-point duration $result[2] = 0; // status of ffmpeg-php extension $result[3] = ''; // holder for output text if(extension_loaded($extension)) { $result[2] = 1; } $result = hwd_vs_ExtractDuration::generateOutput($result); return $result; }
function onAfterVideoUpload($params) { global $mosConfig_mailfrom, $mosConfig_fromname, $mosConfig_live_site, $Itemid, $mosConfig_sitename, $mainframe; $c = hwd_vs_Config::get_instance(); $my = & JFactory::getUser(); // send upload to converter if required if ($c->requiredins == 1 && ($params->type == "local" || $params->type == "mp4" || $params->type == "swf")) { $s = hwd_vs_SConfig::get_instance(); if ($c->autoconvert == "direct") { if(substr(PHP_OS, 0, 3) != "WIN") { @exec("env -i $s->phppath ".JPATH_SITE.DS."components".DS."com_hwdvideoshare".DS."converters".DS."converter.php &>/dev/null &"); } else { pclose(popen("start \"bla\" \"" . $s->phppath . "\" " . escapeshellarg("\"".JPATH_SITE.DS."components".DS."com_hwdvideoshare".DS."converters".DS."converter.php\""), "r")); //@exec("$s->phppath \"".JPATH_SITE.DS."components".DS."com_hwdvideoshare".DS."converters".DS."converter.php\" >nul"); } } else if ($c->autoconvert == "wget1") { if(substr(PHP_OS, 0, 3) != "WIN") { @exec("env -i $s->wgetpath -O - -q ".JURI::root()."components/com_hwdvideoshare/converters/converter.php &>/dev/null &"); } else { @exec("$s->wgetpath \"".JURI::root()."components/com_hwdvideoshare/converters/converter.php\" NUL"); } } else if ($c->autoconvert == "wget2") { if(substr(PHP_OS, 0, 3) != "WIN") { @exec("env -i $s->wgetpath -O - -q ".JURI::root()."components/com_hwdvideoshare/converters/converter.php >/dev/null &"); } else { @exec("$s->wgetpath \"".JURI::root()."components/com_hwdvideoshare/converters/converter.php\" NUL"); } } } // mail admin notification if ($c->mailvideonotification == 1) { $jconfig = new jconfig(); $mailbody = ""._HWDVIDS_MAIL_BODY0.$jconfig->sitename.".\n"; $mailbody .= ""._HWDVIDS_MAIL_BODY1."\"".$params->title."\".\n"; $mailbody .= "".JURI::root()."index.php?option=com_hwdvideoshare&Itemid=".$Itemid."&task=viewvideo&video_id=".$params->id."\n\n"; $mailbody .= ""._HWDVIDS_MAIL_BODY2."\n"; $mailbody .= JURI::root()."administrator"; JUtility::sendMail( $jconfig->mailfrom, $jconfig->fromname, $c->mailnotifyaddress, _HWDVIDS_MAIL_SUBJECT1.$jconfig->sitename.' ', $mailbody ); } if ($params->type == "local" || $params->type == "mp4" || $params->type == "swf") { if ($c->aav == 1) { hwdvsEvent::onAfterVideoApproval($params); } } else { if ($c->aa3v == 1) { hwdvsEvent::onAfterVideoApproval($params); } } }