<?php
include("../../config.inc.php");
include($CommonPath."/admin/func/adm.inc.php");
include($CommonPath."/admin/func/db.inc.php");
$msql=new SHARP_SQL;
NeedAuth(0);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>字体设置</title>
<link href="style.css" rel="stylesheet">
<script>
function UploadPic () {
	chose.style.display = "none";
	upload.style.display = "block";
}
function AlertErrow (say) {
	alert (say);
	return false;
}
function ReturnValue (path) {
	returnValue = path;
	window.close ();
}
</script>
</head>

<body leftmargin="0" topmargin="0" class="bodybackground">
<center>
<?php
if ($Submit == "确 定" && $radiobutton != "upload") {
	echo "<script>ReturnValue ('piclib')</script>";
} else if ($Submit == "确 定"){
	if ($pic_size > 0 && $pic_size < 256000) {
		if (($pic_type == "image/gif") || ($pic_type == "image/pjpeg") || ($pic_type == "image/x-png")){
			switch ($pic_type){
  	    		case "image/gif" : $extention=".gif";
   	   			 break;
  				case "image/pjpeg" : $extention=".jpg";
   	    		break;
  				case "image/x-png": $extention=".png";
   	    		break;
 			}		
	
			$img_directory = "../../pic/gif/";
			if (!file_exists ($img_directory)){
				@mkdir($img_directory,0777);
			}
	
			$file_name = time().$extention;
			$file_path = $img_directory.$file_name;
			copy ($pic,$file_path);
			chmod ($file_path,0666);
			$file_path = str_replace ("../../",$SiteUrl, $file_path);
			echo "<script>ReturnValue ('".$file_path."')</script>";
 		 }else{
			echo "<script>AlertErrow ('上传的图片格式错误,只能上传GIF,JPG或PNG图片格式');</script>";
 		 }
	} else {
		echo "<script>AlertErrow ('请选择要上传的文件，且文件不能大于250KB！');</script>";
	}
}
?>
  <table width="20" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td><img src="dot.gif" height="7" width="1"></td>
    </tr>
  </table>
  <table width="100%" border="0" cellspacing="0" cellpadding="10">
    <form action="" method="post" enctype="multipart/form-data">
    <tr> 
      <td valign="middle">
<table width="100%" border="0" cellspacing="3" cellpadding="0" id="chose">
          <tr> 
            <td>
<input type="radio" name="radiobutton" value="upload" onClick="UploadPic ()">
              <a href="#" style="cursor:default;color:#000000;text-decoration: none;" onClick="radiobutton[0].checked = true;UploadPic ()">上传新图片</a></td>
          </tr>
          <tr> 
            <td>
<input name="radiobutton" type="radio" value="chose" checked>
              <a href="#" style="cursor:default;color:#000000;text-decoration: none;" onClick="radiobutton[1].checked = true">从图库中选择一张图</a></td>
          </tr>
        </table>
          <table width="100%" border="0" cellspacing="3" cellpadding="0" id="upload" style="display:none">
            <tr> 
              <td>请选择图片文件：</td>
            </tr>
            <tr>
              <td><input type="file" name="pic" style="width:100%"></td>
            </tr>
          </table></td>
      <td width="2"><img src="images/separator.gif" width="2" height="50"></td>
      <td width="60" valign="middle"> 
        <table width="100%" border="0" cellspacing="2" cellpadding="0">
          <tr> 
            <td align="center"> 
              <input type="submit" name="Submit" value="确 定" style="width:55;"></td>
          </tr>
          <tr>
            <td align="center"> 
              <input type="button" name="Submit2" value="取 消" style="width:55;" onClick="window.close ();"></td>
          </tr>
        </table>
      </td>
    </tr>
	</form>
  </table>
</center>
</body>
</html>
