diff options
Diffstat (limited to 'include/identity.php')
-rw-r--r-- | include/identity.php | 110 |
1 files changed, 84 insertions, 26 deletions
diff --git a/include/identity.php b/include/identity.php index efc0d7d87..4352f026a 100644 --- a/include/identity.php +++ b/include/identity.php @@ -80,6 +80,16 @@ function validate_channelname($name) { function create_sys_channel() { if(get_sys_channel()) return; + + // Ensure that there is a host keypair. + + if((! get_config('system','pubkey')) && (! get_config('system','prvkey'))) { + require_once('include/crypto.php'); + $hostkey = new_keypair(4096); + set_config('system','pubkey',$hostkey['pubkey']); + set_config('system','prvkey',$hostkey['prvkey']); + } + create_identity(array( 'account_id' => 'xxx', // This will create an identity with an (integer) account_id of 0, but account_id is required 'nickname' => 'sys', @@ -99,6 +109,15 @@ function get_sys_channel() { return false; } +function is_sys_channel($channel_id) { + $r = q("select channel_pageflags from channel where channel_id = %d limit 1", + intval($channel_id) + ); + if(($r) && ($r[0]['channel_pageflags'] & PAGE_SYSTEM)) + return true; + return false; +} + /** * @channel_total() @@ -167,6 +186,11 @@ function create_identity($arr) { return $ret; } + if($nick === 'sys' && (! ($pageflags & PAGE_SYSTEM))) { + $ret['message'] = t('Reserved nickname. Please choose another.'); + return $ret; + } + if(check_webbie(array($nick)) !== $nick) { $ret['message'] = t('Nickname has unsupported characters or is already being used on this site.'); return $ret; @@ -200,10 +224,13 @@ function create_identity($arr) { $perms_vals .= ', ' . intval($v); } + $expire = get_config('system', 'default_expire_days'); + $expire = (($expire===false)? '0': $expire); + $r = q("insert into channel ( channel_account_id, channel_primary, channel_name, channel_address, channel_guid, channel_guid_sig, - channel_hash, channel_prvkey, channel_pubkey, channel_pageflags $perms_keys ) - values ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d $perms_vals ) ", + channel_hash, channel_prvkey, channel_pubkey, channel_pageflags, channel_expire_days $perms_keys ) + values ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d $perms_vals ) ", intval($arr['account_id']), intval($primary), @@ -214,7 +241,8 @@ function create_identity($arr) { dbesc($hash), dbesc($key['prvkey']), dbesc($key['pubkey']), - intval($pageflags) + intval($pageflags), + intval($expire) ); @@ -523,12 +551,20 @@ function profile_load(&$a, $nickname, $profile = '') { ); } + if(! $p) { logger('profile error: ' . $a->query_string, LOGGER_DEBUG); notice( t('Requested profile is not available.') . EOL ); $a->error = 404; return; } + + $z = q("select xchan_photo_date from xchan where xchan_hash = '%s' limit 1", + dbesc($p[0]['channel_hash']) + ); + if($z) + $p[0]['picdate'] = $z[0]['xchan_photo_date']; + // fetch user tags if this isn't the default profile @@ -547,14 +583,16 @@ function profile_load(&$a, $nickname, $profile = '') { } + $a->profile = $p[0]; + $a->profile_uid = $p[0]['profile_uid']; + $a->page['title'] = $a->profile['channel_name'] . " - " . $a->profile['channel_address'] . "@" . $a->get_hostname(); + + $a->profile['permission_to_view'] = $can_view_profile; + if($can_view_profile) { - $a->profile = $p[0]; $online = get_online_status($nickname); $a->profile['online_status'] = $online['result']; - $a->profile_uid = $p[0]['profile_uid']; - - $a->page['title'] = $a->profile['channel_name'] . " - " . $a->profile['channel_address'] . "@" . $a->get_hostname(); } if(local_user()) { @@ -568,18 +606,12 @@ function profile_load(&$a, $nickname, $profile = '') { $_SESSION['theme'] = $p[0]['channel_theme']; - $a->set_template_engine(); // reset the template engine to the default in case the user's theme doesn't specify one +// $a->set_template_engine(); // reset the template engine to the default in case the user's theme doesn't specify one - $theme_info_file = "view/theme/".current_theme()."/php/theme.php"; - if (file_exists($theme_info_file)){ - require_once($theme_info_file); - } - - if(! $can_view_profile) { - // permission denied - notice( t(' Sorry, you don\'t have the permission to view this profile. ') . EOL); - return; - } +// $theme_info_file = "view/theme/".current_theme()."/php/theme.php"; +// if (file_exists($theme_info_file)){ +// require_once($theme_info_file); +// } return; } @@ -703,7 +735,7 @@ logger('online: ' . $profile['online']); $block = true; } - if(($profile['hidewall'] || $block) && (! local_user()) && (! remote_user())) { + if(($profile['hidewall'] && (! local_user()) && (! remote_user())) || $block ) { $location = $pdesc = $gender = $marital = $homepage = $online = False; } @@ -715,7 +747,7 @@ logger('online: ' . $profile['online']); $channel_menu = false; $menu = get_pconfig($profile['uid'],'system','channel_menu'); - if($menu) { + if($menu && ! $block) { require_once('include/menu.php'); $m = menu_fetch($menu,$profile['uid'],$observer['xchan_hash']); if($m) @@ -921,15 +953,20 @@ function advanced_profile(&$a) { if(($a->profile['dob']) && ($a->profile['dob'] != '0000-00-00')) { + + $val = ''; + + if((substr($a->profile['dob'],5,2) === '00') || (substr($a->profile['dob'],8,2) === '00')) + $val = substr($a->profile['dob'],0,4); $year_bd_format = t('j F, Y'); $short_bd_format = t('j F'); - - $val = ((intval($a->profile['dob'])) - ? day_translate(datetime_convert('UTC','UTC',$a->profile['dob'] . ' 00:00 +00:00',$year_bd_format)) - : day_translate(datetime_convert('UTC','UTC','2001-' . substr($a->profile['dob'],5) . ' 00:00 +00:00',$short_bd_format))); - + if(! $val) { + $val = ((intval($a->profile['dob'])) + ? day_translate(datetime_convert('UTC','UTC',$a->profile['dob'] . ' 00:00 +00:00',$year_bd_format)) + : day_translate(datetime_convert('UTC','UTC','2001-' . substr($a->profile['dob'],5) . ' 00:00 +00:00',$short_bd_format))); + } $profile['birthday'] = array( t('Birthday:'), $val); } @@ -940,7 +977,7 @@ function advanced_profile(&$a) { if($a->profile['marital']) $profile['marital'] = array( t('Status:'), $a->profile['marital']); - if($a->profile['with']) $profile['marital']['with'] = $a->profile['with']; + if($a->profile['with']) $profile['marital']['with'] = bbcode($a->profile['with']); if(strlen($a->profile['howlong']) && $a->profile['howlong'] !== '0000-00-00 00:00:00') { $profile['howlong'] = relative_date($a->profile['howlong'], t('for %1$d %2$s')); @@ -1221,3 +1258,24 @@ function get_channel_by_nick($nick) { return(($r) ? $r[0] : false); } + + +function identity_selector() { + if(local_user()) { + $r = q("select channel.*, xchan.* from channel left join xchan on channel.channel_hash = xchan.xchan_hash where channel.channel_account_id = %d and not ( channel_pageflags & %d ) order by channel_name ", + intval(get_account_id()), + intval(PAGE_REMOVED) + ); + if(count($r) > 1) { + $selected_channel = null; + $account = get_app()->get_account(); + $o = replace_macros(get_markup_template('channel_id_select.tpl'),array( + '$channels' => $r, + '$selected' => local_user() + )); + return $o; + } + } + + return ''; +} |