/home/banprang/domains/plai.go.th/public_html/coremain/module/gallery/gallery.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
<?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'] = "ภาพกิจกรรม";
  
navigator($navig);
  echo 
"<br>";
  
bar_header("ภาพกิจกรรม");
  
fieldset_top("ภาพกิจกรรม");
} else {
  
$navig['gallery'] = "ผลงานที่ผ่านมา";
  
navigator($navig);
  echo 
"<br>";
  
bar_header("ผลงานที่ผ่านมา");
  
fieldset_top("ผลงานที่ผ่านมา");
}
import_request_variables('pG''p_');
if(
$p_g_type!="")                                {         $g_type=trim($p_g_type);                                            }
if(
$p_yearthai!="")                                {         $yearthai=trim($p_yearthai);                                        }
if(
$p_id_hide!="")                                {         $id_hide=trim($p_id_hide);                                            }
if(
$p_id_show!="")                            {         $id_show=trim($p_id_show);                                        }
if(
$p_id_delsss!="")                            {         $id_delsss=trim($p_id_delsss);                                    }
if(
$p_startrow!="")                                {         $startrow=trim($p_startrow);                                        }
if(
$p_viewAsAnother!="")                {         $viewAsAnother=trim($p_viewAsAnother);                }


//###################### สำหรับ Admin
if ($_SESSION['admin_web'] == "admin" or ( id_top_permission("b"))) {
// Hide - Show news
  
if ($id_hide != "") {
    
$sql "UPDATE port_gallery_topic SET status='0'  WHERE id_topic='$id_hide'";
    
mysql_query($sql);
  }
  if (
$id_show != "") {
    
$sql "UPDATE port_gallery_topic SET status='1'  WHERE id_topic='$id_show'";
    
mysql_query($sql);
  }
// Delete port_gallery_topic
  
if ($id_delsss != "") {
    
// delete port_gallery_topic
    
$sql "delete from port_gallery_topic where id_topic='$id_delsss'";
    
$result mysql_query($sql);
    
// delete file 
    
$sql "SELECT pic FROM port_gallery_record WHERE id_topic='$id_delsss'";
    
$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]");
      }
    }
    
// delete port_gallery_record
    
$sql "delete from port_gallery_record  where id_topic='$id_delsss'";
    
$result mysql_query($sql);
  }
  if (
$_SESSION['check_size'] != "1") {
    
button_add("index.php?mod=gallery_add&path=gallery"); // Add_News
  
} else {
    echo 
"<br>";
  }
}

// ################################ภาพกิจกรรม ###################################
$row_per_page 10//กำหนดจำนวนบรรทัดต่อหน้า 
if ($_SESSION['admin_web'] == "admin" || ( id_top_permission("b"))) {
  
//$query = "SELECT DISTINCT a.id_topic, a . *  ,b.pic,a.block FROM `port_gallery_topic` AS a INNER JOIN port_gallery_record AS b ON a.id_topic = b.id_topic  GROUP BY a.id_topic ORDER BY a.id_topic DESC";
  
$query "SELECT a.*, b.pic FROM port_gallery_topic AS a LEFT JOIN port_gallery_record AS b ON a.id_topic = b.id_topic GROUP BY a.id_topic ORDER BY a.id_topic DESC";
  
//$query_count = "select count(a.id_topic) FROM `port_gallery_topic` AS a INNER JOIN port_gallery_record AS b ON a.id_topic = b.id_topic  GROUP BY a.id_topic ORDER BY a.id_topic DESC";
  
$query_count "SELECT count(id_topic) FROM port_gallery_topic";
} else {
//  $query = "SELECT DISTINCT a.id_topic, a . *  ,b.pic,a.block FROM `port_gallery_topic` AS a INNER JOIN port_gallery_record AS b ON a.id_topic = b.id_topic WHERE  a.status=1 GROUP BY a.id_topic ORDER BY a.id_topic DESC";
  
$query "SELECT a.*, b.pic FROM port_gallery_topic AS a LEFT JOIN port_gallery_record AS b ON a.id_topic = b.id_topic WHERE a.status = 1 GROUP BY a.id_topic ORDER BY a.id_topic DESC";
  
//$query_count = "select count(a.id_topic) FROM `port_gallery_topic` AS a INNER JOIN port_gallery_record AS b ON a.id_topic = b.id_topic WHERE  a.status=1 GROUP BY a.id_topic ORDER BY a.id_topic DESC";
  
$query_count "SELECT count(id_topic) FROM port_gallery_topic WHERE status = 1";
}

if (empty(
$startrow)) { //ลองตรวจดูว่าค่าแถวเริ่มต้นที่จะแสดงไม่ได้กำหนดหรือเปล่า ถ้าไม่ได้กำหนด จะกำหนดให้เป็น 0 
  
$startrow 0;
}

$result_count mysql_query($query_count);
$row mysql_fetch_array($result_count);

$total_row $row[0]; //ได้ค่าจำนวนบรรทัดทั้งหมดที่จะต้องแสดง 
$total_page intval((($total_row 1) / $row_per_page) + 1); //หาค่าจำนวนหน้าทั้งหมดที่ต้องแสดง 
$current_page = (($startrow) / $row_per_page) + 1//หาว่าหน้าที่แสดงอยู่ปัจจุบันเป็นหน้าที่เท่าไหร่ 
$count 0;
$result mysql_query($query " LIMIT $startrow,$row_per_page");
?>
<table width='97%' border='0' cellpadding='0' cellspacing='0' align='center'>
  <?php while ($data mysql_fetch_array($result)) { ?>
  <tr>
    <td width='20%' valign='top'>
    <?php
      
if ($data['pic'] != "") {
        
box_picture_firstpage("../gallery/$data[pic]""index.php?mod=gallery_update&id_update=$data[id_topic]&block=$data[block]&path=gallery");
      } else {
        
box_nopicture_firstpage("index.php?mod=gallery_update&id_update=$data[id_topic]&block=$data[block]&path=gallery");
      }
    
?>
    </td>
    <td width='3%' valign='top'></td>
    <td width='75%' height='100'  valign='top'>
      <img SRC='coremain/images/marker.gif'> <?= strip_tags($data['fulltexts']); ?>
    </td>
  </tr>
  <?php if ($_SESSION['admin_web'] == "admin" || ( id_top_permission("b"))) { ?>
  <tr>
    <td valign='top' align=center>
    <?php if ($data['status'] == '1') { ?>
      &nbsp;&nbsp;<a href='index.php?mod=gallery&path=gallery&id_hide=<?= $data['id_topic'?>'><img src='coremain/images/show.gif' border='0' title='ซ่อน'></a>
    <?php } else { ?>
      &nbsp; &nbsp;<a href='index.php?mod=gallery&path=gallery&id_show=<?= $data['id_topic'?>'><img src='coremain/images/hide.gif' border='0' title='แสดง'></a>
    <?php ?>
    <!--// update -->
    &nbsp;<a href='index.php?mod=gallery_edit&path=gallery&id_update=<?= $data['id_topic'?>'><img src='coremain/images/edit.gif' border='0' title='แก้ไขข้อมูล'></a>
    <!--// delete -->
    &nbsp; <a href='index.php?mod=gallery&path=gallery&id_delsss=<?= $data['id_topic'?>' onclick='return goURL();'><img src='coremain/images/del1.gif' border='0' title='ลบข้อมูล'></a>
    </td>
  </tr>
<?php
    
}
  }
?>
</table>

<?php
if ($total_page 1) { //ตรวจดูว่าถ้าจำนวนหน้าทั้งหมดมีไม่เกิน 1 หน้า ต้องแสดงบรรทัดที่จะให้เลือกหน้า 
  
$previous_page $current_page 1//หาว่าหน้าก่อนหน้าปัจจุบันคือหน้าอะไร 
  
$next_page $current_page 1//หาว่าหน้าถัดจากหน้าปัจจุบันคืออะไร 
  
if ($previous_page 0) { //ถ้าหน้าก่อนหน้าติดลบหรือเป็นศูนย์แสดงว่าไม่สามารถแสดงหน้าก่อนหน้าได้ 
    
$new_startrow $startrow $row_per_page;
    
$left_page_show "<A HREF=index.php?mod=gallery&path=gallery&startrow=$new_startrow><b>ก่อนหน้า</b></A> ";
  } else {
    
$left_page_show "<b><font color='$datatm[color1]'>ก่อนหน้า</font></b> ";
  }
  if (
$next_page $total_page) { //ถ้าหน้าถัดไป มากกว่าจำนวนหน้าทั้งหมด แสดงว่าไม่สามารถแสดงหน้าถัดไปได้ 
    
$right_page_show " <b><font color='$datatm[color1]'>ต่อไป</font></b>";
  } else {
    
$new_startrow $startrow $row_per_page;
    
$right_page_show " <A HREF=index.php?mod=gallery&path=gallery&startrow=$new_startrow><b>ต่อไป</b></A>";
  }

  
$middle_page_show "";
  for (
$i 1$i <= $total_page$i++) { //วนลูปแสดงหน้าทั้งหมด 
    
if ($i == $current_page) { //ถ้าหน้าที่พิมพ์เป็นหน้าเดียวกับหน้าปัจจุบัน แสดงให้ไม่สามารถคลิ๊กได้ 
      
$middle_page_show .= " <font color='ff0000'><b>[</font><font color='$datatm[color1]'>$i</font><font color='ff0000'>]</font></b> ";
    } else {
      
$new_startrow = (($i 1) * $row_per_page);
      
$middle_page_show .= " <A HREF=index.php?mod=gallery&path=gallery&startrow=$new_startrow> <b>$i</b> </A> ";
    }
  }
  
$page_show $left_page_show $middle_page_show $right_page_show;
} else {
  
$page_show "";
}
echo 
"<br>&nbsp;<font color='0000ff'>$page_show</font>";

fieldset_down();
?>
<script language="JavaScript">
<!--
function goURL() {
var blnLink
blnLink = confirm("Click OK เพื่อยืนยันการลบข้อมูล?")
if (!blnLink) { return false; }
return true;
}
//-->    
</script>