owncloud: validate prefs value as an URL

This commit is contained in:
Andrew Dolgov 2012-12-28 09:32:55 +04:00
parent 7a0e05bb95
commit 0ed86aa12e

View file

@ -51,18 +51,18 @@ class OwnCloud extends Plugin {
}); });
} }
</script>"; </script>";
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pluginhandler\">"; print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pluginhandler\">";
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"save\">"; print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"save\">";
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"plugin\" value=\"owncloud\">"; print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"plugin\" value=\"owncloud\">";
print "<table width=\"100%\" class=\"prefPrefsList\">"; print "<table width=\"100%\" class=\"prefPrefsList\">";
print "<tr><td width=\"40%\">".__("Owncloud url")."</td>"; print "<tr><td width=\"40%\">".__("Owncloud url")."</td>";
print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" name=\"owncloud_url\" value=\"$value\"></td></tr>"; print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" name=\"owncloud_url\" regExp='^(http|https)://.*' value=\"$value\"></td></tr>";
print "</table>"; print "</table>";
print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">".__("Set value")."</button>"; print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">".__("Set value")."</button>";
print "</form>"; print "</form>";
print "</div>"; #pane print "</div>"; #pane
} }
@ -76,17 +76,17 @@ class OwnCloud extends Plugin {
function getOwnCloud() { function getOwnCloud() {
$id = db_escape_string($_REQUEST['id']); $id = db_escape_string($_REQUEST['id']);
$result = db_query($this->link, "SELECT title, link $result = db_query($this->link, "SELECT title, link
FROM ttrss_entries, ttrss_user_entries FROM ttrss_entries, ttrss_user_entries
WHERE id = '$id' AND ref_id = id AND owner_uid = " .$_SESSION['uid']); WHERE id = '$id' AND ref_id = id AND owner_uid = " .$_SESSION['uid']);
if (db_num_rows($result) != 0) { if (db_num_rows($result) != 0) {
$title = truncate_string(strip_tags(db_fetch_result($result, 0, 'title')), $title = truncate_string(strip_tags(db_fetch_result($result, 0, 'title')),
100, '...'); 100, '...');
$article_link = db_fetch_result($result, 0, 'link'); $article_link = db_fetch_result($result, 0, 'link');
} }
$own_url = $this->host->get($this, "owncloud"); $own_url = $this->host->get($this, "owncloud");
print json_encode(array("title" => $title, "link" => $article_link, print json_encode(array("title" => $title, "link" => $article_link,