<?php
/*
	power by JASON.ZHANG  DM建站  www.demososo.com
*/
if(!defined('IN_DEMOSOSO')) {
	exit('this is wrong page,please back to homepage');
}


if($act=='update'){
    $imgname=$_FILES["addr"]["name"] ;
			$imgsize=$_FILES["addr"]["size"] ;
			   $ifwater=@htmlentitdm($_POST['water']);
			    $titlehere=@htmlentitdm($_POST['title']);

			   // pre($_POST); 
 
		if(!empty($imgname)){
			$imgtype = gl_imgtype($imgname);

			$oldimgtype = 	gl_imgtype($imgsqlname);	

			if(in_array($imgtype,$attach_img) && in_array($oldimgtype,$attach_img) ) { }
		    else {
		    	if($imgtype<>$oldimgtype){
		    		alert('出错，文件扩展名不同');
					jump($jumpv.'&act=show');
		    	}
		    }		
			//
			//$up_water='y';	
			//$up_water='y';	//water value is in inc_logcheck.php of lang talbe

		 
				
				if($ifwater=='y') $up_water='y';
				else $up_water='n';

		  if(!in_array($imgtype,$attach_img))  $up_water='n';//docx,ppt not water
			
			//-------------
			$up_small='n';
			$up_delbig='n'; 
			$i='';		

			//$imgsqlname='';//alway change img name,because the kv img
			require_once('../plugin/upload_img.php');//need get the return value,then upimg part turn to easy.
		 
		
	}//end not empty
	else  alert('请上传附件。');
	 
	jump($jumpv.'&act=show');


    
}

 
if($act=='show'){


 
 echo '<div class="tc">';
 
 $v=UPLOADPATHIMAGE.$imgsqlname;

 $vrand = $v.'?v='.rand(1111,9999);

 $vroot = UPLOADROOTIMAGE.$imgsqlname;
 if(!is_file($vroot)) {
 echo '文件不存在 - '.$imgsqlname;
 exit;
}

 $imgtype = gl_imgtype($imgsqlname);


 echo '<div style="padding:10px;margin:10px;border:1px dashed #e2e2e2">'.$v.'</div>';

?>
<div class="tc" style="padding:10px;margin:10px;border:1px dashed #e2e2e2">
<form action="<?php echo $jumpv; ?>&act=update" method="post" enctype="multipart/form-data">

<input name="addr" size="35" style="display:inline-block" type="file"  />
<p class="cred">(<?php
		echo $format_t;
		?>)</p>
		 
	   <input type="checkbox" name="water" id="water"  value="y" checked="checked"   size="10"> <label for="water">加上水印</label>
       <div class="c5"> </div>
	  

	   <input  class="mysubmit" type="submit" name="Submit" value="<?php echo '修改';?>">
</form>
</div>
<?php

 if(!in_array($imgtype,$attach_img)) {
  echo  '<br/><br/><br/><a href='.$vrand.' target="_blank">'.$imgtype.'格式[下载]</a>';  

 }
 else   echo '<img src="'.$vrand.'" alt="" />';
 
 echo '</div>';

}
 
?>