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 /mod | |
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 'mod')
-rw-r--r-- | mod/connedit.php | 2 | ||||
-rw-r--r-- | mod/frphotos.php | 79 |
2 files changed, 80 insertions, 1 deletions
diff --git a/mod/connedit.php b/mod/connedit.php index b7535550d..b2de42343 100644 --- a/mod/connedit.php +++ b/mod/connedit.php @@ -121,7 +121,7 @@ function connedit_post(&$a) { if($orig_record[0]['abook_profile'] != $profile_id) { //Update profile photo permissions - logger('As a new profile was assigned updateing profile photos'); + logger('As a new profile was assigned updating profile photos'); require_once('mod/profile_photo.php'); profile_photo_set_profile_perms($profile_id); diff --git a/mod/frphotos.php b/mod/frphotos.php new file mode 100644 index 000000000..943651aa2 --- /dev/null +++ b/mod/frphotos.php @@ -0,0 +1,79 @@ +<?php + + + +function frphotos_init(&$a) { + + if(! local_user()) + return; + + if(intval(get_pconfig(local_user(),'frphotos','complete'))) + return; + + $channel = $a->get_channel(); + + $fr_server = $_REQUEST['fr_server']; + $fr_username = $_REQUEST['fr_username']; + $fr_password = $_REQUEST['fr_password']; + + $cookies = 'store/[data]/frphoto_cookie_' . $channel['channel_address']; + + if($fr_server && $fr_username && $fr_password) { + + $ch = curl_init($fr_server . '/api/friendica/photos/list'); + + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt ($ch, CURLOPT_COOKIEFILE, $cookies); + curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookies); + curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); + curl_setopt($ch, CURLOPT_USERPWD, $fr_username . ':' . $fr_password); + 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); + +// echo print_r($j,true); + + $total = 0; + if(count($j)) { + foreach($j as $jj) { + $total ++; + proc_run('php','util/frphotohelper.php',$jj, $channel['channel_address'], urlencode($fr_server)); + sleep(3); + } + } + if($total) { + set_pconfig(local_user(),'frphotos','complete','1'); + } + @unlink($cookies); + goaway(z_root() . '/photos/' . $channel['channel_address']); + } +} + + +function frphotos_content(&$a) { + + if(! local_user()) { + notice( t('Permission denied') . EOL); + return; + } + + if(intval(get_pconfig(local_user(),'frphotos','complete'))) { + info('Friendica photos have already been imported into this channel.'); + return; + } + + $o = replace_macros(get_markup_template('frphotos.tpl'),array( + '$header' => t('Friendica Photo Album Import'), + '$desc' => t('This will import all your Friendica photo albums to this Red channel.'), + '$fr_server' => array('fr_server', t('Friendica Server base URL'),'',''), + '$fr_username' => array('fr_username', t('Friendica Login Username'),'',''), + '$fr_password' => array('fr_password', t('Friendica Login Password'),'',''), + '$submit' => t('Submit'), + )); + return $o; +} |