From 23846a98488bec2aaade6d983b4c0b0db13af80c Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Sun, 3 Jul 2011 19:00:54 +0300 Subject: ajax mediamanager --- lib/exe/ajax.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'lib/exe/ajax.php') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 1056a05f8..16efd9ac7 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -210,7 +210,30 @@ function ajax_medialist(){ global $NS; $NS = $_POST['ns']; - tpl_mediaContent(true); + if ($_POST['do'] == 'media') { + tpl_fileList(true); + } else { + tpl_mediaContent(true); + } +} + +/** + * Return the content of the right column + * (image details) for the Mediamanager + * + * @author Kate Arzamastseva + */ +function ajax_mediadetails(){ + global $conf; + global $NS; + + $NS = $_POST['ns']; + $image = $_POST['image']; + if (isset($_POST['full'])) { + tpl_fileDetails($image, false); + } else { + tpl_fileDetails($image, false, true); + } } /** -- cgit v1.2.3 From ed69a2ae06c0707fdd5634e18d569c25f0cda6d5 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Sun, 3 Jul 2011 23:56:26 +0300 Subject: ajax mediamanager fix --- lib/exe/ajax.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'lib/exe/ajax.php') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 16efd9ac7..8ff0f8eda 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -211,7 +211,7 @@ function ajax_medialist(){ $NS = $_POST['ns']; if ($_POST['do'] == 'media') { - tpl_fileList(true); + tpl_fileList(); } else { tpl_mediaContent(true); } @@ -229,11 +229,7 @@ function ajax_mediadetails(){ $NS = $_POST['ns']; $image = $_POST['image']; - if (isset($_POST['full'])) { - tpl_fileDetails($image, false); - } else { - tpl_fileDetails($image, false, true); - } + tpl_fileDetails($image, false); } /** -- cgit v1.2.3 From 7d7ab775ac0252d50835987b276a95b790cd1434 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Mon, 4 Jul 2011 22:35:44 +0300 Subject: mediamanager ajax forms --- lib/exe/ajax.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'lib/exe/ajax.php') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 8ff0f8eda..59953ddc3 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -224,12 +224,17 @@ function ajax_medialist(){ * @author Kate Arzamastseva */ function ajax_mediadetails(){ - global $conf; - global $NS; + global $DEL, $NS, $IMG, $AUTH, $JUMPTO, $REV, $lang, $fullscreen; + $fullscreen = true; + require_once(DOKU_INC.'lib/exe/mediamanager.php'); - $NS = $_POST['ns']; - $image = $_POST['image']; - tpl_fileDetails($image, false); + if ($_REQUEST['image']) $image = cleanID($_REQUEST['image']); + if (isset($IMG)) $image = $IMG; + if (isset($JUMPTO)) $image = $JUMPTO; + if (isset($REV) && !$JUMPTO) $rev = $REV; + + html_msgarea(); + tpl_fileDetails($image, $rev); } /** -- cgit v1.2.3 From 4ee1558545059fa73700709a9ef4c0ab22ce8f92 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Tue, 26 Jul 2011 11:55:38 +0300 Subject: image diffs fixes --- lib/exe/ajax.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib/exe/ajax.php') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 483d65cff..300fb8acb 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -235,6 +235,19 @@ function ajax_mediadetails(){ tpl_fileDetails($image, $rev); } +/** + * Returns image diff representation for mediamanager + * @author Kate Arzamastseva + */ +function ajax_mediadiff(){ + global $NS; + + if ($_REQUEST['image']) $image = cleanID($_REQUEST['image']); + $NS = $_POST['ns']; + $auth = auth_quickaclcheck("$ns:*"); + media_diff($image, $NS, $auth); +} + /** * Return sub index for index view * -- cgit v1.2.3 From 92cac9a97ee63d9c3c9bb8b0da1e3eb0604ba04f Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Wed, 3 Aug 2011 15:19:52 +0300 Subject: issue #38 diff links only if diff available; deleted files --- lib/exe/ajax.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/exe/ajax.php') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 300fb8acb..20fc99de4 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -222,7 +222,7 @@ function ajax_medialist(){ * @author Kate Arzamastseva */ function ajax_mediadetails(){ - global $DEL, $NS, $IMG, $AUTH, $JUMPTO, $REV, $lang, $fullscreen; + global $DEL, $NS, $IMG, $AUTH, $JUMPTO, $REV, $lang, $fullscreen, $conf; $fullscreen = true; require_once(DOKU_INC.'lib/exe/mediamanager.php'); -- cgit v1.2.3 From 09063cc66339d6e5daa12af4896a2457c03cfaf3 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Thu, 4 Aug 2011 20:32:16 +0300 Subject: issue #44 multi file uploader --- lib/exe/ajax.php | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) (limited to 'lib/exe/ajax.php') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 20fc99de4..391e951e5 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -248,6 +248,88 @@ function ajax_mediadiff(){ media_diff($image, $NS, $auth); } +function ajax_mediaupload(){ + global $NS; + $NS = $_REQUEST['ns']; + $AUTH = auth_quickaclcheck("$NS:*"); + if($AUTH >= AUTH_UPLOAD) { io_createNamespace("$NS:xxx", 'media'); } + + if($_FILES['qqfile']['error']){ + unset($_FILES['qqfile']); + } + + if($_FILES['qqfile']['tmp_name']){ + $id = $_FILES['qqfile']['name']; + $file = $_FILES['qqfile']['tmp_name']; + list($ext,$mime,$dl) = mimetype($id); + + $res = media_save( + array('name' => $file, + 'mime' => $mime, + 'ext' => $ext), + $NS.':'.$id, + false, + $AUTH, + 'move_uploaded_file' + ); + if (!is_array($res)) { + $result = array('success'=>true); + } + } + + if (isset($_GET['qqfile'])) { + $id = $_GET['qqfile']; + list($ext,$mime,$dl) = mimetype($id); + $input = fopen("php://input", "r"); + $temp = tmpfile(); + $realSize = stream_copy_to_stream($input, $temp); + fclose($input); + if ($realSize != (int)$_SERVER["CONTENT_LENGTH"]) return false; + if (!($tmp = io_mktmpdir())) return false; + $path = $tmp.'/'.$id; + $target = fopen($path, "w"); + fseek($temp, 0, SEEK_SET); + stream_copy_to_stream($temp, $target); + fclose($target); + $res = media_save( + array('name' => $path, + 'mime' => $mime, + 'ext' => $ext), + $NS.':'.$id, + false, + $AUTH, + 'copy' + ); + unlink($path); + if ($tmp) dir_delete($tmp); + if (!is_array($res)) { + $result = array('success'=>true); + } + } + if (!$result) $result = array('error'=> 'Could not save uploaded file.'); + echo htmlspecialchars(json_encode($result), ENT_NOQUOTES); +} + +function dir_delete($path) { + if (!is_string($path) || $path == "") return false; + + if (is_dir($path) && !is_link($path)) { + if (!$dh = @opendir($path)) return false; + + while ($f = readdir($dh)) { + if ($f == '..' || $f == '.') continue; + dir_delete("$path/$f"); + } + + closedir($dh); + return @rmdir($path); + } else { + return @unlink($path); + } + + return false; +} + /** * Return sub index for index view * -- cgit v1.2.3 From 6bdff0836f4bc1eee19aa8c30d03ba4bfc876733 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Mon, 8 Aug 2011 19:37:09 +0300 Subject: issue #44 overwrite checkbox added to uploader --- lib/exe/ajax.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/exe/ajax.php') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 391e951e5..7a4cea360 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -245,7 +245,7 @@ function ajax_mediadiff(){ if ($_REQUEST['image']) $image = cleanID($_REQUEST['image']); $NS = $_POST['ns']; $auth = auth_quickaclcheck("$ns:*"); - media_diff($image, $NS, $auth); + media_diff($image, $NS, $auth, true); } function ajax_mediaupload(){ @@ -259,7 +259,8 @@ function ajax_mediaupload(){ } if($_FILES['qqfile']['tmp_name']){ - $id = $_FILES['qqfile']['name']; + $id = $_REQUEST['file_name']; + if (!$id) $id = $_FILES['qqfile']['name']; $file = $_FILES['qqfile']['tmp_name']; list($ext,$mime,$dl) = mimetype($id); @@ -268,7 +269,7 @@ function ajax_mediaupload(){ 'mime' => $mime, 'ext' => $ext), $NS.':'.$id, - false, + $_REQUEST['ow'], $AUTH, 'move_uploaded_file' ); @@ -296,7 +297,7 @@ function ajax_mediaupload(){ 'mime' => $mime, 'ext' => $ext), $NS.':'.$id, - false, + (($_REQUEST['ow'] == 'true') ? true : false), $AUTH, 'copy' ); -- cgit v1.2.3 From 2d6cc64fdb73879f54aa25b2122f36631c654e3c Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Fri, 12 Aug 2011 12:50:34 +0300 Subject: issue #44, #52 media_upload reused, error handling --- lib/exe/ajax.php | 63 ++++++++++---------------------------------------------- 1 file changed, 11 insertions(+), 52 deletions(-) (limited to 'lib/exe/ajax.php') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 7a4cea360..aa07fe7b0 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -249,65 +249,24 @@ function ajax_mediadiff(){ } function ajax_mediaupload(){ - global $NS; + global $NS, $MSG; + $NS = $_REQUEST['ns']; $AUTH = auth_quickaclcheck("$NS:*"); if($AUTH >= AUTH_UPLOAD) { io_createNamespace("$NS:xxx", 'media'); } - if($_FILES['qqfile']['error']){ - unset($_FILES['qqfile']); - } - - if($_FILES['qqfile']['tmp_name']){ - $id = $_REQUEST['file_name']; - if (!$id) $id = $_FILES['qqfile']['name']; - $file = $_FILES['qqfile']['tmp_name']; - list($ext,$mime,$dl) = mimetype($id); - - $res = media_save( - array('name' => $file, - 'mime' => $mime, - 'ext' => $ext), - $NS.':'.$id, - $_REQUEST['ow'], - $AUTH, - 'move_uploaded_file' - ); - if (!is_array($res)) { - $result = array('success'=>true); - } - } + if ($_FILES['qqfile']['error']) unset($_FILES['qqfile']); + if ($_FILES['qqfile']['tmp_name']) $res = media_upload($NS, $AUTH, $_FILES['qqfile']); + if (isset($_GET['qqfile'])) $res = media_upload_xhr($NS, $AUTH); + if ($res) $result = array('success'=>true); - if (isset($_GET['qqfile'])) { - $id = $_GET['qqfile']; - list($ext,$mime,$dl) = mimetype($id); - $input = fopen("php://input", "r"); - $temp = tmpfile(); - $realSize = stream_copy_to_stream($input, $temp); - fclose($input); - if ($realSize != (int)$_SERVER["CONTENT_LENGTH"]) return false; - if (!($tmp = io_mktmpdir())) return false; - $path = $tmp.'/'.$id; - $target = fopen($path, "w"); - fseek($temp, 0, SEEK_SET); - stream_copy_to_stream($temp, $target); - fclose($target); - $res = media_save( - array('name' => $path, - 'mime' => $mime, - 'ext' => $ext), - $NS.':'.$id, - (($_REQUEST['ow'] == 'true') ? true : false), - $AUTH, - 'copy' - ); - unlink($path); - if ($tmp) dir_delete($tmp); - if (!is_array($res)) { - $result = array('success'=>true); + if (!$result) { + $error = ''; + if (isset($MSG)) { + foreach($MSG as $msg) $error .= $msg['msg']; } + $result = array('error'=> $msg['msg']); } - if (!$result) $result = array('error'=> 'Could not save uploaded file.'); echo htmlspecialchars(json_encode($result), ENT_NOQUOTES); } -- cgit v1.2.3 From 873cd06e1bda38e0decce16d6ec7d3bdaece612e Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Mon, 15 Aug 2011 14:22:19 +0300 Subject: issue #50 styling the new uploader --- lib/exe/ajax.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'lib/exe/ajax.php') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index aa07fe7b0..52131d864 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -256,16 +256,25 @@ function ajax_mediaupload(){ if($AUTH >= AUTH_UPLOAD) { io_createNamespace("$NS:xxx", 'media'); } if ($_FILES['qqfile']['error']) unset($_FILES['qqfile']); - if ($_FILES['qqfile']['tmp_name']) $res = media_upload($NS, $AUTH, $_FILES['qqfile']); - if (isset($_GET['qqfile'])) $res = media_upload_xhr($NS, $AUTH); - if ($res) $result = array('success'=>true); + + if ($_FILES['qqfile']['tmp_name']) { + $res = media_upload($NS, $AUTH, $_FILES['qqfile']); + $id = ((empty($_POST['mediaid'])) ? $_FILES['qqfile']['name'] : $_POST['mediaid']); + } + if (isset($_GET['qqfile'])) { + $res = media_upload_xhr($NS, $AUTH); + $id = $_GET['qqfile']; + } + + if ($res) $result = array('success' => true, + 'link' => media_managerURL(array('ns' => getNS($id), 'image' => $id), '&')); if (!$result) { $error = ''; if (isset($MSG)) { foreach($MSG as $msg) $error .= $msg['msg']; } - $result = array('error'=> $msg['msg']); + $result = array('error' => $msg['msg']); } echo htmlspecialchars(json_encode($result), ENT_NOQUOTES); } -- cgit v1.2.3 From c472bad9de398442c30ec1410d07284f0db8b821 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Fri, 19 Aug 2011 20:56:43 +0300 Subject: issue #44 new uploader in the media popup --- lib/exe/ajax.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/exe/ajax.php') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 52131d864..d8754b875 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -265,9 +265,11 @@ function ajax_mediaupload(){ $res = media_upload_xhr($NS, $AUTH); $id = $_GET['qqfile']; } + $id = cleanID($id, false, true); if ($res) $result = array('success' => true, - 'link' => media_managerURL(array('ns' => getNS($id), 'image' => $id), '&')); + 'link' => media_managerURL(array('ns' => getNS($id), 'image' => $id), '&'), + 'id' => $id); if (!$result) { $error = ''; -- cgit v1.2.3 From 9de3b5710719658ef75740c0bd930423cc7c209c Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Sun, 21 Aug 2011 02:16:39 +0300 Subject: issue #44 uploader fixes, #45 browser testing --- lib/exe/ajax.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/exe/ajax.php') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index d8754b875..7fcccd4d9 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -268,15 +268,15 @@ function ajax_mediaupload(){ $id = cleanID($id, false, true); if ($res) $result = array('success' => true, - 'link' => media_managerURL(array('ns' => getNS($id), 'image' => $id), '&'), - 'id' => $id); + 'link' => media_managerURL(array('ns' => $NS, 'image' => $id), '&'), + 'id' => $NS.':'.$id, 'ns' => $NS); if (!$result) { $error = ''; if (isset($MSG)) { foreach($MSG as $msg) $error .= $msg['msg']; } - $result = array('error' => $msg['msg']); + $result = array('error' => $msg['msg'], 'ns' => $NS); } echo htmlspecialchars(json_encode($result), ENT_NOQUOTES); } -- cgit v1.2.3 From 035e07f1301d5d7a13de017640d80db14d300ac3 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Wed, 24 Aug 2011 22:34:06 +0300 Subject: issue #57, function names, params, html fixes --- lib/exe/ajax.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/exe/ajax.php') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 7fcccd4d9..a6e45c4de 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -209,7 +209,7 @@ function ajax_medialist(){ $NS = $_POST['ns']; if ($_POST['do'] == 'media') { - tpl_fileList(); + tpl_mediaFileList(); } else { tpl_mediaContent(true); } @@ -232,7 +232,7 @@ function ajax_mediadetails(){ if (isset($REV) && !$JUMPTO) $rev = $REV; html_msgarea(); - tpl_fileDetails($image, $rev); + tpl_mediaFileDetails($image, $rev); } /** @@ -268,7 +268,7 @@ function ajax_mediaupload(){ $id = cleanID($id, false, true); if ($res) $result = array('success' => true, - 'link' => media_managerURL(array('ns' => $NS, 'image' => $id), '&'), + 'link' => media_managerURL(array('ns' => $NS, 'image' => $NS.':'.$id), '&'), 'id' => $NS.':'.$id, 'ns' => $NS); if (!$result) { -- cgit v1.2.3 From 30fd72fbc3c8bd3fbcae4f7041aa0e001a719c6a Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Fri, 2 Sep 2011 14:50:19 +0300 Subject: issue #47 Changes to old media manager popup: removing edit and delete functionality --- lib/exe/ajax.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/exe/ajax.php') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index a6e45c4de..4f627e995 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -268,7 +268,7 @@ function ajax_mediaupload(){ $id = cleanID($id, false, true); if ($res) $result = array('success' => true, - 'link' => media_managerURL(array('ns' => $NS, 'image' => $NS.':'.$id), '&'), + 'link' => media_managerURL(array('ns' => $NS.':'.getNS($id), 'image' => $NS.':'.$id), '&'), 'id' => $NS.':'.$id, 'ns' => $NS); if (!$result) { -- cgit v1.2.3 From cc2c0b9d6af82732ed79eeb85c22b7c3192a4e55 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Tue, 6 Sep 2011 19:22:07 +0300 Subject: issue #61 security fix --- lib/exe/ajax.php | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'lib/exe/ajax.php') diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 4f627e995..d4ef8dc11 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -251,24 +251,27 @@ function ajax_mediadiff(){ function ajax_mediaupload(){ global $NS, $MSG; - $NS = $_REQUEST['ns']; - $AUTH = auth_quickaclcheck("$NS:*"); - if($AUTH >= AUTH_UPLOAD) { io_createNamespace("$NS:xxx", 'media'); } - - if ($_FILES['qqfile']['error']) unset($_FILES['qqfile']); - if ($_FILES['qqfile']['tmp_name']) { - $res = media_upload($NS, $AUTH, $_FILES['qqfile']); $id = ((empty($_POST['mediaid'])) ? $_FILES['qqfile']['name'] : $_POST['mediaid']); - } - if (isset($_GET['qqfile'])) { - $res = media_upload_xhr($NS, $AUTH); + } elseif (isset($_GET['qqfile'])) { $id = $_GET['qqfile']; } + $id = cleanID($id, false, true); + $NS = $_REQUEST['ns']; + $ns = $NS.':'.getNS($id); + + $AUTH = auth_quickaclcheck("$ns:*"); + if($AUTH >= AUTH_UPLOAD) { io_createNamespace("$ns:xxx", 'media'); } + + if ($_FILES['qqfile']['error']) unset($_FILES['qqfile']); + + if ($_FILES['qqfile']['tmp_name']) $res = media_upload($NS, $AUTH, $_FILES['qqfile']); + if (isset($_GET['qqfile'])) $res = media_upload_xhr($NS, $AUTH); + if ($res) $result = array('success' => true, - 'link' => media_managerURL(array('ns' => $NS.':'.getNS($id), 'image' => $NS.':'.$id), '&'), + 'link' => media_managerURL(array('ns' => $ns, 'image' => $NS.':'.$id), '&'), 'id' => $NS.':'.$id, 'ns' => $NS); if (!$result) { -- cgit v1.2.3