From ba547c22571d90bc8757e45643463d53d9cae2e6 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 3 Dec 2017 17:22:18 -0800 Subject: chunked uploads for photos page --- Zotlabs/Module/Photos.php | 52 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Module/Photos.php') diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php index caef45d98..279c393aa 100644 --- a/Zotlabs/Module/Photos.php +++ b/Zotlabs/Module/Photos.php @@ -465,6 +465,51 @@ class Photos extends \Zotlabs\Web\Controller { $_REQUEST['group_deny'] = expand_acl($channel['channel_deny_gid']); } + + $matches = []; + $partial = false; + + + + if(array_key_exists('HTTP_CONTENT_RANGE',$_SERVER)) { + $pm = preg_match('/bytes (\d*)\-(\d*)\/(\d*)/',$_SERVER['HTTP_CONTENT_RANGE'],$matches); + if($pm) { + logger('Content-Range: ' . print_r($matches,true)); + $partial = true; + } + } + + if($partial) { + $x = save_chunk($channel,$matches[1],$matches[2],$matches[3]); + + if($x['partial']) { + header('Range: bytes=0-' . (($x['length']) ? $x['length'] - 1 : 0)); + json_return_and_die($result); + } + else { + header('Range: bytes=0-' . (($x['size']) ? $x['size'] - 1 : 0)); + + $_FILES['userfile'] = [ + 'name' => $x['name'], + 'type' => $x['type'], + 'tmp_name' => $x['tmp_name'], + 'error' => $x['error'], + 'size' => $x['size'] + ]; + } + } + else { + if(! array_key_exists('userfile',$_FILES)) { + $_FILES['userfile'] = [ + 'name' => $_FILES['files']['name'], + 'type' => $_FILES['files']['type'], + 'tmp_name' => $_FILES['files']['tmp_name'], + 'error' => $_FILES['files']['error'], + 'size' => $_FILES['files']['size'] + ]; + } + } + $r = attach_store($channel,get_observer_hash(), '', $_REQUEST); if(! $r['success']) { @@ -557,8 +602,11 @@ class Photos extends \Zotlabs\Web\Controller { nav_set_selected('Photos'); - $o = ""; - + $o = ' + + '; + + $o .= "\r\n"; -- cgit v1.2.3 From 1c32c5fd2ad2185ce2ea53f94edac1de1c178f7b Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 3 Dec 2017 17:25:00 -0800 Subject: rename button --- Zotlabs/Module/Photos.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Module/Photos.php') diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php index 279c393aa..6aece0ed6 100644 --- a/Zotlabs/Module/Photos.php +++ b/Zotlabs/Module/Photos.php @@ -704,7 +704,7 @@ class Photos extends \Zotlabs\Web\Controller { '$uploader' => $ret['addon_text'], '$default' => (($ret['default_upload']) ? true : false), '$uploadurl' => $ret['post_url'], - '$submit' => t('Submit') + '$submit' => t('Upload') )); -- cgit v1.2.3 From 0305983360568f991365cd815d081afedaa6d742 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 4 Dec 2017 20:46:06 +0100 Subject: fix another PHP 7.2 warning --- Zotlabs/Module/Photos.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Module/Photos.php') diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php index 6aece0ed6..1c42c0510 100644 --- a/Zotlabs/Module/Photos.php +++ b/Zotlabs/Module/Photos.php @@ -1100,7 +1100,7 @@ class Photos extends \Zotlabs\Web\Controller { } $comments = ''; - if(! count($r)) { + if(! $r) { if($observer && ($can_post || $can_comment)) { $commentbox = replace_macros($cmnt_tpl,array( '$return_path' => '', -- cgit v1.2.3 From ffaab27e77844c47501b9fd8202a6b94792c3686 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 6 Dec 2017 14:20:17 -0800 Subject: synchronise an attach_move operation to clones --- Zotlabs/Module/Photos.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Zotlabs/Module/Photos.php') diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php index 1c42c0510..81af607ec 100644 --- a/Zotlabs/Module/Photos.php +++ b/Zotlabs/Module/Photos.php @@ -202,6 +202,11 @@ class Photos extends \Zotlabs\Web\Controller { ); if(($m) && ($m[0]['folder'] != $_POST['move_to_album'])) { attach_move($page_owner_uid,argv(2),$_POST['move_to_album']); + + $sync = attach_export_data(\App::$data['channel'],argv(2),true); + if($sync) + build_sync_packet($page_owner_uid,array('file' => array($sync))); + if(! ($_POST['desc'] && $_POST['newtag'])) goaway(z_root() . '/' . $_SESSION['photo_return']); } -- cgit v1.2.3