3 * @file include/identity.php
6 require_once('include/forums.php');
11 * Function : profile_load
13 * @parameter string $nickname
14 * @parameter int $profile
16 * Summary: Loads a profile into the page sidebar.
17 * The function requires a writeable copy of the main App structure, and the nickname
18 * of a registered local account.
20 * If the viewer is an authenticated remote viewer, the profile displayed is the
21 * one that has been configured for his/her viewing in the Contact manager.
22 * Passing a non-zero profile ID can also allow a preview of a selected profile
25 * Profile information is placed in the App structure for later retrieval.
26 * Honours the owner's chosen theme for display.
28 * IMPORTANT: Should only be run in the _init() functions of a module. That ensures that
29 * the theme is chosen before the _init() function of a theme is run, which will usually
30 * load a lot of theme-specific content
34 if(! function_exists('profile_load')) {
35 function profile_load(&$a, $nickname, $profile = 0, $profiledata = array()) {
37 $user = q("SELECT `uid` FROM `user` WHERE `nickname` = '%s' LIMIT 1",
41 if(!$user && count($user) && !count($profiledata)) {
42 logger('profile error: ' . $a->query_string, LOGGER_DEBUG);
43 notice( t('Requested account is not available.') . EOL );
48 if(remote_user() && count($_SESSION['remote'])) {
49 foreach($_SESSION['remote'] as $visitor) {
50 if($visitor['uid'] == $user[0]['uid']) {
51 $r = q("SELECT `profile-id` FROM `contact` WHERE `id` = %d LIMIT 1",
52 intval($visitor['cid'])
55 $profile = $r[0]['profile-id'];
64 $profile_int = intval($profile);
65 $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `contact`.`addr` AS faddr, `user`.* FROM `profile`
66 INNER JOIN `contact` on `contact`.`uid` = `profile`.`uid` INNER JOIN `user` ON `profile`.`uid` = `user`.`uid`
67 WHERE `user`.`nickname` = '%s' AND `profile`.`id` = %d AND `contact`.`self` = 1 LIMIT 1",
72 if((!$r) && (!count($r))) {
73 $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `contact`.`addr` AS faddr, `user`.* FROM `profile`
74 INNER JOIN `contact` ON `contact`.`uid` = `profile`.`uid` INNER JOIN `user` ON `profile`.`uid` = `user`.`uid`
75 WHERE `user`.`nickname` = '%s' AND `profile`.`is-default` = 1 AND `contact`.`self` = 1 LIMIT 1",
80 if(($r === false) || (!count($r)) && !count($profiledata)) {
81 logger('profile error: ' . $a->query_string, LOGGER_DEBUG);
82 notice( t('Requested profile is not available.') . EOL );
87 // fetch user tags if this isn't the default profile
89 if(!$r[0]['is-default']) {
90 $x = q("SELECT `pub_keywords` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1",
91 intval($r[0]['profile_uid'])
94 $r[0]['pub_keywords'] = $x[0]['pub_keywords'];
98 $a->profile_uid = $r[0]['profile_uid'];
100 $a->profile['mobile-theme'] = get_pconfig($a->profile['profile_uid'], 'system', 'mobile_theme');
101 $a->profile['network'] = NETWORK_DFRN;
103 $a->page['title'] = $a->profile['name'] . " @ " . $a->config['sitename'];
105 // if (!$profiledata)
106 // $_SESSION['theme'] = $a->profile['theme'];
108 $_SESSION['mobile-theme'] = $a->profile['mobile-theme'];
111 * load/reload current theme info
114 $a->set_template_engine(); // reset the template engine to the default in case the user's theme doesn't specify one
116 $theme_info_file = "view/theme/".current_theme()."/theme.php";
117 if (file_exists($theme_info_file)){
118 require_once($theme_info_file);
121 if(! (x($a->page,'aside')))
122 $a->page['aside'] = '';
124 if(local_user() && local_user() == $a->profile['uid'] && $profiledata) {
125 $a->page['aside'] .= replace_macros(get_markup_template('profile_edlink.tpl'),array(
126 '$editprofile' => t('Edit profile'),
127 '$profid' => $a->profile['id']
131 $block = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false);
134 // By now, the contact block isn't shown, when a different profile is given
135 // But: When this profile was on the same server, then we could display the contacts
137 $a->page['aside'] .= profile_sidebar($profiledata, true);
139 $a->page['aside'] .= profile_sidebar($a->profile, $block);
143 $a->page['aside'] .= contact_block();*/
152 * Function: profile_sidebar
154 * Formats a profile for display in the sidebar.
155 * It is very difficult to templatise the HTML completely
156 * because of all the conditional logic.
158 * @parameter: array $profile
160 * Returns HTML string stuitable for sidebar inclusion
161 * Exceptions: Returns empty string if passed $profile is wrong type or not populated
166 if(! function_exists('profile_sidebar')) {
167 function profile_sidebar($profile, $block = 0) {
175 if((! is_array($profile)) && (! count($profile)))
178 $profile['picdate'] = urlencode($profile['picdate']);
180 if (($profile['network'] != "") AND ($profile['network'] != NETWORK_DFRN)) {
181 require_once('include/contact_selectors.php');
182 if ($profile['url'] != "")
183 $profile['network_name'] = '<a href="'.$profile['url'].'">'.network_to_name($profile['network'], $profile['url'])."</a>";
185 $profile['network_name'] = network_to_name($profile['network']);
187 $profile['network_name'] = "";
189 call_hooks('profile_sidebar_enter', $profile);
192 // don't show connect link to yourself
193 $connect = (($profile['uid'] != local_user()) ? t('Connect') : False);
195 // don't show connect link to authenticated visitors either
196 if(remote_user() && count($_SESSION['remote'])) {
197 foreach($_SESSION['remote'] as $visitor) {
198 if($visitor['uid'] == $profile['uid']) {
205 // Is the local user already connected to that user?
206 if ($connect AND local_user()) {
207 if (isset($profile["url"]))
208 $profile_url = normalise_link($profile["url"]);
210 $profile_url = normalise_link($a->get_baseurl()."/profile/".$profile["nickname"]);
212 $r = q("SELECT * FROM `contact` WHERE NOT `pending` AND `uid` = %d AND `nurl` = '%s'",
213 local_user(), $profile_url);
218 if ($connect AND ($profile['network'] != NETWORK_DFRN) AND !isset($profile['remoteconnect']))
221 if (isset($profile['remoteconnect']))
222 $remoteconnect = $profile['remoteconnect'];
224 if ($connect AND ($profile['network'] == NETWORK_DFRN) AND !isset($remoteconnect))
225 $subscribe_feed = t("Atom feed");
227 $subscribe_feed = false;
229 if(get_my_url() && $profile['unkmail'] && ($profile['uid'] != local_user()))
230 $wallmessage = t('Message');
232 $wallmessage = false;
234 // show edit profile to yourself
235 if ($profile['uid'] == local_user() && feature_enabled(local_user(),'multi_profiles')) {
236 $profile['edit'] = array($a->get_baseurl(). '/profiles', t('Profiles'),"", t('Manage/edit profiles'));
237 $r = q("SELECT * FROM `profile` WHERE `uid` = %d",
240 $profile['menu'] = array(
241 'chg_photo' => t('Change profile photo'),
242 'cr_new' => t('Create New Profile'),
243 'entries' => array(),
249 $profile['menu']['entries'][] = array(
250 'photo' => $rr['thumb'],
252 'alt' => t('Profile Image'),
253 'profile_name' => $rr['profile-name'],
254 'isdefault' => $rr['is-default'],
255 'visibile_to_everybody' => t('visible to everybody'),
256 'edit_visibility' => t('Edit visibility'),
264 if ($profile['uid'] == local_user() && !feature_enabled(local_user(),'multi_profiles')) {
265 $profile['edit'] = array($a->get_baseurl(). '/profiles/'.$profile['id'], t('Edit profile'),"", t('Edit profile'));
266 $profile['menu'] = array(
267 'chg_photo' => t('Change profile photo'),
269 'entries' => array(),
273 if((x($profile,'address') == 1)
274 || (x($profile,'locality') == 1)
275 || (x($profile,'region') == 1)
276 || (x($profile,'postal-code') == 1)
277 || (x($profile,'country-name') == 1))
278 $location = t('Location:');
280 $gender = ((x($profile,'gender') == 1) ? t('Gender:') : False);
283 $marital = ((x($profile,'marital') == 1) ? t('Status:') : False);
285 $homepage = ((x($profile,'homepage') == 1) ? t('Homepage:') : False);
287 $about = ((x($profile,'about') == 1) ? t('About:') : False);
289 if(($profile['hidewall'] || $block) && (! local_user()) && (! remote_user())) {
290 $location = $pdesc = $gender = $marital = $homepage = $about = False;
293 $firstname = ((strpos($profile['name'],' '))
294 ? trim(substr($profile['name'],0,strpos($profile['name'],' '))) : $profile['name']);
295 $lastname = (($firstname === $profile['name']) ? '' : trim(substr($profile['name'],strlen($firstname))));
298 'guid' => $profile['guid'],
299 'podloc' => $a->get_baseurl(),
300 'searchable' => (($profile['publish'] && $profile['net-publish']) ? 'true' : 'false' ),
301 'nickname' => $profile['nickname'],
302 'fullname' => $profile['name'],
303 'firstname' => $firstname,
304 'lastname' => $lastname,
305 'photo300' => $a->get_cached_avatar_image($a->get_baseurl() . '/photo/custom/300/' . $profile['uid'] . '.jpg'),
306 'photo100' => $a->get_cached_avatar_image($a->get_baseurl() . '/photo/custom/100/' . $profile['uid'] . '.jpg'),
307 'photo50' => $a->get_cached_avatar_image($a->get_baseurl() . '/photo/custom/50/' . $profile['uid'] . '.jpg'),
311 $contact_block = contact_block();
313 if(is_array($a->profile) AND !$a->profile['hide-friends']) {
314 $r = q("SELECT `gcontact`.`updated` FROM `contact` INNER JOIN `gcontact` WHERE `gcontact`.`nurl` = `contact`.`nurl` AND `self` AND `uid` = %d LIMIT 1",
315 intval($a->profile['uid']));
317 $updated = date("c", strtotime($r[0]['updated']));
319 $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0
320 AND `network` IN ('%s', '%s', '%s', '')",
321 intval($profile['uid']),
323 dbesc(NETWORK_DIASPORA),
324 dbesc(NETWORK_OSTATUS)
327 $contacts = intval($r[0]['total']);
332 foreach($profile as $k => $v) {
333 $k = str_replace('-','_',$k);
337 if($a->theme['template_engine'] === 'internal')
338 $location = template_escape($location);
340 $tpl = get_markup_template('profile_vcard.tpl');
341 $o .= replace_macros($tpl, array(
343 '$connect' => $connect,
344 '$remoteconnect' => $remoteconnect,
345 '$subscribe_feed' => $subscribe_feed,
346 '$wallmessage' => $wallmessage,
347 '$location' => $location,
348 '$gender' => $gender,
350 '$marital' => $marital,
351 '$homepage' => $homepage,
353 '$network' => t('Network:'),
354 '$contacts' => $contacts,
355 '$updated' => $updated,
356 '$diaspora' => $diaspora,
357 '$contact_block' => $contact_block,
361 $arr = array('profile' => &$profile, 'entry' => &$o);
363 call_hooks('profile_sidebar', $arr);
370 if(! function_exists('get_birthdays')) {
371 function get_birthdays() {
376 if(! local_user() || $a->is_mobile || $a->is_tablet)
379 // $mobile_detect = new Mobile_Detect();
380 // $is_mobile = $mobile_detect->isMobile() || $mobile_detect->isTablet();
385 $bd_format = t('g A l F d') ; // 8 AM Friday January 18
386 $bd_short = t('F d');
388 $r = q("SELECT `event`.*, `event`.`id` AS `eid`, `contact`.* FROM `event`
389 INNER JOIN `contact` ON `contact`.`id` = `event`.`cid`
390 WHERE `event`.`uid` = %d AND `type` = 'birthday' AND `start` < '%s' AND `finish` > '%s'
391 ORDER BY `start` ASC ",
392 intval(local_user()),
393 dbesc(datetime_convert('UTC','UTC','now + 6 days')),
394 dbesc(datetime_convert('UTC','UTC','now'))
397 if($r && count($r)) {
399 $now = strtotime('now');
404 if(strlen($rr['name']))
406 if((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now))
409 $classtoday = $istoday ? ' birthday-today ' : '';
411 foreach($r as &$rr) {
412 if(! strlen($rr['name']))
417 if(in_array($rr['cid'],$cids))
419 $cids[] = $rr['cid'];
421 $today = (((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now)) ? true : false);
424 if($rr['network'] === NETWORK_DFRN) {
425 $sparkle = " sparkle";
426 $url = $a->get_baseurl() . '/redir/' . $rr['cid'];
430 $rr['title'] = $rr['name'];
431 $rr['date'] = day_translate(datetime_convert('UTC', $a->timezone, $rr['start'], $rr['adjust'] ? $bd_format : $bd_short)) . (($today) ? ' ' . t('[today]') : '');
432 $rr['startime'] = Null;
433 $rr['today'] = $today;
438 $tpl = get_markup_template("birthdays_reminder.tpl");
439 return replace_macros($tpl, array(
440 '$baseurl' => $a->get_baseurl(),
441 '$classtoday' => $classtoday,
443 '$event_reminders' => t('Birthday Reminders'),
444 '$event_title' => t('Birthdays this week:'),
446 '$lbr' => '{', // raw brackets mess up if/endif macro processing
454 if(! function_exists('get_events')) {
455 function get_events() {
457 require_once('include/bbcode.php');
461 if(! local_user() || $a->is_mobile || $a->is_tablet)
465 // $mobile_detect = new Mobile_Detect();
466 // $is_mobile = $mobile_detect->isMobile() || $mobile_detect->isTablet();
471 $bd_format = t('g A l F d') ; // 8 AM Friday January 18
472 $bd_short = t('F d');
474 $r = q("SELECT `event`.* FROM `event`
475 WHERE `event`.`uid` = %d AND `type` != 'birthday' AND `start` < '%s' AND `start` >= '%s'
476 ORDER BY `start` ASC ",
477 intval(local_user()),
478 dbesc(datetime_convert('UTC','UTC','now + 7 days')),
479 dbesc(datetime_convert('UTC','UTC','now - 1 days'))
482 if($r && count($r)) {
483 $now = strtotime('now');
486 if(strlen($rr['name']))
489 $strt = datetime_convert('UTC',$rr['convert'] ? $a->timezone : 'UTC',$rr['start'],'Y-m-d');
490 if($strt === datetime_convert('UTC',$a->timezone,'now','Y-m-d'))
493 $classtoday = (($istoday) ? 'event-today' : '');
497 foreach($r as &$rr) {
498 $title = strip_tags(html_entity_decode(bbcode($rr['summary']),ENT_QUOTES,'UTF-8'));
500 if(strlen($title) > 35)
501 $title = substr($title,0,32) . '... ';
503 $description = substr(strip_tags(bbcode($rr['desc'])),0,32) . '... ';
505 $description = t('[No description]');
507 $strt = datetime_convert('UTC',$rr['convert'] ? $a->timezone : 'UTC',$rr['start']);
509 if(substr($strt,0,10) < datetime_convert('UTC',$a->timezone,'now','Y-m-d')) {
514 $today = ((substr($strt,0,10) === datetime_convert('UTC',$a->timezone,'now','Y-m-d')) ? true : false);
516 $rr['title'] = $title;
517 $rr['description'] = $desciption;
518 $rr['date'] = day_translate(datetime_convert('UTC', $rr['adjust'] ? $a->timezone : 'UTC', $rr['start'], $bd_format)) . (($today) ? ' ' . t('[today]') : '');
519 $rr['startime'] = $strt;
520 $rr['today'] = $today;
524 $tpl = get_markup_template("events_reminder.tpl");
525 return replace_macros($tpl, array(
526 '$baseurl' => $a->get_baseurl(),
527 '$classtoday' => $classtoday,
528 '$count' => count($r) - $skip,
529 '$event_reminders' => t('Event Reminders'),
530 '$event_title' => t('Events this week:'),
536 function advanced_profile(&$a) {
539 $uid = $a->profile['uid'];
541 $o .= replace_macros(get_markup_template('section_title.tpl'),array(
542 '$title' => t('Profile')
545 if($a->profile['name']) {
547 $tpl = get_markup_template('profile_advanced.tpl');
551 $profile['fullname'] = array( t('Full Name:'), $a->profile['name'] ) ;
553 if($a->profile['gender']) $profile['gender'] = array( t('Gender:'), $a->profile['gender'] );
556 if(($a->profile['dob']) && ($a->profile['dob'] != '0000-00-00')) {
558 $year_bd_format = t('j F, Y');
559 $short_bd_format = t('j F');
562 $val = ((intval($a->profile['dob']))
563 ? day_translate(datetime_convert('UTC','UTC',$a->profile['dob'] . ' 00:00 +00:00',$year_bd_format))
564 : day_translate(datetime_convert('UTC','UTC','2001-' . substr($a->profile['dob'],5) . ' 00:00 +00:00',$short_bd_format)));
566 $profile['birthday'] = array( t('Birthday:'), $val);
570 if($age = age($a->profile['dob'],$a->profile['timezone'],'')) $profile['age'] = array( t('Age:'), $age );
573 if($a->profile['marital']) $profile['marital'] = array( t('Status:'), $a->profile['marital']);
576 if($a->profile['with']) $profile['marital']['with'] = $a->profile['with'];
578 if(strlen($a->profile['howlong']) && $a->profile['howlong'] !== '0000-00-00 00:00:00') {
579 $profile['howlong'] = relative_date($a->profile['howlong'], t('for %1$d %2$s'));
582 if($a->profile['sexual']) $profile['sexual'] = array( t('Sexual Preference:'), $a->profile['sexual'] );
584 if($a->profile['homepage']) $profile['homepage'] = array( t('Homepage:'), linkify($a->profile['homepage']) );
586 if($a->profile['hometown']) $profile['hometown'] = array( t('Hometown:'), linkify($a->profile['hometown']) );
588 if($a->profile['pub_keywords']) $profile['pub_keywords'] = array( t('Tags:'), $a->profile['pub_keywords']);
590 if($a->profile['politic']) $profile['politic'] = array( t('Political Views:'), $a->profile['politic']);
592 if($a->profile['religion']) $profile['religion'] = array( t('Religion:'), $a->profile['religion']);
594 if($txt = prepare_text($a->profile['about'])) $profile['about'] = array( t('About:'), $txt );
596 if($txt = prepare_text($a->profile['interest'])) $profile['interest'] = array( t('Hobbies/Interests:'), $txt);
598 if($txt = prepare_text($a->profile['likes'])) $profile['likes'] = array( t('Likes:'), $txt);
600 if($txt = prepare_text($a->profile['dislikes'])) $profile['dislikes'] = array( t('Dislikes:'), $txt);
603 if($txt = prepare_text($a->profile['contact'])) $profile['contact'] = array( t('Contact information and Social Networks:'), $txt);
605 if($txt = prepare_text($a->profile['music'])) $profile['music'] = array( t('Musical interests:'), $txt);
607 if($txt = prepare_text($a->profile['book'])) $profile['book'] = array( t('Books, literature:'), $txt);
609 if($txt = prepare_text($a->profile['tv'])) $profile['tv'] = array( t('Television:'), $txt);
611 if($txt = prepare_text($a->profile['film'])) $profile['film'] = array( t('Film/dance/culture/entertainment:'), $txt);
613 if($txt = prepare_text($a->profile['romance'])) $profile['romance'] = array( t('Love/Romance:'), $txt);
615 if($txt = prepare_text($a->profile['work'])) $profile['work'] = array( t('Work/employment:'), $txt);
617 if($txt = prepare_text($a->profile['education'])) $profile['education'] = array( t('School/education:'), $txt );
619 //show subcribed forum if it is enabled in the usersettings
620 if (feature_enabled($uid,'forumlist_profile')) {
621 $profile['forumlist'] = array( t('Forums:'), forumlist_profile_advanced($uid));
624 if ($a->profile['uid'] == local_user())
625 $profile['edit'] = array($a->get_baseurl(). '/profiles/'.$a->profile['id'], t('Edit profile'),"", t('Edit profile'));
627 return replace_macros($tpl, array(
628 '$title' => t('Profile'),
629 '$profile' => $profile
636 if(! function_exists('profile_tabs')){
637 function profile_tabs($a, $is_owner=False, $nickname=Null){
638 //echo "<pre>"; var_dump($a->user); killme();
640 if (is_null($nickname))
641 $nickname = $a->user['nickname'];
644 $tab = notags(trim($_GET['tab']));
646 $url = $a->get_baseurl() . '/profile/' . $nickname;
650 'label'=>t('Status'),
652 'sel' => ((!isset($tab)&&$a->argv[0]=='profile')?'active':''),
653 'title' => t('Status Messages and Posts'),
654 'id' => 'status-tab',
658 'label' => t('Profile'),
659 'url' => $url.'/?tab=profile',
660 'sel' => ((isset($tab) && $tab=='profile')?'active':''),
661 'title' => t('Profile Details'),
662 'id' => 'profile-tab',
666 'label' => t('Photos'),
667 'url' => $a->get_baseurl() . '/photos/' . $nickname,
668 'sel' => ((!isset($tab)&&$a->argv[0]=='photos')?'active':''),
669 'title' => t('Photo Albums'),
674 'label' => t('Videos'),
675 'url' => $a->get_baseurl() . '/videos/' . $nickname,
676 'sel' => ((!isset($tab)&&$a->argv[0]=='videos')?'active':''),
677 'title' => t('Videos'),
684 if ($a->theme_events_in_profile)
686 'label' => t('Events'),
687 'url' => $a->get_baseurl() . '/events',
688 'sel' =>((!isset($tab)&&$a->argv[0]=='events')?'active':''),
689 'title' => t('Events and Calendar'),
690 'id' => 'events-tab',
694 'label' => t('Personal Notes'),
695 'url' => $a->get_baseurl() . '/notes',
696 'sel' =>((!isset($tab)&&$a->argv[0]=='notes')?'active':''),
697 'title' => t('Only You Can See This'),
703 if ((! $is_owner) && ((count($a->profile)) || (! $a->profile['hide-friends']))) {
705 'label' => t('Contacts'),
706 'url' => $a->get_baseurl() . '/viewcontacts/' . $nickname,
707 'sel' => ((!isset($tab)&&$a->argv[0]=='viewcontacts')?'active':''),
708 'title' => t('Contacts'),
709 'id' => 'viewcontacts-tab',
714 $arr = array('is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => (($tab) ? $tab : false), 'tabs' => $tabs);
715 call_hooks('profile_tabs', $arr);
717 $tpl = get_markup_template('common_tabs.tpl');
719 return replace_macros($tpl,array('$tabs' => $arr['tabs']));
723 function get_my_url() {
724 if(x($_SESSION,'my_url'))
725 return $_SESSION['my_url'];
729 function zrl_init(&$a) {
730 $tmp_str = get_my_url();
731 if(validate_url($tmp_str)) {
733 // Is it a DDoS attempt?
734 // The check fetches the cached value from gprobe to reduce the load for this system
735 $urlparts = parse_url($tmp_str);
737 $result = Cache::get("gprobe:".$urlparts["host"]);
738 if (!is_null($result)) {
739 $result = unserialize($result);
740 if (in_array($result["network"], array(NETWORK_FEED, NETWORK_PHANTOM))) {
741 logger("DDoS attempt detected for ".$urlparts["host"]." by ".$_SERVER["REMOTE_ADDR"].". server data: ".print_r($_SERVER, true), LOGGER_DEBUG);
746 proc_run('php','include/gprobe.php',bin2hex($tmp_str));
747 $arr = array('zrl' => $tmp_str, 'url' => $a->cmd);
748 call_hooks('zrl_init',$arr);
752 function zrl($s,$force = false) {
755 if((! strpos($s,'/profile/')) && (! $force))
757 if($force && substr($s,-1,1) !== '/')
759 $achar = strpos($s,'?') ? '&' : '?';
760 $mine = get_my_url();
761 if($mine and ! link_compare($mine,$s))
762 return $s . $achar . 'zrl=' . urlencode($mine);
766 // Used from within PCSS themes to set theme parameters. If there's a
767 // puid request variable, that is the "page owner" and normally their theme
768 // settings take precedence; unless a local user sets the "always_my_theme"
769 // system pconfig, which means they don't want to see anybody else's theme
770 // settings except their own while on this site.
772 function get_theme_uid() {
773 $uid = (($_REQUEST['puid']) ? intval($_REQUEST['puid']) : 0);
775 if((get_pconfig(local_user(),'system','always_my_theme')) || (! $uid))