From: Andrew Dolgov Date: Sun, 1 Oct 2006 10:05:20 +0000 (+0100) Subject: split backend.php into modules, backend cleanups X-Git-Tag: 1.2.4~35 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=ef8be8ea8da90596d321bc25e88c48121715ed18;p=tt-rss.git split backend.php into modules, backend cleanups --- diff --git a/backend.php b/backend.php index 49ca35c3..ac984705 100644 --- a/backend.php +++ b/backend.php @@ -1,6 +1,5 @@ "User", 10 => "Administrator"); + require_once "modules/popup-dialog.php"; + require_once "modules/help.php"; + require_once "modules/pref-feeds.php"; + require_once "modules/pref-filters.php"; + require_once "modules/pref-labels.php"; + require_once "modules/pref-users.php"; + require_once "modules/pref-prefs.php"; + require_once "modules/backend-rpc.php"; + $script_started = getmicrotime(); $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); @@ -104,22 +105,6 @@ pg_query("set client_encoding = 'utf-8'"); } - if ($_SESSION["uid"]) { - -// setcookie('ttrss_vf_refresh', FEEDS_FRAME_REFRESH); -// setcookie('ttrss_vf_daemon', ENABLE_UPDATE_DAEMON); - -/* if (get_pref($link, "ON_CATCHUP_SHOW_NEXT_FEED")) { - setcookie('ttrss_vf_catchupnext', 1); - } else { - setcookie('ttrss_vf_catchupnext', 0); - } */ - } - - $fetch = $_GET["fetch"]; - -// setcookie("ttrss_icons_url", ICONS_URL); - if (!sanity_check($link)) { return; } if ($op == "rpc") { @@ -583,2797 +568,286 @@ } if ($op == "pref-feeds") { - - $subop = $_REQUEST["subop"]; - $quiet = $_REQUEST["quiet"]; - - if ($subop == "massSubscribe") { - $ids = split(",", db_escape_string($_GET["ids"])); - - $subscribed = array(); + module_pref_feeds($link); + } - foreach ($ids as $id) { - $result = db_query($link, "SELECT feed_url,title FROM ttrss_feeds - WHERE id = '$id'"); + if ($op == "pref-filters") { + module_pref_filters($link); + } - $feed_url = db_escape_string(db_fetch_result($result, 0, "feed_url")); - $title = db_escape_string(db_fetch_result($result, 0, "title")); + if ($op == "pref-labels") { + module_pref_labels($link); + } - $title_orig = db_fetch_result($result, 0, "title"); + if ($op == "error") { + print "
"; + $msg = $_GET["msg"]; + print $msg; + print "
"; + } - $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE - feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]); + if ($op == "help") { + module_help($link); + } - if (db_num_rows($result) == 0) { - $result = db_query($link, - "INSERT INTO ttrss_feeds (owner_uid,feed_url,title,cat_id) - VALUES ('".$_SESSION["uid"]."', '$feed_url', '$title', NULL)"); + if ($op == "dlg") { + module_popup_dialog($link); + } - array_push($subscribed, $title_orig); - } - } + // update feeds of all users, may be used anonymously + if ($op == "globalUpdateFeeds") { - if (count($subscribed) > 0) { - print "
"; - print "Subscribed to feeds:"; - print ""; - print "
"; - } - } + $result = db_query($link, "SELECT id FROM ttrss_users"); - if ($subop == "browse") { + while ($line = db_fetch_assoc($result)) { + $user_id = $line["id"]; +// print ""; + update_all_feeds($link, false, $user_id); + } - if (!ENABLE_FEED_BROWSER) { - print "Feed browser is administratively disabled."; - return; - } + print " + + "; - print "
Other feeds: Top 25
"; - - print "
"; + } - print "

Showing top 25 registered feeds, sorted by popularity:

"; + if ($op == "pref-prefs") { + module_pref_prefs($link); + } -# $result = db_query($link, "SELECT feed_url,count(id) AS subscribers -# FROM ttrss_feeds -# WHERE auth_login = '' AND auth_pass = '' AND private = false -# GROUP BY feed_url ORDER BY subscribers DESC LIMIT 25"); + if ($op == "pref-users") { + module_pref_users($link); + } - $owner_uid = $_SESSION["uid"]; + if ($op == "user-details") { - $result = db_query($link, "SELECT feed_url,COUNT(id) AS subscribers - FROM ttrss_feeds WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf - WHERE tf.feed_url = ttrss_feeds.feed_url - AND owner_uid = '$owner_uid') GROUP BY feed_url - ORDER BY subscribers DESC LIMIT 25"); + if (WEB_DEMO_MODE || $_SESSION["access_level"] < 10) { + return; + } + +/* print " + Tiny Tiny RSS : User Details + + + "; */ - print "