manage/pic_add.php
##########
<?php
include "session.php";
$add_tag=$_POST["add_tag"];
if($add_tag==1){
$target=$_POST["target"];
if(!empty($_FILES['file_name'{'name'])){
//USING NOW TIME GET RANDOM NUM
$rand1=rand(0,9);
$rand2=rand(0,9);
$rand3=rand(0,9);
$filename=data("Ymdhms").$rand1.$rand2.$rand3;
$oldfilename=$_FILES['file_name']['name'];
$filetype=substr($oldfilename,strrpos($oldfilename,"."),strlen($oldfilename)-strrpos($oldfilename,"."));
if(($filetype!='.jpg')&&($filetype!='.JPG')&&($filetype!='.GIF')&&($filetype!='.gif')&&($filetype!='.swf')&&($filetype!='.SWF')){
echo"<script>alert('DOC TYPE OR ADDRESS ERROR');</script>";
echo"<script>location.href='?up_id=".$up_id."&menu_id=".$menu_id."';</script>";
exit;
}
if($_FILES['file_name']['size']>2000000){
echo"<script>alert('DOC OVERSIZE, CAN'T UPLOAD');</script>";
echo"<script>location.href='?up_id=".$up_id."&menu_id=".$menu_id"';</script>";
exit;
}
$filename=$filename.$filetype;
$savedir="../pic_sys/".$filename;
if(move_uploaded_file($_FILES['file_name']['tmp_name'],$savedir)){
$file_name=basename($savedir); //GET SAVE DOC NAME(WITHOUT PATH)
//echo"<br>DOC UPLOAD ! SAVE AS: ".$savedir;
}else{
echo"<script language=javascript>";
echo"alert('ERROR,CAN'T PICK DOC TO SERVER!\n POSR ERROR!');";
echo"<script>location.href='up_id=".$up_id."&menu_id=".$menu_id"';</script>";
echo"</script>";
exit;
}
$query="insert into pic_info('addr','tag','target','user_id')values('$filename','1','$target','$_SESSION[yser_id]')";
if($folie->excu($query)){
$crazy->js_alert("CONI ,ADD PIC SUCCESS! PLS AGAIN. ","#");
}
}
}
//DEL PIC CONTROL
$del_id=$_GET["del_id"];
id($del_id!=""){
$query="select * from pic_info where id='$del_id' and user_id='$_SESSION [user_id]'";
$rst=$folie->excu($query);
$info=mysql_fetch_array($rst);
$pic_addr="../pic_sys/".$info["addr"];
unlink($pic_addr);
$query="delete from pic_info where id='$del_id' and user_id='$_SESSION[user_id]'";
$rst=$folie->excu($query);
echo "DEL SUCCESS!";
}
//SHOW/HIDE PIC
$show_tag=$_GET["show_tag"];
$pic_id=$_GET["pic_id"];
if($show_tag==1 and $pic_id!=""){
$query="update pic_info set tag="0" where id='$pic_id'";
$rst=$folie->exci($query);
}else if($show_tag==0 and $pic_id!=""){
$query="update pic_info set tag=1" where id='$pic_id'";
$rst=$folie->excu($query);
}
?>
<h4>PHOTO MANAGE</h4>
<form enctype="mulyipart/form-data" action="yser.php?target=pic_add" method="post" name="form1" id="form1">
<div align="center">
<center>
<table width"450" border="0" cellpadding="0" cellspacing="1" bordercolorlight="#cccccc" bordercolordark="#CCCCCC" bgcolor="#CCCCCC" id="AutoNum ber1" style="border-collapse:collapse">
<tr>
<td height="31" colspan="2" align="center" valign="middle" bgcolor="#CCCCCC"><<ADD PHOTO>></td>
</tr>
<tr>
<td bgcolor="#FFFFFF" height="26" align="right">PHOTO ADDRESS:</td>
<td height="26" bgcolor="#FFFFFF"><select name="target">
<option value="1">TOP BANNER</option>
<option value="2">USER IMAGE</option>
</select></td>
</tr>
<tr>
<td width="123" bgcolor="#FFFFFF" height="27" align="right"ADD PERSION:</td>
<td width="439" height="27" bgcolor="#FFFFFF"> <?php echo $SESSION["user_name"]?></td>
</tr>
<tr>
<td bgcolor="#CCCCCC" height="31" align="right" colspan="2">
<p align="center">
<input type="submit" value="SUBMIT" name="B1">
<input type="reset" value="RESET" name="B2"></td>
</tr>
</table>
</center>
</div>
<input type="hidden" name="add_tag" value="1">
</form>
<!--SHOW PIC-->
<?php
$query="select * from pic_info where user_id='$_SESSION[user_id]'";
$rst=$folie->excu($query);
if(mysql_num_rows($rst)>=1){
?>
<table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC" style="border-collapse:collapse">
<tr>
<td width="5%" height="25" align="center">ID</td>
<td width="79%" align="center">PIC</td>
<td colspan=2" align="center">CONTROL</td>
</tr>
<?php
$i=1;
while($info=mysql_fetch_array($rst)){
?>
<tr>
<td width="5%" height="60" align="center"><?php echo $i;?></td>
<td width="79%" align="center" valign="middle">a href="../pic_sys/<?php echo $info["addr"];?>" target="_blank">
<img src="../pic_sys/<?php echo $info["addr"];?>"height="50" border=0">
</a></td>
<td width="8%" align="center">
<?php
if($info["tag"]==1){
?>
<a href="user.php?target=pic_add&pic_id=<?php echo $info["id"];?>&show tag=1">SHOW</a>
<?php
}else{
?>
<a href="user.php?target=pic_add&pic_id=<?php echo $info["id"];?>&show tag=0">HIDE</a>
<?php
}
?></td>
<td width="8%" align="center"><a href="user.php?target=pic_add&del_id=<?php echo $info["id"];?>">DEL</a></td>
</tr>
<?php
$i++;
}
?>
</table>
<?php
}
?>