예제 #1
0
파일: Hook.php 프로젝트: piratevn/cms-gio
 public static function add($articleId)
 {
     $request = Gio_Core_Request::getInstance();
     $articleRelateIds = $request->getParam('relateArticleIds');
     if ($articleId && !empty($articleRelateIds)) {
         $conn = Gio_Db_Connection::getConnection();
         $dao = new Modules_News_Models_Mysql_Article();
         $dao->addToRelateArticles($articleId, $articleRelateIds);
     }
 }
예제 #2
0
파일: Update.php 프로젝트: piratevn/cms-gio
 public function linkAction()
 {
     $this->setNoRender();
     $this->disableLayout();
     $request = $this->getRequest();
     $linkId = (int) $request->getParam('link_id');
     $type = $request->getParam('web_id');
     if (!$linkId) {
         return;
     }
     $cron = new Modules_News_Services_Cron();
     switch ($type) {
         case 'vnexpress':
             $cron->vnexpress($linkId);
             break;
         case 'zing':
             $cron->zing($linkId);
             break;
         case 'dantri':
             $cron->dantri($linkId);
             break;
         case 'megafun':
             $cron->megafun($linkId);
             break;
         case 'kenh14':
             $cron->kenh14($linkId);
             break;
         case 'ngoisao':
             $cron->ngoisao($linkId);
             break;
         case 'haitugio':
             $cron->haitugio($linkId);
             break;
         case 'tuoitre':
             $cron->tuoitre($linkId);
             break;
         case 'thanhnien':
             $cron->thanhnien($linkId);
             break;
         case 'nguoilaodong':
             $cron->nguoilaodong($linkId);
             break;
         case 'haisao':
             $cron->haisao($linkId);
             break;
         case 'autopro':
             $cron->autopro($linkId);
             break;
         case 'bongda':
             $cron->bongda($linkId);
             break;
         case 'vtc':
             $cron->vtc($linkId);
             break;
         case 'tintuconline':
             $cron->tintuconline($linkId);
             break;
     }
     $arrayArticles = $cron->addArticles;
     $arrayCategories = $cron->addCategories;
     /**
      * 
      */
     if (!empty($arrayArticles) && !empty($arrayCategories)) {
         $conn = Gio_Db_Connection::getConnection();
         $articleDao = new Modules_News_Models_Mysql_Article();
         $articleDao->setConnection($conn);
         $articleAutoDao = new Modules_News_Models_Mysql_Articleauto();
         $articleAutoDao->setConnection($conn);
         for ($i = 0; $i < count($arrayArticles); $i++) {
             $addArticles = $arrayArticles[$i];
             $categories = $arrayCategories[$i];
             foreach ($addArticles as $index => $article) {
                 $existsArticle = $articleAutoDao->getByLink($article['link_source']);
                 if (null == $existsArticle) {
                     $articleAutoDao->add($article);
                 }
             }
         }
     }
 }
예제 #3
0
파일: Auto.php 프로젝트: piratevn/cms-gio
 public function run()
 {
     ini_set("max_execution_time", 100);
     ini_set('memory_limit', '256M');
     require_once LIB_DIR . DS . 'simplehtmldom' . DS . 'simple_html_dom.php';
     $conn = Gio_Db_Connection::getConnection();
     $articleAutoDao = new Modules_News_Models_Mysql_Articleauto();
     $articleAutoDao->setConnection($conn);
     $numArticles = 30;
     $articlesAuto = $articleAutoDao->find($numArticles);
     $articleDao = new Modules_News_Models_Mysql_Article();
     $articleDao->setConnection($conn);
     /**
      * Auto Tags
      */
     $autoTag = false;
     $allTags = array();
     if ($autoTag) {
         //			$tagDao = new Admin_Modules_News_Models_Mysql_Tag();
         //			$tagDao->setConnection($conn);
         //			$allTags = $tagDao->getAllTags();
     }
     if ($articlesAuto) {
         foreach ($articlesAuto as $index => $articleAuto) {
             $categories = explode('-', $articleAuto['category_ids']);
             $article = array('title' => trim($articleAuto['title']), 'slug' => trim($articleAuto['slug']), 'created_date' => $articleAuto['created_date'], 'category_id' => $categories[0], 'status' => 'active', 'description' => trim($articleAuto['description']), 'article_hot' => $index % 5 == 0 ? 1 : 0, 'article_sticky' => $index % 3 != 0 ? 1 : 0, 'link_source' => $articleAuto['link_source'], 'image_url' => $articleAuto['image_url'], 'web_id' => $articleAuto['website'], 'article_photo' => $articleAuto['article_photo'], 'article_video' => $articleAuto['article_video'], 'language' => 'vi_VN');
             $existsArticle = $articleDao->getByLink($article['link_source']);
             $articleAutoDao->delete($articleAuto['auto_id']);
             if (null == $existsArticle) {
                 switch ($articleAuto['website']) {
                     case 'vtc':
                         $article = $this->_vtc($article);
                         break;
                     case 'vnexpress':
                         $article = $this->_vnexpress($article);
                         break;
                     case 'dantri':
                         $article = $this->_dantri($article);
                         break;
                     case 'thethaovanhoa':
                         $article = $this->_thethaovanhoa($article);
                         break;
                     case 'zing':
                         $article = $this->_zing($article);
                         break;
                     case 'megafun':
                         $article = $this->_megafun($article);
                         break;
                     case 'kenh14':
                         $article = $this->_kenh14($article);
                         break;
                     case 'ngoisao':
                         $article = $this->_ngoisao($article);
                         break;
                     case 'haitugio':
                         $article = $this->_haitugio($article);
                         break;
                     case 'tuoitre':
                         $article = $this->_tuoitre($article);
                         break;
                     case 'thanhnien':
                         $article = $this->_thanhnien($article);
                         break;
                     case 'nguoilaodong':
                         $article = $this->_nguoilaodong($article);
                         break;
                     case 'haisao':
                         $article = $this->_haisao($article);
                         break;
                     case 'autopro':
                         $article = $this->_autopro($article);
                         break;
                     case 'bongda':
                         $article = $this->_bongda($article);
                         break;
                     case 'tintuconline':
                         $article = $this->_tintuconline($article);
                         break;
                 }
                 if ($article['title'] && $article['description'] && $article['content']) {
                     $articleId = $articleDao->add($article);
                     if ($articleId) {
                         /**
                          * Add to article category assoc
                          */
                         $articleDao->addToCategories($articleId, $categories);
                     }
                 }
             }
         }
     }
 }
예제 #4
0
 public static function getSource($article)
 {
     $conn = Gio_Db_Connection::getConnection();
     $dao = new Modules_News_Models_Mysql_Article();
     $dao->setConnection($conn);
     return $dao->getSource($article);
 }
예제 #5
0
파일: Cron.php 프로젝트: piratevn/cms-gio
    public function tintuconline($linkId)
    {
        ini_set("memory_limit", "256M");
        $conn = Gio_Db_Connection::getConnection();
        if ($linkId) {
            $ext = $linkId == -1 ? null : ' AND cron_id = ' . (int) $linkId;
            $sql = 'SELECT * FROM ' . $conn->_tablePrefix . 'news_cron WHERE website_name="tintuconline" 
						AND is_locked = 0 AND status = "active"' . $ext;
        } else {
            $numCategories = isset($this->_configs['auto_update_num_category']) ? $this->_configs['auto_update_num_category'] : 5;
            $sql = 'SELECT * FROM ' . $conn->_tablePrefix . 'news_cron
					WHERE status = "active" AND TIMESTAMPDIFF(SECOND, last_update, "' . date('Y-m-d H:i:s') . '") > frequency
						AND website_name = "tintuconline" AND is_locked = 0 
					ORDER BY priority
					LIMIT ' . (int) $numCategories;
        }
        $rsSql = $conn->query($sql);
        $addArticles = array();
        $addCategories = array();
        $articleDao = new Modules_News_Models_Mysql_Article();
        $articleDao->setConnection($conn);
        while ($row = $conn->fetchAll($rsSql)) {
            /**
             * Check time
             */
            $rssData = simplexml_load_file($row['source']);
            $articles = $rssData->channel->item;
            $categories = explode('-', $row['category_ids']);
            foreach ($articles as $index => $item) {
                $title = trim($item->title);
                $title = Gio_Core_String::stripCdata($title);
                $description = Gio_Core_String::stripCdata($item->description);
                $description = strip_tags($description);
                $link = Gio_Core_String::stripCdata($item->link);
                $link = trim($link);
                $date = Gio_Core_String::stripCdata($item->pubDate);
                $date = trim($date);
                /**
                 * Check article exists
                 */
                $existsArticle = $articleDao->getBySlug(Gio_Core_String::removeSign(trim($title), '-', true));
                if (null == $existsArticle) {
                    $article = array('title' => $title, 'slug' => Gio_Core_String::removeSign($title, '-', true), 'description' => $description, 'created_date' => date('Y-m-d H:i:s', strtotime($date)), 'link_source' => $link, 'image_url' => null, 'category_ids' => $row['category_ids'], 'website' => 'tintuconline', 'article_photo' => 0, 'article_video' => 0);
                    $addArticles[] = $article;
                    $addCategories[] = $categories;
                }
            }
            /**
             * Update time for cron
             */
            $sql = 'UPDATE ' . $conn->_tablePrefix . 'news_cron SET last_update = "' . date('Y-m-d H:i:s') . '"
						WHERE cron_id = ' . $conn->escape($row['cron_id']);
            $rsUpdate = $conn->query($sql);
            $conn->freeResult($rsUpdate);
        }
        $conn->freeResult($rsSql);
        /**
         * Add articles, Add Categories
         */
        if ($addArticles && $addCategories) {
            $this->addArticles[] = $addArticles;
            $this->addCategories[] = $addCategories;
        }
    }