diff options
author | zotlabs <mike@macgirvin.com> | 2017-11-06 00:17:46 -0800 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2017-11-06 00:17:46 -0800 |
commit | 04d66ba7f499e138baf322cd08f973eb6e3f73c9 (patch) | |
tree | 7db9eff587a80a804e146e1a6bc2374efd76ec6c /include/attach.php | |
parent | 7efcb3c75f08c8d974f13cd8b5f32f14749d8b6e (diff) | |
download | volse-hubzilla-04d66ba7f499e138baf322cd08f973eb6e3f73c9.tar.gz volse-hubzilla-04d66ba7f499e138baf322cd08f973eb6e3f73c9.tar.bz2 volse-hubzilla-04d66ba7f499e138baf322cd08f973eb6e3f73c9.zip |
attach.php minor cleanup and doc
Diffstat (limited to 'include/attach.php')
-rw-r--r-- | include/attach.php | 87 |
1 files changed, 26 insertions, 61 deletions
diff --git a/include/attach.php b/include/attach.php index bfe3d5d46..ab9a15ec2 100644 --- a/include/attach.php +++ b/include/attach.php @@ -2341,6 +2341,11 @@ function attach_move($channel_id, $resource_id, $new_folder_hash) { } +/** + * Used to generate a select input box of all your folders + */ + + function attach_folder_select_list($channel_id) { $r = q("select * from attach where is_dir = 1 and uid = %d", @@ -2391,6 +2396,10 @@ function attach_folder_rpaths($all_folders,$that_folder) { return (($error) ? false : [ $current_hash , $path ]); } +/** + * @brief Given a channel_id and attach_hash, return an array with the full relative path and os_path + */ + function attach_syspaths($channel_id,$attach_hash) { @@ -2414,6 +2423,17 @@ function attach_syspaths($channel_id,$attach_hash) { return [ 'os_path' => $os_path, 'path' => $path ]; } +/** + * in earlier releases we did not fill in os_path and display_path in the attach DB structure. + * (It was not needed or used). Going forward we intend to make use of these fields. + * A cron task checks for empty values (as older attachments may have arrived at our site + * in a clone operation) and executes attach_syspaths() to generate these field values and correct + * the attach table entry. The operation is limited to 100 DB entries at a time so as not to + * overload the system in any cron run. Eventually it will catch up with old attach structures + * and switch into maintenance mode to correct any that might arrive in clone packets from older + * sites. + */ + function attach_upgrade() { @@ -2440,6 +2460,12 @@ function attach_upgrade() { } +/** + * Chunked uploader for integration with the blueimp jquery-uploader + * This is currently used. + */ + + function save_chunk($channel,$start,$end,$len) { $result = []; @@ -2478,64 +2504,3 @@ function save_chunk($channel,$start,$end,$len) { } -/** - * @brief Submit handler for chunked uploads. - * - * @param array $channel - * @param array $arr - * @return array - */ -function chunkloader($channel, $arr) { - - logger('request: ' . print_r($arr,true), LOGGER_DEBUG); - logger('files: ' . print_r($_FILES,true), LOGGER_DEBUG); - - $result = []; - - $tmp_path = $_FILES['file']['tmp_name']; - $new_base = 'store/[data]/' . $channel['channel_address'] . '/tmp'; - os_mkdir($new_base,STORAGE_DEFAULT_PERMISSIONS,true); - - $new_path = $new_base . '/' . $arr['resumableFilename']; - - rename($tmp_path,$new_path . '.' . intval($arr['resumableChunkNumber'])); - - $missing_parts = false; - for($x = 1; $x <= intval($arr['resumableTotalChunks']); $x ++) { - if(! file_exists($new_path . '.' . $x)) { - $missing_parts = true; - break; - } - } - - if($missing_parts) { - $result['partial'] = true; - return $result; - } - - if(intval($arr['resumableTotalChunks']) === 1) { - rename($new_path . '.' . '1', $new_path); - } - else { - for($x = 1; $x <= intval($arr['resumableTotalChunks']); $x ++) { - $istream = fopen($new_path . '.' . $x,'rb'); - $ostream = fopen($new_path,'ab'); - if($istream && $ostream) { - pipe_streams($istream,$ostream); - fclose($istream); - fclose($ostream); - } - unlink($new_path . '.' . $x); - } - } - - $result['name'] = $arr['resumableFilename']; - $result['type'] = $arr['resumableType']; - $result['tmp_name'] = $new_path; - $result['error'] = 0; - $result['size'] = $arr['resumableTotalSize']; - $result['complete'] = true; - - return $result; -} - |