Path : /var/www/html/main/
File Upload :
Current File : /var/www/html/main/themes454545.php

<?php
/*!
 * Copyright Anucha Puangpaka
 * Contact anucha.ppk@icloud.com 062-479-9836
 */

  include('modify-top-slide.php');

  /*
  Slide
   */
  ?>
  <div id="carousel-main-generic" class="carousel slide" data-ride="carousel">
    <?php
    $sql = "select count(*) as total from ap_slides where lang='$_GET[lang]' and (date_time>$dt and place='1' and status='1') order by date_time asc";
    $query = mysqli_query($conn,$sql);
    $rows = mysqli_fetch_array($query);
    $num_rows = $rows['total'];
    if($num_rows>0){
    ?>
      <ol class="carousel-indicators">
      <?php
      $sql = "select * from ap_slides where lang='$_GET[lang]' and (date_time>$dt and place='1' and status='1') order by date_time asc";
      $query = mysqli_query($conn,$sql);
      $i = 0;
      while($rows = mysqli_fetch_array($query)){
      $i++;
      ?>
        <li data-target="#carousel-main-generic" data-slide-to="<?php echo ($i-1);?>"<?php if($i==1){ echo " class=\"active\""; } ?>></li>
      <?php
      }
      ?>
      </ol>
      <?php ?>
      <div class="carousel-inner" role="listbox">
        <?php
        /*$sql = "select * from ap_slides where date_time>$dt and place='1' and status='1' order by date_time asc";*/
        $query = mysqli_query($conn,$sql);
        $i = 0;
        while($rows = mysqli_fetch_array($query)){
        $i++;

          if(preg_match("/\b$_SERVER[SERVER_NAME]\b/", $rows['images']) == true){
            $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");
            }
            $rows['images'] = "$ap_site$ap_folder".str_replace("//", "/", "$dir/thumbs/thumb_l_$images2");
          }
          ?>
          <div class="item<?php if($i==1){ echo " active"; } ?>">
            <?php if($rows['url_link']=="#" || $rows['url_link']==""){?>
              <!-- <img src="images.php?nu=&xwidth=1175&ximg=<?php echo $rows['images']?>" width="100%" alt="<?php echo $rows['name']?>"> -->
              <img src="<?php echo $rows['images']?>" width="100%" alt="<?php echo $rows['name']?>"  title="<?php echo $rows['name']?>">
            <?php }else{ ?>
              <a href="<?php echo $rows['url_link']; ?>" target="_blank">
            <!-- <img src="images.php?nu=&xwidth=1175&ximg=<?php echo $rows['images']?>" width="100%" alt="<?php echo $rows['name']?>" title="<?php echo $rows['name']?>"> -->
                <img src="<?php echo $rows['images']?>" width="100%" alt="<?php echo $rows['name']?>" title="<?php echo $rows['name']?>">
              </a>
            <?php } ?>
          </div>
        <?php
        }
        ?>
      </div>
      <a class="left carousel-control" href="#carousel-main-generic" role="button" data-slide="prev">
        <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
        <span class="sr-only">Previous</span>
      </a>
      <a class="right carousel-control" href="#carousel-main-generic" role="button" data-slide="next">
        <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
        <span class="sr-only">Next</span>
      </a>
    <?php
    }
    ?>
  </div>
  <?php
  /*
  End Slide
   */
  
  /*
  External Banner
   */
  if($externalbanner_bottom_slide=="2"){
  ?>
    <div class="" style="margin-top: 20px;">
    <?php
    $sql_eb = "select * from ap_externalbanner where lang='$_GET[lang]' and status='1' order by code asc, level asc";
    $query_eb = mysqli_query($conn,$sql_eb);
    $num_rows_eb = mysqli_num_rows($query_eb);
    //$sql_eb .= " limit 8";
    $query_eb = mysqli_query($conn,$sql_eb);
    if($num_rows_eb>0){
    ?>
      <div class="row">
        <?php
        $i_eb = 0;
        while($rows_eb = mysqli_fetch_array($query_eb)){
          $i_eb++;
          /*$sql2 = "select * from ap_catalogs where code='$rows_eb[catalogCode]'";
          $query2 = mysqli_query($conn,$sql2);
          $rows2 = mysqli_fetch_array($query2);
          if($i_eb==1){
          ?>
            <div class="col-lg-12 col-md-12 col-sm-12">
              <div class="row">
              <p align="right"><b><?php echo $rows2['name'] ?></b></p>
              </div>
            </div>
          <?php
          }*/
          if(!empty($rows_eb['images'])){

            if(preg_match("/\b$_SERVER[SERVER_NAME]\b/", $rows_eb['images']) == true){
              $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");
              }

              $sizeImg = getimagesize("$dir/thumbs/thumb_s_$images2");
              $widthImg = $sizeImg['0'];
              $heightImg = $sizeImg['1'];

              $rows_eb['images'] = "$ap_site$ap_folder".str_replace("//", "/", "$dir/thumbs/thumb_s_$images2");
            }
            ?>
            <div class="col-lg-2 col-md-2 col-sm-6">
              <?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 if($num_rows_eb>8){ ?>
      <div class="col-lg-12 col-md-12 col-sm-12">
        <div class="row slideanimx">
          <p align="right"><a class="btn btn-primary" role="button" href="?banners=all" target="new" title="มีต่อ">มีต่อ</a></p>
        </div>
      </div>
      <?php 
      }
    }
    ?>
    </div>
  <?php
  }
  /*
  End External Banner
   */
  ?>

  <div class="row">
    <div class="col-lg-12 col-md-12 col-sm-12">
      <p></p>
    </div>
  </div>
  <?php
  include('modify-bottom-slide.php');
  ?>
  <div class="row">
    <div class="col-lg-12 col-md-12 col-sm-12">
      <p></p>
    </div>
  </div>
  <?php
  /*
  Columns 1-3
   */ 
  ?>
  <div class="row">
    <?php
    /*
    Columns 1
     */
    ?>
    <div class="col-lg-<?php echo "$col1_w"; ?> col-md-<?php echo "$col1_w"; ?> col-sm-12" <?php if($col1==""){ echo "style='display:none;'"; } ?>>
      <?php /*
      if(!empty($slogan)){ 
      ?>
        <div class="well slideanim">" <?php echo $slogan; ?> "</div>
      <?php 
      } */

      /*
      Featured video
       */ /*
      $allowed_types = array('mp4','MP4','m4v','M4V','mov','MOV');
      $sql2 = "select * from ap_gallery2 where lang='$_GET[lang]' and status='1' order by date_time desc limit 1";
      $query2 = mysqli_query($conn,$sql2);
      $num_rows2 = mysqli_num_rows($query2);
      ?>
      <div class="row">
      <?php
      while($rows2 = mysqli_fetch_array($query2)){
        if($rows2['createByStatus']=="Admin"){
          $dir = "contents/gallery2/$rows2[code]/";
        }else{
          $dir = "contents/$rows2[createBy]/$rows2[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++;
            }
          }
        }
        ?>
        <div class="col-lg-12 col-md-12 col-sm-12">
          <p align="left"><a href="?gal2=<?php echo $rows2['code']?>&id=<?php echo $rows2['id']?>&lang=<?php echo $_GET['lang']?>" target="new"><?php echo $rows2['name']?></a></p>
        </div>
        <?php
        for($indexPicture = 0;$indexPicture<1;$indexPicture++){
          $images = $pic_path[$indexPicture];
          if($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>
                <p align="right"><a class="btn btn-primary" role="button" href="?gal2_cat=all&lang=<?php echo $_GET['lang']?>" target="new"><?php echo $ap_more ?></a></p>
              </div>
            </div>
          <?php
          }
        }
      }
      ?>
      </div>
      <?php */
      /*
      End Featured video
       */

      /*
      Pages
       */
      $sql_c = "select count(id) as total from ap_catalogs where lang='$_GET[lang]' and status='1' order by level asc";
      $query_c = mysqli_query($conn,$sql_c);
      $rows_c = mysqli_fetch_array($query_c);
      $num_rows_c = $rows_c['total'];
      if($num_rows_c>0){
      ?>
        <ul class="nav nav-tabs">
      <?php
      }

      $sql_c = "select * from ap_catalogs where lang='$_GET[lang]' and status='1' order by level asc";
      $query_c = mysqli_query($conn,$sql_c);
      $i_c = 0;
      while($rows_c = mysqli_fetch_array($query_c)){
      
        $sql2 = "select count(id) as total from ap_pages where lang='$_GET[lang]' and catalogCode='$rows_c[code]'";
        $query2 = mysqli_query($conn,$sql2);
        $rows2 = mysqli_fetch_array($query2);
        $num_rows2 = $rows2['total'];

        if($num_rows2>0){
          $i_c++;
          ?>
          <li <?php if($i_c==1){ echo "class=\"active\""; } ?>><a href="#<?php echo $rows_c['code']?>" data-toggle="tab" title="<?php echo $rows_c['name']; ?>"><img src="<?php echo $logo_touch; ?>" width="16px" alt="<?php echo $rows_c['name']?>"> <?php echo $rows_c['name']?></a></li>
        <?php
        }

        include('modify-tab-API.php');
      }
      ?>
      </ul>
      <div class="tab-content">
        <?php
        $query_c = mysqli_query($conn,$sql_c);
        $i_c = 0;
        while($rows_c = mysqli_fetch_array($query_c)){

          $sql2x = "select count(id) as total from ap_pages where date_time<='".date('Ymd')."%' and lang='$_GET[lang]' and catalogCode='$rows_c[code]'";
          $query2x = mysqli_query($conn,$sql2x);
          $rows2x = mysqli_fetch_array($query2x);
          $num_rows2 = $rows2x['total'];
          
          if($num_rows2>0){
            $i_c++;
            ?>
            <div class="tab-pane<?php if($i_c==1){ echo " active"; } ?>" id="<?php echo $rows_c['code']?>">
              <p></p>
              <?php
              if($rows_c['code']=="Public_Relations" || $rows_c['code']=="Public_Relations_Eng"){
                $sql2 = "select * from ap_pages where date_time<='".date('Ymd')."%' and lang='$_GET[lang]' and (catalogCode='$rows_c[code]' or public_relations='1') order by date_time desc,level asc,id desc limit $limit_list";
              }else{
                $sql2 = "select * from ap_pages where date_time<='".date('Ymd')."%' and lang='$_GET[lang]' and catalogCode='$rows_c[code]' order by date_time desc,level asc,id desc limit $limit_list";
              }
              $query2 = mysqli_query($conn,$sql2);
              $i2 = 0;
              while($rows2 = mysqli_fetch_array($query2)){
                $i2++;
                if(!empty($rows2['images2_status'])){
                ?>
                  <?php /* ?><div class="row">
                    <div class="col-lg-12 col-md-12 col-sm-12">
                      <h5 class="media-heading"><i class="fas fa-bullhorn"></i> <a href="<?php echo $rows2['images2']?>" target="_blank"><?php echo $rows2['title']?></a> <!-- <?php if($i2==1){?><img src="img/new.gif" width="24" alt=""><?php } ?> --></h5>
                      <p class="media-heading"><?php echo $ap_publish ?> <?php echo dateThai($rows2['date_time'])?></p>
                    </div>
                  </div>
                  <p></p><hr><?php */ ?>
                  <div class="row">
                    <div class="col-lg-12 col-md-12 col-sm-12">
                      <h1 class="h5"><i class="fas fa-bullhorn"></i> <?php echo $i2; ?>. <a href="<?php echo $rows2['images2']?>" target="_blank" title="<?php echo dateThai($rows2['date_time']); ?>"><?php echo $rows2['title']?></a> <?php if($i2<=3){ ?><img src="contents/images/new.gif" width="24" alt="<?php echo dateThai($rows2['date_time']); ?>"><?php } ?> [<?php echo dateThai($rows2['date_time']); ?>] 
                      </h1><hr>
                    </div>
                  </div>
                <?php
                }else{
                  ?>
                  <script type="text/javascript">
                  $(".tiptext").mouseover(function() {
                    $(this).children(".description").show();
                  }).mouseout(function() {
                    $(this).children(".description").hide();
                  });
                  </script>
                  <div class="row">
                    <?php
                    if(empty($rows2['images'])){
                      $ap_col = 12;
                    }else{
                      
                      if(preg_match("/\b$_SERVER[SERVER_NAME]\b/", $rows2['images']) == true){
                        $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_s_$images2")){
                          $size = getimagesize("$images");
                          resize($size[0], "$dir/thumbs/thumb_s_$images2","$images");
                        }
                        $rows2['images'] = "$dir/thumbs/thumb_s_$images2";
                      }

                      if(!file_exists("$rows2[images]")){
                        $ap_col = 12;
                      }else{
                        $ap_col = 9;
                      }
                    }
                    ?>

                    <?php if($ap_col!=12){ ?>
                    <div class="col-lg-3 col-md-3 col-sm-12">
                      <div class="panel2 panel2-default">
                        <!-- <div class="panel2-body" style="max-width: 100%;height: 120px"> -->
                        <div class="panel2-body" style="max-width: 100%;">
                          <?php 
                          if($ap_rewrite=="on"){ 
                          ?>
                            <a class="zoom" data-type="image" data-title="<?php echo $rows2['title']?>" data-footer="<?php echo $rows2['title']?>" data-toggle="lightbox" href="page_id/<?php echo $rows2['id'] ?>/<?php echo $_GET['lang']?>" title="<?php echo $rows2['title']; ?>">
                          <?php 
                          }else{
                          ?>
                            <a class="zoom" data-type="image" data-title="<?php echo $rows2['title']?>" data-footer="<?php echo $rows2['title']?>" data-toggle="lightbox" href="?page_id=<?php echo $rows2['id'] ?>&lang=<?php echo $_GET['lang']?>" title="<?php echo $rows2['title']; ?>">
                          <?php 
                          } 
                          ?>
                            <!-- <img class="img-thumbnail" src="images.php?nu=&xwidth=300&ximg=<?php echo $rows2['images']?>" alt="<?php echo $rows2['title']?>" title="<?php echo $rows2['title']?>"> -->

                            <div id="slides_<?php echo $rows2['id'];?>" class="carousel slide" data-ride="carousel">
                              <div class="carousel-inner" role="listbox">
                                <?php 
                                if(preg_match("/\b$_SERVER[SERVER_NAME]\b/", $rows2['images']) == true){
                                  $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_s_$images2")){
                                    $size = getimagesize("$images");
                                    resize($size[0], "$dir/thumbs/thumb_s_$images2","$images");
                                  }
                                  /*if(!file_exists("$dir/thumbs/thumb_s_$images2")){
                                    resize(100, "$dir/thumbs/thumb_s_$images2","$images");
                                  }*/

                                  $rows2['images'] = "$dir/thumbs/thumb_s_$images2";
                                }
                                ?>
                                <div class="item active">
                                  <img class="img-thumbnail" src="<?php echo $rows2['images']; ?>" width="100%" alt="<?php echo $rows2['title']?>" title="<?php echo $rows2['title']?>">
                                </div>
                                <?php
                                if($rows2['gallery_status']=="1"){
                                  $sql_ximg = "select * from ap_gallery where id='$rows2[galleryID]'";
                                  $query_ximg = mysqli_query($conn,$sql_ximg);
                                  $rows_ximg = mysqli_fetch_array($query_ximg);
                                  
                                  $allowed_types = array('JPG', 'jpg', 'JPEG', 'jpeg', 'GIF', 'gif', 'PNG', 'png','WEBP','webp');
                                  
                                  if($rows_ximg['createByStatus']=="Admin"){
                                    $dir = "contents/gallery/$rows_ximg[code]/";
                                  }else{
                                    $dir = "contents/$rows_ximg[createBy]/$rows_ximg[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 = 4;
                                    $ximg_end = 7;
                                  }else{
                                    $ximg_start = 0;
                                    $ximg_end = 3;
                                  }
                                  
                                  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_s_$images2")){
                                        $size = getimagesize("$images");
                                        resize($size[0], "$dir/thumbs/thumb_s_$images2","$images");
                                      }
                                      /*if(!file_exists("$dir/thumbs/thumb_s_$images2")){
                                        resize(100, "$dir/thumbs/thumb_s_$images2","$images");
                                      }*/
                                      ?>
                                      <div class="item">
                                        <img class="img-thumbnail" src="<?php echo "$dir/thumbs/thumb_s_$images2"?>" width="100%" alt="<?php echo $rows2['title']?>" title="<?php echo $rows2['title']?>">
                                      </div>
                                    <?php
                                    }
                                  }
                                }
                                ?>
                              </div>
                            </div>

                          </a>
                          <span class="overlay"></span>
                        </div>
                      </div>
                    </div>
                    <?php 
                    }
                    ?>
                    
                    <?php
                    if(empty($rows2['counters'])){
                      $rows2['counters'] = 1;
                    }

                    $xlen = $rows2['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="col-lg-<?php echo $ap_col;?> col-md-<?php echo $ap_col;?> col-sm-12">
                      <p></p><h1 class="media-heading h5">
                        <i class="fas fa-bullhorn"></i> 
                        <?php if($ap_rewrite=="on"){ ?>
                          <a href="page_id/<?php echo $rows2['id'] ?>/<?php echo $_GET['lang']?>" <?php if(detect_devices()==2){ ?>class="tiptext" <?php } ?> title="<?php echo $rows2['title']; ?>">
                        <?php }else{ ?>
                          <a href="?page_id=<?php echo $rows2['id'] ?>&lang=<?php echo $_GET['lang']?>" <?php if(detect_devices()==2){ ?>class="tiptext" <?php } ?> title="<?php echo $rows2['title']; ?>">
                        <?php } ?>
                        <?php echo $rows2['title']?>
                        <?php /*if(detect_devices()==2){ ?>
                        <iframe class="description slideanim" src="?page_id=<?php echo $rows2['id'] ?>&box=1"></iframe><?php }*/ ?>
                        </a>
                      </h1>
                      <p><?php echo $rows2['info2']?></p>
                      <?php /* ?><p class="media-heading"><?php echo $ap_publish ?> <?php echo date_reformat($rows2['date_time'])?> <?php echo $ap_visits ?> <?php if(!empty($rows2['counters'])){ echo number_format($rows2['counters']); }?></p><?php */ ?>
                      <div class="justify-content-center" id="results_pagesLike_<?php echo $rows2['id']; ?>">
                        <?php echo $ap_publish ?> <?php echo dateThai($rows2['date_time'])?> <?php echo "<a onclick=\"pagesLike_$rows2[id]();\" title=\"Like\"><i class=\"far fa-thumbs-up\" style=\"font-size:18px;color:blue\"></i></a> ".number_format($rows2['likes'])." $xl"; if($rows2['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($rows2['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/$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>
                      </div>
                      <script type="text/javascript">
                      // Modify Anucha Puangpaka
                      function pagesLike_<?php echo $rows2['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 $rows2['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 $rows2['id']; ?>").loaddata();
                      }
                      </script>
                    </div>

                    <?php
                    if($rows2['gallery_status']=="1" && $g_gallery_show=="1"){
                      echo "<div class='row 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 count(id) as total from ap_gallery where id='$rows2[galleryID]'";
                      $query_g = mysqli_query($conn,$sql_g);
                      $rows_g = mysqli_fetch_array($query_g);
                      $num_rows_g = $rows_g['total'];
                      
                      $sql_g = "select * from ap_gallery where id='$rows2[galleryID]'";
                      $query_g = mysqli_query($conn,$sql_g);
                      if($num_rows_g>0){
                        //$query_g2 = mysqli_query($conn,$sql_g);
                        while($rows_g2 = mysqli_fetch_array($query_g)){
                          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++;
                              }
                            }
                          }
                          
                          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");
                              }
                              /*if(!file_exists("$dir/thumbs/thumb_s_$images2")){
                                resize(100, "$dir/thumbs/thumb_s_$images2","$images");
                              }*/
                              ?>
                              <div class="visible-lg visible-md col-lg-3 col-md-3 col-sm-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 title="<?php echo $rows_g2['name']; ?>" 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 title="<?php echo $rows_g2['name']; ?>" 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_s_$images2"?>" width="100%" alt="<?php echo ($indexPicture+1).'. '.$rows_g2['name']?>" title="<?php echo ($indexPicture+1).'. '.$rows_g2['name']?>">
                                  </a><p>
                                  <span class="overlay"></span>
                                  </div>
                                </div>
                                <p></p>
                              </div>
                            <?php
                            }
                          }
                          
                        }
                      }

                    }
                    ?>
                  </div>
                  <hr>
                <?php
                }
              }

              /*if($num_rows_c=="1"){
              ?>
                <p align="right"><a class="btn btn-primary" role="button" href="?cat=all&lang=<?php echo $_GET['lang']?>" target="new"><?php echo $ap_more ?></a></p>
              <?php 
              }else{*/
                /*if($rows_c['code']=="Public_Relations" || $rows_c['code']=="Public_Relations_Eng"){
                ?>
                  <p align="right"><a class="btn btn-primary" role="button" href="?cat=all&lang=<?php echo $_GET['lang']?>" target="new"><?php echo $ap_more ?></a></p>
                <?php 
                }else{*/
                ?>
                <p align="right">
                  <?php if($ap_rewrite=="on"){ ?>
                  <a class="btn btn-primary" role="button" href="cat/<?php echo $rows_c['code']?>/<?php echo $_GET['lang']?>" target="new" title="<?php echo $ap_more ?>">
                  <?php }else{ ?>
                    <a class="btn btn-primary" role="button" href="?cat=<?php echo $rows_c['code']?>&lang=<?php echo $_GET['lang']?>" target="new" title="<?php echo $ap_more ?>">
                  <?php } ?>
                  <?php echo $ap_more ?></a>
                </p>
                <?php  
                /*}
              }*/
              ?>
            </div>
          <?php
          }

          include('modify-tab-content-API.php');
          
        }
        ?>
      </div>
      <?php
      /*
      End Page
       */
      
      /*
      Gallery
       */ /*
      $num_rows_g = mysqli_num_rows(mysqli_query($conn,"select * from ap_gallery"));
      if($num_rows_g>0){
      ?>
        <p></p>
        <ul class="nav nav-tabs">
          <?php
          if($g_gallery=="1"){
          ?>
            <li class="active"><a href="#ap" data-toggle="tab"><?php echo $g_gallery_name;?></a></li>
          <?php
          }else{
            $sql_c = "select * from ap_catalogs where status='1' order by level asc";
            $query_c = mysqli_query($conn,$sql_c);
            $i_c = 0;
            while($rows_c = mysqli_fetch_array($query_c)){
              $i_c++;
              if($i_c==1){
                $active_status = " class=\"active\"";
                $ct = "คลังรูปภาพ";
              }else{
                $ct = "";
              }
              $num_rows_g = mysqli_num_rows(mysqli_query($conn,"select * from ap_gallery where catalogCode='$rows_c[code]'"));
              if($num_rows_g>0){
              ?>
              <li <?php echo $active_status;?>><a href="#ap<?php echo $rows_c['code']?>" data-toggle="tab"><?php echo $ct.' '.$rows_c['name']?></a></li>
              <?php
              }
              $active_status = "";
            }
          }
          ?>
        </ul>
      <?php
      }
      ?>
      <div class="tab-content">
        <?php
        $allowed_types = array('JPG','jpg','JPEG','jpeg','GIF','gif','PNG','png','WEBP','webp');

        if($g_gallery==""){
          $query_c = mysqli_query($conn,$sql_c);
          $i_c = 0;
          while($rows_c = mysqli_fetch_array($query_c)){
            $i_c++;
            if($i_c==1){
              $active_status = " active";
            }

            $num_rows_g = mysqli_num_rows(mysqli_query($conn,"select * from ap_gallery where catalogCode='$rows_c[code]'"));
            if($num_rows_g>0){
            ?>
            <div class="tab-pane<?php echo $active_status?>" id="ap<?php echo $rows_c['code']?>">
              <p></p>
              <div class="row slideanim">
              <?php
              $sql2 = "select * from ap_gallery where catalogCode='$rows_c[code]' order by date_time desc limit $limit_list";

              $query2 = mysqli_query($conn,$sql2);
              while($rows2 = mysqli_fetch_array($query2)){
                if($rows2['createByStatus']=="Admin"){
                  $dir = "contents/gallery/$rows2[code]/";
                }else{
                  $dir = "contents/$rows2[createBy]/$rows2[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++;
                    }
                  }
                }
                ?>
                <div class="col-lg-12 col-md-12 col-sm-12">
                  <span class="glyphicon glyphicon-picture"></span> <a href="?gal=<?php echo $rows2['code']?>&id=<?php echo $rows2['id']?>" target="_blank" title="<?php echo $rows2['name']?>"><?php echo $rows2['name']?></a>
                  <p></p>
                </div>
                <?php
                for($indexPicture = 0;$indexPicture<4;$indexPicture++){
                  $images = $pic_path[$indexPicture];
                  if($images){
                  ?>
                    <div class="col-lg-3 col-md-3 col-sm-6">
                      <div class="panel2 panel2-default">
                      <!-- <div class="panel2-body" style="max-width: 100%;height: 140px"> -->
                      <div class="panel2-body" style="max-width: 100%;">
                      <p><a class="zoom" data-type="image" data-title="<?php echo $rows2['name']?>" data-footer="<?php echo $rows2['name']?>" data-toggle="lightbox" href="?gal=<?php echo $rows2['code']?>&id=<?php echo $rows2['id']?>" target="_blank" title="<?php echo $rows2['name']?>">
                      <img class="img-thumbnail" src="images.php?nu=&xwidth=300&ximg=<?php echo $images?>" width="100%" alt="<?php echo ($indexPicture+1).'. '.$rows2['name']?>" title="<?php echo ($indexPicture+1).'. '.$rows2['name']?>">
                      </a><p>
                      <span class="overlay"></span>
                      </div>
                      </div>
                      <p></p>
                    </div>
                  <?php
                  }
                }
                echo "</div><div class='row slideanim'>";
              }
              ?>
              </div>
              <div class="col-lg-12 col-md-12 col-sm-12">
                <div class="row">
                <p align="right"><a class="btn btn-primary" role="button" href="?gal_cat=<?php echo $rows_c['code']?>" target="new">มีต่อ</a></p>
                </div>
              </div>
            </div>
            <?php
            }
            $active_status = "";
          }
        }else{
        ?>
          <div class="tab-pane active" id="ap">
            <p></p>
            <div class="row slideanim">
            <?php
            $sql2 = "select * from ap_gallery order by date_time desc limit $limit_list";
            $query2 = mysqli_query($conn,$sql2);
            while($rows2 = mysqli_fetch_array($query2)){
              if($rows2['createByStatus']=="Admin"){
                $dir = "contents/gallery/$rows2[code]/";
              }else{
                $dir = "contents/$rows2[createBy]/$rows2[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++;
                  }
                }
              }
              ?>
              <div class="col-lg-12 col-md-12 col-sm-12">
                <span class="glyphicon glyphicon-picture"></span> <a href="?gal=<?php echo $rows2['code']?>&id=<?php echo $rows2['id']?>" target="_blank" title="<?php echo $rows2['name']?>"><?php echo $rows2['name']?></a>
                <p></p>
              </div>
              <?php
              for($indexPicture = 0;$indexPicture<4;$indexPicture++){
                $images = $pic_path[$indexPicture];
                if($images){
                ?>
                  <div class="col-lg-3 col-md-3 col-sm-6">
                    <div class="panel2 panel2-default">
                      <!-- <div class="panel2-body" style="max-width: 100%;height: 140px"> -->
                      <div class="panel2-body" style="max-width: 100%;">
                        <p><a class="zoom" data-type="image" data-title="<?php echo $rows2['name']?>" data-footer="<?php echo $rows2['name']?>" data-toggle="lightbox" href="?gal=<?php echo $rows2['code']?>&id=<?php echo $rows2['id']?>" target="_blank" title="<?php echo $rows2['name']?>">
                        <img class="img-thumbnail" src="images.php?nu=&xwidth=300&ximg=<?php echo $images?>" width="100%" alt="<?php echo ($indexPicture+1).'. '.$rows2['name']?>" title="<?php echo ($indexPicture+1).'. '.$rows2['name']?>">
                        </a><p>
                        <span class="overlay"></span>
                      </div>
                    </div>
                    <p></p>
                  </div>
                <?php
                }
              }
              echo "</div><div class='row slideanim'>";
            }
            ?>
            </div>
            <div class="col-lg-12 col-md-12 col-sm-12">
              <div class="row">
              <p align="right"><a class="btn btn-primary" role="button" href="?gal_cat=all" target="new">มีต่อ</a></p>
              </div>
            </div>
          </div>
        <?php
        }
        ?>
      </div>
      <?php */
      /*
      End Gallery
       */
      ?>
    </div>
    <?php
    /*include('connDB.php');
    $tg = "";
    $sql4 = "select * from ap_slides where level='00' and place='3' and status='1'";
    $query4 = mysqli_query($conn,$sql4);
    $i4 = 0;
    while($rows4 = mysqli_fetch_array($query4)){
    $i4++;
      if($rows4['url_link']!="#"){
        $tg = " target=\"_blank\"";
      }
    ?>
      <div class="col-lg-6 col-md-6 col-sm-6">
      <a href="<?php echo $rows4['url_link']?>"<?php echo $tg?>><img src="<?php echo $rows4['images']?>" alt="<?php echo $rows4['name']?>" width="100%" title="<?php echo $rows4['name']?>"></a>
      <p></p>
      </div>
    <?php
    } */

    /*
    End Columns 1
     */
    
    /*
    Columns 2
     */
    ?>
    <div class="col-lg-<?php echo "$col2_w"; ?> col-md-<?php echo "$col2_w"; ?> col-sm-12" <?php if($col2==""){ echo "style='display:none;'"; } ?>>
      <div class="row" align="rightx">
      <?php
      $sql4 = "select * from ap_slides where lang='$_GET[lang]' and date_time>$dt and place2='2' and status='1' order by date_time asc";
      $query4 = mysqli_query($conn,$sql4);
      $i4 = 0;
      while($rows4 = mysqli_fetch_array($query4)){
        $i4++;
        if(!empty($rows4['images'])){

          $images = str_replace("$ap_site$ap_folder/", "", $rows4['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");
          }

          $rows4['images'] = "$ap_site$ap_folder".str_replace("//", "/", "$dir/thumbs/thumb_s_$images2");
          ?>
          <div class="slideanimx">
            <?php if($rows4['url_link']!="#"){ ?><a class="zoom" href="<?php echo $rows4['url_link']?>" target="_blank" title="<?php echo $rows4['name']; ?>"><?php } ?>
            <img src="<?php echo $rows4['images']?>" width="95%" alt="<?php echo $rows4['name']?>" title="<?php echo $rows4['name']?>">
            <?php if($rows4['url_link']!="#"){ ?></a><?php } ?>
            <p></p>
            <p><div style="width: 95%"><?php echo $rows4['name']?></div></p>
            <p></p>
          </div>
        <?php
        }
      }
      ?>
      </div>
    </div>
    <?php
    /*
    End Columns 2
     */

    /*
    Columns 3
     */
    ?>
    <div class="col-lg-<?php echo "$col3_w"; ?> col-md-<?php echo "$col3_w"; ?> col-sm-12" <?php if($col3==""){ echo "style='display:none;'"; } ?>>
      <div style="text-align:right"><p><?php social(); ?></p></div>
      <div class="">
      <?php
      include('modify-top-columns3.php');
      ?>
      
      <?php /* google search */ /* ?>
      <form action="https://www.google.co.th/custom" id="labnolC32" target="google_window">
      <div class="input-group">
        <input type="hidden" name="sitesearch" value="<?php echo $_SERVER['SERVER_NAME'];?>"/>
        <input type="text" name="q" id="transcriptC32" class="form-control" placeholder="<?php echo $ap_enter_keyword ?>"/>
        <span class="input-group-btn" style="background-color: #cccccc">
            <img height="30" onclick="startDictationC32()" src="//i.imgur.com/cHidSVu.gif" />
            <button type="submit" class="btn btn-default"><?php echo $ap_search ?></button>
        </span>
      </div>
      </form><?php */ ?>

      <div class="row">
        <div class="col-lg-12 col-md-12 col-sm-12">
          <form action="?" id="labnolC32" method="GET" target="google_window">
          <input type="hidden" name="cat" value="all"/>
          <div class="input-group">
            <input type="text" name="q" id="transcriptC32" class="form-control" placeholder=""/>
            <span class="input-group-btn" style="background-color: #cccccc">
                <img height="30" onclick="startDictationC32()" src="//i.imgur.com/cHidSVu.gif" alt="ค้นหาข้อมูลใน <?php echo $title ?>" />
                <button type="submit" class="btn btn-default"><?php echo $ap_search ?></button>
            </span>
          </div>
          <input type="hidden" name="lang" value="<?php echo $_GET['lang'] ?>"/>
          </form>
          <p></p>
        </div>
      </div>
      
      <div class="row">
        <?php
        $tg = "";
        $sql4 = "select * from ap_slides where lang='$_GET[lang]' and level<='01' and (date_time>$dt and place3='3' and status='1') order by date_time asc";
        $query4 = mysqli_query($conn,$sql4);
        $i4 = 0;
        while($rows4 = mysqli_fetch_array($query4)){
        $i4++;

          if(preg_match("/\b$_SERVER[SERVER_NAME]\b/", $rows4['images']) == true){
            $images = str_replace("$ap_site$ap_folder/", "", $rows4['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");
            }
            $rows4['images'] = "$ap_site$ap_folder".str_replace("//", "/", "$dir/thumbs/thumb_s_$images2");
          }
          ?>
          <div class="col-lg-12 col-md-12 col-sm-6 col-xs-6 slideanimx">
            <a href="<?php echo $rows4['url_link']?>"<?php if($rows4['url_link']!="#"){ echo " target=\"_blank\""; } ?> title="<?php echo $rows4['name']; ?>">
              <img src="<?php echo $rows4['images']?>" alt="<?php echo $rows4['name']?>" width="100%" title="<?php echo $rows4['name']?>">
            </a>
            <p></p>
          </div>
        <?php
        }

        $sql4 = "select * from ap_slides where lang='$_GET[lang]' and level>'01' and (date_time>$dt and place3='3' and status='1') order by level asc";
        $query4 = mysqli_query($conn,$sql4);
        $i4 = 0;
        while($rows4 = mysqli_fetch_array($query4)){
        $i4++;

          if(preg_match("/\b$_SERVER[SERVER_NAME]\b/", $rows4['images']) == true){
            $images = str_replace("$ap_site$ap_folder/", "", $rows4['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");
            }
            $rows4['images'] = "$ap_site$ap_folder".str_replace("//", "/", "$dir/thumbs/thumb_s_$images2");
          }
          ?>
          <div class="col-lg-12 col-md-12 col-sm-6 col-xs-6 slideanimx">
            <a href="<?php echo $rows4['url_link']?>"<?php if($rows4['url_link']!="#"){ echo " target=\"_blank\""; } ?> title="<?php echo $rows4['name']; ?>">
              <img src="<?php echo $rows4['images']?>" width="100%" alt="<?php echo $rows4['name']?>" title="<?php echo $rows4['name']; ?>">
            </a>
            <p></p>
          </div>
        <?php
        }
        ?>
      </div>

      </div>
      <?php
      /*$_REQUEST['data'] = "$ap_site$ap_folder";
      $PNG_TEMP_DIR = dirname(__FILE__).DIRECTORY_SEPARATOR.'temp'.DIRECTORY_SEPARATOR;
      $PNG_WEB_DIR = 'temp/';
      if(!is_dir($PNG_WEB_DIR)) mkdir ($PNG_WEB_DIR);
      include('qrcode/qrlib.php');

      if(!file_exists($PNG_TEMP_DIR))
      mkdir($PNG_TEMP_DIR);
      $filename = $PNG_TEMP_DIR.'ap.png';

      $errorCorrectionLevel = 'H';
      if(isset($_REQUEST['level']) && in_array($_REQUEST['level'], array('L','M','Q','H')))
        $errorCorrectionLevel = $_REQUEST['level'];    

      $matrixPointSize = 10;
      if(isset($_REQUEST['size']))
        $matrixPointSize = min(max((int)$_REQUEST['size'], 1), 10);

      if(isset($_REQUEST['data'])) { 
        if(trim($_REQUEST['data']) == '')
          die('Anucha Puangpaka');

          $filename = $PNG_TEMP_DIR.'ap'.md5($_REQUEST['data'].'|'.$errorCorrectionLevel.'|'.$matrixPointSize).'.png';
          QRcode::png($_REQUEST['data'], $filename, $errorCorrectionLevel, $matrixPointSize, 2);
      }else{
        QRcode::png('Anucha Puangpaka', $filename, $errorCorrectionLevel, $matrixPointSize, 2);
      }
      echo '<img class="p-3 bg-white rounded shadow-sm" src="'.$PNG_WEB_DIR.basename($filename).'" width="100%" /><div class="pt-3"></div>';*/
      ?>
      <?php /* ?><img class="p-3 bg-white rounded shadow-sm" src="ap/qrcode/qrcode.php?data=<?php echo urlencode("$ap_site$ap_folder"); ?>&size=177x177&logo=<?php echo $logo; ?>" width="100%" border="0" alt="<?php echo $title ?>" title="<?php echo $title ?>" />
      <div class="pt-3"></div><?php */ ?>
      <?php
      mkdir("contents/qrcode/", 0777, true);
      if(!file_exists("contents/qrcode/qrcode.png")){
      ?>
        <img src="qrcode/qrcode.php?data=<?php echo $ap_site.$ap_folder; ?>&size=177x177&logo=<?php echo $logo_touch;?>&filename=<?php echo "qrcode"; ?>" alt="<?php echo "$apSubOwner $apOwner"; ?>" width="100%" title="<?php echo "$apSubOwner $apOwner"; ?>">
      <?php
      }else{ 
      ?>
        <img src="contents/qrcode/qrcode.png" alt="<?php echo "$apSubOwner $apOwner"; ?>" width="100%" title="<?php echo "$apSubOwner $apOwner"; ?>">
      <?php 
      }
 
      include('modify-bottom-columns3.php');
      ?>
    </div>
    <?php
    /*
    End Columns 3
     */
    ?>
  </div>
  <?php
  /*
  End Columns 1-3
   */

  /*
  Gallery 3
   */
  ?>
  <div class="visible-lg visible-md">
  <?php
  //if($_GET['lang']=="TH"){
    $rows_g = mysqli_fetch_array(mysqli_query($conn,"select count(id) as total from ap_gallery3"));
    $num_rows_g = $rows_g['total'];
    if($num_rows_g>0){
    ?>
      <p></p>
      <!-- <ul class="nav nav-tabs">
        <li class="active"><a href="#ap-ebooks" data-toggle="tab">eBooks Online</a></li>
      </ul> -->
      <?php
      $sql_c = "select * from ap_catalogs where code like 'eBooks%' and code not like 'eBooks-Ex-%' order by id asc";
      $sql_c = "select a.* from ap_catalogs a where a.code like 'eBooks%' and a.code not like 'eBooks-Ex-%' AND EXISTS (SELECT 1 FROM ap_gallery3 b WHERE b.catalogCode = a.code) order by a.id asc";
      $query_c = mysqli_query($conn,$sql_c);
      $num_rows_c = mysqli_num_rows($query_c);
      if($num_rows_c>0){
      ?>
      <p></p>
      <ul class="nav nav-tabs">
      <?php
      }
      $i_c = 0;
      while($rows_c = mysqli_fetch_array($query_c)){
      $i_c++;
      ?>
        <li <?php if($i_c==1){ echo " class=\"active\""; } ?>><a href="#<?php echo $rows_c['code']?>" data-toggle="tab" title="<?php echo $rows_c['name']; ?>"><img src="<?php echo $logo_touch; ?>" width="16px" alt="<?php echo $rows_c['name']?>"> <?php echo $rows_c['name']?></a></li>
      <?php
      }
      ?>
      </ul>
      <div class="tab-content">
        <?php 
        $query_c = mysqli_query($conn,$sql_c);
        $i_c = 0;
        while($rows_c = mysqli_fetch_array($query_c)){
        $i_c++;
        ?>
        <div class="tab-pane <?php if($i_c==1){ echo "active"; } ?>" id="<?php echo $rows_c['code']; ?>">
          <p></p>
          <div class="row slideanimx">
          <ul class="bookshelf">
          <?php
          //$sql = "select * from ap_gallery3 where status2=1 order by date_time desc limit $limit_list";
          $limit_listx = 6;
          $sql = "select * from ap_gallery3 where status2='1' and catalogCode='$rows_c[code]' order by date_time desc limit $limit_listx";
          $query = mysqli_query($conn,$sql);
          $ix = 0;
          while($rows = mysqli_fetch_array($query)){
            if($rows['images']){
              $ix++;
              ?>
              <?php /* ?><div class="col-lg-3 col-md-3 col-sm-12">
                <div class="panel2 panel2-default">
                <div class="panel2-body" style="max-width: 100%;height: 230px">
                <p><a class="zoom" data-type="image" data-title="<?php echo $rows['title']?>" data-footer="<?php echo $rows['title']?>" data-toggle="lightbox" href="ap/ebooks/?nu=info&xcode=<?php echo $rows['code']?>&xid=<?php echo $rows['id']?>" target="_blank" title="<?php echo $rows['title']?>">
                <img class="img-thumbnail" src="<?php echo $rows['images']?>" width="100%" alt="<?php echo $rows['title']?>" title="<?php echo $rows['title']?>">
                </a><p>
                <span class="overlay"></span>
                </div>
                </div>
                <p></p>
              </div><?php */
              if($limit_listx==1){
                $col = 12;
              }elseif($limit_listx==2){
                $col = 6;
              }elseif($limit_listx==3){
                $col = 3;
              }elseif($limit_listx==4){
                $col = 3;
              }else{
                $col = 2;
              }

              if(preg_match("/\b$_SERVER[SERVER_NAME]\b/", $rows['images']) == true){
                $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_s_$images2")){
                  $size = getimagesize("$images");
                  resize($size[0], "$dir/thumbs/thumb_s_$images2","$images");
                }
                $rows['images'] = "$ap_site$ap_folder".str_replace("//", "/", "$dir/thumbs/thumb_s_$images2");
              }
              ?>
              <div class="col-lg-<?php echo $col; ?> col-md-<?php echo $col; ?> col-sm-12">
              <li class="bookshelf-book bg-white">
              <?php if($ix<2){ ?>
              <div class="ribbon-new">
                <div><?php echo $ap_new ?></div>
              </div>
              <?php } ?>
              <!-- <img width="100%" src="images.php?nu=&xwidth=300&ximg=<?php echo $rows['images']?>" alt="<?php echo $rows['title']?>" title="<?php echo $rows['title']?>"> -->
              <img width="100%" src="<?php echo $rows['images']?>" alt="<?php echo $rows['title']?>" title="<?php echo $rows['title']?>">
              <div class="bookshelf-caption bottom-to-top" style="width: 100%;">
                <h1 class="h5"><?php echo $rows['title']?></h1>
                <a class="btn btn-primary" href="ap/ebooks/?nu=info&xcode=<?php echo $rows['code']?>&xid=<?php echo $rows['id']?>" target="_blank" title="<?php echo $rows['title']?>"><?php echo $ap_click ?></a>
              </div>
              </li>
              <p></p>
              </div>
            <?php
            }
          }
          ?>
          </ul>
          </div>
          <div class="col-lg-12 col-md-12 col-sm-12">
            <div class="row">
            <p></p>
            <p align="right"><a class="btn btn-primary" role="button" href="ap/ebooks/" target="_blank" title="<?php echo $ap_more; ?>"><?php echo $ap_more ?></a></p>
            </div>
          </div>
        </div>
        <?php 
        } 
        ?>
      </div>
      <?php
    }
  //}
  ?>
  </div>
  <?php
  /*
  End Gallery 3
   */

  /*
  Gallery 4
   */
  ?>
  <div class="">
  <?php
  //if($_GET['lang']=="TH"){
    $rows_g = mysqli_fetch_array(mysqli_query($conn,"select count(id) as total from ap_gallery4"));
    $num_rows_g = $rows_g['total'];
    if($num_rows_g>0){
    ?>
      <p></p>
      <!-- <ul class="nav nav-tabs">
        <li class="active"><a href="#ap-ebooks" data-toggle="tab">eBooks Online</a></li>
      </ul> -->
      <?php
      $sql_c = "select * from ap_catalogs where code like 'eBooks-Ex-%' order by id asc";
      $sql_c = "select a.* from ap_catalogs a where a.code like 'eBooks-Ex-%' AND EXISTS (SELECT 1 FROM ap_gallery4 b WHERE b.catalogCode = a.code) order by a.id asc";
      $query_c = mysqli_query($conn,$sql_c);
      $num_rows_c = mysqli_num_rows($query_c);
      if($num_rows_c>0){
      ?>
      <p></p>
      <ul class="nav nav-tabs">
      <?php
      }
      $i_c = 0;
      while($rows_c = mysqli_fetch_array($query_c)){
      $i_c++;
        ?>
        <li <?php if($i_c==1){ echo " class=\"active\""; } ?>><a href="#<?php echo $rows_c['code']?>" data-toggle="tab" title="<?php echo $rows_c['name']; ?>"><img src="<?php echo $logo_touch; ?>" width="16px" alt="<?php echo $rows_c['name']?>"> <?php echo $rows_c['name']?></a></li>
      <?php
      }
      ?>
      </ul>
      <div class="tab-content">
        <?php 
        $query_c = mysqli_query($conn,$sql_c);
        $i_c = 0;
        while($rows_c = mysqli_fetch_array($query_c)){
        $i_c++;
        ?>
        <div class="tab-pane <?php if($i_c==1){ echo "active"; } ?>" id="<?php echo $rows_c['code']; ?>">
          <p></p>
          <div class="row slideanimx">
          <ul class="bookshelf">
          <?php
          //$sql = "select * from ap_gallery4 where status2=1 order by date_time desc limit $limit_list";
          $limit_listx = 6;
          $sql = "select * from ap_gallery4 where status2='1' and catalogCode='$rows_c[code]' order by date_time desc limit $limit_listx";
          $query = mysqli_query($conn,$sql);
          $ix = 0;
          while($rows = mysqli_fetch_array($query)){
            if($rows['images']){
              $ix++;
              ?>
              <?php /* ?><div class="col-lg-3 col-md-3 col-sm-12">
                <div class="panel2 panel2-default">
                <div class="panel2-body" style="max-width: 100%;height: 230px">
                <p><a class="zoom" data-type="image" data-title="<?php echo $rows['title']?>" data-footer="<?php echo $rows['title']?>" data-toggle="lightbox" href="ap/ebooks/?nu=info&xcode=<?php echo $rows['code']?>&xid=<?php echo $rows['id']?>" target="_blank" title="<?php echo $rows['title']?>">
                <img class="img-thumbnail" src="<?php echo $rows['images']?>" width="100%" alt="<?php echo $rows['title']?>" title="<?php echo $rows['title']?>">
                </a><p>
                <span class="overlay"></span>
                </div>
                </div>
                <p></p>
              </div><?php */
              if($limit_listx==1){
                $col = 12;
              }elseif($limit_listx==2){
                $col = 6;
              }elseif($limit_listx==3){
                $col = 3;
              }elseif($limit_listx==4){
                $col = 3;
              }else{
                $col = 2;
              }

              if(preg_match("/\b$_SERVER[SERVER_NAME]\b/", $rows['images']) == true){
                $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_s_$images2")){
                  $size = getimagesize("$images");
                  resize($size[0], "$dir/thumbs/thumb_s_$images2","$images");
                }
                $rows['images'] = "$ap_site$ap_folder".str_replace("//", "/", "$dir/thumbs/thumb_s_$images2");
              }
              ?>
              <div class="col-lg-<?php echo $col; ?> col-md-<?php echo $col; ?> col-sm-12">
              <li class="bookshelf-book bg-white">
              <?php if($ix<2){ ?>
              <div class="ribbon-new">
                <div><?php echo $ap_new ?></div>
              </div>
              <?php } ?>
              <!-- <img width="100%" src="images.php?nu=&xwidth=300&ximg=<?php echo $rows['images']?>" alt="<?php echo $rows['title']?>" title="<?php echo $rows['title']?>"> -->
              <img width="100%" src="<?php echo $rows['images']?>" alt="<?php echo $rows['title']?>" title="<?php echo $rows['title']?>">
              <div class="bookshelf-caption bottom-to-top" style="width: 100%;">
                <h1 class="h5"><?php echo $rows['title']?></h1>
                <!-- <a class="btn btn-primary" href="ap/ebooks/?nu=info&xcode=<?php echo $rows['code']?>&xid=<?php echo $rows['id']?>" target="_blank" title="<?php echo $rows['title']?>"><?php echo $ap_click ?></a> -->
                <a class="btn btn-primary" href="ap/ebooks/?nu=info3&xcode=<?php echo $rows['code']?>&xid=<?php echo $rows['id']?>" target="_blank" title="<?php echo $rows['title']?>"><?php echo $ap_click ?></a>
              </div>
              </li>
              <p></p>
              </div>
            <?php
            }
          }
          ?>
          </ul>
          </div>
          <div class="col-lg-12 col-md-12 col-sm-12">
            <div class="row">
            <p></p>
            <p align="right"><a class="btn btn-primary" role="button" href="ap/ebooks/?nu=list4" target="_blank" title="<?php echo $ap_more; ?>"><?php echo $ap_more ?></a></p>
            </div>
          </div>
        </div>
        <?php 
        } 
        ?>
      </div>
      <?php
    }
  //}
  ?>
  </div>
  <?php
  /*
  End Gallery 4
   */

  /*
  Gallery 2
   */
  $rows_g = mysqli_fetch_array(mysqli_query($conn,"select count(id) as total from ap_gallery2 where lang='$_GET[lang]'"));
  $num_rows_g = $rows_g['total'];
  if($num_rows_g>0){?>
    <div class="col-lg-12 col-md-12 col-sm-12">
      <div class="row"><hr></div>
    </div>
    <ul class="nav nav-tabs">
      <?php
      $sql_c = "select * from ap_catalogs where lang='$_GET[lang]' and status='1' order by level asc limit 1";
      $sql_c = "select * from ap_catalogs where lang='$_GET[lang]' and status='1' order by level asc";
      $query_c = mysqli_query($conn,$sql_c);
      $i_c = 0;
      while($rows_c = mysqli_fetch_array($query_c)){
        $rows_g = mysqli_fetch_array(mysqli_query($conn,"select count(*) as total from ap_gallery2 where lang='$_GET[lang]' and catalogCode='$rows_c[code]'"));
        $num_rows_g = $rows_g['total'];
        if($num_rows_g>0){
          $i_c++;
          ?>
          <li <?php if($i_c==1){ echo "class=\"active\""; } ?>><a href="#ap2<?php echo $rows_c['code']?>" data-toggle="tab" title="<?php echo $rows_c['name']; ?>"><img src="<?php echo $logo_touch; ?>" width="16px" alt="<?php echo $rows_c['name']?>"> <?php echo $rows_c['name']?></a></li>
          <?php /* ?><li <?php echo $active_status;?>><a href="#ap2<?php echo $rows_c['code']?>" data-toggle="tab"><?php echo $ap_media?></a></li><?php */ ?>
          <!-- <li role="presentation"><a href="#">Profile</a></li>
          <li role="presentation"><a href="#">Messages</a></li> -->
        <?php
        }
      }
      ?>
    </ul>
  <?php
  }
  ?>
  <div class="tab-content">
    <?php
    $allowed_types = array('mp4','MP4','m4v','M4V','mov','MOV');
    $query_c = mysqli_query($conn,$sql_c);
    $i_c = 0;
    while($rows_c = mysqli_fetch_array($query_c)){
      $rows_g = mysqli_fetch_array(mysqli_query($conn,"select count(id) as total from ap_gallery2 where lang='$_GET[lang]' and catalogCode='$rows_c[code]'"));
      $rows_g = mysqli_fetch_array(mysqli_query($conn,"select count(id) as total from ap_gallery2 where lang='$_GET[lang]'"));
      $num_rows_g = $rows_g['total'];
      if($num_rows_g>0){
        $i_c++;
        ?>
        <div class="tab-pane<?php if($i_c==1){ echo " active"; } ?>" id="ap2<?php echo $rows_c['code']?>">
          <p></p>
          <div class="row">
          <?php
          if($i_c==1){
            $sql2 = "select * from ap_gallery2 where lang='$_GET[lang]' order by date_time desc limit 4";
          }else{
            $sql2 = "select * from ap_gallery2 where lang='$_GET[lang]' and catalogCode='$rows_c[code]' order by date_time desc limit 4";
          }
          $query2 = mysqli_query($conn,$sql2);
          $i2 = 0;
          while($rows2 = mysqli_fetch_array($query2)){
          $i2++;
            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);

            mkdir($dir2.'thumbs/', 0777, true);

            if($ap_webp=="on"){
              $im = explode(".", $images2);
              $images2 = "$im[0].webp";
            }

            if(!file_exists("$dir2/thumbs/thumb_s_$images2")){
              $size = getimagesize("$images");
              resize($size[0], "$dir2/thumbs/thumb_s_$images2","$images");
            }

            $sizeImg = getimagesize("$dir2/thumbs/thumb_s_$images2");
            $widthImg = $sizeImg['0'];
            $heightImg = $sizeImg['1'];

            $rows2['images'] = "$ap_site$ap_folder".str_replace("//", "/", "$dir2/thumbs/thumb_s_$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="col-lg-3 col-md-3 col-sm-12 col-xs-12">
              <div class="breadcrumb">
                <!-- <a href="?gal2=<?php echo $rows2['code']?>&id=<?php echo $rows2['id']?>&lang=<?php echo $_GET['lang']?>" target="new"><?php echo $rows2['name']?></a><br> -->
                <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 substr_utf8($rows2['name'],0,25)."ฯ..";  ?>">
                  <?php }else{ ?>
                    <a href="?gal2=<?php echo $rows2['code']; ?>&id=<?php echo $rows2['id']; ?>&lang=<?php echo $_GET['lang'] ?>" target="_blank" title="<?php echo substr_utf8($rows2['name'],0,25)."ฯ..";  ?>">
                  <?php } ?>
                  <?php echo substr_utf8($rows2['name'],0,25)."ฯ..";  ?></a></h1>
                <!-- <?php echo number_format($rows2['counters']); ?> views / <?php echo dateThai($rows2['date_time']); ?><br> -->
                <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<1;$indexPicture++){
                  $images = $pic_path[$indexPicture];
                  if($images){
                    ?>
                    <div align="row center">
                      <div class="panel2 panel2-default">
                        <div class="panel2-body" style="max-width: 100%;max-height: 170px">
                          <?php if($ap_rewrite=="on"){ ?>
                            <a href="gal2/<?php echo $rows2['code']?>/<?php echo $rows2['id']?>/<?php echo $_GET['lang']?>" target="new" 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="new" 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 id="<?php echo $rows2['code']?>" poster="<?php echo $rows2['images'] ?>" width="100%" preload="true" controls>
                          <source src="<?php echo $images?>" />
                        </video>
                      </object><?php */ ?>
                      <?php /* ?><div class="slideanimx"><a href="?gal2=<?php echo $rows2['code']?>&id=<?php echo $rows2['id']?>&lang=<?php echo $_GET['lang']?>" target="new"><img src="<?php echo $rows2['images'] ?>" width="100%" height="200" alt="<?php echo $rows4['name']?>" title="<?php echo $rows4['name']?>"></a></div><p></p><?php */ ?>
                    </div>
                  <?php
                  }
                }
                ?>
              </div>
            </div>
          <?php
          }
          ?>
          </div>
          <div class="row">
            <div class="col-lg-8 col-md-8 col-sm-12"></div>
            <div class="col-lg-4 col-md-4 col-sm-12">
              <p align="right">
              <?php if($ap_rewrite=="on"){ ?>
                <a class="btn btn-primary" role="button" href="gal2_cat/<?php if($i_c==1){ echo "all"; }else{ echo $rows_c['code']; } ?>/<?php echo $_GET['lang']?>" target="new" title="<?php echo $ap_more ?>">
              <?php }else{ ?>
                <a class="btn btn-primary" role="button" href="?gal2_cat=<?php if($i_c==1){ echo "all"; }else{ echo $rows_c['code']; } ?>&lang=<?php echo $_GET['lang']?>" target="new" title="<?php echo $ap_more ?>">
              <?php } ?>
              <?php echo $ap_more ?></a></p>
            </div>
          </div>
        </div>
      <?php
      }
    }
    ?>
  </div>
  <?php 
  /*
  End Gallery 2
   */
  ?>

  <?php
  /*
  Slide Place 2 and External Banner
   */
  $sql = "select count(id) as total from ap_slides where lang='$_GET[lang]' and (date_time>$dt and place='2' and status='1') order by date_time asc";
  $query = mysqli_query($conn,$sql);
  $rows = mysqli_fetch_array($query);
  $num_rows = $rows['total'];
  $sql = "select * from ap_slides where lang='$_GET[lang]' and (date_time>$dt and place='2' and status='1') order by date_time asc";
  if($num_rows>0){
  ?>
    <div class="col-lg-12 col-md-12 col-sm-12">
      <?php /* ?><p><strong><?php echo $ap_pr_slide_place2; ?></strong></p><?php */ ?>
      <div class="row"><hr></div>
    </div>
    <div class="row">
      <div class="col-lg-4 col-md-4 col-sm-6 col-xs-6">
        <div id="carousel-main-generic2" class="carousel slide" data-ride="carousel">
          <?php  ?>
            <ol class="carousel-indicators">
            <?php
            //$sql = "select * from ap_slides where date_time>$dt and place='1' and status='1' order by id desc";
            $query = mysqli_query($conn,$sql);
            $i = 0;
            while($rows = mysqli_fetch_array($query)){
            $i++;
            ?>
              <li data-target="#carousel-main-generic2" data-slide-to="<?php echo ($i-1);?>"<?php if($i==1){ echo " class=\"active\""; } ?>></li>
            <?php
            }
            ?>
            </ol>
          <?php  ?>
          <div class="carousel-inner" role="listbox">
            <?php
            /*$sql = "select * from ap_slides where date_time>$dt and place='1' and status='1' order by date_time asc";*/
            $query = mysqli_query($conn,$sql);
            $i = 0;
            while($rows = mysqli_fetch_array($query)){
            $i++;

              if(preg_match("/\b$_SERVER[SERVER_NAME]\b/", $rows['images']) == true){
                $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_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'];

                $rows['images'] = "$ap_site$ap_folder".str_replace("//", "/", "$dir/thumbs/thumb_s_$images2");
              }
              ?>
              <div class="item<?php if($i==1){ echo " active"; } ?>">
                <?php if($rows['url_link']=="#" || $rows['url_link']==""){?>
                  <!-- <img src="images.php?nu=&xwidth=1175&ximg=<?php echo $rows['images']?>" width="100%" alt="<?php echo $rows['name']?>"> -->
                  <img src="<?php echo $rows['images']?>" width="100%" alt="<?php echo $rows['name']?>"  title="<?php echo $rows['name']?>">
                <?php }else{ ?>
                  <a href="<?php echo $rows['url_link']; ?>" target="_blank" title="<?php echo $rows['name']; ?>">
                <!-- <img src="images.php?nu=&xwidth=1175&ximg=<?php echo $rows['images']?>" width="100%" alt="<?php echo $rows['name']?>" title="<?php echo $rows['name']?>"> -->
                    <img src="<?php echo $rows['images']?>" width="100%" alt="<?php echo $rows['name']?>" title="<?php echo $rows['name']?>"></a>
                <?php } ?>
              </div>
            <?php
            }
            ?>
          </div>
        </div>
        <a class="left carousel-control" href="#carousel-main-generic2" role="button" data-slide="prev">
          <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
          <span class="sr-only">Previous</span>
        </a>
        <a class="right carousel-control" href="#carousel-main-generic2" role="button" data-slide="next">
          <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
          <span class="sr-only">Next</span>
        </a>
        <p></p>
      </div>
      <div class="col-lg-8 col-md-8 col-sm-12">
        <div class="row">
          <?php
          /*
          External Banner
           */
          $sql_eb = "select count(id) as total from ap_externalbanner where lang='$_GET[lang]' and status='1' ";
          $query_eb = mysqli_query($conn,$sql_eb);
          $rows_eb = mysqli_fetch_array($query_eb);
          $num_rows_eb = $rows_eb['total'];
          $sql_eb = "select * from ap_externalbanner where lang='$_GET[lang]' and status='1' order by rand()";
          $sql_eb .= " limit 12";
          $query_eb = mysqli_query($conn,$sql_eb);
          if($num_rows_eb>0){
            $i_eb = 0;
            while($rows_eb = mysqli_fetch_array($query_eb)){
              $i_eb++;
              /*$sql2 = "select * from ap_catalogs where code='$rows_eb[catalogCode]'";
              $query2 = mysqli_query($conn,$sql2);
              $rows2 = mysqli_fetch_array($query2);
              if($i_eb==1){
              ?>
                <div class="col-lg-12 col-md-12 col-sm-12">
                  <div class="row">
                  <p align="right"><strong><?php echo $rows2['name'] ?></strong></p>
                  </div>
                </div>
              <?php
              }*/
              if(!empty($rows_eb['images'])){

                if(preg_match("/\b$_SERVER[SERVER_NAME]\b/", $rows_eb['images']) == true){
                  $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");
                  }

                  $sizeImg = getimagesize("$dir/thumbs/thumb_s_$images2");
                  $widthImg = $sizeImg['0'];
                  $heightImg = $sizeImg['1'];

                  $rows_eb['images'] = "$ap_site$ap_folder".str_replace("//", "/", "$dir/thumbs/thumb_s_$images2");
                }
                ?>
                <div class="visible-lg visible-md col-lg-2 col-md-2 col-sm-12 col-xs-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" width="100%" alt="<?php echo $rows_eb['name']?>" title="<?php echo $rows_eb['name']?>">
                  <?php if($rows_eb['url_link']!="#"){ ?></a><?php } ?>
                  <p></p>
                </div>
              <?php
              }
            }
            ?>
            <?php
            /*if($num_rows_eb>4){
            ?>
            <div class="col-lg-12 col-md-12 col-sm-12">
              <div class="row slideanim">
              <p align="right"><a class="btn btn-primary" role="button" href="?banners=all&lang=<?php echo $_GET['lang']?>" target="new"><?php echo $ap_more ?></a></p>
              </div>
            </div>
            <?php
            }*/
          }
          /*
          End External Banner
           */
          ?>
        </div>
      </div>
    </div>
  <?php
  }
  /*
  End Slide Place 2  and External Banner
   */

  /*
  External Banner empty($_GET['options'])
   */
  if(empty($externalbanner_bottom_slide) || $externalbanner_bottom_slide=="1"){
  ?>
    <div class="col-lg-12 col-md-12 col-sm-12">
    <?php
    $sql_eb = "select * from ap_externalbanner where lang='$_GET[lang]' and status='1' order by code asc, level asc";
    $sql_eb = "select * from ap_externalbanner where lang='$_GET[lang]' and status='1' order by rand()";
    $query_eb = mysqli_query($conn,$sql_eb);
    $num_rows_eb = mysqli_num_rows($query_eb);
    //$sql_eb .= " limit 8";
    $query_eb = mysqli_query($conn,$sql_eb);
    if($num_rows_eb>0){
    ?>
      <div class="col-lg-12 col-md-12 col-sm-12">
        <?php /* ?><p><strong><?php echo $ap_pr_slide_place2; ?></strong></p><?php */ ?>
        <div class="row"><hr></div>
      </div>
      <div class="row">
        <?php
        $i_eb = 0;
        while($rows_eb = mysqli_fetch_array($query_eb)){
          $i_eb++;
          /*$sql2 = "select * from ap_catalogs where code='$rows_eb[catalogCode]'";
          $query2 = mysqli_query($conn,$sql2);
          $rows2 = mysqli_fetch_array($query2);
          if($i_eb==1){
          ?>
            <div class="col-lg-12 col-md-12 col-sm-12">
              <div class="row">
              <p align="right"><b><?php echo $rows2['name'] ?></b></p>
              </div>
            </div>
          <?php
          }*/
          if(!empty($rows_eb['images'])){

            if(preg_match("/\b$_SERVER[SERVER_NAME]\b/", $rows_eb['images']) == true){
              $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");
              }

              $sizeImg = getimagesize("$dir/thumbs/thumb_s_$images2");
              $widthImg = $sizeImg['0'];
              $heightImg = $sizeImg['1'];

              $rows_eb['images'] = "$ap_site$ap_folder".str_replace("//", "/", "$dir/thumbs/thumb_s_$images2");
            }
            ?>
            <div class="col-lg-2 col-md-2 col-sm-6">
              <?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 if($num_rows_eb>8){ ?>
      <div class="col-lg-12 col-md-12 col-sm-12">
        <div class="row slideanimx">
          <p align="right"><a class="btn btn-primary" role="button" href="?banners=all" target="new" title="มีต่อ">มีต่อ</a></p>
        </div>
      </div>
      <?php 
      }
    }
    ?>
    </div>
  <?php
  }
  /*
  End External Banner
   */

  /*
  External URL
   */
  $sql_c2 = "select * from ap_catalogs where lang='$_GET[lang]' and external_status='1' order by code asc";
  $query_c2 = mysqli_query($conn,$sql_c2);
  $num_rows_c2 = mysqli_num_rows($query_c2);

  if($num_rows_c2>0){
  ?>
    <div class="col-lg-12 col-md-12 col-sm-12">
      <hr>
      <div class="row">
        <?php
        $i_c2 = 0;
        while($rows_c2 = mysqli_fetch_array($query_c2)){
          $i_c2++;
          ?>
          <div class="col-lg-3 col-md-3 col-sm-6">
            <div class="panelx breadcrumb">
              <div class="panel-headingx">
                <h1 class="h4" align=""><?php echo $rows_c2['name']?></h1>
              </div>
              <div class="panel-bodyx">
                <ul class="list-group" style="box-shadow:none;">
                <?php
                $sql_e = "select * from ap_externalurl where lang='$_GET[lang]' and catalogCode='$rows_c2[code]' order by level asc";
                $query_e = mysqli_query($conn,$sql_e);
                while($rows_e = mysqli_fetch_array($query_e)){
                ?>
                  <li class="" style="list-style-type: none;"><i class="fab fa-creative-commons-nd"></i> <a href="<?php echo $rows_e['url_link']?>" target="_blank" title="<?php echo $rows_e['name']?>">: <?php echo $rows_e['name']?></a></li>
                <?php
                }
                ?>
                </ul>
              </div>
              <p></p>
            </div>
          </div>
          <?php
          if($i_c2 %4==0 && $num_rows_c2>4){
          ?>
              <div class="col-lg-12 col-md-12 col-sm-12"><hr></div>
            </div>
            <div class="row">
          <?php
          }
        }
        ?>
      </div><!-- /.row -->
    </div>
  <?php
  }
  /*
  End External URL
   */
  ?>

  <div class="row slideanimx">
    <!-- <div class="col-lg-6 col-md-6 col-sm-6"> -->
      <!-- <div align="center">
        <object class="embed-responsive-item">
          <video width="100%" controls autoplay>
            <source src="contents/gallery/video/King-10.mp4" />
          </video>
        </object>
      </div> -->
    <!-- </div> -->
    <!-- <div class="col-lg-3 col-md-3 col-sm-6"></div> -->
    <!-- <div class="col-lg-3 col-md-3 col-sm-6"></div> -->
    <!-- <div class="col-lg-12 col-md-12 col-sm-12"><hr></div> -->
  </div><!-- /.row -->

</div>