Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Thursday, November 12, 2026

Diff for Metafox/db.inc.php between version 1.60 and 1.61

version 1.60, 2011/05/31 13:04:30 version 1.61, 2012/05/02 12:58:15
Line 17 
Line 17 
  * http://platon.sk/projects/Metafox/   * http://platon.sk/projects/Metafox/
  */   */
   
 /* $Platon: Metafox/db.inc.php,v 1.59 2011-01-24 16:44:48 igor Exp $ */  /* $Platon: Metafox/db.inc.php,v 1.60 2011-05-31 13:04:30 igor Exp $ */
   
 /*  /*
  * updates: 23/5/2001, 29/7/2001, 11/10/2001, 2/11/2001, 11/1/2002, 23/7/2002   * updates: 23/5/2001, 29/7/2001, 11/10/2001, 2/11/2001, 11/1/2002, 23/7/2002
Line 583  function ezin_get_article_list($section_
Line 583  function ezin_get_article_list($section_
                 ;                  ;
         unset($array[$k]);          unset($array[$k]);
         @mysql_free_result($result);          @mysql_free_result($result);
   
           // add articles from sources
           $src_articles = ezin_get_sources($section_id);
           $added = false;
           foreach($src_articles as $src) {
                   switch ($src['source_type']) {
                           case 'rss':
                                   // download articles from RSS url
                                   $rss_articles = ezin_get_rss_articles($src);
                                   if (count($rss_articles) > 0) {
                                           $array = array_merge($array, $rss_articles);
                                           $added = true;
                                   }
                                   break;
                   }
           }
   
           if ($added
                   && (count($array) > 1))
           {
                   // order all articles by time
                   $sortArray = array();
                   foreach($array as $article){
                       foreach($article as $key=>$value){
                           if(!isset($sortArray[$key])){
                               $sortArray[$key] = array();
                           }
                           $sortArray[$key][] = $value;
                       }
                   }
   
                   $orderby = 'article_timestamp';
                   array_multisort($sortArray[$orderby], ($ezin_cfg['order_articles_desc']) ? SORT_DESC : SORT_ASC, $array);
           }
   
         return $array;          return $array;
 } /* }}} */  } /* }}} */
   
Line 1287  function ezin_update_counts($author_id,
Line 1322  function ezin_update_counts($author_id,
 } /* }}} */  } /* }}} */
   
 /*  /*
    * Return articles from RSS url
    */
   function ezin_get_rss_articles($source) {
           require_once 'soap/toArray.php';
   
        if (!is_array($source)) {
                   return array();
           }
           $articles = array();
   
           $cache_rss_xml = ezin_cache_load('Source'.intval($source['id']));
           $refresh_time = ($cache_rss_xml['var_var'] == 1) ? $source['fail_refresh_time'] : $source['normal_refresh_time'];
           if (($cache_rss_xml['timestamp'] + ($refresh_time*60)) < Time()) {
                   $rss_xml = ezin_get_curl($source['url'], $source['connection_timeout']);
                   ezin_cache_clear('Source'.intval($source['id']));
                   if (is_bool($rss_xml)
                           && !$rss_xml)
                   {
                           ezin_cache_save('Source'.intval($source['id']), $cache_rss_xml['content'], 1);
                   } else {
                           ezin_cache_save('Source'.intval($source['id']), $rss_xml, 0);
                   }
           } else {
                   $rss_xml = $cache_rss_xml['content'];
           }
   
           $rss_arr = xml2ary($rss_xml);
   
           $items = $rss_arr['rss']['_c']['channel']['_c']['item'];
           if (!is_array($items)) {
                   return array();
           }
           foreach($items as $item) {
                   $article = array(
                           'article_access_key' => $item['_c']['link']['_v'],
                           'article_title' => $item['_c']['title']['_v'],
                           'article_timestamp' => strtotime($item['_c']['pubDate']['_v']),
                           'article_hometext' => $item['_c']['description']['_v']
                   );
                   $articles[] = $article;
           }
   
           return $articles;
   }
   
   /*
    * Return sources for section
    */
   function ezin_get_sources($section_id = 0) {
           global $ezin_sys;
           global $ezin_cfg;
           global $ezin_db_handle;
           $section_id = intval($section_id);
   
           $query = sprintf('SELECT sources.*, sections.display'
                                   .' FROM %s AS sources'
                                   .' LEFT JOIN %s AS sections'
                                   .' ON sources.section_id = sections.id'
                                   .' WHERE sources.section_id = %d'
                                   .' AND FIND_IN_SET("articles_in_normal",sections.display)',
                                   $ezin_sys['db']['tables']['sources'],
                                   $ezin_sys['db']['tables']['sections'],
                                   $section_id);
   
           if ($section_id == 0) {
                   // globalna sekcia
                   $query = sprintf('SELECT sources.*, sections.display'
                                           .' FROM %s AS sources'
                                           .' LEFT JOIN %s AS sections'
                                           .' ON sources.section_id = sections.id'
                                           .' WHERE FIND_IN_SET("articles_in_global",sections.display)',
                                           $ezin_sys['db']['tables']['sources'],
                                           $ezin_sys['db']['tables']['sections'],
                                           $section_id);
           } else {
                   // normalna sekcia
                   $query = sprintf('SELECT sources.*, sections.display'
                                           .' FROM %s AS sources'
                                           .' LEFT JOIN %s AS sections'
                                           .' ON sources.section_id = sections.id'
                                           .' WHERE sources.section_id = %d'
                                           .' AND FIND_IN_SET("articles_in_normal",sections.display)',
                                           $ezin_sys['db']['tables']['sources'],
                                           $ezin_sys['db']['tables']['sections'],
                                           $section_id);
           }
           $result = @mysql_query($query, $ezin_db_handle)
                           or ezin_db_error('ezin_get_article_list()');
           $array = array();
           for ($k = 0; ($array[$k] = @mysql_fetch_array($result, MYSQL_ASSOC)); $k++)
                   ;
           unset($array[$k]);
           @mysql_free_result($result);
   
           return $array;
   }
   
   /*
  * MESSAGES RELATED FUNCTION   * MESSAGES RELATED FUNCTION
  */   */
   

Legend:
Removed from v.1.60  
changed lines
  Added in v.1.61

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top