Tryag File Manager
Home
||
Turbo Force
||
B-F Config_Cpanel
Current Path :
/
home
/
nayongnua
/
domains
/
nayongnua.go.th
/
public_html
/
Or
Select Your Path :
Upload File :
New :
File
Dir
/home/nayongnua/domains/nayongnua.go.th/public_html/rssfeedcurl.php
<?php if (!isset($_deptsubId)) { $_deptsubId = ''; echo "<h3><span style='color:#ff0000'>..กรุณาระบุเลขของหน่วยงาน..</span></h3>"; if(isset($conndb)) { mysql_close($conndb);unset($conndb); } die();exit(); } function dateThai_egp($date) { $m_name = array("00"=>" ","01"=>"ม.ค.","02"=>"ก.พ.","03"=>"มี.ค.","04"=>"เม.ย.","05"=>"พ.ค.","06"=>"มิ.ย.","07"=>"ก.ค.","08"=>"ส.ค.","09"=>"ก.ย.","10"=>"ต.ค.","11"=>"พ.ย.","12"=>"ธ.ค."); $yy=substr("$date",0,4);$mm=substr("$date",5,2);$dd=substr("$date",8,2);$time=substr("$date",11,8); $dateTh = ""; if($yy=="0000") { $dateTh = $dd." ".$m_name[$mm]." ".$yy; }else{ $yy+=543; $dateTh = $dd." ".$m_name[$mm]." ".$yy; } if($time != ""){ $dateTh .= " ".$time; } return $dateTh; } $anounceType = array("P0","๑๕","B0","D0","W0","D๑","W๑","D๒","W๒"); //ประเภทประกาศ foreach($anounceType as $atype ): //$rssurl = 'http://process3.gprocurement.go.th/EPROCRssFeedWeb/egpannouncerss.xml?deptsubId='.$_deptsubId."&anounceType=".$atype; if (isset($_GET["Ymd"])) { $mpubdate = $_GET["Ymd"]; $rssurl = 'http://process3.gprocurement.go.th/EPROCRssFeedWeb/egpannouncerss.xml?deptsubId='.$_deptsubId."&anounceType=".$atype."&announceDate=".$mpubdate; } else { $rssurl = 'http://process3.gprocurement.go.th/EPROCRssFeedWeb/egpannouncerss.xml?deptsubId='.$_deptsubId."&anounceType=".$atype; } $num1 = 0; $c_group_name = ""; switch ( $atype ) { case 'P0' : $c_group_name = "แผนการจัดซื้อจัดจ้าง"; break ; case '๑๕' : $c_group_name = "ประกาศราคากลาง"; break ; case 'B0' : $c_group_name = "ร่างเอกสารประกวดราคา(e-Bidding)และร่างเอกสารซื้อหรือจ้างด้วยวิธีสอบราคา"; break ; case 'D0' : $c_group_name = "ประกาศเชิญชวน"; break ; case 'W0' : $c_group_name = "ประกาศรายชื่อผู้ชนะการเสนอราคา/ประกาศผู้ได้รับการคัดเลือก"; break ; case 'D๑' : $c_group_name = "ยกเลิกการประกาศเชิญชวน"; break ; case 'W๑' : $c_group_name = "ยกเลิกการประกาศรายชื่อผู้ชนะการเสนอราคา/ประกาศผู้ได้รับการคัดเลือก"; break ; case 'D๒' : $c_group_name = "เปลี่ยนแปลงประกาศเชิญชวน"; break ; case 'W๒' : $c_group_name = "เปลี่ยนแปลงประกาศรายชื่อผู้ชนะการเสนอราคา"; break ; default : $c_group_name = ""; break ; } echo "<br>"; echo "ประเภทประกาศ : <strong>".$atype."</strong> - ".$c_group_name."\r\n"; $ch = curl_init(); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3); curl_setopt($ch, CURLOPT_TIMEOUT, 300); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $rssurl); // get the url contents $data = curl_exec($ch); // execute curl request curl_close($ch); $numxml = stripos($data,'channel'); if($data && ($numxml >= 1)) { $xml = simplexml_load_string($data); //foreach ($xml as $report_daily): foreach ($xml->channel as $value1): foreach ($value1->item as $value2): $egp_title=$value2->title; $egp_link=$value2->link; $pubDate=$value2->pubDate; $c_egp_date_th = dateThai_egp($pubDate); $num1 = strpos($egp_link,'projectId'); //echo iconv( 'UTF-8', 'TIS-620', $egp_title)."<br>".$egp_link."<br>".$pubDate."<br>".$num1."<br/>"; $egp_projectId = 0;//projectId if ($num1 > 0) { $egp_projectId = substr($egp_link,$num1+10,11); //ตึง projectId จาก link egp } if($egp_projectId > 0){ $sql_rss = "SELECT `egp_projectId` FROM `tbl_egp_rss` WHERE (`egp_projectId` = '".$egp_projectId."') and (`egp_date` = '".$pubDate."')"; $result_rss = mysql_query($sql_rss); $num_rows_rss = mysql_num_rows($result_rss); if($num_rows_rss > 0){ //$sql = "update `tbl_egp_rss` set `egp_title`='".iconv( 'UTF-8', 'TIS-620', $egp_title)."',`egp_link`='".$egp_link."',`egp_date`='".$pubDate."',`egp_update`=now(),`egp_anouncetype`='".$atype."' where (`egp_projectId` = '".$egp_projectId."') and (`egp_date` = '".$pubDate."')"; //$dbquery = mysql_query($sql) or die("ไม่สามารถบันทึกข้อมูลได้ !A ".$atype); } else { $sql = "insert into `tbl_egp_rss` (`egp_projectId`,`egp_title`,`egp_link`,`egp_date`,`egp_update`,`egp_anouncetype`) values ('".$egp_projectId."','".iconv( 'UTF-8', 'TIS-620', $egp_title)."','".$egp_link."','".$pubDate."',now(),'".$atype."')"; $dbquery = mysql_query($sql) or die("ไม่สามารถบันทึกข้อมูลได้ !B ".$atype); } echo "<ul>"; echo "<li>หัวข้อ : ".iconv( 'UTF-8', 'TIS-620', $egp_title)."\r\n"; echo "<ul>"; echo "<li>ลิงค์เอกสาร : ".$egp_link."</li>\r\n"; echo "<li>วันที่ : ".$c_egp_date_th."</li>\r\n"; echo "<li>Project ID : ".$egp_projectId."</li>\r\n"; echo "</ul></li>\r\n"; echo "</ul>"; } else { $num1 = strpos($egp_link,'templateId'); //echo iconv( 'UTF-8', 'TIS-620', $egp_title)."<br>".$egp_link."<br>".$pubDate."<br>".$num1."<br/>"; $egp_templateId = "";//templateId if ($num1 > 0) { $egp_templateId = substr($egp_link,$num1+11,36); //ตึง templateId จาก link egp } if(!empty($egp_templateId)){ $sql_rss = "SELECT `egp_projectId` FROM `tbl_egp_rss` WHERE (`egp_date` = '".$pubDate."') and (`egp_templateId` = '".$egp_templateId."')"; $result_rss = mysql_query($sql_rss); $num_rows_rss = mysql_num_rows($result_rss); if($num_rows_rss > 0){ //$sql = "update `tbl_egp_rss` set `egp_title`='".iconv( 'UTF-8', 'TIS-620', $egp_title)."',`egp_link`='".$egp_link."',`egp_date`='".$pubDate."',`egp_update`=now(),`egp_anouncetype`='".$atype."' where (`egp_date` = '".$pubDate."') and (`egp_templateId` = '".$egp_templateId."')"; //$dbquery = mysql_query($sql) or die("ไม่สามารถบันทึกข้อมูลได้ !C ".$atype); } else { $sql = "insert into `tbl_egp_rss` (`egp_title`,`egp_link`,`egp_date`,`egp_update`,`egp_anouncetype`,`egp_templateId`) values ('".iconv( 'UTF-8', 'TIS-620', $egp_title)."','".$egp_link."','".$pubDate."',now(),'".$atype."','".$egp_templateId."')"; $dbquery = mysql_query($sql) or die("ไม่สามารถบันทึกข้อมูลได้ !D ".$atype); } echo "<ul>"; echo "<li>หัวข้อ : ".iconv( 'UTF-8', 'TIS-620', $egp_title)."\r\n"; echo "<ul>"; echo "<li>ลิงค์เอกสาร : ".$egp_link."</li>\r\n"; echo "<li>วันที่ : ".$c_egp_date_th."</li>\r\n"; echo "<li>Template ID : ".$egp_templateId."</li>\r\n"; echo "</ul></li>\r\n"; echo "</ul>"; } else { $num1 = strpos($egp_link,'fileId'); //echo iconv( 'UTF-8', 'TIS-620', $egp_title)."<br>".$egp_link."<br>".$pubDate."<br>".$num1."<br/>"; $egp_fileId = "";//fileId if ($num1 > 0) { $egp_fileId = substr($egp_link,$num1+7,33); //ตึง fileId จาก link egp } if(!empty($egp_fileId)){ $sql_rss = "SELECT `egp_projectId` FROM `tbl_egp_rss` WHERE (`egp_date` = '".$pubDate."') and (`egp_templateId` = '".$egp_fileId."')"; $result_rss = mysql_query($sql_rss); $num_rows_rss = mysql_num_rows($result_rss); if($num_rows_rss > 0){ //$sql = "update `tbl_egp_rss` set `egp_title`='".iconv( 'UTF-8', 'TIS-620', $egp_title)."',`egp_link`='".$egp_link."',`egp_date`='".$pubDate."',`egp_update`=now(),`egp_anouncetype`='".$atype."' where (`egp_templateId` = '".$egp_fileId."')"; //$dbquery = mysql_query($sql) or die("ไม่สามารถบันทึกข้อมูลได้ !C ".$atype); } else { $sql = "insert into `tbl_egp_rss` (`egp_title`,`egp_link`,`egp_date`,`egp_update`,`egp_anouncetype`,`egp_templateId`) values ('".iconv( 'UTF-8', 'TIS-620', $egp_title)."','".$egp_link."','".$pubDate."',now(),'".$atype."','".$egp_fileId."')"; $dbquery = mysql_query($sql) or die("ไม่สามารถบันทึกข้อมูลได้ !D ".$atype); } echo "<ul>"; echo "<li>หัวข้อ : ".iconv( 'UTF-8', 'TIS-620', $egp_title)."\r\n"; echo "<ul>"; echo "<li>ลิงค์เอกสาร : ".$egp_link."</li>\r\n"; echo "<li>วันที่ : ".$c_egp_date_th."</li>\r\n"; echo "<li>File ID : ".$egp_fileId."</li>\r\n"; echo "</ul></li>\r\n"; echo "</ul>"; }} } endforeach; endforeach; //endforeach; if ($num1 <= 0) { echo " <strong><span style='color:#ff0000'>..ไม่พบข้อมูล..</span></strong><br>\r\n"; } unset($data); } else { if(strlen($data)>=1){ unset($data); if(isset($conndb)) { mysql_close($conndb); unset($conndb); } echo "<meta http-equiv=\"refresh\" content=\"1; URL=http://process3.gprocurement.go.th/EPROCRssFeedWeb/egpannouncerss.xml?deptsubId=".$_deptsubId."\" target=\"_top\">"; } else { echo "<br><br> <h3><span style='color:#ff0000'>..ไม่สามารถอ่านข้อมูลจาก Server e-GP ได้ (Server ของ e-GP ไม่ตอบสนอง) กรุณาเรียกโปรแกรมใหม่อีกครั้ง..</span></h3><br>\r\n"; } unset($data); //exit(); } endforeach; unset($anounceType); echo "<br><br><strong><a href=\"index.php\" target=\"_top\">..คลิกไปหน้าหลัก..</a></strong>\r\n"; //echo "<meta http-equiv=\"refresh\" content=\"5; URL=index.php\" target=\"_top\">"; ?>