diff options
author | friendica <info@friendica.com> | 2014-08-12 18:08:31 -0700 |
---|---|---|
committer | friendica <info@friendica.com> | 2014-08-12 18:08:31 -0700 |
commit | 50da5bd3896f7dfceec6a60cb27976fbd6c2cea0 (patch) | |
tree | b42f4930c6c8f2bbfbe04ec1d519c49f826d3b2e /util | |
parent | 94ed44e76ebb6e1ed197411be16aa4d85f454b0a (diff) | |
download | volse-hubzilla-50da5bd3896f7dfceec6a60cb27976fbd6c2cea0.tar.gz volse-hubzilla-50da5bd3896f7dfceec6a60cb27976fbd6c2cea0.tar.bz2 volse-hubzilla-50da5bd3896f7dfceec6a60cb27976fbd6c2cea0.zip |
Friendica photo import tool. This will bring in all your photos from the chosen Friendica account and import them into Red. Note that profile photos will also be imported, but will not be scaled for profiles, nor will they be attached to any profiles. They will appear however in your Profile Photos album. Photos that had any access restrictions in Friendica will be made private to only you. Comments and likes, captions, and tags are not transferred, only the actual photos. You will only be able to do this once. If something goes wrong but any photos were imported, a pconfig called frphotos.complete will be set and you'll have to remove it to start over. If you should remove this to start over, we also check each photo and will not over-write a photo you already brought over.
Diffstat (limited to 'util')
-rw-r--r-- | util/frphotohelper.php | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/util/frphotohelper.php b/util/frphotohelper.php new file mode 100644 index 000000000..aacfac3e5 --- /dev/null +++ b/util/frphotohelper.php @@ -0,0 +1,72 @@ +<?php + +require_once('include/cli_startup.php'); + +cli_startup(); + +$a = get_app(); + + +$photo_id = $argv[1]; +$channel_address = $argv[2]; +$fr_server = urldecode($argv[3]); +require_once('include/photos.php'); + +$cookies = 'store/[data]/frphoto_cookie_' . $channel_address; + + $c = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_address = '%s' limit 1", + dbesc($channel_address) + ); + if(! $c) { + logger('frphotohelper: channel not found'); + killme(); + } + $channel = $c[0]; + + + $ch = curl_init($fr_server . '/api/friendica/photo?f=&photo_id=' . $photo_id); + + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt ($ch, CURLOPT_COOKIEFILE, $cookies); + curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookies); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($ch, CURLOPT_USERAGENT, 'RedMatrix'); + + $output = curl_exec($ch); + curl_close($ch); + + $j = json_decode($output,true); + +// logger('frphotohelper: ' . print_r($j,true)); + + $args = array(); + $args['data'] = base64_decode($j['data']); + $args['filename'] = $j['filename']; + $args['resource_id'] = $j['resource-id']; + $args['scale'] = $j['scale']; + $args['album'] = $j['album']; + $args['not_visible'] = 1; + + if($j['allow_cid'] || $j['allow_gid'] || $j['deny_cid'] || $j['deny_gid']) + $args['contact_allow'] = $channel['channel_hash']; + + $args['type'] = $j['type']; + + + + $r = q("select * from photo where resource_id = '%s' and uid = %d limit 1", + dbesc($args['resource_id']), + intval($channel['channel_id']) + ); + if($r) { + logger('frphotohelper: duplicate photo ignored'); + killme(); + } + + + $ret = photo_upload($channel,$channel,$args); + logger('photo_import: ' . print_r($ret,true)); + + killme(); + |