aboutsummaryrefslogtreecommitdiffstats
path: root/include/import.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-12-12 11:54:26 -0800
committerzotlabs <mike@macgirvin.com>2017-12-12 11:54:26 -0800
commit215d615fc3bb9e168e21a78a6319a7971c4d1e9e (patch)
treeff0af309ef283c48a6f3df5d590068c103d6bf7a /include/import.php
parent979c05b24da0497be582aacaa8b744f692b56ccf (diff)
parentd0956eb39d7a361639f5cd73fb1c3c8463fb1e99 (diff)
downloadvolse-hubzilla-215d615fc3bb9e168e21a78a6319a7971c4d1e9e.tar.gz
volse-hubzilla-215d615fc3bb9e168e21a78a6319a7971c4d1e9e.tar.bz2
volse-hubzilla-215d615fc3bb9e168e21a78a6319a7971c4d1e9e.zip
Merge branch 'dev' of https://github.com/redmatrix/hubzilla into dev_merge
Diffstat (limited to 'include/import.php')
-rw-r--r--include/import.php37
1 files changed, 35 insertions, 2 deletions
diff --git a/include/import.php b/include/import.php
index cd7056497..a5e8adeb5 100644
--- a/include/import.php
+++ b/include/import.php
@@ -1263,10 +1263,43 @@ function sync_files($channel, $files) {
);
}
- if($p['imgscale'] === 0 && $p['os_storage'])
+ if(intval($p['imgscale']) === 0 && $p['os_storage'])
$p['content'] = $store_path;
else
- $p['content'] = base64_decode($p['content']);
+ $p['content'] = (($p['content'])? base64_decode($p['content']) : '');
+
+ if(intval($p['imgscale']) && (! $p['content'])) {
+
+ $time = datetime_convert();
+
+ $parr = array('hash' => $channel['channel_hash'],
+ 'time' => $time,
+ 'resource' => $att['hash'],
+ 'revision' => 0,
+ 'signature' => base64url_encode(rsa_sign($channel['channel_hash'] . '.' . $time, $channel['channel_prvkey'])),
+ 'resolution' => $p['imgscale']
+ );
+
+ $stored_image = $newfname . '-' . intval($p['imgscale']);
+
+ $fp = fopen($stored_image,'w');
+ if(! $fp) {
+ logger('failed to open storage file.',LOGGER_NORMAL,LOG_ERR);
+ continue;
+ }
+ $redirects = 0;
+
+
+ $headers = [];
+ $headers['Accept'] = 'application/x-zot+json' ;
+ $headers['Sigtoken'] = random_string();
+ $headers = \Zotlabs\Web\HTTPSig::create_sig('',$headers,$channel['channel_prvkey'], 'acct:' . $channel['channel_address'] . '@' . \App::get_hostname(),false,true,'sha512');
+
+ $x = z_post_url($fetch_url,$parr,$redirects,[ 'filep' => $fp, 'headers' => $headers]);
+ fclose($fp);
+ $p['content'] = file_get_contents($stored_image);
+ unlink($stored_image);
+ }
if(!isset($p['display_path']))
$p['display_path'] = '';