<?php
/*!
* Copyright Anucha Puangpaka
* Contacts anucha.ppk@icloud.com 062-479-9836
*/
include('head.php');
if($GLOBALS["nav"]!="firefox"){
/*include('object.php');*/
}
$xsites = "$ap_site$ap_folder";
?>
<main>
<div class="body-main-row-body container theme-showcase" role="main">
<?php
if (empty($_GET['nu']) && empty($_GET['gal_cat']) && empty($_GET['gal2_cat']) && empty($_GET['gal']) && empty($_GET['gal2']) && empty($_GET['page_id']) && empty($_GET['cat']) && empty($_GET['banners']) && empty($_GET['stats'])) {
$dt = date('Ymd');
if($_GET['ap']==""){
include("$themes");
}else{
include($_GET['ap']);
}
}
// Catalogs
if (!empty($_GET['cat'])) {
if ($_GET['api']>0){
include('modify-cat-API.php');
}else{
// $_GET['lang'] = mysqli_real_escape_string($conn, $_GET['lang']);
// $_GET['cat'] = mysqli_real_escape_string($conn, $_GET['cat']);
if($_GET['cat']=='all'){
$sql = "select * from ap_catalogs where lang='$_GET[lang]'";
}else{
$sql = "select * from ap_catalogs where lang='$_GET[lang]' and code='$_GET[cat]'";
}
$query = mysqli_query($conn,$sql);
$rows = mysqli_fetch_array($query);
if(!empty($_GET['q'])){
wordcloud("$_GET[q]");
}else{
if($_GET['cat']=='all'){
wordcloud("คลังข้อมูล");
}else{
wordcloud("$rows[name]");
}
}
$s_id = session_id();
$views_catalogs = $s_id.$rows['id'];
if ($_SESSION['views_catalogs'] != ($s_id.$rows['id'])) {
$_SESSION['views_catalogs'] = $views_catalogs;
if (empty($rows['counters'])) {
$rows['counters'] = 0;
}
$c = $rows['counters']+1;
mysqli_query($conn,"update ap_catalogs set counters='$c' where id='$rows[id]'");
}
$query = mysqli_query($conn,$sql);
$rows = mysqli_fetch_array($query);
?>
<div class="breadcrumbx">
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-12">
<ul class="breadcrumb" itemscope="" itemtype="http://schema.org/BreadcrumbList">
<li itemprop="itemListElement" itemscope="" itemtype="http://schema.org/ListItem">
<a href="<?php echo $_SERVER['SERVER_SCRIPT'] ?>?lang=<?php echo $_GET['lang'] ?>" itemprop="item">
<span itemprop="name"><?php echo $ap_home; ?></span>
</a>
<meta itemprop="position" content="1">
</li>
<li itemprop="itemListElement" itemscope="" itemtype="http://schema.org/ListItem">
<?php if($ap_rewrite=="on"){ ?>
<a href="<?php echo $ap_site.$ap_folder; ?>cat/<?php echo $_GET['cat']; ?>/<?php echo $_GET['lang']; ?>" itemprop="item" title="<?php echo $rows['name'] ?>">
<?php }else{ ?>
<a href="<?php echo $_SERVER['SERVER_SCRIPT'] ?>?cat=<?php echo $_GET['cat']; ?>&lang=<?php echo $_GET['lang']; ?>" itemprop="item" title="<?php echo $rows['name'] ?>">
<?php } ?>
<span itemprop="name"><?php echo $rows['name'] ?></span>
</a>
<meta itemprop="position" content="2">
</li>
</ul>
<p></p>
</div>
<div class="col-lg-4 col-md-4 col-sm-12">
<form class="form-inline text-right" action="<?php echo $_SERVER[SCRIPT_NAME]; ?>" method="GET">
<input type="hidden" name="cat" value="<?php echo $_GET['cat'] ?>">
<div class="form-group">
<input type="text" name="q" value="<?php echo $_GET['q']; ?>" placeholder="ระบุคำค้น" class="form-control" autofocus>
</div>
<button type="submit" class="btn btn-default">ค้นหา</button>
</form>
</div>
</div>
<div class="row"><div class="col-lg-12 col-md-12 col-sm-12"><hr></div></div>
<!-- <div class="row"> -->
<!-- <div class="col-lg-12 col-md-12 col-sm-12"> -->
<?php
if($_GET['cat']=='all'){
$sql2 = "select * from ap_pages where lang='$_GET[lang]' and (title like '%$_GET[q]%' or keywords like '%$_GET[q]%')";
}else{
$sql2 = "select * from ap_pages where lang='$_GET[lang]' and (catalogCode='$rows[code]')";
}
$query2 = mysqli_query($conn,$sql2);
$num_rows2 = mysqli_num_rows($query2);
$per_page = 10;
$page = 1;
if(isset($_GET["Page"])){
$page = $_GET["Page"];
}
$prev_page = $page-1;
$next_page = $page+1;
$row_start = (($per_page*$page)-$per_page);
if($num_rows2<=$per_page){
$num_pages = 1;
}elseif(($num_rows2 % $per_page)==0){
$num_pages = ($num_rows2/$per_page) ;
}else{
$num_pages =($num_rows2/$per_page)+1;
$num_pages = (int)$num_pages;
}
/*$row_end = $per_page * $page;
if($row_end > $num_rows2){
$row_end = $num_rows2;
}*/
$row_end = $per_page;
$sql2 .= " order by date_time desc limit $row_start, $row_end";
$query2 = mysqli_query($conn,$sql2);
$i2 = (($row_start/$per_page)*$per_page);
while ($rows2 = mysqli_fetch_array($query2)) {
$i2++;
/*$filename = "$ap_site$ap_folder"."contents/pdf/pages/$rows2[id].pdf";
$file_headers = @get_headers($filename);
if($file_headers[0] == 'HTTP/1.1 404 Not Found') {*/
if(!empty($rows2['images2_status'])){
?>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<h1 class="media-heading h5"><i class="fas fa-bullhorn"></i> <?php echo $i2; ?>. <a href="<?php echo $rows2['images2']?>" target="_blank" title="<?php echo $rows2['title']; ?>"><?php echo $rows2['title']?></a> <?php if($i2<=3){ ?><img src="contents/images/new.gif" width="24" alt="<?php echo $rows2['title']; ?>"><?php } ?> [<?php echo dateThai($rows2['date_time']); ?>] </h1>
</div>
<p></p>
</div>
<?php /* ?><div class="col-lg-12 col-md-12 col-sm-12 <?php if ($i2 > 5) { echo "slideanimx"; } ?>">
<p>
<i class="fas fa-bullhorn"></i> <?php echo $ap_num.' '.$i2; ?>.
<?php if($ap_rewrite=="on"){ ?>
<a href="<?php echo $ap_site.$ap_folder; ?>page_id/<?php echo $rows2['id']?>/<?php echo $_GET['lang']?>" target="_blank">
<?php }else{ ?>
<a href="?page_id=<?php echo $rows2['id']?>&lang=<?php echo $_GET['lang']?>" target="_blank">
<?php } ?>
<b><?php echo $rows2['title']?></b></a>
</p>
<p class="featurette-heading">
<?php echo $ap_publish; ?> <?php echo dateThai($rows2['date_time'])?> <?php echo $ap_visits; ?> <?php echo number_format($rows2['counters'])?>
<?php if($ap_rewrite=="on"){ ?>
<a class="btn-floating btn-fb" href="javascript:void(0);" onClick="window.open('https://www.facebook.com/sharer.php?u=<?php echo urlencode("$ap_site$ap_folder"."page_id/$rows2[id]/$rows2[lang]"); ?>','facebook','scrollbars=yes,resizable=yes,width=1000,height=600')">
<?php }else{ ?>
<a class="btn-floating btn-fb" href="javascript:void(0);" onClick="window.open('https://www.facebook.com/sharer.php?u=<?php echo urlencode("$ap_site$ap_folder?page_id=$rows2[id]&lang=$rows2[lang]"); ?>','facebook','scrollbars=yes,resizable=yes,width=1000,height=600')">
<?php } ?>
<i class="fas fa-share text-danger"> Share </i>
</a>
</p>
<!-- <div class="fb-share-button" data-href="<?php echo $ap_site.$ap_folder?>?page_id=<?php echo $rows2['id']?>" data-layout="button_count"></div> -->
<!-- <hr> -->
<!-- <p class="lead"><?php echo $rows2['info2']?></p> -->
<!-- <p class="lead" align="right"><?php if (!empty($rows2['images2'])) {echo "<a href='contents/images/$rows2[images2]' target='new'>เอกสารประกอบ</a>";}?></p> -->
</div>
<div class="col-lg-12 col-md-12 col-sm-12 <?php if ($i2 > 5) {echo "slideanimx";}?>"><hr class="ap_hr"></div>
</div><?php */ ?>
<?php
}else{
?>
<!-- <div class=" row <?php if ($i2 > 1) {echo "slideanimx";}?>"> -->
<div class="row">
<div class="col-lg-9 col-md-9 col-sm-12 <?php if ($i2 > 5) {echo "slideanimx";}?>">
<h1 class="h5">
<i class="fas fa-bullhorn"></i> <?php echo $ap_num.' '.$i2; ?>.
<?php if($ap_rewrite=="on"){ ?>
<a href="<?php echo $ap_site.$ap_folder; ?>page_id/<?php echo $rows2['id']?>/<?php echo $_GET['lang']?>" target="_blank" title="<?php echo $rows2['title']; ?>">
<?php }else{ ?>
<a href="?page_id=<?php echo $rows2['id']?>&lang=<?php echo $_GET['lang']?>" target="_blank" title="<?php echo $rows2['title']; ?>">
<?php } ?>
<b><?php echo $rows2['title']?></b></a>
</h1>
<p class="featurette-heading">
<?php echo $ap_publish; ?> <?php echo date_reformat($rows2['date_time'])?> <?php echo $ap_visits; ?> <?php echo number_format($rows2['counters'])?>
<?php if($ap_rewrite=="on"){ ?>
<a class="btn-floating btn-fb" href="javascript:void(0);" onClick="window.open('https://www.facebook.com/sharer.php?u=<?php echo urlencode("$ap_site$ap_folder"."page_id/$rows2[id]/$rows2[lang]"); ?>','facebook','scrollbars=yes,resizable=yes,width=1000,height=600')" title="Facebook share">
<?php }else{ ?>
<a class="btn-floating btn-fb" href="javascript:void(0);" onClick="window.open('https://www.facebook.com/sharer.php?u=<?php echo urlencode("$ap_site$ap_folder?page_id=$rows2[id]&lang=$rows2[lang]"); ?>','facebook','scrollbars=yes,resizable=yes,width=1000,height=600')" title="Facebook share">
<?php } ?>
<i class="fas fa-share text-danger"> Share </i></a></p>
<!-- <div class="fb-share-button" data-href="<?php echo $ap_site.$ap_folder?>?page_id=<?php echo $rows2['id']?>" data-layout="button_count"></div> -->
<!-- <hr> -->
<p class="lead"><?php echo $rows2['info2']?></p><!-- <p class="lead" align="right"><?php if (!empty($rows2['images2'])) {echo "<a href='contents/images/$rows2[images2]' target='new' title='เอกสารประกอบ'>เอกสารประกอบ</a>";}?></p> -->
</div>
<div class="col-lg-3 col-md-3 col-sm-12 <?php if ($i2 > 5) {echo "slideanimx";}?>">
<?php
$images = str_replace("$ap_site$ap_folder/", "", $rows2['images']);
$apExp = explode("/", $images);
$apCount = count($apExp);
$images2 = $apExp[($apCount-1)];
$dir = str_replace($images2, "", $images);
if($ap_webp=="on"){
$im = explode(".", $images2);
$images2 = "$im[0].webp";
}
mkdir($dir.'thumbs/', 0777, true);
if(!file_exists("$dir/thumbs/thumb_m_$images2")){
$size = getimagesize("$images");
resize($size[0], "$dir/thumbs/thumb_m_$images2","$images");
}
?>
<p>
<?php if($ap_rewrite=="on"){ ?>
<a href="page_id/<?php echo $rows2['id']?>/<?php echo $_GET['lang']?>" target="_blank" title="<?php echo $rows2['title']; ?>">
<?php }else{ ?>
<a href="?page_id=<?php echo $rows2['id']?>&lang=<?php echo $_GET['lang']?>" target="_blank" title="<?php echo $rows2['title']; ?>">
<?php } ?>
<img class="img-thumbnail" width="100%" src="<?php if($rows2['images']==""){ echo $logo; }else{ echo "$dir/thumbs/thumb_m_$images2"; } ?>" alt="<?php echo $rows2['title']?>" title="<?php echo $rows2['title']?>"></a>
</p>
</div>
</div>
<?php
if($rows2['gallery_status']==1){
echo "<div class='row'>";
echo "<div class='col-lg-12 col-md-12 col-sm-12'><p></p></div>";
$allowed_types = array('JPG','jpg','JPEG','jpeg','GIF','gif','PNG','png','WEBP','webp');
$sql_g = "select * from ap_gallery where id='$rows2[galleryID]'";
$query_g = mysqli_query($conn,$sql_g);
$num_rows_g = mysqli_num_rows($query_g);
if($num_rows_g>0){
$query_g2 = mysqli_query($conn,$sql_g);
while($rows_g2 = mysqli_fetch_array($query_g2)){
if($rows_g2['createByStatus']=="Admin"){
$dir = "contents/gallery/$rows_g2[code]/";
}else{
$dir = "contents/$rows_g2[createBy]/$rows_g2[code]/";
}
mkdir($dir.'thumbs/', 0777, true);
$files1 = scandir($dir);
$total = 0;
$pic_path = array();
foreach($files1 as $key=>$value){
if($key>0){
$file_parts = explode('.',$value);
$ext = strtolower(array_pop($file_parts));
if(in_array($ext,$allowed_types)){
$pic_path[] = $dir.$value;
$pic_path2[] = $value;
$total++;
}
}
}
if($total>3){
$ximg_start = 0;
$ximg_end = 4;
}else{
$ximg_start = 0;
$ximg_end = 4;
}
for($indexPicture = $ximg_start; $indexPicture<$ximg_end; $indexPicture++){
$images = $pic_path[$indexPicture];
$images2 = $pic_path2[$indexPicture];
if($ap_webp=="on"){
$im = explode(".", $images2);
$images2 = "$im[0].webp";
}
if(!empty($images)){
if(!file_exists("$dir/thumbs/thumb_m_$images2")){
$size = getimagesize("$images");
resize($size[0], "$dir/thumbs/thumb_m_$images2","$images");
}
/*if(!file_exists("$dir/thumbs/thumb_s_$images2")){
resize(100, "$dir/thumbs/thumb_s_$images2","$images");
}*/
?>
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-6">
<div class="panel2 panel2-default">
<div class="panel2-body" style="max-width: 100%;">
<!-- <div class="panel2-body" style="max-width: 100%;"> -->
<p>
<?php if($ap_rewrite=="on"){ ?>
<a class="zoom" data-type="image" data-title="<?php echo $rows_g2['name']?>" data-footer="<?php echo $rows_g2['name']?>" data-toggle="lightbox" href="page_id/<?php echo $rows2['id'] ?>/<?php echo $_GET['lang']?>" target="_blank" title="<?php echo $rows_g2['name']; ?>">
<?php }else{ ?>
<a class="zoom" data-type="image" data-title="<?php echo $rows_g2['name']?>" data-footer="<?php echo $rows_g2['name']?>" data-toggle="lightbox" href="?page_id=<?php echo $rows2['id'] ?>&lang=<?php echo $_GET['lang']?>" target="_blank" title="<?php echo $rows_g2['name']?>">
<?php } ?>
<img class="img-thumbnail" src="<?php echo "$dir/thumbs/thumb_m_$images2"; ?>" width="100%" alt="<?php echo ($indexPicture+1).'. '.$rows_g2['name']?>" title="<?php echo ($indexPicture+1).'. '.$rows_g2['name']?>">
<?php /* ?><img class="img-thumbnail" src="images.php?nu=&xwidth=300&ximg=<?php echo $images?>" width="100%" alt="<?php echo ($indexPicture+1).'. '.$rows_g2['name']?>" title="<?php echo ($indexPicture+1).'. '.$rows_g2['name']?>"><?php */ ?>
</a><p>
<span class="overlay"></span>
</div>
</div>
<p></p>
</div>
<?php
}
}
}
}
echo "</div>";
}
}
/*if($i2 %2==0){
echo "</div></div><div class='row'><div class='col-lg-12 col-md-12 col-sm-12'>";
}*/
/*}*/
?>
<div class="row"><div class="col-lg-12 col-md-12 col-sm-12 <?php if ($i2 > 5) {echo "slideanimx";}?>"><hr></div></div>
<?php
}
?>
<div class="text-right">
<p><strong><?php echo number_format($num_rows2);?> รายการ : <?php echo $num_pages;?> หน้า</strong></p>
<ul class="pagination justify-content-end">
<?php
if($prev_page){
echo "<li class=\"page-item\"><a class=\"page-link\" href='$_SERVER[SCRIPT_NAME]?cat=$_GET[cat]&Page=1&q=$_GET[q]&lang=$_GET[lang]' title='First page'>หน้าแรก</a></li>";
echo "<li class=\"page-item\"><a class=\"page-link\" href='$_SERVER[SCRIPT_NAME]?cat=$_GET[cat]&Page=$prev_page&q=$_GET[q]&lang=$_GET[lang]' title='Previous page'><< ย้อนกลับ</a></li>";
}
for($i=1; $i<=$num_pages; $i++){
if ($i > ($_GET['Page']-6) && $i < ($_GET['Page']+6)) {
if($i != $page){
echo "<li class=\"page-item\"><a class=\"page-link\" href='$_SERVER[SCRIPT_NAME]?cat=$_GET[cat]&Page=$i&q=$_GET[q]&lang=$_GET[lang]' title='$i'>$i</a></li>";
}else{
echo "<li class=\"page-item active\"><a class=\"page-link\" href=\"$_SERVER[SCRIPT_NAME]?cat=$_GET[cat]&Page=$_GET[Page]&q=$_GET[q]&lang=$_GET[lang]#\" title='$i'>$i</a></li>";
}
}
}
if($page!=$num_pages){
echo "<li class=\"page-item\"><a class=\"page-link\" href='$_SERVER[SCRIPT_NAME]?cat=$_GET[cat]&Page=$next_page&q=$_GET[q]&lang=$_GET[lang]' title='Next page'>ถัดไป>></a></li>";
echo "<li class=\"page-item\"><a class=\"page-link\" href='$_SERVER[SCRIPT_NAME]?cat=$_GET[cat]&Page=$num_pages&q=$_GET[q]&lang=$_GET[lang]' title='Last page'>หน้าสุดท้าย</a></li>";
}
?>
</ul>
</div>
</div>
<!-- </div> -->
<!-- </div> -->
<?php
}
}
// Pages
if (!empty($_GET['page_id'])) {
if ($_GET['api']>0){
include('modify-pages-API.php');
}else{
// $_GET['page_id'] = mysqli_real_escape_string($conn, $_GET['page_id']);
$sql = "select * from ap_pages where id='$_GET[page_id]'";
$query = mysqli_query($conn,$sql);
$rows = mysqli_fetch_array($query);
wordcloud($rows['title']);
$sql2 = "select * from ap_catalogs where lang='$rows[lang]' and code='$rows[catalogCode]'";
$query2 = mysqli_query($conn,$sql2);
$rows2 = mysqli_fetch_array($query2);
$sqlu = "select * from ap_users where user='$rows_pid[createBy]'";
$queryu = mysqli_query($conn,$sqlu);
$rowsu = mysqli_fetch_array($queryu);
$s_id = session_id();
$views_pages = $s_id.$rows['id'];
if ($_SESSION['views_pages'] != ($s_id.$rows['id'])) {
$_SESSION['views_pages'] = $views_pages;
if (empty($rows['counters'])) {$rows['counters'] = 0;}
$c = $rows['counters']+1;
mysqli_query($conn,"update ap_pages set counters='$c' where id='$rows[id]'");
}
$query = mysqli_query($conn,$sql);
$rows = mysqli_fetch_array($query);
if($_GET['pdf']==1){
//if($rows['counters']<3){
require_once('mpdf/mpdf.php');
$header = "
<table width=\"100%\" style=\"border-bottom: 1px solid #000000; color: #000088;\">
<tr>
<td width=\"50\"><a href='$ap_site$ap_folder' title='$title'><img src=\"$logo\" style=\"width: 50px\" alt=\"\"></a></td>
<td><font class=\"style1\">$title</font><br><font class=\"style4\">$title_en</font></span></td>
</tr>
</table>";
$today = date('Y-m-d H:i:s');
$footer = "
<table width=\"100%\" style=\"border-bottom: 0px solid #000000; color: #000088;\">
<tr>
<td></td>
<td align=\"right\"><font class=\"style4\">
<p>$ap_page {PAGENO}</p>
<p>$title<br></p>
<p>$ap_expire : ".date('Y-m-d H:i:s',strtotime("$today +1 month"))."</p>
</font></td>
</tr>
</table>";
$html = "
<p><span class=\"style2\">$ap_title</span> $rows[title]</p>";
if($rows['images']!=""){
$html .= "<p align=\"center\"><img src=\"$rows[images]\" style=\"width: 400px\"></p>";
}
$html .= "<p><span class=\"style2\">$ap_description</span><br>
<span class=\"style3\">$rows[info]</span></p>
<p><span class=\"style3\">$ap_report : $rowsu[fullname]</span><br>
<span class=\"style3\">$ap_date : ".substr($rows['date_time'],0,4)."-".substr($rows['date_time'],4,2)."-".substr($rows['date_time'],6,2)."</span><br>";
if($ap_rewrite=="on"){
$html .= "<a href=\"$ap_site$ap_folder"."page_id/$_GET[page_id]/$_GET[lang]\">$ap_site$ap_folder"."page_id/$_GET[page_id]/$_GET[lang]</a>";
}else{
$html .= "<a href=\"$ap_site$ap_folder?page_id=$_GET[page_id]&lang=$_GET[lang]\">$ap_site$ap_folder?page_id=$_GET[page_id]&lang=$_GET[lang]</a>";
}
/*ob_start();
$html = ob_get_contents();
ob_end_clean();*/
/*if($rows['counters']<3){*/
/*$filename = "$ap_site$ap_folder"."contents/pdf/pages/$_GET[page_id].pdf";
$file_headers = @get_headers($filename);
if($file_headers[0] == 'HTTP/1.1 404 Not Found') {*/
$pdf = new mPDF('th', 'A4', '0', '', 20, 15, 30, 35);
$pdf->mirrorMargins = 1;
$pdf->SetDisplayMode('fullpage');
$stylesheet = file_get_contents('theme.css');
$pdf->WriteHTML($stylesheet,1);
$pdf->SetHTMLHeader($header);
$pdf->SetHTMLHeader($header,'E');
$pdf->SetHTMLFooter($footer);
$pdf->SetHTMLFooter($footer,'E');
$pdf->SetWatermarkText("$ap_watermark");
$pdf->watermark_font = 'DejaVuSansCondensed';
$pdf->showWatermarkText = true;
$pdf->SetTitle("$rows[title]");
$pdf->SetAuthor("$title");
$pdf->SetCreator("$rows_u[fullname]");
$pdf->SetSubject("$rows[title]");
$pdf->SetKeywords("$rows[keywords]");
$pdf->WriteHTML($html, 2);
$pdf->Output("contents/pdf/pages/$_GET[page_id].pdf");
echo "<meta http-equiv='refresh' content='0;URL=$ap_site$ap_folder"."contents/pdf/pages/$_GET[page_id].pdf'>";
/*}*/
/*}else{
$filename = "$ap_site$ap_folder"."contents/pdf/pages/$_GET[page_id].pdf";
$file_headers = @get_headers($filename);
if($file_headers[0] == 'HTTP/1.1 404 Not Found') {
$pdf = new mPDF('th', 'A4', '0', '', 20, 15, 30, 20);
$pdf->mirrorMargins = 1;
$pdf->SetDisplayMode('fullpage');
$stylesheet = file_get_contents('theme.css');
$pdf->WriteHTML($stylesheet,1);
$pdf->SetHTMLHeader($header);
$pdf->SetHTMLHeader($header,'E');
$pdf->SetHTMLFooter($footer);
$pdf->SetHTMLFooter($footer,'E');
$pdf->SetWatermarkText("$title_en");
$pdf->watermark_font = 'DejaVuSansCondensed';
$pdf->showWatermarkText = true;
$pdf->SetTitle("$rows[title]");
$pdf->SetAuthor("$title");
$pdf->SetCreator("$rows_u[fullname]");
$pdf->SetSubject("$rows[title]");
$pdf->SetKeywords("$rows[keywords]");
$pdf->WriteHTML($html, 2);
$pdf->Output("contents/pdf/pages/$_GET[page_id].pdf");
}
}*/
}
?>
<div <?php if($_GET['box']==""){ ?> class="breadcrumbx" <?php } ?>>
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-12">
<ul class="breadcrumb" itemscope="" itemtype="http://schema.org/BreadcrumbList">
<li itemprop="itemListElement" itemscope="" itemtype="http://schema.org/ListItem">
<a href="<?php echo $_SERVER['SERVER_SCRIPT'] ?>?lang=<?php echo $_GET['lang'] ?>" itemprop="item" title="<?php echo $ap_home; ?>">
<span itemprop="name"><?php echo $ap_home; ?></span>
</a>
<meta itemprop="position" content="1">
</li>
<li itemprop="itemListElement" itemscope="" itemtype="http://schema.org/ListItem">
<?php if($ap_rewrite=="on"){ ?>
<a href="cat/<?php echo $rows['catalogCode'] ?>/<?php echo $_GET['lang'] ?>" itemprop="item" title="<?php echo $rows2['name']; ?>">
<?php }else{ ?>
<a href="<?php echo $_SERVER['SERVER_SCRIPT'] ?>?cat=<?php echo $rows['catalogCode'] ?>&lang=<?php echo $_GET['lang'] ?>" itemprop="item" title="<?php echo $rows2['name']; ?>">
<?php } ?>
<span itemprop="name"><?php echo $rows2['name'] ?></span>
</a>
<meta itemprop="position" content="2">
</li>
</ul>
<p></p>
</div>
<div class="col-lg-4 col-md-4 col-sm-12">
<form class="form-inline text-right" action="<?php echo $_SERVER[SCRIPT_NAME]; ?>" method="GET">
<input type="hidden" name="cat" value="all">
<div class="form-group">
<input type="text" name="q" value="<?php echo $_GET['q']; ?>" placeholder="ระบุคำค้น" class="form-control" autofocus>
</div>
<button type="submit" class="btn btn-default">ค้นหา</button>
</form>
</div>
</div>
<div class="row"><div class="col-lg-12 col-md-12 col-sm-12"><hr></div></div>
<div class="row">
<?php
if (empty($rows['images'])) {
?>
<div class="col-lg-12 col-md-12 col-sm-12">
<?php
} else {
?>
<div class="col-lg-8 col-md-8 col-sm-12">
<?php
if(!empty($rows['images'])){
$images = str_replace("$ap_site$ap_folder/", "", $rows['images']);
$apExp = explode("/", $images);
$apCount = count($apExp);
$images2 = $apExp[($apCount-1)];
$dir = str_replace($images2, "", $images);
if($ap_webp=="on"){
$im = explode(".", $images2);
$images2 = "$im[0].webp";
}
mkdir($dir.'thumbs/', 0777, true);
if(!file_exists("$dir/thumbs/thumb_l_$images2")){
$size = getimagesize("$images");
resize($size[0], "$dir/thumbs/thumb_l_$images2","$images");
}
$sizeImg = getimagesize("$dir/thumbs/thumb_l_$images2");
$widthImg = $sizeImg['0'];
$heightImg = $sizeImg['1'];
$imagesA = "$ap_site$ap_folder".str_replace("//", "/", "$dir/thumbs/thumb_l_$images2");
?>
<p>
<a href="<?php echo $rows['images']?>" class="fancybox" data-fancybox-group="gallery" title="<?php echo $rows['title']?>">
<img src="<?php echo $imagesA; ?>" width="100%" alt="<?php echo $rows['title']?>" title="<?php echo $rows['title']?>">
</a>
</p>
<p>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
<i class="fas fa-download"></i> <a href="<?php echo $rows['images']; ?>" target="_blank" title="<?php echo $ap_download; ?>"><?php echo $ap_download; ?></a>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 text-right">
<?php fb_like(substr("$ap_site",0,-1)."$_SERVER[REQUEST_URI]"); ?>
</div>
</div>
</p>
<?php
}
}
if ($_GET['box']=="") {
?>
<h1 class="h3"><i class="fas fa-bullhorn"></i> <?php echo $rows['title']?></h1>
<?php
}else{
?>
<p></p>
<h1 class="h3"><i class="fas fa-bullhorn"></i> <?php echo $rows['title']?></h1>
<?php
}
?>
<?php /* ?><p><?php echo $ap_publish; ?> <?php echo date_reformat($rows['date_time'])?> <?php echo $ap_visits; ?> <?php echo number_format($rows['counters'])?></p><?php */ ?>
<?php
$xlen = $rows['likes'];
if($xlen<=10){
$xl = "<i class=\"fa fa-star\" style=\"font-size:18px;color:#e6c12f\"></i>";
}elseif($xlen>10 && $xlen<=20){
$xl = "<i class=\"fa fa-star\" style=\"font-size:18px;color:#e6c12f\"></i>
<i class=\"fa fa-star\" style=\"font-size:18px;color:#e6c12f\"></i>";
}elseif($xlen>20 && $xlen<=30){
$xl = "<i class=\"fa fa-star\" style=\"font-size:18px;color:#e6c12f\"></i>
<i class=\"fa fa-star\" style=\"font-size:18px;color:#e6c12f\"></i>
<i class=\"fa fa-star\" style=\"font-size:18px;color:#e6c12f\"></i>";
}elseif($$xlen>30 && $xlen<=40){
$xl = "<i class=\"fa fa-star\" style=\"font-size:18px;color:#e6c12f\"></i>
<i class=\"fa fa-star\" style=\"font-size:18px;color:#e6c12f\"></i>
<i class=\"fa fa-star\" style=\"font-size:18px;color:#e6c12f\"></i>
<i class=\"fa fa-star\" style=\"font-size:18px;color:#e6c12f\"></i>";
}elseif($xlen>40){
$xl = "<i class=\"fa fa-star\" style=\"font-size:18px;color:#e6c12f\"></i>
<i class=\"fa fa-star\" style=\"font-size:18px;color:#e6c12f\"></i>
<i class=\"fa fa-star\" style=\"font-size:18px;color:#e6c12f\"></i>
<i class=\"fa fa-star\" style=\"font-size:18px;color:#e6c12f\"></i>
<i class=\"fa fa-star\" style=\"font-size:18px;color:#e6c12f\"></i>";
}else{
$xl = "";
}
?>
<div class="justify-content-center" id="results_pagesLike_<?php echo $rows[id]; ?>">
<?php echo $ap_publish ?> <?php echo dateThai($rows['date_time'])?> <?php echo "<a onclick=\"pagesLike_$rows[id]();\" title=\"Like\"><i class=\"far fa-thumbs-up\" style=\"font-size:18px;color:blue\"></i></a> ".number_format($rows['likes'])." $xl"; if($rows['counters']>0){ ?><i class="fa fa-signal" style="font-size:18px;color:red"></i> <span class="badge bg-success text-white"><?php echo number_format($rows['counters']) ?></span><?php } ?>
<?php if($ap_rewrite=="on"){ ?>
<a class="btn-floating btn-fb" href="javascript:void(0);" onClick="window.open('https://www.facebook.com/sharer.php?u=<?php echo urlencode("$ap_site$ap_folder"."page_id/$rows[id]/$rows[lang]"); ?>','facebook','scrollbars=yes,resizable=yes,width=1000,height=600')" title="Facebook share">
<?php }else{ ?>
<a class="btn-floating btn-fb" href="javascript:void(0);" onClick="window.open('https://www.facebook.com/sharer.php?u=<?php echo urlencode("$ap_site$ap_folder?page_id=$rows[id]&lang=$rows[lang]"); ?>','facebook','scrollbars=yes,resizable=yes,width=1000,height=600')" title="Facebook share">
<?php } ?>
<i class="fas fa-share text-danger"> Share </i></a>
</div>
<script type="text/javascript">
// Modify Anucha Puangpaka
function pagesLike_<?php echo $rows['id']; ?>(){
(function($){
$.fn.loaddata = function(options) {
var settings = $.extend({
loading_gif_url : "contents/images/loader.gif",
end_record_text : '',
data_url : 'fetch-pages-like.php',
id : '<?php echo $rows['id']; ?>',
lang : '<?php echo $_GET['lang']; ?>',
start_page : 1
}, options);
var el = this;
loading = false;
end_record = false;
contents(el, settings);
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() >= $(document).height()){
contents(el, settings);
}
});
};
function contents(el, settings){
var load_img = $('<img/>').attr('src',settings.loading_gif_url).addClass('loading-image');
var record_end_txt = $('<div/>').text(settings.end_record_text).addClass('end-record-info');
if(loading == false && end_record == false){
loading = true;
//el.append(load_img);
$.post(settings.data_url, {'page': settings.start_page,'id': settings.id,'lang': settings.lang}, function(data){
if(data.trim().length == 0){
el.html(record_end_txt);
load_img.remove();
end_record = true;
return;
}
loading = false;
load_img.remove();
el.html(data);
settings.start_page ++;
})
}
}
})(jQuery);
$("#results_pagesLike_<?php echo $rows['id']; ?>").loaddata();
}
</script>
<p class="lead"><?php echo html_entity_decode($rows['info']); ?></p>
<hr>
<?php echo "$title. (".(substr($rows['date_time'],0,4)+543)."). $rows[title]. สืบค้น ".dateThai(date('Y-m-d')).", จาก ".autolink(substr($ap_site,0,-1)."$_SERVER[REQUEST_URI]"); ?>
<hr>
<p class="lead" align="right"><?php if (!empty($rows['images2'])) {echo "<a href='$rows[images2]' target='_blank'>$ap_documents</a>";}?></p>
<?php
if($_GET['box']==""){
/*$filename = "$ap_site$ap_folder"."contents/pdf/pages/$_GET[page_id].pdf";
$file_headers = @get_headers($filename);
if($file_headers[0] == 'HTTP/1.1 200 OK') {*/
?>
<p><a href="<?php echo substr($ap_site,0,-1).$_SERVER['REQUEST_URI'];?>&pdf=1" target="_blank" title="<?php echo $rows['title']?>"><img src="<?php echo $ap_site.$ap_folder; ?>contents/images/pdf.png" width="50" height="50" alt="<?php echo $rows['title']?>"></a></p>
<meta name="citation_pdf_url" content="<?php echo substr($ap_site,0,-1).$_SERVER['REQUEST_URI'];?>&pdf=1">
<?php /*}*/ ?>
<div class="row">
<ul>
<?php
/*$sql2 = "select * from ap_pages order by rand() limit 5";
$query2 = mysqli_query($conn,$sql2);
while ($rows2 = mysqli_fetch_array($query2)) {
echo "<a href='?page_id=$rows2[id]' title='$rows2[title]' class=\"label label-success\">$rows2[title]</a> ";
}*/
/*$sql2 = "select * from ap_gallery order by rand() limit 5";
$query2 = mysqli_query($conn,$sql2);
while ($rows2 = mysqli_fetch_array($query2)) {
echo "<a href='?gal=$rows2[code]&id=$rows2[id]' title='$rows2[name]' class=\"label label-success\">$rows2[name]</a> ";
}*/
$keywords = explode(",",changeText($title.",".$rows['keywords']));
$cKeywords = count($keywords);
for($x=0;$x<$cKeywords;$x++){
if(!empty($keywords[$x])){
echo "<li><a href='https://www.google.co.th/search?q=$keywords[$x]' title='$keywords[$x]' class=\"label label-success\" target='google_window'>#$keywords[$x]</a></li>";
/*echo "<a href='https://www.google.co.th/search?sitesearch=$_SERVER[SERVER_NAME]&q=$keywords[$x]' title='$keywords[$x]' class=\"label label-success\" target='google_window'>$keywords[$x]</a> ";*/
/*echo "<a href='?cat=all&q=$keywords[$x]&lang=$_GET[lang]' title='$keywords[$x]' class=\"label label-success\"><cite>$keywords[$x]</cite></a> ";*/
}
}
?>
</ul>
</div>
<p>
<?php /* ?><img src='ap/qrcode/qrcode.php?data=<?php echo urlencode(substr($ap_site,0,-1).$_SERVER['REQUEST_URI']); ?>&size=114x114&logo=<?php echo $logo;?>' border='0' alt="QRCODE" /><?php */ ?>
<?php
mkdir("contents/qrcode/", 0777, true);
if(!file_exists("contents/qrcode/page_id$_GET[page_id].png")){
?>
<img src="qrcode/qrcode.php?data=<?php echo urlencode(substr($ap_site,0,-1).$_SERVER['REQUEST_URI']); ?>&size=177x177&logo=<?php echo $logo;?>&filename=<?php echo "page_id$_GET[page_id]"; ?>" alt="<?php echo "$apSubOwner $apOwner"; ?>" title="<?php echo "$apSubOwner $apOwner"; ?>">
<?php
}else{
?>
<img src="contents/qrcode/<?php echo "page_id$_GET[page_id]"; ?>.png" alt="<?php echo "$apSubOwner $apOwner"; ?>" title="<?php echo "$apSubOwner $apOwner"; ?>">
<?php
}
?>
</p>
<p>
<?php if($ap_rewrite=="on"){ ?>
<a href="<?php echo "page_id/$_GET[page_id]";?>/<?php echo $_GET['lang']?>"><?php echo $ap_site.$ap_folder."page_id/$_GET[page_id]";?>/<?php echo $_GET['lang']?>
<?php }else{ ?>
<a href="<?php echo $ap_site.$ap_folder."?page_id=$_GET[page_id]";?>&lang=<?php echo $_GET['lang']?>"><?php echo $ap_site.$ap_folder."?page_id=$_GET[page_id]";?>&lang=<?php echo $_GET['lang']?>
<?php } ?>
</a></p>
<?php
if($ap_rewrite=="on"){
fb_comments("$ap_site$ap_folder" ."page_id/$_GET[page_id]/$_GET[lang]");
}else{
fb_comments("$ap_site$ap_folder" ."?page_id=$_GET[page_id]&lang=$_GET[lang]");
}
}
?>
</div>
<?php
if(!empty($rows['images'])){
/*$images = str_replace("$ap_site$ap_folder/", "", $rows['images']);
$apExp = explode("/", $images);
$apCount = count($apExp);
$images2 = $apExp[($apCount-1)];
$dir = str_replace($images2, "", $images);
if(!file_exists("$dir/thumbs/thumb_m_$images2")){
resize(728, "$dir/thumbs/thumb_m_$images2","$images");
}
$sizeImg = getimagesize("$dir/thumbs/thumb_m_$images2");
$widthImg = $sizeImg['0'];
$heightImg = $sizeImg['1'];
$imagesA = "$ap_site$ap_folder".str_replace("//", "/", "$dir/thumbs/thumb_m_$images2");*/
?>
<div class="col-lg-4 col-md-4 col-sm-12">
<?php /* ?><p>
<a href="<?php echo $rows['images']?>" class="fancybox" data-fancybox-group="gallery" title="<?php echo $rows['title']?>">
<img src="<?php echo $imagesA; ?>" width="100%" alt="<?php echo $rows['title']?>" title="<?php echo $rows['title']?>">
</a>
</p>
<p>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
<i class="fas fa-download"></i> <a href="<?php echo $rows['images']; ?>" target="_blank"><?php echo $ap_download; ?></a>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 text-right">
<?php fb_like(substr("$ap_site",0,-1)."$_SERVER[REQUEST_URI]"); ?>
</div>
</div>
</p><?php */ ?>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12"><?php $_GET['text'] = $rows['title']; echo social(); ?></div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12"><?php AdSense(); ?></div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12"><?php echo "<br><h4><strong>$ap_new_infomation</strong></h4><hr>"; ?></div>
</div>
<?php
$sql_n = "select * from ap_pages where catalogCode='$rows[catalogCode]' and id!='$_GET[page_id]' order by date_time desc limit 5";
$sql_n = "select * from ap_pages where id!='$_GET[page_id]' order by date_time desc limit 5";
$query_n = mysqli_query($conn,$sql_n);
while($rows_n = mysqli_fetch_array($query_n)){
?>
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
<?php
if(!empty($rows_n['images'])){
$images = str_replace("$ap_site$ap_folder/", "", $rows_n['images']);
$apExp = explode("/", $images);
$apCount = count($apExp);
$images2 = $apExp[($apCount-1)];
$dir = str_replace($images2, "", $images);
if($ap_webp=="on"){
$im = explode(".", $images2);
$images2 = "$im[0].webp";
}
if(!file_exists("$dir/thumbs/thumb_s_$images2")){
$size = getimagesize("$images");
resize($size[0], "$dir/thumbs/thumb_s_$images2","$images");
}
$sizeImg = getimagesize("$dir/thumbs/thumb_s_$images2");
$widthImg = $sizeImg['0'];
$heightImg = $sizeImg['1'];
$imagesB = "$ap_site$ap_folder".str_replace("//", "/", "$dir/thumbs/thumb_s_$images2");
if($ap_rewrite=="on"){
?>
<a href="<?php echo $ap_site.$ap_folder; ?>page_id/<?php echo $rows_n['id']; ?>/<?php echo $rows_n['lang']; ?>" title="<?php echo $rows_n['title']?>">
<?php }else{ ?>
<a href="?page_id=<?php echo $rows_n['id']; ?>&lang=<?php echo $rows_n['lang']; ?>" title="<?php echo $rows_n['title']?>">
<?php } ?>
<img style="padding: 3" src="<?php echo $imagesB; ?>" width="100%" alt="<?php echo $rows_n['title']?>" title="<?php echo $rows_n['title']?>">
</a>
<?php
}
?>
</div>
<div class="col-lg-8 col-md-8 col-sm-8 col-xs-8">
<h1 class="h5">
<?php if($ap_rewrite=="on"){ ?>
<a href="<?php echo $ap_site.$ap_folder; ?>page_id/<?php echo $rows_n['id']; ?>/<?php echo $rows_n['lang']; ?>" title="<?php echo $rows_n['title']?>">
<?php }else{ ?>
<a href="?page_id=<?php echo $rows_n['id']; ?>&lang=<?php echo $rows_n['lang']; ?>" title="<?php echo $rows_n['title']?>">
<?php } ?>
<?php echo $rows_n['title']; ?></a>
</h1>
<p><?php echo $ap_publish ?> <?php echo dateThai($rows_n['date_time']); ?></p>
</div>
<div class="col-lg-12 col-md-12 col-sm-12"><hr></div>
</div>
<?php /* ?><p>
<a href="?page_id=<?php echo $rows_n['id']; ?>&lang=<?php echo $rows_n['lang']; ?>" title="<?php echo $rows_n['title']?>">
<?php
if(!empty($rows_n['images'])){
?>
<img style="padding: 3" src="<?php echo $rows_n['images']?>" width="100%" alt="<?php echo $rows_n['title']?>" title="<?php echo $rows_n['title']?>">
<?php
}
echo "<p>- ".$rows_n['title']."</p>";
?>
</a>
</p><?php */ ?>
<?php
}
?>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<h4>
<?php if($ap_rewrite=="on"){ ?>
<a href="<?php echo $ap_site.$ap_folder; ?>cat/all/<?php echo $_GET['lang']; ?>" title="<?php echo $ap_all_infomation; ?>">
<?php }else{ ?>
<a href="<?php echo $_SERVER['SERVER_SCRIPT'] ?>?cat=all&lang=<?php echo $_GET['lang'] ?>" title="<?php echo $ap_all_infomation; ?>">
<?php } ?>
<?php echo $ap_all_infomation; ?></a>
</h4>
</div>
</div>
</div>
<?php
}
?>
</div>
<?php
if ($rows['gallery2_status'] == '1') {
?>
<div class="row">
<p></p>
<?php
$allowed_types = array('mp4', 'MP4', 'm4v', 'M4V', 'mov', 'MOV');
if ($rows['createByStatus'] == "Admin") {
if(empty($rows['gallery2'])){
$sql_g2 = "select * from ap_gallery2 where id='$rows[gallery2ID]'";
$query_g2 = mysqli_query($conn,$sql_g2);
$rows_g2 = mysqli_fetch_array($query_g2);
$dir = "contents/gallery2/$rows_g2[code]/";
}else{
$dir = "contents/gallery2/$rows[gallery2]/";
}
} else {
$dir = "contents/$rows[createBy]/$rows[code]/";
}
$files1 = scandir($dir);
$total = 0;
$pic_path = array();
foreach ($files1 as $key => $value) {
if ($key > 0) {
$file_parts = explode('.', $value);
$ext = strtolower(array_pop($file_parts));
if (in_array($ext, $allowed_types)) {
$pic_path[] = $dir.$value;
$total++;
}
}
}
for ($indexPicture = 0; $indexPicture < $total; $indexPicture++) {
$images = $pic_path[$indexPicture];
if (!empty($images)) {
?>
<div class="col-lg-12 col-md-12 col-sm-12">
<div align="center">
<object class="embed-responsive-item">
<video autoplay="true" preload="true" width="100%" controls preload="true">
<source src="<?php echo $images?>" />
</video>
</object>
</div>
</div>
<?php
}
}
?>
</div>
<?php
}
}
if ($rows['gallery_status'] == 1) {
?>
<div class="row">
<p></p>
<?php
$allowed_types = array('JPG', 'jpg', 'JPEG', 'jpeg', 'GIF', 'gif', 'PNG', 'png','WEBP','webp');
if ($rows['createByStatus'] == "Admin") {
if ($rows['galleryID'] == "") {
$dir = "contents/gallery/$rows[gallery]/";
} else {
$sqlg = "select * from ap_gallery where id='$rows[galleryID]'";
$queryg = mysqli_query($conn,$sqlg);
$rowsg = mysqli_fetch_array($queryg);
$dir = "contents/gallery/$rowsg[code]/";
}
echo $dir;
} else {
if ($rows['galleryID'] == "") {
$dir = "contents/$rows[createBy]/$rows[gallery]/";
} else {
$sqlg = "select * from ap_gallery where id='$rows[galleryID]'";
$queryg = mysqli_query($conn,$sqlg);
$rowsg = mysqli_fetch_array($queryg);
$dir = "contents/$rows[createBy]/$rowsg[code]/";
}
}//echo $dir;
mkdir($dir.'thumbs/', 0777, true);
$files1 = scandir($dir);
$total = 0;
$pic_path = array();
foreach ($files1 as $key => $value) {
if ($key > 0) {
$file_parts = explode('.', $value);
$ext = strtolower(array_pop($file_parts));
if (in_array($ext, $allowed_types)) {
$pic_path[] = $dir.$value;
$pic_path2[] = $value;
$total++;
}
}
}
if($_GET['box']==1){
$total = $limit_list;
}
for ($indexPicture = 0; $indexPicture < $total; $indexPicture++) {
$images = $pic_path[$indexPicture];
$images2 = $pic_path2[$indexPicture];
if($ap_webp=="on"){
$im = explode(".", $images2);
$images2 = "$im[0].webp";
}
if (!empty($images)) {
if(!file_exists("$dir/thumbs/thumb_s_$images2")){
$size = getimagesize("$images");
resize($size[0], "$dir/thumbs/thumb_s_$images2","$images");
}
/*if(!file_exists("$dir/thumbs/thumb_s_$images2")){
resize(300, "$dir/thumbs/thumb_s_$images2","$images");
}*/
?>
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-6 <?php if($indexPicture>7){ echo "slideanimx"; } ?>">
<p><a href="<?php echo $images?>" class="img-thumbnail fancybox" data-fancybox-group="gallery" title="<?php echo $rowsu['dePart'].' '.$title;?>">
<img src="<?php echo "$dir/thumbs/thumb_s_$images2"; ?>" width="100%" alt="<?php echo ($indexPicture+1).'. '.$rows['title'];?>" title="<?php echo ($indexPicture+1).'. '.$rows['title'];?>"></a></p>
<p><i class="fas fa-download"></i> <a href="<?php echo "$images"; ?>" target="_blank"><?php echo $ap_download; ?></a></p>
</div>
<?php
}
/*if(($indexPicture+1) %4==0){
echo "</div><div class='row'>";
}*/
}
?>
</div>
<?php
}
?>
</div>
<?php
}
// Gallery Catalog
if (!empty($_GET['gal_cat'])) {
if(!empty($_GET['q'])){
wordcloud("$_GET[q]");
}else{
if($_GET['gal_cat']=="all"){
wordcloud("$ap_picture");
$rows2['name'] = "$ap_picture";
}else{
$sql2 = "select * from ap_catalogs where lang='$_GET[lang]' and code='$_GET[gal_cat]'";
$query2 = mysqli_query($conn,$sql2);
$rows2 = mysqli_fetch_array($query2);
wordcloud("$ap_picture $rows2[name]");
}
}
?>
<div class="breadcrumbx">
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-12">
<ul class="breadcrumb" itemscope="" itemtype="http://schema.org/BreadcrumbList">
<li itemprop="itemListElement" itemscope="" itemtype="http://schema.org/ListItem">
<a href="<?php echo $_SERVER['SERVER_SCRIPT'] ?>?lang=<?php echo $_GET['lang'] ?>" itemprop="item">
<span itemprop="name"><?php echo $ap_home; ?></span>
</a>
<meta itemprop="position" content="1">
</li>
<li itemprop="itemListElement" itemscope="" itemtype="http://schema.org/ListItem">
<?php if($ap_rewrite=="on"){ ?>
<a href="gal_cat/<?php echo $_GET['gal_cat'] ?>/<?php echo $_GET['lang']; ?>" itemprop="item">
<?php }else{ ?>
<a href="<?php echo $_SERVER['SERVER_SCRIPT'] ?>?gal_cat=<?php echo $_GET['gal_cat'] ?>&lang=<?php echo $_GET['lang']; ?>" itemprop="item">
<?php } ?>
<span itemprop="name"><?php echo $rows2['name'] ?></span>
</a>
<meta itemprop="position" content="2">
</li>
</ul>
<p></p>
</div>
<div class="col-lg-4 col-md-4 col-sm-12">
<form class="form-inline text-right" action="<?php echo $_SERVER[SCRIPT_NAME]; ?>" method="GET">
<input type="hidden" name="gal_cat" value="all">
<div class="form-group">
<input type="text" name="q" value="<?php echo $_GET['q']; ?>" placeholder="ระบุคำค้น" class="form-control" autofocus>
</div>
<button type="submit" class="btn btn-default">ค้นหา</button>
</form>
</div>
<div class="col-lg-12 col-md-12 col-sm-12"><hr></div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<?php
$allowed_types = array('JPG', 'jpg', 'JPEG', 'jpeg', 'GIF', 'gif', 'PNG', 'png','WEBP','webp');
if($_GET['q']==""){
$qx = "";
}else{
$qx = "and (name like '%$_GET[q]%')";
}
if($_GET['gal_cat']=="all"){
$sql2 = "select * from ap_gallery where lang='$_GET[lang]' $qx";
}else{
$sql2 = "select * from ap_gallery where lang='$_GET[lang]' and catalogCode='$_GET[gal_cat]' $qx";
}
$limit = 10;
if ($_GET['page'] == "") {
$_GET['page'] = 1;
}
$prev_page = $_GET['page']-1;
$next_page = $_GET['page']+1;
$query2 = mysqli_query($conn,$sql2);
$start = ($limit*$_GET['page'])-$limit;
if ($query2 != false) {
$num_rows2 = mysqli_num_rows($query2);
}
if ($num_rows2 <= $limit) {
$num_page = 1;
} elseif (($num_rows2%$limit) == 0) {
$num_page = ($num_rows2/$limit);
} else {
$num_page = ($num_rows2/$limit)+1;
}
$num_page = (int) $num_page;
if (($_GET['page'] > $num_page) || ($_GET['page'] < 0)) {
print"<center><b>error<b></center><br>";
}
$sql2 .= " order by date_time desc limit $start, $limit";
$query2 = mysqli_query($conn,$sql2);
$i2 = 0;
while ($rows2 = mysqli_fetch_array($query2)) {
$i2++;
//$dir = "contents/gallery/$rows2[code]/";
if ($rows2['createByStatus'] == "Admin") {
$dir = "contents/gallery/$rows2[code]/";
} else {
$dir = "contents/$rows2[createBy]/$rows2[code]/";
}
mkdir($dir.'thumbs/', 0777, true);
$files1 = scandir($dir);
$total = 0;
$pic_path = array();
foreach ($files1 as $key => $value) {
if ($key > 0) {
$file_parts = explode('.', $value);
$ext = strtolower(array_pop($file_parts));
if (in_array($ext, $allowed_types)) {
$pic_path[] = $dir.$value;
$pic_path2[] = $value;
$total++;
}
}
}
?>
<div class="row <?php if($i2>2){ echo "slideanimx"; } ?>">
<div class="col-lg-12 col-md-12 col-sm-12">
<h1 class="h4"><span class="glyphicon glyphicon-picture"></span> <?php echo $rows2['name']?></h1>
<p><?php echo $ap_publish; ?> <?php echo dateThai($rows2['date_time'])?> <?php echo $ap_visits ?> <?php echo number_format($rows2['counters'])?></p>
<p></p>
</div>
<?php
for ($indexPicture = 0; $indexPicture < 4; $indexPicture++) {
$images = $pic_path[$indexPicture];
$images2 = $pic_path2[$indexPicture];
if($ap_webp=="on"){
$im = explode(".", $images2);
$images2 = "$im[0].webp";
}
if($images){
if(!file_exists("$dir/thumbs/thumb_s_$images2")){
$size = getimagesize("$images");
resize($size[0], "$dir/thumbs/thumb_s_$images2","$images");
}
?>
<div class="col-lg-3 col-md-4 col-sm-12">
<p>
<?php if($ap_rewrite=="on"){ ?>
<a href="gal/<?php echo $rows2['code']; ?>/<?php echo $rows2['id']; ?>/<?php echo $_GET['lang']; ?>" target="_blank" class="img-thumbnail" title="<?php echo ($indexPicture+1).'. '.$rows2['name']; ?>">
<?php }else{ ?>
<a href="?gal=<?php echo $rows2['code']?>&id=<?php echo $rows2['id']?>&lang=<?php echo $_GET['lang']?>" target="_blank" class="img-thumbnail" title="<?php echo ($indexPicture+1).'. '.$rows2['name']; ?>">
<?php } ?>
<img src="<?php echo "$dir/thumbs/thumb_s_$images2"; ?>" width="100%" title="<?php echo ($indexPicture+1).'. '.$rows2['name']?>" alt="<?php echo ($indexPicture+1).'. '.$rows2['name']?>"></a>
</p>
</div>
<?php
}
}
?>
</div>
<div class="row slideanimx"><hr></div>
<?php
}
?>
</div>
</div>
<div class="row slideanimx">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="btn-group" role="group" aria-label="...">
<?php
for ($i = 1; $i <= $num_page; $i++) {
if ($i > ($_GET['page']-10) && $i < ($_GET['page']+5)) {
if ($_GET['page'] == $i) {
$a = " active";
} else {
$a = "";
}
echo "<a href='?gal_cat=$_GET[gal_cat]&page=$i&lang=$_GET[lang]' title='$i'><button type=\"button\" class=\"btn btn-default$a\">$i</button></a> ";
}
}
?>
</div>
</div>
</div><!-- /.row -->
</div>
<?php
}
// Gallery
if (!empty($_GET['gal'])) {
$sql = "select * from ap_gallery where id='$_GET[id]' and code='$_GET[gal]'";
$query = mysqli_query($conn,$sql);
$rows = mysqli_fetch_array($query);
if(!empty($rows['name'])){
$sql2 = "select * from ap_catalogs where lang='$rows[lang]' and code='$rows[catalogCode]'";
$query2 = mysqli_query($conn,$sql2);
$rows2 = mysqli_fetch_array($query2);
wordcloud("$ap_picture $rows[name]");
}
$sqlu = "select * from ap_users where user='$rows[createBy]'";
$queryu = mysqli_query($conn,$sqlu);
$rowsu = mysqli_fetch_array($queryu);
$s_id = session_id();
$views_gallery = $s_id.$rows['id'];
if ($_SESSION['views_gallery'] != "$views_gallery") {
$_SESSION['views_gallery'] = $views_gallery;
if (empty($rows['counters'])) {$rows['counters'] = 0;}
$c = $rows['counters']+1;
mysqli_query($conn,"update ap_gallery set counters='$c' where id='$rows[id]'");
}
$query = mysqli_query($conn,$sql);
$rows = mysqli_fetch_array($query);
?>
<div class="breadcrumbx">
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-12">
<ul class="breadcrumb" itemscope="" itemtype="http://schema.org/BreadcrumbList">
<li itemprop="itemListElement" itemscope="" itemtype="http://schema.org/ListItem">
<a href="<?php echo $_SERVER['SERVER_SCRIPT'] ?>?lang=<?php echo $_GET['lang'] ?>" itemprop="item">
<span itemprop="name"><?php echo $ap_home; ?></span>
</a>
<meta itemprop="position" content="1">
</li>
<li itemprop="itemListElement" itemscope="" itemtype="http://schema.org/ListItem">
<?php if($ap_rewrite=="on"){ ?>
<a href="gal_cat/<?php echo $rows['catalogCode'] ?>/<?php echo $_GET['lang']; ?>" itemprop="item">
<?php }else{ ?>
<a href="<?php echo $_SERVER['SERVER_SCRIPT'] ?>?gal_cat=<?php echo $rows['catalogCode'] ?>&lang=<?php echo $_GET['lang'] ?>" itemprop="item">
<?php } ?>
<span itemprop="name"><?php echo $rows2['name'] ?></span>
</a>
<meta itemprop="position" content="2">
</li>
</ul>
<p></p>
</div>
<div class="col-lg-4 col-md-4 col-sm-12">
<form class="form-inline text-right" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="GET">
<input type="hidden" name="gal_cat" value="all">
<div class="form-group">
<input type="text" name="q" value="<?php echo $_GET['q']; ?>" placeholder="ระบุคำค้น" class="form-control" autofocus>
</div>
<button type="submit" class="btn btn-default">ค้นหา</button>
</form>
</div>
<div class="col-lg-12 col-md-12 col-sm-12"><hr></div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<h1 class="h4"><span class="glyphicon glyphicon-picture"></span> <?php echo $rows['name']?></h1>
<p><?php echo $ap_publish ?> <?php echo date_reformat($rows['date_time'])?> <?php echo $ap_visits ?> <?php echo number_format($rows['counters'])?></p>
<p></p>
<?php if($ap_rewrite=="on"){ ?>
<div class="fb-share-button" data-href="gal/<?php echo $_GET['gal']; ?>/<?php echo $_GET['id']; ?>/<?php echo $_GET['lang']; ?>" data-layout="button_count"></div>
<?php }else{ ?>
<div class="fb-share-button" data-href="<?php echo $ap_site.$ap_folder; ?>?gal=<?php echo $_GET['gal']?>&id=<?php echo $_GET['id']?>&lang=<?php echo $_GET['lang']?>" data-layout="button_count"></div>
<?php } ?>
<p></p>
<?php /* AdSense(); */ ?>
</div>
<?php
$allowed_types = array('JPG', 'jpg', 'JPEG', 'jpeg', 'GIF', 'gif', 'PNG', 'png','WEBP','webp');
//$dir = "contents/gallery/$rows[code]/";
if ($rows['createByStatus'] == "Admin") {
$dir = "contents/gallery/$rows[code]/";
} else {
$dir = "contents/$rows[createBy]/$rows[code]/";
}
mkdir($dir.'thumbs/', 0777, true);
$files1 = scandir($dir);
$total = 0;
$pic_path = array();
foreach ($files1 as $key => $value) {
if ($key > 0) {
$file_parts = explode('.', $value);
$ext = strtolower(array_pop($file_parts));
if (in_array($ext, $allowed_types)) {
$pic_path[] = $dir.$value;
$pic_path2[] = $value;
$total++;
}
}
}
for ($indexPicture = 0; $indexPicture < $total; $indexPicture++) {
$images = $pic_path[$indexPicture];
$images2 = $pic_path2[$indexPicture];
if($ap_webp=="on"){
$im = explode(".", $images2);
$images2 = "$im[0].webp";
}
if($images){
if(!file_exists("$dir/thumbs/thumb_s_$images2")){
$size = getimagesize("$images");
resize($size[0], "$dir/thumbs/thumb_s_$images2","$images");
}
?>
<div class="col-lg-3 col-md-4 col-sm-12 <?php if($indexPicture>7){ echo "slideanimx"; } ?>">
<p><a class="img-thumbnail fancybox" href="<?php echo $images; ?>" data-fancybox-group="gallery" title="<?php echo $rowsu['dePart'].' '.$title?>">
<img src="<?php echo "$dir/thumbs/thumb_s_$images2"; ?>" width="100%" alt="<?php echo ($indexPicture+1).'. '.$rows['name']?>" title="<?php echo ($indexPicture+1).'. '.$rows['name']?>"></a></p>
</div>
<?php
// if(($indexPicture+1) %4==0){
// echo "</div><div class='row'>";
// }
}
}
?>
</div>
<u>
<?php
$sql2 = "select * from ap_pages where lang='$_GET[lang]' order by rand() limit 5";
$query2 = mysqli_query($conn,$sql2);
while ($rows2 = mysqli_fetch_array($query2)) {
if($ap_rewrite=="on"){
echo "<li> <a href='page_id/$rows2[id]/$_GET[lang]' title='$rows2[title]' class=\"label label-success\">$rows2[title]</a></li>";
}else{
echo "<li> <a href='?page_id=$rows2[id]&lang=$_GET[lang]' title='$rows2[title]' class=\"label label-success\">$rows2[title]</a></li>";
}
}
/*$sql2 = "select * from ap_gallery order by rand() limit 5";
$query2 = mysqli_query($conn,$sql2);
while ($rows2 = mysqli_fetch_array($query2)) {
echo "<a href='?gal=$rows2[code]&id=$rows2[id]' title='$rows2[name]' class=\"label label-success\">$rows2[name]</a> ";
}*/
?>
</u>
<p></p>
<?php AdSense();?>
<p></p>
</div>
<?php
}
// Gallery2 Catalog
if (!empty($_GET['gal2_cat'])) {
if(!empty($_GET['q'])){
wordcloud("$_GET[q]");
}else{
if($_GET['gal2_cat']=="all"){
wordcloud("$ap_media");
}else{
$sql2 = "select * from ap_catalogs where lang='$_GET[lang]' and code='$_GET[gal2_cat]'";
$query2 = mysqli_query($conn,$sql2);
$rows2 = mysqli_fetch_array($query2);
wordcloud("$ap_media $rows2[name]");
}
}
?>
<div class="breadcrumbx">
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-12">
<ul class="breadcrumb" itemscope="" itemtype="http://schema.org/BreadcrumbList">
<li itemprop="itemListElement" itemscope="" itemtype="http://schema.org/ListItem">
<a href="<?php echo $_SERVER['SERVER_SCRIPT'] ?>?lang=<?php echo $_GET['lang'] ?>" itemprop="item">
<span itemprop="name"><?php echo $ap_home; ?></span>
</a>
<meta itemprop="position" content="1">
</li>
<li itemprop="itemListElement" itemscope="" itemtype="http://schema.org/ListItem">
<?php if($ap_rewrite=="on"){ ?>
<a href="gal2_cat/<?php echo $_GET['gal2_cat'] ?>/<?php echo $_GET['lang']; ?>" itemprop="item" title="<?php echo $rows2['name'] ?>">
<?php }else{ ?>
<a href="<?php echo $_SERVER['SERVER_SCRIPT'] ?>?gal2_cat=<?php echo $_GET['gal2_cat'] ?>&lang=<?php echo $_GET['lang'] ?>" itemprop="item" title="<?php echo $rows2['name'] ?>">
<?php } ?>
<span itemprop="name"><?php echo $rows2['name'] ?></span>
</a>
<meta itemprop="position" content="2">
</li>
</ul>
<p></p>
</div>
<div class="col-lg-4 col-md-4 col-sm-12">
<form class="form-inline text-right" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="GET">
<input type="hidden" name="gal2_cat" value="<?php echo $rows['catalogCode'] ?>">
<div class="form-group">
<input type="text" name="q" value="<?php echo $_GET['q']; ?>" placeholder="ระบุคำค้น" class="form-control" autofocus>
</div>
<button type="submit" class="btn btn-default">ค้นหา</button>
</form>
</div>
</div>
<div class="row col-lg-12 col-md-12 col-sm-12"><hr></div>
<div class="featurette">
<div class="row">
<?php
$allowed_types = array('mp4', 'MP4', 'm4v', 'M4V', 'mov', 'MOV');
if($_GET['q']==""){
$qx = "";
}else{
$qx = "and (name like '%$_GET[q]%')";
}
if($_GET['gal2_cat']=="all"){
$sql2 = "select * from ap_gallery2 where lang='$_GET[lang]' $qx";
}else{
$sql2 = "select * from ap_gallery2 where lang='$_GET[lang]' and catalogCode='$_GET[gal2_cat]' $qx";
}
$limit = 12;
if (!$_GET['page']) {
$_GET['page'] = 1;
}
$prev_page = $_GET['page']-1;
$next_page = $_GET['page']+1;
$query2 = mysqli_query($conn,$sql2);
$start = ($limit*$_GET['page'])-$limit;
if ($query2 != false) {
$num_rows2 = mysqli_num_rows($query2);
}
if ($num_rows2 <= $limit) {
$num_page = 1;
} elseif (($num_rows2%$limit) == 0) {
$num_page = ($num_rows2/$limit);
} else {
$num_page = ($num_rows2/$limit)+1;
}
$num_page = (int) $num_page;
if (($_GET['page'] > $num_page) || ($_GET['page'] < 0)) {
print"<center><b>error<b></center><br>";
}
$sql2 .= " order by date_time desc limit $start, $limit";
$query2 = mysqli_query($conn,$sql2);
$i = 0;
while ($rows2 = mysqli_fetch_array($query2)) {
$i++;
if ($rows2['createByStatus'] == "Admin") {
$dir = "contents/gallery2/$rows2[code]/";
} else {
$dir = "contents/$rows2[createBy]/$rows2[code]/";
}
mkdir($dir.'thumbs/', 0777, true);
$images = str_replace("$ap_site$ap_folder/", "", $rows2['images']);
$apExp = explode("/", $images);
$apCount = count($apExp);
$images2 = $apExp[($apCount-1)];
$dir2 = str_replace($images2, "", $images);
if($ap_webp=="on"){
$im = explode(".", $images2);
$images2 = "$im[0].webp";
}
mkdir($dir2.'thumbs/', 0777, true);
if(!file_exists("$dir2/thumbs/thumb_m_$images2")){
$size = getimagesize("$images");
resize($size[0], "$dir2/thumbs/thumb_m_$images2","$images");
}
$sizeImg = getimagesize("$dir2/thumbs/thumb_m_$images2");
$widthImg = $sizeImg['0'];
$heightImg = $sizeImg['1'];
$rows2['images'] = "$ap_site$ap_folder".str_replace("//", "/", "$dir2/thumbs/thumb_m_$images2");
$files1 = scandir($dir);
$total = 0;
$pic_path = array();
foreach ($files1 as $key => $value) {
if ($key > 0) {
$file_parts = explode('.', $value);
$ext = strtolower(array_pop($file_parts));
if (in_array($ext, $allowed_types)) {
$pic_path[] = $dir.$value;
$total++;
}
}
}
?>
<div class="<?php if($i>6){ echo "slideanimx"; } ?>">
<div class="col-lg-4 col-md-4 col-sm-12">
<h1 class="h5">
<span class="glyphicon glyphicon-bullhorn"></span>
<?php if($ap_rewrite=="on"){ ?>
<a href="gal2/<?php echo $rows2[code]; ?>/<?php echo $rows2[id]; ?>/<?php echo $_GET['lang']; ?>" target="_blank" title="<?php echo $rows2['name']?>">
<?php }else{ ?>
<a href="?gal2=<?php echo $rows2[code]; ?>&id=<?php echo $rows2[id]; ?>&lang=<?php echo $_GET['lang'] ?>" target="_blank" title="<?php echo $rows2['name']?>">
<?php } ?>
<?php echo $rows2['name']?></a>
</h1>
<p><?php echo $ap_publish ?> <?php echo dateThai($rows2['date_time'])?> <?php echo $ap_visits ?> <?php echo number_format($rows2['counters'])?></p>
<p></p>
<?php
for ($indexPicture = 0; $indexPicture < 2; $indexPicture++) {
$images = $pic_path[$indexPicture];
if ($images) {
?>
<div align="center">
<div class="panel2 panel2-default">
<div class="panel2-body" style="max-width: 100%;max-height: 170px">
<?php if($ap_rewrite=="on"){ ?>
<a href="<?php echo $ap_site.$ap_folder; ?>gal2/<?php echo $rows2[code]; ?>/<?php echo $rows2[id]; ?>/<?php echo $_GET['lang']; ?>" target="_blank" title="<?php echo $rows2['name']; ?>">
<?php }else{ ?>
<a href="?gal2=<?php echo $rows2[code]; ?>&id=<?php echo $rows2[id]; ?>&lang=<?php echo $_GET['lang'] ?>" target="_blank" title="<?php echo $rows2['name']; ?>">
<?php } ?>
<img src="<?php echo $rows2['images'] ?>" width="100%" alt="<?php echo $rows2['name']; ?>">
</a>
</div>
</div>
<?php /* ?><object class="embed-responsive-item">
<video width="100%" preload="true" poster="<?php echo $rows2['images'] ?>" controls>
<source src="<?php echo $images?>" />
</video>
</object><?php */ ?>
</div>
<?php
}
}
?>
<p></p>
</div>
</div>
<?php
}
?>
</div>
</div>
<div class="row slideanimx">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="btn-group" role="group" aria-label="...">
<?php
for ($i = 1; $i <= $num_page; $i++) {
if ($i > ($_GET['page']-10) && $i < ($_GET['page']+5)) {
if ($_GET['page'] == $i) {
$a = " active";
} else {
$a = "";
}
echo "<a href='?gal2_cat=$_GET[gal2_cat]&page=$i&lang=$_GET[lang]' title='$i'><button type=\"button\" class=\"btn btn-default$a\">$i</button></a> ";
}
}
?>
</div>
<p></p>
</div>
</div><!-- /.row -->
</div>
<?php
}
// Gallery2
if (!empty($_GET['gal2'])) {
$sql = "select * from ap_gallery2 where id='$_GET[id]' and code='$_GET[gal2]'";
$query = mysqli_query($conn,$sql);
$rows = mysqli_fetch_array($query);
if(!empty($rows['name'])){
$sql2 = "select * from ap_catalogs where lang='$_GET[lang]' and code='$rows[catalogCode]'";
$query2 = mysqli_query($conn,$sql2);
$rows2 = mysqli_fetch_array($query2);
wordcloud("$rows[name]");
}
$s_id = session_id();
$views_gallery2 = $s_id.$rows['id'];
if ($_SESSION['views_gallery2'] != $s_id.$rows['id']) {
$_SESSION['views_gallery2'] = $views_gallery2;
if (empty($rows['counters'])) {$rows['counters'] = 0;}
$c = $rows['counters']+1;
mysqli_query($conn,"update ap_gallery2 set counters='$c' where id='$rows[id]'");
}
?>
<div class="breadcrumbx">
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-12">
<ul class="breadcrumb" itemscope="" itemtype="http://schema.org/BreadcrumbList">
<li itemprop="itemListElement" itemscope="" itemtype="http://schema.org/ListItem">
<a href="<?php echo $_SERVER['SERVER_SCRIPT'] ?>?lang=<?php echo $_GET['lang'] ?>" itemprop="item">
<span itemprop="name"><?php echo $ap_home; ?></span>
</a>
<meta itemprop="position" content="1">
</li>
<li itemprop="itemListElement" itemscope="" itemtype="http://schema.org/ListItem">
<?php if($ap_rewrite=="on"){ ?>
<a href="gal2_cat/<?php echo $rows['catalogCode'] ?>/<?php echo $_GET['lang']; ?>" itemprop="item">
<?php }else{ ?>
<a href="<?php echo $_SERVER['SERVER_SCRIPT'] ?>?gal2_cat=<?php echo $rows['catalogCode'] ?>&lang=<?php echo $_GET['lang'] ?>" itemprop="item">
<?php } ?>
<span itemprop="name"><?php echo $rows2['name'] ?></span>
</a>
<meta itemprop="position" content="2">
</li>
</ul>
<p></p>
</div>
<div class="col-lg-4 col-md-4 col-sm-12">
<form class="form-inline text-right" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="GET">
<input type="hidden" name="gal2_cat" value="<?php echo $rows['catalogCode'] ?>">
<div class="form-group">
<input type="text" name="q" value="<?php echo $_GET['q']; ?>" placeholder="ระบุคำค้น" class="form-control" autofocus>
</div>
<button type="submit" class="btn btn-default">ค้นหา</button>
</form>
</div>
<p></p>
</div>
<div class="row"><div class="col-lg-12 col-md-12 col-sm-12"><hr></div></div>
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-12">
<p><span class="glyphicon glyphicon-bullhorn"></span> <font class="font-14-bold"><?php echo $rows['name']?></font></p>
<p><?php echo $ap_publish ?> <?php echo dateThai($rows['date_time'])?> <?php echo $ap_visits; ?> <?php echo number_format($rows['counters'])?></p>
<?php /* ?><div class="fb-share-button" data-href="<?php echo $ap_site.$ap_folder?>?gal2=<?php echo $_GET['gal2']?>&id=<?php echo $_GET['id']?>&lang=<?php echo $_GET['lang']?>" data-layout="button_count"></div>
<p></p>
<?php AdSense();?><?php */ ?>
<?php
$images = str_replace("$ap_site$ap_folder/", "", $rows['images']);
$apExp = explode("/", $images);
$apCount = count($apExp);
$images2 = $apExp[($apCount-1)];
$dir = str_replace($images2, "", $images);
$im = explode(".", $images2);
$images2 = "$im[0].webp";
if(!file_exists("$dir/thumbs/thumb_m_$images2")){
$size = getimagesize("$images");
resize($size[0], "$dir/thumbs/thumb_m_$images2","$images");
}
$sizeImg = getimagesize("$dir/thumbs/thumb_m_$images2");
$widthImg = $sizeImg['0'];
$heightImg = $sizeImg['1'];
$rows['images'] = "$ap_site$ap_folder".str_replace("//", "/", "$dir/thumbs/thumb_m_$images2");
$allowed_types = array('mp4', 'MP4', 'm4v', 'M4V', 'mov', 'MOV');
if($rows['createByStatus'] == "Admin") {
$dir = "contents/gallery2/$rows[code]/";
} else {
$dir = "contents/$rows[createBy]/$rows[code]/";
}
$files1 = scandir($dir);
$total = 0;
$pic_path = array();
foreach ($files1 as $key => $value) {
if ($key > 0) {
$file_parts = explode('.', $value);
$ext = strtolower(array_pop($file_parts));
if (in_array($ext, $allowed_types)) {
$pic_path[] = $dir.$value;
$total++;
}
}
}
for ($indexPicture = 0; $indexPicture < $total; $indexPicture++) {
$images = $pic_path[$indexPicture];
if ($images) {
?>
<div class="row col-lg-12 col-md-12 col-sm-12 <?php if($indexPicture>4){ echo "slideanimx"; } ?>">
<div align="center">
<object class="embed-responsive-item">
<video width="100%" preload="true" poster="<?php echo $rows['images'] ?>" autoplay loop controls>
<source src="<?php echo $images?>" />
</video>
</object>
</div>
</div>
<?php
}
}
?>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<?php $_GET['text'] = $rows['name']; echo social(); ?><br>
<p>
<?php /* ?><img src="ap/qrcode/qrcode.php?data=<?php echo urlencode(substr($ap_site,0,-1).$_SERVER['REQUEST_URI']); ?>&size=114x114&logo=<?php echo $logo;?>" border='0' alt="QRCODE" /><?php */ ?>
<?php
mkdir("contents/qrcode/", 0777, true);
if(!file_exists("contents/qrcode/gal2$_GET[id].png")){
?>
<img src="qrcode/qrcode.php?data=<?php echo urlencode(substr($ap_site,0,-1).$_SERVER['REQUEST_URI']); ?>&size=177x177&logo=<?php echo $logo;?>&filename=<?php echo "gal2$_GET[id]"; ?>" alt="<?php echo "$apSubOwner $apOwner"; ?>" title="<?php echo "$apSubOwner $apOwner"; ?>">
<?php
}else{
?>
<img src="contents/qrcode/<?php echo "gal2$_GET[id]"; ?>.png" alt="<?php echo "$apSubOwner $apOwner"; ?>" title="<?php echo "$apSubOwner $apOwner"; ?>">
<?php
}
?>
</p>
<p><a href="<?php echo substr($ap_site,0,-1).$_SERVER['REQUEST_URI'];?>"><?php echo substr($ap_site,0,-1).$_SERVER['REQUEST_URI'];?></a></p>
</div>
</div>
</div>
<div class="col-lg-4 col-md-4 col-sm-12">
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12"><?php echo "<h4><strong>$ap_new_infomation</strong></h4><hr>"; ?></div>
</div>
<div class="row">
<?php
$allowed_types = array('mp4', 'MP4', 'm4v', 'M4V', 'mov', 'MOV');
$sql2 = "select * from ap_gallery2 where id!='$_GET[id]' and catalogCode='$rows[catalogCode]' and lang='$_GET[lang]'";
$sql2 = "select * from ap_gallery2 where id!='$_GET[id]' and lang='$_GET[lang]'";
$limit = 5;
if (!$_GET['page']) {
$_GET['page'] = 1;
}
$prev_page = $_GET['page']-1;
$next_page = $_GET['page']+1;
$query2 = mysqli_query($conn,$sql2);
$start = ($limit*$_GET['page'])-$limit;
if ($query2 != false) {
$num_rows2 = mysqli_num_rows($query2);
}
if ($num_rows2 <= $limit) {
$num_page = 1;
} elseif (($num_rows2%$limit) == 0) {
$num_page = ($num_rows2/$limit);
} else {
$num_page = ($num_rows2/$limit)+1;
}
$num_page = (int) $num_page;
if (($_GET['page'] > $num_page) || ($_GET['page'] < 0)) {
print"<center><b>error<b></center><br>";
}
$sql2 .= " order by rand() limit $start, $limit";
$query2 = mysqli_query($conn,$sql2);
$i = 0;
while ($rows2 = mysqli_fetch_array($query2)) {
$i++;
if ($rows2['createByStatus'] == "Admin") {
$dir = "contents/gallery2/$rows2[code]/";
} else {
$dir = "contents/$rows2[createBy]/$rows2[code]/";
}
mkdir($dir.'thumbs/', 0777, true);
$images = str_replace("$ap_site$ap_folder/", "", $rows2['images']);
$apExp = explode("/", $images);
$apCount = count($apExp);
$images2 = $apExp[($apCount-1)];
$dir2 = str_replace($images2, "", $images);
if($ap_webp=="on"){
$im = explode(".", $images2);
$images2 = "$im[0].webp";
}
mkdir($dir2.'thumbs/', 0777, true);
if(!file_exists("$dir2/thumbs/thumb_m_$images2")){
$size = getimagesize("$images");
resize($size[0], "$dir2/thumbs/thumb_m_$images2","$images");
}
$sizeImg = getimagesize("$dir2/thumbs/thumb_m_$images2");
$widthImg = $sizeImg['0'];
$heightImg = $sizeImg['1'];
$rows2['images'] = "$ap_site$ap_folder".str_replace("//", "/", "$dir2/thumbs/thumb_m_$images2");
$files1 = scandir($dir);
$total = 0;
$pic_path = array();
foreach ($files1 as $key => $value) {
if ($key > 0) {
$file_parts = explode('.', $value);
$ext = strtolower(array_pop($file_parts));
if (in_array($ext, $allowed_types)) {
$pic_path[] = $dir.$value;
$total++;
}
}
}
?>
<div class="<?php if($i>2){ echo "slideanimx"; } ?>">
<div class="col-lg-4 col-md-4 col-sm-12">
<?php
for ($indexPicture = 0; $indexPicture < 2; $indexPicture++) {
$images = $pic_path[$indexPicture];
if(!empty($images)) {
?>
<?php if($ap_rewrite=="on"){ ?>
<a href="gal2/<?php echo $rows2[code]; ?>/<?php echo $rows2[id]; ?>/<?php echo $_GET['lang'] ?>" title="<?php echo $rows2['name']?>">
<?php }else{ ?>
<a href="?gal2=<?php echo $rows2[code]; ?>&id=<?php echo $rows2[id]; ?>&lang=<?php echo $_GET['lang'] ?>" title="<?php echo $rows2['name']?>">
<?php } ?>
<img style="padding: 3" src="<?php echo $rows2['images']; ?>" width="100%" alt="<?php echo $rows2['name']?>" title="<?php echo $rows2['name']?>">
</a>
<?php
/* ?><div align="center">
<object class="embed-responsive-item">
<video width="100%" preload="true" poster="<?php echo $rows2['images'] ?>" loop="true" controls>
<source src="<?php echo $images?>" />
</video>
</object>
</div><?php */ ?>
<?php
}
}
?>
</div>
<div class="col-lg-8 col-md-8 col-sm-12">
<h1 class="h5">
<i class="fas fa-video"></i>
<?php if($ap_rewrite=="on"){ ?>
<a href="gal2/<?php echo $rows2[code]; ?>/<?php echo $rows2[id]; ?>/<?php echo $_GET['lang']; ?>" title="<?php echo $rows2['name']; ?>">
<?php }else{ ?>
<a href="?gal2=<?php echo $rows2[code]; ?>&id=<?php echo $rows2[id]; ?>&lang=<?php echo $_GET['lang']; ?>" title="<?php echo $rows2['name']; ?>">
<?php } ?>
<?php echo $rows2['name']; ?></a>
</h1>
<?php /* ?><p><?php echo $ap_publish ?> <?php echo date_reformat($rows2['date_time'])?> <?php echo $ap_visits ?> <?php echo number_format($rows2['counters'])?></p><?php */ ?>
</div>
<div class="col-lg-12 col-md-12 col-sm-12"><hr></div>
</div>
<?php
}
?>
<div class="">
<div class="col-lg-12 col-md-12 col-sm-12">
<h4>
<?php if($ap_rewrite=="on"){ ?>
<a href="gal2_cat/all/<?php echo $_GET['lang']; ?>" title="<?php echo $ap_all_infomation; ?>">
<?php }else{ ?>
<a href="<?php echo $_SERVER['SERVER_SCRIPT'] ?>?gal2_cat=all&lang=<?php echo $_GET['lang']; ?>" title="<?php echo $ap_all_infomation; ?>">
<?php } ?>
<?php echo $ap_all_infomation; ?></a>
</h4>
</div>
</div>
</div>
</div>
</div>
<p></p>
</div>
<?php
}
// Banners
if (!empty($_GET['banners'])) {
?>
<div class="breadcrumbx">
<?php
$sql_eb = "select * from ap_externalbanner where lang='$_GET[lang]' order by catalogCode asc";
$query_eb = mysqli_query($conn,$sql_eb);
$num_rows_eb = mysqli_num_rows($query_eb);
if($num_rows_eb>0){
?>
<div class="row slideanimx">
<?php
$i_eb = 0;
while($rows_eb = mysqli_fetch_array($query_eb)){
$i_eb++;
$sql2 = "select * from ap_catalogs where lang='$_GET[lang]' and code='$rows_eb[catalogCode]'";
$query2 = mysqli_query($conn,$sql2);
$rows2 = mysqli_fetch_array($query2);
if($last!=$rows2['name']){
?>
<div class="col-lg-12 col-md-12 col-sm-12">
<p><h3><?php echo $rows2['name']; ?></h3></p>
</div>
<?php
}
$last = $rows2['name'];
if(!empty($rows_eb['images'])){
$images = str_replace("$ap_site$ap_folder/", "", $rows_eb['images']);
$apExp = explode("/", $images);
$apCount = count($apExp);
$images2 = $apExp[($apCount-1)];
$dir = str_replace($images2, "", $images);
if($ap_webp=="on"){
$im = explode(".", $images2);
$images2 = "$im[0].webp";
}
mkdir($dir.'thumbs/', 0777, true);
if(!file_exists("$dir/thumbs/thumb_s_$images2")){
$size = getimagesize("$images");
resize($size[0], "$dir/thumbs/thumb_s_$images2","$images");
}
$rows_eb['images'] = "$dir/thumbs/thumb_s_$images2";
?>
<div class="col-lg-3 col-md-3 col-sm-12">
<?php if($rows_eb['url_link']!="#"){ ?><a href="<?php echo $rows_eb['url_link']?>" target="_blank" title="<?php echo $rows_eb['name']?>"><?php } ?>
<img src="<?php echo $rows_eb['images'];?>" class="img-thumbnail" alt="<?php echo $rows_eb['name']?>" title="<?php echo $rows_eb['name']?>">
<?php if($rows_eb['url_link']!="#"){ ?></a><?php } ?>
<p></p>
</div>
<?php
}
}
?>
</div> <!-- ./row -->
<?php
}
?>
</div>
<?php
}
// RSS Feed
if($_GET['nu']=="rss" || $_GET['nu']=="feed"){
class feed{
public $urls = array();
public $data = array();
public function addFeeds(array $feeds){
$this->urls = array_merge($this->urls, array_values($feeds));
}
public function grabRss(){
foreach($this->urls as $feed){
$data = @new SimpleXMLElement($feed, 0, true);
if(!$data)
throw new Exception('Could not load: '.$feed);
foreach($data->channel->item as $item){
$this->data[] = $item;
}
}
}
public function merge_feeds(){
$temp = array();
foreach( $this->data as $item){
if(!in_array($item->link, $this->links($temp))){
$temp[] = $item;
}
}
$this->data = $temp;
}
private function links( array $items ){
$links = array();
foreach($items as $item){
$links[] = $item->link;
}
return $links;
}
}
?>
<div class="row slideanimx">
<div class="col-lg-12 col-md-12 col-sm-12">
<h1 style="text-align: center;">ข่าวใหม่(RSS Feed)</h1>
<h4 style="text-align: center;">วันที่ <?php echo dateThai(date('Y-m-d')); ?></h4>
<hr>
<?php
$sql2 = "SELECT rss FROM ap_settings";
$query2 = mysqli_query($conn,$sql2);
$rows2 = mysqli_fetch_array($query2);
if(empty(strip_tags($rows2['rss']))){
?>
<p align="center">ไม่พบ RSS Feed URL</p>
<hr>
<?php
}else{
$result = explode(',',$rows2['rss']);
$urls = array();
for($i=0;$i<count($result);$i++){
$urls[] = strip_tags($result[$i]);
}
try{
$feeds = new feed;
$feeds->addFeeds($urls);
$feeds->grabRss();
$feeds->merge_feeds();
}catch(exception $e){
die($e->getMessage());
}
$data = array();
$data = $feeds -> data;
usort($data, function($a,$b){
return $a->pubDate - $b->pubDate;
// return strtotime($a->pubDate) - strtotime($b->pubDate);
});
if(count($data)==0){
?>
<p align="center">ไม่พบ ข่าวใหม่(RSS Feed)</p>
<hr>
<?php
}
echo "<div class='row'>";
foreach ($data as $item) :
// extract((array) $item);
if(empty($item->enclosure['url'])){
$ap_col = 12;
}else{
$ap_col = 9;
}
if($ap_col!=12){
?>
<div class="col-lg-3 col-md-3 col-sm-3">
<img src="<?php echo $item->enclosure['url']; ?>" width="100%" alt="<?php echo $item->title; ?>" title="<?php echo $item->title; ?>">
</div>
<?php
}
?>
<div class="col-lg-<?php echo $ap_col;?> col-md-<?php echo $ap_col;?> col-sm-12">
<h1 class="media-heading h5">
<span class="glyphicon glyphicon-bullhorn"></span> <a href="<?php echo $item->link; ?>" <?php if(detect_devices()==2){ ?>class="tiptext" <?php } ?> target="_blank" title="<?php echo $item->title; ?>"><?php echo $item->title; ?></a>
</h1>
<p><?php echo $item->description; ?></p>
<div class="justify-content-center" id="">
<i class="far fa-calendar-alt"></i> <?php echo $ap_publish ?> <?php echo dateThai($item->pubDate); ?> <a href="<?php echo $item->link ?>" target="_blank"><u><?php echo $ap_more; ?></u></a>
</div>
<p style="font-weight: bold;margin-top: 5px"><i class="fas fa-globe-asia"></i> <a href="<?php echo $item->source['url'] ?>" target="_blank"><?php echo $item->source; ?></a></p>
</div>
<div class="col-lg-12 col-md-12 col-sm-12"><hr></div>
<?php
endforeach;
echo "</div>";
}
?>
</div>
</div>
<?php
}
?>
</div><!-- /.container -->
</main>
<?php include ('footText.php');?>
<?php include ('foot.php');?>