FIXED... WAS A MYSQL TIME OUT
THX FOR THE HELP
if($_REQUEST[field_myvideo_title]){
function get_size($path)
{
if (!is_dir($path))
return filesize($path);
$dir = opendir($path);
while ($file = readdir($dir))
{
if (is_file($path . "/" . $file))
$size += filesize($path . "/" . $file);
if (is_dir($path . "/" . $file) && $file != "." && $file != "..")
$size += get_size($path . "/" . $file);
}
return $size;
}
function urlfilesize($url,$thereturn) {
if (substr($url,0,4)=='http') {
$x = array_change_key_case(get_headers($url, 1),CASE_LOWER);
$x = $x['content-length'];
}
else { $x = @filesize($url); }
if (!$thereturn) { return $x ; }
elseif($thereturn == 'mb') { return round($x / (1024*1024),2) ; }
elseif($thereturn == 'kb') { return round($x / (1024),2) ; }
}
function download($remote, $local) {
$cp = curl_init($remote);
$fp = fopen($local, "w");
curl_setopt($cp, CURLOPT_FILE, $fp);
curl_setopt($cp, CURLOPT_HEADER, 0);
curl_exec($cp);
curl_close($cp);
fclose($fp);
}
include( "include/config.php" );
include( "include/function.php" );
chk_member_login( );
ismailverified( );
if ( $config['enable_package'] == "yes" )
{
check_subscriber( 100 );
}
header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
header( "Last-Modified: ".gmdate( "D, d M Y H:i:s" )." GMT" );
header( "Cache-Control: no-store, no-cache, must-revalidate" );
header( "Cache-Control: post-check=0, pre-check=0", FALSE );
header( "Pragma: no-cache" );
$videotitle = $_REQUEST[field_myvideo_title];
stemplate::assign( "videotitle", $videotitle );
$videodesc = $_REQUEST[field_myvideo_descr];
stemplate::assign( "videodesc", $videodesc );
$videochans = $_REQUEST[listch];
stemplate::assign( "videochans", $videochans );
$videourl = $_REQUEST[url];
stemplate::assign( "videourl", $videourl );
$videokeywords = $_REQUEST[field_myvideo_keywords];
stemplate::assign( "videokeywords", $videokeywords );
$videoprivacy = $_REQUEST[field_privacy];
stemplate::assign( "videoprivacy", $videoprivacy );
$videop = $_REQUEST[p];
stemplate::assign( "videop", $videop );
$randname = rand(1,9).substr(md5($_REQUEST[field_myvideo_title]), 0, 5).rand(1,9);
$ext2 = substr( strrchr( $videourl, "." ), 1 );
$randname .= ".".$ext2;
$temp_dir = $config[vdodir]."/";
download( $videourl, $temp_dir.$randname );
$upload_file = $randname;
$upload_file_path = $temp_dir.$randname;
$size = urlfilesize($videourl);
$size2 = filesize($upload_file_path);
while($size != $size2){
sleep(1);
}
if (!is_file($upload_file_path) || filesize($upload_file_path) < 0 || $size != $size2)
{
$err = 'Failed to upload selected file! - 1 - FileSizeURL:'.$size.' FileSizeDownload:'.$size2;
}
$upload_file_size = filesize($uploaded_file_path);
if ($err == "")
{
$pos = strrpos($upload_file, ".");
$ph = strtolower(substr($upload_file, $pos + 1, strlen($upload_file) - $pos));
$space = round($upload_file_size / (1024 * 1024));
if ($config['enable_package'] == "yes")
{
check_subscriber($space);
}
//this should never happen
if (($ph != "3gp" && $ph != "mp4" && $ph != "mov" && $ph != "asf" && $ph != "flv" && $ph != "mpg" && $ph != "avi" && $ph != "mpeg" && $ph != "wmv" && $ph != "rm" && $ph != "dat") || $space > $config[max_video_size])
$err = 'Invalid video format or invalid video size! - 2';
}
if ($err == "")
{
// ----- Approve Video -----
if ($config['approve'] == 1)
{
$active = "active='0'";
}
else
{
$active = "active='1'";
}
// -------------------------
$v_title = htmlentities(strip_tags($_REQUEST[field_myvideo_title]));
$v_descr = htmlentities(strip_tags($_REQUEST[field_myvideo_descr]));
$sql = "insert into video set
UID=$_SESSION[UID],
title='$v_title',
description='$v_descr',
keyword='$_REQUEST[field_myvideo_keywords]',
channel='0|$_REQUEST[listch]|0',
space = '$space',
addtime='" . time() . "',
adddate='" . date("Y-m-d") . "',
vkey='" . mt_rand() . "',
type='$_REQUEST[field_privacy]',
$active,
filehome='$_REQUEST[p]'";
$conn->execute($sql);
$vid = mysql_insert_id();
$vdoname = $vid . "." . $ph;
$ff = $config['vdodir'] . '/' . $vdoname;
//rename uploaded file
if(rename($upload_file_path,$ff))
{
exec("$config[mplayer] -vo null -ao null -frames 0 -identify $config[vdodir]/$vdoname", $p);
while(list($k,$v)=each($p))
{
if (preg_match("/^ID_.+\=.+/", $v))
{
$lx = explode("=", $v);
$vidinfo[$lx[0]] = $lx[1];
}
}
$duration = $vidinfo['ID_LENGTH'];
$height = $vidinfo['ID_VIDEO_HEIGHT'];
$width = $vidinfo['ID_VIDEO_WIDTH'];
$fps = $vidinfo['ID_VIDEO_FPS'];
$id_video_format = $vidinfo['ID_VIDEO_FORMAT'];
video_to_frame2($ff, $vid, $duration);
run_in_background("$config[phppath] $config[BASE_DIR]/convert.php $vdoname $vid $ff $fps $width $height $id_video_format > $config[BASE_DIR]/log.txt");
}
else
{
$err = 'Failed to rename uploaded file!';
}
}
if ($err == "")
{
$space = get_size($ff);
$space = round($space / (1024 * 1024));
$conn->execute("update video set space='$space' where VID='$vid'");
$key = substr(md5($vid), 11, 20);
$sql = "update video set
vdoname='$vdoname',
flvdoname='" . $vid . ".flv',
duration='$duration',
vkey='$key' WHERE VID=$vid";
$conn->execute($sql);
if ($config['enable_package'] == "yes")
{
$sql = "update subscriber set used_space=used_space+$space, used_bw=used_bw+$space, total_video=total_video+1 where UID=$_SESSION[UID]";
$conn->execute($sql);
}
header("Location:$config[baseurl]/upload_success.php?viewkey=$key&upload=yes");
exit;
}
include( "urluploadertemplates.php" );
}else{
echo 'Cannot find post data.';
}