diff --git a/.gitignore b/.gitignore old mode 100755 new mode 100644 index 6302bc1c8b..2531fe4cdd --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,9 @@ addon #ignore documentation, it should be newly built doc/api +#ignore reports, should be generted with every build +report/ + #ignore config files from eclipse, we don't want IDE files in our repository .project .buildpath diff --git a/.htaccess b/.htaccess old mode 100755 new mode 100644 index 1df5096702..6cb3a07494 --- a/.htaccess +++ b/.htaccess @@ -1,4 +1,4 @@ -#Options -Indexes +Options -Indexes AddType application/x-java-archive .jar AddType audio/ogg .oga diff --git a/INSTALL.txt b/INSTALL.txt old mode 100755 new mode 100644 diff --git a/LICENSE b/LICENSE old mode 100755 new mode 100644 diff --git a/README b/README index 152d481eac..d85d98aad1 100644 --- a/README +++ b/README @@ -1,4 +1,11 @@ Friendica Social Communications Server ====================================== +http://friendica.com + Welcome to the free social web. + + +Friendica is a communications platform for integrated social communications utilising decentralised communications and linkage to several indie social projects - as well as popular mainstream providers. + +Our mission is to free our friends and families from the clutches of data-harvesting corporations, and pave the way to a future where social communications are free and open and flow between alternate providers as easily as email does today. \ No newline at end of file diff --git a/boot.php b/boot.php old mode 100755 new mode 100644 index b464d25259..576cad6b63 --- a/boot.php +++ b/boot.php @@ -9,9 +9,9 @@ require_once('include/nav.php'); require_once('include/cache.php'); define ( 'FRIENDICA_PLATFORM', 'Friendica'); -define ( 'FRIENDICA_VERSION', '2.3.1269' ); -define ( 'DFRN_PROTOCOL_VERSION', '2.22' ); -define ( 'DB_UPDATE_VERSION', 1131 ); +define ( 'FRIENDICA_VERSION', '2.3.1304' ); +define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); +define ( 'DB_UPDATE_VERSION', 1137 ); define ( 'EOL', "
\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); @@ -90,13 +90,14 @@ define ( 'PAGE_SOAPBOX', 1 ); define ( 'PAGE_COMMUNITY', 2 ); define ( 'PAGE_FREELOVE', 3 ); define ( 'PAGE_BLOG', 4 ); +define ( 'PAGE_PRVGROUP', 5 ); /** * Network and protocol family types */ -define ( 'NETWORK_ZOT', 'zot!'); // Zot! define ( 'NETWORK_DFRN', 'dfrn'); // Friendica, Mistpark, other DFRN implementations +define ( 'NETWORK_ZOT', 'zot!'); // Zot! 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 @@ -108,6 +109,28 @@ define ( 'NETWORK_XMPP', 'xmpp'); // XMPP define ( 'NETWORK_MYSPACE', 'mysp'); // MySpace define ( 'NETWORK_GPLUS', 'goog'); // Google+ +/* + * These numbers are used in stored permissions + * and existing allocations MUST NEVER BE CHANGED + * OR RE-ASSIGNED! You may only add to them. + */ + +$netgroup_ids = array( + NETWORK_DFRN => (-1), + NETWORK_ZOT => (-2), + NETWORK_OSTATUS => (-3), + NETWORK_FEED => (-4), + NETWORK_DIASPORA => (-5), + NETWORK_MAIL => (-6), + NETWORK_MAIL2 => (-7), + NETWORK_FACEBOOK => (-8), + NETWORK_LINKEDIN => (-9), + NETWORK_XMPP => (-10), + NETWORK_MYSPACE => (-11), + NETWORK_GPLUS => (-12), +); + + /** * Maximum number of "people who like (or don't like) this" that we will list by name */ @@ -135,6 +158,9 @@ define ( 'NOTIFY_PROFILE', 0x0040 ); define ( 'NOTIFY_TAGSELF', 0x0080 ); define ( 'NOTIFY_TAGSHARE', 0x0100 ); +define ( 'NOTIFY_SYSTEM', 0x8000 ); + + /** * various namespaces we may need to parse */ @@ -268,6 +294,8 @@ class App { public $nav_sel; + public $category; + private $scheme; private $hostname; private $baseurl; @@ -286,7 +314,12 @@ class App { startup(); - $this->scheme = ((isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'])) ? 'https' : 'http' ); + $this->scheme = 'http'; + if(x($_SERVER,'HTTPS') && $_SERVER['HTTPS']) + $this->scheme = 'https'; + elseif(x($_SERVER,'SERVER_PORT') && (intval($_SERVER['SERVER_PORT']) == 443)) + $this->scheme = 'https'; + if(x($_SERVER,'SERVER_NAME')) { $this->hostname = $_SERVER['SERVER_NAME']; @@ -347,6 +380,9 @@ class App { $this->argc = count($this->argv); if((array_key_exists('0',$this->argv)) && strlen($this->argv[0])) { $this->module = str_replace(".", "_", $this->argv[0]); + if(array_key_exists('2',$this->argv)) { + $this->category = $this->argv[2]; + } } else { $this->argc = 1; @@ -379,11 +415,22 @@ class App { $scheme = $this->scheme; - if(x($this->config,'ssl_policy')) { - if(($ssl) || ($this->config['ssl_policy'] == SSL_POLICY_FULL)) - $scheme = 'https'; - if(($this->config['ssl_policy'] == SSL_POLICY_SELFSIGN) && (local_user() || x($_POST,'auth-params'))) + if((x($this->config,'system')) && (x($this->config['system'],'ssl_policy'))) { + if(intval($this->config['system']['ssl_policy']) === intval(SSL_POLICY_FULL)) $scheme = 'https'; + +// We need to populate the $ssl flag across the entire program before turning this on. +// Basically, we'll have $ssl = true on any links which can only be seen by a logged in user +// (and also the login link). Anything seen by an outsider will have it turned off. +// At present, setting SSL_POLICY_SELFSIGN will only force remote contacts to update their +// contact links to this site with "http:" if they are currently using "https:" + +// if($this->config['system']['ssl_policy'] == SSL_POLICY_SELFSIGN) { +// if($ssl) +// $scheme = 'https'; +// else +// $scheme = 'http'; +// } } $this->baseurl = $scheme . "://" . $this->hostname . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : '' ); @@ -544,6 +591,10 @@ function absurl($path) { return $path; } +function is_ajax() { + return (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'); +} + // Primarily involved with database upgrade, but also sets the // base url for use in cmdline programs which don't have @@ -685,6 +736,7 @@ function get_guid($size=16) { if(! function_exists('login')) { function login($register = false, $hiddens=false) { + $a = get_app(); $o = ""; $reg = false; if ($register) { @@ -696,31 +748,35 @@ function login($register = false, $hiddens=false) { $noid = get_config('system','no_openid'); + $dest_url = $a->get_baseurl(true) . '/' . $a->query_string; + if(local_user()) { $tpl = get_markup_template("logout.tpl"); } else { $tpl = get_markup_template("login.tpl"); - + $_SESSION['return_url'] = $a->query_string; } $o .= replace_macros($tpl,array( - '$logout' => t('Logout'), - '$login' => t('Login'), + + '$dest_url' => $dest_url, + '$logout' => t('Logout'), + '$login' => t('Login'), '$lname' => array('username', t('Nickname or Email address: ') , '', ''), '$lpassword' => array('password', t('Password: '), '', ''), '$openid' => !$noid, - '$lopenid' => array('openid_url', t('Or login using OpenID: '),'',''), + '$lopenid' => array('openid_url', t('Or login using OpenID: '),'',''), - '$hiddens' => $hiddens, + '$hiddens' => $hiddens, - '$register' => $reg, + '$register' => $reg, - '$lostpass' => t('Forgot your password?'), - '$lostlink' => t('Password Reset'), + '$lostpass' => t('Forgot your password?'), + '$lostlink' => t('Password Reset'), )); call_hooks('login_hook',$o); @@ -934,6 +990,12 @@ function profile_sidebar($profile, $block = 0) { if((remote_user()) && ($_SESSION['visitor_visiting'] == $profile['uid'])) $connect = False; + if(get_my_url() && $profile['unkmail']) + $wallmessage = t('Message'); + else + $wallmessage = false; + + // show edit profile to yourself if ($profile['uid'] == local_user()) { @@ -1016,6 +1078,7 @@ function profile_sidebar($profile, $block = 0) { $o .= replace_macros($tpl, array( '$profile' => $profile, '$connect' => $connect, + '$wallmessage' => $wallmessage, '$location' => template_escape($location), '$gender' => $gender, '$pdesc' => $pdesc, @@ -1209,19 +1272,22 @@ function current_theme(){ $a = get_app(); $system_theme = ((isset($a->config['system']['theme'])) ? $a->config['system']['theme'] : ''); - $theme_name = ((is_array($_SESSION) && x($_SESSION,'theme')) ? $_SESSION['theme'] : $system_theme); + $theme_name = ((isset($_SESSION) && x($_SESSION,'theme')) ? $_SESSION['theme'] : $system_theme); - if($theme_name && file_exists('view/theme/' . $theme_name . '/style.css')) + if($theme_name && + (file_exists('view/theme/' . $theme_name . '/style.css') || + file_exists('view/theme/' . $theme_name . '/style.php'))) return($theme_name); foreach($app_base_themes as $t) { - if(file_exists('view/theme/' . $t . '/style.css')) + if(file_exists('view/theme/' . $t . '/style.css')|| + file_exists('view/theme/' . $t . '/style.php')) return($t); } - $fallback = glob('view/theme/*/style.css'); + $fallback = glob('view/theme/*/style.[css|php]'); if(count($fallback)) - return (str_replace('view/theme/','', str_replace("/style.css","",$fallback[0]))); + return (str_replace('view/theme/','', substr($fallback[0],0,-10))); }} @@ -1233,6 +1299,8 @@ if(! function_exists('current_theme_url')) { function current_theme_url() { global $a; $t = current_theme(); + if (file_exists('view/theme/' . $t . '/style.php')) + return($a->get_baseurl() . '/view/theme/' . $t . '/style.pcss'); return($a->get_baseurl() . '/view/theme/' . $t . '/style.css'); }} @@ -1258,8 +1326,12 @@ function feed_birthday($uid,$tz) { * */ + $birthday = ''; + if(! strlen($tz)) + $tz = 'UTC'; + $p = q("SELECT `dob` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1", intval($uid) ); @@ -1335,7 +1407,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){ array( 'label' => t('Profile'), 'url' => $url.'/?tab=profile', - 'sel' => (($tab=='profile')?'active':''), + 'sel' => ((isset($tab) && $tab=='profile')?'active':''), ), array( 'label' => t('Photos'), @@ -1357,6 +1429,29 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){ ); } + + $arr = array('is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => (($tab) ? $tab : false), 'tabs' => $tabs); + call_hooks('profile_tabs', $arr); + $tpl = get_markup_template('common_tabs.tpl'); - return replace_macros($tpl,array('$tabs'=>$tabs)); + + return replace_macros($tpl,array('$tabs' => $arr['tabs'])); }} + +function get_my_url() { + if(x($_SESSION,'my_url')) + return $_SESSION['my_url']; + return false; +} + +function zrl($s) { + if(! strlen($s)) + return $s; + if(! strpos($s,'/profile/')) + return $s; + $achar = strpos($s,'?') ? '&' : '?'; + $mine = get_my_url(); + if($mine and ! link_compare($mine,$s)) + return $s . $achar . 'zrl=' . urlencode($mine); + return $s; +} diff --git a/build.xml b/build.xml index 83c5300264..a61a5123d7 100644 --- a/build.xml +++ b/build.xml @@ -1,14 +1,49 @@ - + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + @@ -31,6 +66,9 @@ + + + diff --git a/database.sql b/database.sql old mode 100755 new mode 100644 index 35c257f021..010c63bb24 --- a/database.sql +++ b/database.sql @@ -34,10 +34,11 @@ CREATE TABLE IF NOT EXISTS `challenge` ( CREATE TABLE IF NOT EXISTS `config` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `cat` char(255) NOT NULL, - `k` char(255) NOT NULL, + `cat` char(255) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL, + `k` char(255) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL, `v` text NOT NULL, - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + UNIQUE KEY `access`(`cat`,`k`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; @@ -92,6 +93,7 @@ CREATE TABLE IF NOT EXISTS `contact` ( `blocked` tinyint(1) NOT NULL DEFAULT '1', `readonly` tinyint(1) NOT NULL DEFAULT '0', `writable` tinyint(1) NOT NULL DEFAULT '0', + `forum` tinyint(1) NOT NULL DEFAULT '0', `hidden` tinyint(1) NOT NULL DEFAULT '0', `pending` tinyint(1) NOT NULL DEFAULT '1', `rating` tinyint(1) NOT NULL DEFAULT '0', @@ -116,6 +118,7 @@ CREATE TABLE IF NOT EXISTS `contact` ( KEY `dfrn-id` (`dfrn-id`), KEY `blocked` (`blocked`), KEY `readonly` (`readonly`), + KEY `forum` (`forum`), KEY `hidden` (`hidden`), KEY `pending` (`pending`), KEY `closeness` (`closeness`) @@ -287,9 +290,10 @@ CREATE TABLE IF NOT EXISTS `mail` ( `convid` int(10) unsigned NOT NULL, `title` char(255) NOT NULL, `body` mediumtext NOT NULL, - `seen` tinyint(1) NOT NULL, + `seen` tinyint(1) NOT NULL DEFAULT '0', `reply` tinyint(1) NOT NULL DEFAULT '0', - `replied` tinyint(1) NOT NULL, + `replied` tinyint(1) NOT NULL DEFAULT '0', + `unknown` tinyint(1) NOT NULL DEFAULT '0', `uri` char(255) NOT NULL, `parent-uri` char(255) NOT NULL, `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', @@ -298,6 +302,7 @@ CREATE TABLE IF NOT EXISTS `mail` ( KEY `guid` (`guid`), KEY `convid` (`convid`), KEY `reply` (`reply`), + KEY `unknown` (`unknown`), KEY `uri` (`uri`), KEY `parent-uri` (`parent-uri`), KEY `created` (`created`) @@ -451,6 +456,8 @@ CREATE TABLE IF NOT EXISTS `user` ( `blockwall` tinyint(1) unsigned NOT NULL DEFAULT '0', `hidewall` tinyint(1) unsigned NOT NULL DEFAULT '0', `blocktags` tinyint(1) unsigned NOT NULL DEFAULT '0', + `unkmail` tinyint(1) unsigned NOT NULL DEFAULT '0', + `cntunkmail` int(11) unsigned NOT NULL DEFAULT '10', `notify-flags` int(11) unsigned NOT NULL DEFAULT '65535', `page-flags` int(11) unsigned NOT NULL DEFAULT '0', `prvnets` tinyint(1) NOT NULL DEFAULT '0', @@ -470,6 +477,8 @@ CREATE TABLE IF NOT EXISTS `user` ( KEY `account_expired` (`account_expired`), KEY `hidewall` (`hidewall`), KEY `blockwall` (`blockwall`), + KEY `unkmail` (`unkmail`), + KEY `cntunkmail` (`cntunkmail`), KEY `blocked` (`blocked`), KEY `verified` (`verified`), KEY `login_date` (`login_date`) @@ -534,9 +543,10 @@ INDEX ( `batch` ) CREATE TABLE IF NOT EXISTS `pconfig` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `uid` INT NOT NULL DEFAULT '0', -`cat` CHAR( 255 ) NOT NULL , -`k` CHAR( 255 ) NOT NULL , -`v` MEDIUMTEXT NOT NULL +`cat` CHAR( 255 ) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL , +`k` CHAR( 255 ) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL , +`v` MEDIUMTEXT NOT NULL, +UNIQUE KEY `access`(`cat`, `k`) ) ENGINE = MyISAM DEFAULT CHARSET=utf8; @@ -636,6 +646,7 @@ CREATE TABLE IF NOT EXISTS `mailacct` ( `mailbox` CHAR( 255 ) NOT NULL, `user` CHAR( 255 ) NOT NULL , `pass` TEXT NOT NULL , +`reply_to` CHAR( 255 ) NOT NULL , `action` INT NOT NULL , `movetofolder` CHAR(255) NOT NULL , `pubmail` TINYINT(1) NOT NULL DEFAULT '0', @@ -858,3 +869,9 @@ INDEX ( `term` ) ) ENGINE = MyISAM DEFAULT CHARSET=utf8; +CREATE TABLE IF NOT EXISTS `userd` ( +`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , +`username` CHAR( 255 ) NOT NULL, +INDEX ( `username` ) +) ENGINE = MyISAM DEFAULT CHARSET=utf8; + diff --git a/doc/Account-Basics.md b/doc/Account-Basics.md old mode 100755 new mode 100644 index b5e757dbc5..164a6be462 --- a/doc/Account-Basics.md +++ b/doc/Account-Basics.md @@ -6,7 +6,9 @@ Account Basics **Registration** -Not all Friendica sites allow open registration. If registration is allowed, you will see a "Register" link immediately below the login prompts on the site home page. Following this link will take you to the site Registration page. +Not all Friendica sites allow open registration. If registration is allowed, you will see a "Register" link immediately below the login prompts on the site home page. Following this link will take you to the site registration page. The strength of our network is that lots of different sites are all completely compatible with each other. If the site you're visting doesn't allow registration, or you think you might prefer another one, you can find a list of public servers here, and find one that meets your needs. + +If you'd like to have your own server, you can do that too. Visit the Friendica website to download the code with setup instructions. It's a very simple install process that anybody experienced in hosting websites, or with basic Linux experience can handle easily. *OpenID* @@ -14,11 +16,11 @@ The first field on the Registration page is for an OpenID address. If you do not *Your Full Name* -Please provide your full name as you would like it to be displayed on this system. +Please provide your full name **as you would like it to be displayed on this system**. Most people use their real name for this, but you're under no obligation to do so yourself. *Email Address* -Please provide a valid email address. Your email address is **never** published. We need this to send you account information and your login details. You may also occasionally receive notifications of incoming messages or items requiring your attention, but you have the ability to completely disable these from your Settings page once you have logged in. +Please provide a valid email address. Your email address is **never** published. We need this to send you account information and your login details. You may also occasionally receive notifications of incoming messages or items requiring your attention, but you have the ability to completely disable these from your Settings page once you have logged in. This doesn't have to be your primary email address, but it does need to be a real email address. You can't get your initial password, or reset a lost password later without it. This is the only bit of personal information that has to be accurate. *Nickname* @@ -28,12 +30,12 @@ A nickname is used to generate web addresses for many of your personal pages, an *Directory Publishing* -The Registration form also allows you to choose whether or not to list your account in the online directory. This is like a "phone book" and you may choose to be unlisted. We recommend that you select 'Yes' so that other people (friends, family, etc.) will be able to find you. If you choose 'No', you will essentially be invisible and have few opportunities for interaction. Whichever you choose, this can be changed any time from your Settings page after you login. - +The Registration form also allows you to choose whether or not to list your account in the online directory. This is like a "phone book" and you may choose to be unlisted. We recommend that you select 'Yes' so that other people (friends, family, etc.) will be able to find you. If you choose 'No', you will essentially be invisible and have few opportunities for interaction. Whichever you choose, this can be changed any time from your Settings page after you login. *Register* -Once you have provided the necessary details, click the 'Register' button. An email will be sent to you providing your account login details. Some sites may require administrator approval before the registration is processed, and you will be alerted if this is the case. Please watch your email (including spam folders) for your registration approval. +Once you have provided the necessary details, click the 'Register' button. An email will be sent to you providing your account login details. Please watch your email (including spam folders) for your registration details and initial password. + @@ -58,6 +60,11 @@ After your first login, please visit the 'Settings' page from the top menu bar a A ['Tips for New Members'](newmember) link will show up on your home page for two weeks to provide some important Getting Started information. +**Retrieving Personal Data** + +You can export a copy of your personal data in XML format from the "Export personal data" link at the top of your settings page. + + **See Also** * [Profiles](help/Profiles) @@ -66,4 +73,3 @@ A ['Tips for New Members'](newmember) link will show up on your home page for tw * [Remove Account](help/Remove-Account) - \ No newline at end of file diff --git a/doc/Bugs-and-Issues.md b/doc/Bugs-and-Issues.md old mode 100755 new mode 100644 index c119b99684..46abea9a3e --- a/doc/Bugs-and-Issues.md +++ b/doc/Bugs-and-Issues.md @@ -4,18 +4,19 @@ Bugs and Issues * [Home](help) -Please report any bugs/issues you encounter using our bug tracker at [[http://bugs.friendica.com]] +If your server has a support page, you should report any bugs/issues you encounter there first. Reporting to your support page before reporting to the developers makes their job easier, as they don't have to deal with bug reports that might not have anything to do with them, and that helps us get new features faster. -Try to provide as much information as you can about the bug (including the full text of any error messages or notices), and if possible your Friendica version. +If you're a technical user, or your site doesn't have a support page, you'll need to use the Bug Tracker. Please perform a search to see if there's already an open bug that matches yours before submitting anything. -Your Friendica version may be found in newer releases by visiting http://YOURFRIENDICASITE/friendica +Try to provide as much information as you can about the bug, including the **full** text of any error messages or notices, and any steps required to replicate the problem in as much detail as possible. It's generally better to provide too much information than not enough. -For older versions, view the HTML source of your profile page. The Friendica version is in the HTML header, 5-10 lines from the top of the page. +See this article to learn more about submitting **good** bug reports. -For really old versions which don't have a version number in the HTML header - please upgrade. Your bug was probably fixed a long time ago. **Bug Sponsorship** +If you find a bug, and it is caused by a problem in main branch (ie, is not specific to our site), you may sponsor it. + The bug/issue database allows you to sponsor issues. This provides an incentive for developers to work on your issue. This isn't necessary - we don't like bugs and will try to fix them. This has more importance for future development projects and feature requests. Bug sponsorship works on the honour system. If you agree to pay $10 to fix a bug, when the fix has been checked in and verified you should send a paypal payment to the developer assigned to the bug. Don't ever think you can get away with not paying a developer for work performed. Some of these guys could hack into your credit card account if you make them mad. diff --git a/doc/Connectors.md b/doc/Connectors.md old mode 100755 new mode 100644 diff --git a/doc/Developers.md b/doc/Developers.md old mode 100755 new mode 100644 diff --git a/doc/Home.md b/doc/Home.md old mode 100755 new mode 100644 index 56abe8075c..30efc93f7d --- a/doc/Home.md +++ b/doc/Home.md @@ -5,6 +5,7 @@ Friendica Documentation and Resources **Contents** * [Account Basics](help/Account-Basics) +* [New User Quick Start](help/guide) * [Profiles](help/Profiles) * [Connectors](help/Connectors) * [Making Friends](help/Making-Friends) diff --git a/doc/Install.md b/doc/Install.md old mode 100755 new mode 100644 diff --git a/doc/Installing-Connectors.md b/doc/Installing-Connectors.md old mode 100755 new mode 100644 diff --git a/doc/Making-Friends.md b/doc/Making-Friends.md old mode 100755 new mode 100644 index 1a9c8d8981..3f1a24c8de --- a/doc/Making-Friends.md +++ b/doc/Making-Friends.md @@ -5,7 +5,13 @@ Making Friends Friendship in Friendica can take on a great many different meanings. But let's keep it simple, you want to be friends with somebody. How do you do it? -The first thing you can do is look at the Directory for somebody you would like to connect with. Visit their profile. Just beneath their profile picture will be the word 'Connect' (we're assuming this is an English language profile). +The easiest thing to do is to join the New Here group. This group is especially for people new to the Friendica network. Simply connect to the group, post to the wall, and make new friends. You don't even have to like us - comment on a few of our posts, and other people will start to add you too. + +The next thing you can do is look at the Directory. The directory is split up into two parts. If you click the directory button, you will be presented with a list of all members (who chose to be listed) on your server. You'll also see a link to the Global Directory. If you click through to the global directory, you will be presented with a list of everybody who chose to be listed across all instances of Friendica. You will also see a "Show Community Forums" link, which will direct you to Groups, Forums and Fanpages. You connect to people, groups and forums in the same way, except groups and forums will automatically accept your introduction request, whereas a human will approve you manually. + +To connect with other Friendica user + +Visit their profile. Just beneath their profile picture will be the word 'Connect' (we're assuming this is an English language profile). Click that. It will take you to a "Connect" form. @@ -23,6 +29,7 @@ When you've submitted the connection page, it will take you back to your own sit If you already know somebody's Identity Address, you can enter it in the "connect" box on your "Contacts" page. This will take you through a similar process. + **Alternate Networks** You can also use your Identity Address or other people's Identity Addresses to become friends across networks. The list of possible networks is growing all the time. If you know (for instance) "bob" on identi.ca (a Status.Net site) you could put bob@identi.ca into your Contact page and become friends across networks. (Or you can put in the URL to Bob's identi.ca page if you wish). You can also be "partial" friends with somebody on Google Buzz by putting in their gmail address. Google Buzz does not yet support all the protocols we need for direct messaging, but you should be able to follow status updates from within Friendica. You can do the same for Twitter accounts and Diaspora accounts. In fact you can "follow" most anybody or any website that produces a syndication feed (RSS/Atom,etc.). If we can find an information stream and a name to attach to the contact, we'll try to connect with them. diff --git a/doc/Message-Flow.md b/doc/Message-Flow.md old mode 100755 new mode 100644 diff --git a/doc/Pages.md b/doc/Pages.md old mode 100755 new mode 100644 diff --git a/doc/Plugins.md b/doc/Plugins.md old mode 100755 new mode 100644 diff --git a/doc/Profiles.md b/doc/Profiles.md old mode 100755 new mode 100644 diff --git a/doc/Remove-Account.md b/doc/Remove-Account.md old mode 100755 new mode 100644 index f526b78a8f..ae5de2cb65 --- a/doc/Remove-Account.md +++ b/doc/Remove-Account.md @@ -5,9 +5,20 @@ Remove Account We don't like to see people leave Friendica, but if you need to remove your account, you should visit the URL -http://friendica-site/removeme +http://sitename/removeme -with your web browser. You will need to be logged in at the time. (Replace "friendica-site" with the hostname of your Friendica server) +with your web browser. You will need to be logged in at the time. You will be asked for your password to confirm the request. If this matches your stored password, your account will immediately be removed. Unlike some social networks we do **not** hold onto it for a grace period in case you change your mind. Your user details, your conversations, your photos, your friends - everything; will be removed immediately and you will be logged out. +When we expire posts we send notifications out to Friendica to remove the posts. Diaspora doesn't have a bulk delete so this step is skipped on that network - and hopefully it will be obvious that deletion doesn't work on any other networks. If you manually delete a post or a range of posts we send individual delete notifications to Friendica and Diaspora for each deleted post. + +Diaspora often loses these. + +If you delete a post but somebody else has starred it, it is still removed. Your wishes take priority. + +When you remove your account we physically remove all your posts and your profile and user data, etc. immediately. + +In order to send out a bulk remove we would need to keep your account around to do this, as we would need to prove to your friends who it is that is submitting the request. We can't do this if you don't have an account. + +Your friends may still see your posts if your account is gone, but there is no public place within Friendica where they can be viewed. If you had friends on Diaspora, your public posts may stick around and be visible to others from that network. diff --git a/doc/Settings.md b/doc/Settings.md old mode 100755 new mode 100644 diff --git a/doc/Tags-and-Mentions.md b/doc/Tags-and-Mentions.md old mode 100755 new mode 100644 diff --git a/doc/andfinally.md b/doc/andfinally.md new file mode 100644 index 0000000000..cd8a6994ba --- /dev/null +++ b/doc/andfinally.md @@ -0,0 +1,24 @@ +And that brings the Quick Start to an end. + +Here are some more things to help get you started: + +**Groups** + + +- New Here - a group for people new to Friendica + +- Friendica Support - problems? This is the place to ask. + +- Public Stream - a place to talk about anything to anyone. + +- Let's Talk a group for finding people and groups who share similar interests. + +- Local Friendica a page for local Friendica groups + + +**Documentation** + +- Connecting to more networks +- Help Index + + diff --git a/doc/groupsandpages.md b/doc/groupsandpages.md new file mode 100644 index 0000000000..418e682c83 --- /dev/null +++ b/doc/groupsandpages.md @@ -0,0 +1,11 @@ +This is the global directory. If you get lost, you can click this link to bring yourself back here. + +On this page, you'll find a collection of groups, forums and celebrity pages. Groups are not real people. Connecting to them is similar to "liking" something on Facebook, or signing up for a new forum. You don't have to feel awkward about introducing yourself to a new person, because they're not people! + +When you connect to a group, all messages to that group will start appearing in your network tab. You can comment on these posts, or post to the group yourself without ever having to add any of the groups members. This is a great way to make friends dynamically - you'll find people you like and add each other naturally instead of adding random strangers. Simply find a group you're interested in, and connect to it the same way you did with people in the last section. There are a lot of groups, and you're likely to get lost. Remember the link at the top of this page will bring you back here. + +Once you've added some groups, move on to the next section. + + + + diff --git a/doc/guide.md b/doc/guide.md new file mode 100644 index 0000000000..178170c4e2 --- /dev/null +++ b/doc/guide.md @@ -0,0 +1,13 @@ +First things first, let's make sure you're logged in to your account. If you're not already logged in, do so in the frame below. + +Once you've logged in (or if you are already logged in), you'll now be looking at your profile page. + +This is a bit like your Facebook wall. It's where all your status messgages are kept, and where your friends come to post on your wall. To write your status, simply click in the box that says "share". When you do this, the box will expand. You can see some formatting options at the top such as Bold, Italics and Underline, as well as ways to add links and pictures. At the bottom you'll find some more links. You can use these to upload pictures and files from your computer, share websites with a bit of preview text, or embed video and audio files from elsewhere on the web. You can also set your post location here. + +Once you've finished writing your post, click on the padlock icon to select who can see it. If you do not use the padlock icon, your post will be public. This means it will appear to anybody who views your profile, and in the community tab if your site has it enabled, as well as in the network tab of any of your contacts. + +Play around with this a bit, then when you're ready to move on, we'll take a look at the Network Tab + + + + diff --git a/doc/makingnewfriends.md b/doc/makingnewfriends.md new file mode 100644 index 0000000000..35befaa365 --- /dev/null +++ b/doc/makingnewfriends.md @@ -0,0 +1,11 @@ +This is your Suggested Friends page. If you get lost, you can click this link to bring yourself back here. + +This is a bit like the Friend Suggestions page of Facebook. Everybody on this list has agreed that they may be suggested as a friend. This means they're unlikely to refuse an introduction you send, and they want to meet new people too! + +See somebody you like the look of? Click the connect button beneath their photograph. This will bring you to the introductions page. Fill in the form as instructed, and add a small note (optional). Now, wait a bit and they'll accept your request - note that these are real people, and it might take a while. Now you've added one, you're probably lost. Click the link at the top of this page to go back to the suggested friends list and add some more. + +Feel uncomfortable adding people you don't know? Don't worry - that's where Groups and Pages come in! + + + + diff --git a/doc/network.md b/doc/network.md new file mode 100644 index 0000000000..f445b0055e --- /dev/null +++ b/doc/network.md @@ -0,0 +1,9 @@ +This is your Network Tab. If you get lost, you can click this link to bring yourself back here. + +This is a bit like the Newsfeed at Facebook or the Stream at Diaspora. It's where all the posts from your contacts, groups, and feeds will appear. If you're new, you won't see anything in this page, unless you posted your status in the last step. If you've already added a few friends, you'll be able to see their posts. Here, you can comment, like, or dislike posts, or click on somebody's name to visit their profile page where you can write on their wall. + +Now we need to fill it up, the first step, is to add people you already know from Facebook. + + + + diff --git a/doc/peopleyouknow.md b/doc/peopleyouknow.md new file mode 100644 index 0000000000..143c492176 --- /dev/null +++ b/doc/peopleyouknow.md @@ -0,0 +1,13 @@ +This is your connector settings page. If you get lost, you can click this link to bring yourself back here. + +This is the bit that makes Friendica unique. You can connect to anybody on the internet from your Friendica account using this page! The available connectors varies depending on which plugins you have installed, but for now, we'll walk you through Facebook. Note that not all servers have the Facebook connector installed. If you can't find it in the list below, don't worry, we'll look at ways of connecting to more people in the following pages. + +The biggest of all social networks is Facebook. Fortunately, this connector is really easy. Scroll down the page, and click Facebook Connector Settings. Enter your Facebook user name and password and let the application (the connector) do everything the options suggest. You can fine tune this or experiment with the other connectors too. If you need help, you can always ask at Friendica Support or see the instructions here. + +When you're ready, we can move on to making new friends. + + + + + + diff --git a/docblox.dist.xml b/docblox.dist.xml new file mode 100644 index 0000000000..a2ea8e2cb7 --- /dev/null +++ b/docblox.dist.xml @@ -0,0 +1,13 @@ + + + + data/output + + + data/output + + + . + + + diff --git a/htconfig.php b/htconfig.php old mode 100755 new mode 100644 index 423d5d369f..63a40c8090 --- a/htconfig.php +++ b/htconfig.php @@ -69,7 +69,7 @@ $a->config['system']['rino_encrypt'] = true; // allowed themes (change this from admin panel after installation) -$a->config['system']['allowed_themes'] = 'dispy,quattro,testbubble,vier,darkbubble,darkzero,duepuntozero,greenzero,purplezero,quattro-green,slackr,diabook'; +$a->config['system']['allowed_themes'] = 'dispy,quattro,testbubble,vier,darkbubble,darkzero,duepuntozero,greenzero,purplezero,quattro-green,slackr,diabook,diabook-blue'; // default system theme @@ -79,3 +79,12 @@ $a->config['system']['theme'] = 'duepuntozero'; // By default allow pseudonyms $a->config['system']['no_regfullname'] = true; + +// If set to true the priority settings of ostatus contacts are used +$a->config['system']['ostatus_use_priority'] = false; + +// If enabled, all items are cached in the given directory +$a->config['system']['itemcache'] = ""; + +// If enabled, the lockpath is used for a lockfile to check if the poller is running +$a->config['system']['lockpath'] = ""; diff --git a/images/article.gif b/images/article.gif old mode 100755 new mode 100644 diff --git a/images/audio.gif b/images/audio.gif old mode 100755 new mode 100644 diff --git a/images/b_block.gif b/images/b_block.gif old mode 100755 new mode 100644 diff --git a/images/b_drop.gif b/images/b_drop.gif old mode 100755 new mode 100644 diff --git a/images/b_drop.png b/images/b_drop.png old mode 100755 new mode 100644 diff --git a/images/b_drophide.gif b/images/b_drophide.gif old mode 100755 new mode 100644 diff --git a/images/b_dropshow.gif b/images/b_dropshow.gif old mode 100755 new mode 100644 diff --git a/images/b_edit.gif b/images/b_edit.gif old mode 100755 new mode 100644 diff --git a/images/b_edit.png b/images/b_edit.png old mode 100755 new mode 100644 diff --git a/images/beer_mug.gif b/images/beer_mug.gif index a047d19873..9a3e051922 100644 Binary files a/images/beer_mug.gif and b/images/beer_mug.gif differ diff --git a/images/blank.png b/images/blank.png new file mode 100644 index 0000000000..67d3919667 Binary files /dev/null and b/images/blank.png differ diff --git a/images/bug-x.gif b/images/bug-x.gif new file mode 100644 index 0000000000..10936caa77 Binary files /dev/null and b/images/bug-x.gif differ diff --git a/images/calendar.png b/images/calendar.png old mode 100755 new mode 100644 diff --git a/images/camera-icon.gif b/images/camera-icon.gif old mode 100755 new mode 100644 diff --git a/images/connect-bg.png b/images/connect-bg.png old mode 100755 new mode 100644 diff --git a/images/content-types.png b/images/content-types.png old mode 100755 new mode 100644 diff --git a/images/default-group-mm.png b/images/default-group-mm.png old mode 100755 new mode 100644 diff --git a/images/default-profile-mm.jpg b/images/default-profile-mm.jpg old mode 100755 new mode 100644 diff --git a/images/default-profile-sm.jpg b/images/default-profile-sm.jpg old mode 100755 new mode 100644 diff --git a/images/default-profile.jpg b/images/default-profile.jpg old mode 100755 new mode 100644 diff --git a/images/diaspora.png b/images/diaspora.png old mode 100755 new mode 100644 diff --git a/images/dislike.gif b/images/dislike.gif old mode 100755 new mode 100644 diff --git a/images/document.gif b/images/document.gif old mode 100755 new mode 100644 diff --git a/images/ff-128.jpg b/images/ff-128.jpg old mode 100755 new mode 100644 diff --git a/images/ff-16.jpg b/images/ff-16.jpg old mode 100755 new mode 100644 diff --git a/images/ff-256.jpg b/images/ff-256.jpg old mode 100755 new mode 100644 diff --git a/images/ff-32.jpg b/images/ff-32.jpg old mode 100755 new mode 100644 diff --git a/images/ff-64.jpg b/images/ff-64.jpg old mode 100755 new mode 100644 diff --git a/images/ff.xcf b/images/ff.xcf old mode 100755 new mode 100644 diff --git a/images/friendica-128.jpg b/images/friendica-128.jpg old mode 100755 new mode 100644 diff --git a/images/friendica-128.png b/images/friendica-128.png old mode 100755 new mode 100644 diff --git a/images/friendica-16.jpg b/images/friendica-16.jpg old mode 100755 new mode 100644 diff --git a/images/friendica-16.png b/images/friendica-16.png old mode 100755 new mode 100644 diff --git a/images/friendica-1600.png b/images/friendica-1600.png old mode 100755 new mode 100644 diff --git a/images/friendica-256.jpg b/images/friendica-256.jpg old mode 100755 new mode 100644 diff --git a/images/friendica-256.png b/images/friendica-256.png old mode 100755 new mode 100644 diff --git a/images/friendica-32.jpg b/images/friendica-32.jpg old mode 100755 new mode 100644 diff --git a/images/friendica-32.png b/images/friendica-32.png old mode 100755 new mode 100644 diff --git a/images/friendica-48.png b/images/friendica-48.png old mode 100755 new mode 100644 diff --git a/images/friendica-64.jpg b/images/friendica-64.jpg old mode 100755 new mode 100644 diff --git a/images/friendica-64.png b/images/friendica-64.png old mode 100755 new mode 100644 diff --git a/images/friendica-96.png b/images/friendica-96.png old mode 100755 new mode 100644 diff --git a/images/friendica.svg b/images/friendica.svg old mode 100755 new mode 100644 diff --git a/images/friendika-128.jpg b/images/friendika-128.jpg old mode 100755 new mode 100644 diff --git a/images/friendika-128.png b/images/friendika-128.png old mode 100755 new mode 100644 diff --git a/images/friendika-16.jpg b/images/friendika-16.jpg old mode 100755 new mode 100644 diff --git a/images/friendika-16.png b/images/friendika-16.png old mode 100755 new mode 100644 diff --git a/images/friendika-1600.png b/images/friendika-1600.png old mode 100755 new mode 100644 diff --git a/images/friendika-256.jpg b/images/friendika-256.jpg old mode 100755 new mode 100644 diff --git a/images/friendika-256.png b/images/friendika-256.png old mode 100755 new mode 100644 diff --git a/images/friendika-32.jpg b/images/friendika-32.jpg old mode 100755 new mode 100644 diff --git a/images/friendika-32.png b/images/friendika-32.png old mode 100755 new mode 100644 diff --git a/images/friendika-48.png b/images/friendika-48.png old mode 100755 new mode 100644 diff --git a/images/friendika-64.jpg b/images/friendika-64.jpg old mode 100755 new mode 100644 diff --git a/images/friendika-64.png b/images/friendika-64.png old mode 100755 new mode 100644 diff --git a/images/friendika-96.png b/images/friendika-96.png old mode 100755 new mode 100644 diff --git a/images/friendika.svg b/images/friendika.svg old mode 100755 new mode 100644 diff --git a/images/globe.gif b/images/globe.gif old mode 100755 new mode 100644 diff --git a/images/hide_off.png b/images/hide_off.png old mode 100755 new mode 100644 diff --git a/images/hide_on.png b/images/hide_on.png old mode 100755 new mode 100644 diff --git a/images/icons.png b/images/icons.png old mode 100755 new mode 100644 diff --git a/images/icons/10/add.png b/images/icons/10/add.png old mode 100755 new mode 100644 diff --git a/images/icons/10/delete.png b/images/icons/10/delete.png old mode 100755 new mode 100644 diff --git a/images/icons/10/edit.png b/images/icons/10/edit.png old mode 100755 new mode 100644 diff --git a/images/icons/10/feed.png b/images/icons/10/feed.png old mode 100755 new mode 100644 diff --git a/images/icons/10/gear.png b/images/icons/10/gear.png old mode 100755 new mode 100644 diff --git a/images/icons/10/group.png b/images/icons/10/group.png old mode 100755 new mode 100644 diff --git a/images/icons/10/info.png b/images/icons/10/info.png old mode 100755 new mode 100644 diff --git a/images/icons/10/link.png b/images/icons/10/link.png old mode 100755 new mode 100644 diff --git a/images/icons/10/lock.png b/images/icons/10/lock.png old mode 100755 new mode 100644 diff --git a/images/icons/10/menu.png b/images/icons/10/menu.png old mode 100755 new mode 100644 diff --git a/images/icons/10/notice.png b/images/icons/10/notice.png old mode 100755 new mode 100644 diff --git a/images/icons/10/notify_off.png b/images/icons/10/notify_off.png old mode 100755 new mode 100644 diff --git a/images/icons/10/notify_on.png b/images/icons/10/notify_on.png old mode 100755 new mode 100644 diff --git a/images/icons/10/play.png b/images/icons/10/play.png old mode 100755 new mode 100644 diff --git a/images/icons/10/plugin.png b/images/icons/10/plugin.png old mode 100755 new mode 100644 diff --git a/images/icons/10/star.png b/images/icons/10/star.png old mode 100755 new mode 100644 diff --git a/images/icons/10/unlock.png b/images/icons/10/unlock.png old mode 100755 new mode 100644 diff --git a/images/icons/10/user.png b/images/icons/10/user.png old mode 100755 new mode 100644 diff --git a/images/icons/16/add.png b/images/icons/16/add.png old mode 100755 new mode 100644 diff --git a/images/icons/16/delete.png b/images/icons/16/delete.png old mode 100755 new mode 100644 diff --git a/images/icons/16/edit.png b/images/icons/16/edit.png old mode 100755 new mode 100644 diff --git a/images/icons/16/feed.png b/images/icons/16/feed.png old mode 100755 new mode 100644 diff --git a/images/icons/16/gear.png b/images/icons/16/gear.png old mode 100755 new mode 100644 diff --git a/images/icons/16/group.png b/images/icons/16/group.png old mode 100755 new mode 100644 diff --git a/images/icons/16/info.png b/images/icons/16/info.png old mode 100755 new mode 100644 diff --git a/images/icons/16/link.png b/images/icons/16/link.png old mode 100755 new mode 100644 diff --git a/images/icons/16/lock.png b/images/icons/16/lock.png old mode 100755 new mode 100644 diff --git a/images/icons/16/menu.png b/images/icons/16/menu.png old mode 100755 new mode 100644 diff --git a/images/icons/16/notice.png b/images/icons/16/notice.png old mode 100755 new mode 100644 diff --git a/images/icons/16/notify_off.png b/images/icons/16/notify_off.png old mode 100755 new mode 100644 diff --git a/images/icons/16/notify_on.png b/images/icons/16/notify_on.png old mode 100755 new mode 100644 diff --git a/images/icons/16/play.png b/images/icons/16/play.png old mode 100755 new mode 100644 diff --git a/images/icons/16/plugin.png b/images/icons/16/plugin.png old mode 100755 new mode 100644 diff --git a/images/icons/16/star.png b/images/icons/16/star.png old mode 100755 new mode 100644 diff --git a/images/icons/16/unlock.png b/images/icons/16/unlock.png old mode 100755 new mode 100644 diff --git a/images/icons/16/user.png b/images/icons/16/user.png old mode 100755 new mode 100644 diff --git a/images/icons/22/add.png b/images/icons/22/add.png old mode 100755 new mode 100644 diff --git a/images/icons/22/delete.png b/images/icons/22/delete.png old mode 100755 new mode 100644 diff --git a/images/icons/22/edit.png b/images/icons/22/edit.png old mode 100755 new mode 100644 diff --git a/images/icons/22/feed.png b/images/icons/22/feed.png old mode 100755 new mode 100644 diff --git a/images/icons/22/gear.png b/images/icons/22/gear.png old mode 100755 new mode 100644 diff --git a/images/icons/22/group.png b/images/icons/22/group.png old mode 100755 new mode 100644 diff --git a/images/icons/22/info.png b/images/icons/22/info.png old mode 100755 new mode 100644 diff --git a/images/icons/22/link.png b/images/icons/22/link.png old mode 100755 new mode 100644 diff --git a/images/icons/22/lock.png b/images/icons/22/lock.png old mode 100755 new mode 100644 diff --git a/images/icons/22/menu.png b/images/icons/22/menu.png old mode 100755 new mode 100644 diff --git a/images/icons/22/notice.png b/images/icons/22/notice.png old mode 100755 new mode 100644 diff --git a/images/icons/22/notify_off.png b/images/icons/22/notify_off.png old mode 100755 new mode 100644 diff --git a/images/icons/22/notify_on.png b/images/icons/22/notify_on.png old mode 100755 new mode 100644 diff --git a/images/icons/22/play.png b/images/icons/22/play.png old mode 100755 new mode 100644 diff --git a/images/icons/22/plugin.png b/images/icons/22/plugin.png old mode 100755 new mode 100644 diff --git a/images/icons/22/star.png b/images/icons/22/star.png old mode 100755 new mode 100644 diff --git a/images/icons/22/unlock.png b/images/icons/22/unlock.png old mode 100755 new mode 100644 diff --git a/images/icons/22/user.png b/images/icons/22/user.png old mode 100755 new mode 100644 diff --git a/images/icons/48/add.png b/images/icons/48/add.png old mode 100755 new mode 100644 diff --git a/images/icons/48/delete.png b/images/icons/48/delete.png old mode 100755 new mode 100644 diff --git a/images/icons/48/edit.png b/images/icons/48/edit.png old mode 100755 new mode 100644 diff --git a/images/icons/48/feed.png b/images/icons/48/feed.png old mode 100755 new mode 100644 diff --git a/images/icons/48/gear.png b/images/icons/48/gear.png old mode 100755 new mode 100644 diff --git a/images/icons/48/group.png b/images/icons/48/group.png old mode 100755 new mode 100644 diff --git a/images/icons/48/info.png b/images/icons/48/info.png old mode 100755 new mode 100644 diff --git a/images/icons/48/link.png b/images/icons/48/link.png old mode 100755 new mode 100644 diff --git a/images/icons/48/lock.png b/images/icons/48/lock.png old mode 100755 new mode 100644 diff --git a/images/icons/48/menu.png b/images/icons/48/menu.png old mode 100755 new mode 100644 diff --git a/images/icons/48/notice.png b/images/icons/48/notice.png old mode 100755 new mode 100644 diff --git a/images/icons/48/notify_off.png b/images/icons/48/notify_off.png old mode 100755 new mode 100644 diff --git a/images/icons/48/notify_on.png b/images/icons/48/notify_on.png old mode 100755 new mode 100644 diff --git a/images/icons/48/play.png b/images/icons/48/play.png old mode 100755 new mode 100644 diff --git a/images/icons/48/plugin.png b/images/icons/48/plugin.png old mode 100755 new mode 100644 diff --git a/images/icons/48/star.png b/images/icons/48/star.png old mode 100755 new mode 100644 diff --git a/images/icons/48/unlock.png b/images/icons/48/unlock.png old mode 100755 new mode 100644 diff --git a/images/icons/48/user.png b/images/icons/48/user.png old mode 100755 new mode 100644 diff --git a/images/icons/Makefile b/images/icons/Makefile old mode 100755 new mode 100644 diff --git a/images/icons/add.png b/images/icons/add.png old mode 100755 new mode 100644 diff --git a/images/icons/delete.png b/images/icons/delete.png old mode 100755 new mode 100644 diff --git a/images/icons/edit.png b/images/icons/edit.png old mode 100755 new mode 100644 diff --git a/images/icons/feed.png b/images/icons/feed.png old mode 100755 new mode 100644 diff --git a/images/icons/gear.png b/images/icons/gear.png old mode 100755 new mode 100644 diff --git a/images/icons/group.png b/images/icons/group.png old mode 100755 new mode 100644 diff --git a/images/icons/info.png b/images/icons/info.png old mode 100755 new mode 100644 diff --git a/images/icons/link.png b/images/icons/link.png old mode 100755 new mode 100644 diff --git a/images/icons/lock.png b/images/icons/lock.png old mode 100755 new mode 100644 diff --git a/images/icons/menu.png b/images/icons/menu.png old mode 100755 new mode 100644 diff --git a/images/icons/notice.png b/images/icons/notice.png old mode 100755 new mode 100644 diff --git a/images/icons/notify_off.png b/images/icons/notify_off.png old mode 100755 new mode 100644 diff --git a/images/icons/notify_on.png b/images/icons/notify_on.png old mode 100755 new mode 100644 diff --git a/images/icons/play.png b/images/icons/play.png old mode 100755 new mode 100644 diff --git a/images/icons/plugin.png b/images/icons/plugin.png old mode 100755 new mode 100644 diff --git a/images/icons/star.png b/images/icons/star.png old mode 100755 new mode 100644 diff --git a/images/icons/unlock.png b/images/icons/unlock.png old mode 100755 new mode 100644 diff --git a/images/icons/user.png b/images/icons/user.png old mode 100755 new mode 100644 diff --git a/images/larrow.gif b/images/larrow.gif old mode 100755 new mode 100644 diff --git a/images/larrw.gif b/images/larrw.gif old mode 100755 new mode 100644 diff --git a/images/like.gif b/images/like.gif old mode 100755 new mode 100644 diff --git a/images/link-icon.gif b/images/link-icon.gif old mode 100755 new mode 100644 diff --git a/images/lock_icon.gif b/images/lock_icon.gif old mode 100755 new mode 100644 diff --git a/images/logo.png b/images/logo.png old mode 100755 new mode 100644 diff --git a/images/lrarrow.gif b/images/lrarrow.gif old mode 100755 new mode 100644 diff --git a/images/mapicon.gif b/images/mapicon.gif old mode 100755 new mode 100644 diff --git a/images/no.gif b/images/no.gif old mode 100755 new mode 100644 diff --git a/images/noglobe.gif b/images/noglobe.gif old mode 100755 new mode 100644 diff --git a/images/nosign.jpg b/images/nosign.jpg old mode 100755 new mode 100644 diff --git a/images/onoff.jpg b/images/onoff.jpg old mode 100755 new mode 100644 diff --git a/images/pause.gif b/images/pause.gif old mode 100755 new mode 100644 diff --git a/images/pen.png b/images/pen.png old mode 100755 new mode 100644 diff --git a/images/pencil.gif b/images/pencil.gif old mode 100755 new mode 100644 diff --git a/images/penhover.png b/images/penhover.png old mode 100755 new mode 100644 diff --git a/images/people.gif b/images/people.gif old mode 100755 new mode 100644 diff --git a/images/person-175.jpg b/images/person-175.jpg new file mode 100644 index 0000000000..fc0ec3d771 Binary files /dev/null and b/images/person-175.jpg differ diff --git a/images/person-48.jpg b/images/person-48.jpg new file mode 100644 index 0000000000..dc5eb6e692 Binary files /dev/null and b/images/person-48.jpg differ diff --git a/images/person-80.jpg b/images/person-80.jpg new file mode 100644 index 0000000000..75b8faf922 Binary files /dev/null and b/images/person-80.jpg differ diff --git a/images/play.gif b/images/play.gif old mode 100755 new mode 100644 diff --git a/images/plugin.png b/images/plugin.png old mode 100755 new mode 100644 diff --git a/images/rarrow.gif b/images/rarrow.gif old mode 100755 new mode 100644 diff --git a/images/rarrw.gif b/images/rarrw.gif old mode 100755 new mode 100644 diff --git a/images/recycle.gif b/images/recycle.gif old mode 100755 new mode 100644 diff --git a/images/remote-link.gif b/images/remote-link.gif old mode 100755 new mode 100644 diff --git a/images/rotator.gif b/images/rotator.gif old mode 100755 new mode 100644 diff --git a/images/search_18.png b/images/search_18.png old mode 100755 new mode 100644 diff --git a/images/selected.png b/images/selected.png old mode 100755 new mode 100644 diff --git a/images/share.gif b/images/share.gif old mode 100755 new mode 100644 diff --git a/images/show_all_off.png b/images/show_all_off.png old mode 100755 new mode 100644 diff --git a/images/show_all_on.png b/images/show_all_on.png old mode 100755 new mode 100644 diff --git a/images/show_off.png b/images/show_off.png old mode 100755 new mode 100644 diff --git a/images/show_on.png b/images/show_on.png old mode 100755 new mode 100644 diff --git a/images/smiley-Oo.gif b/images/smiley-Oo.gif old mode 100755 new mode 100644 index a125d0ff20..a15d974275 Binary files a/images/smiley-Oo.gif and b/images/smiley-Oo.gif differ diff --git a/images/smiley-beard.png b/images/smiley-beard.png new file mode 100644 index 0000000000..5d4b28463f Binary files /dev/null and b/images/smiley-beard.png differ diff --git a/images/smiley-brokenheart.gif b/images/smiley-brokenheart.gif old mode 100755 new mode 100644 index 79ca0c31b4..971b57fd98 Binary files a/images/smiley-brokenheart.gif and b/images/smiley-brokenheart.gif differ diff --git a/images/smiley-cool.gif b/images/smiley-cool.gif old mode 100755 new mode 100644 index ba90cc36fb..cee1c1aa3d Binary files a/images/smiley-cool.gif and b/images/smiley-cool.gif differ diff --git a/images/smiley-cry.gif b/images/smiley-cry.gif old mode 100755 new mode 100644 index 74d897a4f6..06e6ca2c25 Binary files a/images/smiley-cry.gif and b/images/smiley-cry.gif differ diff --git a/images/smiley-embarassed.gif b/images/smiley-embarassed.gif old mode 100755 new mode 100644 index 963a96b8a7..adc12e7c51 Binary files a/images/smiley-embarassed.gif and b/images/smiley-embarassed.gif differ diff --git a/images/smiley-foot-in-mouth.gif b/images/smiley-foot-in-mouth.gif old mode 100755 new mode 100644 index 16f68cc1e9..b444e5781e Binary files a/images/smiley-foot-in-mouth.gif and b/images/smiley-foot-in-mouth.gif differ diff --git a/images/smiley-frown.gif b/images/smiley-frown.gif old mode 100755 new mode 100644 index 716f55e161..9ff19850d9 Binary files a/images/smiley-frown.gif and b/images/smiley-frown.gif differ diff --git a/images/smiley-heart.gif b/images/smiley-heart.gif old mode 100755 new mode 100644 index 21c0c65308..6a11e70652 Binary files a/images/smiley-heart.gif and b/images/smiley-heart.gif differ diff --git a/images/smiley-innocent.gif b/images/smiley-innocent.gif old mode 100755 new mode 100644 index 334d49e0e6..9d747140ec Binary files a/images/smiley-innocent.gif and b/images/smiley-innocent.gif differ diff --git a/images/smiley-kiss.gif b/images/smiley-kiss.gif old mode 100755 new mode 100644 index 4efd549ed3..cc356611ee Binary files a/images/smiley-kiss.gif and b/images/smiley-kiss.gif differ diff --git a/images/smiley-laughing.gif b/images/smiley-laughing.gif old mode 100755 new mode 100644 index 1606c119e7..1bf29de795 Binary files a/images/smiley-laughing.gif and b/images/smiley-laughing.gif differ diff --git a/images/smiley-money-mouth.gif b/images/smiley-money-mouth.gif old mode 100755 new mode 100644 index ca2451e102..1e8ccd0f3d Binary files a/images/smiley-money-mouth.gif and b/images/smiley-money-mouth.gif differ diff --git a/images/smiley-sealed.gif b/images/smiley-sealed.gif old mode 100755 new mode 100644 index b33d3cca1e..98186742d2 Binary files a/images/smiley-sealed.gif and b/images/smiley-sealed.gif differ diff --git a/images/smiley-smile.gif b/images/smiley-smile.gif old mode 100755 new mode 100644 index e6a9e60d5d..b9bff40a43 Binary files a/images/smiley-smile.gif and b/images/smiley-smile.gif differ diff --git a/images/smiley-surprised.gif b/images/smiley-surprised.gif old mode 100755 new mode 100644 index cb99cdd913..b074653260 Binary files a/images/smiley-surprised.gif and b/images/smiley-surprised.gif differ diff --git a/images/smiley-thumbsup.gif b/images/smiley-thumbsup.gif old mode 100755 new mode 100644 diff --git a/images/smiley-tongue-out.gif b/images/smiley-tongue-out.gif old mode 100755 new mode 100644 index 2075dc1605..48867dc262 Binary files a/images/smiley-tongue-out.gif and b/images/smiley-tongue-out.gif differ diff --git a/images/smiley-undecided.gif b/images/smiley-undecided.gif old mode 100755 new mode 100644 index bef7e25730..28029794f3 Binary files a/images/smiley-undecided.gif and b/images/smiley-undecided.gif differ diff --git a/images/smiley-whitebeard.png b/images/smiley-whitebeard.png new file mode 100644 index 0000000000..2a1fccbb72 Binary files /dev/null and b/images/smiley-whitebeard.png differ diff --git a/images/smiley-wink.gif b/images/smiley-wink.gif old mode 100755 new mode 100644 index 9faf1aff8f..e1cefb05c9 Binary files a/images/smiley-wink.gif and b/images/smiley-wink.gif differ diff --git a/images/smiley-yell.gif b/images/smiley-yell.gif old mode 100755 new mode 100644 index 648e6e8791..5296c88365 Binary files a/images/smiley-yell.gif and b/images/smiley-yell.gif differ diff --git a/images/spencil.gif b/images/spencil.gif old mode 100755 new mode 100644 diff --git a/images/star.png b/images/star.png new file mode 100644 index 0000000000..0b00cb1893 Binary files /dev/null and b/images/star.png differ diff --git a/images/star_dummy.png b/images/star_dummy.png new file mode 100644 index 0000000000..ce11f30d4d Binary files /dev/null and b/images/star_dummy.png differ diff --git a/images/tag.png b/images/tag.png old mode 100755 new mode 100644 diff --git a/images/tag_b.png b/images/tag_b.png old mode 100755 new mode 100644 diff --git a/images/tools.png b/images/tools.png old mode 100755 new mode 100644 diff --git a/images/twopeople.png b/images/twopeople.png old mode 100755 new mode 100644 diff --git a/images/unlock_icon.gif b/images/unlock_icon.gif old mode 100755 new mode 100644 diff --git a/images/video.gif b/images/video.gif old mode 100755 new mode 100644 diff --git a/images/youtube_icon.gif b/images/youtube_icon.gif old mode 100755 new mode 100644 diff --git a/include/Contact.php b/include/Contact.php old mode 100755 new mode 100644 index baccea3055..d9949b1ef8 --- a/include/Contact.php +++ b/include/Contact.php @@ -15,6 +15,12 @@ function user_remove($uid) { call_hooks('remove_user',$r[0]); + // save username (actually the nickname as it is guaranteed + // unique), so it cannot be re-registered in the future. + + q("insert into userd ( username ) values ( '%s' )", + $r[0]['nickname'] + ); q("DELETE FROM `contact` WHERE `uid` = %d", intval($uid)); q("DELETE FROM `group` WHERE `uid` = %d", intval($uid)); diff --git a/include/EmailNotification.php b/include/EmailNotification.php old mode 100755 new mode 100644 diff --git a/include/Photo.php b/include/Photo.php old mode 100755 new mode 100644 index 1450374ffc..4d02b5c651 --- a/include/Photo.php +++ b/include/Photo.php @@ -268,9 +268,9 @@ function import_profile_photo($photo,$uid,$cid) { $photo_failure = true; if($photo_failure) { - $photo = $a->get_baseurl() . '/images/default-profile.jpg'; - $thumb = $a->get_baseurl() . '/images/default-profile-sm.jpg'; - $micro = $a->get_baseurl() . '/images/default-profile-mm.jpg'; + $photo = $a->get_baseurl() . '/images/person-175.jpg'; + $thumb = $a->get_baseurl() . '/images/person-80.jpg'; + $micro = $a->get_baseurl() . '/images/person-48.jpg'; } return(array($photo,$thumb,$micro)); diff --git a/include/Scrape.php b/include/Scrape.php old mode 100755 new mode 100644 index 8344aa7373..9c237916bc --- a/include/Scrape.php +++ b/include/Scrape.php @@ -684,7 +684,7 @@ function probe_url($url, $mode = PROBE_NORMAL) { if(! x($vcard,'photo')) { $a = get_app(); - $vcard['photo'] = $a->get_baseurl() . '/images/default-profile.jpg' ; + $vcard['photo'] = $a->get_baseurl() . '/images/person-175.jpg' ; } if(! $profile) diff --git a/include/acl_selectors.php b/include/acl_selectors.php old mode 100755 new mode 100644 index 67d8cebdeb..a5f5aff532 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -113,11 +113,13 @@ function contact_selector($selname, $selclass, $preselected = false, $options) { $str_nets = implode(',',$x['networks']); $sql_extra .= " AND `network` IN ( $str_nets ) "; } + + $tabindex = (x($options, 'tabindex') ? "tabindex=\"" . $options["tabindex"] . "\"" : ""); if($x['single']) - $o .= "\r\n"; else - $o .= "\r\n"; $r = q("SELECT `id`, `name`, `url`, `network` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `notify` != '' @@ -156,7 +158,7 @@ function contact_selector($selname, $selclass, $preselected = false, $options) { -function contact_select($selname, $selclass, $preselected = false, $size = 4, $privmail = false, $celeb = false, $privatenet = false) { +function contact_select($selname, $selclass, $preselected = false, $size = 4, $privmail = false, $celeb = false, $privatenet = false, $tabindex = null) { $a = get_app(); @@ -178,12 +180,12 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p $sql_extra .= " AND `network` IN ( 'dfrn', 'mail', 'face', 'dspr' ) "; } - + $tabindex = ($tabindex > 0 ? "tabindex=\"$tabindex\"" : ""); if($privmail) - $o .= "\r\n"; else - $o .= "\r\n"; $r = q("SELECT `id`, `name`, `url`, `network` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `notify` != '' diff --git a/include/api.php b/include/api.php old mode 100755 new mode 100644 index 013f4b97ae..ab83d63be4 --- a/include/api.php +++ b/include/api.php @@ -3,6 +3,7 @@ require_once("datetime.php"); require_once("conversation.php"); require_once("oauth.php"); + require_once("html2plain.php"); /* * Twitter-Like API * @@ -82,7 +83,7 @@ $record = $r[0]; } else { logger('API_login failure: ' . print_r($_SERVER,true), LOGGER_DEBUG); - header('WWW-Authenticate: Basic realm="Friendika"'); + header('WWW-Authenticate: Basic realm="Friendica"'); header('HTTP/1.0 401 Unauthorized'); die('This api requires login'); } @@ -120,6 +121,7 @@ if (strpos($a->query_string, ".json")>0) $type="json"; if (strpos($a->query_string, ".rss")>0) $type="rss"; if (strpos($a->query_string, ".atom")>0) $type="atom"; + if (strpos($a->query_string, ".as")>0) $type="as"; $r = call_user_func($info['func'], $a, $type); if ($r===false) return; @@ -143,6 +145,12 @@ header ("Content-Type: application/atom+xml"); return ''."\n".$r; break; + case "as": + //header ("Content-Type: application/json"); + //foreach($r as $rr) + // return json_encode($rr); + return json_encode($r); + break; } //echo "
"; var_dump($r); die();
@@ -306,10 +314,10 @@
 		}
 
 		$ret = Array(
+			'id' => intval($uinfo[0]['cid']),
 			'self' => intval($uinfo[0]['self']),
 			'uid' => intval($uinfo[0]['uid']),
-			'id' => intval($uinfo[0]['cid']),
-			'name' => $uinfo[0]['name'],
+			'name' => (($uinfo[0]['name']) ? $uinfo[0]['name'] : $uinfo[0]['nick']),
 			'screen_name' => (($uinfo[0]['nick']) ? $uinfo[0]['nick'] : $uinfo[0]['name']),
 			'location' => ($usr) ? $usr[0]['default-location'] : '',
 			'profile_image_url' => $uinfo[0]['micro'],
@@ -347,6 +355,8 @@
 	}
 
 	function api_item_get_user(&$a, $item) {
+		global $usercache;
+
 		// The author is our direct contact, in a conversation with us.
 		if(link_compare($item['url'],$item['author-link'])) {
 			return api_get_user($a,$item['cid']);
@@ -362,27 +372,40 @@
 		
 		list($nick, $name) = array_map("trim",explode("(",$item['author-name']));
 		$name=str_replace(")","",$name);
-		
+
+		if ($name == '')
+			$name = $nick;
+
+		if ($nick == '')
+			$nick = $name;
+
+		// Generating a random ID
+		if (!array_key_exists($nick, $usercache))
+			$usercache[$nick] = mt_rand(2000000, 2100000);
+
 		$ret = array(
-			'uid' => 0,
-			'id' => 0,
+			'id' => $usercache[$nick],
 			'name' => $name,
 			'screen_name' => $nick,
 			'location' => '', //$uinfo[0]['default-location'],
+			'description' => '',
 			'profile_image_url' => $item['author-avatar'],
 			'url' => $item['author-link'],
-			'contact_url' => 0,
 			'protected' => false,	#
+			'followers_count' => 0,
 			'friends_count' => 0,
 			'created_at' => '',
+			'favourites_count' => 0,
 			'utc_offset' => 0, #XXX: fix me
 			'time_zone' => '', //$uinfo[0]['timezone'],
-			'geo_enabled' => false,
 			'statuses_count' => 0,
+			'following' => 1,
+			'statusnet_blocking' => false,
+			'notifications' => false,
+			'uid' => 0,
+			'contact_url' => 0,
+			'geo_enabled' => false,
 			'lang' => 'en', #XXX: fix me
-			'description' => '',
-			'followers_count' => 0,
-			'favourites_count' => 0,
 			'contributors_enabled' => false,
 			'follow_request_sent' => false,
 			'profile_background_color' => 'cfe8f6',
@@ -393,7 +416,6 @@
 			'profile_background_image_url' => '',
 			'profile_background_tile' => false,
 			'profile_use_background_image' => false,
-			'notifications' => false,
 			'verified' => true, #XXX: fix me
 			'followers' => '', #XXX: fix me
 			'status' => array()
@@ -591,16 +613,16 @@
 				$in_reply_to_screen_name = $lastwall['reply_author'];
 			}  
 			$status_info = array(
-				'created_at' => api_date($lastwall['created']),
-				'id' => $lastwall['contact-id'],
-				'text' => strip_tags(bbcode($lastwall['body'])),
-				'source' => (($lastwall['app']) ? $lastwall['app'] : 'web'),
+				'text' => html2plain(bbcode($lastwall['body']), 0),
 				'truncated' => false,
+				'created_at' => api_date($lastwall['created']),
 				'in_reply_to_status_id' => $in_reply_to_status_id,
+				'source' => (($lastwall['app']) ? $lastwall['app'] : 'web'),
+				'id' => $lastwall['contact-id'],
 				'in_reply_to_user_id' => $in_reply_to_user_id,
-				'favorited' => false,
 				'in_reply_to_screen_name' => $in_reply_to_screen_name,
 				'geo' => '',
+				'favorited' => false,
 				'coordinates' => $lastwall['coord'],
 				'place' => $lastwall['location'],
 				'contributors' => ''					
@@ -650,7 +672,7 @@
 			$user_info['status'] = array(
 				'created_at' => api_date($lastwall['created']),
 				'id' => $lastwall['contact-id'],
-				'text' => strip_tags(bbcode($lastwall['body'])),
+				'text' => html2plain(bbcode($lastwall['body']), 0),
 				'source' => (($lastwall['app']) ? $lastwall['app'] : 'web'),
 				'truncated' => false,
 				'in_reply_to_status_id' => $in_reply_to_status_id,
@@ -686,10 +708,17 @@
 		$count = (x($_REQUEST,'count')?$_REQUEST['count']:20);
 		$page = (x($_REQUEST,'page')?$_REQUEST['page']-1:0);
 		if ($page<0) $page=0;
-		$since_id = 0;//$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
+		$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
+		$max_id = (x($_REQUEST,'max_id')?$_REQUEST['max_id']:0);
+		//$since_id = 0;//$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
 		
 		$start = $page*$count;
 
+		//$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false);
+
+		if ($max_id > 0)
+			$sql_extra = 'AND `item`.`id` <= '.intval($max_id);
+
 		$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, 
 			`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
 			`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
@@ -715,6 +744,13 @@
 			case "atom":
 			case "rss":
 				$data = api_rss_extra($a, $data, $user_info);
+				break;
+			case "as":
+				$as = api_format_as($a, $ret, $user_info);
+				$as['title'] = $a->config['sitename']." Home Timeline";
+				$as['link']['url'] = $a->get_baseurl()."/".$user_info["screen_name"]."/all";
+				return($as);
+				break;
 		}
 				
 		return  api_apply_template("timeline", $type, $data);
@@ -722,6 +758,271 @@
 	api_register_func('api/statuses/home_timeline','api_statuses_home_timeline', true);
 	api_register_func('api/statuses/friends_timeline','api_statuses_home_timeline', true);
 
+	function api_statuses_public_timeline(&$a, $type){
+		if (local_user()===false) return false;
+				
+		$user_info = api_get_user($a);
+		// get last newtork messages
+
+
+		// params
+		$count = (x($_REQUEST,'count')?$_REQUEST['count']:20);
+		$page = (x($_REQUEST,'page')?$_REQUEST['page']-1:0);
+		if ($page<0) $page=0;
+		$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
+		$max_id = (x($_REQUEST,'max_id')?$_REQUEST['max_id']:0);
+		//$since_id = 0;//$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
+		
+		$start = $page*$count;
+
+		//$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false);
+
+		if ($max_id > 0)
+			$sql_extra = 'AND `item`.`id` <= '.intval($max_id);
+
+		/*$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, 
+			`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
+			`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
+			`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
+			FROM `item`, `contact`
+			WHERE `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
+			AND `item`.`allow_cid` = ''  AND `item`.`allow_gid` = '' 
+			AND `item`.`deny_cid`  = '' AND `item`.`deny_gid`  = '' 
+			AND `item`.`private` = 0 AND `item`.`wall` = 1 AND `user`.`hidewall` = 0
+			AND `contact`.`id` = `item`.`contact-id`
+			AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
+			$sql_extra
+			AND `item`.`id`>%d
+			ORDER BY `item`.`received` DESC LIMIT %d ,%d ",
+			intval($since_id),
+			intval($start),	intval($count)
+		);*/
+	        $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, 
+	                `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
+        	        `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, 
+                	`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`,
+                	`user`.`nickname`, `user`.`hidewall`
+                	FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
+                	LEFT JOIN `user` ON `user`.`uid` = `item`.`uid`
+                	WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
+                	AND `item`.`allow_cid` = ''  AND `item`.`allow_gid` = '' 
+                	AND `item`.`deny_cid`  = '' AND `item`.`deny_gid`  = '' 
+                	AND `item`.`private` = 0 AND `item`.`wall` = 1 AND `user`.`hidewall` = 0 
+                	AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
+			$sql_extra
+			AND `item`.`id`>%d
+                	ORDER BY `received` DESC LIMIT %d, %d ",
+			intval($since_id),
+                	intval($start),
+                	intval($count));
+
+		$ret = api_format_items($r,$user_info);
+
+		
+		$data = array('$statuses' => $ret);
+		switch($type){
+			case "atom":
+			case "rss":
+				$data = api_rss_extra($a, $data, $user_info);
+				break;
+			case "as":
+				$as = api_format_as($a, $ret, $user_info);
+				$as['title'] = $a->config['sitename']." Public Timeline";
+				$as['link']['url'] = $a->get_baseurl()."/";
+				return($as);
+				break;
+		}
+				
+		return  api_apply_template("timeline", $type, $data);
+	}
+	api_register_func('api/statuses/public_timeline','api_statuses_public_timeline', true);
+
+	/**
+	 * 
+	 */
+	function api_statuses_show(&$a, $type){
+		if (local_user()===false) return false;
+
+		$user_info = api_get_user($a);
+
+		// params
+		$id = intval($a->argv[3]);
+
+		logger('API: api_statuses_show: '.$id);		
+
+		//$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false);
+
+		$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, 
+			`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
+			`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
+			`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
+			FROM `item`, `contact`
+			WHERE `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
+			AND `contact`.`id` = `item`.`contact-id`
+			AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
+			$sql_extra
+			AND `item`.`id`=%d",
+			intval($id)
+		);
+
+		$ret = api_format_items($r,$user_info);
+		
+		$data = array('$status' => $ret[0]);
+		/*switch($type){
+			case "atom":
+			case "rss":
+				$data = api_rss_extra($a, $data, $user_info);
+		}*/
+		return  api_apply_template("status", $type, $data);
+	}
+	api_register_func('api/statuses/show','api_statuses_show', true);
+
+
+	/**
+	 * 
+	 */
+	function api_statuses_repeat(&$a, $type){
+		if (local_user()===false) return false;
+
+		$user_info = api_get_user($a);
+
+		// params
+		$id = intval($a->argv[3]);
+
+		logger('API: api_statuses_repeat: '.$id);		
+
+		//$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false);
+
+		$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `contact`.`nick` as `reply_author`,
+			`contact`.`name`, `contact`.`photo`, `contact`.`url` as `reply_url`, `contact`.`rel`,
+			`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
+			`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
+			FROM `item`, `contact`
+			WHERE `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
+			AND `contact`.`id` = `item`.`contact-id`
+			AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
+			$sql_extra
+			AND `item`.`id`=%d",
+			intval($id)
+		);
+
+		$_REQUEST['body'] = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8')."[url=".$r[0]['reply_url']."]".$r[0]['reply_author']."[/url] \n".$r[0]['body'];
+		$_REQUEST['profile_uid'] = local_user();
+		$_REQUEST['type'] = 'wall';
+		$_REQUEST['api_source'] = true;
+
+		require_once('mod/item.php');
+		item_post($a);
+
+		if ($type == 'xml')
+			$ok = "true";
+		else
+			$ok = "ok";
+
+		return api_apply_template('test', $type, array('$ok' => $ok));
+	}
+	api_register_func('api/statuses/retweet','api_statuses_repeat', true);
+
+	/**
+	 * 
+	 */
+	function api_statuses_destroy(&$a, $type){
+		if (local_user()===false) return false;
+
+		$user_info = api_get_user($a);
+
+		// params
+		$id = intval($a->argv[3]);
+
+		logger('API: api_statuses_destroy: '.$id);	
+
+		require_once('include/items.php');
+		drop_item($id, false);
+
+		if ($type == 'xml')
+			$ok = "true";
+		else
+			$ok = "ok";
+
+		return api_apply_template('test', $type, array('$ok' => $ok));
+	}
+	api_register_func('api/statuses/destroy','api_statuses_destroy', true);
+
+	/**
+	 * 
+	 * http://developer.twitter.com/doc/get/statuses/mentions
+	 * 
+	 */
+	function api_statuses_mentions(&$a, $type){
+		if (local_user()===false) return false;
+				
+		$user_info = api_get_user($a);
+		// get last newtork messages
+
+
+		// params
+		$count = (x($_REQUEST,'count')?$_REQUEST['count']:20);
+		$page = (x($_REQUEST,'page')?$_REQUEST['page']-1:0);
+		if ($page<0) $page=0;
+		$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
+		$max_id = (x($_REQUEST,'max_id')?$_REQUEST['max_id']:0);
+		//$since_id = 0;//$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
+		
+		$start = $page*$count;
+
+		//$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false);
+
+		$myurl = $a->get_baseurl() . '/profile/'. $a->user['nickname'];
+		$myurl = substr($myurl,strpos($myurl,'://')+3);
+		$myurl = str_replace(array('www.','.'),array('','\\.'),$myurl);
+		$diasp_url = str_replace('/profile/','/u/',$myurl);
+		$sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` regexp '%s' or `tag` regexp '%s' or tag regexp '%s' )) ",
+			dbesc($myurl . '$'),
+			dbesc($myurl . '\\]'),
+			dbesc($diasp_url . '\\]')
+		);
+
+		if ($max_id > 0)
+			$sql_extra .= ' AND `item`.`id` <= '.intval($max_id);
+
+		$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, 
+			`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
+			`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
+			`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
+			FROM `item`, `contact`
+			WHERE `item`.`uid` = %d
+			AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
+			AND `contact`.`id` = `item`.`contact-id`
+			AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
+			$sql_extra
+			AND `item`.`id`>%d
+			ORDER BY `item`.`received` DESC LIMIT %d ,%d ",
+			intval($user_info['uid']),
+			intval($since_id),
+			intval($start),	intval($count)
+		);
+
+		$ret = api_format_items($r,$user_info);
+
+		
+		$data = array('$statuses' => $ret);
+		switch($type){
+			case "atom":
+			case "rss":
+				$data = api_rss_extra($a, $data, $user_info);
+				break;
+			case "as":
+				$as = api_format_as($a, $ret, $user_info);
+				$as["title"] = $a->config['sitename']." Mentions";
+				$as['link']['url'] = $a->get_baseurl()."/";
+				return($as);
+				break;
+		}
+				
+		return  api_apply_template("timeline", $type, $data);
+	}
+	api_register_func('api/statuses/mentions','api_statuses_mentions', true);
+	api_register_func('api/statuses/replies','api_statuses_mentions', true);
 
 
 	function api_statuses_user_timeline(&$a, $type){
@@ -740,7 +1041,8 @@
 		$count = (x($_REQUEST,'count')?$_REQUEST['count']:20);
 		$page = (x($_REQUEST,'page')?$_REQUEST['page']-1:0);
 		if ($page<0) $page=0;
-		$since_id = 0;//$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
+		$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
+		//$since_id = 0;//$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
 		
 		$start = $page*$count;
 
@@ -833,6 +1135,70 @@
 
 	api_register_func('api/favorites','api_favorites', true);
 
+	function api_format_as($a, $ret, $user_info) {
+
+		$as = array();
+		$as['title'] = $a->config['sitename']." Public Timeline";
+		$items = array();
+		foreach ($ret as $item) {
+			$singleitem["actor"]["displayName"] = $item["user"]["name"];
+			$singleitem["actor"]["id"] = $item["user"]["contact_url"];
+			$avatar[0]["url"] = $item["user"]["profile_image_url"];
+			$avatar[0]["rel"] = "avatar";
+			$avatar[0]["type"] = "";
+			$avatar[0]["width"] = 96;
+			$avatar[0]["height"] = 96;
+			$avatar[1]["url"] = $item["user"]["profile_image_url"];
+			$avatar[1]["rel"] = "avatar";
+			$avatar[1]["type"] = "";
+			$avatar[1]["width"] = 48;
+			$avatar[1]["height"] = 48;
+			$avatar[2]["url"] = $item["user"]["profile_image_url"];
+			$avatar[2]["rel"] = "avatar";
+			$avatar[2]["type"] = "";
+			$avatar[2]["width"] = 24;
+			$avatar[2]["height"] = 24;
+			$singleitem["actor"]["avatarLinks"] = $avatar;
+
+			$singleitem["actor"]["image"]["url"] = $item["user"]["profile_image_url"];
+			$singleitem["actor"]["image"]["rel"] = "avatar";
+			$singleitem["actor"]["image"]["type"] = "";
+			$singleitem["actor"]["image"]["width"] = 96;
+			$singleitem["actor"]["image"]["height"] = 96;
+			$singleitem["actor"]["type"] = "person";
+			$singleitem["actor"]["url"] = $item["person"]["contact_url"];
+			$singleitem["actor"]["statusnet:profile_info"]["local_id"] = $item["user"]["id"];
+			$singleitem["actor"]["statusnet:profile_info"]["following"] = $item["user"]["following"] ? "true" : "false";
+			$singleitem["actor"]["statusnet:profile_info"]["blocking"] = "false";
+			$singleitem["actor"]["contact"]["preferredUsername"] = $item["user"]["screen_name"];
+			$singleitem["actor"]["contact"]["displayName"] = $item["user"]["name"];
+			$singleitem["actor"]["contact"]["addresses"] = "";
+
+			$singleitem["body"] = $item["text"];
+			$singleitem["object"]["displayName"] = $item["text"];
+			$singleitem["object"]["id"] = $item["url"];
+			$singleitem["object"]["type"] = "note";
+			$singleitem["object"]["url"] = $item["url"];
+			//$singleitem["context"] =;
+			$singleitem["postedTime"] = date("c", strtotime($item["published"]));
+			$singleitem["provider"]["objectType"] = "service";
+			$singleitem["provider"]["displayName"] = "Test";
+			$singleitem["provider"]["url"] = "http://test.tld";
+			$singleitem["title"] = $item["text"];
+			$singleitem["verb"] = "post";
+			$singleitem["statusnet:notice_info"]["local_id"] = $item["id"];
+				$singleitem["statusnet:notice_info"]["source"] = $item["source"];
+				$singleitem["statusnet:notice_info"]["favorite"] = "false";
+				$singleitem["statusnet:notice_info"]["repeated"] = "false";
+				//$singleitem["original"] = $item;
+				$items[] = $singleitem;
+		}
+		$as['items'] = $items;
+		$as['link']['url'] = $a->get_baseurl()."/".$user_info["screen_name"]."/all";
+		$as['link']['rel'] = "alternate";
+		$as['link']['type'] = "text/html";
+		return($as);
+	}
 	
 	function api_format_items($r,$user_info) {
 
@@ -846,33 +1212,64 @@
 		foreach($r as $item) {
 			localize_item($item);
 			$status_user = (($item['cid']==$user_info['id'])?$user_info: api_item_get_user($a,$item));
+
+			if ($item['parent']!=$item['id']) {
+				$r = q("select id from item where parent=%s and id<%s order by id desc limit 1", 
+					intval($item['parent']), intval($item['id']));
+				if ($r)
+					$in_reply_to_status_id = $r[0]['id'];
+				else
+					$in_reply_to_status_id = $item['parent'];
+
+				$r = q("select `item`.`contact-id`, `contact`.nick, `item`.`author-name` from item, contact 
+					where `contact`.`id` = `item`.`contact-id` and `item`.id=%d", intval($in_reply_to_status_id));
+
+				$in_reply_to_screen_name = $r[0]['author-name'];
+				$in_reply_to_user_id = $r[0]['contact-id'];
+
+			} else {
+				$in_reply_to_screen_name = '';
+				$in_reply_to_user_id = 0;
+				$in_reply_to_status_id = 0;
+			}
+
 			$status = array(
-				'created_at'=> api_date($item['created']),
-				'published' => api_date($item['created']),
-				'updated'   => api_date($item['edited']),
-				'id'		=> intval($item['id']),
-				'message_id' => $item['uri'],
-				'text'		=> strip_tags(bbcode($item['body'])),
-				'statusnet_html'		=> bbcode($item['body']),
-				'source'    => (($item['app']) ? $item['app'] : 'web'),
-				'url'		=> ($item['plink']!=''?$item['plink']:$item['author-link']),
+				'text'		=> trim($item['title']." \n".html2plain(bbcode($item['body']), 0)),
 				'truncated' => False,
-				'in_reply_to_status_id' => ($item['parent']!=$item['id']? intval($item['parent']):''),
-				'in_reply_to_user_id' => '',
-				'favorited' => $item['starred'] ? true : false,
-				'in_reply_to_screen_name' => '',
+				'created_at'=> api_date($item['created']),
+				'in_reply_to_status_id' => $in_reply_to_status_id,
+				'source'    => (($item['app']) ? $item['app'] : 'web'),
+				'id'		=> intval($item['id']),
+				'in_reply_to_user_id' => $in_reply_to_user_id,
+				'in_reply_to_screen_name' => $in_reply_to_screen_name,
 				'geo' => '',
-				'coordinates' => $item['coord'],
-				'place' => $item['location'],
-				'contributors' => '',
-				'annotations'  => '',
-				'entities'  => '',
+				'favorited' => $item['starred'] ? true : false,
 				'user' =>  $status_user ,
-				'objecttype' => (($item['object-type']) ? $item['object-type'] : ACTIVITY_OBJ_NOTE),
-				'verb' => (($item['verb']) ? $item['verb'] : ACTIVITY_POST),
-				'self' => $a->get_baseurl()."/api/statuses/show/".$item['id'].".".$type,
-				'edit' => $a->get_baseurl()."/api/statuses/show/".$item['id'].".".$type,				
+				'statusnet_html'		=> bbcode($item['body']),
+				'statusnet_conversation_id'	=> 0,
 			);
+
+			// Seesmic doesn't like the following content
+			if ($_SERVER['HTTP_USER_AGENT'] != 'Seesmic') {
+				$status2 = array(
+					'updated'   => api_date($item['edited']),
+					'published' => api_date($item['created']),
+					'message_id' => $item['uri'],
+					'url'		=> ($item['plink']!=''?$item['plink']:$item['author-link']),
+					'coordinates' => $item['coord'],
+					'place' => $item['location'],
+					'contributors' => '',
+					'annotations'  => '',
+					'entities'  => '',
+					'objecttype' => (($item['object-type']) ? $item['object-type'] : ACTIVITY_OBJ_NOTE),
+					'verb' => (($item['verb']) ? $item['verb'] : ACTIVITY_POST),
+					'self' => $a->get_baseurl()."/api/statuses/show/".$item['id'].".".$type,
+					'edit' => $a->get_baseurl()."/api/statuses/show/".$item['id'].".".$type,
+				);
+
+				$status = array_merge($status, $status2);
+			}
+
 			$ret[]=$status;
 		};
 		return $ret;
@@ -882,17 +1279,31 @@
 	function api_account_rate_limit_status(&$a,$type) {
 
 		$hash = array(
+			  'reset_time_in_seconds' => strtotime('now + 1 hour'),
 			  'remaining_hits' => (string) 150,
 			  'hourly_limit' => (string) 150,
 			  'reset_time' => datetime_convert('UTC','UTC','now + 1 hour',ATOM_TIME),
-			  'reset_time_in_seconds' => strtotime('now + 1 hour')
 		);
+		if ($type == "xml")
+			$hash['resettime_in_seconds'] = $hash['reset_time_in_seconds'];
 
 		return api_apply_template('ratelimit', $type, array('$hash' => $hash));
 
 	}
 	api_register_func('api/account/rate_limit_status','api_account_rate_limit_status',true);
 
+	function api_help_test(&$a,$type) {
+
+		if ($type == 'xml')
+			$ok = "true";
+		else
+			$ok = "ok";
+
+		return api_apply_template('test', $type, array('$ok' => $ok));
+
+	}
+	api_register_func('api/help/test','api_help_test',true);
+
 	/**
 	 *  https://dev.twitter.com/docs/api/1/get/statuses/friends 
 	 *  This function is deprecated by Twitter
@@ -1075,7 +1486,7 @@
 					'recipient_screen_name'=> $recipient['screen_name'],
 					'recipient'=> $recipient,
 					
-					'text'=> $item['title']."\n".strip_tags(bbcode($item['body'])) ,
+					'text'=> $item['title']."\n".html2plain(bbcode($item['body']), 0) ,
 					
 			);
 		
@@ -1144,7 +1555,7 @@
 				'recipient_screen_name'=> $recipient['screen_name'],
 				'recipient'=> $recipient,
 				
-				'text'=> $item['title']."\n".strip_tags(bbcode($item['body'])) ,
+				'text'=> $item['title']."\n".html2plain(bbcode($item['body']), 0) ,
 				
 			);
 			
@@ -1197,4 +1608,31 @@
 	api_register_func('api/oauth/request_token', 'api_oauth_request_token', false);
 	api_register_func('api/oauth/access_token', 'api_oauth_access_token', false);
 
+/*
+Not implemented by now:
+favorites
+favorites/create
+favorites/destroy
+statuses/retweets_of_me
+friendships/create
+friendships/destroy
+friendships/exists
+friendships/show
+account/update_location
+account/update_profile_background_image
+account/update_profile_image
+blocks/create
+blocks/destroy
+oauth/authorize
 
+Not implemented in status.net:
+statuses/retweeted_to_me
+statuses/retweeted_by_me
+direct_messages/destroy
+account/end_session
+account/update_delivery_device
+notifications/follow
+notifications/leave
+blocks/exists
+blocks/blocking
+*/
diff --git a/include/attach.php b/include/attach.php
old mode 100755
new mode 100644
diff --git a/include/auth.php b/include/auth.php
old mode 100755
new mode 100644
index fc52684e64..1341f3bb8a
--- a/include/auth.php
+++ b/include/auth.php
@@ -24,7 +24,7 @@ if((isset($_SESSION)) && (x($_SESSION,'authenticated')) && ((! (x($_POST,'auth-p
 	if(((x($_POST,'auth-params')) && ($_POST['auth-params'] === 'logout')) || ($a->module === 'logout')) {
 	
 		// process logout request
-
+		call_hooks("logging_out");
 		nuke_session();
 		info( t('Logged out.') . EOL);
 		goaway(z_root());
@@ -77,7 +77,7 @@ else {
 
 			$noid = get_config('system','no_openid');
 
-			$openid_url = trim(  (strlen($_POST['openid_url'])?$_POST['openid_url']:$_POST['username']) );
+			$openid_url = trim((strlen($_POST['openid_url'])?$_POST['openid_url']:$_POST['username']) );
 
 			// validate_url alters the calling parameter
 
@@ -94,37 +94,21 @@ else {
 
 			// Otherwise it's probably an openid.
 
+                        try {
 			require_once('library/openid.php');
 			$openid = new LightOpenID;
 			$openid->identity = $openid_url;
 			$_SESSION['openid'] = $openid_url;
 			$a = get_app();
-			$openid->returnUrl = $a->get_baseurl() . '/openid'; 
-
-			$r = q("SELECT `uid` FROM `user` WHERE `openid` = '%s' LIMIT 1",
-				dbesc($openid_url)
-			);
-			if(count($r)) { 
-				// existing account
-				goaway($openid->authUrl());
-				// NOTREACHED	
-			}
-			else {
-				if($a->config['register_policy'] == REGISTER_CLOSED) {
-					$a = get_app();
-					notice( t('Login failed.') . EOL);
-					goaway(z_root());
-					// NOTREACHED
-				}
-				// new account
-				$_SESSION['register'] = 1;
-				$openid->required = array('namePerson/friendly', 'contact/email', 'namePerson');
-				$openid->optional = array('namePerson/first','media/image/aspect11','media/image/default');
-				goaway($openid->authUrl());
-				// NOTREACHED	
-			}
+			$openid->returnUrl = $a->get_baseurl(true) . '/openid'; 
+                        goaway($openid->authUrl());
+                        } catch (Exception $e) {
+                            notice( t('We encountered a problem while logging in with the OpenID you provided. Please check the correct spelling of the ID.').'

'. t('The error message was:').' '.$e->getMessage()); + } + // NOTREACHED } } + if((x($_POST,'auth-params')) && $_POST['auth-params'] === 'login') { $record = null; @@ -165,7 +149,7 @@ else { } if((! $record) || (! count($record))) { - logger('authenticate: failed login attempt: ' . notags(trim($_POST['username']))); + logger('authenticate: failed login attempt: ' . notags(trim($_POST['username'])) . ' from IP ' . $_SERVER['REMOTE_ADDR']); notice( t('Login failed.') . EOL ); goaway(z_root()); } diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php old mode 100755 new mode 100644 diff --git a/include/bbcode.php b/include/bbcode.php index cff26f5c8e..3697f1fc5d 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -189,8 +189,29 @@ function bbcode($Text,$preserve_nl = false) { // Check for [code] text $Text = preg_replace("/\[code\](.*?)\[\/code\]/ism","$CodeLayout", $Text); + // Declare the format for [spoiler] layout + $SpoilerLayout = '
$1
'; + + // Check for [spoiler] text + // handle nested quotes + $endlessloop = 0; + while ((strpos($Text, "[/spoiler]") !== false) and (strpos($Text, "[spoiler]") !== false) and (++$endlessloop < 20)) + $Text = preg_replace("/\[spoiler\](.*?)\[\/spoiler\]/ism","$SpoilerLayout", $Text); + + // Check for [spoiler=Author] text + + $t_wrote = t('$1 wrote:'); + + // handle nested quotes + $endlessloop = 0; + while ((strpos($Text, "[/spoiler]")!== false) and (strpos($Text, "[spoiler=") !== false) and (++$endlessloop < 20)) + $Text = preg_replace("/\[spoiler=[\"\']*(.*?)[\"\']*\](.*?)\[\/spoiler\]/ism", + "
" . $t_wrote . "
$2
", + $Text); + // Declare the format for [quote] layout $QuoteLayout = '
$1
'; + // Check for [quote] text // handle nested quotes $endlessloop = 0; @@ -205,17 +226,21 @@ function bbcode($Text,$preserve_nl = false) { $endlessloop = 0; while ((strpos($Text, "[/quote]")!== false) and (strpos($Text, "[quote=") !== false) and (++$endlessloop < 20)) $Text = preg_replace("/\[quote=[\"\']*(.*?)[\"\']*\](.*?)\[\/quote\]/ism", - "
" . $t_wrote . " $2
", + "
" . $t_wrote . "
$2
", $Text); // [img=widthxheight]image source[/img] - $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '', $Text); + //$Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '', $Text); + $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '', $Text); // Images // [img]pathtoimage[/img] $Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '' . t('Image/photo') . '', $Text); + $Text = preg_replace("/\[video\](.*?\.(ogg|ogv|oga|ogm|webm|mp4))\[\/video\]/ism", '', $Text); + + $Text = preg_replace("/\[audio\](.*?\.(ogg|ogv|oga|ogm|webm|mp4|mp3))\[\/audio\]/ism", '', $Text); // Try to Oembed $Text = preg_replace_callback("/\[video\](.*?)\[\/video\]/ism", 'tryoembed', $Text); @@ -224,9 +249,6 @@ function bbcode($Text,$preserve_nl = false) { // html5 video and audio - $Text = preg_replace("/\[video\](.*?)\[\/video\]/ism", '', $Text); - - $Text = preg_replace("/\[audio\](.*?)\[\/audio\]/ism", '', $Text); $Text = preg_replace("/\[iframe\](.*?)\[\/iframe\]/ism", '', $Text); diff --git a/include/cache.php b/include/cache.php old mode 100755 new mode 100644 diff --git a/include/config.php b/include/config.php index 2cddda0b8d..4cff38090c 100755 --- a/include/config.php +++ b/include/config.php @@ -80,6 +80,7 @@ function set_config($family,$key,$value) { // manage array value $dbvalue = (is_array($value)?serialize($value):$value); + $dbvalue = (is_bool($value) ? intval($value) : $value); if(get_config($family,$key,true) === false) { $a->config[$family][$key] = $value; diff --git a/include/contact_selectors.php b/include/contact_selectors.php old mode 100755 new mode 100644 diff --git a/include/contact_widgets.php b/include/contact_widgets.php old mode 100755 new mode 100644 index caa0572d20..e0f37f078f --- a/include/contact_widgets.php +++ b/include/contact_widgets.php @@ -15,8 +15,6 @@ function findpeople_widget() { $a = get_app(); - $inv = (($a->config['register_policy'] != REGISTER_CLOSED) ? t('Invite Friends') : ''); - if(get_config('system','invitation_only')) { $x = get_pconfig(local_user(),'system','invites_remaining'); if($x || is_site_admin()) { @@ -34,7 +32,7 @@ function findpeople_widget() { '$findthem' => t('Find'), '$suggest' => t('Friend Suggestions'), '$similar' => t('Similar Interests'), - '$inv' => $inv + '$inv' => t('Invite Friends') )); } @@ -48,7 +46,7 @@ function networks_widget($baseurl,$selected = '') { return ''; - $r = q("select distinct(network) from contact where uid = %d", + $r = q("select distinct(network) from contact where uid = %d and self = 0", intval(local_user()) ); @@ -75,4 +73,61 @@ function networks_widget($baseurl,$selected = '') { )); } +function fileas_widget($baseurl,$selected = '') { + $a = get_app(); + if(! local_user()) + return ''; + + $saved = get_pconfig(local_user(),'system','filetags'); + if(! strlen($saved)) + return; + + $matches = false; + $terms = array(); + $cnt = preg_match_all('/\[(.*?)\]/',$saved,$matches,PREG_SET_ORDER); + if($cnt) { + foreach($matches as $mtch) { + $unescaped = xmlify(file_tag_decode($mtch[1])); + $terms[] = array('name' => $unescaped,'selected' => (($selected == $unescaped) ? 'selected' : '')); + } + } + + return replace_macros(get_markup_template('fileas_widget.tpl'),array( + '$title' => t('Saved Folders'), + '$desc' => '', + '$sel_all' => (($selected == '') ? 'selected' : ''), + '$all' => t('Everything'), + '$terms' => $terms, + '$base' => $baseurl, + + )); +} + +function categories_widget($baseurl,$selected = '') { + $a = get_app(); + + $saved = get_pconfig($a->profile['profile_uid'],'system','filetags'); + if(! strlen($saved)) + return; + + $matches = false; + $terms = array(); + $cnt = preg_match_all('/<(.*?)>/',$saved,$matches,PREG_SET_ORDER); + if($cnt) { + foreach($matches as $mtch) { + $unescaped = xmlify(file_tag_decode($mtch[1])); + $terms[] = array('name' => $unescaped,'selected' => (($selected == $unescaped) ? 'selected' : '')); + } + } + + return replace_macros(get_markup_template('categories_widget.tpl'),array( + '$title' => t('Categories'), + '$desc' => '', + '$sel_all' => (($selected == '') ? 'selected' : ''), + '$all' => t('Everything'), + '$terms' => $terms, + '$base' => $baseurl, + + )); +} diff --git a/include/conversation.php b/include/conversation.php old mode 100755 new mode 100644 index f4740688cd..df92a40ed0 --- a/include/conversation.php +++ b/include/conversation.php @@ -94,9 +94,9 @@ function localize_item(&$item){ } - $A = '[url=' . $Alink . ']' . $Aname . '[/url]'; - $B = '[url=' . $Blink . ']' . $Bname . '[/url]'; - if ($Bphoto!="") $Bphoto = '[url=' . $Blink . '][img]' . $Bphoto . '[/img][/url]'; + $A = '[url=' . zrl($Alink) . ']' . $Aname . '[/url]'; + $B = '[url=' . zrl($Blink) . ']' . $Bname . '[/url]'; + if ($Bphoto!="") $Bphoto = '[url=' . zrl($Blink) . '][img]' . $Bphoto . '[/img][/url]'; $item['body'] = sprintf( t('%1$s is now friends with %2$s'), $A, $B)."\n\n\n".$Bphoto; @@ -108,8 +108,8 @@ function localize_item(&$item){ if(count($r)==0) return; $obj=$r[0]; - $author = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]'; - $objauthor = '[url=' . $obj['author-link'] . ']' . $obj['author-name'] . '[/url]'; + $author = '[url=' . zrl($item['author-link']) . ']' . $item['author-name'] . '[/url]'; + $objauthor = '[url=' . zrl($obj['author-link']) . ']' . $obj['author-name'] . '[/url]'; switch($obj['verb']){ case ACTIVITY_POST: @@ -158,14 +158,21 @@ function localize_item(&$item){ $target = $r[0]; $Bname = $target['author-name']; $Blink = $target['author-link']; - $A = '[url=' . $Alink . ']' . $Aname . '[/url]'; - $B = '[url=' . $Blink . ']' . $Bname . '[/url]'; + $A = '[url=' . zrl($Alink) . ']' . $Aname . '[/url]'; + $B = '[url=' . zrl($Blink) . ']' . $Bname . '[/url]'; $P = '[url=' . $target['plink'] . ']' . t('post/item') . '[/url]'; $item['body'] = sprintf( t('%1$s marked %2$s\'s %3$s as favorite'), $A, $B, $P)."\n"; } } } + $matches = null; + if(preg_match_all('/@\[url=(.*?)\]/is',$item['body'],$matches,PREG_SET_ORDER)) { + foreach($matches as $mtch) { + if(! strpos($mtch[1],'zrl=')) + $item['body'] = str_replace($mtch[0],'@[url=' . zrl($mtch[1]). ']',$item['body']); + } + } } @@ -179,11 +186,15 @@ function localize_item(&$item){ * that are based on unique features of the calling module. * */ - if(!function_exists('conversation')){ + +if(!function_exists('conversation')) { function conversation(&$a, $items, $mode, $update, $preview = false) { + require_once('bbcode.php'); + $ssl_state = ((local_user()) ? true : false); + $profile_owner = 0; $page_writeable = false; @@ -217,7 +228,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { if($update) $return_url = $_SESSION['return_url']; else - $return_url = $_SESSION['return_url'] = $a->cmd; + $return_url = $_SESSION['return_url'] = $a->query_string; load_contact_links(local_user()); @@ -239,7 +250,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { $threads = array(); $threadsid = -1; - if(count($items)) { + if($items && count($items)) { if($mode === 'network-new' || $mode === 'search' || $mode === 'community') { @@ -272,13 +283,16 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { if($item['author-link'] && (! $item['author-name'])) $profile_name = $item['author-link']; + + $sp = false; $profile_link = best_link_url($item,$sp); - if($sp) - $sparkle = ' sparkle'; if($profile_link === 'mailbox') $profile_link = ''; - + if($sp) + $sparkle = ' sparkle'; + else + $profile_link = zrl($profile_link); $normalised = normalise_link((strlen($item['author-link'])) ? $item['author-link'] : $item['url']); if(($normalised != 'mailbox') && (x($a->contacts[$normalised]))) @@ -343,7 +357,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { 'like' => '', 'dislike' => '', 'comment' => '', - 'conv' => (($preview) ? '' : array('href'=> $a->get_baseurl() . '/display/' . $nickname . '/' . $item['id'], 'title'=> t('View in context'))), + 'conv' => (($preview) ? '' : array('href'=> $a->get_baseurl($ssl_state) . '/display/' . $nickname . '/' . $item['id'], 'title'=> t('View in context'))), 'previewing' => $previewing, 'wait' => t('Please wait'), ); @@ -373,7 +387,8 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { $comments[$item['parent']] = 1; else $comments[$item['parent']] += 1; - } + } elseif(! x($comments,$item['parent'])) + $comments[$item['parent']] = 0; // avoid notices later on } // map all the like/dislike activities for each parent item @@ -418,26 +433,6 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { $toplevelprivate = (($toplevelpost && $item['private']) ? true : false); $item_writeable = (($item['writable'] || $item['self']) ? true : false); - // DISABLED - /* - if($blowhard == $item['cid'] && (! $item['self']) && ($mode != 'profile') && ($mode != 'notes')) { - $blowhard_count ++; - if($blowhard_count == 3) { - $o .= '' . ''; - $blowhard_count = 0; - } - // END DISABLED - */ - $comments_seen = 0; $comments_collapsed = false; $comment_lastcollapsed = false; @@ -445,13 +440,16 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { $threadsid++; $threads[$threadsid]['id'] = $item['item_id']; + $threads[$threadsid]['private'] = $item['private']; $threads[$threadsid]['items'] = array(); } else { - // prevent private email from leaking into public conversation - if((! $toplevelpost) && (! $toplevelprivate) && ($item['private']) && ($profile_owner != local_user())) + + // prevent private email reply to public conversation from leaking. + if($item['private'] && ! $threads[$threadsid]['private']) continue; + $comments_seen ++; $comment_lastcollapsed = false; $comment_firstcollapsed = false; @@ -475,7 +473,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { $comment_lastcollapsed = true; } - $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ; + $redirect_url = $a->get_baseurl($ssl_state) . '/redir/' . $item['cid'] ; $lock = ((($item['private']) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid'])))) @@ -496,13 +494,13 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { // This will have been stored in $a->page_contact by our calling page. // Put this person on the left of the wall-to-wall notice. - $owner_url = $a->page_contact['url']; + $owner_url = zrl($a->page_contact['url']); $owner_photo = $a->page_contact['thumb']; $owner_name = $a->page_contact['name']; $template = $wallwall; $commentww = 'ww'; } - if((! $item['wall']) && (strlen($item['owner-link'])) && ($item['owner-link'] != $item['author-link'])) { + if((! $item['wall']) && (strlen($item['owner-link'])) && (! link_compare($item['owner-link'],$item['author-link']))) { // Could be anybody. @@ -513,10 +511,12 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { $commentww = 'ww'; // If it is our contact, use a friendly redirect link if((link_compare($item['owner-link'],$item['url'])) - && ($item['network'] === 'dfrn')) { + && ($item['network'] === NETWORK_DFRN)) { $owner_url = $redirect_url; $osparkle = ' sparkle'; } + else + $owner_url = zrl($owner_url); } } @@ -532,9 +532,12 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { if ($shareable) $likebuttons['share'] = array( t('Share this'), t('share')); } + $qc = $qcomment = null; - $qc = ((local_user()) ? get_pconfig(local_user(),'qcomment','words') : null); - $qcomment = (($qc) ? explode("\n",$qc) : null); + if(in_array('qcomment',$a->plugins)) { + $qc = ((local_user()) ? get_pconfig(local_user(),'qcomment','words') : null); + $qcomment = (($qc) ? explode("\n",$qc) : null); + } if(($show_comment_box) || (($show_comment_box == false) && ($override_comment_box == false) && ($item['last-child']))) { $comment = replace_macros($cmnt_tpl,array( @@ -557,7 +560,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { } $edpost = (((($profile_owner == local_user()) && ($toplevelpost) && (intval($item['wall']) == 1)) || ($mode === 'notes')) - ? array($a->get_baseurl()."/editpost/".$item['id'], t("Edit")) + ? array($a->get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit")) : False); @@ -574,24 +577,28 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { ); $star = false; + $filer = false; + $isstarred = "unstarred"; - if ($profile_owner == local_user() && $toplevelpost) { - $isstarred = (($item['starred']) ? "starred" : "unstarred"); + if ($profile_owner == local_user()) { + if($toplevelpost) { + $isstarred = (($item['starred']) ? "starred" : "unstarred"); - $star = array( - 'do' => t("add star"), - 'undo' => t("remove star"), - 'toggle' => t("toggle star status"), - 'classdo' => (($item['starred']) ? "hidden" : ""), - 'classundo' => (($item['starred']) ? "" : "hidden"), - 'starred' => t('starred'), - 'tagger' => t("add tag"), - 'classtagger' => "", - ); + $star = array( + 'do' => t("add star"), + 'undo' => t("remove star"), + 'toggle' => t("toggle star status"), + 'classdo' => (($item['starred']) ? "hidden" : ""), + 'classundo' => (($item['starred']) ? "" : "hidden"), + 'starred' => t('starred'), + 'tagger' => t("add tag"), + 'classtagger' => "", + ); + } + $filer = t("save to folder"); } - $photo = $item['photo']; $thumb = $item['thumb']; @@ -604,14 +611,14 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { if($item['author-link'] && (! $item['author-name'])) $profile_name = $item['author-link']; - $sp = false; $profile_link = best_link_url($item,$sp); - if($sp) - $sparkle = ' sparkle'; - if($profile_link === 'mailbox') $profile_link = ''; + if($sp) + $sparkle = ' sparkle'; + else + $profile_link = zrl($profile_link); $normalised = normalise_link((strlen($item['author-link'])) ? $item['author-link'] : $item['url']); if(($normalised != 'mailbox') && (x($a->contacts,$normalised))) @@ -657,7 +664,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { // template to use to render item (wall, walltowall, search) 'template' => $template, - 'type' => implode("",array_slice(split("/",$item['verb']),-1)), + 'type' => implode("",array_slice(explode("/",$item['verb']),-1)), 'tags' => $tags, 'body' => template_escape($body), 'text' => strip_tags(template_escape($body)), @@ -685,6 +692,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { 'edpost' => $edpost, 'isstarred' => $isstarred, 'star' => $star, + 'filer' => $filer, 'drop' => $drop, 'vote' => $likebuttons, 'like' => $like, @@ -706,7 +714,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { $page_template = get_markup_template("conversation.tpl"); $o .= replace_macros($page_template, array( - '$baseurl' => $a->get_baseurl(), + '$baseurl' => $a->get_baseurl($ssl_state), '$mode' => $mode, '$user' => $a->user, '$threads' => $threads, @@ -716,7 +724,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { return $o; }} -function best_link_url($item,&$sparkle) { +function best_link_url($item,&$sparkle,$ssl_state = false) { $a = get_app(); @@ -728,7 +736,7 @@ function best_link_url($item,&$sparkle) { if((local_user()) && (local_user() == $item['uid'])) { if(isset($a->contacts) && x($a->contacts,$clean_url)) { if($a->contacts[$clean_url]['network'] === NETWORK_DFRN) { - $best_url = $a->get_baseurl() . '/redir/' . $a->contacts[$clean_url]['id']; + $best_url = $a->get_baseurl($ssl_state) . '/redir/' . $a->contacts[$clean_url]['id']; $sparkle = true; } else @@ -749,10 +757,14 @@ function best_link_url($item,&$sparkle) { if(! function_exists('item_photo_menu')){ function item_photo_menu($item){ $a = get_app(); - - if (local_user() && (! count($a->contacts))) - load_contact_links(local_user()); + $ssl_state = false; + + if(local_user()) { + $ssl_state = true; + if(! count($a->contacts)) + load_contact_links(local_user()); + } $contact_url=""; $pm_url=""; $status_link=""; @@ -760,7 +772,7 @@ function item_photo_menu($item){ $posts_link=""; $sparkle = false; - $profile_link = best_link_url($item,$sparkle); + $profile_link = best_link_url($item,$sparkle,$ssl_state); if($profile_link === 'mailbox') $profile_link = ''; @@ -769,9 +781,11 @@ function item_photo_menu($item){ $status_link = $profile_link . "?url=status"; $photos_link = $profile_link . "?url=photos"; $profile_link = $profile_link . "?url=profile"; - $pm_url = $a->get_baseurl() . '/message/new/' . $cid; + $pm_url = $a->get_baseurl($ssl_state) . '/message/new/' . $cid; + $zurl = ''; } else { + $profile_link = zrl($profile_link); if(local_user() && local_user() == $item['uid'] && link_compare($item['url'],$item['author-link'])) { $cid = $item['contact-id']; } @@ -780,14 +794,25 @@ function item_photo_menu($item){ } } if(($cid) && (! $item['self'])) { - $contact_url = $a->get_baseurl() . '/contacts/' . $cid; - $posts_link = $a->get_baseurl() . '/network/?cid=' . $cid; + $contact_url = $a->get_baseurl($ssl_state) . '/contacts/' . $cid; + $posts_link = $a->get_baseurl($ssl_state) . '/network/?cid=' . $cid; + + $clean_url = normalise_link($item['author-link']); + + if((local_user()) && (local_user() == $item['uid'])) { + if(isset($a->contacts) && x($a->contacts,$clean_url)) { + if($a->contacts[$clean_url]['network'] === NETWORK_DIASPORA) { + $pm_url = $a->get_baseurl($ssl_state) . '/message/new/' . $cid; + } + } + } + } $menu = Array( t("View status") => $status_link, t("View profile") => $profile_link, - t("View photos") => $photos_link, + t("View photos") => $photos_link, t("View recent") => $posts_link, t("Edit contact") => $contact_url, t("Send PM") => $pm_url, @@ -817,9 +842,11 @@ function like_puller($a,$item,&$arr,$mode) { if((activity_match($item['verb'],$verb)) && ($item['id'] != $item['parent'])) { $url = $item['author-link']; if((local_user()) && (local_user() == $item['uid']) && ($item['network'] === 'dfrn') && (! $item['self']) && (link_compare($item['author-link'],$item['url']))) { - $url = $a->get_baseurl() . '/redir/' . $item['contact-id']; + $url = $a->get_baseurl(true) . '/redir/' . $item['contact-id']; $sparkle = ' class="sparkle" '; } + else + $url = zrl($url); if(! ((isset($arr[$item['parent'] . '-l'])) && (is_array($arr[$item['parent'] . '-l'])))) $arr[$item['parent'] . '-l'] = array(); if(! isset($arr[$item['parent']])) @@ -879,7 +906,7 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) { $a->page['htmlhead'] .= replace_macros($tpl, array( '$newpost' => 'true', - '$baseurl' => $a->get_baseurl(), + '$baseurl' => $a->get_baseurl(true), '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), '$geotag' => $geotag, '$nickname' => $x['nickname'], @@ -888,8 +915,8 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) { '$vidurl' => t("Please enter a video link/URL:"), '$audurl' => t("Please enter an audio link/URL:"), '$term' => t('Tag term:'), - '$whereareu' => t('Where are you right now?'), - '$title' => t('Enter a title for this item') + '$fileas' => t('Save to Folder:'), + '$whereareu' => t('Where are you right now?') )); @@ -929,8 +956,8 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) { $o .= replace_macros($tpl,array( '$return_path' => $a->cmd, - '$action' => $a->get_baseurl().'/item', - '$share' => (($x['button']) ? $x['button'] : t('Share')), + '$action' => $a->get_baseurl(true) . '/item', + '$share' => (x($x,'button') ? $x['button'] : t('Share')), '$upload' => t('Upload photo'), '$shortupload' => t('upload photo'), '$attach' => t('Attach file'), @@ -947,13 +974,15 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) { '$shortnoloc' => t('clear location'), '$title' => "", '$placeholdertitle' => t('Set title'), + '$category' => "", + '$placeholdercategory' => t('Categories (comma-separated list)'), '$wait' => t('Please wait'), '$permset' => t('Permission settings'), '$shortpermset' => t('permissions'), '$ptyp' => (($notes_cid) ? 'note' : 'wall'), '$content' => '', '$post_id' => '', - '$baseurl' => $a->get_baseurl(), + '$baseurl' => $a->get_baseurl(true), '$defloc' => $x['default_location'], '$visitor' => $x['visitor'], '$pvisit' => (($notes_cid) ? 'none' : $x['visitor']), @@ -995,8 +1024,8 @@ function conv_sort($arr,$order) { usort($parents,'sort_thr_commented'); if(count($parents)) - foreach($parents as $x) - $x['children'] = array(); + foreach($parents as $i=>$_x) + $parents[$i]['children'] = array(); foreach($arr as $x) { if($x['id'] != $x['parent']) { diff --git a/include/cronhooks.php b/include/cronhooks.php old mode 100755 new mode 100644 diff --git a/include/crypto.php b/include/crypto.php old mode 100755 new mode 100644 diff --git a/include/datetime.php b/include/datetime.php old mode 100755 new mode 100644 diff --git a/include/dba.php b/include/dba.php old mode 100755 new mode 100644 index 7455b6b3ee..76cc0bc7b9 --- a/include/dba.php +++ b/include/dba.php @@ -1,5 +1,7 @@ debug) - logger('dba: ' . printable(print_r($r, true)), LOGGER_DATA); + logger('dba: ' . printable(print_r($r, true))); return($r); } @@ -207,8 +207,10 @@ function q($sql) { unset($args[0]); if($db && $db->connected) { - $ret = $db->q(vsprintf($sql,$args)); - return $ret; + $stmt = vsprintf($sql,$args); + if($stmt === false) + logger('dba: vsprintf error: ' . print_r(debug_backtrace(),true)); + return $db->q($stmt); } /** diff --git a/include/delivery.php b/include/delivery.php old mode 100755 new mode 100644 index c1ff07bd54..794b8f27a3 --- a/include/delivery.php +++ b/include/delivery.php @@ -256,7 +256,8 @@ function delivery_run($argv, $argc){ '$picdate' => xmlify(datetime_convert('UTC','UTC',$owner['avatar-date'] . '+00:00' , ATOM_TIME)) , '$uridate' => xmlify(datetime_convert('UTC','UTC',$owner['uri-date'] . '+00:00' , ATOM_TIME)) , '$namdate' => xmlify(datetime_convert('UTC','UTC',$owner['name-date'] . '+00:00' , ATOM_TIME)) , - '$birthday' => $birthday + '$birthday' => $birthday, + '$community' => (($owner['page-flags'] == PAGE_COMMUNITY) ? '1' : '') )); foreach($items as $item) { @@ -320,6 +321,14 @@ function delivery_run($argv, $argc){ $x[0]['writable'] = 1; } + $ssl_policy = get_config('system','ssl_policy'); + fix_contact_ssl_policy($x[0],$ssl_policy); + + // If we are setup as a soapbox we aren't accepting input from this person + + if($x[0]['page-flags'] == PAGE_SOAPBOX) + break; + require_once('library/simplepie/simplepie.inc'); logger('mod-delivery: local delivery'); local_delivery($x[0],$atom); @@ -435,8 +444,8 @@ function delivery_run($argv, $argc){ $headers .= 'Reply-to: ' . $reply_to . "\n"; // for testing purposes: Collect exported mails - $file = tempnam("/tmp/friendica/", "mail-out-"); - file_put_contents($file, json_encode($it)); + // $file = tempnam("/tmp/friendica/", "mail-out-"); + // file_put_contents($file, json_encode($it)); $headers .= 'Message-Id: <' . iri2msgid($it['uri']). '>' . "\n"; @@ -446,30 +455,16 @@ function delivery_run($argv, $argc){ if($it['uri'] !== $it['parent-uri']) { $headers .= 'References: <' . iri2msgid($it['parent-uri']) . '>' . "\n"; - if(! strlen($it['title'])) { + if(!strlen($it['title'])) { $r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' LIMIT 1", - dbesc($it['parent-uri']) - ); - if(count($r)) { - $subtitle = $r[0]['title']; - if($subtitle) { - if(strncasecmp($subtitle,'RE:',3)) - $subject = $subtitle; - else - $subject = 'Re: ' . $subtitle; - } - } + dbesc($it['parent-uri'])); + + if(count($r) AND ($r[0]['title'] != '')) + $subject = $r[0]['title']; } + if(strncasecmp($subject,'RE:',3)) + $subject = 'Re: '.$subject; } - /*$headers .= 'MIME-Version: 1.0' . "\n"; - //$headers .= 'Content-Type: text/html; charset=UTF-8' . "\n"; - $headers .= 'Content-Type: text/plain; charset=UTF-8' . "\n"; - $headers .= 'Content-Transfer-Encoding: 8bit' . "\n\n"; - $html = prepare_body($it); - //$message = '' . $html . ''; - $message = html2plain($html); - logger('notifier: email delivery to ' . $addr); - mail($addr, $subject, $message, $headers);*/ email_send($addr, $subject, $headers, $it); } break; diff --git a/include/diaspora.php b/include/diaspora.php old mode 100755 new mode 100644 index dca857a198..06df9c24a4 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -9,6 +9,12 @@ require_once('include/queue_fn.php'); function diaspora_dispatch_public($msg) { + $enabled = intval(get_config('system','diaspora_enabled')); + if(! $enabled) { + logger('mod-diaspora: disabled'); + return; + } + $r = q("SELECT `user`.* FROM `user` WHERE `user`.`uid` IN ( SELECT `contact`.`uid` FROM `contact` WHERE `contact`.`network` = '%s' AND `contact`.`addr` = '%s' ) AND `account_expired` = 0 ", dbesc(NETWORK_DIASPORA), dbesc($msg['author']) @@ -29,6 +35,12 @@ function diaspora_dispatch($importer,$msg) { $ret = 0; + $enabled = intval(get_config('system','diaspora_enabled')); + if(! $enabled) { + logger('mod-diaspora: disabled'); + return; + } + // php doesn't like dashes in variable names $msg['message'] = str_replace( @@ -688,9 +700,9 @@ function diaspora_post($importer,$xml) { // don't link tags that are already embedded in links - if(preg_match('/\[(.*?)' . preg_quote($tag) . '(.*?)\]/',$body)) + if(preg_match('/\[(.*?)' . preg_quote($tag,'/') . '(.*?)\]/',$body)) continue; - if(preg_match('/\[(.*?)\]\((.*?)' . preg_quote($tag) . '(.*?)\)/',$body)) + if(preg_match('/\[(.*?)\]\((.*?)' . preg_quote($tag,'/') . '(.*?)\)/',$body)) continue; $basetag = str_replace('_',' ',substr($tag,1)); @@ -853,9 +865,9 @@ function diaspora_reshare($importer,$xml) { // don't link tags that are already embedded in links - if(preg_match('/\[(.*?)' . preg_quote($tag) . '(.*?)\]/',$body)) + if(preg_match('/\[(.*?)' . preg_quote($tag,'/') . '(.*?)\]/',$body)) continue; - if(preg_match('/\[(.*?)\]\((.*?)' . preg_quote($tag) . '(.*?)\)/',$body)) + if(preg_match('/\[(.*?)\]\((.*?)' . preg_quote($tag,'/') . '(.*?)\)/',$body)) continue; @@ -1094,9 +1106,9 @@ function diaspora_comment($importer,$xml,$msg) { // don't link tags that are already embedded in links - if(preg_match('/\[(.*?)' . preg_quote($tag) . '(.*?)\]/',$body)) + if(preg_match('/\[(.*?)' . preg_quote($tag,'/') . '(.*?)\]/',$body)) continue; - if(preg_match('/\[(.*?)\]\((.*?)' . preg_quote($tag) . '(.*?)\)/',$body)) + if(preg_match('/\[(.*?)\]\((.*?)' . preg_quote($tag,'/') . '(.*?)\)/',$body)) continue; @@ -1159,6 +1171,48 @@ function diaspora_comment($importer,$xml,$msg) { proc_run('php','include/notifier.php','comment',$message_id); } + + $myconv = q("SELECT `author-link`, `author-avatar`, `parent` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d AND `parent` != 0 ", + dbesc($parent_item['uri']), + intval($importer['uid']) + ); + + if(count($myconv)) { + $importer_url = $a->get_baseurl() . '/profile/' . $importer['nickname']; + + foreach($myconv as $conv) { + + // now if we find a match, it means we're in this conversation + + if(! link_compare($conv['author-link'],$importer_url)) + continue; + + require_once('include/enotify.php'); + + $conv_parent = $conv['parent']; + + notification(array( + 'type' => NOTIFY_COMMENT, + 'notify_flags' => $importer['notify-flags'], + 'language' => $importer['language'], + 'to_name' => $importer['username'], + 'to_email' => $importer['email'], + 'uid' => $importer['uid'], + 'item' => $datarray, + 'link' => $a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $message_id, + 'source_name' => $datarray['author-name'], + 'source_link' => $datarray['author-link'], + 'source_photo' => $datarray['author-avatar'], + 'verb' => ACTIVITY_POST, + 'otype' => 'item', + 'parent' => $conv_parent, + + )); + + // only send one notification + break; + } + } return; } @@ -1695,7 +1749,7 @@ function diaspora_retraction($importer,$xml) { contact_remove($contact['id']); } elseif($type === 'Post') { - $r = q("select * from item where guid = '%s' and uid = %d limit 1", + $r = q("select * from item where guid = '%s' and uid = %d and not file like '%%[%%' limit 1", dbesc('guid'), intval($importer['uid']) ); @@ -1743,7 +1797,7 @@ function diaspora_signed_retraction($importer,$xml,$msg) { } if($type === 'StatusMessage') { - $r = q("select * from item where guid = '%s' and uid = %d limit 1", + $r = q("select * from item where guid = '%s' and uid = %d and not file like '%%[%%' limit 1", dbesc($guid), intval($importer['uid']) ); @@ -1878,6 +1932,7 @@ function diaspora_send_status($item,$owner,$contact,$public_batch = false) { $images = array(); + $title = $item['title']; $body = $item['body']; /* @@ -1902,9 +1957,12 @@ function diaspora_send_status($item,$owner,$contact,$public_batch = false) { } } */ - $body = xmlify(html_entity_decode(bb2diaspora($body))); + if(strlen($title)) + $body = xmlify('**' . html_entity_decode($title) . '**' . "\n") . $body; + + if($item['attach']) { $cnt = preg_match_all('/href=\"(.*?)\"(.*?)title=\"(.*?)\"/ism',$item['attach'],$matches,PREG_SET_ORDER); if(cnt) { @@ -2225,6 +2283,11 @@ function diaspora_send_mail($item,$owner,$contact) { function diaspora_transmit($owner,$contact,$slap,$public_batch) { + $enabled = intval(get_config('system','diaspora_enabled')); + if(! $enabled) { + return 200; + } + $a = get_app(); $logid = random_string(4); $dest_url = (($public_batch) ? $contact['batch'] : $contact['notify']); diff --git a/include/directory.php b/include/directory.php old mode 100755 new mode 100644 diff --git a/include/email.php b/include/email.php old mode 100755 new mode 100644 index 659978b6ee..b43ae0dc1c --- a/include/email.php +++ b/include/email.php @@ -1,5 +1,7 @@ parts) { $ret['body'] = email_get_part($mbox,$uid,$struc,0, 'html'); + $html = $ret['body']; if (trim($ret['body']) == '') $ret['body'] = email_get_part($mbox,$uid,$struc,0, 'plain'); @@ -107,6 +110,17 @@ function email_get_msg($mbox,$uid) { else $ret['body'] = $text; } + + $ret['body'] = removegpg($ret['body']); + $msg = removesig($ret['body']); + $ret['body'] = $msg['body']; + $ret['body'] = convertquote($ret['body'], $reply); + + if (trim($html) != '') + $ret['body'] = removelinebreak($ret['body']); + + $ret['body'] = unifyattributionline($ret['body']); + return $ret; } @@ -236,7 +250,7 @@ function email_header_encode($in_str, $charset) { // remove trailing spacer and // add start and end delimiters - $spacer = preg_quote($spacer); + $spacer = preg_quote($spacer,'/'); $out_str = preg_replace("/" . $spacer . "$/", "", $out_str); $out_str = $start . $out_str . $end; } diff --git a/include/enotify.php b/include/enotify.php old mode 100755 new mode 100644 index a505f1f040..8385bdec59 --- a/include/enotify.php +++ b/include/enotify.php @@ -5,6 +5,12 @@ function notification($params) { logger('notification: entry', LOGGER_DEBUG); $a = get_app(); + + // from here on everything is in the recipients language + + push_lang($params['language']); + + $banner = t('Friendica Notification'); $product = FRIENDICA_PLATFORM; $siteurl = z_path(); @@ -153,9 +159,33 @@ function notification($params) { } - // from here on everything is in the recipients language + if($params['type'] == NOTIFY_SYSTEM) { + + } + + $h = array( + 'params' => $params, + 'subject' => $subject, + 'preamble' => $preamble, + 'epreamble' => $epreamble, + 'body' => $body, + 'sitelink' => $sitelink, + 'tsitelink' => $tsitelink, + 'hsitelink' => $hsitelink, + 'itemlink' => $itemlink + ); + + call_hooks('enotify',$h); + + $subject = $h['subject']; + $preamble = $h['preamble']; + $epreamble = $h['epreamble']; + $body = $h['body']; + $sitelink = $h['sitelink']; + $tsitelink = $h['tsitelink']; + $hsitelink = $h['hsitelink']; + $itemlink = $h['itemlink']; - push_lang($params['language']); require_once('include/html2bbcode.php'); @@ -207,8 +237,10 @@ function notification($params) { ); if($r) $notify_id = $r[0]['id']; - else + else { + pop_lang(); return; + } $itemlink = $a->get_baseurl() . '/notify/view/' . $notify_id; $msg = replace_macros($epreamble,array('$itemlink' => $itemlink)); @@ -219,11 +251,10 @@ function notification($params) { ); - // send email notification if notification preferences permit require_once('bbcode.php'); - if(intval($params['notify_flags']) & intval($params['type'])) { + if((intval($params['notify_flags']) & intval($params['type'])) || $params['type'] == NOTIFY_SYSTEM) { logger('notification: sending notification email'); diff --git a/include/event.php b/include/event.php old mode 100755 new mode 100644 index 4a9a9a0041..29202baddf --- a/include/event.php +++ b/include/event.php @@ -163,7 +163,7 @@ function bbtoevent($s) { if(preg_match("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is",$s,$match)) $ev['adjust'] = $match[1]; $match = ''; - $ev['nofinish'] = (($ev['start'] && (!x($ev, 'finish') || !$ev['finish'])) ? 1 : 0); + $ev['nofinish'] = (((x($ev, 'start') && $ev['start']) && (!x($ev, 'finish') || !$ev['finish'])) ? 1 : 0); return $ev; } diff --git a/include/expire.php b/include/expire.php old mode 100755 new mode 100644 diff --git a/include/fcontact.php b/include/fcontact.php old mode 100755 new mode 100644 diff --git a/include/group.php b/include/group.php old mode 100755 new mode 100644 diff --git a/include/html2bbcode.php b/include/html2bbcode.php old mode 100755 new mode 100644 index 442e386911..69ccf41b71 --- a/include/html2bbcode.php +++ b/include/html2bbcode.php @@ -142,14 +142,14 @@ function html2bbcode($message) node2bbcode($doc, 'span', array('style'=>'font-style: italic;'), '[i]', '[/i]'); node2bbcode($doc, 'span', array('style'=>'font-weight: bold;'), '[b]', '[/b]'); - node2bbcode($doc, 'font', array('face'=>'/([\w ]+)/', 'size'=>'/(\d+)/', 'color'=>'/(.+)/'), '[font=$1][size=$2][color=$3]', '[/color][/size][/font]'); + /*node2bbcode($doc, 'font', array('face'=>'/([\w ]+)/', 'size'=>'/(\d+)/', 'color'=>'/(.+)/'), '[font=$1][size=$2][color=$3]', '[/color][/size][/font]'); node2bbcode($doc, 'font', array('size'=>'/(\d+)/', 'color'=>'/(.+)/'), '[size=$1][color=$2]', '[/color][/size]'); node2bbcode($doc, 'font', array('face'=>'/([\w ]+)/', 'size'=>'/(.+)/'), '[font=$1][size=$2]', '[/size][/font]'); node2bbcode($doc, 'font', array('face'=>'/([\w ]+)/', 'color'=>'/(.+)/'), '[font=$1][color=$3]', '[/color][/font]'); node2bbcode($doc, 'font', array('face'=>'/([\w ]+)/'), '[font=$1]', '[/font]'); node2bbcode($doc, 'font', array('size'=>'/(\d+)/'), '[size=$1]', '[/size]'); node2bbcode($doc, 'font', array('color'=>'/(.+)/'), '[color=$1]', '[/color]'); - +*/ // Untested //node2bbcode($doc, 'span', array('style'=>'/.*font-size:\s*(.+?)[,;].*font-family:\s*(.+?)[,;].*color:\s*(.+?)[,;].*/'), '[size=$1][font=$2][color=$3]', '[/color][/font][/size]'); //node2bbcode($doc, 'span', array('style'=>'/.*font-size:\s*(\d+)[,;].*/'), '[size=$1]', '[/size]'); @@ -191,13 +191,13 @@ function html2bbcode($message) node2bbcode($doc, 'hr', array(), "[hr]", ""); - //node2bbcode($doc, 'table', array(), "", ""); - //node2bbcode($doc, 'tr', array(), "\n", ""); - //node2bbcode($doc, 'td', array(), "\t", ""); - node2bbcode($doc, 'table', array(), "[table]", "[/table]"); - node2bbcode($doc, 'th', array(), "[th]", "[/th]"); - node2bbcode($doc, 'tr', array(), "[tr]", "[/tr]"); - node2bbcode($doc, 'td', array(), "[td]", "[/td]"); + node2bbcode($doc, 'table', array(), "", ""); + node2bbcode($doc, 'tr', array(), "\n", ""); + node2bbcode($doc, 'td', array(), "\t", ""); + //node2bbcode($doc, 'table', array(), "[table]", "[/table]"); + //node2bbcode($doc, 'th', array(), "[th]", "[/th]"); + //node2bbcode($doc, 'tr', array(), "[tr]", "[/tr]"); + //node2bbcode($doc, 'td', array(), "[td]", "[/td]"); node2bbcode($doc, 'h1', array(), "\n\n[size=xx-large][b]", "[/b][/size]\n"); node2bbcode($doc, 'h2', array(), "\n\n[size=x-large][b]", "[/b][/size]\n"); @@ -216,7 +216,7 @@ function html2bbcode($message) node2bbcode($doc, 'audio', array('src'=>'/(.+)/'), '[audio]$1', '[/audio]'); node2bbcode($doc, 'iframe', array('src'=>'/(.+)/'), '[iframe]$1', '[/iframe]'); - node2bbcode($doc, 'code', array(), '[code]$1', '[/code]'); + node2bbcode($doc, 'code', array(), '[code]', '[/code]'); $message = $doc->saveHTML(); diff --git a/include/html2plain.php b/include/html2plain.php index 2a4cf66391..21261327db 100644 --- a/include/html2plain.php +++ b/include/html2plain.php @@ -1,9 +1,15 @@ (.*?)<\/a>/is'; + preg_match_all($pattern, $message, $result, PREG_SET_ORDER); + + $urls = array(); + foreach ($result as $treffer) { + // A list of some links that should be ignored + $list = array("/user/", "/tag/", "/group/", "/profile/", "/search?search=", "mailto:", "/u/", "/node/", + "//facebook.com/profile.php?id=", "//plus.google.com/"); + foreach ($list as $listitem) + if (strpos($treffer[1], $listitem) !== false) + $ignore = true; + + if ((strpos($treffer[1], "//plus.google.com/") !== false) and (strpos($treffer[1], "/posts") !== false)) + $ignore = false; + + if (!$ignore) + $urls[$treffer[1]] = $treffer[1]; + } + return($urls); +} + +function html2plain($html, $wraplength = 75, $compact = false) { global $lang; @@ -93,22 +121,16 @@ function html2plain($html) $message = str_replace(array("\n<", ">\n", "\r", "\n", "\xC3\x82\xC2\xA0"), array("<", ">", "
", " ", ""), $message); $message = preg_replace('= [\s]*=i', " ", $message); - // nach ... suchen, die ... miteinander vergleichen und bei Gleichheit durch ein einzelnes ... ersetzen. - $pattern = '/(.*?)<\/a>/is'; - preg_match_all($pattern, $message, $result, PREG_SET_ORDER); + // Collecting all links + $urls = collecturls($message); - foreach ($result as $treffer) { - if ($treffer[1] == $treffer[2]) { - $search = ''.$treffer[1].''; - $message = str_replace($search, $treffer[1], $message); - } - } @$doc->loadHTML($message); node2bbcode($doc, 'html', array(), '', ''); node2bbcode($doc, 'body', array(), '', ''); // MyBB-Auszeichnungen + /* node2bbcode($doc, 'span', array('style'=>'text-decoration: underline;'), '_', '_'); node2bbcode($doc, 'span', array('style'=>'font-style: italic;'), '/', '/'); node2bbcode($doc, 'span', array('style'=>'font-weight: bold;'), '*', '*'); @@ -117,8 +139,12 @@ function html2plain($html) node2bbcode($doc, 'b', array(), '*', '*'); node2bbcode($doc, 'i', array(), '/', '/'); node2bbcode($doc, 'u', array(), '_', '_'); + */ - node2bbcode($doc, 'blockquote', array(), '[quote]', "[/quote]\n"); + if ($compact) + node2bbcode($doc, 'blockquote', array(), "»", "«"); + else + node2bbcode($doc, 'blockquote', array(), '[quote]', "[/quote]\n"); node2bbcode($doc, 'br', array(), "\n", ''); @@ -131,7 +157,7 @@ function html2plain($html) //node2bbcode($doc, 'ol', array(), "\n[list=1]", "[/list]\n"); node2bbcode($doc, 'li', array(), "\n* ", "\n"); - node2bbcode($doc, 'hr', array(), str_repeat("-", 70), ""); + node2bbcode($doc, 'hr', array(), "\n".str_repeat("-", 70)."\n", ""); node2bbcode($doc, 'tr', array(), "\n", ""); node2bbcode($doc, 'td', array(), "\t", ""); @@ -143,16 +169,25 @@ function html2plain($html) node2bbcode($doc, 'h5', array(), "\n\n*", "*\n"); node2bbcode($doc, 'h6', array(), "\n\n*", "*\n"); - node2bbcode($doc, 'a', array('href'=>'/(.+)/'), ' $1', '', true); - node2bbcode($doc, 'img', array('alt'=>'/(.+)/'), '$1', ''); - node2bbcode($doc, 'img', array('title'=>'/(.+)/'), '$1', ''); - node2bbcode($doc, 'img', array(), '', ''); - node2bbcode($doc, 'img', array('src'=>'/(.+)/'), '[img]$1', '[/img]'); + // Problem: there is no reliable way to detect if it is a link to a tag or profile + //node2bbcode($doc, 'a', array('href'=>'/(.+)/'), ' $1 ', '', true); + node2bbcode($doc, 'a', array('href'=>'/(.+)/', 'rel'=>'oembed'), ' $1 ', '', true); + //node2bbcode($doc, 'img', array('alt'=>'/(.+)/'), '$1', ''); + //node2bbcode($doc, 'img', array('title'=>'/(.+)/'), '$1', ''); + //node2bbcode($doc, 'img', array(), '', ''); + if (!$compact) + node2bbcode($doc, 'img', array('src'=>'/(.+)/'), '[img]$1', '[/img]'); + else + node2bbcode($doc, 'img', array('src'=>'/(.+)/'), '', ''); + + node2bbcode($doc, 'iframe', array('src'=>'/(.+)/'), ' $1 ', '', true); $message = $doc->saveHTML(); - $message = str_replace("[img]", "", $message); - $message = str_replace("[/img]", "", $message); + if (!$compact) { + $message = str_replace("[img]", "", $message); + $message = str_replace("[/img]", "", $message); + } // was ersetze ich da? // Irgendein stoerrisches UTF-Zeug @@ -168,12 +203,20 @@ function html2plain($html) $message = html_entity_decode($message, ENT_QUOTES, 'UTF-8'); + if (!$compact) { + $counter = 1; + foreach ($urls as $id=>$url) + if (strpos($message, $url) == false) + $message .= "\n".$url." "; + //$message .= "\n[".($counter++)."] ".$url; + } + do { $oldmessage = $message; $message = str_replace("\n\n\n", "\n\n", $message); } while ($oldmessage != $message); - $message = quotelevel(trim($message)); + $message = quotelevel(trim($message), $wraplength); return(trim($message)); } diff --git a/include/items.php b/include/items.php old mode 100755 new mode 100644 index a1254e165a..ee69605349 --- a/include/items.php +++ b/include/items.php @@ -7,14 +7,11 @@ require_once('include/crypto.php'); function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0) { - // default permissions - anonymous user - - if(! strlen($owner_nick)) - killme(); + $sitefeed = ((strlen($owner_nick)) ? false : true); // not yet implemented, need to rewrite huge chunks of following logic $public_feed = (($dfrn_id) ? false : true); - $starred = false; - $converse = false; + $starred = false; // not yet implemented, possible security issues + $converse = false; if($public_feed && $a->argc > 2) { for($x = 2; $x < $a->argc; $x++) { @@ -25,10 +22,11 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0) } } + // default permissions - anonymous user $sql_extra = " AND `allow_cid` = '' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = '' "; - $r = q("SELECT `contact`.*, `user`.`uid` AS `user_uid`, `user`.`nickname`, `user`.`timezone` + $r = q("SELECT `contact`.*, `user`.`uid` AS `user_uid`, `user`.`nickname`, `user`.`timezone`, `user`.`page-flags` FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid` WHERE `contact`.`self` = 1 AND `user`.`nickname` = '%s' LIMIT 1", dbesc($owner_nick) @@ -156,7 +154,8 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0) '$picdate' => xmlify(datetime_convert('UTC','UTC',$owner['avatar-date'] . '+00:00' , ATOM_TIME)) , '$uridate' => xmlify(datetime_convert('UTC','UTC',$owner['uri-date'] . '+00:00' , ATOM_TIME)) , '$namdate' => xmlify(datetime_convert('UTC','UTC',$owner['name-date'] . '+00:00' , ATOM_TIME)) , - '$birthday' => ((strlen($birthday)) ? '' . xmlify($birthday) . '' : '') + '$birthday' => ((strlen($birthday)) ? '' . xmlify($birthday) . '' : ''), + '$community' => (($owner['page-flags'] == PAGE_COMMUNITY) ? '1' : '') )); call_hooks('atom_feed', $atom); @@ -417,7 +416,7 @@ function get_atom_elements($feed,$item) { // the wild, by sanitising it and converting supported tags to bbcode before we rip out any remaining // html. - if((strpos($res['body'],'<') !== false) || (strpos($res['body'],'>') !== false)) { + if((strpos($res['body'],'<') !== false) && (strpos($res['body'],'>') !== false)) { $res['body'] = reltoabs($res['body'],$base_url); @@ -430,13 +429,21 @@ function get_atom_elements($feed,$item) { // we shouldn't need a whitelist, because the bbcode converter // will strip out any unsupported tags. - // $config->set('HTML.Allowed', 'p,b,a[href],i'); $purifier = new HTMLPurifier($config); $res['body'] = $purifier->purify($res['body']); - $res['body'] = html2bbcode($res['body']); + $res['body'] = @html2bbcode($res['body']); } + elseif(! $have_real_body) { + + // it's not one of our messages and it has no tags + // so it's probably just text. We'll escape it just to be safe. + + $res['body'] = escape_tags($res['body']); + } + + // this tag is obsolete but we keep it for really old sites $allow = $item->get_item_tags(NAMESPACE_DFRN,'comment-allow'); if($allow && $allow[0]['data'] == 1) @@ -682,7 +689,7 @@ function item_store($arr,$force_parent = false) { unset($arr['dsprsig']); } - if($arr['gravity']) + if(x($arr, 'gravity')) $arr['gravity'] = intval($arr['gravity']); elseif($arr['parent-uri'] === $arr['uri']) $arr['gravity'] = 0; @@ -742,6 +749,7 @@ function item_store($arr,$force_parent = false) { if($arr['parent-uri'] === $arr['uri']) { $parent_id = 0; + $parent_deleted = 0; $allow_cid = $arr['allow_cid']; $allow_gid = $arr['allow_gid']; $deny_cid = $arr['deny_cid']; @@ -800,6 +808,8 @@ function item_store($arr,$force_parent = false) { logger('item_store: item parent was not found - ignoring item'); return 0; } + + $parent_deleted = 0; } } @@ -1043,6 +1053,22 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { if(! $rino_enable) $rino = 0; + $ssl_val = intval(get_config('system','ssl_policy')); + $ssl_policy = ''; + + switch($ssl_val){ + case SSL_POLICY_FULL: + $ssl_policy = 'full'; + break; + case SSL_POLICY_SELFSIGN: + $ssl_policy = 'self'; + break; + case SSL_POLICY_NONE: + default: + $ssl_policy = 'none'; + break; + } + $url = $contact['notify'] . '&dfrn_id=' . $idtosend . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . (($rino) ? '&rino=1' : ''); logger('dfrn_deliver: ' . $url); @@ -1072,11 +1098,23 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { $postvars = array(); $sent_dfrn_id = hex2bin((string) $res->dfrn_id); $challenge = hex2bin((string) $res->challenge); + $perm = (($res->perm) ? $res->perm : null); $dfrn_version = (float) (($res->dfrn_version) ? $res->dfrn_version : 2.0); $rino_allowed = ((intval($res->rino) === 1) ? 1 : 0); + $page = (($owner['page-flags'] == PAGE_COMMUNITY) ? 1 : 0); $final_dfrn_id = ''; + if($perm) { + if((($perm == 'rw') && (! intval($contact['writable']))) + || (($perm == 'r') && (intval($contact['writable'])))) { + q("update contact set writable = %d where id = %d limit 1", + intval(($perm == 'rw') ? 1 : 0), + intval($contact['id']) + ); + $contact['writable'] = (string) 1 - intval($contact['writable']); + } + } if(($contact['duplex'] && strlen($contact['pubkey'])) || ($owner['page-flags'] == PAGE_COMMUNITY && strlen($contact['pubkey'])) @@ -1115,6 +1153,11 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { $postvars['perm'] = 'r'; } + $postvars['ssl_policy'] = $ssl_policy; + + if($page) + $postvars['page'] = '1'; + if($rino && $rino_allowed && (! $dissolve)) { $key = substr(random_string(),0,16); $data = bin2hex(aes_encrypt($postvars['data'],$key)); @@ -1379,6 +1422,19 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) } + $community_page = 0; + $rawtags = $feed->get_feed_tags( NAMESPACE_DFRN, 'community'); + if($rawtags) { + $community_page = intval($rawtags[0]['data']); + } + if(is_array($contact) && intval($contact['forum']) != $community_page) { + q("update contact set forum = %d where id = %d limit 1", + intval($community_page), + intval($contact['id']) + ); + $contact['forum'] = (string) $community_page; + } + // process any deleted entries @@ -1398,7 +1454,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) } if($deleted && is_array($contact)) { $r = q("SELECT `item`.*, `contact`.`self` FROM `item` left join `contact` on `item`.`contact-id` = `contact`.`id` - WHERE `uri` = '%s' AND `item`.`uid` = %d AND `contact-id` = %d LIMIT 1", + WHERE `uri` = '%s' AND `item`.`uid` = %d AND `contact-id` = %d AND NOT `item`.`file` LIKE '%%[%%' LIMIT 1", dbesc($uri), intval($importer['uid']), intval($contact['id']) @@ -1543,9 +1599,10 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) if(count($r)) { if((x($datarray,'edited') !== false) && (datetime_convert('UTC','UTC',$datarray['edited']) !== $r[0]['edited'])) { - $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", + $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", dbesc($datarray['title']), dbesc($datarray['body']), + dbesc($datarray['tag']), dbesc(datetime_convert('UTC','UTC',$datarray['edited'])), dbesc($item_id), intval($importer['uid']) @@ -1595,6 +1652,14 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) if((activity_match($datarray['verb'],ACTIVITY_LIKE)) || (activity_match($datarray['verb'],ACTIVITY_DISLIKE))) { $datarray['type'] = 'activity'; $datarray['gravity'] = GRAVITY_LIKE; + // only one like or dislike per person + $r = q("select id from item where uid = %d and `contact-id` = %d and verb ='%s' and deleted = 0 limit 1", + intval($datarray['uid']), + intval($datarray['contact-id']), + dbesc($datarray['verb']) + ); + if($r && count($r)) + continue; } if(($datarray['verb'] === ACTIVITY_TAG) && ($datarray['object-type'] === ACTIVITY_OBJ_TAGTERM)) { @@ -1680,9 +1745,10 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) if(count($r)) { if((x($datarray,'edited') !== false) && (datetime_convert('UTC','UTC',$datarray['edited']) !== $r[0]['edited'])) { - $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", + $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", dbesc($datarray['title']), dbesc($datarray['body']), + dbesc($datarray['tag']), dbesc(datetime_convert('UTC','UTC',$datarray['edited'])), dbesc($item_id), intval($importer['uid']) @@ -1747,6 +1813,18 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) $datarray['parent-uri'] = $item_id; $datarray['uid'] = $importer['uid']; $datarray['contact-id'] = $contact['id']; + + if(! link_compare($datarray['owner-link'],$contact['url'])) { + // The item owner info is not our contact. It's OK and is to be expected if this is a tgroup delivery, + // but otherwise there's a possible data mixup on the sender's system. + // the tgroup delivery code called from item_store will correct it if it's a forum, + // but we're going to unconditionally correct it here so that the post will always be owned by our contact. + logger('consume_feed: Correcting item owner.', LOGGER_DEBUG); + $datarray['owner-name'] = $contact['name']; + $datarray['owner-link'] = $contact['url']; + $datarray['owner-avatar'] = $contact['thumb']; + } + $r = item_store($datarray); continue; @@ -1837,6 +1915,14 @@ function local_delivery($importer,$data) { ); if(count($r)) { $fid = $r[0]['id']; + + // OK, we do. Do we already have an introduction for this person ? + $r = q("select id from intro where uid = %d and fid = %d limit 1", + intval($fsugg['uid']), + intval($fid) + ); + if(count($r)) + return 0; } if(! $fid) $r = q("INSERT INTO `fcontact` ( `name`,`url`,`photo`,`request` ) VALUES ( '%s', '%s', '%s', '%s' ) ", @@ -1857,6 +1943,7 @@ function local_delivery($importer,$data) { else return 0; + $hash = random_string(); $r = q("INSERT INTO `intro` ( `uid`, `fid`, `contact-id`, `note`, `hash`, `datetime`, `blocked` ) @@ -1942,6 +2029,19 @@ function local_delivery($importer,$data) { // NOTREACHED } + + $community_page = 0; + $rawtags = $feed->get_feed_tags( NAMESPACE_DFRN, 'community'); + if($rawtags) { + $community_page = intval($rawtags[0]['data']); + } + if(intval($importer['forum']) != $community_page) { + q("update contact set forum = %d where id = %d limit 1", + intval($community_page), + intval($importer['id']) + ); + $importer['forum'] = (string) $community_page; + } logger('local_delivery: feed item count = ' . $feed->get_item_quantity()); @@ -1964,7 +2064,7 @@ function local_delivery($importer,$data) { if($deleted) { $r = q("SELECT `item`.*, `contact`.`self` FROM `item` left join contact on `item`.`contact-id` = `contact`.`id` - WHERE `uri` = '%s' AND `item`.`uid` = %d AND `contact-id` = %d LIMIT 1", + WHERE `uri` = '%s' AND `item`.`uid` = %d AND `contact-id` = %d AND NOT `item`.`file` LIKE '%%[%%' LIMIT 1", dbesc($uri), intval($importer['importer_uid']), intval($importer['id']) @@ -1981,6 +2081,7 @@ function local_delivery($importer,$data) { if(($item['verb'] === ACTIVITY_TAG) && ($item['object-type'] === ACTVITY_OBJ_TAGTERM)) { $xo = parse_xml_string($item['object'],false); $xt = parse_xml_string($item['target'],false); + if($xt->type === ACTIVITY_OBJ_NOTE) { $i = q("select * from `item` where uri = '%s' and uid = %d limit 1", dbesc($xt->id), @@ -2136,6 +2237,14 @@ function local_delivery($importer,$data) { $datarray['type'] = 'activity'; $datarray['gravity'] = GRAVITY_LIKE; $datarray['last-child'] = 0; + // only one like or dislike per person + $r = q("select id from item where uid = %d and `contact-id` = %d and verb ='%s' and deleted = 0 limit 1", + intval($datarray['uid']), + intval($datarray['contact-id']), + dbesc($datarray['verb']) + ); + if($r && count($r)) + continue; } if(($datarray['verb'] === ACTIVITY_TAG) && ($datarray['object-type'] === ACTIVITY_OBJ_TAGTERM)) { @@ -2251,9 +2360,10 @@ function local_delivery($importer,$data) { if(count($r)) { if((x($datarray,'edited') !== false) && (datetime_convert('UTC','UTC',$datarray['edited']) !== $r[0]['edited'])) { - $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", + $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", dbesc($datarray['title']), dbesc($datarray['body']), + dbesc($datarray['tag']), dbesc(datetime_convert('UTC','UTC',$datarray['edited'])), dbesc($item_id), intval($importer['importer_uid']) @@ -2285,6 +2395,15 @@ function local_delivery($importer,$data) { if(($datarray['verb'] == ACTIVITY_LIKE) || ($datarray['verb'] == ACTIVITY_DISLIKE)) { $datarray['type'] = 'activity'; $datarray['gravity'] = GRAVITY_LIKE; + // only one like or dislike per person + $r = q("select id from item where uid = %d and `contact-id` = %d and verb ='%s' and deleted = 0 limit 1", + intval($datarray['uid']), + intval($datarray['contact-id']), + dbesc($datarray['verb']) + ); + if($r && count($r)) + continue; + } if(($datarray['verb'] === ACTIVITY_TAG) && ($datarray['object-type'] === ACTIVITY_OBJ_TAGTERM)) { @@ -2407,9 +2526,10 @@ function local_delivery($importer,$data) { if(count($r)) { if((x($datarray,'edited') !== false) && (datetime_convert('UTC','UTC',$datarray['edited']) !== $r[0]['edited'])) { - $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", + $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", dbesc($datarray['title']), dbesc($datarray['body']), + dbesc($datarray['tag']), dbesc(datetime_convert('UTC','UTC',$datarray['edited'])), dbesc($item_id), intval($importer['importer_uid']) @@ -2439,6 +2559,18 @@ function local_delivery($importer,$data) { $datarray['parent-uri'] = $item_id; $datarray['uid'] = $importer['importer_uid']; $datarray['contact-id'] = $importer['id']; + + if(! link_compare($datarray['owner-link'],$contact['url'])) { + // The item owner info is not our contact. It's OK and is to be expected if this is a tgroup delivery, + // but otherwise there's a possible data mixup on the sender's system. + // the tgroup delivery code called from item_store will correct it if it's a forum, + // but we're going to unconditionally correct it here so that the post will always be owned by our contact. + logger('local_delivery: Correcting item owner.', LOGGER_DEBUG); + $datarray['owner-name'] = $importer['senderName']; + $datarray['owner-link'] = $importer['url']; + $datarray['owner-avatar'] = $importer['thumb']; + } + $r = item_store($datarray); continue; } @@ -2823,6 +2955,11 @@ function item_expire($uid,$days) { foreach($r as $item) { + // don't expire filed items + + if(strpos($item['file'],'[') !== false) + continue; + // Only expire posts, not photos and photo comments if($expire_photos==0 && strlen($item['resource-id'])) diff --git a/include/message.php b/include/message.php old mode 100755 new mode 100644 index 7ad80ae9c6..377d7c715b --- a/include/message.php +++ b/include/message.php @@ -1,4 +1,5 @@ get_baseurl() . ':' . local_user() . ':' . $hash ; + + $convid = 0; + $reply = false; + + require_once('include/Scrape.php'); + + $me = probe_url($replyto); + + if(! $me['name']) + return -2; + + $conv_guid = get_guid(); + + $recip_handle = $recipient['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3); + + $sender_nick = basename($replyto); + $sender_host = substr($replyto,strpos($replyto,'://')+3); + $sender_host = substr($sender_host,0,strpos($sender_host,'/')); + $sender_handle = $sender_nick . '@' . $sender_host; + + $handles = $recip_handle . ';' . $sender_handle; + + $r = q("insert into conv (uid,guid,creator,created,updated,subject,recips) values(%d, '%s', '%s', '%s', '%s', '%s', '%s') ", + intval(local_user()), + dbesc($conv_guid), + dbesc($sender_handle), + dbesc(datetime_convert()), + dbesc(datetime_convert()), + dbesc($subject), + dbesc($handles) + ); + + $r = q("select * from conv where guid = '%s' and uid = %d limit 1", + dbesc($conv_guid), + intval($recipient['uid']) + ); + if(count($r)) + $convid = $r[0]['id']; + + if(! $convid) { + logger('send message: conversation not found.'); + return -4; + } + + $r = q("INSERT INTO `mail` ( `uid`, `guid`, `convid`, `from-name`, `from-photo`, `from-url`, + `contact-id`, `title`, `body`, `seen`, `reply`, `replied`, `uri`, `parent-uri`, `created`, `unknown`) + VALUES ( %d, '%s', %d, '%s', '%s', '%s', %d, '%s', '%s', %d, %d, %d, '%s', '%s', '%s', %d )", + intval($recipient['uid']), + dbesc(get_guid()), + intval($convid), + dbesc($me['name']), + dbesc($me['photo']), + dbesc($me['url']), + 0, + dbesc($subject), + dbesc($body), + 0, + 0, + 0, + dbesc($uri), + dbesc($replyto), + datetime_convert(), + 1 + ); + + return 0; + +} diff --git a/include/msgclean.php b/include/msgclean.php new file mode 100644 index 0000000000..eabb47788a --- /dev/null +++ b/include/msgclean.php @@ -0,0 +1,225 @@ +\s.*?To: (.*?)\s*?Cc: (.*?)\s*?Sent: (.*?)\s.*?Subject: ([^\n].*)\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message); + $message = savereplace('/----- Original Message -----\s.*?From: "([^<"].*?)" <(.*?)>\s.*?To: (.*?)\s*?Sent: (.*?)\s.*?Subject: ([^\n].*)\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message); + + $message = savereplace('/-------- Original-Nachricht --------\s*\['.$quote.'\]\nDatum: (.*?)\nVon: (.*?) <(.*?)>\nAn: (.*?)\nBetreff: (.*?)\n/i', "[".$quote."='$2']\n", $message); + $message = savereplace('/-------- Original-Nachricht --------\s*\['.$quote.'\]\sDatum: (.*?)\s.*Von: "([^<"].*?)" <(.*?)>\s.*An: (.*?)\n.*/i', "[".$quote."='$2']\n", $message); + $message = savereplace('/-------- Original-Nachricht --------\s*\['.$quote.'\]\nDatum: (.*?)\nVon: (.*?)\nAn: (.*?)\nBetreff: (.*?)\n/i', "[".$quote."='$2']\n", $message); + + $message = savereplace('/-----Urspr.*?ngliche Nachricht-----\sVon: "([^<"].*?)" <(.*?)>\s.*Gesendet: (.*?)\s.*An: (.*?)\s.*Betreff: ([^\n].*?).*:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message); + $message = savereplace('/-----Urspr.*?ngliche Nachricht-----\sVon: "([^<"].*?)" <(.*?)>\s.*Gesendet: (.*?)\s.*An: (.*?)\s.*Betreff: ([^\n].*?)\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message); + + $message = savereplace('/Am (.*?), schrieb (.*?):\s*\['.$quote.'\]/i', "[".$quote."='$2']\n", $message); + + $message = savereplace('/Am .*?, \d+ .*? \d+ \d+:\d+:\d+ \+\d+\sschrieb\s(.*?)\s<(.*?)>:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message); + + $message = savereplace('/Am (.*?) schrieb (.*?) <(.*?)>:\s*\['.$quote.'\]/i', "[".$quote."='$2']\n", $message); + $message = savereplace('/Am (.*?) schrieb <(.*?)>:\s*\['.$quote.'\]/i', "[".$quote."='$2']\n", $message); + $message = savereplace('/Am (.*?) schrieb (.*?):\s*\['.$quote.'\]/i', "[".$quote."='$2']\n", $message); + $message = savereplace('/Am (.*?) schrieb (.*?)\n(.*?):\s*\['.$quote.'\]/i', "[".$quote."='$2']\n", $message); + + $message = savereplace('/(\d+)\/(\d+)\/(\d+) ([^<"].*?) <(.*?)>\s*\['.$quote.'\]/i', "[".$quote."='$4']\n", $message); + + $message = savereplace('/On .*?, \d+ .*? \d+ \d+:\d+:\d+ \+\d+\s(.*?)\s<(.*?)>\swrote:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message); + + $message = savereplace('/On (.*?) at (.*?), (.*?)\s<(.*?)>\swrote:\s*\['.$quote.'\]/i', "[".$quote."='$3']\n", $message); + $message = savereplace('/On (.*?)\n([^<].*?)\s<(.*?)>\swrote:\s*\['.$quote.'\]/i', "[".$quote."='$2']\n", $message); + $message = savereplace('/On (.*?), (.*?), (.*?)\s<(.*?)>\swrote:\s*\['.$quote.'\]/i', "[".$quote."='$3']\n", $message); + $message = savereplace('/On ([^,].*?), (.*?)\swrote:\s*\['.$quote.'\]/i', "[".$quote."='$2']\n", $message); + $message = savereplace('/On (.*?), (.*?)\swrote\s*\['.$quote.'\]/i', "[".$quote."='$2']\n", $message); + + // Der loescht manchmal den Body - was eigentlich unmoeglich ist + $message = savereplace('/On (.*?),(.*?),(.*?),(.*?), (.*?) wrote:\s*\['.$quote.'\]/i', "[".$quote."='$5']\n", $message); + + $message = savereplace('/Zitat von ([^<].*?) <(.*?)>:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message); + + $message = savereplace('/Quoting ([^<].*?) <(.*?)>:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message); + + $message = savereplace('/From: "([^<"].*?)" <(.*?)>\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message); + $message = savereplace('/From: <(.*?)>\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message); + + $message = savereplace('/Du \(([^)].*?)\) schreibst:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message); + + $message = savereplace('/--- (.*?) <.*?> schrieb am (.*?):\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message); + $message = savereplace('/--- (.*?) schrieb am (.*?):\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message); + + $message = savereplace('/\* (.*?) <(.*?)> hat geschrieben:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message); + + $message = savereplace('/(.*?) <(.*?)> schrieb (.*?)\):\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message); + $message = savereplace('/(.*?) <(.*?)> schrieb am (.*?) um (.*):\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message); + $message = savereplace('/(.*?) schrieb am (.*?) um (.*):\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message); + $message = savereplace('/(.*?) \((.*?)\) schrieb:\s*\['.$quote.'\]/i', "[".$quote."='$2']\n", $message); + $message = savereplace('/(.*?) schrieb:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message); + + $message = savereplace('/(.*?) <(.*?)> writes:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message); + $message = savereplace('/(.*?) \((.*?)\) writes:\s*\['.$quote.'\]/i', "[".$quote."='$2']\n", $message); + $message = savereplace('/(.*?) writes:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message); + + $message = savereplace('/\* (.*?) wrote:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message); + $message = savereplace('/(.*?) wrote \(.*?\):\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message); + $message = savereplace('/(.*?) wrote:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message); + + $message = savereplace('/([^<].*?) <.*?> hat am (.*?)\sum\s(.*)\sgeschrieben:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message); + + $message = savereplace('/(\d+)\/(\d+)\/(\d+) ([^<"].*?) <(.*?)>:\s*\['.$quote.'\]/i', "[".$quote."='$4']\n", $message); + $message = savereplace('/(\d+)\/(\d+)\/(\d+) (.*?) <(.*?)>\s*\['.$quote.'\]/i', "[".$quote."='$4']\n", $message); + $message = savereplace('/(\d+)\/(\d+)\/(\d+) <(.*?)>:\s*\['.$quote.'\]/i', "[".$quote."='$4']\n", $message); + $message = savereplace('/(\d+)\/(\d+)\/(\d+) <(.*?)>\s*\['.$quote.'\]/i', "[".$quote."='$4']\n", $message); + + $message = savereplace('/(.*?) <(.*?)> schrubselte:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message); + $message = savereplace('/(.*?) \((.*?)\) schrubselte:\s*\['.$quote.'\]/i', "[".$quote."='$2']\n", $message); + + } + return($message); +} + +function removegpg($message) +{ + + $pattern = '/(.*)\s*-----BEGIN PGP SIGNED MESSAGE-----\s*[\r\n].*Hash:.*?[\r\n](.*)'. + '[\r\n]\s*-----BEGIN PGP SIGNATURE-----\s*[\r\n].*'. + '[\r\n]\s*-----END PGP SIGNATURE-----(.*)/is'; + + preg_match($pattern, $message, $result); + + $cleaned = trim($result[1].$result[2].$result[3]); + + $cleaned = str_replace(array("\n- --\n", "\n- -"), array("\n-- \n", "\n-"), $cleaned); + + + if ($cleaned == '') + $cleaned = $message; + + return($cleaned); +} + +function removesig($message) +{ + $sigpos = strrpos($message, "\n-- \n"); + $quotepos = strrpos($message, "[/quote]"); + + if ($sigpos == 0) { + // Speziell fuer web.de, die das als Trenner verwenden + $message = str_replace("\n___________________________________________________________\n", "\n-- \n", $message); + $sigpos = strrpos($message, "\n-- \n"); + $quotepos = strrpos($message, "[/quote]"); + } + + // Sollte sich der Signaturtrenner innerhalb eines Quotes befinden + // wird keine Signaturtrennung ausgefuehrt + if (($sigpos < $quotepos) and ($sigpos != 0)) + return(array('body' => $message, 'sig' => '')); + + // To-Do: Regexp umstellen, so dass auf 1 oder kein Leerzeichen + // geprueft wird + //$message = str_replace("\n--\n", "\n-- \n", $message); + + $pattern = '/(.*)[\r\n]-- [\r\n](.*)/is'; + + preg_match($pattern, $message, $result); + + if (($result[1] != '') and ($result[2] != '')) { + $cleaned = trim($result[1])."\n"; + $sig = trim($result[2]); + // '[hr][size=x-small][color=darkblue]'.trim($result[2]).'[/color][/size]'; + } else { + $cleaned = $message; + $sig = ''; + } + + return(array('body' => $cleaned, 'sig' => $sig)); +} + +function removelinebreak($message) +{ + $arrbody = explode("\n", trim($message)); + + $lines = array(); + $lineno = 0; + + foreach($arrbody as $i => $line) { + $currquotelevel = 0; + $currline = $line; + while ((strlen($currline)>0) and ((substr($currline, 0, 1) == '>') + or (substr($currline, 0, 1) == ' '))) { + if (substr($currline, 0, 1) == '>') + $currquotelevel++; + + $currline = ltrim(substr($currline, 1)); + } + + $quotelevel = 0; + $nextline = trim($arrbody[$i+1]); + while ((strlen($nextline)>0) and ((substr($nextline, 0, 1) == '>') + or (substr($nextline, 0, 1) == ' '))) { + if (substr($nextline, 0, 1) == '>') + $quotelevel++; + + $nextline = ltrim(substr($nextline, 1)); + } + + $len = strlen($line); + $firstword = strpos($nextline.' ', ' '); + + $specialchars = ((substr(trim($nextline), 0, 1) == '-') or + (substr(trim($nextline), 0, 1) == '=') or + (substr(trim($nextline), 0, 1) == '*') or + (substr(trim($nextline), 0, 1) == '·') or + (substr(trim($nextline), 0, 4) == '[url') or + (substr(trim($nextline), 0, 5) == '[size') or + (substr(trim($nextline), 0, 7) == 'http://') or + (substr(trim($nextline), 0, 8) == 'https://')); + + if (!$specialchars) + $specialchars = ((substr(rtrim($line), -1) == '-') or + (substr(rtrim($line), -1) == '=') or + (substr(rtrim($line), -1) == '*') or + (substr(rtrim($line), -1) == '·') or + (substr(rtrim($line), -6) == '[/url]') or + (substr(rtrim($line), -7) == '[/size]')); + + //if ($specialchars) + // echo ("Special\n"); + + if ($lines[$lineno] != '') { + if (substr($lines[$lineno], -1) != ' ') + $lines[$lineno] .= ' '; + + while ((strlen($line)>0) and ((substr($line, 0, 1) == '>') + or (substr($line, 0, 1) == ' '))) { + + $line = ltrim(substr($line, 1)); + } + + } + //else + // $lines[$lineno] = $quotelevel.'-'.$len.'-'.$firstword.'-'; + + $lines[$lineno] .= $line; + //if ((($len + $firstword < 68) and (substr($line, -1, 1) != ' ')) + // or ($quotelevel != $currquotelevel) or $specialchars) + if (((substr($line, -1, 1) != ' ')) + or ($quotelevel != $currquotelevel)) + $lineno++; + } + return(implode("\n", $lines)); + +} +?> diff --git a/include/nav.php b/include/nav.php old mode 100755 new mode 100644 index 511ca07fc0..2c9c643a92 --- a/include/nav.php +++ b/include/nav.php @@ -8,6 +8,8 @@ function nav(&$a) { * */ + $ssl_state = ((local_user()) ? true : false); + if(!(x($a->page,'nav'))) $a->page['nav'] = ''; @@ -27,7 +29,7 @@ function nav(&$a) { $myident = ((is_array($a->user) && isset($a->user['nickname'])) ? $a->user['nickname'] . '@' : ''); - $sitelocation = $myident . substr($a->get_baseurl(),strpos($a->get_baseurl(),'//') + 2 ); + $sitelocation = $myident . substr($a->get_baseurl($ssl_state),strpos($a->get_baseurl($ssl_state),'//') + 2 ); // nav links: array of array('href', 'text', 'extra css classes', 'title') @@ -53,7 +55,7 @@ function nav(&$a) { // user info $r = q("SELECT micro FROM contact WHERE uid=%d AND self=1", intval($a->user['uid'])); $userinfo = array( - 'icon' => (count($r) ? $r[0]['micro']: $a->get_baseurl()."/images/default-profile-mm.jpg"), + 'icon' => (count($r) ? $r[0]['micro']: $a->get_baseurl($ssl_state)."/images/person-48.jpg"), 'name' => $a->user['username'], ); @@ -67,7 +69,9 @@ function nav(&$a) { * "Home" should also take you home from an authenticated remote profile connection */ - $homelink = ((x($_SESSION,'visitor_home')) ? $_SESSION['visitor_home'] : ''); + $homelink = get_my_url(); + if(! $homelink) + $homelink = ((x($_SESSION,'visitor_home')) ? $_SESSION['visitor_home'] : ''); if(($a->module != 'home') && (! (local_user()))) $nav['home'] = array($homelink, t('Home'), "", t('Home Page')); @@ -76,7 +80,7 @@ function nav(&$a) { if(($a->config['register_policy'] == REGISTER_OPEN) && (! local_user()) && (! remote_user())) $nav['register'] = array('register',t('Register'), "", t('Create an account')); - $help_url = $a->get_baseurl() . '/help'; + $help_url = $a->get_baseurl($ssl_state) . '/help'; if(! get_config('system','hide_help')) $nav['help'] = array($help_url, t('Help'), "", t('Help and documentation')); @@ -122,6 +126,9 @@ function nav(&$a) { } $nav['messages'] = array('message', t('Messages'), "", t('Private mail')); + $nav['messages']['inbox'] = array('message', t('Inbox'), "", t('Inbox')); + $nav['messages']['outbox']= array('message/sent', t('Outbox'), "", t('Outbox')); + $nav['messages']['new'] = array('message/new', t('New Message'), "", t('New Message')); if(is_array($a->identities) && count($a->identities) > 1) { $nav['manage'] = array('manage', t('Manage'), "", t('Manage other pages')); diff --git a/include/network.php b/include/network.php old mode 100755 new mode 100644 index c72919dd8b..38d0980d50 --- a/include/network.php +++ b/include/network.php @@ -303,7 +303,7 @@ function webfinger_dfrn($s,&$hcard) { if(! function_exists('webfinger')) { -function webfinger($s) { +function webfinger($s, $debug = false) { $host = ''; if(strstr($s,'@')) { $host = substr($s,strpos($s,'@') + 1); @@ -328,7 +328,7 @@ function webfinger($s) { }} if(! function_exists('lrdd')) { -function lrdd($uri) { +function lrdd($uri, $debug = false) { $a = get_app(); @@ -364,6 +364,9 @@ function lrdd($uri) { logger('lrdd: host_meta: ' . $xml, LOGGER_DATA); + if(! stristr($xml,'get_hostname(); + $localhost = str_replace('www.','',$a->get_hostname()); if(strpos($localhost,':')) $localhost = substr($localhost,0,strpos($localhost,':')); @@ -337,7 +337,9 @@ function notifier_run($argv, $argc){ '$picdate' => xmlify(datetime_convert('UTC','UTC',$owner['avatar-date'] . '+00:00' , ATOM_TIME)) , '$uridate' => xmlify(datetime_convert('UTC','UTC',$owner['uri-date'] . '+00:00' , ATOM_TIME)) , '$namdate' => xmlify(datetime_convert('UTC','UTC',$owner['name-date'] . '+00:00' , ATOM_TIME)) , - '$birthday' => $birthday + '$birthday' => $birthday, + '$community' => (($owner['page-flags'] == PAGE_COMMUNITY) ? '1' : '') + )); if($mail) { @@ -535,6 +537,17 @@ function notifier_run($argv, $argc){ $x[0]['writable'] = 1; } + // if contact's ssl policy changed, which we just determined + // is on our own server, update our contact links + + $ssl_policy = get_config('system','ssl_policy'); + fix_contact_ssl_policy($x[0],$ssl_policy); + + // If we are setup as a soapbox we aren't accepting input from this person + + if($x[0]['page-flags'] == PAGE_SOAPBOX) + break; + require_once('library/simplepie/simplepie.inc'); logger('mod-delivery: local delivery'); local_delivery($x[0],$atom); @@ -648,38 +661,23 @@ function notifier_run($argv, $argc){ $headers .= 'Reply-to: ' . $reply_to . "\n"; // for testing purposes: Collect exported mails - $file = tempnam("/tmp/friendica/", "mail-out2-"); - file_put_contents($file, json_encode($it)); + //$file = tempnam("/tmp/friendica/", "mail-out2-"); + //file_put_contents($file, json_encode($it)); $headers .= 'Message-Id: <' . iri2msgid($it['uri']) . '>' . "\n"; if($it['uri'] !== $it['parent-uri']) { $headers .= 'References: <' . iri2msgid($it['parent-uri']) . '>' . "\n"; - if(! strlen($it['title'])) { + if(!strlen($it['title'])) { $r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' LIMIT 1", - dbesc($it['parent-uri']) - ); - if(count($r)) { - $subtitle = $r[0]['title']; - if($subtitle) { - if(strncasecmp($subtitle,'RE:',3)) - $subject = $subtitle; - else - $subject = 'Re: ' . $subtitle; - } - } - } - } + dbesc($it['parent-uri'])); - /*$headers .= 'MIME-Version: 1.0' . "\n"; - //$headers .= 'Content-Type: text/html; charset=UTF-8' . "\n"; - $headers .= 'Content-Type: text/plain; charset=UTF-8' . "\n"; - $headers .= 'Content-Transfer-Encoding: 8bit' . "\n\n"; - $html = prepare_body($it); - //$message = '' . $html . ''; - $message = html2plain($html); - logger('notifier: email delivery to ' . $addr); - mail($addr, $subject, $message, $headers);*/ + if(count($r) AND ($r[0]['title'] != '')) + $subject = $r[0]['title']; + } + if(strncasecmp($subject,'RE:',3)) + $subject = 'Re: '.$subject; + } email_send($addr, $subject, $headers, $it); } break; diff --git a/include/oauth.php b/include/oauth.php old mode 100755 new mode 100644 diff --git a/include/oembed.php b/include/oembed.php old mode 100755 new mode 100644 index 5c3c595f57..1f45d28143 --- a/include/oembed.php +++ b/include/oembed.php @@ -1,6 +1,6 @@ query("//link[@type='application/json+oembed']"); foreach($entries as $e){ $href = $e->getAttributeNode("href")->nodeValue; - $txt = fetch_url($href); + $txt = fetch_url($href . '&maxwidth=425'); + break; } } } @@ -43,7 +47,7 @@ function oembed_fetch_url($embedurl){ if ($txt==false || $txt==""){ // try oohembed service - $ourl = "http://oohembed.com/oohembed/?url=".urlencode($embedurl); + $ourl = "http://oohembed.com/oohembed/?url=".urlencode($embedurl).'&maxwidth=425'; $txt = fetch_url($ourl); } @@ -62,7 +66,7 @@ function oembed_fetch_url($embedurl){ function oembed_format_object($j){ $embedurl = $j->embedurl; - $jhtml = oembed_iframe($j->embedurl,$j->width,$j->height ); + $jhtml = oembed_iframe($j->embedurl,(isset($j->width) ? $j->width : null), (isset($j->height) ? $j->height : null) ); $ret=""; switch ($j->type) { case "video": { diff --git a/include/pgettext.php b/include/pgettext.php old mode 100755 new mode 100644 diff --git a/include/pidfile.php b/include/pidfile.php new file mode 100644 index 0000000000..47df8d1f46 --- /dev/null +++ b/include/pidfile.php @@ -0,0 +1,32 @@ +_file = "$dir/$name.pid"; + + if (file_exists($this->_file)) { + $pid = trim(file_get_contents($this->_file)); + if (posix_kill($pid, 0)) { + $this->_running = true; + } + } + + if (! $this->_running) { + $pid = getmypid(); + file_put_contents($this->_file, $pid); + } + } + + public function __destruct() { + if ((! $this->_running) && file_exists($this->_file)) { + unlink($this->_file); + } + } + + public function is_already_running() { + return $this->_running; + } +} +?> diff --git a/include/plugin.php b/include/plugin.php old mode 100755 new mode 100644 index 8280b1022e..8196e87561 --- a/include/plugin.php +++ b/include/plugin.php @@ -17,7 +17,12 @@ function uninstall_plugin($plugin){ }} if (! function_exists('install_plugin')){ -function install_plugin($plugin){ +function install_plugin($plugin) { + + // silently fail if plugin was removed + + if(! file_exists('addon/' . $plugin . '/' . $plugin . '.php')) + return false; logger("Addons: installing " . $plugin); $t = @filemtime('addon/' . $plugin . '/' . $plugin . '.php'); @include_once('addon/' . $plugin . '/' . $plugin . '.php'); @@ -32,9 +37,11 @@ function install_plugin($plugin){ intval($t), $plugin_admin ); + return true; } else { logger("Addons: FAILED installing " . $plugin); + return false; } }} @@ -249,6 +256,7 @@ function get_theme_info($theme){ list($k,$v) = array_map("trim", explode(":",$l,2)); $k= strtolower($k); if ($k=="author"){ + $r=preg_match("|([^<]+)<([^>]+)>|", $v, $m); if ($r) { $info['author'][] = array('name'=>$m[1], 'link'=>$m[2]); @@ -276,3 +284,13 @@ function get_theme_info($theme){ return $info; }} + +function get_theme_screenshot($theme) { + $a = get_app(); + $exts = array('.png','.jpg'); + foreach($exts as $ext) { + if(file_exists('view/theme/' . $theme . '/screenshot' . $ext)) + return($a->get_baseurl() . '/view/theme/' . $theme . '/screenshot' . $ext); + } + return($a->get_baseurl() . '/images/blank.png'); +} diff --git a/include/poller.php b/include/poller.php old mode 100755 new mode 100644 index cfbc46b87e..499483d007 --- a/include/poller.php +++ b/include/poller.php @@ -1,7 +1,6 @@ is_already_running()) { + logger("poller: Already running"); + exit; + } + } + $a->set_baseurl(get_config('system','url')); load_hooks(); @@ -70,6 +79,19 @@ function poller_run($argv, $argc){ // clear old cache Cache::clear(); + // clear item cache files if they are older than one day + $cache = get_config('system','itemcache'); + if (($cache != '') and is_dir($cache)) { + if ($dh = opendir($cache)) { + while (($file = readdir($dh)) !== false) { + $fullpath = $cache."/".$file; + if ((filetype($fullpath) == "file") and filectime($fullpath) < (time() - 86400)) + unlink($fullpath); + } + closedir($dh); + } + } + $manual_id = 0; $generation = 0; $hub_update = false; @@ -141,7 +163,10 @@ function poller_run($argv, $argc){ if($manual_id) $contact['last-update'] = '0000-00-00 00:00:00'; - if($contact['network'] === NETWORK_DFRN || $contact['network'] === NETWORK_OSTATUS) + if($contact['network'] === NETWORK_DFRN) + $contact['priority'] = 2; + + if(!get_config('system','ostatus_use_priority') and ($contact['network'] === NETWORK_OSTATUS)) $contact['priority'] = 2; if($contact['priority'] || $contact['subhub']) { @@ -217,7 +242,7 @@ function poller_run($argv, $argc){ $importer_uid = $contact['uid']; - $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1", + $r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` LEFT JOIN `user` on `contact`.`uid` = `user`.`uid` WHERE `user`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1", intval($importer_uid) ); if(! count($r)) @@ -489,12 +514,17 @@ function poller_run($argv, $argc){ //$datarray['title'] = notags(trim($meta->subject)); $datarray['created'] = datetime_convert('UTC','UTC',$meta->date); - $r = email_get_msg($mbox,$msg_uid); + // Is it reply? + $reply = ((substr(strtolower($datarray['title']), 0, 3) == "re:") or + (substr(strtolower($datarray['title']), 0, 3) == "re-") or + (raw_refs != "")); + + $r = email_get_msg($mbox,$msg_uid, $reply); if(! $r) { logger("Mail: can't fetch msg ".$msg_uid); continue; } - $datarray['body'] = escape_tags(convertquote($r['body'], false)); + $datarray['body'] = escape_tags($r['body']); logger("Mail: Importing ".$msg_uid); diff --git a/include/profile_advanced.php b/include/profile_advanced.php old mode 100755 new mode 100644 diff --git a/include/profile_selectors.php b/include/profile_selectors.php old mode 100755 new mode 100644 diff --git a/include/profile_update.php b/include/profile_update.php old mode 100755 new mode 100644 diff --git a/include/queue.php b/include/queue.php old mode 100755 new mode 100644 index d312b50f5a..7e92705be2 --- a/include/queue.php +++ b/include/queue.php @@ -61,13 +61,18 @@ function queue_run($argv, $argc){ q("DELETE FROM `queue` WHERE `created` < UTC_TIMESTAMP() - INTERVAL 3 DAY"); } - if($queue_id) + if($queue_id) { $r = q("SELECT `id` FROM `queue` WHERE `id` = %d LIMIT 1", intval($queue_id) ); - else - $r = q("SELECT `id` FROM `queue` WHERE `last` < UTC_TIMESTAMP() - INTERVAL 15 MINUTE "); + } + else { + // For the first 12 hours we'll try to deliver every 15 minutes + // After that, we'll only attempt delivery once per hour. + + $r = q("SELECT `id` FROM `queue` WHERE (( `created` > UTC_TIMESTAMP() - INTERVAL 12 HOUR && `last` < UTC_TIMESTAMP() - INTERVAL 15 MINUTE ) OR ( `last` < UTC_TIMESTAMP() - INTERVAL 1 HOUR ))"); + } if(! count($r)){ return; } diff --git a/include/queue_fn.php b/include/queue_fn.php old mode 100755 new mode 100644 diff --git a/include/quoteconvert.php b/include/quoteconvert.php index 3aee93234f..2a6d28370a 100644 --- a/include/quoteconvert.php +++ b/include/quoteconvert.php @@ -124,7 +124,7 @@ function removetofu($message) } if ($quotestart != 0) { - $message = trim(substr($message, 0, $quotestart))."\n[collapsed]\n".substr($message, $quotestart+7, -8).'[/collapsed]'; + $message = trim(substr($message, 0, $quotestart))."\n[spoiler]".substr($message, $quotestart+7, -8).'[/spoiler]'; } return($message); diff --git a/include/remoteupdate.php b/include/remoteupdate.php old mode 100755 new mode 100644 diff --git a/include/salmon.php b/include/salmon.php old mode 100755 new mode 100644 diff --git a/include/security.php b/include/security.php old mode 100755 new mode 100644 index bc2c9f0bf8..66622fd331 --- a/include/security.php +++ b/include/security.php @@ -9,6 +9,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive $_SESSION['authenticated'] = 1; $_SESSION['page_flags'] = $user_record['page-flags']; $_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $user_record['nickname']; + $_SESSION['my_address'] = $user_record['nickname'] . '@' . substr($a->get_baseurl(),strpos($a->get_baseurl(),'://')+3); $_SESSION['addr'] = $_SERVER['REMOTE_ADDR']; $a->user = $user_record; @@ -108,14 +109,18 @@ function can_write_wall(&$a,$owner) { if(remote_user()) { - // user remembered decision and avoid a DB lookup for each and every display item + // use remembered decision and avoid a DB lookup for each and every display item // DO NOT use this function if there are going to be multiple owners + // We have a contact-id for an authenticated remote user, this block determines if the contact + // belongs to this page owner, and has the necessary permissions to post content + if($verified === 2) return true; elseif($verified === 1) return false; else { + $r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` LEFT JOIN `user` on `user`.`uid` = `contact`.`uid` WHERE `contact`.`uid` = %d AND `contact`.`id` = %d AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `user`.`blockwall` = 0 AND `readonly` = 0 AND ( `contact`.`rel` IN ( %d , %d ) OR `user`.`page-flags` = %d ) LIMIT 1", @@ -125,6 +130,7 @@ function can_write_wall(&$a,$owner) { intval(CONTACT_IS_FRIEND), intval(PAGE_COMMUNITY) ); + if(count($r)) { $verified = 2; return true; @@ -197,7 +203,7 @@ function permissions_sql($owner_id,$remote_verified = false,$groups = null) { " AND ( allow_cid = '' OR allow_cid REGEXP '<%d>' ) AND ( deny_cid = '' OR NOT deny_cid REGEXP '<%d>' ) AND ( allow_gid = '' OR allow_gid REGEXP '%s' ) - AND ( deny_gid = '' OR NOT deny_gid REGEXP '%s') + AND ( deny_gid = '' OR NOT deny_gid REGEXP '%s') ", intval($remote_user), intval($remote_user), @@ -207,4 +213,135 @@ function permissions_sql($owner_id,$remote_verified = false,$groups = null) { } } return $sql; +} + + +function item_permissions_sql($owner_id,$remote_verified = false,$groups = null) { + + $local_user = local_user(); + $remote_user = remote_user(); + + /** + * Construct permissions + * + * default permissions - anonymous user + */ + + $sql = " AND allow_cid = '' + AND allow_gid = '' + AND deny_cid = '' + AND deny_gid = '' + AND private = 0 + "; + + /** + * Profile owner - everything is visible + */ + + if(($local_user) && ($local_user == $owner_id)) { + $sql = ''; + } + + /** + * Authenticated visitor. Unless pre-verified, + * check that the contact belongs to this $owner_id + * and load the groups the visitor belongs to. + * If pre-verified, the caller is expected to have already + * done this and passed the groups into this function. + */ + + elseif($remote_user) { + + if(! $remote_verified) { + $r = q("SELECT id FROM contact WHERE id = %d AND uid = %d AND blocked = 0 LIMIT 1", + intval($remote_user), + intval($owner_id) + ); + if(count($r)) { + $remote_verified = true; + $groups = init_groups_visitor($remote_user); + } + } + if($remote_verified) { + + $gs = '<<>>'; // should be impossible to match + + if(is_array($groups) && count($groups)) { + foreach($groups as $g) + $gs .= '|<' . intval($g) . '>'; + } + + $sql = sprintf( + " AND ( private = 0 OR ( private = 1 AND wall = 1 AND ( allow_cid = '' OR allow_cid REGEXP '<%d>' ) + AND ( deny_cid = '' OR NOT deny_cid REGEXP '<%d>' ) + AND ( allow_gid = '' OR allow_gid REGEXP '%s' ) + AND ( deny_gid = '' OR NOT deny_gid REGEXP '%s'))) + ", + intval($remote_user), + intval($remote_user), + dbesc($gs), + dbesc($gs) + ); + } + } + + return $sql; +} + + +/* + * Functions used to protect against Cross-Site Request Forgery + * The security token has to base on at least one value that an attacker can't know - here it's the session ID and the private key. + * In this implementation, a security token is reusable (if the user submits a form, goes back and resubmits the form, maybe with small changes; + * or if the security token is used for ajax-calls that happen several times), but only valid for a certain amout of time (3hours). + * The "typename" seperates the security tokens of different types of forms. This could be relevant in the following case: + * A security token is used to protekt a link from CSRF (e.g. the "delete this profile"-link). + * If the new page contains by any chance external elements, then the used security token is exposed by the referrer. + * Actually, important actions should not be triggered by Links / GET-Requests at all, but somethimes they still are, + * so this mechanism brings in some damage control (the attacker would be able to forge a request to a form of this type, but not to forms of other types). + */ +function get_form_security_token($typename = '') { + $a = get_app(); + + $timestamp = time(); + $sec_hash = hash('whirlpool', $a->user['guid'] . $a->user['prvkey'] . session_id() . $timestamp . $typename); + + return $timestamp . '.' . $sec_hash; +} + +function check_form_security_token($typename = '', $formname = 'form_security_token') { + if (!x($_REQUEST, $formname)) return false; + $hash = $_REQUEST[$formname]; + + $max_livetime = 10800; // 3 hours + + $a = get_app(); + + $x = explode('.', $hash); + if (time() > (IntVal($x[0]) + $max_livetime)) return false; + + $sec_hash = hash('whirlpool', $a->user['guid'] . $a->user['prvkey'] . session_id() . $x[0] . $typename); + + return ($sec_hash == $x[1]); +} + +function check_form_security_std_err_msg() { + return t('The form security token was not correct. This probably happened because the form has been opened for too long (>3 hours) before subitting it.') . EOL; +} +function check_form_security_token_redirectOnErr($err_redirect, $typename = '', $formname = 'form_security_token') { + if (!check_form_security_token($typename, $formname)) { + $a = get_app(); + logger('check_form_security_token failed: user ' . $a->user['guid'] . ' - form element ' . $typename); + logger('check_form_security_token failed: _REQUEST data: ' . print_r($_REQUEST, true), LOGGER_DATA); + notice( check_form_security_std_err_msg() ); + goaway($a->get_baseurl() . $err_redirect ); + } +} +function check_form_security_token_ForbiddenOnErr($typename = '', $formname = 'form_security_token') { + if (!check_form_security_token($typename, $formname)) { + logger('check_form_security_token failed: user ' . $a->user['guid'] . ' - form element ' . $typename); + logger('check_form_security_token failed: _REQUEST data: ' . print_r($_REQUEST, true), LOGGER_DATA); + header('HTTP/1.1 403 Forbidden'); + killme(); + } } \ No newline at end of file diff --git a/include/session.php b/include/session.php old mode 100755 new mode 100644 diff --git a/include/socgraph.php b/include/socgraph.php old mode 100755 new mode 100644 index 79d7340a4e..3f51940492 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -230,19 +230,21 @@ function all_friends($uid,$cid,$start = 0, $limit = 80) { -function suggestion_query($uid, $start = 0, $limit = 40) { +function suggestion_query($uid, $start = 0, $limit = 80) { if(! $uid) return array(); $r = q("SELECT count(glink.gcid) as `total`, gcontact.* from gcontact left join glink on glink.gcid = gcontact.id - where uid = %d and not gcontact.nurl in ( select nurl from contact where uid = %d) + where uid = %d and not gcontact.nurl in ( select nurl from contact where uid = %d ) + and not gcontact.name in ( select name from contact where uid = %d ) and not gcontact.id in ( select gcid from gcign where uid = %d ) group by glink.gcid order by total desc limit %d, %d ", intval($uid), intval($uid), intval($uid), + intval($uid), intval($start), intval($limit) ); @@ -252,11 +254,13 @@ function suggestion_query($uid, $start = 0, $limit = 40) { $r2 = q("SELECT gcontact.* from gcontact left join glink on glink.gcid = gcontact.id - where glink.uid = 0 and glink.cid = 0 and not gcontact.nurl in ( select nurl from contact where uid = %d) + where glink.uid = 0 and glink.cid = 0 and not gcontact.nurl in ( select nurl from contact where uid = %d ) + and not gcontact.name in ( select name from contact where uid = %d ) and not gcontact.id in ( select gcid from gcign where uid = %d ) order by rand() limit %d, %d ", intval($uid), intval($uid), + intval($uid), intval($start), intval($limit) ); diff --git a/include/system_unavailable.php b/include/system_unavailable.php old mode 100755 new mode 100644 diff --git a/include/template_processor.php b/include/template_processor.php old mode 100755 new mode 100644 index 8671587fc4..46252c355f --- a/include/template_processor.php +++ b/include/template_processor.php @@ -13,12 +13,14 @@ var $debug=false; private function _preg_error(){ + switch(preg_last_error()){ case PREG_INTERNAL_ERROR: echo('PREG_INTERNAL_ERROR'); break; case PREG_BACKTRACK_LIMIT_ERROR: echo('PREG_BACKTRACK_LIMIT_ERROR'); break; case PREG_RECURSION_LIMIT_ERROR: echo('PREG_RECURSION_LIMIT_ERROR'); break; case PREG_BAD_UTF8_ERROR: echo('PREG_BAD_UTF8_ERROR'); break; - case PREG_BAD_UTF8_OFFSET_ERROR: echo('PREG_BAD_UTF8_OFFSET_ERROR'); break; +// This is only valid for php > 5.3, not certain how to code around it for unit tests +// case PREG_BAD_UTF8_OFFSET_ERROR: echo('PREG_BAD_UTF8_OFFSET_ERROR'); break; default: //die("Unknown preg error."); return; @@ -80,8 +82,13 @@ */ private function _replcb_for($args){ $m = array_map('trim', explode(" as ", $args[2])); - list($keyname, $varname) = explode("=>",$m[1]); - if (is_null($varname)) { $varname=$keyname; $keyname=""; } + $x = explode("=>",$m[1]); + if (count($x) == 1) { + $varname = $x[0]; + $keyname = ""; + } else { + list($keyname, $varname) = $x; + } if ($m[0]=="" || $varname=="" || is_null($varname)) die("template error: 'for ".$m[0]." as ".$varname."'") ; //$vals = $this->r[$m[0]]; $vals = $this->_get_var($m[0]); @@ -91,7 +98,7 @@ $this->_push_stack(); $r = $this->r; $r[$varname] = $v; - if ($keyname!='') $r[$keyname] = $k; + if ($keyname!='') $r[$keyname] = (($k === 0) ? '0' : $k); $ret .= $this->replace($args[3], $r); $this->_pop_stack(); } @@ -198,7 +205,7 @@ $os=$s; $count++; $s = $this->var_replace($s); } - return template_unescape($s); + return $s; } } diff --git a/include/text.php b/include/text.php old mode 100755 new mode 100644 index 042ee982cb..aced9e0a81 --- a/include/text.php +++ b/include/text.php @@ -20,7 +20,7 @@ function replace_macros($s,$r) { //$a = get_app(); //$a->page['debug'] .= "$tt
\n"; - return $r; + return template_unescape($r); }} @@ -80,6 +80,9 @@ function escape_tags($string) { if(! function_exists('autoname')) { function autoname($len) { + if($len <= 0) + return ''; + $vowels = array('a','a','ai','au','e','e','e','ee','ea','i','ie','o','ou','u'); if(mt_rand(0,5) == 4) $vowels[] = 'y'; @@ -205,7 +208,6 @@ function hex2bin($s) { return ''; if(! ctype_xdigit($s)) { - logger('hex2bin: illegal input: ' . print_r(debug_backtrace(), true)); return($s); } @@ -226,6 +228,9 @@ if(! function_exists('paginate')) { function paginate(&$a) { $o = ''; $stripped = preg_replace('/(&page=[0-9]*)/','',$a->query_string); + +// $stripped = preg_replace('/&zrl=(.*?)([\?&]|$)/ism','',$stripped); + $stripped = str_replace('q=','',$stripped); $stripped = trim($stripped,'/'); $pagenum = $a->pager['page']; @@ -610,6 +615,8 @@ function micropro($contact, $redirect = false, $class = '', $textmode = false) { $url = $redirect_url; $sparkle = ' sparkle'; } + else + $url = zrl($url); } $click = ((x($contact,'click')) ? ' onclick="' . $contact['click'] . '" ' : ''); if($click) @@ -638,7 +645,7 @@ if(! function_exists('search')) { function search($s,$id='search-box',$url='/search',$save = false) { $a = get_app(); $o = '
'; - $o .= '
'; + $o .= ''; $o .= ''; $o .= ''; if($save) @@ -694,8 +701,13 @@ function linkify($s) { if(! function_exists('smilies')) { function smilies($s, $sample = false) { + $a = get_app(); + if(intval(get_config('system','no_smilies')) + || (local_user() && intval(get_pconfig(local_user(),'system','no_smilies')))) + return $s; + $s = preg_replace_callback('/
(.*?)<\/pre>/ism','smile_encode',$s);
 	$s = preg_replace_callback('/(.*?)<\/code>/ism','smile_encode',$s);
 
@@ -704,27 +716,23 @@ function smilies($s, $sample = false) {
 		'</3', 
 		'<\\3', 
 		':-)', 
-//		':)', 
 		';-)', 
-//		';)', 
 		':-(', 
-//		':(', 
 		':-P', 
-//		':P', 
+		':-p', 
 		':-"', 
 		':-"', 
 		':-x', 
 		':-X', 
 		':-D', 
-//		':D', 
 		'8-|', 
 		'8-O', 
 		':-O', 
 		'\\o/', 
 		'o.O', 
 		'O.o', 
-		'\\.../', 
-		'\\ooo/', 
+		'o_O', 
+		'O_o', 
 		":'(", 
 		":-!", 
 		":-/", 
@@ -734,10 +742,9 @@ function smilies($s, $sample = false) {
 		':homebrew', 
 		':coffee', 
 		':facepalm',
-		':headdesk',
 		'~friendika', 
-		'~friendica', 
-		'Diaspora*' 
+		'~friendica'
+
 	);
 
 	$icons = array(
@@ -745,27 +752,23 @@ function smilies($s, $sample = false) {
 		'</3',
 		'<\\3',
 		':-)',
-//		':)',
 		';-)',
-//		';)',                
 		':-(',
-//		':(',
 		':-P',
-//		':P',
+		':-p',
 		':-\',
 		':-\',
 		':-x',
 		':-X',
 		':-D',
-//		':D',                
 		'8-|',
 		'8-O',
 		':-O',                
 		'\\o/',
 		'o.O',
 		'O.o',
-		'\\.../',
-		'\\ooo/',
+		'o_O',
+		'O_o',
 		':\'(',
 		':-!',
 		':-/',
@@ -775,11 +778,8 @@ function smilies($s, $sample = false) {
 		':homebrew',
 		':coffee',
 		':facepalm',
-		':headdesk',
 		'~friendika ~friendika',
-		'~friendica ~friendica',
-		'DiasporaDiaspora*',
-
+		'~friendica ~friendica'
 	);
 
 	$params = array('texts' => $texts, 'icons' => $icons, 'string' => $s);
@@ -870,16 +870,30 @@ function link_compare($a,$b) {
 if(! function_exists('prepare_body')) {
 function prepare_body($item,$attach = false) {
 
+	$a = get_app();
 	call_hooks('prepare_body_init', $item); 
 
-	$s = prepare_text($item['body']);
+	$cache = get_config('system','itemcache');
+
+	if (($cache != '')) {
+		$cachefile = $cache."/".$item["guid"]."-".strtotime($item["edited"])."-".hash("crc32", $item['body']);
+
+		if (file_exists($cachefile))
+			$s = file_get_contents($cachefile);
+		else {
+			$s = prepare_text($item['body']);
+			file_put_contents($cachefile, $s);
+		}
+	} else
+		$s = prepare_text($item['body']);
 
 	$prep_arr = array('item' => $item, 'html' => $s);
 	call_hooks('prepare_body', $prep_arr);
 	$s = $prep_arr['html'];
 
-	if(! $attach)
+	if(! $attach) {
 		return $s;
+	}
 
 	$arr = explode(',',$item['attach']);
 	if(count($arr)) {
@@ -909,10 +923,67 @@ function prepare_body($item,$attach = false) {
 		}
 		$s .= '
'; } + $matches = false; + $cnt = preg_match_all('/<(.*?)>/',$item['file'],$matches,PREG_SET_ORDER); + if($cnt) { +// logger('prepare_text: categories: ' . print_r($matches,true), LOGGER_DEBUG); + foreach($matches as $mtch) { + if(strlen($x)) + $x .= ','; + $x .= xmlify(file_tag_decode($mtch[1])); + } + if(strlen($x)) + $s .= '
' . t('Categories:') . ' ' . $x . '
'; + } + $matches = false; + $x = ''; + $cnt = preg_match_all('/\[(.*?)\]/',$item['file'],$matches,PREG_SET_ORDER); + if($cnt) { +// logger('prepare_text: filed_under: ' . print_r($matches,true), LOGGER_DEBUG); + foreach($matches as $mtch) { + if(strlen($x)) + $x .= '   '; + $x .= xmlify(file_tag_decode($mtch[1])) . ' ' . t('[remove]') . ''; + } + if(strlen($x) && (local_user() == $item['uid'])) + $s .= '
' . t('Filed under:') . ' ' . $x . '
'; + } + + // Look for spoiler + $spoilersearch = '
'; + + // Remove line breaks before the spoiler + while ((strpos($s, "\n".$spoilersearch) !== false)) + $s = str_replace("\n".$spoilersearch, $spoilersearch, $s); + while ((strpos($s, "
".$spoilersearch) !== false)) + $s = str_replace("
".$spoilersearch, $spoilersearch, $s); + + while ((strpos($s, $spoilersearch) !== false)) { + + $pos = strpos($s, $spoilersearch); + $rnd = random_string(8); + $spoilerreplace = '
'.sprintf(t('Click to open/close')).''. + '