- security fix to /xml/bookmarks/posts/delete_p.xml - YaCy-UI: added 'add' and 'delete' bookmarks git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5171 6c8d7289-2bf4-0310-a012-ef5d649a1542pull/1/head
parent
cd1ac5bb90
commit
bbacf86fe8
@ -0,0 +1,111 @@
|
||||
// /xml/bookmarks/posts/add_p.java
|
||||
// -------------------------------
|
||||
// part of the AnomicHTTPD caching proxy
|
||||
// (C) by Michael Peter Christen; mc@yacy.net
|
||||
// first published on http://www.anomic.de
|
||||
// Frankfurt, Germany, 2004, 2005
|
||||
//
|
||||
// last major change: 16.09.2008
|
||||
// this file is contributed by Stefan Förster
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
package xml.bookmarks.posts;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
|
||||
import de.anomic.data.bookmarksDB;
|
||||
import de.anomic.data.listManager;
|
||||
import de.anomic.data.userDB;
|
||||
import de.anomic.http.httpRequestHeader;
|
||||
import de.anomic.plasma.plasmaSwitchboard;
|
||||
import de.anomic.server.serverObjects;
|
||||
import de.anomic.server.serverSwitch;
|
||||
import de.anomic.yacy.yacyNewsPool;
|
||||
import de.anomic.yacy.yacyNewsRecord;
|
||||
|
||||
|
||||
public class add_p {
|
||||
|
||||
private static final serverObjects prop = new serverObjects();
|
||||
private static plasmaSwitchboard sb = null;
|
||||
private static userDB.Entry user = null;
|
||||
private static boolean isAdmin = false;
|
||||
|
||||
public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
|
||||
|
||||
sb = (plasmaSwitchboard) env;
|
||||
isAdmin=sb.verifyAuthentication(header, true);
|
||||
user = sb.userDB.getUser(header);
|
||||
|
||||
// set user name
|
||||
String username="";
|
||||
if(user != null) username=user.getUserName();
|
||||
else if(isAdmin) username="admin";
|
||||
|
||||
if(post!= null){
|
||||
if(!isAdmin){
|
||||
// force authentication if desired
|
||||
if(post.containsKey("login")){
|
||||
prop.put("AUTHENTICATE","admin log-in");
|
||||
}
|
||||
return prop;
|
||||
}
|
||||
final String url=post.get("url","");
|
||||
final String title=post.get("title",url);
|
||||
final String description=post.get("description","");
|
||||
String tagsString = post.get("tags","");
|
||||
String pathString = post.get("path","/unsorted");
|
||||
tagsString=tagsString+","+pathString;
|
||||
final Set<String> tags=listManager.string2set(bookmarksDB.cleanTagsString(tagsString));
|
||||
final bookmarksDB.Bookmark bookmark = sb.bookmarksDB.createBookmark(url, username);
|
||||
if(bookmark != null){
|
||||
bookmark.setProperty(bookmarksDB.Bookmark.BOOKMARK_TITLE, title);
|
||||
bookmark.setProperty(bookmarksDB.Bookmark.BOOKMARK_DESCRIPTION, description);
|
||||
if(user!=null){
|
||||
bookmark.setOwner(user.getUserName());
|
||||
}
|
||||
if((post.get("public")).equals("public")){
|
||||
bookmark.setPublic(true);
|
||||
publishNews(url, title, description, tagsString);
|
||||
}else{
|
||||
bookmark.setPublic(false);
|
||||
}
|
||||
if(post.containsKey("feed") && (post.get("feed")).equals("feed")){
|
||||
bookmark.setFeed(true);
|
||||
}else{
|
||||
bookmark.setFeed(false);
|
||||
}
|
||||
bookmark.setTags(tags, true);
|
||||
sb.bookmarksDB.saveBookmark(bookmark);
|
||||
prop.put("result", "1");
|
||||
} else {
|
||||
// ERROR
|
||||
prop.put("result", "0");
|
||||
}
|
||||
}
|
||||
// return rewrite properties
|
||||
return prop;
|
||||
}
|
||||
private static void publishNews(final String url, final String title, final String description, final String tagsString) {
|
||||
// create a news message
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
map.put("url", url.replace(',', '|'));
|
||||
map.put("title", title.replace(',', ' '));
|
||||
map.put("description", description.replace(',', ' '));
|
||||
map.put("tags", tagsString.replace(',', ' '));
|
||||
sb.webIndex.newsPool.publishMyNews(yacyNewsRecord.newRecord(sb.webIndex.seedDB.mySeed(), yacyNewsPool.CATEGORY_BOOKMARK_ADD, map));
|
||||
}
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
<?xml version='1.0' encoding="UTF-8" standalone='yes'?>
|
||||
<result code="#(result)#something went wrong::done#(/result)#" />
|
@ -0,0 +1,97 @@
|
||||
/* This file skins dialog */
|
||||
|
||||
.bmdialog .ui-dialog,
|
||||
.bmdialog.ui-dialog {
|
||||
background-color: white;
|
||||
font-family: "Trebuchet MS", Trebuchet, Verdana, Helvetica, Arial, sans-serif;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.bmdialog .ui-dialog .ui-dialog-titlebar,
|
||||
.bmdialog.ui-dialog .ui-dialog-titlebar {
|
||||
background: url(../img/tab.png) no-repeat;
|
||||
padding: 2px;
|
||||
height: 28px;
|
||||
_height: 29px;
|
||||
}
|
||||
|
||||
.bmdialog .ui-dialog.ui-draggable .ui-dialog-titlebar,
|
||||
.bmdialog.ui-dialog.ui-draggable .ui-dialog-titlebar {
|
||||
cursor: move;
|
||||
}
|
||||
|
||||
.bmdialog .ui-dialog .ui-dialog-titlebar-close,
|
||||
.bmdialog.ui-dialog .ui-dialog-titlebar-close {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
background: url(../img-2/cancel.png) no-repeat;
|
||||
position:absolute;
|
||||
top: 6px;
|
||||
right: 7px;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.bmdialog .ui-dialog .ui-dialog-titlebar-close span,
|
||||
.bmdialog.ui-dialog .ui-dialog-titlebar-close span {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.bmdialog .ui-dialog .ui-dialog-titlebar-close-hover,
|
||||
.bmdialog.ui-dialog .ui-dialog-titlebar-close-hover {
|
||||
background: url(../img-2/cancel.png) no-repeat;
|
||||
}
|
||||
|
||||
.bmdialog .ui-dialog .ui-dialog-title,
|
||||
.bmdialog.ui-dialog .ui-dialog-title {
|
||||
margin-left: 5px;
|
||||
color: #27537a;
|
||||
font-weight: bold;
|
||||
line-height: 1.2;
|
||||
position: relative;
|
||||
top: 7px;
|
||||
left: 4px;
|
||||
}
|
||||
|
||||
.bmdialog .ui-dialog .ui-dialog-content,
|
||||
.bmdialog.ui-dialog .ui-dialog-content {
|
||||
margin: 1.2em;
|
||||
}
|
||||
|
||||
.bmdialog .ui-dialog .ui-dialog-buttonpane,
|
||||
.bmdialog.ui-dialog .ui-dialog-buttonpane {
|
||||
position: absolute;
|
||||
bottom: 8px;
|
||||
right: 12px;
|
||||
width: 100%;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.bmdialog .ui-dialog .ui-dialog-buttonpane button,
|
||||
.bmdialog.ui-dialog .ui-dialog-buttonpane button {
|
||||
margin: 6px;
|
||||
}
|
||||
|
||||
/* Dialog handle styles */
|
||||
.bmdialog .ui-dialog .ui-resizable-n,
|
||||
.bmdialog.ui-dialog .ui-resizable-n { cursor: n-resize; height: 6px; width: 100%; top: 0px; left: 0px; background: transparent url(i/dialog-n.gif) repeat scroll center top; }
|
||||
|
||||
.bmdialog .ui-dialog .ui-resizable-s,
|
||||
.bmdialog.ui-dialog .ui-resizable-s { cursor: s-resize; height: 8px; width: 100%; bottom: 0px; left: 0px; background: transparent url(i/dialog-s.gif) repeat scroll center top; }
|
||||
|
||||
.bmdialog .ui-dialog .ui-resizable-e,
|
||||
.bmdialog.ui-dialog .ui-resizable-e { cursor: e-resize; width: 7px; right: 0px; top: 0px; height: 100%; background: transparent url(i/dialog-e.gif) repeat scroll right center; }
|
||||
|
||||
.bmdialog .ui-dialog .ui-resizable-w,
|
||||
.bmdialog.ui-dialog .ui-resizable-w { cursor: w-resize; width: 7px; left: 0px; top: 0px; height: 100%; background: transparent url(i/dialog-w.gif) repeat scroll right center; }
|
||||
|
||||
.bmdialog .ui-dialog .ui-resizable-se,
|
||||
.bmdialog.ui-dialog .ui-resizable-se { cursor: se-resize; width: 9px; height: 9px; right: 0px; bottom: 0px; background: transparent url(i/dialog-se.gif); }
|
||||
|
||||
.bmdialog .ui-dialog .ui-resizable-sw,
|
||||
.bmdialog.ui-dialog .ui-resizable-sw { cursor: sw-resize; width: 9px; height: 9px; left: 0px; bottom: 0px; background: transparent url(i/dialog-sw.gif); }
|
||||
|
||||
.bmdialog .ui-dialog .ui-resizable-nw,
|
||||
.bmdialog.ui-dialog .ui-resizable-nw { cursor: nw-resize; width: 9px; height: 29px; left: 0px; top: 0px; background: transparent url(i/dialog-nw.gif); }
|
||||
|
||||
.bmdialog .ui-dialog .ui-resizable-ne,
|
||||
.bmdialog.ui-dialog .ui-resizable-ne { cursor: ne-resize; width: 9px; height: 29px; right: 0px; top: 0px; background: transparent url(i/dialog-ne.gif); }
|
Loading…
Reference in new issue