www.gusucode.com > Tatter Tools 0.961 SE GB2312 简体中文版 > upload/admin/com_mfile.php

    <?
	include("../inc_global.php");
	include("../inc_function.php");
	check_authority();

?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312">
<meta name="keywords" content="TT,TatterTools,Skin,php">
<meta name="description" content="Meyu,梦游,华人中文网">
<meta name="generator" content="TatterTools中文BLOG">
<meta name="MSSmartTagsPreventParsing" content="TRUE">
<meta http-equiv="MSThemeCompatible" content="Yes">
</head>
<script type="text/javascript" src="../lib.js"></script>
<script type="text/javascript">
<?
	if ($mode == "attach") {

		if (!$uploadfile) $uploadfile = $_FILES["uploadfile"][tmp_name];
		if (!$uploadfile_name) $uploadfile_name = $_FILES["uploadfile"][name];

		if (!@is_dir($r_attach_path.$image_file_path1)) { mkdir($r_attach_path.$image_file_path1, 0777); chmod($r_attach_path.$image_file_path1, 0777); }
		if (!@is_dir($r_attach_path.$image_file_path1.$image_file_path2)) { mkdir($r_attach_path.$image_file_path1.$image_file_path2, 0777); chmod($r_attach_path.$image_file_path1.$image_file_path2, 0777); }

		$uploadfile_name = ereg_replace("'", "", $uploadfile_name);
		$attachname = get_timestamp3().substr($uploadfile_name, strrpos($uploadfile_name, "."));

		if (!move_uploaded_file($uploadfile, $r_attach_path.$image_file_path1.$image_file_path2.$attachname)) exit;
		chmod($r_attach_path.$image_file_path1.$image_file_path2.$attachname, 0777);
		$filesize = filesize($r_attach_path.$image_file_path1.$image_file_path2.$attachname);
		list ($width, $height) = getimagesize($r_attach_path.$image_file_path1.$image_file_path2.$attachname);

		$type = analyze_file($r_attach_path.$image_file_path1.$image_file_path2.$attachname);

		// if (!$width) { @unlink($r_attach_path.$image_file_path1.$image_file_path2.$attachname); print "<script> alert('捞固瘤 颇老父 诀肺靛 啊瓷钦聪促'); </script>"; exit; }
		// if ($filesize > 500*1024) { @unlink($r_attach_path.$image_file_path1.$image_file_path2.$attachname); print "<script> alert('侩樊 500KB 捞窍狼 颇老父 诀肺靛 啊瓷钦聪促'); </script>"; exit; }

		put_query("
			insert into $filetable (
				pno, filename, attachname, filesize, width, height, regdate
			) values (
				$num, '$uploadfile_name', '$attachname', $filesize, '$width', '$height', '".time()."'
			)
		");

		$sql = "select max(no) from $filetable";
		list ($no) = mysql_fetch_array(mysql_query($sql));

		switch ($type) {
			case "1":
				$tmp1_buf = "($width"."x"."$height / ".get_filesize($filesize).")";
				$tmp2_buf = "width=\"$width\" height=\"$height\"";
				break;

			case "2":
				$tmp1_buf = "(flash: ".get_filesize($filesize).")";
				$tmp2_buf = "width=\"320\" height=\"240\"";
				break;

			case "3":
			case "4":
				$tmp1_buf = "(multimedia: ".get_filesize($filesize).")";
				$tmp2_buf = "";
				break;

			case "0":
				$tmp1_buf = "(attached: ".get_filesize($filesize).")";
				$tmp2_buf = "";
				break;
		}

		?>
		var temp1 = '<?=$uploadfile_name?> <?=$tmp1_buf?>';
		var temp2 = '<?=$uploadfile_name?>|<?=$tmp2_buf?>|<?=$attachname?>|<?=$no?>';
		addList(parent.document.<?=$formname?>.filelist,temp1,temp2);
		set_preview_image(parent.document.<?=$formname?>.filelist, parent.document.getElementById('s_image'), '<?=$image_file_path1?>', '<?=$image_file_path2?>')
		if (navigator.userAgent.indexOf("Opera", 0) > 0) alert('如附件清单内无显示上传档案请按预览按钮重新载入\t');
		<?
	}

	if ($mode=="delete") {

		if (trim($deletefile) != "") $deletefile = substr($deletefile,1);
		$file_row = split("\^",$deletefile);

		while(count($file_row) != 0) {
			$row = array_pop ($file_row);
			list ($del_line, $filename, $wh, $attachname, $no) = split("\|",$row);
			if (@unlink($r_attach_path.$image_file_path1.$image_file_path2.$attachname)) {
				print " parent.document.".$formname.".filelist.options[$del_line] = null; ";
				put_query ("delete from $filetable where no = '$no'");
			}
		}
		?> set_preview_no_image(parent.document.getElementById('s_image')); <?
	}
?>
</script>