Server IP : 43.241.58.20 / Your IP : 216.73.216.25 Web Server : Apache/2 System : Linux ns1-1556229.dragonhispeed.com 3.16.0 #1 SMP Fri Mar 29 22:50:14 MSK 2024 x86_64 User : ratsitne ( 1130) 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/ratsitne/domains/tessabalpatiu.go.th/public_html/egp/ |
Upload File : |
<?php // Load WordPress require_once 'wp-load.php'; require_once ABSPATH . 'wp-admin/includes/taxonomy.php'; 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(); $cnt_new_row = 0; //echo "/".$now."/".$begintime1."/".$endtime1."/".$begintime2."/".$now."/".$endtime2."/<br>"; if (($now >= $begintime1 && $now <= $endtime1) || ($now >= $begintime2 && $now <= $endtime2) || ($now >= $begintime3 && $now <= $endtime3)) { //echo "Yes, this time for e-GP"; global $wpdb; $aType = array('P0', '15', 'B0', 'D0', 'W0', 'D1', 'W1', 'D2', 'W2'); $aCat = array(118, 119, 120, 121, 122, 123, 124, 125, 126); //รหัสหมวดหมู่ใน WordPress สำหรับแยกประเภทประกาศ anounceType $i = 0; foreach ($aType as $newsType) { //ประเภทประกาศ //$url = "http://www.tungpheung.go.th/newsfeed.xml"; //ไฟล์ xml สำหรับใช้ทดสอบ //เทศบาลเมืองเขลางค์นคร=4520101 $depid = '4520101'; $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) { $itemtitle = wp_strip_all_tags($item->title); $wpdb->show_errors(true); $sql = $wpdb->prepare("SELECT $wpdb->posts.ID FROM $wpdb->posts LEFT JOIN $wpdb->term_relationships ON $wpdb->posts.ID = $wpdb->term_relationships.object_id WHERE $wpdb->term_relationships.term_taxonomy_id=" . $aCat[$i] . " AND post_status='publish' AND post_title LIKE '%s'", $itemtitle); //echo $sql; $result = $wpdb->get_results($sql); if (!$result) { $itemcontent = "<a href=\"" . TRIM($item->link) . "\" targer=\"_blank\">".$itemtitle." คลิกอ่านที่นี่</a>"; $id = wp_insert_post(array( 'post_title' => $itemtitle, 'post_content' => $itemcontent, 'post_date' => date('Y-m-d H:i:s'), 'post_author' => 1, 'post_type' => 'post', 'post_status' => 'publish', )); if ($id) { $cnt_new_row += 1; $cat = array($aCat[$i]); $setcat = wp_set_post_categories($id, $cat); } else { echo "WARNING: Failed to insert post into WordPress\n"; } } } $i++; } } } else { //echo "Not time to e-GP"; } ?>