10 foreach($aOptions
as $sKey => $sValue)
11 $sTemplate = str_replace(
"#" . $sKey .
"#", $sValue, $sTemplate);
27 $sTempFileName =
$sFilesPath . $sUserId . VC_TEMP_FILE_NAME;
28 @unlink($sTempFileName);
30 if(is_uploaded_file($sFilePath)) {
31 move_uploaded_file($sFilePath, $sTempFileName);
32 @chmod($sTempFileName, 0666);
33 if(file_exists($sTempFileName) && filesize($sTempFileName)>0) {
35 getResult(
"INSERT INTO `" .
$sDBModule .
"Files` SET `Date`='" .
time() .
"', `Owner`='" . $sUserId .
"', `Status`='" . VC_STATUS_PENDING .
"'");
49 $sPlayFile =
$sFilesPath . $sUserId . VC_TEMP_FILE_NAME . VC_FLV_EXTENSION;
50 if(file_exists($sPlayFile) && filesize($sPlayFile)>0) {
53 "', `Status`='" . VC_STATUS_PENDING .
"'");
56 @rename(
$sFilesPath . $sUserId . VC_TEMP_FILE_NAME . VC_IMAGE_EXTENSION,
$sFilesPath . $sFileId . VC_IMAGE_EXTENSION);
57 @rename(
$sFilesPath . $sUserId . VC_TEMP_FILE_NAME . VC_THUMB_FILE_NAME . VC_IMAGE_EXTENSION,
$sFilesPath . $sFileId . VC_THUMB_FILE_NAME . VC_IMAGE_EXTENSION);
70 return $oDb->getAffectedRows() > 0 ?
true :
false;
77 if(!file_exists($sInputFile) || filesize($sInputFile)==0) {
78 if(strpos($sInputFile,
$sFilesPath) === FALSE)
return $sInputFile;
79 else return VC_VIDEO_SIZE_16_9;
85 $aSize = getimagesize(
$sFile);
87 $iRelation = $aSize[0]/$aSize[1];
88 $i169Dif = abs($iRelation - 16/9);
89 $i43Dif = abs($iRelation - 4/3);
91 if($i169Dif > $i43Dif)
return VC_VIDEO_SIZE_4_3;
92 else return VC_VIDEO_SIZE_16_9;
94 return VC_VIDEO_SIZE_16_9;
103 $sSound = $bUsex264 ?
" -acodec aac -strict experimental -b:a 128k -ar 44100 " :
" -acodec libmp3lame -b:a 128k -ar 44100 ";
115 $iBitrate = (int)
getParam(
'videoBitrate');
124 popen($sCommand,
"r");
136 $sResultFile = $sTempFile . (
vcUsex264() ? VC_M4V_EXTENSION : VC_FLV_EXTENSION);
139 if(!file_exists($sResultFile) || filesize($sResultFile)==0) {
152 @chmod($sResultFile, 0666);
162 $sSourceFile = $sTempFile;
165 $sTmpl =
vcPrepareCommand(
$GLOBALS[
'aConvertTmpls'][$bUseX264 ?
"playX264" :
"play"], array(
"bitrate" =>
_getVideoBitrate(),
"audio_options" => $bUseX264 ?
" -acodec aac -strict experimental -b:a 128k -ar 44100 " :
" -acodec libmp3lame -b:a 128k -ar 44100 "));
166 if(file_exists($sTempFile) && filesize($sTempFile)>0)
169 $sSourceFile .= VC_FLV_EXTENSION;
170 if(file_exists($sSourceFile) && filesize($sSourceFile)>0)
173 if(
empty($sTmpl))
return false;
176 getResult(
"UPDATE `" .
$sDBModule .
"Files` SET `Date`='" .
time() .
"', `Status`='" . VC_STATUS_PROCESSING .
"' WHERE `ID`='" .
$sId .
"'");
183 'ffmpeg' =>
$GLOBALS[
'sFfmpegPath'],
184 'tmp_file' => $sTempFile,
192 $sAutoApprove =
'on' ==
getParam(
'videoAutoApprove') ? STATUS_APPROVED : STATUS_DISAPPROVED;
193 getResult(
"UPDATE `" .
$sDBModule .
"Files` SET `Date`='" .
time() .
"', `Status`='" . $sAutoApprove .
"' WHERE `ID`='" .
$sId .
"'");
195 getResult(
"UPDATE `" .
$sDBModule .
"Files` SET `Status`='" . VC_STATUS_FAILED .
"' WHERE `ID`='" .
$sId .
"'");
201 function _grabImages($sInputFile, $sOutputFile, $iSecond = 0, $bForse =
false)
203 $sImageFile = $sOutputFile . VC_IMAGE_EXTENSION;
204 $sThumbFile = $sOutputFile . VC_THUMB_FILE_NAME . VC_IMAGE_EXTENSION;
206 if(!$bForse && file_exists($sImageFile) && filesize($sImageFile)>0)
$bResult =
true;
210 if(!$bForse && file_exists($sThumbFile) && filesize($sThumbFile)>0)
$bResult =
true;
219 return vcPrepareCommand($aConvertTmpls[
"image"], array(
"input" => $sInputFile,
"second" => $iSecond,
"size" => (
empty($sSize) ?
"" : $sSize),
"output" => $sOutputFile));
226 $sTempFile = $sUserId . VC_TEMP_FILE_NAME;
228 if($bSourceOnly)
return;
229 @unlink(
$sFilesPath . $sTempFile . VC_IMAGE_EXTENSION);
230 @unlink(
$sFilesPath . $sTempFile . VC_THUMB_FILE_NAME . VC_IMAGE_EXTENSION);
231 @unlink(
$sFilesPath . $sTempFile . VC_FLV_EXTENSION);
232 @unlink(
$sFilesPath . $sTempFile . VC_M4V_EXTENSION);
250 @unlink($sFileName . VC_MOBILE_EXTENSION);
251 $bResult = (@unlink($sFileName . VC_FLV_EXTENSION) || @unlink($sFileName . VC_M4V_EXTENSION)) &&
252 @unlink($sFileName . VC_IMAGE_EXTENSION) &&
253 @unlink($sFileName . VC_THUMB_FILE_NAME . VC_IMAGE_EXTENSION);
269 $iCurrentTime =
time();
271 getResult(
"INSERT INTO `" . MODULE_DB_PREFIX .
"Tokens`(`ID`, `Token`, `Date`) VALUES('" .
$sId .
"', '" .
$sToken .
"', '" . $iCurrentTime .
"')");