X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=boot.php;h=af5c2db0b429cea3f52fafb5a9aae29ba1cc5e60;hb=2825c4957315fab90445bfec5a47bdb64f712355;hp=b53dfb531d5550afb3936b2d02ba1ad712019a17;hpb=096347040491081164857f51e13852b3e05983d7;p=friendica.git diff --git a/boot.php b/boot.php index b53dfb531d..af5c2db0b4 100644 --- a/boot.php +++ b/boot.php @@ -6,11 +6,12 @@ require_once('include/plugin.php'); require_once('include/text.php'); require_once("include/pgettext.php"); require_once('include/nav.php'); +require_once('include/cache.php'); -define ( 'FRIENDIKA_PLATFORM', 'Free Friendika'); -define ( 'FRIENDIKA_VERSION', '2.3.1128' ); -define ( 'DFRN_PROTOCOL_VERSION', '2.21' ); -define ( 'DB_UPDATE_VERSION', 1094 ); +define ( 'FRIENDIKA_PLATFORM', 'Friendica'); +define ( 'FRIENDIKA_VERSION', '2.3.1159' ); +define ( 'DFRN_PROTOCOL_VERSION', '2.22' ); +define ( 'DB_UPDATE_VERSION', 1103 ); define ( 'EOL', "
\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); @@ -93,7 +94,7 @@ define ( 'PAGE_FREELOVE', 3 ); */ define ( 'NETWORK_ZOT', 'zot!'); // Zot! -define ( 'NETWORK_DFRN', 'dfrn'); // Friendika, Mistpark, other DFRN implementations +define ( 'NETWORK_DFRN', 'dfrn'); // Friendica, Mistpark, other DFRN implementations define ( 'NETWORK_OSTATUS', 'stat'); // status.net, identi.ca, GNU-social, other OStatus implementations define ( 'NETWORK_FEED', 'feed'); // RSS/Atom feeds with no known "post/notify" protocol define ( 'NETWORK_DIASPORA', 'dspr'); // Diaspora @@ -190,7 +191,7 @@ function startup() { set_time_limit(0); // This has to be quite large to deal with embedded private photos - ini_set('pcre.backtrack_limit', 350000); + ini_set('pcre.backtrack_limit', 500000); if (get_magic_quotes_gpc()) { @@ -238,7 +239,7 @@ class App { public $contacts; public $page_contact; public $content; - public $data; + public $data = array(); public $error = false; public $cmd; public $argv; @@ -251,8 +252,10 @@ class App { public $timezone; public $interactive = true; public $plugins; - public $apps = Array(); + public $apps = array(); public $identities; + + public $nav_sel; private $scheme; private $hostname; @@ -539,6 +542,8 @@ function check_config(&$a) { $current = intval(DB_UPDATE_VERSION); if(($stored < $current) && file_exists('update.php')) { + load_config('database'); + // We're reporting a different version than what is currently installed. // Run any existing update scripts to bring the database up to current. @@ -552,6 +557,21 @@ function check_config(&$a) { for($x = $stored; $x < $current; $x ++) { if(function_exists('update_' . $x)) { + + // There could be a lot of processes running or about to run. + // We want exactly one process to run the update command. + // So store the fact that we're taking responsibility + // after first checking to see if somebody else already has. + + // If the update fails or times-out completely you may need to + // delete the config entry to try again. + + if(get_config('database','update_' . $x)) + break; + set_config('database','update_' . $x, '1'); + + // call the specific update + $func = 'update_' . $x; $func($a); } @@ -634,31 +654,18 @@ function get_guid($size=16) { // returns the complete html for inserting into the page if(! function_exists('login')) { -function login($register = false) { +function login($register = false, $hiddens=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"); } @@ -667,17 +674,23 @@ function login($register = false) { } - $o = ''; $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: '),'',''), + + '$hiddens' => $hiddens, + + '$register' => $reg, + + '$lostpass' => t('Forgot your password?'), + '$lostlink' => t('Password Reset'), )); call_hooks('login_hook',$o); @@ -813,6 +826,13 @@ function profile_load(&$a, $nickname, $profile = 0) { if(! (x($a->page,'aside'))) $a->page['aside'] = ''; + if(local_user() && local_user() == $a->profile['uid']) { + $a->page['aside'] .= replace_macros(get_markup_template('profile_edlink.tpl'),array( + '$editprofile' => t('Edit profile'), + '$profid' => $a->profile['id'] + )); + } + $block = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false); $a->page['aside'] .= profile_sidebar($a->profile, $block); @@ -920,11 +940,17 @@ function profile_sidebar($profile, $block = 0) { $location = $pdesc = $connect = $gender = $marital = $homepage = False; } + $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', @@ -968,11 +994,12 @@ 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` WHERE `event`.`uid` = %d AND `type` = 'birthday' AND `start` < '%s' AND `finish` > '%s' - ORDER BY `start` DESC ", + ORDER BY `start` ASC ", intval(local_user()), dbesc(datetime_convert('UTC','UTC','now + 6 days')), dbesc(datetime_convert('UTC','UTC','now')) @@ -980,25 +1007,34 @@ function get_birthdays() { if($r && count($r)) { $total = 0; - foreach($r as $rr) + $now = strtotime('now'); + $istoday = false; + foreach($r as $rr) { if(strlen($rr['name'])) $total ++; - + if((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now)) + $istoday = true; + } + $classtoday = $istoday ? ' birthday-today ' : ''; if($total) { - $o .= ''; + $o .= '
' . t('Birthday Reminders') . ' ' . '(' . $total . ')' . '
'; $o .= ''; @@ -1008,6 +1044,70 @@ function get_birthdays() { }} +if(! function_exists('get_events')) { +function get_events() { + + require_once('include/bbcode.php'); + + $a = get_app(); + $o = ''; + + if(! local_user()) + return $o; + + $bd_format = t('g A l F d') ; // 8 AM Friday January 18 + $bd_short = t('F d'); + + $r = q("SELECT `event`.* FROM `event` + WHERE `event`.`uid` = %d AND `type` != 'birthday' AND `start` < '%s' AND `start` > '%s' + ORDER BY `start` ASC ", + intval(local_user()), + dbesc(datetime_convert('UTC','UTC','now + 6 days')), + dbesc(datetime_convert('UTC','UTC','now - 1 days')) + ); + + if($r && count($r)) { + $now = strtotime('now'); + $istoday = false; + foreach($r as $rr) { + if(strlen($rr['name'])) + $total ++; + + $strt = datetime_convert('UTC',$rr['convert'] ? $a->timezone : 'UTC',$rr['start'],'Y-m-d'); + if($strt === datetime_convert('UTC',$a->timezone,'now','Y-m-d')) + $istoday = true; + } + $classtoday = (($istoday) ? ' event-today ' : ''); + + $o .= '
' . t('Event Reminders') . ' ' . '(' . count($r) . ')' . '
'; + $o .= ''; + } + + return $o; +}} + + /** * * Wrap calls to proc_close(proc_open()) and call hook @@ -1155,3 +1255,49 @@ function load_contact_links($uid) { return; }} +if(! function_exists('profile_tabs')){ +function profile_tabs($a, $is_owner=False, $nickname=Null){ + //echo "
"; 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));
+}}