| Server IP : 27.254.152.13 / Your IP : 216.73.217.38 Web Server : Apache/2 System : Linux ns1-252017.dragonhispeed.com 5.2.0 #1 SMP Fri Mar 29 22:50:14 MSK 2024 x86_64 User : coloflew ( 1072) PHP Version : 5.6.40 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/coloflew/domains/tessabalpatiu.go.th/public_html/egp/ |
Upload File : |
<html lang="en">
<head>
<meta charset="utf-8">
<link href="dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="./css/menu1.css" media="all">
<link rel="stylesheet" type="text/css" href="./css/menu2.css" media="all">
<link href="font-awesome-4.6.3/css/font-awesome.min.css" rel="stylesheet" media="all">
<link href="https://fonts.googleapis.com/css?family=Kanit:100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i|Mitr:200,300,400,500,600,700|Prompt:100,100i,200,200i,300,300i,400,400i,500,500i,600,700,700i,800,800i,900,900i" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp" crossorigin="anonymous">
</head>
<?php
$serverName = "localhost";
$userName = "root";
$userPassword = "";
$dbName = "egp_link";
$conn = mysqli_connect($serverName, $userName, $userPassword, $dbName);
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$depid = "5350501";
$aType = array('P0', '15', 'B0', 'D0', 'W0', 'D1', 'W1', 'D2', 'W2');
$aCat = array(1, 2, 3, 4, 5, 6, 7, 8, 9); //รหัสหมวดหมู่ สำหรับแยกประเภทประกาศ anounceType
date_default_timezone_set('Asia/Bangkok');
$begintime1 = strtotime("12:01:01");
$endtime1 = strtotime("12:59:00");
$begintime2 = strtotime("17:01:01");
$endtime2 = strtotime("24:00:00");
$begintime3 = strtotime("00:00:01");
$endtime3 = strtotime("08:59:59");
$now = time();
?>
<?php
if (($now >= $begintime1 && $now <= $endtime1) || ($now >= $begintime2 && $now <= $endtime2) || ($now >= $begintime3 && $now <= $endtime3)) {
$i = 0;
foreach ($aType as $newsType) { //ประเภทประกาศ
//$url = "http://www.tungpheung.go.th/newsfeed.xml"; //ไฟล์ xml สำหรับใช้ทดสอบ
$url = "http://process3.gprocurement.go.th/EPROCRssFeedWeb/egpannouncerss.xml?deptId=" . $depid . "&anounceType=" . $newsType;
libxml_use_internal_errors(true);
$doc = simplexml_load_string(file_get_contents($url));
if ($doc === false) {
libxml_clear_errors();
libxml_use_internal_errors($doc);
} else {
$items = $doc->xpath("/rss/channel/item");
foreach ($items as $item) {
//ตรวจสอบข่าวที่มีอยู่แล้ว
$sql = "SELECT * FROM tbl_egp WHERE TRIM(egp_detail)=TRIM('".$item->link."') AND cat_id=".$aCat[$i];
$result = $conn->query($sql);
$numrows = $result->num_rows; //ขอโทษด้วยครับ โค้ดเดิม $conn->num_rows มันผิดครับ
if(!$numrows) { //ถ้าไม่ซ้ำ (มี Feed ข่าวใหม่)
$sql = "INSERT INTO tbl_egp (egp_title, egp_detail, cat_id) VALUES ('".trim($item->title)."' , '".trim($item->link)."', ".$aCat[$i].")";
$query = $conn->query($sql) ;
}
$i++;
} //for each ($item
} // else if ($doc
} //foreach ($aType
} // if (in time
$sql = "SELECT a.*, b.cat_name, b.cat_alias,b.cat_id FROM tbl_egp a, tbl_category b WHERE a.cat_id=b.cat_id ORDER BY id DESC";
$result =$conn->query($sql);
if($result->num_rows) { //ถ้ามี Feed ข่าวในฐานข้อมูล
echo "<ul>";
while($row=$result->fetch_array(MYSQLI_ASSOC)) {
echo "<div class=\"header-top\">";
echo "".$row["cat_id"]." || ".$row["cat_alias"]."|| ".$row["cat_name"]."";
echo "</div>";
echo "<div class=\"header-top\">";
echo "<a href=\"".$row["egp_detail"]."\" targer=\"_blank\">".$row["egp_title"]."</a>";
echo "</div>";
}
echo "</ul>";
} else {
echo "-- ยังไม่มีข้อมูล -- <br>โปรดค้นหาจากเว็บไซต์กรมบัญชีกลางโดยตรง -> <a href='http://www.gprocurement.go.th' target='_blank'>คลิก</a>";
}
?>