| version 1.83, 2015/02/11 13:28:34 |
version 1.84, 2016/07/11 13:28:12 |
|
|
| * http://platon.sk/projects/Metafox/ |
* http://platon.sk/projects/Metafox/ |
| */ |
*/ |
| |
|
| /* $Platon: Metafox/db.inc.php,v 1.82 2015-01-15 16:22:22 igor Exp $ */ |
/* $Platon: Metafox/db.inc.php,v 1.83 2015/02/11 13:28:34 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 193 function ezin_validate_IDs($ar) /* {{{ * |
|
| Line 193 function ezin_validate_IDs($ar) /* {{{ * |
|
| $ar_redirect = ezin_validate_IDs(array('article_id' => $ret['id'])); |
$ar_redirect = ezin_validate_IDs(array('article_id' => $ret['id'])); |
| $ar_redirect['redirect'] = true; |
$ar_redirect['redirect'] = true; |
| } |
} |
| |
if (is_null($ar_redirect)) { |
| |
$parts = ezin_source_article_id_decode($ar['article_id']); |
| |
$section = ezin_get_section($parts['section_id']); |
| |
$ar_redirect['section_id'] = $parts['section_id']; |
| |
$ar_redirect['article_id'] = $ar['article_id']; |
| |
$ar_redirect['lang'] = $section['section_lang']; |
| |
} |
| |
|
| } else if (strlen($ar['section_id']) > 0) { |
} else if (strlen($ar['section_id']) > 0) { |
| $ret = ezin_get_access_key_redirect($ar['section_id'], 'section'); |
$ret = ezin_get_access_key_redirect($ar['section_id'], 'section'); |
| if (is_array($ret) |
if (is_array($ret) |
| Line 394 function ezin_get_section($section_id, $ |
|
| Line 402 function ezin_get_section($section_id, $ |
|
| .' sections.name section_name,' |
.' sections.name section_name,' |
| .' sections.access_key section_access_key,' |
.' sections.access_key section_access_key,' |
| .' sections.template_key section_template_key,' |
.' sections.template_key section_template_key,' |
| .' sections.link section_link' |
.' sections.link section_link,' |
| |
.' sections.lang section_lang' |
| .' FROM '.$ezin_sys['db']['tables']['sections'].' AS sections' |
.' FROM '.$ezin_sys['db']['tables']['sections'].' AS sections' |
| /* XXX let this here, although global sections now use direct ID retrieving */ |
/* XXX let this here, although global sections now use direct ID retrieving */ |
| .' WHERE '.($section_id > 0 |
.' WHERE '.($section_id > 0 |
| Line 687 function ezin_get_article_list($section_ |
|
| Line 696 function ezin_get_article_list($section_ |
|
| @mysql_free_result($result); |
@mysql_free_result($result); |
| |
|
| // add articles from sources |
// add articles from sources |
| $src_articles = ezin_get_sources($section_id); |
$sources_articles = ezin_get_article_list_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 |
if (is_array($sources_articles) |
| && (count($array) > 1)) |
&& (count($sources_articles) > 1)) |
| { |
{ |
| |
$array = array_merge($array, $sources_articles); |
| // order all articles by time |
// order all articles by time |
| $sortArray = array(); |
$sortArray = array(); |
| foreach($array as $article){ |
foreach($array as $article){ |
| Line 922 function ezin_get_article_list_counts($s |
|
| Line 919 function ezin_get_article_list_counts($s |
|
| } /* }}} */ |
} /* }}} */ |
| |
|
| /* |
/* |
| |
* ezin_get_article_list_source() |
| |
*/ |
| |
function ezin_get_article_list_sources($section_id) /* {{{ */ |
| |
{ |
| |
$src_articles = ezin_get_sources($section_id); |
| |
$array = array(); |
| |
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); |
| |
} |
| |
break; |
| |
} |
| |
} |
| |
return $array; |
| |
} /* }}} */ |
| |
|
| |
/* |
| * ezin_get_article() |
* ezin_get_article() |
| */ |
*/ |
| function ezin_get_article($article_id) /* {{{ */ |
function ezin_get_article($article_id) /* {{{ */ |
| Line 930 function ezin_get_article($article_id) / |
|
| Line 948 function ezin_get_article($article_id) / |
|
| global $ezin_cfg; |
global $ezin_cfg; |
| global $ezin_db_handle; |
global $ezin_db_handle; |
| |
|
| |
/* Article from source */ |
| |
if (strlen($article_id) >= 6 |
| |
&& substr($article_id, 0, 6) == 'source') |
| |
{ |
| |
$parts = ezin_source_article_id_decode($article_id); |
| |
$source = ezin_get_source($parts['source_id']); |
| |
$articles = ezin_get_rss_articles($source); |
| |
foreach ($articles as $article) { |
| |
if ($article['article_id'] == $article_id) { |
| |
return $article; |
| |
} |
| |
} |
| |
return false; |
| |
} |
| |
|
| |
/* Article from DB */ |
| $article_id = intval($article_id); |
$article_id = intval($article_id); |
| |
|
| $query = 'SELECT' |
$query = 'SELECT' |
| Line 1605 function ezin_update_counts($author_id, |
|
| Line 1639 function ezin_update_counts($author_id, |
|
| } /* }}} */ |
} /* }}} */ |
| |
|
| /* |
/* |
| |
* Encode parts of source article |
| |
*/ |
| |
function ezin_source_article_id_encode($arr) { |
| |
return implode(':', array('source', intval($arr['section_id']), intval($arr['source_id']), $arr['hash'])); |
| |
} |
| |
|
| |
/* |
| |
* Decode source article into parts |
| |
*/ |
| |
function ezin_source_article_id_decode($str) { |
| |
$parts = explode(':', $str); |
| |
return array( |
| |
'type' => $parts[0], // always 'source' |
| |
'section_id' => $parts[1], |
| |
'source_id' => $parts[2], |
| |
'hash' => $parts[3], |
| |
); |
| |
} |
| |
|
| |
/* |
| * Return articles from RSS url |
* Return articles from RSS url |
| */ |
*/ |
| function ezin_get_rss_articles($source) { |
function ezin_get_rss_articles($source) { |
| Line 1639 function ezin_get_rss_articles($source) |
|
| Line 1693 function ezin_get_rss_articles($source) |
|
| if (!is_array($items)) { |
if (!is_array($items)) { |
| return array(); |
return array(); |
| } |
} |
| |
$section = ezin_get_section($source['section_id']); |
| foreach($items as $item) { |
foreach($items as $item) { |
| $article = array( |
$article = array( |
| |
'article_id' => ezin_source_article_id_encode(array('section_id' => $source['section_id'], 'source_id' => $source['id'], 'hash' => md5($item['_c']['link']['_v']))), |
| 'article_access_key' => $item['_c']['link']['_v'], |
'article_access_key' => $item['_c']['link']['_v'], |
| 'article_title' => $item['_c']['title']['_v'], |
'article_title' => $item['_c']['title']['_v'], |
| 'article_timestamp' => strtotime($item['_c']['pubDate']['_v']), |
'article_timestamp' => strtotime($item['_c']['pubDate']['_v']), |
| 'article_hometext' => $item['_c']['description']['_v'], |
'article_hometext' => $item['_c']['description']['_v'], |
| 'article_section_link' => $rss_arr['rss']['_c']['channel']['_c']['link']['_v'], |
'article_section_link' => $rss_arr['rss']['_c']['channel']['_c']['link']['_v'], |
| 'article_section_name' => $rss_arr['rss']['_c']['channel']['_c']['title']['_v'] |
'article_section_name' => $rss_arr['rss']['_c']['channel']['_c']['title']['_v'], |
| |
'article_lang' => $section['section_lang'], |
| |
'article_section_id' => $section['section_id'], |
| ); |
); |
| $articles[] = $article; |
$articles[] = $article; |
| } |
} |
| Line 1655 function ezin_get_rss_articles($source) |
|
| Line 1713 function ezin_get_rss_articles($source) |
|
| } |
} |
| |
|
| /* |
/* |
| |
* Return source |
| |
*/ |
| |
function ezin_get_source($source_id) { |
| |
global $ezin_sys; |
| |
global $ezin_db_handle; |
| |
$source_id = intval($source_id); |
| |
$query = sprintf('SELECT *' |
| |
.' FROM %s AS sources' |
| |
.' WHERE sources.id = %d', |
| |
$ezin_sys['db']['tables']['sources'], |
| |
$source_id); |
| |
$result = @mysql_query($query, $ezin_db_handle) |
| |
or ezin_db_error('ezin_get_source()'); |
| |
$ret = @mysql_fetch_array($result, MYSQL_ASSOC); |
| |
@mysql_free_result($result); |
| |
return $ret; |
| |
} |
| |
|
| |
/* |
| * Return sources for section |
* Return sources for section |
| */ |
*/ |
| function ezin_get_sources($section_id = 0) { |
function ezin_get_sources($section_id = 0) { |