]> git.mxchange.org Git - friendica.git/blobdiff - boot.php
works on login form
[friendica.git] / boot.php
index f7c9d39d2340b71c6218b79df372618c8f76a0fc..e7cd065044590037799033360844b844822b6a52 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -5,11 +5,12 @@ require_once('include/network.php');
 require_once('include/plugin.php');
 require_once('include/text.php');
 require_once("include/pgettext.php");
+require_once('include/nav.php');
 
-
-define ( 'FRIENDIKA_VERSION',      '2.3.1109' );
+define ( 'FRIENDIKA_PLATFORM',     'Free Friendika');
+define ( 'FRIENDIKA_VERSION',      '2.3.1134' );
 define ( 'DFRN_PROTOCOL_VERSION',  '2.21'    );
-define ( 'DB_UPDATE_VERSION',      1090      );
+define ( 'DB_UPDATE_VERSION',      1097      );
 
 define ( 'EOL',                    "<br />\r\n"     );
 define ( 'ATOM_TIME',              'Y-m-d\TH:i:s\Z' );
@@ -151,6 +152,8 @@ define ( 'ACTIVITY_DISLIKE',     NAMESPACE_DFRN            . '/dislike' );
 define ( 'ACTIVITY_OBJ_HEART',   NAMESPACE_DFRN            . '/heart' );
 
 define ( 'ACTIVITY_FRIEND',      NAMESPACE_ACTIVITY_SCHEMA . 'make-friend' );
+define ( 'ACTIVITY_REQ_FRIEND',  NAMESPACE_ACTIVITY_SCHEMA . 'request-friend' );
+define ( 'ACTIVITY_UNFRIEND',    NAMESPACE_ACTIVITY_SCHEMA . 'remove-friend' );
 define ( 'ACTIVITY_FOLLOW',      NAMESPACE_ACTIVITY_SCHEMA . 'follow' );
 define ( 'ACTIVITY_UNFOLLOW',    NAMESPACE_ACTIVITY_SCHEMA . 'stop-following' );
 define ( 'ACTIVITY_POST',        NAMESPACE_ACTIVITY_SCHEMA . 'post' );
@@ -185,7 +188,9 @@ define ( 'GRAVITY_COMMENT',      6);
 function startup() {
        error_reporting(E_ERROR | E_WARNING | E_PARSE);
        set_time_limit(0);
-       ini_set('pcre.backtrack_limit', 250000);
+
+       // This has to be quite large to deal with embedded private photos
+       ini_set('pcre.backtrack_limit', 350000);
 
 
        if (get_magic_quotes_gpc()) {
@@ -246,7 +251,7 @@ class App {
        public  $timezone;
        public  $interactive = true;
        public  $plugins;
-       public  $apps;
+       public  $apps = Array();
        public  $identities;
 
        private $scheme;
@@ -631,29 +636,16 @@ function get_guid($size=16) {
 if(! function_exists('login')) {
 function login($register = false) {
        $o = "";
-       $register_tpl = (($register) ? get_markup_template("register-link.tpl") : "");
-       
-       $register_html = replace_macros($register_tpl,array(
-               '$title' => t('Create a New Account'),
-               '$desc' => t('Register')
-       ));
-
-       $noid = get_config('system','no_openid');
-       if($noid) {
-               $classname = 'no-openid';
-               $namelabel = t('Nickname or Email address: ');
-               $passlabel = t('Password: ');
-               $login     = t('Login');
-       }
-       else {
-               $classname = 'openid';
-               $namelabel = t('Nickname/Email/OpenID: ');
-               $passlabel = t("Password \x28if not OpenID\x29: ");
-               $login     = t('Login');
+       $reg = false;
+       if ($register) {
+               $reg = array(
+                       'title' => t('Create a New Account'),
+                       'desc' => t('Register')
+               );
        }
-       $lostpass = t('Forgot your password?');
-       $lostlink = t('Password Reset');
 
+       $noid = get_config('system','no_openid');
+       
        if(local_user()) {
                $tpl = get_markup_template("logout.tpl");
        }
@@ -662,17 +654,22 @@ function login($register = false) {
 
        }
 
-       $o = '<script type="text/javascript"> $(document).ready(function() { $("#login-name").focus();} );</script>';   
 
        $o .= replace_macros($tpl,array(
                '$logout'        => t('Logout'),
-               '$register_html' => $register_html, 
-               '$classname'     => $classname,
-               '$namelabel'     => $namelabel,
-               '$passlabel'     => $passlabel,
-               '$login'         => $login,
-               '$lostpass'      => $lostpass,
-               '$lostlink'      => $lostlink 
+               '$login'                 => t('Login'),
+               
+               '$lname'                => array('username', t('Nickname or Email address: ') , '', ''),
+               '$lpassword'    => array('password', t('Password: '), '', ''),
+               
+               '$openid'               => !$noid,
+               '$lopenid'      => array('openid_url', t('OpenID: '),'',''),
+               
+               
+               '$register'             => $reg,
+               
+               '$lostpass'      => t('Forgot your password?'),
+               '$lostlink'      => t('Password Reset'),
        ));
 
        call_hooks('login_hook',$o);
@@ -721,14 +718,16 @@ function remote_user() {
 if(! function_exists('notice')) {
 function notice($s) {
        $a = get_app();
+       if(! x($_SESSION,'sysmsg'))     $_SESSION['sysmsg'] = array();
        if($a->interactive)
-               $_SESSION['sysmsg'] .= $s;
+               $_SESSION['sysmsg'][] = $s;
 }}
 if(! function_exists('info')) {
 function info($s) {
        $a = get_app();
+       if(! x($_SESSION,'sysmsg_info')) $_SESSION['sysmsg_info'] = array();
        if($a->interactive)
-               $_SESSION['sysmsg_info'] .= $s;
+               $_SESSION['sysmsg_info'][] = $s;
 }}
 
 
@@ -810,8 +809,8 @@ function profile_load(&$a, $nickname, $profile = 0) {
 
        $a->page['aside'] .= profile_sidebar($a->profile, $block);
 
-       if(! $block)
-               $a->page['aside'] .= contact_block();
+       /*if(! $block)
+               $a->page['aside'] .= contact_block();*/
 
        return;
 }}
@@ -839,132 +838,113 @@ function profile_sidebar($profile, $block = 0) {
        $a = get_app();
 
        $o = '';
-       $location = '';
+       $location = false;
        $address = false;
+       $pdesc = true;
 
        if((! is_array($profile)) && (! count($profile)))
                return $o;
 
        call_hooks('profile_sidebar_enter', $profile);
 
-       $fullname = '<div class="fn">' . $profile['name'] . '</div>';
+       
+       // don't show connect link to yourself
+       $connect = (($profile['uid'] != local_user()) ? t('Connect')  : False);
 
-       $pdesc = '<div class="title">' . $profile['pdesc'] . '</div>';
+       // don't show connect link to authenticated visitors either
 
-       $tabs = '';
+       if((remote_user()) && ($_SESSION['visitor_visiting'] == $profile['uid']))
+               $connect = False; 
+
+
+       // show edit profile to yourself
+       if ($profile['uid'] == local_user()) {
+               $profile['edit'] = array($a->get_baseurl(). '/profiles', t('Profiles'),"", t('Manage/edit profiles'));
+               
+               $r = q("SELECT * FROM `profile` WHERE `uid` = %d",
+                               local_user());
+               
+               $profile['menu'] = array(
+                       'chg_photo' => t('Change profile photo'),
+                       'cr_new' => t('Create New Profile'),
+                       'entries' => array(),
+               );
+                               
+               if(count($r)) {
 
-       $photo = '<div id="profile-photo-wrapper"><img class="photo" width="175" height="175" src="' . $profile['photo'] . '" alt="' . $profile['name'] . '" /></div>';
+                       foreach($r as $rr) {
+                               $profile['menu']['entries'][] = array(
+                                       'photo' => $rr['thumb'],
+                                       'id' => $rr['id'],
+                                       'alt' => t('Profile Image'),
+                                       'profile_name' => $rr['profile-name'],
+                                       'isdefault' => $rr['is-default'],
+                                       'visibile_to_everybody' =>  t('visible to everybody'),
+                                       'edit_visibility' => t('Edit visibility'),
+                                       
+                               );
+                       }
 
-       // don't show connect link to yourself
-       $connect = (($profile['uid'] != local_user()) ? '<li><a id="dfrn-request-link" href="dfrn_request/' . $profile['nickname'] . '">' . t('Connect') . '</a></li>' : '');
 
-       // don't show connect link to authenticated visitors either
+               }
+               
+               
+       }
 
-       if((remote_user()) && ($_SESSION['visitor_visiting'] == $profile['uid']))
-               $connect = ''; 
 
+
+       
        if((x($profile,'address') == 1) 
                || (x($profile,'locality') == 1) 
                || (x($profile,'region') == 1) 
                || (x($profile,'postal-code') == 1) 
                || (x($profile,'country-name') == 1))
-               $address = true;
-
-       if($address) {
-               $location .= '<div class="location"><span class="location-label">' . t('Location:') . '</span> <div class="adr">';
-               $location .= ((x($profile,'address') == 1) ? '<div class="street-address">' . $profile['address'] . '</div>' : '');
-               $location .= (((x($profile,'locality') == 1) || (x($profile,'region') == 1) || (x($profile,'postal-code') == 1)) 
-                       ? '<span class="city-state-zip"><span class="locality">' . $profile['locality'] . '</span>' 
-                       . ((x($profile['locality']) == 1) ? t(', ') : '') 
-                       . '<span class="region">' . $profile['region'] . '</span>'
-                       . ' <span class="postal-code">' . $profile['postal-code'] . '</span></span>' : '');
-               $location .= ((x($profile,'country-name') == 1) ? ' <span class="country-name">' . $profile['country-name'] . '</span>' : '');  
-               $location .= '</div></div><div class="profile-clear"></div>';
+               $location = t('Location:');
 
-       }
+       $gender = ((x($profile,'gender') == 1) ? t('Gender:') : False);
 
 
-       $gender = ((x($profile,'gender') == 1) ? '<div class="mf"><span class="gender-label">' . t('Gender:') . '</span> <span class="x-gender">' . $profile['gender'] . '</span></div><div class="profile-clear"></div>' : '');
+       $marital = ((x($profile,'marital') == 1) ?  t('Status:') : False);
 
-       $pubkey = ((x($profile,'pubkey') == 1) ? '<div class="key" style="display:none;">' . $profile['pubkey'] . '</div>' : '');
+       $homepage = ((x($profile,'homepage') == 1) ?  t('Homepage:') : False);
 
-       $marital = ((x($profile,'marital') == 1) ? '<div class="marital"><span class="marital-label"><span class="heart">&hearts;</span> ' . t('Status:') . ' </span><span class="marital-text">' . $profile['marital'] . '</span></div><div class="profile-clear"></div>' : '');
+       if(($profile['hidewall'] || $block) && (! local_user()) && (! remote_user())) {
+               $location = $pdesc = $connect = $gender = $marital = $homepage = False;
+       }
 
-       $homepage = ((x($profile,'homepage') == 1) ? '<div class="homepage"><span class="homepage-label">' . t('Homepage:') . ' </span><span class="homepage-url">' . linkify($profile['homepage']) . '</span></div><div class="profile-clear"></div>' : '');
+       $firstname = ((strpos($profile['name'],' ')) 
+               ? trim(substr($profile['name'],0,strpos($profile['name'],' '))) : $profile['name']);
+       $lastname = (($firstname === $profile['name']) ? '' : trim(substr($profile['name'],strlen($firstname))));
+
+       $diaspora = array(
+               'podloc' => $a->get_baseurl(),
+               'searchable' => (($profile['publish'] && $profile['net-publish']) ? 'true' : 'false' ),
+               'nickname ' => $profile['nickname'],
+               'fullname' => $profile['name'],
+               'firstname' => $firstname,
+               'lastname' => $lastname,
+               'photo300' => $a->get_baseurl() . '/photo/custom/300/' . $profile['uid'] . '.jpg',
+               'photo100' => $a->get_baseurl() . '/photo/custom/100/' . $profile['uid'] . '.jpg',
+               'photo50' => $a->get_baseurl() . '/photo/custom/50/'  . $profile['uid'] . '.jpg',
+       );
 
-       if(($profile['hidewall'] || $block) && (! local_user()) && (! remote_user())) {
-               $location = $pdesc = $connect = $gender = $marital = $homepage = '';
+       if (!$block){
+               $contact_block = contact_block();
        }
 
-       $podloc = $a->get_baseurl();
-       $searchable = (($profile['publish'] && $profile['net-publish']) ? 'true' : 'false' );
-       $nickname = $profile['nickname'];
-       $photo300 = $a->get_baseurl() . '/photo/custom/300/' . $profile['uid'] . '.jpg';
-       $photo100 = $a->get_baseurl() . '/photo/custom/100/' . $profile['uid'] . '.jpg';
-       $photo50  = $a->get_baseurl() . '/photo/custom/50/'  . $profile['uid'] . '.jpg';
-
-       $diaspora_vcard = <<< EOT
-
-<div style="display:none;">
-<dl class='entity_nickname'>
-<dt>Nickname</dt>
-<dd>
-<a class="nickname url uid" href="$podloc/" rel="me">$nickname</a>
-</dd>
-</dl>
-<dl class='entity_fn'>
-<dt>Full name</dt>
-<dd>
-<span class='fn'>$fullname</span>
-</dd>
-</dl>
-<dl class="entity_url">
-<dt>URL</dt>
-<dd>
-<a class="url" href="$podloc/" id="pod_location" rel="me">$podloc/</a>
-</dd>
-</dl>
-<dl class="entity_photo">
-<dt>Photo</dt>
-<dd>
-<img class="photo avatar" height="300px" width="300px" src="$photo300">
-</dd>
-</dl>
-<dl class="entity_photo_medium">
-<dt>Photo</dt>
-<dd> 
-<img class="photo avatar" height="100px" width="100px" src="$photo100">
-</dd>
-</dl>
-<dl class="entity_photo_small">
-<dt>Photo</dt>
-<dd>
-<img class="photo avatar" height="50px" width="50px" src="$photo50">
-</dd>
-</dl>
-<dl class="entity_searchable">
-<dt>Searchable</dt>
-<dd>
-<span class="searchable">$searchable</span>
-</dd>
-</dl>
-</div>
-EOT;
 
        $tpl = get_markup_template('profile_vcard.tpl');
 
        $o .= replace_macros($tpl, array(
-               '$fullname' => $fullname,
-               '$pdesc'    => $pdesc,
-               '$tabs'     => $tabs,
-               '$photo'    => $photo,
+               '$profile' => $profile,
                '$connect'  => $connect,                
-               '$location' => $location,
+               '$location' => template_escape($location),
                '$gender'   => $gender,
-               '$pubkey'   => $pubkey,
+               '$pdesc'        => $pdesc,
                '$marital'  => $marital,
                '$homepage' => $homepage,
-               '$diaspora' => $diaspora_vcard
+               '$diaspora' => $diaspora,
+               '$contact_block' => $contact_block,
        ));
 
 
@@ -986,6 +966,7 @@ function get_birthdays() {
                return $o;
 
        $bd_format = t('g A l F d') ; // 8 AM Friday January 18
+       $bd_short = t('F d');
 
        $r = q("SELECT `event`.*, `event`.`id` AS `eid`, `contact`.* FROM `event` 
                LEFT JOIN `contact` ON `contact`.`id` = `event`.`cid` 
@@ -1005,7 +986,7 @@ function get_birthdays() {
                if($total) {
                        $o .= '<div id="birthday-notice" class="birthday-notice fakelink" onclick=openClose(\'birthday-wrapper\'); >' . t('Birthday Reminders') . ' ' . '(' . $total . ')' . '</div>'; 
                        $o .= '<div id="birthday-wrapper" style="display: none;" ><div id="birthday-title">' . t('Birthdays this week:') . '</div>'; 
-                       $o .= '<div id="birthday-adjust">' . t("\x28Adjusted for local time\x29") . '</div>';
+//                     $o .= '<div id="birthday-adjust">' . t("\x28Adjusted for local time\x29") . '</div>';
                        $o .= '<div id="birthday-title-end"></div>';
 
                        foreach($r as $rr) {
@@ -1013,10 +994,16 @@ function get_birthdays() {
                                        continue;
                                $now = strtotime('now');
                                $today = (((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now)) ? true : false); 
+                               $sparkle = '';
+                               $url = $rr['url'];
+                               if($rr['network'] === NETWORK_DFRN) {
+                                       $sparkle = " sparkle";
+                                       $url = $a->get_baseurl() . '/redir/'  . $rr['cid'];
+                               }
        
-                               $o .= '<div class="birthday-list" id="birthday-' . $rr['eid'] . '"><a class="sparkle" target="redir" href="' 
-                               . $a->get_baseurl() . '/redir/'  . $rr['cid'] . '">' . $rr['name'] . '</a> ' 
-                               . day_translate(datetime_convert('UTC', $a->timezone, $rr['start'], $bd_format)) . (($today) ?  ' ' . t('[today]') : '')
+                               $o .= '<div class="birthday-list" id="birthday-' . $rr['eid'] . '"><a class="birthday-link$sparkle" target="redir" href="' 
+                               . $url . '">' . $rr['name'] . '</a> ' 
+                               . day_translate(datetime_convert('UTC', $a->timezone, $rr['start'], $rr['adjust'] ? $bd_format : $bd_short)) . (($today) ?  ' ' . t('[today]') : '')
                                . '</div>' ;
                        }
                        $o .= '</div></div>';
@@ -1172,3 +1159,50 @@ function load_contact_links($uid) {
        $a->contacts = $ret;
        return;         
 }}
+
+if(! function_exists('profile_tabs')){
+function profile_tabs($a, $is_owner=False, $nickname=Null){
+       //echo "<pre>"; var_dump($a->user); killme();
+       
+       if (is_null($nickname))
+               $nickname  = $a->user['nickname'];
+               
+       if(x($_GET,'tab'))
+               $tab = notags(trim($_GET['tab']));
+       
+       $url = $a->get_baseurl() . '/profile/' . $nickname;
+
+       $tabs = array(
+               array(
+                       'label'=>t('Status'),
+                       'url' => $url,
+                       'sel' => ((!isset($tab)&&$a->argv[0]=='profile')?'active':''),
+               ),
+               array(
+                       'label' => t('Profile'),
+                       'url'   => $url.'/?tab=profile',
+                       'sel'   => (($tab=='profile')?'active':''),
+               ),
+               array(
+                       'label' => t('Photos'),
+                       'url'   => $a->get_baseurl() . '/photos/' . $nickname,
+                       'sel'   => ((!isset($tab)&&$a->argv[0]=='photos')?'active':''),
+               ),
+       );
+       
+       if ($is_owner){
+                $tabs[] = array(
+                       'label' => t('Events'),
+                       'url'   => $a->get_baseurl() . '/events',
+                       'sel'   =>((!isset($tab)&&$a->argv[0]=='events')?'active':''),
+               );
+               $tabs[] = array(
+                       'label' => t('Personal Notes'),
+                       'url'   => $a->get_baseurl() . '/notes',
+                       'sel'   =>((!isset($tab)&&$a->argv[0]=='notes')?'active':''),
+               );
+       }
+
+       $tpl = get_markup_template('common_tabs.tpl');
+       return replace_macros($tpl,array('$tabs'=>$tabs));
+}}