Path : /var/www/html/main/ap/university/
File Upload :
Current File : /var/www/html/main/ap/university/index.php

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

error_reporting(E_ALL);
ini_set("display_errors", 0);

include('../../head.php');

$xsites = "$ap_site$ap_folder"."ap/university/";
?>

<div class="body-main-row-body container theme-showcase" role="main">
  <div class="breadcrumbx">
    
    <p></p>
    
    <?php
    if($_GET['nu']==""){
      $headers = array("Content-Type: application/json", "Method: GET", "Token: S2FtcGhhZW5nIFBoZXQgUmFqYWJoYXQgVW5pdmVyc2l0eQ==");
	    $url = "https://arit.kpru.ac.th/ap/api/index.php?nu=department";
	    $ch = curl_init($url);
	    curl_setopt($ch, CURLOPT_HEADER, 0);
	    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
	    curl_setopt($ch, CURLOPT_TIMEOUT, 15);
	    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
	    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
	    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	    $data = curl_exec($ch);
	    curl_close($ch);
	    $json = json_decode($data, true);
	    $json_total = count($json);
    	?>

      <h1 class="h3 text-center">มหาวิทยาลัยราชภัฏกำแพงเพชร</h1>
      <br>
      <div class="table-responsive">
        <table class="table table-bordered">
        <thead>
          <tr>
            <th width="100">ลำดับ</th>
            <th>หน่วยงาน</th>
            <th>รหัส</th>
            <th>Website</th>
          </tr>
        </thead>
        <tbody>
        <?php
        $n = 0;
        for($i=0;$i<$json_total;$i++){
        	$headers2 = array("Content-Type: application/json", "Method: GET", "Token: S2FtcGhhZW5nIFBoZXQgUmFqYWJoYXQgVW5pdmVyc2l0eQ==");
		      $url2 = "https://arit.kpru.ac.th/ap/api/index.php?nu=subdepartment&code=".$json[$i]['code'];
		      $ch2 = curl_init($url2);
		      curl_setopt($ch2, CURLOPT_HEADER, 0);
		      curl_setopt($ch2, CURLOPT_HTTPHEADER, $headers2);
		      curl_setopt($ch2, CURLOPT_TIMEOUT, 15);
		      curl_setopt($ch2, CURLOPT_CONNECTTIMEOUT, 15);
		      curl_setopt($ch2, CURLOPT_SSL_VERIFYPEER, 0);
		      curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1);
		      $data2 = curl_exec($ch2);
		      curl_close($ch2);
		      $json2 = json_decode($data2, true);
		      $json_total2 = count($json2);
		      for($i2=0;$i2<$json_total2;$i2++){
		      	$n++;
        		?>
	          <tr>
	            <td><?php echo $n; ?>.</td>
	            <td><a href="<?php echo $json2[$i2]['url_link']; ?>" target="_blank"><?php echo $json2[$i2]['name']; ?></a></td>
	            <td><a href="<?php echo $json2[$i2]['url_link']; ?>" target="_blank"><?php echo $json2[$i2]['code']; ?></a></td>
	            <td><a href="<?php echo $json2[$i2]['url_link']; ?>" target="_blank"><?php echo $json2[$i2]['url_link']; ?></a></td>
	          </tr>
        	<?php 
        	}
        } 
        ?>
        </tbody>
        </table>
      </div>
    <?php
    }
    ?>

  </div>
  <p></p>
</div>
<?php
include('../../footText.php');
include('../../foot.php');
?>