/*
* @function 根据类型码获得文件类型
* @param $typeCode类型码十六进制
* @return string 文件类型
* @notice 硬编码值查表http://www.garykessler.net/library/file_sigs.html
*/
public function getFileTypeByC4chars_TypeCode($typeCode){
$fileType="";
switch($typeCode){
case "4B57414A88F027D1":
$fileType = 'exe';
break;
case "4D5A":
$fileType = 'exe';
break;
case "535A444488F02733":
$fileType = 'exe';
break;
case "7F454C46":
$fileType = 'exe';
break;
case "E8":
$fileType = 'exe';
break;
case "E9":
$fileType = 'exe';
break;
case "EB":
$fileType = 'exe';
break;
case "FF":
$fileType = 'exe';
break;
case "526172211A0700":
$fileType = 'rar';
break;
case "526172211A070100":
$fileType = 'rar';
break;
case "504B0304":
$fileType = 'zip';
break;
case "504B030414000100":
$fileType = 'zip';
break;
case "630000000000":
$fileType = 'zip';
break;
case "504B0506":
$fileType = 'zip';
break;
case "504B0708":
$fileType = 'zip';
break;
case "504B4C495445":
$fileType = 'zip';
break;
case "57696E5A6970":
$fileType = 'zip';
break;
case "504B537058":
$fileType = 'zip';
break;
case "FFD8FFE1xxxx4578":
$fileType = 'jpg';
break;
case "696600":
$fileType = 'jpg';
break;
case "FFD8FFE8xxxx5350":
$fileType = 'jpg';
break;
case "49464600":
$fileType = 'jpg';
break;
case "474946383761":
$fileType = 'gif';
break;
case "474946383961":
$fileType = 'gif';
break;
case "89504E470D0A1A0A":
$fileType = 'png';
break;
case "FFD8FFE0xxxx4A46":
$fileType = 'jpeg';
break;
case "494600":
$fileType = 'jpeg';
break;
case "415649204C495354":
$fileType = 'avi';
break;
case "464C5601":
$fileType = 'flv';
break;
case "3026B2758E66CF11":
$fileType = 'wmv';
break;
case "A6D900AA0062CE6C":
$fileType = 'wmv';
break;
case "6674797033677035":
$fileType = 'mp4';
break;
case "667479704D534E56":
$fileType = 'mp4';
break;
case "6674797069736F6D":
$fileType = 'mp4';
break;
case "0000001466747970":
$fileType = 'mp4';
break;
case "69736F6D":
$fileType = 'mp4';
break;
case "0000001866747970":
$fileType = 'mp4';
break;
case "33677035":
$fileType = 'mp4';
break;
case "0000001C66747970":
$fileType = 'mp4';
break;
case "4D534E5601290046":
$fileType = 'mp4';
break;
case "4D534E566D703432":
$fileType = 'mp4';
break;
case "000001BA":
$fileType = 'vob';
break;
case "2E524D46":
$fileType = 'rmvb';
break;
default:
$fileType = 'unknown: '.$typeCode;
break;
}
return $fileType;
}
/*
* @function 检测上传的文件类型是否在允许范围内
* @return boolean 返回true表示上传的文件在允许范围内,false表示不在范围内
*/
public function checkFileType(){
$ext=$this->temp_fileExt;
$ext_arr=$this->allow_type;
$flag=false;
foreach($ext_arr as $key=>$value){
if(in_array($ext,$value)){
$flag=true;
$this->file_category=$key;
break;
}
}
return $flag;
}
/*
* @function 是否是真实的图片
* @return mixed 返回false表示不是真实的图片,返回数组表示是真实的图片
*/
public function is_realPic(){
$file=$this->datainfo["tmp_name"];
return getimagesize($file);
}
//接下面太长了