summaryrefslogtreecommitdiff
path: root/classes/opml.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2013-04-11 19:12:00 +0400
committerAndrew Dolgov <[email protected]>2013-04-11 19:12:00 +0400
commit3306daecf4450555961490c11e70e7cf7fe7b86e (patch)
tree98e1162f201f0f0672e14bd12c76677e4d24337e /classes/opml.php
parent063ac6135304223d6667401936e3a3931522b07c (diff)
implement upload-related support for open_basedir
Diffstat (limited to 'classes/opml.php')
-rw-r--r--classes/opml.php30
1 files changed, 27 insertions, 3 deletions
diff --git a/classes/opml.php b/classes/opml.php
index 7a49f757c..2ecae4237 100644
--- a/classes/opml.php
+++ b/classes/opml.php
@@ -461,11 +461,35 @@ class Opml extends Handler_Protected {
# if ($debug) $doc = DOMDocument::load("/tmp/test.opml");
- if (is_file($_FILES['opml_file']['tmp_name'])) {
+ 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($_FILES['opml_file']['tmp_name']);
+ $doc->load($tmp_file);
+ unlink($tmp_file);
} else if (!$doc) {
- print_error(__('Error: please upload OPML file.'));
+ print_error(__('Error: unable to find moved OPML file.'));
return;
}