<?php
/*********************************************************
程序名称：站长助手 WEBMASTER HELPER
作者：feixin
email:kusite@etang.com
版权：feixin (http://www.zc18.com)
//////////////////////////////////////////////////////////
文件名：upload_type.php
此文件功能描述：辨别文件类型和是否可以编辑、浏览
最后编辑日期：2003-1-18
*********************************************************/

if (!defined('IN_WH')) {
  die("不要黑我啊");
}

function get_file_type($file)
{

	if(eregi(".gif", $file))
	{
		$gif = "gif.gif";
		$type = "gif图像文件";
		$can_view = 1;
		$can_edit = 0;
	}
	elseif(eregi(".jpg|.jpeg", $file))
	{
		$gif = "jpg.gif";
		$type = "jpg图像文件";
		$can_view = 1;
		$can_edit = 0;
	}
	elseif(eregi(".php|.php3|.php4", $file))
	{
		$gif = "php.gif";
		$type = "php文件";
		$can_view = 1;
		$can_edit = 1;
	}
	elseif(eregi(".txt|.text", $file))
	{
		$gif = "txt.gif";
		$type = "文本文件";
		$can_view = 1;
		$can_edit = 1;
	}
	elseif(eregi(".pl|.cgi", $file))
	{
		$gif = "pl.gif";
		$type = "cgi文件";
		$can_view = 1;
		$can_edit = 1;
	}
	elseif(eregi(".zip|.rar|.tar|.gz|.tar.gz|.cab", $file))
	{
		$gif = "zip.gif";
		$type = "压缩文件";
		$can_view = 1;
		$can_edit = 0;
	}
	elseif(eregi(".html|.htm|.css", $file))
	{
		$gif = "htm.gif";
		$type = "网页文件";
		$can_view = 1;
		$can_edit = 1;
	}
	elseif(eregi(".wav|.mp3|.mp4", $file))
	{
		$gif = "wav.gif";
		$type = "wav声音文件";
		$can_view = 1;
		$can_edit = 0;
	}
	elseif(eregi(".rm|.ra|.ram|.avi", $file))
	{
		$gif = "ram.gif";
		$type = "rm文件";
		$can_view = 1;
		$can_edit = 0;
	}
	elseif(eregi(".exe", $file))
	{
		$gif = "exe.gif";
		$type = "执行文件";
		$can_view = 1;
		$can_edit = 0;
	}
	elseif(eregi(".js", $file))
	{
		$gif = "js.gif";
		$type = "js文件";
		$can_view = 1;
		$can_edit = 1;
	}
	elseif(eregi(".mid|.midi", $file))
	{
		$gif = "mid.gif";
		$type = "mid声音文件";
		$can_view = 1;
		$can_edit = 0;
	}
	else
	{
		$gif = "default.gif";
		$type = "未识别文件";
		$can_view = 1;
		$can_edit = 1;
	}

	//
	$arr_type = array("gif" => $gif,
					  "type" => $type,
					  "can_view" => $can_view,
					  "can_edit" => $can_edit
					 );
	return $arr_type;
}

?>