1
0
mirror of https://git.tt-rss.org/git/tt-rss.git synced 2025-12-13 15:25:59 +00:00

implement upload-related support for open_basedir

This commit is contained in:
Andrew Dolgov
2013-04-11 19:12:00 +04:00
parent 063ac61353
commit 3306daecf4
7 changed files with 80 additions and 19 deletions

View File

@@ -461,14 +461,38 @@ class Opml extends Handler_Protected {
# if ($debug) $doc = DOMDocument::load("/tmp/test.opml");
if (is_file($_FILES['opml_file']['tmp_name'])) {
$doc = new DOMDocument();
$doc->load($_FILES['opml_file']['tmp_name']);
} else if (!$doc) {
if ($_FILES['opml_file']['error'] != 0) {
print_error(T_sprintf("Upload failed with error code %d",
$_FILES['opml_file']['error']));
return;
}
$tmp_file = false;
if (is_uploaded_file($_FILES['opml_file']['tmp_name'])) {
$tmp_file = tempnam(CACHE_DIR . '/upload', 'opml');
$result = move_uploaded_file($_FILES['opml_file']['tmp_name'],
$tmp_file);
if (!$result) {
print_error(__("Unable to move uploaded file."));
return;
}
} else {
print_error(__('Error: please upload OPML file.'));
return;
}
if (is_file($tmp_file)) {
$doc = new DOMDocument();
$doc->load($tmp_file);
unlink($tmp_file);
} else if (!$doc) {
print_error(__('Error: unable to find moved OPML file.'));
return;
}
if ($doc) {
$this->opml_import_category($doc, false, $owner_uid, false);
} else {