/home/bjcompany/domains/benjabhorn.com/public_html/benjabhorn_group/control/blockprogress.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
            
require_once("config.inc.php");
            include(
"function.inc.php");
            
$link mysql_connect($cfgServers['host'],$cfgServers['stduser'],$cfgServers['stdpass'])or die("Can't connect Server");
            
mysql_select_db($cfgServers['selectdb']) or die("Can't connect databases");
            
//-----------------------------------------------------------------------------------------------------------
            
$path_product='../uploadfile/';
            
//-----------------------------------------------------------------------------------------------------------    
            
if($_GET['act']=='deletePic'){
                                    @
unlink($path_product.$_GET['picName']);
                                        @
unlink($path_product."thb/".$_GET['picName']);
                                        
$query="UPDATE tbl_home_reserv  SET  image_detail=''  WHERE box_name= '".$_GET['name']."' ";
                                        
mysql_query($query);
                                        echo 
"<script language=\"javascript\">window.location.href='blockprogress.php?name=".$_GET['name']."'</script>";
                }
            
//-----------------------------------------------------------------------------------------------------------                        
            
if($_POST['action']=='add'){
                            if(
$_FILES['uploadfile']['name']!=""){
                                        
$tempFileName $_FILES['uploadfile']['name'];
                                        
GetNewFileName($_FILES['uploadfile']['tmp_name'],$_FILES['uploadfile']['name'],$i);
                                        
move_uploaded_file($_FILES['uploadfile']['tmp_name'], $path_product.$_FILES['uploadfile']['name']);
                                        @
unlink($path_product.$_POST['oldFileName']);
                                        @
unlink($path_product."thb/".$_POST['oldFileName']);
                                }    else {
                                        
$_FILES['uploadfile']['name']=$_POST['oldFileName'];
                                }
                                    
$query "UPDATE  `tbl_home_reserv` "
                                            
." SET detail='".$_POST['detail']."' , image_detail='".$_FILES['uploadfile']['name']."'  "
                                            
." WHERE box_name='".$_GET['name']."' ";
                                    
                                        
mysql_query($query);            
                }
            
            
//-----------------------------------------------------------------------------------------------------------            
            
if($_GET['name']){
                        
$query="SELECT * FROM  tbl_home_reserv WHERE box_name= '".$_GET['name']."' ";
                        
$result=mysql_query($query);
                        
$data=mysql_fetch_assoc($result);
                }
            
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script language="javascript">
        function DeletePic(pic){
             if(confirm('ต้องการลบรูปนี้')){
                         window.location.href='blockprogress.php?name=<?php echo $_GET['name']?>&act=deletePic&picName='+pic;
                 }else{
                         return false;
                     }
                
            }
</script>
</head>

<body>
<form action="<?php $_SERVER['PHP_SELF']?>" method="post" name="form1" enctype="multipart/form-data">
<table width="450" border="0" align="center">
  <tr>
    <td bgcolor="#CCCCCC"><table width="450" border="0" align="center" cellpadding="3" cellspacing="0">
      <tr>
        <td width="139" align="right" bgcolor="#FFFFFF" class="txt10-black">ชื่อบ้าน</td>
        <td width="345" bgcolor="#FFFFFF">&nbsp;<?php echo $_GET['name']?></td>
      </tr>
      <tr>
        <td align="right" bgcolor="#FFFFFF" class="txt10-black">รูปภาพ</td>
        <td bgcolor="#FFFFFF" class="txt-8-red">
        <?php if($data['image_detail']){  
                    
$n_width=350;$n_height=350;
                    
$info =  pathinfo($path_product.$data['image_detail']);
                    
$info[extension]=strtolower($info[extension]);
                        if((
$info[extension]=='pjpeg')  || ($info[extension]=='gif')  ||  ($info[extension]=='png')  ||  ($info[extension]=='x-png') || ($info[extension]=='jpeg') || ($info[extension]=='jpg')){
                            list(
$width$height$type$attr) = getimagesize($path_product.$data['image_detail']);
                                        
create_thub($path_product."/",$data['image_detail'],$n_width,$n_height);
                            }
        
?>
            <a href="<?php echo $path_product.$data['image_detail']?>" target="_blank">
            <img src="<?php echo $path_product."thb/".$data['image_detail']?>"  border="0"/></a><br />
            <a href='#' onclick="DeletePic('<?php echo $data['image_detail']?>')">
            <img src="images/black_icon/16x16/delete.png" width="16" height="16" border="0" /> ลบรูปนี้</a><br />
        <?php ?>
          <input name="uploadfile" type="file" id="uploadfile" />
          <br />
          *jpg, *png,*gif กว้าง 350 สูง 350 pixel ขนาดไฟล์ไม่เกิน 2 เมกกะไบต์ </td>
      </tr>
      <tr>
        <td align="right" bgcolor="#FFFFFF" class="txt10-black">รายละเอียด</td>
        <td bgcolor="#FFFFFF"><label for="detail"></label>
          <textarea name="detail" cols="40" rows="5" id="detail"><?php echo $data['detail']?></textarea></td>
      </tr>
      <tr>
        <td align="right" bgcolor="#FFFFFF" class="txt10-black"><input type="hidden" name="oldFileName" id="oldFileName"  value="<?php echo $data['image_detail']?>"/>          <input name="action" type="hidden" id="action" value="add" /></td>
        <td bgcolor="#FFFFFF"><span class="txt10-black">
          <input type="submit" name="button" id="button" value="เพิ่ม / แก้ไขข้อมูล" />
        </span></td>
      </tr>
    </table></td>
  </tr>
</table>
<br /><div align="center"><a href="#" onclick="window.opener.location.reload(); window.close()">Close</a></div>
</form>
</body>
</html><?php mysql_close();?>