/home/banprang/domains/plai.go.th/public_html/coremain/module/gallery/gallery_update.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
<?php
// Status Package Module
$status_module=select_query("status_module","cms_status_module","id","18");
if(
$status_module[0]!=1)    {    
    
fieldset_no_module();
}
if (
$_SESSION['dbname'] != "nversion_62") {
  
$navig['gallery'] = "ภาพกิจกรรม";
  
$navig['gallery_add'] = "ภาพทั้งหมด";
  
navigator($navig);
  echo 
"<br>";
  
bar_header("ภาพทั้งหมด");
  
fieldset_top("ภาพกิจกรรม");
} else {
  
$navig['gallery'] = "ผลงานที่ผ่านมา";
  
$navig['gallery_add'] = "ภาพทั้งหมด";
  
navigator($navig);
  echo 
"<br>";
  
bar_header("ภาพทั้งหมด");
  
fieldset_top("ภาพทั้งหมด");
}

import_request_variables('pG''p_');
//include_once("coremain/module/gallery/class.upload.php");
if($p_g_type!="")                                                    {         $g_type=trim($p_g_type);                                    }
if(
$p_id_update!="")                                                {         $id_update=trim($p_id_update);                        }
if(
$p_yearthai1!="")                                                {         $yearthai1=trim($p_yearthai1);                            }
if(
$p_id_hide!="")                                                    {         $id_hide=trim($p_id_hide);                                    }
if(
$p_id_show!="")                                                {         $id_show=trim($p_id_show);                                }
if(
$p_id_del!="")                                                    {         $id_del=trim($p_id_del);                                        }
if(
$p_block!="")                                                        {         $block=trim($p_block);                                        }
$array_allow_image allow_image_type();

//###################### สำหรับ Admin
if ($_SESSION['admin_web'] == "admin" || ( id_top_permission("b"))) {
// Hide - Show port_gallery_record
  
if ($id_hide != "") {
    
$sql "UPDATE port_gallery_record SET status='0'  WHERE id_record='$id_hide'";
    
mysql_query($sql);
  }
  if (
$id_show != "") {
    
$sql "UPDATE port_gallery_record SET status='1'  WHERE id_record='$id_show'";
    
mysql_query($sql);
  }
// Delete port_gallery_record
  
if ($id_del != "") {
    
// delete port_gallery_record
    
$sql "SELECT pic FROM port_gallery_record WHERE id_record='$id_del'";
    
$result mysql_query($sql);
    while(
$data mysql_fetch_array($result)){
      if (
$data[0] != "") {
        if(
file_exists("$_SESSION[web_name]/gallery/$data[0]")){
          
unlink("$_SESSION[web_name]/gallery/$data[0]");
        }
        if(
file_exists("$_SESSION[web_name]/gallery/$data[0]")){
          
unlink("$_SESSION[web_name]/gallery/$data[0]");
        }
      }
    }
    
$sql "delete from port_gallery_record  where id_record='$id_del'";
    
$result mysql_query($sql);
  }

  if (
$p_hiddata != "") {
    
$hiddata trim($p_hiddata);
  }
  
$num "'";
  
$hiddata ereg_replace('"'$num$hiddata);

// Update
  
if ($hiddata != "") {
    
$sql "UPDATE `port_gallery_topic` SET fulltexts ='$hiddata' ,'en_fulltexts'='$hiddata2' WHERE id_topic='$id_update'";
    
$result mysql_query($sql);
  }
}

// ################################ภาพกิจกรรม ###################################
$sql="SELECT * FROM `port_gallery_topic`  WHERE  id_topic='$id_update'"
$result=mysql_query($sql);
$data mysql_fetch_array($result);

echo 
"$data[fulltexts]";    


 
// เพิ่มรูปภาพกิจกรรม 
if($_SESSION['admin_web']=="admin" || (id_top_permission("b"))){
?>
<!--<form  action='index.php?id_update=<?//= $id_update ?>&mod=gallery_update&path=gallery&id_hide=<?//= $data['id_record'] ?>&block=<?//= $block ?>' method='post' enctype='multipart/form-data' name='add' id='add' onSubmit='return checkadd()'>-->
<form id="fm_gallery" name="fm_gallery">
  <table width='98%' border='0' align='center' cellpadding='1' cellspacing='1'>
    <tr>
      <td colspan='2' align='center'>
        <b>Upload รูปเพิ่มเติม</b><br><br>
        
        <!--<INPUT TYPE='hidden' name='check_upload' value='1'>-->
        <input type="hidden" name="id_update" value="<?= $id_update ?>" />
        <input type="hidden" name="block" value="<?= $block ?>" />
      </td>
    </tr>
    <?php
      $option 
= array(
          
'title' => 'Upload รูป',
          
'description' => 'เลือกภาพกิจกรรม',
          
'file_type' => 'image',
          
'prefix' => 'pic',
          
'extraHTML' => array(
              
=> array('type' => 'input''text' => 'คำอธิบายรูป''name' => 'explain''style' => 'width: 100%;')
            )
      );
      
file_upload('userfile''gallery''fm_gallery''coremain/module/gallery/gallery_update_output.php'$option);
      
      
button_text('Upload รูป''submit'2'userfile''กรุณาเลือกรูปที่จะอัพโหลด !');
    
?>
  </table>
</form>
<?php ?>

<table width='97%' border='0' cellpadding='0' cellspacing='0' align=center>
<?php
  $sql 
= ($_SESSION['admin_web']=="admin" || (id_top_permission("b"))) ?
          
"SELECT * FROM `port_gallery_record`  WHERE  id_topic='$id_update' order by id_record" :
          
"SELECT * FROM `port_gallery_record`  WHERE  id_topic='$id_update' and status='1' order by id_record";
  
$result=mysql_query($sql);
  
$count=2;
  
$num 0;
  while(
$data mysql_fetch_array($result)){
    
$count++;
    
$mots=$count%3;
    
//###################### คอลัมน์ที่ 1 ###############
    
if($mots==0){ ?>
  <tr>
    <td width=33% align=center>
      <a href="javascript:void(0);" class="show_image" id="<?= $num.'#'.$id_update ?>" style="text-decoration: none;">
        <img src="<?php echo "$_SESSION[web_name]/gallery/$data[pic]"?> " class="img-corner" / width='100' height='80'>
      </a>
    <?php
      
echo ($data['explain']!="") ? '<br/>'.$data['explain'] : "&nbsp;";
      
      if (
$_SESSION['admin_web'] == "admin" || ( id_top_permission("b"))) {
        
// show - hide
        
if ($data['status'] == '1') { ?>
          <br><a href='index.php?id_update=<?= $id_update ?>&mod=gallery_update&path=gallery&id_hide=<?= $data['id_record'?>&block=<?= $block ?>'><img src='coremain/images/show.gif' border='0' title='ซ่อน'></a>
        <?php } else { ?>
          <br><a href='index.php?id_update=<?= $id_update ?>&mod=gallery_update&path=gallery&id_show=<?= $data['id_record'?>&block=<?= $block ?>'><img src='coremain/images/hide.gif' border='0' title='แสดง'></a>
        <?php }
        
// delete ?>
        &nbsp;<a href='index.php?id_update=<?= $id_update ?>&mod=gallery_update&path=gallery&id_del=<?= $data['id_record'?>&block=<?= $block ?>' onclick='return goURL();'><img src='coremain/images/del1.gif' border='0' title='ลบข้อมูล'></a>
    <?php ?>
    </td>
  <?php }
    
//###################### คอลัมน์ที่ 2 ###############    
    
else if($mots==1){ ?>
    <td width=33% align=center>
      <a href="javascript:void(0);" class="show_image" id="<?= $num.'#'.$id_update ?>" style="text-decoration: none;">
        <img src="<?php echo "$_SESSION[web_name]/gallery/$data[pic]"?>" class="img-corner" / width='100' height='80'>
      </a>
    <?php
      
echo ($data['explain']!="") ? '<br/>'.$data['explain'] : "&nbsp;";
    
      
// Admin
      
if($_SESSION['admin_web']=="admin" || (id_top_permission("b"))){
        
// show - hide
        
if($data['status']=='1'){ ?>
          <br><a href='index.php?id_update=<?= $id_update ?>&mod=gallery_update&path=gallery&id_hide=<?= $data['id_record'?>&block=<?= $block ?>'><img src='coremain/images/show.gif' border='0' title='ซ่อน'></a>
        <?php }else{ ?>
          <br><a href='index.php?id_update=<?= $id_update ?>&mod=gallery_update&path=gallery&id_show=<?= $data['id_record'?>&block=<?= $block ?>'><img src='coremain/images/hide.gif' border='0' title='แสดง'></a>
        <?php }
            
// delete ?>
      &nbsp;<a href='index.php?id_update=<?= $id_update ?>&mod=gallery_update&path=gallery&id_del=<?= $data['id_record'?>&block=<?= $block ?>' onclick='return goURL();'><img src='coremain/images/del1.gif' border='0' title='ลบข้อมูล'></a>
      <?php ?>
    </td>
    <?php }
    
//###################### คอลัมน์ที่ 3 ###############    
    
else{ ?>
    <td width=33% align=center>
      <a href="javascript:void(0);" class="show_image" id="<?= $num.'#'.$id_update ?>" style="text-decoration: none;">
        <img src="<?php echo "$_SESSION[web_name]/gallery/$data[pic]"?>" class="img-corner" / width='100' height='80'>
      </a>
    <?php
      
echo ($data['explain']!="") ? '<br/>'.$data['explain'] : "&nbsp;";
      
      
// Admin
      
if($_SESSION['admin_web']=="admin" || (id_top_permission("b"))){
        
// show - hide
        
if($data['status']=='1'){ ?>
          <br><a href='index.php?id_update=<?= $id_update ?>&mod=gallery_update&path=gallery&id_hide=<?= $data['id_record'?>&block=<?= $block ?>'><img src='coremain/images/show.gif' border='0' title='ซ่อน'></a>
        <?php }else{ ?>
          <br><a href='index.php?id_update=<?= $id_update ?>&mod=gallery_update&path=gallery&id_show=<?= $data['id_record'?>&block=<?= $block ?>'><img src='coremain/images/hide.gif' border='0' title='แสดง'></a>
        <?php }
            
// delete ?>
          &nbsp;<a href='index.php?id_update=<?= $id_update ?>&mod=gallery_update&path=gallery&id_del=<?= $data['id_record'?>&block=<?= $block ?>' onclick='return goURL();'><img src='coremain/images/del1.gif' border='0' title='ลบข้อมูล'></a>
      <?php ?>
    </td>
  </tr>
  <tr height='20'><td></td><td></td></tr>
  <?php }
  ++
$num;
?>
</table>

<?php fieldset_down(); ?>


<script language="JavaScript">
  
  var arrData = [
    { name: 'web_name', value: '<?= $_SESSION['dbname'?>' },
    { name: 'folder', value: '<?= $_SESSION['web_name'?>' }
  ];
  $('.show_image').click(function(){
    var arr = $(this).attr('id').split('#');
    arrData.push({ name: 'startrow', value: arr[0]});
    arrData.push({ name: 'id_top', value: arr[1]});
    
    show_gallery(arrData);
  });
  
  function show_gallery(arrData){
    var dialog = 'dialog-popup';
    var popup = $('#'+dialog);
    showDialog(dialog);
    popup.dialog('option', 'title', 'รายละเอียด');
    
    $.ajax({
      type: 'post',
      url: 'coremain/module/gallery/gallery_show.php',
      data: arrData,
      success: function(result){
        popup.html(result);
      }
    });
  }
  
<!--
function goURL() {
var blnLink
blnLink = confirm("Click OK เพื่อยืนยันการลบข้อมูล?")
if (!blnLink) { return false; }
return true;
}
//-->    
</script>

<script language="javascript">
//function checkadd() {
//if(document.add.userfile1.value=="") {
//alert("กรุณาเลือกรูปที่จะอัพโหลด") ;
//document.add.userfile1.focus() ;
//return false ;}
//else 
//return true ;
//}
</script>