Label editor"; print "
"; print "
"; print ""; print ""; print ""; print ""; print ""; print "
Caption: "; print "

SQL Expression:

"; print ""; print "
"; print "
"; print "
"; print "
"; print "
"; print " "; print "
"; $is_disabled = (strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== FALSE) ? "disabled" : ""; print " "; print " "; print ""; print "
"; return; } if ($subop == "test") { // no escaping here on purpose $expr = trim($_GET["expr"]); $descr = db_escape_string(trim($_GET["descr"])); $expr = str_replace(";", "", $expr); if (!$expr) { print "
Error: SQL expression is blank.
"; return; } print "
"; error_reporting(0); $result = db_query($link, "SELECT count(ttrss_entries.id) AS num_matches FROM ttrss_entries,ttrss_user_entries,ttrss_feeds WHERE ($expr) AND ttrss_user_entries.ref_id = ttrss_entries.id AND ttrss_user_entries.feed_id = ttrss_feeds.id AND ttrss_user_entries.owner_uid = " . $_SESSION["uid"], false); error_reporting (DEFAULT_ERROR_LEVEL); if (!$result) { print "
" . db_last_error($link) . "
"; print "
"; return; } $num_matches = db_fetch_result($result, 0, "num_matches");; if ($num_matches > 0) { if ($num_matches > 10) { $showing_msg = ", showing first 10"; } print "

Query returned $num_matches matches$showing_msg:

"; $result = db_query($link, "SELECT ttrss_entries.title, (SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title FROM ttrss_entries,ttrss_user_entries,ttrss_feeds WHERE ($expr) AND ttrss_user_entries.ref_id = ttrss_entries.id AND ttrss_user_entries.feed_id = ttrss_feeds.id AND ttrss_user_entries.owner_uid = " . $_SESSION["uid"] . " ORDER BY date_entered LIMIT 10", false); print ""; } else { print "

Query didn't return any matches.

"; } print "
"; return; } if ($subop == "editSave") { $sql_exp = db_escape_string(trim($_GET["sql_exp"])); $descr = db_escape_string(trim($_GET["description"])); $label_id = db_escape_string($_GET["id"]); $sql_exp = str_replace(";", "", $sql_exp); $result = db_query($link, "UPDATE ttrss_labels SET sql_exp = '$sql_exp', description = '$descr' WHERE id = '$label_id'"); if (db_affected_rows($link, $result) != 0) { print_notice(T_sprintf("Saved label %s", htmlspecialchars($descr))); } } if ($subop == "remove") { if (!WEB_DEMO_MODE) { $ids = split(",", db_escape_string($_GET["ids"])); foreach ($ids as $id) { db_query($link, "DELETE FROM ttrss_labels WHERE id = '$id'"); } } } if ($subop == "add") { $sql_exp = db_escape_string(trim($_GET["sql_exp"])); $description = db_escape_string($_GET["description"]); $sql_exp = str_replace(";", "", $sql_exp); if (!$sql_exp || !$description) return; $result = db_query($link, "INSERT INTO ttrss_labels (sql_exp,description,owner_uid) VALUES ('$sql_exp', '$description', '".$_SESSION["uid"]."')"); if (db_affected_rows($link, $result) != 0) { print T_sprintf("Created label %s", htmlspecialchars($description)); } return; } set_pref($link, "_PREFS_ACTIVE_TAB", "labelConfig"); $sort = db_escape_string($_GET["sort"]); if (!$sort || $sort == "undefined") { $sort = "description"; } $label_search = db_escape_string($_GET["search"]); if (array_key_exists("search", $_GET)) { $_SESSION["prefs_label_search"] = $label_search; } else { $label_search = $_SESSION["prefs_label_search"]; } print "

"; print "
"; print"
"; if ($label_search) { $label_search_query = "(sql_exp LIKE '%$label_search%' OR description LIKE '%$label_search%') AND"; } else { $label_search_query = ""; } $result = db_query($link, "SELECT id,sql_exp,description FROM ttrss_labels WHERE $label_search_query owner_uid = ".$_SESSION["uid"]." ORDER BY $sort"); // print "
PLACEHOLDER
"; if (db_num_rows($result) != 0) { print "

"; print ""; $lnum = 0; while ($line = db_fetch_assoc($result)) { $class = ($lnum % 2) ? "even" : "odd"; $label_id = $line["id"]; $edit_label_id = $_GET["id"]; if ($subop == "edit" && $label_id != $edit_label_id) { $class .= "Grayed"; $this_row_id = ""; } else { $this_row_id = "id=\"LILRR-$label_id\""; } print ""; $line["sql_exp"] = htmlspecialchars($line["sql_exp"]); $line["description"] = htmlspecialchars($line["description"]); if (!$line["description"]) $line["description"] = "[No caption]"; print ""; print ""; print ""; print ""; ++$lnum; } if ($lnum == 0) { print ""; } print "
".__('Select:')." ".__('All').", ".__('None')." "; print "
  ".__('Caption')." ".__('SQL Expression')."
" . $line["description"] . "" . $line["sql_exp"] . "
".__('No labels defined.')."
"; print "

"; print " "; } else { print "

".__('No labels defined.')."

"; } } ?>