function api_getArticles_invoke($params) { $article_ids = array(); if ($params['id36']) { $id36s = preg_split("/[\\s,]+/", $params['id36']); foreach ($id36s as $id36) { $article_ids[] = article_id36_to_id($id36); } } if ($params['url']) { // look up article by its original url $url = $params['url']; $art_id = article_find($url); if (is_null($art_id)) { api_error("couldn't find article with url: '" . $url . "'"); return; } $article_ids[] = $art_id; } if (!$article_ids) { api_error("No articles specified - use 'id36' and/or 'url'"); return; } #$brief = $params['brief'] ? TRUE : FALSE; $fields = array('title', 'id36', 'srcorgname', 'iso_pubdate', 'permalink', 'journos', 'description'); $results = array(); foreach ($article_ids as $id) { $raw = article_collect($id); $art = array_cherrypick($raw, $fields); $results[] = $art; } $output = array('status' => 0, 'results' => $results); api_output($output); }
function view() { $url = get_http_var('url', ''); $action = get_http_var('action'); $art = null; $return_code = null; $raw_output = ''; $summary = 'FAILED'; $urls_form = new ArticleURLsForm($_GET); if ($urls_form->is_valid()) { $url = $urls_form->cleaned_data['url']; // already got it? $art_id = article_find($url); if (is_null($art_id)) { list($return_code, $raw_output) = scrape_ScrapeURL($url); $scraped = scrape_ParseOutput($raw_output); if (sizeof($scraped) > 0) { $art_id = $scraped[0]['id']; $summary = 'ARTICLE SCRAPED'; } else { $summary = 'NOT SCRAPED'; } } else { $summary = 'ALREADY IN DATABASE'; } if (!is_null($art_id)) { $art = fetch_art($art_id); } } $v = array('urls_form' => $urls_form, 'return_code' => $return_code, 'raw_output' => $raw_output, 'summary' => $summary, 'art' => $art); template($v); }
function __construct($journo, $blank = FALSE) { $this->journo = $journo; if (!$blank) { $this->url = get_http_var('url', ''); if ($this->url) { $this->url = clean_url($this->url); } // so we can detect if url is changed $this->prev_url = get_http_var('prev_url', ''); } if ($blank || !$this->url && !$this->prev_url) { $this->state = 'initial'; return; } $msg = is_sane_article_url($this->url); if (!is_null($msg)) { $this->errs['url'] = $msg; $this->state = 'bad_url'; return; } // article already in DB? $art_id = article_find($this->url); if (is_null($art_id)) { // nope - try and scrape it list($ret, $txt) = scrape_ScrapeURL($this->url, $this->journo['ref']); if ($ret != 0) { $this->errs['error_message'] = "Journa<i>listed</i> had problems reading this article"; $this->state = 'scrape_failed'; $this->_register_error(); return; } $arts = scrape_ParseOutput($txt); if (sizeof($arts) < 1) { $this->errs['error_message'] = "Journa<i>listed</i> had problems reading this article"; $this->state = 'scrape_failed'; $this->_register_error(); return; } $art_id = $arts[0]; } // if we get this far, $art_id will be set // fetch some basic details about the article $art = db_getRow("SELECT id,title,permalink,pubdate,srcorg FROM article WHERE id=?", $art_id); $sql = <<<EOT SELECT j.id,j.prettyname,j.ref FROM (journo j INNER JOIN journo_attr attr ON attr.journo_id=j.id) WHERE attr.article_id=? EOT; $journos = db_getAll($sql, $art_id); $art['journos'] = $journos; $this->article = $art; // attributed to the expected journo? $got_expected_journo = FALSE; foreach ($journos as $j) { if ($j['id'] == $this->journo['id']) { $got_expected_journo = TRUE; break; } } if ($got_expected_journo) { // all is well. $this->state = 'done'; return; } else { // $this->errs['error_message'] = "Journa<i>listed</i> had trouble reading the byline"; $this->state = 'journo_mismatch'; $this->_register_error(); return; } }
public function update_status() { if ($this->status == 'rejected') { return; } if (!$this->article) { // check to see if article now exists... $art_id = article_find($this->url); if (!is_null($art_id)) { $this->set_article($art_id); } } if (!$this->article) { $this->status = 'scrape_failed'; } else { $this->status = 'journo_mismatch'; foreach ($this->article->authors as $attributed) { if ($attributed->ref == $this->expected_journo->ref) { $this->status = 'resolved'; break; } } } }
include './xiunophp/image.func.php'; include './xiunophp/xn_html_safe.func.php'; include './model/article.func.php'; $action = param(1); if ($action == 'list') { $header['title'] = '文章管理'; $cateid = param(2, 0); $keyword = trim(urldecode(param(3))); $page = param(4, 0); $pagesize = 20; $cond = array(); $cateid and $cond['cateid'] = $cateid; $keyword and $cond['subject'] = array('LIKE' => $keyword); $n = article_count($cond); $page = page($page, $n, $pagesize); $articlelist = article_find($cond, array('articleid' => -1), $page, $pagesize); $pages = pages("admin/article-list-{$cateid}-" . urlencode($keyword) . '-{page}.htm', $n, $page, $pagesize); include "./admin/view/article_list.htm"; } elseif ($action == 'create') { if ($method == 'GET') { $header['title'] = '创建文章'; $articleid = article_maxid() + 1; include "./admin/view/article_create.htm"; } elseif ($method == 'POST') { $articleid = param(2, 0); $cateid = param('cateid', 0); $subject = param('subject'); $brief = param('brief'); $message = param('message', '', FALSE); $cover = param('cover'); $seo_title = param('seo_title');