• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP get_article_filters函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中get_article_filters函数的典型用法代码示例。如果您正苦于以下问题:PHP get_article_filters函数的具体用法?PHP get_article_filters怎么用?PHP get_article_filters使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_article_filters函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: rescoreAll

 function rescoreAll()
 {
     $result = $this->dbh->query("SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION['uid']);
     while ($feed_line = $this->dbh->fetch_assoc($result)) {
         $id = $feed_line["id"];
         $filters = load_filters($id, $_SESSION["uid"], 6);
         $tmp_result = $this->dbh->query("SELECT\n\t\t\t\ttitle, content, link, ref_id, author," . SUBSTRING_FOR_DATE . "(updated, 1, 19) AS updated\n\t\t\t\t\tFROM\n\t\t\t\t\tttrss_user_entries, ttrss_entries\n\t\t\t\t\tWHERE ref_id = id AND feed_id = '{$id}' AND\n\t\t\t\t\t\towner_uid = " . $_SESSION['uid'] . "\n\t\t\t\t\t");
         $scores = array();
         while ($line = $this->dbh->fetch_assoc($tmp_result)) {
             $tags = get_article_tags($line["ref_id"]);
             $article_filters = get_article_filters($filters, $line['title'], $line['content'], $line['link'], strtotime($line['updated']), $line['author'], $tags);
             $new_score = calculate_article_score($article_filters);
             if (!$scores[$new_score]) {
                 $scores[$new_score] = array();
             }
             array_push($scores[$new_score], $line['ref_id']);
         }
         foreach (array_keys($scores) as $s) {
             if ($s > 1000) {
                 $this->dbh->query("UPDATE ttrss_user_entries SET score = '{$s}',\n\t\t\t\t\t\tmarked = true WHERE\n\t\t\t\t\t\tref_id IN (" . join(',', $scores[$s]) . ")");
             } else {
                 $this->dbh->query("UPDATE ttrss_user_entries SET score = '{$s}' WHERE\n\t\t\t\t\t\tref_id IN (" . join(',', $scores[$s]) . ")");
             }
         }
     }
     print __("All done.");
 }
开发者ID:AHinMaine,项目名称:ttrss,代码行数:27,代码来源:feeds.php


示例2: update_rss_feed_real


//.........这里部分代码省略.........
                // base post entry does not exist, create it
                $result = db_query($link, "INSERT INTO ttrss_entries \n\t\t\t\t\t\t\t(title,\n\t\t\t\t\t\t\tguid,\n\t\t\t\t\t\t\tlink,\n\t\t\t\t\t\t\tupdated,\n\t\t\t\t\t\t\tcontent,\n\t\t\t\t\t\t\tcontent_hash,\n\t\t\t\t\t\t\tno_orig_date,\n\t\t\t\t\t\t\tdate_entered,\n\t\t\t\t\t\t\tcomments,\n\t\t\t\t\t\t\tnum_comments,\n\t\t\t\t\t\t\tauthor)\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t('{$entry_title}', \n\t\t\t\t\t\t\t'{$entry_guid}', \n\t\t\t\t\t\t\t'{$entry_link}',\n\t\t\t\t\t\t\t'{$entry_timestamp_fmt}', \n\t\t\t\t\t\t\t'{$entry_content}', \n\t\t\t\t\t\t\t'{$content_hash}',\n\t\t\t\t\t\t\t{$no_orig_date}, \n\t\t\t\t\t\t\tNOW(), \n\t\t\t\t\t\t\t'{$entry_comments}',\n\t\t\t\t\t\t\t'{$num_comments}',\n\t\t\t\t\t\t\t'{$entry_author}')");
            } else {
                // we keep encountering the entry in feeds, so we need to
                // update date_entered column so that we don't get horrible
                // dupes when the entry gets purged and reinserted again e.g.
                // in the case of SLOW SLOW OMG SLOW updating feeds
                $base_entry_id = db_fetch_result($result, 0, "id");
                db_query($link, "UPDATE ttrss_entries SET date_entered = NOW()\n\t\t\t\t\t\tWHERE id = '{$base_entry_id}'");
            }
            // now it should exist, if not - bad luck then
            $result = db_query($link, "SELECT \n\t\t\t\t\t\tid,content_hash,no_orig_date,title,\n\t\t\t\t\t\t" . SUBSTRING_FOR_DATE . "(date_entered,1,19) as date_entered,\n\t\t\t\t\t\t" . SUBSTRING_FOR_DATE . "(updated,1,19) as updated,\n\t\t\t\t\t\tnum_comments\n\t\t\t\t\tFROM \n\t\t\t\t\t\tttrss_entries \n\t\t\t\t\tWHERE guid = '{$entry_guid}'");
            $entry_ref_id = 0;
            $entry_int_id = 0;
            if (db_num_rows($result) == 1) {
                if (defined('DAEMON_EXTENDED_DEBUG') || $_REQUEST['xdebug']) {
                    _debug("update_rss_feed: base guid found, checking for user record");
                }
                // this will be used below in update handler
                $orig_content_hash = db_fetch_result($result, 0, "content_hash");
                $orig_title = db_fetch_result($result, 0, "title");
                $orig_num_comments = db_fetch_result($result, 0, "num_comments");
                $orig_date_entered = strtotime(db_fetch_result($result, 0, "date_entered"));
                $ref_id = db_fetch_result($result, 0, "id");
                $entry_ref_id = $ref_id;
                // check for user post link to main table
                // do we allow duplicate posts with same GUID in different feeds?
                if (get_pref($link, "ALLOW_DUPLICATE_POSTS", $owner_uid, false)) {
                    $dupcheck_qpart = "AND (feed_id = '{$feed}' OR feed_id IS NULL)";
                } else {
                    $dupcheck_qpart = "";
                }
                //					error_reporting(0);
                $article_filters = get_article_filters($filters, $entry_title, $entry_content, $entry_link, $entry_timestamp, $entry_author);
                if (defined('DAEMON_EXTENDED_DEBUG') || $_REQUEST['xdebug']) {
                    _debug("update_rss_feed: article filters: ");
                    if (count($article_filters) != 0) {
                        print_r($article_filters);
                    }
                }
                if (find_article_filter($article_filters, "filter")) {
                    db_query($link, "COMMIT");
                    // close transaction in progress
                    continue;
                }
                //					error_reporting (DEFAULT_ERROR_LEVEL);
                $score = calculate_article_score($article_filters);
                if (defined('DAEMON_EXTENDED_DEBUG') || $_REQUEST['xdebug']) {
                    _debug("update_rss_feed: initial score: {$score}");
                }
                $query = "SELECT ref_id, int_id FROM ttrss_user_entries WHERE\n\t\t\t\t\t\t\tref_id = '{$ref_id}' AND owner_uid = '{$owner_uid}'\n\t\t\t\t\t\t\t{$dupcheck_qpart}";
                //					if ($_REQUEST["xdebug"]) print "$query\n";
                $result = db_query($link, $query);
                // okay it doesn't exist - create user entry
                if (db_num_rows($result) == 0) {
                    if (defined('DAEMON_EXTENDED_DEBUG') || $_REQUEST['xdebug']) {
                        _debug("update_rss_feed: user record not found, creating...");
                    }
                    if ($score >= -500 && !find_article_filter($article_filters, 'catchup')) {
                        $unread = 'true';
                        $last_read_qpart = 'NULL';
                    } else {
                        $unread = 'false';
                        $last_read_qpart = 'NOW()';
                    }
                    if (find_article_filter($article_filters, 'mark') || $score > 1000) {
开发者ID:wangroot,项目名称:Tiny-Tiny-RSS,代码行数:67,代码来源:functions.php


示例3: update_rss_feed


//.........这里部分代码省略.........
                $base_entry_id = db_fetch_result($result, 0, "id");
                db_query("UPDATE ttrss_entries SET date_updated = NOW()\n\t\t\t\t\t\tWHERE id = '{$base_entry_id}'");
                $article_labels = get_article_labels($base_entry_id, $owner_uid);
            }
            // now it should exist, if not - bad luck then
            $result = db_query("SELECT\n\t\t\t\t\t\tid,content_hash,no_orig_date,title,plugin_data,guid,\n\t\t\t\t\t\t" . SUBSTRING_FOR_DATE . "(date_updated,1,19) as date_updated,\n\t\t\t\t\t\t" . SUBSTRING_FOR_DATE . "(updated,1,19) as updated,\n\t\t\t\t\t\tnum_comments\n\t\t\t\t\tFROM\n\t\t\t\t\t\tttrss_entries\n\t\t\t\t\tWHERE guid = '{$entry_guid}' OR guid = '{$entry_guid_hashed}'");
            $entry_ref_id = 0;
            $entry_int_id = 0;
            if (db_num_rows($result) == 1) {
                _debug("base guid found, checking for user record", $debug_enabled);
                // this will be used below in update handler
                $orig_content_hash = db_fetch_result($result, 0, "content_hash");
                $orig_title = db_fetch_result($result, 0, "title");
                $orig_num_comments = db_fetch_result($result, 0, "num_comments");
                $orig_date_updated = strtotime(db_fetch_result($result, 0, "date_updated"));
                $orig_plugin_data = db_fetch_result($result, 0, "plugin_data");
                $ref_id = db_fetch_result($result, 0, "id");
                $entry_ref_id = $ref_id;
                /* $stored_guid = db_fetch_result($result, 0, "guid");
                					if ($stored_guid != $entry_guid_hashed) {
                						if ($debug_enabled) _debug("upgrading compat guid to hashed one", $debug_enabled);
                
                						db_query("UPDATE ttrss_entries SET guid = '$entry_guid_hashed' WHERE
                							id = '$ref_id'");
                					} */
                // check for user post link to main table
                // do we allow duplicate posts with same GUID in different feeds?
                if (get_pref("ALLOW_DUPLICATE_POSTS", $owner_uid, false)) {
                    $dupcheck_qpart = "AND (feed_id = '{$feed}' OR feed_id IS NULL)";
                } else {
                    $dupcheck_qpart = "";
                }
                /* Collect article tags here so we could filter by them: */
                $article_filters = get_article_filters($filters, $entry_title, $entry_content, $entry_link, $entry_timestamp, $entry_author, $entry_tags);
                if ($debug_enabled) {
                    _debug("article filters: ", $debug_enabled);
                    if (count($article_filters) != 0) {
                        print_r($article_filters);
                    }
                }
                if (find_article_filter($article_filters, "filter")) {
                    db_query("COMMIT");
                    // close transaction in progress
                    continue;
                }
                $score = calculate_article_score($article_filters);
                _debug("initial score: {$score}", $debug_enabled);
                $query = "SELECT ref_id, int_id FROM ttrss_user_entries WHERE\n\t\t\t\t\t\t\tref_id = '{$ref_id}' AND owner_uid = '{$owner_uid}'\n\t\t\t\t\t\t\t{$dupcheck_qpart}";
                //					if ($_REQUEST["xdebug"]) print "$query\n";
                $result = db_query($query);
                // okay it doesn't exist - create user entry
                if (db_num_rows($result) == 0) {
                    _debug("user record not found, creating...", $debug_enabled);
                    if ($score >= -500 && !find_article_filter($article_filters, 'catchup')) {
                        $unread = 'true';
                        $last_read_qpart = 'NULL';
                    } else {
                        $unread = 'false';
                        $last_read_qpart = 'NOW()';
                    }
                    if (find_article_filter($article_filters, 'mark') || $score > 1000) {
                        $marked = 'true';
                    } else {
                        $marked = 'false';
                    }
                    if (find_article_filter($article_filters, 'publish')) {
开发者ID:cs-team,项目名称:tiny_tiny_rss-openshift-quickstart,代码行数:67,代码来源:rssfuncs.php


示例4: testFilterDo

 function testFilterDo()
 {
     require_once "include/rssfuncs.php";
     $offset = (int) db_escape_string($_REQUEST["offset"]);
     $limit = (int) db_escape_string($_REQUEST["limit"]);
     $filter = array();
     $filter["enabled"] = true;
     $filter["match_any_rule"] = sql_bool_to_bool(checkbox_to_sql_bool($this->dbh->escape_string($_REQUEST["match_any_rule"])));
     $filter["inverse"] = sql_bool_to_bool(checkbox_to_sql_bool($this->dbh->escape_string($_REQUEST["inverse"])));
     $filter["rules"] = array();
     $filter["actions"] = array("dummy-action");
     $result = $this->dbh->query("SELECT id,name FROM ttrss_filter_types");
     $filter_types = array();
     while ($line = $this->dbh->fetch_assoc($result)) {
         $filter_types[$line["id"]] = $line["name"];
     }
     $scope_qparts = array();
     $rctr = 0;
     foreach ($_REQUEST["rule"] as $r) {
         $rule = json_decode($r, true);
         if ($rule && $rctr < 5) {
             $rule["type"] = $filter_types[$rule["filter_type"]];
             unset($rule["filter_type"]);
             if (strpos($rule["feed_id"], "CAT:") === 0) {
                 $rule["cat_id"] = (int) substr($rule["feed_id"], 4);
                 unset($rule["feed_id"]);
             }
             if (isset($rule["feed_id"]) && $rule['feed_id'] > 0) {
                 array_push($scope_qparts, "feed_id = " . $rule["feed_id"]);
             } else {
                 if (isset($rule["cat_id"])) {
                     array_push($scope_qparts, "cat_id = " . $rule["cat_id"]);
                 } else {
                     array_push($scope_qparts, "true");
                 }
             }
             array_push($filter["rules"], $rule);
             ++$rctr;
         } else {
             break;
         }
     }
     $glue = $filter['match_any_rule'] ? " OR " : " AND ";
     $scope_qpart = join($glue, $scope_qparts);
     if (!$scope_qpart) {
         $scope_qpart = "true";
     }
     $rv = array();
     //while ($found < $limit && $offset < $limit * 1000 && time() - $started < ini_get("max_execution_time") * 0.7) {
     $result = db_query("SELECT ttrss_entries.id,\n\t\t\t\t\tttrss_entries.title,\n\t\t\t\t\tttrss_feeds.id AS feed_id,\n\t\t\t\t\tttrss_feeds.title AS feed_title,\n\t\t\t\t\tttrss_feed_categories.id AS cat_id,\n\t\t\t\t\tcontent,\n\t\t\t\t\tdate_entered,\n\t\t\t\t\tlink,\n\t\t\t\t\tauthor,\n\t\t\t\t\ttag_cache\n\t\t\t\tFROM\n\t\t\t\t\tttrss_entries, ttrss_user_entries\n\t\t\t\t\t\tLEFT JOIN ttrss_feeds ON (feed_id = ttrss_feeds.id)\n\t\t\t\t\t\tLEFT JOIN ttrss_feed_categories ON (ttrss_feeds.cat_id = ttrss_feed_categories.id)\n\t\t\t\tWHERE\n\t\t\t\t\tref_id = ttrss_entries.id AND\n\t\t\t\t\t({$scope_qpart}) AND\n\t\t\t\t\tttrss_user_entries.owner_uid = " . $_SESSION["uid"] . "\n\t\t\t\tORDER BY date_entered DESC LIMIT {$limit} OFFSET {$offset}");
     while ($line = db_fetch_assoc($result)) {
         $rc = get_article_filters(array($filter), $line['title'], $line['content'], $line['link'], false, $line['author'], explode(",", $line['tag_cache']));
         if (count($rc) > 0) {
             $line["content_preview"] = truncate_string(strip_tags($line["content"]), 200, '&hellip;');
             foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
                 $line = $p->hook_query_headlines($line, 100);
             }
             $content_preview = $line["content_preview"];
             $tmp = "<tr style='margin-top : 5px'>";
             #$tmp .= "<td width='5%' align='center'><input dojoType=\"dijit.form.CheckBox\"
             #	checked=\"1\" disabled=\"1\" type=\"checkbox\"></td>";
             $id = $line['id'];
             $tmp .= "<td width='5%' align='center'><img style='cursor : pointer' title='" . __("Preview article") . "'\n\t\t\t\t\t\tsrc='images/information.png' onclick='openArticlePopup({$id})'></td><td>";
             /*foreach ($filter['rules'] as $rule) {
             						$reg_exp = str_replace('/', '\/', $rule["reg_exp"]);
             
             						$line["title"] = preg_replace("/($reg_exp)/i",
             							"<span class=\"highlight\">$1</span>", $line["title"]);
             
             						$content_preview = preg_replace("/($reg_exp)/i",
             							"<span class=\"highlight\">$1</span>", $content_preview);
             					}*/
             $tmp .= "<strong>" . $line["title"] . "</strong><br/>";
             $tmp .= $line['feed_title'] . ", " . mb_substr($line["date_entered"], 0, 16);
             $tmp .= "<div class='insensitive'>" . $content_preview . "</div>";
             $tmp .= "</td></tr>";
             array_push($rv, $tmp);
             /*array_push($rv, array("title" => $line["title"],
             		"content" => $content_preview,
             		"date" => $line["date_entered"],
             		"feed" => $line["feed_title"])); */
         }
     }
     //$offset += $limit;
     //}
     /*if ($found == 0) {
     			print "<tr><td align='center'>" .
     				__("No recent articles matching this filter have been found.");
     		}*/
     print json_encode($rv);
 }
开发者ID:AHinMaine,项目名称:ttrss,代码行数:91,代码来源:filters.php


示例5: update_rss_feed


//.........这里部分代码省略.........
                // base post entry does not exist, create it
                $result = db_query($link, "INSERT INTO ttrss_entries\n\t\t\t\t\t\t\t(title,\n\t\t\t\t\t\t\tguid,\n\t\t\t\t\t\t\tlink,\n\t\t\t\t\t\t\tupdated,\n\t\t\t\t\t\t\tcontent,\n\t\t\t\t\t\t\tcontent_hash,\n\t\t\t\t\t\t\tno_orig_date,\n\t\t\t\t\t\t\tdate_updated,\n\t\t\t\t\t\t\tdate_entered,\n\t\t\t\t\t\t\tcomments,\n\t\t\t\t\t\t\tnum_comments,\n\t\t\t\t\t\t\tauthor)\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t('{$entry_title}',\n\t\t\t\t\t\t\t'{$entry_guid}',\n\t\t\t\t\t\t\t'{$entry_link}',\n\t\t\t\t\t\t\t'{$entry_timestamp_fmt}',\n\t\t\t\t\t\t\t'{$entry_content}',\n\t\t\t\t\t\t\t'{$content_hash}',\n\t\t\t\t\t\t\t{$no_orig_date},\n\t\t\t\t\t\t\tNOW(),\n\t\t\t\t\t\t\tNOW(),\n\t\t\t\t\t\t\t'{$entry_comments}',\n\t\t\t\t\t\t\t'{$num_comments}',\n\t\t\t\t\t\t\t'{$entry_author}')");
            } else {
                // we keep encountering the entry in feeds, so we need to
                // update date_updated column so that we don't get horrible
                // dupes when the entry gets purged and reinserted again e.g.
                // in the case of SLOW SLOW OMG SLOW updating feeds
                $base_entry_id = db_fetch_result($result, 0, "id");
                db_query($link, "UPDATE ttrss_entries SET date_updated = NOW()\n\t\t\t\t\t\tWHERE id = '{$base_entry_id}'");
            }
            // now it should exist, if not - bad luck then
            $result = db_query($link, "SELECT\n\t\t\t\t\t\tid,content_hash,no_orig_date,title,\n\t\t\t\t\t\t" . SUBSTRING_FOR_DATE . "(date_updated,1,19) as date_updated,\n\t\t\t\t\t\t" . SUBSTRING_FOR_DATE . "(updated,1,19) as updated,\n\t\t\t\t\t\tnum_comments\n\t\t\t\t\tFROM\n\t\t\t\t\t\tttrss_entries\n\t\t\t\t\tWHERE guid = '{$entry_guid}'");
            $entry_ref_id = 0;
            $entry_int_id = 0;
            if (db_num_rows($result) == 1) {
                if ($debug_enabled) {
                    _debug("update_rss_feed: base guid found, checking for user record");
                }
                // this will be used below in update handler
                $orig_content_hash = db_fetch_result($result, 0, "content_hash");
                $orig_title = db_fetch_result($result, 0, "title");
                $orig_num_comments = db_fetch_result($result, 0, "num_comments");
                $orig_date_updated = strtotime(db_fetch_result($result, 0, "date_updated"));
                $ref_id = db_fetch_result($result, 0, "id");
                $entry_ref_id = $ref_id;
                // check for user post link to main table
                // do we allow duplicate posts with same GUID in different feeds?
                if (get_pref($link, "ALLOW_DUPLICATE_POSTS", $owner_uid, false)) {
                    $dupcheck_qpart = "AND (feed_id = '{$feed}' OR feed_id IS NULL)";
                } else {
                    $dupcheck_qpart = "";
                }
                /* Collect article tags here so we could filter by them: */
                $article_filters = get_article_filters($filters, $entry_title, $entry_content, $entry_link, $entry_timestamp, $entry_author, $entry_tags);
                if ($debug_enabled) {
                    _debug("update_rss_feed: article filters: ");
                    if (count($article_filters) != 0) {
                        print_r($article_filters);
                    }
                }
                if (find_article_filter($article_filters, "filter")) {
                    db_query($link, "COMMIT");
                    // close transaction in progress
                    continue;
                }
                $score = calculate_article_score($article_filters);
                if ($debug_enabled) {
                    _debug("update_rss_feed: initial score: {$score}");
                }
                $query = "SELECT ref_id, int_id FROM ttrss_user_entries WHERE\n\t\t\t\t\t\t\tref_id = '{$ref_id}' AND owner_uid = '{$owner_uid}'\n\t\t\t\t\t\t\t{$dupcheck_qpart}";
                //					if ($_REQUEST["xdebug"]) print "$query\n";
                $result = db_query($link, $query);
                // okay it doesn't exist - create user entry
                if (db_num_rows($result) == 0) {
                    if ($debug_enabled) {
                        _debug("update_rss_feed: user record not found, creating...");
                    }
                    if ($score >= -500 && !find_article_filter($article_filters, 'catchup')) {
                        $unread = 'true';
                        $last_read_qpart = 'NULL';
                    } else {
                        $unread = 'false';
                        $last_read_qpart = 'NOW()';
                    }
                    if (find_article_filter($article_filters, 'mark') || $score > 1000) {
                        $marked = 'true';
开发者ID:nvdnkpr,项目名称:Tiny-Tiny-RSS,代码行数:67,代码来源:rssfuncs.php


示例6: update_rss_feed


//.........这里部分代码省略.........
            $entry_content = db_escape_string($entry_content, false);
            db_query("BEGIN");
            $result = db_query("SELECT id FROM\tttrss_entries\n\t\t\t\t\tWHERE (guid = '{$entry_guid}' OR guid = '{$entry_guid_hashed}')");
            if (db_num_rows($result) == 0) {
                _debug("base guid [{$entry_guid}] not found", $debug_enabled);
                // base post entry does not exist, create it
                $result = db_query("INSERT INTO ttrss_entries\n\t\t\t\t\t\t\t(title,\n\t\t\t\t\t\t\tguid,\n\t\t\t\t\t\t\tlink,\n\t\t\t\t\t\t\tupdated,\n\t\t\t\t\t\t\tcontent,\n\t\t\t\t\t\t\tcontent_hash,\n\t\t\t\t\t\t\tno_orig_date,\n\t\t\t\t\t\t\tdate_updated,\n\t\t\t\t\t\t\tdate_entered,\n\t\t\t\t\t\t\tcomments,\n\t\t\t\t\t\t\tnum_comments,\n\t\t\t\t\t\t\tplugin_data,\n\t\t\t\t\t\t\tlang,\n\t\t\t\t\t\t\tauthor)\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t('{$entry_title}',\n\t\t\t\t\t\t\t'{$entry_guid_hashed}',\n\t\t\t\t\t\t\t'{$entry_link}',\n\t\t\t\t\t\t\t'{$entry_timestamp_fmt}',\n\t\t\t\t\t\t\t'{$entry_content}',\n\t\t\t\t\t\t\t'{$entry_current_hash}',\n\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\tNOW(),\n\t\t\t\t\t\t\t'{$date_feed_processed}',\n\t\t\t\t\t\t\t'{$entry_comments}',\n\t\t\t\t\t\t\t'{$num_comments}',\n\t\t\t\t\t\t\t'{$entry_plugin_data}',\n\t\t\t\t\t\t\t'{$entry_language}',\n\t\t\t\t\t\t\t'{$entry_author}')");
            } else {
                $base_entry_id = db_fetch_result($result, 0, "id");
            }
            // now it should exist, if not - bad luck then
            $result = db_query("SELECT id FROM ttrss_entries\n\t\t\t\t\tWHERE guid = '{$entry_guid}' OR guid = '{$entry_guid_hashed}'");
            $entry_ref_id = 0;
            $entry_int_id = 0;
            if (db_num_rows($result) == 1) {
                _debug("base guid found, checking for user record", $debug_enabled);
                $ref_id = db_fetch_result($result, 0, "id");
                $entry_ref_id = $ref_id;
                /* $stored_guid = db_fetch_result($result, 0, "guid");
                					if ($stored_guid != $entry_guid_hashed) {
                						if ($debug_enabled) _debug("upgrading compat guid to hashed one", $debug_enabled);
                
                						db_query("UPDATE ttrss_entries SET guid = '$entry_guid_hashed' WHERE
                							id = '$ref_id'");
                					} */
                // check for user post link to main table
                // do we allow duplicate posts with same GUID in different feeds?
                if (get_pref("ALLOW_DUPLICATE_POSTS", $owner_uid, false)) {
                    $dupcheck_qpart = "AND (feed_id = '{$feed}' OR feed_id IS NULL)";
                } else {
                    $dupcheck_qpart = "";
                }
                /* Collect article tags here so we could filter by them: */
                $article_filters = get_article_filters($filters, $entry_title, $entry_content, $entry_link, $entry_timestamp, $entry_author, $entry_tags);
                if ($debug_enabled) {
                    _debug("article filters: ", $debug_enabled);
                    if (count($article_filters) != 0) {
                        print_r($article_filters);
                    }
                }
                if (find_article_filter($article_filters, "filter")) {
                    db_query("COMMIT");
                    // close transaction in progress
                    continue;
                }
                $score = calculate_article_score($article_filters) + $entry_score_modifier;
                _debug("initial score: {$score} [including plugin modifier: {$entry_score_modifier}]", $debug_enabled);
                $query = "SELECT ref_id, int_id FROM ttrss_user_entries WHERE\n\t\t\t\t\t\t\tref_id = '{$ref_id}' AND owner_uid = '{$owner_uid}'\n\t\t\t\t\t\t\t{$dupcheck_qpart}";
                //					if ($_REQUEST["xdebug"]) print "$query\n";
                $result = db_query($query);
                // okay it doesn't exist - create user entry
                if (db_num_rows($result) == 0) {
                    _debug("user record not found, creating...", $debug_enabled);
                    if ($score >= -500 && !find_article_filter($article_filters, 'catchup') && !$entry_force_catchup) {
                        $unread = 'true';
                        $last_read_qpart = 'NULL';
                    } else {
                        $unread = 'false';
                        $last_read_qpart = 'NOW()';
                    }
                    if (find_article_filter($article_filters, 'mark') || $score > 1000) {
                        $marked = 'true';
                    } else {
                        $marked = 'false';
                    }
                    if (find_article_filter($article_filters, 'publish')) {
开发者ID:rnavarro,项目名称:tt-rss,代码行数:67,代码来源:rssfuncs.php


示例7: testFilter

 function testFilter()
 {
     $filter = array();
     $filter["enabled"] = true;
     $filter["match_any_rule"] = sql_bool_to_bool(checkbox_to_sql_bool($this->dbh->escape_string($_REQUEST["match_any_rule"])));
     $filter["inverse"] = sql_bool_to_bool(checkbox_to_sql_bool($this->dbh->escape_string($_REQUEST["inverse"])));
     $filter["rules"] = array();
     $filter["actions"] = array("dummy-action");
     $result = $this->dbh->query("SELECT id,name FROM ttrss_filter_types");
     $filter_types = array();
     while ($line = $this->dbh->fetch_assoc($result)) {
         $filter_types[$line["id"]] = $line["name"];
     }
     $scope_qparts = array();
     $rctr = 0;
     foreach ($_REQUEST["rule"] as $r) {
         $rule = json_decode($r, true);
         if ($rule && $rctr < 5) {
             $rule["type"] = $filter_types[$rule["filter_type"]];
             unset($rule["filter_type"]);
             if (strpos($rule["feed_id"], "CAT:") === 0) {
                 $rule["cat_id"] = (int) substr($rule["feed_id"], 4);
                 unset($rule["feed_id"]);
             }
             if (isset($rule["feed_id"]) && $rule['feed_id'] > 0) {
                 array_push($scope_qparts, "feed_id = " . $rule["feed_id"]);
             } else {
                 if (isset($rule["cat_id"])) {
                     array_push($scope_qparts, "cat_id = " . $rule["cat_id"]);
                 } else {
                     array_push($scope_qparts, "true");
                 }
             }
             array_push($filter["rules"], $rule);
             ++$rctr;
         } else {
             break;
         }
     }
     $found = 0;
     $offset = 0;
     $limit = 30;
     $started = time();
     print __("Articles matching this filter:");
     require_once "include/rssfuncs.php";
     print "<div class=\"filterTestHolder\">";
     print "<table width=\"100%\" cellspacing=\"0\" id=\"prefErrorFeedList\">";
     $glue = $filter['match_any_rule'] ? " OR " : " AND ";
     $scope_qpart = join($glue, $scope_qparts);
     if (!$scope_qpart) {
         $scope_qpart = "true";
     }
     while ($found < $limit && $offset < $limit * 10 && time() - $started < ini_get("max_execution_time") * 0.7) {
         $result = db_query("SELECT ttrss_entries.id,\n\t\t\t\t\tttrss_entries.title,\n\t\t\t\t\tttrss_feeds.id AS feed_id,\n\t\t\t\t\tttrss_feeds.title AS feed_title,\n\t\t\t\t\tttrss_feed_categories.id AS cat_id,\n\t\t\t\t\tcontent,\n\t\t\t\t\tlink,\n\t\t\t\t\tauthor,\n\t\t\t\t\ttag_cache\n\t\t\t\tFROM\n\t\t\t\t\tttrss_entries, ttrss_user_entries\n\t\t\t\t\t\tLEFT JOIN ttrss_feeds ON (feed_id = ttrss_feeds.id)\n\t\t\t\t\t\tLEFT JOIN ttrss_feed_categories ON (ttrss_feeds.cat_id = ttrss_feed_categories.id)\n\t\t\t\tWHERE\n\t\t\t\t\tref_id = ttrss_entries.id AND\n\t\t\t\t\t({$scope_qpart}) AND\n\t\t\t\t\tttrss_user_entries.owner_uid = " . $_SESSION["uid"] . "\n\t\t\t\tORDER BY date_entered DESC LIMIT {$limit} OFFSET {$offset}");
         while ($line = db_fetch_assoc($result)) {
             $rc = get_article_filters(array($filter), $line['title'], $line['content'], $line['link'], false, $line['author'], explode(",", $line['tag_cache']));
             if (count($rc) > 0) {
                 $line["content_preview"] = truncate_string(strip_tags($line["content"]), 100, '...');
                 foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
                     $line = $p->hook_query_headlines($line, 100);
                 }
                 $content_preview = $line["content_preview"];
                 if ($line["feed_title"]) {
                     $feed_title = "(" . $line["feed_title"] . ")";
                 }
                 print "<tr>";
                 print "<td width='5%' align='center'><input dojoType=\"dijit.form.CheckBox\"\n\t\t\t\t\t\tchecked=\"1\" disabled=\"1\" type=\"checkbox\"></td>";
                 print "<td>";
                 /*foreach ($filter['rules'] as $rule) {
                 						$reg_exp = $rule['reg_exp'];
                 						$reg_exp = str_replace('/', '\/', $rule["reg_exp"]);
                 
                 						$line["title"] = preg_replace("/($reg_exp)/i",
                 							"<span class=\"highlight\">$1</span>", $line["title"]);
                 
                 						$content_preview = preg_replace("/($reg_exp)/i",
                 							"<span class=\"highlight\">$1</span>", $content_preview);
                 					}*/
                 print $line["title"];
                 print "<div class='small' style='float : right'>" . $feed_title . "</div>";
                 print "<div class=\"insensitive\">" . $content_preview . "</div>";
                 print " " . mb_substr($line["date_entered"], 0, 16);
                 print "</td></tr>";
                 $found++;
             }
         }
         $offset += $limit;
     }
     if ($found == 0) {
         print "<tr><td align='center'>" . __("No recent articles matching this filter have been found.");
     }
     print "</table></div>";
     print "<div style='text-align : center'>";
     print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('filterTestDlg').hide()\">" . __('Close this window') . "</button>";
     print "</div>";
 }
开发者ID:Verisor,项目名称:tt-rss,代码行数:96,代码来源:filters.php


示例8: module_pref_feeds


//.........这里部分代码省略.........
                            $qpart = "update_method = '{$update_method}'";
                            break;
                        case "cat_id":
                            $qpart = $category_qpart_nocomma;
                            break;
                    }
                    if ($qpart) {
                        db_query($link, "UPDATE ttrss_feeds SET {$qpart} WHERE id IN ({$feed_ids})\n\t\t\t\t\t\t\tAND owner_uid = " . $_SESSION["uid"]);
                        print "<br/>";
                    }
                }
                db_query($link, "COMMIT");
            }
        }
    }
    if ($subop == "remove") {
        $ids = split(",", db_escape_string($_REQUEST["ids"]));
        foreach ($ids as $id) {
            remove_feed($link, $id, $_SESSION["uid"]);
        }
        return;
    }
    if ($subop == "clear") {
        $id = db_escape_string($_REQUEST["id"]);
        clear_feed_articles($link, $id);
    }
    if ($subop == "rescore") {
        $ids = split(",", db_escape_string($_REQUEST["ids"]));
        foreach ($ids as $id) {
            $filters = load_filters($link, $id, $_SESSION["uid"], 6);
            $result = db_query($link, "SELECT title, content, link, ref_id FROM\n\t\t\t\t\t\tttrss_user_entries, ttrss_entries \n\t\t\t\t\t\tWHERE ref_id = id AND feed_id = '{$id}' AND \n\t\t\t\t\t\t\towner_uid = " . $_SESSION['uid'] . "\n\t\t\t\t\t\t");
            $scores = array();
            while ($line = db_fetch_assoc($result)) {
                $article_filters = get_article_filters($filters, $line['title'], $line['content'], $line['link']);
                $new_score = calculate_article_score($article_filters);
                if (!$scores[$new_score]) {
                    $scores[$new_score] = array();
                }
                array_push($scores[$new_score], $line['ref_id']);
            }
            foreach (array_keys($scores) as $s) {
                if ($s > 1000) {
                    db_query($link, "UPDATE ttrss_user_entries SET score = '{$s}', \n\t\t\t\t\t\t\tmarked = true WHERE\n\t\t\t\t\t\t\tref_id IN (" . join(',', $scores[$s]) . ")");
                } else {
                    if ($s < -500) {
                        db_query($link, "UPDATE ttrss_user_entries SET score = '{$s}', \n\t\t\t\t\t\t\tunread = false WHERE\n\t\t\t\t\t\t\tref_id IN (" . join(',', $scores[$s]) . ")");
                    } else {
                        db_query($link, "UPDATE ttrss_user_entries SET score = '{$s}' WHERE\n\t\t\t\t\t\t\tref_id IN (" . join(',', $scores[$s]) . ")");
                    }
                }
            }
        }
        print __("All done.");
    }
    if ($subop == "rescoreAll") {
        $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION['uid']);
        while ($feed_line = db_fetch_assoc($result)) {
            $id = $feed_line["id"];
            $filters = load_filters($link, $id, $_SESSION["uid"], 6);
            $tmp_result = db_query($link, "SELECT title, content, link, ref_id FROM\n\t\t\t\t\t\tttrss_user_entries, ttrss_entries \n\t\t\t\t\t\tWHERE ref_id = id AND feed_id = '{$id}' AND \n\t\t\t\t\t\t\towner_uid = " . $_SESSION['uid'] . "\n\t\t\t\t\t\t");
            $scores = array();
            while ($line = db_fetch_assoc($tmp_result)) {
                $article_filters = get_article_filters($filters, $line['title'], $line['content'], $line['link']);
                $new_score = calculate_article_score($article_filters);
                if (!$scores[$new_score]) {
                    $scores[$new_score] = array();
开发者ID:buggithubs,项目名称:Tiny-Tiny-RSS,代码行数:67,代码来源:pref-feeds.php


示例9: update_rss_feed


//.........这里部分代码省略.........
            } else {
                // we keep encountering the entry in feeds, so we need to
                // update date_updated column so that we don't get horrible
                // dupes when the entry gets purged and reinserted again e.g.
                // in the case of SLOW SLOW OMG SLOW updating feeds
                $base_entry_id = db_fetch_result($result, 0, "id");
                db_query($link, "UPDATE ttrss_entries SET date_updated = NOW()\n\t\t\t\t\t\tWHERE id = '{$base_entry_id}'");
                $article_labels = get_article_labels($link, $base_entry_id, $owner_uid);
            }
            // now it should exist, if not - bad luck then
            $result = db_query($link, "SELECT\n\t\t\t\t\t\tid,content_hash,no_orig_date,title,plugin_data,\n\t\t\t\t\t\t" . SUBSTRING_FOR_DATE . "(date_updated,1,19) as date_updated,\n\t\t\t\t\t\t" . SUBSTRING_FOR_DATE . "(updated,1,19) as updated,\n\t\t\t\t\t\tnum_comments\n\t\t\t\t\tFROM\n\t\t\t\t\t\tttrss_entries\n\t\t\t\t\tWHERE guid = '{$entry_guid}'");
            $entry_ref_id = 0;
            $entry_int_id = 0;
            if (db_num_rows($result) == 1) {
                if ($debug_enabled) {
                    _debug("update_rss_feed: base guid [{$entry_guid}] found, checking for user record");
                }
                // this will be used below in update handler
                $orig_content_hash = db_fetch_result($result, 0, "content_hash");
                $orig_title = db_fetch_result($result, 0, "title");
                $orig_num_comments = db_fetch_result($result, 0, "num_comments");
                $orig_date_updated = strtotime(db_fetch_result($result, 0, "date_updated"));
                $orig_plugin_data = db_fetch_result($result, 0, "plugin_data");
                $ref_id = db_fetch_result($result, 0, "id");
                $entry_ref_id = $ref_id;
                // check for user post link to main table
                // do we allow duplicate posts with same GUID in different feeds?
                if (get_pref($link, "ALLOW_DUPLICATE_POSTS", $owner_uid, false)) {
                    $dupcheck_qpart = "AND (feed_id = '{$feed}' OR feed_id IS NULL)";
                } else {
                    $dupcheck_qpart = "";
                }
                /* Collect article tags here so we could filter by them: */
                $article_filters = get_article_filters($filters, $entry_title, $entry_content, $entry_link, $entry_timestamp, $entry_author, $entry_tags);
                if ($debug_enabled) {
                    _debug("update_rss_feed: article filters: ");
                    if (count($article_filters) != 0) {
                        print_r($article_filters);
                    }
                }
                if (find_article_filter($article_filters, "filter")) {
                    db_query($link, "COMMIT");
                    // close transaction in progress
                    continue;
                }
                $score = calculate_article_score($article_filters);
                if ($debug_enabled) {
                    _debug("update_rss_feed: initial score: {$score}");
                }
                $query = "SELECT ref_id, int_id FROM ttrss_user_entries WHERE\n\t\t\t\t\t\t\tref_id = '{$ref_id}' AND owner_uid = '{$owner_uid}'\n\t\t\t\t\t\t\t{$dupcheck_qpart}";
                //					if ($_REQUEST["xdebug"]) print "$query\n";
                $result = db_query($link, $query);
                // okay it doesn't exist - create user entry
                if (db_num_rows($result) == 0) {
                    if ($debug_enabled) {
                        _debug("update_rss_feed: user record not found, creating...");
                    }
                    if ($score >= -500 && !find_article_filter($article_filters, 'catchup')) {
                        $unread = 'true';
                        $last_read_qpart = 'NULL';
                    } else {
                        $unread = 'false';
                        $last_read_qpart = 'NOW()';
                    }
                    if (find_article_filter($article_filters, 'mark') || $score > 1000) {
                        $marked = 'true';
开发者ID:bohoo,项目名称:tiny_tiny_rss-openshift-quickstart-1,代码行数:67,代码来源:rssfuncs.php


示例10: module_pref_feeds


//.........这里部分代码省略.........
                        db_query($link, "UPDATE ttrss_feeds SET {$qpart} WHERE id IN ({$feed_ids})\n\t\t\t\t\t\t\tAND owner_uid = " . $_SESSION["uid"]);
                        print "<br/>";
                    }
                }
                db_query($link, "COMMIT");
            }
        }
        return;
    }
    if ($subop == "resetPubSub") {
        $ids = db_escape_string($_REQUEST["ids"]);
        db_query($link, "UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ({$ids})\n\t\t\t\tAND owner_uid = " . $_SESSION["uid"]);
        return;
    }
    if ($subop == "remove") {
        $ids = split(",", db_escape_string($_REQUEST["ids"]));
        foreach ($ids as $id) {
            remove_feed($link, $id, $_SESSION["uid"]);
        }
        return;
    }
    if ($subop == "clear") {
        $id = db_escape_string($_REQUEST["id"]);
        clear_feed_articles($link, $id);
    }
    if ($subop == "rescore") {
        $ids = split(",", db_escape_string($_REQUEST["ids"]));
        foreach ($ids as $id) {
            $filters = load_filters($link, $id, $_SESSION["uid"], 6);
            $result = db_query($link, "SELECT\n\t\t\t\t\ttitle, content, link, ref_id, author," . SUBSTRING_FOR_DATE . "(updated, 1, 19) AS updated\n\t\t\t\t  \tFROM\n\t\t\t\t\t\tttrss_user_entries, ttrss_entries\n\t\t\t\t\t\tWHERE ref_id = id AND feed_id = '{$id}' AND\n\t\t\t\t\t\t\towner_uid = " . $_SESSION['uid'] . "\n\t\t\t\t\t\t");
            $scores = array();
            while ($line = db_fetch_assoc($result)) {
                $tags = get_article_tags($link, $line["ref_id"]);
                $article_filters = get_article_filters($filters, $line['title'], $line['content'], $line['link'], strtotime($line['updated']), $line['author'], $tags);
                $new_score = calculate_article_score($article_filters);
                if (!$scores[$new_score]) {
                    $scores[$new_score] = array();
                }
                array_push($scores[$new_score], $line['ref_id']);
            }
            foreach (array_keys($scores) as $s) {
                if ($s > 1000) {
                    db_query($link, "UPDATE ttrss_user_entries SET score = '{$s}',\n\t\t\t\t\t\t\tmarked = true WHERE\n\t\t\t\t\t\t\tref_id IN (" . join(',', $scores[$s]) . ")");
                } else {
                    if ($s < -500) {
                        db_query($link, "UPDATE ttrss_user_entries SET score = '{$s}',\n\t\t\t\t\t\t\tunread = false WHERE\n\t\t\t\t\t\t\tref_id IN (" . join(',', $scores[$s]) . ")");
                    } else {
                        db_query($link, "UPDATE ttrss_user_entries SET score = '{$s}' WHERE\n\t\t\t\t\t\t\tref_id IN (" . join(',', $scores[$s]) . ")");
                    }
                }
            }
        }
        print __("All done.");
    }
    if ($subop == "rescoreAll") {
        $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION['uid']);
        while ($feed_line = db_fetch_assoc($result)) {
            $id = $feed_line["id"];
            $filters = load_filters($link, $id, $_SESSION["uid"], 6);
            $tmp_result = db_query($link, "SELECT\n\t\t\t\t\ttitle, content, link, ref_id, author," . SUBSTRING_FOR_DATE . "(updated, 1, 19) AS updated\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\tttrss_user_entries, ttrss_entries\n\t\t\t\t\t\tWHERE ref_id = id AND feed_id = '{$id}' AND\n\t\t\t\t\t\t\towner_uid = " . $_SESSION['uid'] . "\n\t\t\t\t\t\t");
            $scores = array();
            while ($line = db_fetch_assoc($tmp_result)) {
                $tags = get_article_tags($link, $line["ref_id"]);
                $article_filters = get_article_filters($filters, $line['title'], $line['content'], $line['link'], strtotime($line['updated']), $line['author'], $tags);
                $new_score = calculate_article_score($article_filters);
                if (!$scores[$new_score]) {
开发者ID:nougad,项目名称:Tiny-Tiny-RSS,代码行数:67,代码来源:pref-feeds.php



注:本文中的get_article_filters函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_article_info函数代码示例发布时间:2022-05-15
下一篇:
PHP get_article_enclosures函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap