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 $pdata = get_profiledata_by_nick($nickname, $user[0]['uid'], $profile);
50 if(($pdata === false) || (!count($pdata)) && !count($profiledata)) {
51 logger('profile error: ' . $a->query_string, LOGGER_DEBUG);
52 notice( t('Requested profile is not available.') . EOL );
57 // fetch user tags if this isn't the default profile
59 if(!$pdata['is-default']) {
60 $x = q("SELECT `pub_keywords` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1",
61 intval($pdata['profile_uid'])
64 $pdata['pub_keywords'] = $x[0]['pub_keywords'];
68 $a->profile_uid = $pdata['profile_uid'];
70 $a->profile['mobile-theme'] = get_pconfig($a->profile['profile_uid'], 'system', 'mobile_theme');
71 $a->profile['network'] = NETWORK_DFRN;
73 $a->page['title'] = $a->profile['name'] . " @ " . $a->config['sitename'];
76 // $_SESSION['theme'] = $a->profile['theme'];
78 $_SESSION['mobile-theme'] = $a->profile['mobile-theme'];
81 * load/reload current theme info
84 $a->set_template_engine(); // reset the template engine to the default in case the user's theme doesn't specify one
86 $theme_info_file = "view/theme/".current_theme()."/theme.php";
87 if (file_exists($theme_info_file)){
88 require_once($theme_info_file);
91 if(! (x($a->page,'aside')))
92 $a->page['aside'] = '';
94 if(local_user() && local_user() == $a->profile['uid'] && $profiledata) {
95 $a->page['aside'] .= replace_macros(get_markup_template('profile_edlink.tpl'),array(
96 '$editprofile' => t('Edit profile'),
97 '$profid' => $a->profile['id']
101 $block = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false);
104 // By now, the contact block isn't shown, when a different profile is given
105 // But: When this profile was on the same server, then we could display the contacts
107 $a->page['aside'] .= profile_sidebar($profiledata, true);
109 $a->page['aside'] .= profile_sidebar($a->profile, $block);
113 $a->page['aside'] .= contact_block();*/
121 * @brief Get all profil data of a local user
122 * If the viewer is an authenticated remote viewer, the profile displayed is the
123 * one that has been configured for his/her viewing in the Contact manager.
124 * Passing a non-zero profile ID can also allow a preview of a selected profile
127 * @param string $nickname
129 * @param int $profile
132 * Includes all available profile data
134 function get_profiledata_by_nick($nickname, $uid = 0, $profile = 0) {
135 if(remote_user() && count($_SESSION['remote'])) {
136 foreach($_SESSION['remote'] as $visitor) {
137 if($visitor['uid'] == $uid) {
138 $r = q("SELECT `profile-id` FROM `contact` WHERE `id` = %d LIMIT 1",
139 intval($visitor['cid'])
142 $profile = $r[0]['profile-id'];
151 $profile_int = intval($profile);
152 $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `contact`.`addr`, `user`.* FROM `profile`
153 INNER JOIN `contact` on `contact`.`uid` = `profile`.`uid` INNER JOIN `user` ON `profile`.`uid` = `user`.`uid`
154 WHERE `user`.`nickname` = '%s' AND `profile`.`id` = %d AND `contact`.`self` = 1 LIMIT 1",
159 if((!$r) && (!count($r))) {
160 $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `contact`.`addr`, `user`.* FROM `profile`
161 INNER JOIN `contact` ON `contact`.`uid` = `profile`.`uid` INNER JOIN `user` ON `profile`.`uid` = `user`.`uid`
162 WHERE `user`.`nickname` = '%s' AND `profile`.`is-default` = 1 AND `contact`.`self` = 1 LIMIT 1",
174 * Function: profile_sidebar
176 * Formats a profile for display in the sidebar.
177 * It is very difficult to templatise the HTML completely
178 * because of all the conditional logic.
180 * @parameter: array $profile
182 * Returns HTML string stuitable for sidebar inclusion
183 * Exceptions: Returns empty string if passed $profile is wrong type or not populated
186 if(! function_exists('profile_sidebar')) {
187 function profile_sidebar($profile, $block = 0) {
195 if((! is_array($profile)) && (! count($profile)))
198 $profile['picdate'] = urlencode($profile['picdate']);
200 if (($profile['network'] != "") AND ($profile['network'] != NETWORK_DFRN)) {
201 $profile['network_name'] = format_network_name($profile['network'],$profile['url']);
203 $profile['network_name'] = "";
205 call_hooks('profile_sidebar_enter', $profile);
208 // don't show connect link to yourself
209 $connect = (($profile['uid'] != local_user()) ? t('Connect') : False);
211 // don't show connect link to authenticated visitors either
212 if(remote_user() && count($_SESSION['remote'])) {
213 foreach($_SESSION['remote'] as $visitor) {
214 if($visitor['uid'] == $profile['uid']) {
221 // Is the local user already connected to that user?
222 if ($connect AND local_user()) {
223 if (isset($profile["url"]))
224 $profile_url = normalise_link($profile["url"]);
226 $profile_url = normalise_link($a->get_baseurl()."/profile/".$profile["nickname"]);
228 $r = q("SELECT * FROM `contact` WHERE NOT `pending` AND `uid` = %d AND `nurl` = '%s'",
229 local_user(), $profile_url);
234 if ($connect AND ($profile['network'] != NETWORK_DFRN) AND !isset($profile['remoteconnect']))
237 if (isset($profile['remoteconnect']))
238 $remoteconnect = $profile['remoteconnect'];
240 if ($connect AND ($profile['network'] == NETWORK_DFRN) AND !isset($remoteconnect))
241 $subscribe_feed = t("Atom feed");
243 $subscribe_feed = false;
245 if(get_my_url() && $profile['unkmail'] && ($profile['uid'] != local_user()))
246 $wallmessage = t('Message');
248 $wallmessage = false;
250 // show edit profile to yourself
251 if ($profile['uid'] == local_user() && feature_enabled(local_user(),'multi_profiles')) {
252 $profile['edit'] = array($a->get_baseurl(). '/profiles', t('Profiles'),"", t('Manage/edit profiles'));
253 $r = q("SELECT * FROM `profile` WHERE `uid` = %d",
256 $profile['menu'] = array(
257 'chg_photo' => t('Change profile photo'),
258 'cr_new' => t('Create New Profile'),
259 'entries' => array(),
265 $profile['menu']['entries'][] = array(
266 'photo' => $rr['thumb'],
268 'alt' => t('Profile Image'),
269 'profile_name' => $rr['profile-name'],
270 'isdefault' => $rr['is-default'],
271 'visibile_to_everybody' => t('visible to everybody'),
272 'edit_visibility' => t('Edit visibility'),
280 if ($profile['uid'] == local_user() && !feature_enabled(local_user(),'multi_profiles')) {
281 $profile['edit'] = array($a->get_baseurl(). '/profiles/'.$profile['id'], t('Edit profile'),"", t('Edit profile'));
282 $profile['menu'] = array(
283 'chg_photo' => t('Change profile photo'),
285 'entries' => array(),
289 // check if profile is a forum
290 if((x($profile['page-flags']) == 2)
291 || (x($profile['page-flags']) == 5)
292 || (x($profile['forum']))
293 || (x($profile['prv']))
294 || (x($profile['community'])))
295 $account_type = t('Forum');
299 if((x($profile,'address') == 1)
300 || (x($profile,'locality') == 1)
301 || (x($profile,'region') == 1)
302 || (x($profile,'postal-code') == 1)
303 || (x($profile,'country-name') == 1))
304 $location = t('Location:');
306 $gender = ((x($profile,'gender') == 1) ? t('Gender:') : False);
309 $marital = ((x($profile,'marital') == 1) ? t('Status:') : False);
311 $homepage = ((x($profile,'homepage') == 1) ? t('Homepage:') : False);
313 $about = ((x($profile,'about') == 1) ? t('About:') : False);
315 if(($profile['hidewall'] || $block) && (! local_user()) && (! remote_user())) {
316 $location = $pdesc = $gender = $marital = $homepage = $about = False;
319 $firstname = ((strpos($profile['name'],' '))
320 ? trim(substr($profile['name'],0,strpos($profile['name'],' '))) : $profile['name']);
321 $lastname = (($firstname === $profile['name']) ? '' : trim(substr($profile['name'],strlen($firstname))));
324 'guid' => $profile['guid'],
325 'podloc' => $a->get_baseurl(),
326 'searchable' => (($profile['publish'] && $profile['net-publish']) ? 'true' : 'false' ),
327 'nickname' => $profile['nickname'],
328 'fullname' => $profile['name'],
329 'firstname' => $firstname,
330 'lastname' => $lastname,
331 'photo300' => $a->get_cached_avatar_image($a->get_baseurl() . '/photo/custom/300/' . $profile['uid'] . '.jpg'),
332 'photo100' => $a->get_cached_avatar_image($a->get_baseurl() . '/photo/custom/100/' . $profile['uid'] . '.jpg'),
333 'photo50' => $a->get_cached_avatar_image($a->get_baseurl() . '/photo/custom/50/' . $profile['uid'] . '.jpg'),
337 $contact_block = contact_block();
339 if(is_array($a->profile) AND !$a->profile['hide-friends']) {
340 $r = q("SELECT `gcontact`.`updated` FROM `contact` INNER JOIN `gcontact` WHERE `gcontact`.`nurl` = `contact`.`nurl` AND `self` AND `uid` = %d LIMIT 1",
341 intval($a->profile['uid']));
343 $updated = date("c", strtotime($r[0]['updated']));
345 $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
346 AND `network` IN ('%s', '%s', '%s', '')",
347 intval($profile['uid']),
349 dbesc(NETWORK_DIASPORA),
350 dbesc(NETWORK_OSTATUS)
353 $contacts = intval($r[0]['total']);
358 foreach($profile as $k => $v) {
359 $k = str_replace('-','_',$k);
363 if($a->theme['template_engine'] === 'internal')
364 $location = template_escape($location);
366 $tpl = get_markup_template('profile_vcard.tpl');
367 $o .= replace_macros($tpl, array(
369 '$connect' => $connect,
370 '$remoteconnect' => $remoteconnect,
371 '$subscribe_feed' => $subscribe_feed,
372 '$wallmessage' => $wallmessage,
373 '$account_type' => $account_type,
374 '$location' => $location,
375 '$gender' => $gender,
376 // '$pdesc' => $pdesc,
377 '$marital' => $marital,
378 '$homepage' => $homepage,
380 '$network' => t('Network:'),
381 '$contacts' => $contacts,
382 '$updated' => $updated,
383 '$diaspora' => $diaspora,
384 '$contact_block' => $contact_block,
388 $arr = array('profile' => &$profile, 'entry' => &$o);
390 call_hooks('profile_sidebar', $arr);
397 if(! function_exists('get_birthdays')) {
398 function get_birthdays() {
403 if(! local_user() || $a->is_mobile || $a->is_tablet)
406 // $mobile_detect = new Mobile_Detect();
407 // $is_mobile = $mobile_detect->isMobile() || $mobile_detect->isTablet();
412 $bd_format = t('g A l F d') ; // 8 AM Friday January 18
413 $bd_short = t('F d');
415 $r = q("SELECT `event`.*, `event`.`id` AS `eid`, `contact`.* FROM `event`
416 INNER JOIN `contact` ON `contact`.`id` = `event`.`cid`
417 WHERE `event`.`uid` = %d AND `type` = 'birthday' AND `start` < '%s' AND `finish` > '%s'
418 ORDER BY `start` ASC ",
419 intval(local_user()),
420 dbesc(datetime_convert('UTC','UTC','now + 6 days')),
421 dbesc(datetime_convert('UTC','UTC','now'))
424 if($r && count($r)) {
426 $now = strtotime('now');
431 if(strlen($rr['name']))
433 if((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now))
436 $classtoday = $istoday ? ' birthday-today ' : '';
438 foreach($r as &$rr) {
439 if(! strlen($rr['name']))
444 if(in_array($rr['cid'],$cids))
446 $cids[] = $rr['cid'];
448 $today = (((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now)) ? true : false);
451 if($rr['network'] === NETWORK_DFRN) {
452 $sparkle = " sparkle";
453 $url = $a->get_baseurl() . '/redir/' . $rr['cid'];
457 $rr['title'] = $rr['name'];
458 $rr['date'] = day_translate(datetime_convert('UTC', $a->timezone, $rr['start'], $rr['adjust'] ? $bd_format : $bd_short)) . (($today) ? ' ' . t('[today]') : '');
459 $rr['startime'] = Null;
460 $rr['today'] = $today;
465 $tpl = get_markup_template("birthdays_reminder.tpl");
466 return replace_macros($tpl, array(
467 '$baseurl' => $a->get_baseurl(),
468 '$classtoday' => $classtoday,
470 '$event_reminders' => t('Birthday Reminders'),
471 '$event_title' => t('Birthdays this week:'),
473 '$lbr' => '{', // raw brackets mess up if/endif macro processing
481 if(! function_exists('get_events')) {
482 function get_events() {
484 require_once('include/bbcode.php');
488 if(! local_user() || $a->is_mobile || $a->is_tablet)
492 // $mobile_detect = new Mobile_Detect();
493 // $is_mobile = $mobile_detect->isMobile() || $mobile_detect->isTablet();
498 $bd_format = t('g A l F d') ; // 8 AM Friday January 18
499 $bd_short = t('F d');
501 $r = q("SELECT `event`.* FROM `event`
502 WHERE `event`.`uid` = %d AND `type` != 'birthday' AND `start` < '%s' AND `start` >= '%s'
503 ORDER BY `start` ASC ",
504 intval(local_user()),
505 dbesc(datetime_convert('UTC','UTC','now + 7 days')),
506 dbesc(datetime_convert('UTC','UTC','now - 1 days'))
509 if($r && count($r)) {
510 $now = strtotime('now');
513 if(strlen($rr['name']))
516 $strt = datetime_convert('UTC',$rr['convert'] ? $a->timezone : 'UTC',$rr['start'],'Y-m-d');
517 if($strt === datetime_convert('UTC',$a->timezone,'now','Y-m-d'))
520 $classtoday = (($istoday) ? 'event-today' : '');
524 foreach($r as &$rr) {
525 $title = strip_tags(html_entity_decode(bbcode($rr['summary']),ENT_QUOTES,'UTF-8'));
527 if(strlen($title) > 35)
528 $title = substr($title,0,32) . '... ';
530 $description = substr(strip_tags(bbcode($rr['desc'])),0,32) . '... ';
532 $description = t('[No description]');
534 $strt = datetime_convert('UTC',$rr['convert'] ? $a->timezone : 'UTC',$rr['start']);
536 if(substr($strt,0,10) < datetime_convert('UTC',$a->timezone,'now','Y-m-d')) {
541 $today = ((substr($strt,0,10) === datetime_convert('UTC',$a->timezone,'now','Y-m-d')) ? true : false);
543 $rr['title'] = $title;
544 $rr['description'] = $desciption;
545 $rr['date'] = day_translate(datetime_convert('UTC', $rr['adjust'] ? $a->timezone : 'UTC', $rr['start'], $bd_format)) . (($today) ? ' ' . t('[today]') : '');
546 $rr['startime'] = $strt;
547 $rr['today'] = $today;
551 $tpl = get_markup_template("events_reminder.tpl");
552 return replace_macros($tpl, array(
553 '$baseurl' => $a->get_baseurl(),
554 '$classtoday' => $classtoday,
555 '$count' => count($r) - $skip,
556 '$event_reminders' => t('Event Reminders'),
557 '$event_title' => t('Events this week:'),
563 function advanced_profile(&$a) {
566 $uid = $a->profile['uid'];
568 $o .= replace_macros(get_markup_template('section_title.tpl'),array(
569 '$title' => t('Profile')
572 if($a->profile['name']) {
574 $tpl = get_markup_template('profile_advanced.tpl');
578 $profile['fullname'] = array( t('Full Name:'), $a->profile['name'] ) ;
580 if($a->profile['gender']) $profile['gender'] = array( t('Gender:'), $a->profile['gender'] );
583 if(($a->profile['dob']) && ($a->profile['dob'] != '0000-00-00')) {
585 $year_bd_format = t('j F, Y');
586 $short_bd_format = t('j F');
589 $val = ((intval($a->profile['dob']))
590 ? day_translate(datetime_convert('UTC','UTC',$a->profile['dob'] . ' 00:00 +00:00',$year_bd_format))
591 : day_translate(datetime_convert('UTC','UTC','2001-' . substr($a->profile['dob'],5) . ' 00:00 +00:00',$short_bd_format)));
593 $profile['birthday'] = array( t('Birthday:'), $val);
597 if($age = age($a->profile['dob'],$a->profile['timezone'],'')) $profile['age'] = array( t('Age:'), $age );
600 if($a->profile['marital']) $profile['marital'] = array( t('Status:'), $a->profile['marital']);
603 if($a->profile['with']) $profile['marital']['with'] = $a->profile['with'];
605 if(strlen($a->profile['howlong']) && $a->profile['howlong'] !== '0000-00-00 00:00:00') {
606 $profile['howlong'] = relative_date($a->profile['howlong'], t('for %1$d %2$s'));
609 if($a->profile['sexual']) $profile['sexual'] = array( t('Sexual Preference:'), $a->profile['sexual'] );
611 if($a->profile['homepage']) $profile['homepage'] = array( t('Homepage:'), linkify($a->profile['homepage']) );
613 if($a->profile['hometown']) $profile['hometown'] = array( t('Hometown:'), linkify($a->profile['hometown']) );
615 if($a->profile['pub_keywords']) $profile['pub_keywords'] = array( t('Tags:'), $a->profile['pub_keywords']);
617 if($a->profile['politic']) $profile['politic'] = array( t('Political Views:'), $a->profile['politic']);
619 if($a->profile['religion']) $profile['religion'] = array( t('Religion:'), $a->profile['religion']);
621 if($txt = prepare_text($a->profile['about'])) $profile['about'] = array( t('About:'), $txt );
623 if($txt = prepare_text($a->profile['interest'])) $profile['interest'] = array( t('Hobbies/Interests:'), $txt);
625 if($txt = prepare_text($a->profile['likes'])) $profile['likes'] = array( t('Likes:'), $txt);
627 if($txt = prepare_text($a->profile['dislikes'])) $profile['dislikes'] = array( t('Dislikes:'), $txt);
630 if($txt = prepare_text($a->profile['contact'])) $profile['contact'] = array( t('Contact information and Social Networks:'), $txt);
632 if($txt = prepare_text($a->profile['music'])) $profile['music'] = array( t('Musical interests:'), $txt);
634 if($txt = prepare_text($a->profile['book'])) $profile['book'] = array( t('Books, literature:'), $txt);
636 if($txt = prepare_text($a->profile['tv'])) $profile['tv'] = array( t('Television:'), $txt);
638 if($txt = prepare_text($a->profile['film'])) $profile['film'] = array( t('Film/dance/culture/entertainment:'), $txt);
640 if($txt = prepare_text($a->profile['romance'])) $profile['romance'] = array( t('Love/Romance:'), $txt);
642 if($txt = prepare_text($a->profile['work'])) $profile['work'] = array( t('Work/employment:'), $txt);
644 if($txt = prepare_text($a->profile['education'])) $profile['education'] = array( t('School/education:'), $txt );
646 //show subcribed forum if it is enabled in the usersettings
647 if (feature_enabled($uid,'forumlist_profile')) {
648 $profile['forumlist'] = array( t('Forums:'), forumlist_profile_advanced($uid));
651 if ($a->profile['uid'] == local_user())
652 $profile['edit'] = array($a->get_baseurl(). '/profiles/'.$a->profile['id'], t('Edit profile'),"", t('Edit profile'));
654 return replace_macros($tpl, array(
655 '$title' => t('Profile'),
656 '$profile' => $profile
663 if(! function_exists('profile_tabs')){
664 function profile_tabs($a, $is_owner=False, $nickname=Null){
665 //echo "<pre>"; var_dump($a->user); killme();
667 if (is_null($nickname))
668 $nickname = $a->user['nickname'];
671 $tab = notags(trim($_GET['tab']));
673 $url = $a->get_baseurl() . '/profile/' . $nickname;
677 'label'=>t('Status'),
679 'sel' => ((!isset($tab)&&$a->argv[0]=='profile')?'active':''),
680 'title' => t('Status Messages and Posts'),
681 'id' => 'status-tab',
685 'label' => t('Profile'),
686 'url' => $url.'/?tab=profile',
687 'sel' => ((isset($tab) && $tab=='profile')?'active':''),
688 'title' => t('Profile Details'),
689 'id' => 'profile-tab',
693 'label' => t('Photos'),
694 'url' => $a->get_baseurl() . '/photos/' . $nickname,
695 'sel' => ((!isset($tab)&&$a->argv[0]=='photos')?'active':''),
696 'title' => t('Photo Albums'),
701 'label' => t('Videos'),
702 'url' => $a->get_baseurl() . '/videos/' . $nickname,
703 'sel' => ((!isset($tab)&&$a->argv[0]=='videos')?'active':''),
704 'title' => t('Videos'),
711 if ($a->theme_events_in_profile)
713 'label' => t('Events'),
714 'url' => $a->get_baseurl() . '/events',
715 'sel' =>((!isset($tab)&&$a->argv[0]=='events')?'active':''),
716 'title' => t('Events and Calendar'),
717 'id' => 'events-tab',
721 'label' => t('Personal Notes'),
722 'url' => $a->get_baseurl() . '/notes',
723 'sel' =>((!isset($tab)&&$a->argv[0]=='notes')?'active':''),
724 'title' => t('Only You Can See This'),
730 if ((! $is_owner) && ((count($a->profile)) || (! $a->profile['hide-friends']))) {
732 'label' => t('Contacts'),
733 'url' => $a->get_baseurl() . '/viewcontacts/' . $nickname,
734 'sel' => ((!isset($tab)&&$a->argv[0]=='viewcontacts')?'active':''),
735 'title' => t('Contacts'),
736 'id' => 'viewcontacts-tab',
741 $arr = array('is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => (($tab) ? $tab : false), 'tabs' => $tabs);
742 call_hooks('profile_tabs', $arr);
744 $tpl = get_markup_template('common_tabs.tpl');
746 return replace_macros($tpl,array('$tabs' => $arr['tabs']));
750 function get_my_url() {
751 if(x($_SESSION,'my_url'))
752 return $_SESSION['my_url'];
756 function zrl_init(&$a) {
757 $tmp_str = get_my_url();
758 if(validate_url($tmp_str)) {
760 // Is it a DDoS attempt?
761 // The check fetches the cached value from gprobe to reduce the load for this system
762 $urlparts = parse_url($tmp_str);
764 $result = Cache::get("gprobe:".$urlparts["host"]);
765 if (!is_null($result)) {
766 $result = unserialize($result);
767 if (in_array($result["network"], array(NETWORK_FEED, NETWORK_PHANTOM))) {
768 logger("DDoS attempt detected for ".$urlparts["host"]." by ".$_SERVER["REMOTE_ADDR"].". server data: ".print_r($_SERVER, true), LOGGER_DEBUG);
773 proc_run('php','include/gprobe.php',bin2hex($tmp_str));
774 $arr = array('zrl' => $tmp_str, 'url' => $a->cmd);
775 call_hooks('zrl_init',$arr);
779 function zrl($s,$force = false) {
782 if((! strpos($s,'/profile/')) && (! $force))
784 if($force && substr($s,-1,1) !== '/')
786 $achar = strpos($s,'?') ? '&' : '?';
787 $mine = get_my_url();
788 if($mine and ! link_compare($mine,$s))
789 return $s . $achar . 'zrl=' . urlencode($mine);
793 // Used from within PCSS themes to set theme parameters. If there's a
794 // puid request variable, that is the "page owner" and normally their theme
795 // settings take precedence; unless a local user sets the "always_my_theme"
796 // system pconfig, which means they don't want to see anybody else's theme
797 // settings except their own while on this site.
799 function get_theme_uid() {
800 $uid = (($_REQUEST['puid']) ? intval($_REQUEST['puid']) : 0);
802 if((get_pconfig(local_user(),'system','always_my_theme')) || (! $uid))