<?php

/*
'**************************************************************************************************
' 程序名称: CCTVAI开源音乐管理系统
' 官方网站: http://www.cctvai.com
' 联系 Q Q: 1542367792
' QQ交流群：136687984
' 版本：(终结版)
' 备注：未经书面授权，不得向任何第三方提供本软件系统！
' 功能，模板，插件，扩展，定制请联系QQ：1542367792
'**************************************************************************************************
*/
error_reporting(0);
include "../../../include/cctvai.conn.php";
$CcTvAi_com_userid=SafeRequest("uid", "get");
$CcTvAi_com_username=base64_decode(SafeRequest("uname", "get"));
if(cd_userupload=="0"){ exit('?error=1');}
if(cd_uploadentrance=="no") {
    exit('?error=1');
} //没有权限
$m = "upload/video";
if(!file_exists(_cctvai_root_ . $m)) {
    exit('?error=3');
} //文件夹不存在
if(strpos(cd_upvideotype, fileext($_FILES['Filedata']['name']))!==false) {
} else {
    exit('?error=4');
} //文件类型错误
if(!empty($_FILES)) {
    $tempFile    = $_FILES['Filedata']['tmp_name'];
    $file        = $_FILES['Filedata']['name'];
    $size        = $_FILES['Filedata']['size'];
    $zmd5        = $size . $file;
    $timemd5     = '' . substr(md5($zmd5), 0, 32) . '';
    $md5         = strtoupper($timemd5);
    $form        = strtolower(trim(substr(strrchr($file, "."), 1)));
    $rdanceName  = str_replace('.' . $form . '', '', $file);
    $targetFile  = "" . $md5 . "." . $form . "";
    $targetFiles = "../../../upload/video/" . $targetFile . "";
    move_uploaded_file($tempFile, $targetFiles);
	@unlink($_FILES['Filedata']['tmp_name']);
	//记录上传信息
	$setarrss=array(
		'cd_userid'=>$CcTvAi_com_userid,
		'cd_username'=>$CcTvAi_com_username,
		'cd_userip'=>$_SERVER["REMOTE_ADDR"],
		'cd_filetype'=>'视频文件',
		'cd_filename'=>$targetFile,
		'cd_filesize'=>$_FILES["Filedata"]["size"],
		'cd_fileurl'=>ReplaceStr($targetFiles, "../../../", ""),
		'cd_filetime'=>time()
	);
	inserttable('upload', $setarrss, 1);
    echo "?rdanceName=$rdanceName&rUrl=upload/video/$targetFile&rsiz=" . formatsize($size) . "&rmd5=$md5";
}
?>