-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathupdate.php
More file actions
executable file
·61 lines (54 loc) · 1.95 KB
/
update.php
File metadata and controls
executable file
·61 lines (54 loc) · 1.95 KB
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
<?php
ob_implicit_flush(TRUE);
require_once './bootstrap.php';
#require_once 'FirePHPCore/fb.php';
// TRUE = disable all output buffering,
// and automatically flush()
// immediately after every print or echo
function sanitize($str, $alphaNumDashOnly=TRUE){
$newStr = "";
if ($alphaNumDashOnly) {
$newStr = preg_replace('/[^A-Za-z0-9\-]/', '', $str);
}
else {
$newStr = strip_tags($str);
}
return $newStr;
}
$dbCreds = new Zend_Config_Ini(CREDS_PATH, 'db');
$config = new Zend_Config_Ini(CONFIG_PATH, ENV);
$collection = new Models_Collection(new Couch_Client($dbCreds->dsn, $dbCreds->name));
if (isset($_REQUEST['id'])) {
$collectionId = $_REQUEST['id'];
} else {
if (isset($_REQUEST['quickreport'])) {
$seed = new Models_Seeder();
if (isset($_REQUEST['mendeleygroup'])) {
$artifactIdList = $seed->getMendeleyGroupArtifacts(sanitize($_REQUEST['mendeleygroup']));
$artifactIds = implode("\n", $artifactIdList); # \n has to be in DOUBLE quotes not single quotes
} elseif (isset($_REQUEST['mendeleyprofile'])) {
$artifactIdList = $seed->getMendeleyProfileArtifacts(sanitize($_REQUEST['mendeleyprofile']));
$artifactIds = implode("\n", $artifactIdList); # \n has to be in DOUBLE quotes not single quotes
}
} else {
/**
* @todo: Models_Collection should accept a proper array, not this string nonsense.
* (It's a legacy from the hackday)
*/
$artifactIds = implode("\n", json_decode(sanitize($_REQUEST['list'], false)));
}
if (isset($_REQUEST['name'])) {
sanitize($title = $_REQUEST['name']);
} else {
$title = "";
}
// save the new collection
$storedDoc = $collection->create($title, $artifactIds);
$collectionId = $storedDoc->id;
}
error_log("now update");
// get the updates
$collection->update($collectionId, $config);
echo $collectionId;
header("HTTP/1.1 200 OK");
?>