blob: 8b63a169a3257f4388bc4c201002bbbbc618e312 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
<?php
// Implements the del.icio.us API request to add a new post.
// http://delicious.com/help/api#posts_add
// del.icio.us behavior:
// - tags can't have spaces
// - address and description are mandatory
// - description == title in semanticscuttle
// - extended == description in semanticscuttle
// Scuttle behavior:
// - Additional 'status' variable for privacy
// - No support for 'replace' variable
// Force HTTP authentication
$httpContentType = 'text/xml';
require_once 'httpauth.inc.php';
/* Service creation: only useful services are created */
$bookmarkservice =SemanticScuttle_Service_Factory::get('Bookmark');
// Get all the bookmark's passed-in information
if (isset($_REQUEST['url']) && (trim($_REQUEST['url']) != ''))
$url = trim(urldecode($_REQUEST['url']));
else
$url = NULL;
if (isset($_REQUEST['description']) && (trim($_REQUEST['description']) != ''))
$description = trim($_REQUEST['description']);
else
$description = NULL;
if (isset($_REQUEST['extended']) && (trim($_REQUEST['extended']) != ""))
$extended = trim($_REQUEST['extended']);
else
$extended = NULL;
if (isset($_REQUEST['tags']) && (trim($_REQUEST['tags']) != '') && (trim($_REQUEST['tags']) != ','))
$tags = trim($_REQUEST['tags']);
else
$tags = NULL;
if (isset($_REQUEST['dt']) && (trim($_REQUEST['dt']) != ''))
$dt = trim($_REQUEST['dt']);
else
$dt = NULL;
$status = 0;
if (isset($_REQUEST['status'])) {
$status_str = trim($_REQUEST['status']);
if (is_numeric($status_str)) {
$status = intval($status_str);
if($status < 0 || $status > 2) {
$status = 0;
}
} else {
switch ($status_str) {
case 'private':
$status = 2;
break;
case 'shared':
$status = 1;
break;
default:
$status = 0;
break;
}
}
}
if (isset($_REQUEST['shared']) && (trim($_REQUEST['shared']) == 'no')) {
$status = 2;
}
// Error out if there's no address or description
if (is_null($url)) {
header('HTTP/1.0 400 Bad Request');
$msg = 'URL missing';
} else if (is_null($description)) {
header('HTTP/1.0 400 Bad Request');
$msg = 'Description missing';
} else {
// We're good with info; now insert it!
if ($bookmarkservice->bookmarkExists($url, $userservice->getCurrentUserId())) {
$msg = 'something went wrong';
} else {
$added = $bookmarkservice->addBookmark(
$url, $description, $extended, '', $status, $tags, null, $dt, true
);
$msg = 'done';
}
}
// Set up the XML file and output the result.
echo '<?xml version="1.0" standalone="yes" ?' . ">\r\n";
echo '<result code="' . $msg .'" />';
?>
|