aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-01-15 20:03:49 +0000
committerMario <mario@mariovavti.com>2021-01-15 20:03:49 +0000
commitdde0f3a4032d2a24f1afa6941452c7c4e933cda7 (patch)
treebd6fc266d683b6b9108f0a58bca087f8317a2aed /Zotlabs
parent597d7bd532c35327c28a1012add9b81e5e0157b5 (diff)
downloadvolse-hubzilla-dde0f3a4032d2a24f1afa6941452c7c4e933cda7.tar.gz
volse-hubzilla-dde0f3a4032d2a24f1afa6941452c7c4e933cda7.tar.bz2
volse-hubzilla-dde0f3a4032d2a24f1afa6941452c7c4e933cda7.zip
formatting
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Module/Attach.php67
1 files changed, 34 insertions, 33 deletions
diff --git a/Zotlabs/Module/Attach.php b/Zotlabs/Module/Attach.php
index 172f6a4bc..5f5779b51 100644
--- a/Zotlabs/Module/Attach.php
+++ b/Zotlabs/Module/Attach.php
@@ -1,4 +1,5 @@
<?php
+
namespace Zotlabs\Module;
use ZipArchive;
@@ -12,24 +13,24 @@ class Attach extends Controller {
function post() {
- $attach_ids = ((x($_REQUEST, 'attach_ids')) ? $_REQUEST['attach_ids'] : []);
+ $attach_ids = ((x($_REQUEST, 'attach_ids')) ? $_REQUEST['attach_ids'] : []);
$attach_path = ((x($_REQUEST, 'attach_path')) ? $_REQUEST['attach_path'] : '');
- $channel_id = ((x($_REQUEST, 'channel_id')) ? intval($_REQUEST['channel_id']) : 0);
- $channel = channelx_by_n($channel_id);
+ $channel_id = ((x($_REQUEST, 'channel_id')) ? intval($_REQUEST['channel_id']) : 0);
+ $channel = channelx_by_n($channel_id);
- if (! $channel) {
+ if (!$channel) {
notice(t('Channel not found.') . EOL);
return;
}
- $strip_str = '/cloud/' . $channel['channel_address'] . '/';
- $count = strlen($strip_str);
+ $strip_str = '/cloud/' . $channel['channel_address'] . '/';
+ $count = strlen($strip_str);
$attach_path = substr($attach_path, $count);
if ($attach_ids) {
$zip_dir = 'store/[data]/' . $channel['channel_address'] . '/tmp';
- if (! is_dir($zip_dir))
+ if (!is_dir($zip_dir))
mkdir($zip_dir, STORAGE_DEFAULT_PERMISSIONS, true);
$token = random_string(32);
@@ -47,14 +48,14 @@ class Attach extends Controller {
$meta = [
'zip_filename' => $zip_filename,
- 'zip_path' => $zip_path
+ 'zip_path' => $zip_path
];
Verify::create('zip_token', 0, $token, json_encode($meta));
json_return_and_die([
'success' => true,
- 'token' => $token
+ 'token' => $token
]);
}
@@ -63,28 +64,28 @@ class Attach extends Controller {
function get() {
- if(argc() < 2) {
- notice( t('Item not available.') . EOL);
+ if (argc() < 2) {
+ notice(t('Item not available.') . EOL);
return;
}
$token = ((x($_REQUEST, 'token')) ? $_REQUEST['token'] : '');
- if(argv(1) === 'download') {
+ if (argv(1) === 'download') {
$meta = Verify::get_meta('zip_token', 0, $token);
- if(! $meta)
+ if (!$meta)
killme();
$meta = json_decode($meta, true);
header('Content-Type: application/zip');
- header('Content-Disposition: attachment; filename="'. $meta['zip_filename'] . '"');
+ header('Content-Disposition: attachment; filename="' . $meta['zip_filename'] . '"');
header('Content-Length: ' . filesize($meta['zip_path']));
$istream = fopen($meta['zip_path'], 'rb');
$ostream = fopen('php://output', 'wb');
- if($istream && $ostream) {
+ if ($istream && $ostream) {
pipe_streams($istream, $ostream);
fclose($istream);
fclose($ostream);
@@ -94,10 +95,10 @@ class Attach extends Controller {
killme();
}
- $r = attach_by_hash(argv(1),get_observer_hash(),((argc() > 2) ? intval(argv(2)) : 0));
+ $r = attach_by_hash(argv(1), get_observer_hash(), ((argc() > 2) ? intval(argv(2)) : 0));
- if(! $r['success']) {
- notice( $r['message'] . EOL);
+ if (!$r['success']) {
+ notice($r['message'] . EOL);
return;
}
@@ -105,27 +106,27 @@ class Attach extends Controller {
intval($r['data']['uid'])
);
- if(! $c)
+ if (!$c)
return;
- $unsafe_types = array('text/html','text/css','application/javascript');
+ $unsafe_types = array('text/html', 'text/css', 'application/javascript');
- if(in_array($r['data']['filetype'],$unsafe_types) && (! channel_codeallowed($r['data']['uid']))) {
- header('Content-Type: text/plain');
+ if (in_array($r['data']['filetype'], $unsafe_types) && (!channel_codeallowed($r['data']['uid']))) {
+ header('Content-Type: text/plain');
}
else {
header('Content-Type: ' . $r['data']['filetype']);
}
header('Content-Disposition: attachment; filename="' . $r['data']['filename'] . '"');
- if(intval($r['data']['os_storage'])) {
+ if (intval($r['data']['os_storage'])) {
$fname = $r['data']['content'];
- if(strpos($fname,'store') !== false)
- $istream = fopen($fname,'rb');
+ if (strpos($fname, 'store') !== false)
+ $istream = fopen($fname, 'rb');
else
- $istream = fopen('store/' . $c[0]['channel_address'] . '/' . $fname,'rb');
- $ostream = fopen('php://output','wb');
- if($istream && $ostream) {
+ $istream = fopen('store/' . $c[0]['channel_address'] . '/' . $fname, 'rb');
+ $ostream = fopen('php://output', 'wb');
+ if ($istream && $ostream) {
pipe_streams($istream, $ostream);
fclose($istream);
fclose($ostream);
@@ -140,14 +141,14 @@ class Attach extends Controller {
public function zip_archive_handler($zip, $attach_ids, $attach_path, $pass = 1) {
$observer_hash = get_observer_hash();
- $single = ((count($attach_ids) == 1) ? true : false);
+ $single = ((count($attach_ids) == 1) ? true : false);
$download_name = 'download.zip';
- foreach($attach_ids as $attach_id) {
+ foreach ($attach_ids as $attach_id) {
$r = attach_by_id($attach_id, $observer_hash);
- if (! $r['success']) {
+ if (!$r['success']) {
continue;
}
@@ -158,8 +159,8 @@ class Attach extends Controller {
if ($attach_path) {
$strip_str = $attach_path . '/';
- $count = strlen($strip_str);
- $zip_path = substr($r['data']['display_path'], $count);
+ $count = strlen($strip_str);
+ $zip_path = substr($r['data']['display_path'], $count);
}
if ($r['data']['is_dir']) {