diff options
-rw-r--r-- | include/channel.php | 12 | ||||
-rw-r--r-- | include/photo/photo_driver.php | 30 |
2 files changed, 42 insertions, 0 deletions
diff --git a/include/channel.php b/include/channel.php index 213676f52..204f375b1 100644 --- a/include/channel.php +++ b/include/channel.php @@ -7,6 +7,7 @@ require_once('include/zot.php'); require_once('include/crypto.php'); require_once('include/menu.php'); require_once('include/perm_upgrade.php'); +require_once('include/photo/photo_driver.php'); /** * @brief Called when creating a new channel. @@ -273,6 +274,17 @@ function create_identity($arr) { return $ret; } + $a = q("select * from account where account_id = %d", + intval($arr['account_id']) + ); + + $z = [ 'account' => $a[0], 'channel' = $r[0], 'photo_url' => '' ]; + call_hooks('create_channel_photo',$z); + + if($z['photo_url']) { + import_channel_photo_from_url($z['photo_url'],$arr['account_id'],$r[0]['channel_id']); + } + if($role_permissions && array_key_exists('limits',$role_permissions)) $perm_limits = $role_permissions['limits']; else diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php index 94d0faa94..c6c023147 100644 --- a/include/photo/photo_driver.php +++ b/include/photo/photo_driver.php @@ -637,6 +637,36 @@ function import_xchan_photo($photo,$xchan,$thing = false) { } +function import_channel_photo_from_url($photo,$aid,$uid) { + + if($photo) { + $filename = basename($photo); + + $result = z_fetch_url($photo,true); + + if($result['success']) { + $img_str = $result['body']; + $type = guess_image_type($photo, $result['header']); + + $h = explode("\n",$result['header']); + if($h) { + foreach($h as $hl) { + if(stristr($hl,'content-type:')) { + if(! stristr($hl,'image/')) { + $photo_failure = true; + } + } + } + } + } + } + else { + $photo_failure = true; + } + + import_channel_photo($img_str,$type,$aid,$uid); + +} function import_channel_photo($photo,$type,$aid,$uid) { |