Merge remote-tracking branch 'upstream/develop' into 1601-api-statuses-lookup

This commit is contained in:
Michael Vogel 2016-04-05 23:35:33 +02:00
commit 542be50e26
152 changed files with 8519 additions and 7585 deletions

104
boot.php
View file

@ -6,11 +6,11 @@
/** /**
* Friendica * Friendica
* *
* Friendica is a communications platform for integrated social communications * Friendica is a communications platform for integrated social communications
* utilising decentralised communications and linkage to several indie social * utilising decentralised communications and linkage to several indie social
* projects - as well as popular mainstream providers. * projects - as well as popular mainstream providers.
* *
* Our mission is to free our friends and families from the clutches of * 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 * data-harvesting corporations, and pave the way to a future where social
* communications are free and open and flow between alternate providers as * communications are free and open and flow between alternate providers as
@ -18,7 +18,7 @@
*/ */
require_once('include/autoloader.php'); require_once('include/autoloader.php');
require_once('include/config.php'); require_once('include/config.php');
require_once('include/network.php'); require_once('include/network.php');
require_once('include/plugin.php'); require_once('include/plugin.php');
@ -30,7 +30,7 @@ require_once('include/cache.php');
require_once('library/Mobile_Detect/Mobile_Detect.php'); require_once('library/Mobile_Detect/Mobile_Detect.php');
require_once('include/features.php'); require_once('include/features.php');
require_once('include/identity.php'); require_once('include/identity.php');
require_once('include/pidfile.php');
require_once('update.php'); require_once('update.php');
require_once('include/dbstructure.php'); require_once('include/dbstructure.php');
@ -465,11 +465,12 @@ class App {
public $plugins; public $plugins;
public $apps = array(); public $apps = array();
public $identities; public $identities;
public $is_mobile; public $is_mobile = false;
public $is_tablet; public $is_tablet = false;
public $is_friendica_app; public $is_friendica_app;
public $performance = array(); public $performance = array();
public $callstack = array(); public $callstack = array();
public $theme_info = array();
public $nav_sel; public $nav_sel;
@ -855,11 +856,11 @@ class App {
$shortcut_icon = get_config("system", "shortcut_icon"); $shortcut_icon = get_config("system", "shortcut_icon");
if ($shortcut_icon == "") if ($shortcut_icon == "")
$shortcut_icon = $this->get_baseurl()."/images/friendica-32.png"; $shortcut_icon = "images/friendica-32.png";
$touch_icon = get_config("system", "touch_icon"); $touch_icon = get_config("system", "touch_icon");
if ($touch_icon == "") if ($touch_icon == "")
$touch_icon = $this->get_baseurl()."/images/friendica-128.png"; $touch_icon = "images/friendica-128.png";
$tpl = get_markup_template('head.tpl'); $tpl = get_markup_template('head.tpl');
$this->page['htmlhead'] = replace_macros($tpl,array( $this->page['htmlhead'] = replace_macros($tpl,array(
@ -938,6 +939,25 @@ class App {
} }
/**
* @brief Removes the baseurl from an url. This avoids some mixed content problems.
*
* @param string $url
*
* @return string The cleaned url
*/
function remove_baseurl($url){
// Is the function called statically?
if (!is_object($this))
return(self::$a->remove_baseurl($url));
$url = normalise_link($url);
$base = normalise_link($this->get_baseurl());
$url = str_replace($base."/", "", $url);
return $url;
}
/** /**
* @brief Register template engine class * @brief Register template engine class
* *
@ -1027,11 +1047,21 @@ class App {
function save_timestamp($stamp, $value) { function save_timestamp($stamp, $value) {
$duration = (float)(microtime(true)-$stamp); $duration = (float)(microtime(true)-$stamp);
if (!isset($this->performance[$value])) {
// Prevent ugly E_NOTICE
$this->performance[$value] = 0;
}
$this->performance[$value] += (float)$duration; $this->performance[$value] += (float)$duration;
$this->performance["marktime"] += (float)$duration; $this->performance["marktime"] += (float)$duration;
$callstack = $this->callstack(); $callstack = $this->callstack();
if (!isset($this->callstack[$value][$callstack])) {
// Prevent ugly E_NOTICE
$this->callstack[$value][$callstack] = 0;
}
$this->callstack[$value][$callstack] += (float)$duration; $this->callstack[$value][$callstack] += (float)$duration;
} }
@ -1068,6 +1098,55 @@ class App {
return($this->is_friendica_app); return($this->is_friendica_app);
} }
/**
* @brief Checks if the maximum load is reached
*
* @return bool Is the load reached?
*/
function maxload_reached() {
$maxsysload = intval(get_config('system', 'maxloadavg'));
if ($maxsysload < 1)
$maxsysload = 50;
$load = current_load();
if ($load) {
if (intval($load) > $maxsysload) {
logger('system: load '.$load.' too high.');
return true;
}
}
return false;
}
/**
* @brief Checks if the process is already running
*
* @param string $taskname The name of the task that will be used for the name of the lockfile
* @param string $task The path and name of the php script
* @param int $timeout The timeout after which a task should be killed
*
* @return bool Is the process running?
*/
function is_already_running($taskname, $task = "", $timeout = 540) {
$lockpath = get_lockpath();
if ($lockpath != '') {
$pidfile = new pidfile($lockpath, $taskname);
if ($pidfile->is_already_running()) {
logger("Already running");
if ($pidfile->running_time() > $timeout) {
$pidfile->kill();
logger("killed stale process");
// Calling a new instance
if ($task != "")
proc_run('php', $task);
}
return true;
}
}
return false;
}
} }
/** /**
@ -1419,7 +1498,7 @@ function login($register = false, $hiddens=false) {
$noid = get_config('system','no_openid'); $noid = get_config('system','no_openid');
$dest_url = $a->get_baseurl(true) . '/' . $a->query_string; $dest_url = $a->query_string;
if(local_user()) { if(local_user()) {
$tpl = get_markup_template("logout.tpl"); $tpl = get_markup_template("logout.tpl");
@ -1479,6 +1558,9 @@ function killme() {
* @brief Redirect to another URL and terminate this process. * @brief Redirect to another URL and terminate this process.
*/ */
function goaway($s) { function goaway($s) {
if (!strstr(normalise_link($s), "http://"))
$s = App::get_baseurl()."/".$s;
header("Location: $s"); header("Location: $s");
killme(); killme();
} }
@ -1738,9 +1820,9 @@ function current_theme_url() {
$opts = (($a->profile_uid) ? '?f=&puid=' . $a->profile_uid : ''); $opts = (($a->profile_uid) ? '?f=&puid=' . $a->profile_uid : '');
if (file_exists('view/theme/' . $t . '/style.php')) if (file_exists('view/theme/' . $t . '/style.php'))
return($a->get_baseurl() . '/view/theme/' . $t . '/style.pcss' . $opts); return('view/theme/'.$t.'/style.pcss'.$opts);
return($a->get_baseurl() . '/view/theme/' . $t . '/style.css'); return('view/theme/'.$t.'/style.css');
} }
function feed_birthday($uid,$tz) { function feed_birthday($uid,$tz) {

View file

@ -201,17 +201,6 @@ CREATE TABLE IF NOT EXISTS `deliverq` (
PRIMARY KEY(`id`) PRIMARY KEY(`id`)
) DEFAULT CHARSET=utf8; ) DEFAULT CHARSET=utf8;
--
-- TABLE dsprphotoq
--
CREATE TABLE IF NOT EXISTS `dsprphotoq` (
`id` int(10) unsigned NOT NULL auto_increment,
`uid` int(11) NOT NULL DEFAULT 0,
`msg` mediumtext NOT NULL,
`attempt` tinyint(4) NOT NULL DEFAULT 0,
PRIMARY KEY(`id`)
) DEFAULT CHARSET=utf8;
-- --
-- TABLE event -- TABLE event
-- --
@ -912,13 +901,11 @@ CREATE TABLE IF NOT EXISTS `session` (
CREATE TABLE IF NOT EXISTS `sign` ( CREATE TABLE IF NOT EXISTS `sign` (
`id` int(10) unsigned NOT NULL auto_increment, `id` int(10) unsigned NOT NULL auto_increment,
`iid` int(10) unsigned NOT NULL DEFAULT 0, `iid` int(10) unsigned NOT NULL DEFAULT 0,
`retract_iid` int(10) unsigned NOT NULL DEFAULT 0,
`signed_text` mediumtext NOT NULL, `signed_text` mediumtext NOT NULL,
`signature` text NOT NULL, `signature` text NOT NULL,
`signer` varchar(255) NOT NULL DEFAULT '', `signer` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY(`id`), PRIMARY KEY(`id`),
INDEX `iid` (`iid`), INDEX `iid` (`iid`)
INDEX `retract_iid` (`retract_iid`)
) DEFAULT CHARSET=utf8; ) DEFAULT CHARSET=utf8;
-- --

View file

@ -37,10 +37,7 @@ General
* o: Profile * o: Profile
* t: Contacts * t: Contacts
* d: Common friends * d: Common friends
* b: Toggle Blocked status * r: Advanced
* i: Toggle Ignored status
* v: Toggle Archive status
* r: Repair
/message /message
-------- --------

View file

@ -143,6 +143,56 @@ Map
You can embed maps from coordinates or addresses. You can embed maps from coordinates or addresses.
This require "openstreetmap" addon version 1.3 or newer. This require "openstreetmap" addon version 1.3 or newer.
-----------------------------------------------------------
Abstract for longer posts
-------------------------
If you want to spread your post to several third party networks you can have the problem that these networks have (for example) a length limitation.
(Like on Twitter)
Friendica is using a semi intelligent mechanism to generate a fitting abstract.
But it can be interesting to define an own abstract that will only be displayed on the external network.
This is done with the [abstract]-element.
Example:
<pre>[abstract]Totally interesting! A must-see! Please click the link![/abstract]
I want to tell you a really boring story that you really never wanted
to hear.</pre>
Twitter would display the text "Totally interesting! A must-see! Please click the link!".
On Friendica you would only see the text after "I want to tell you a really ..."
It is even possible to define abstracts for separate networks:
<pre>
[abstract]Hi friends Here are my newest pictures![abstract]
[abstract=twit]Hi my dear Twitter followers. Do you want to see my new
pictures?[abstract]
[abstract=apdn]Helly my dear followers on ADN. I made sone new pictures
that I wanted to share with you.[abstract]
Today I was in the woods and took some real cool pictures ...
</pre>
For Twitter and App.net the system will use the defined abstracts.
For other networks (e.g. when you are using the "statusnet" connector that is used to post to GNU Social) the general abstract element will be used.
If you use (for example) the "buffer" connector to post to Facebook or Google+ you can use this element to define an abstract for a longer blogpost that you don't want to post completely to these networks.
Networks like Facebook or Google+ aren't length limited.
For this reason the [abstract] element isn't used.
Instead you have to name the explicit network:
<pre>
[abstract]These days I had a strange encounter ...[abstract]
[abstract=goog]Helly my dear Google+ followers. You have to read my
newest blog post![abstract]
[abstract=face]Hello my Facebook friends. These days happened something
really cool.[abstract]
While taking pictures in the woods I had a really strange encounter ... </pre>
The [abstract] element isn't working with the native OStatus connection or with connectors where we post the HTML.
(Like Tumblr, Wordpress or Pump.io)
Special Special
------- -------
@ -150,5 +200,3 @@ Special
If you need to put literal bbcode in a message, [noparse], [nobb] or [pre] are used to escape bbcode: If you need to put literal bbcode in a message, [noparse], [nobb] or [pre] are used to escape bbcode:
<pre>[noparse][b]bold[/b][/noparse]</pre> : [b]bold[/b] <pre>[noparse][b]bold[/b][/noparse]</pre> : [b]bold[/b]

View file

@ -6,6 +6,8 @@ Bugs and Issues
If your server has a support page, you should report any bugs/issues you encounter there first. 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. 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.
This helps us get new features faster. This helps us get new features faster.
You can also contact the [friendica support forum](https://helpers.pyxis.uberspace.de/profile/helpers) and report your problem there.
Maybe someone from another node encountered the problem as well and can help you.
If you're a technical user, or your site doesn't have a support page, you'll need to use the [Bug Tracker](http://bugs.friendica.com/). If you're a technical user, or your site doesn't have a support page, you'll need to use the [Bug Tracker](http://bugs.friendica.com/).
Please perform a search to see if there's already an open bug that matches yours before submitting anything. Please perform a search to see if there's already an open bug that matches yours before submitting anything.

View file

@ -57,13 +57,15 @@ All that the pages need to have is a discoverable feed using either the RSS or A
Twitter Twitter
--- ---
To follow a Twitter member, put the URL of the Twitter member's main page into the Connect box on your [Contacts](contacts) page. To follow a Twitter member, the Twitter-Connector (Addon) needs to be configured on your node.
If this is the case put the URL of the Twitter member's main page into the Connect box on your [Contacts](contacts) page.
To reply, you must have the Twitter connector installed, and reply using your own status editor. To reply, you must have the Twitter connector installed, and reply using your own status editor.
Begin the message with @twitterperson replacing with the Twitter username. Begin the message with @twitterperson replacing with the Twitter username.
Email Email
--- ---
If the php module for IMAP support is available on your server, Friendica can connect to email contacts as well.
Configure the email connector from your [Settings](settings) page. Configure the email connector from your [Settings](settings) page.
Once this has been done, you may enter an email address to connect with using the Connect box on your [Contacts](contacts) page. Once this has been done, you may enter an email address to connect with using the Connect box on your [Contacts](contacts) page.
They must be the sender of a message which is currently in your INBOX for the connection to succeed. They must be the sender of a message which is currently in your INBOX for the connection to succeed.

View file

@ -83,11 +83,11 @@ Ask us to find out whom to talk to about their experiences.
Do not worry about cross-posting. Do not worry about cross-posting.
###Client software ###Client software
There are free software clients that do somehow work with Friendica but most of them need love and maintenance. As Friendica is using a [Twitter/GNU Social compatible API](help/api) any of the clients for those platforms should work with Friendica as well.
Also, they were mostly made for other platforms using the GNU Social API. Furthermore there are several client projects, especially for use with Friendica.
This means they lack the features that are really specific to Friendica. If you are interested in improving those clients, please contact the developers of the clients directly.
Popular clients you might want to have a look at are:
* [Hotot (Linux)](http://hotot.org/) - abandoned * Android / CynogenMod: **Friendica for Android** [src](https://github.com/max-weller/friendica-for-android), [homepage](http://friendica.android.max-weller.de/) - abandoned
* [Friendica for Android](https://github.com/max-weller/friendica-for-android) - abandoned * iOS: *currently no client*
* You can find more working client software in [Wikipedia](https://en.wikipedia.org/wiki/Friendica). * SailfishOS: **Friendiy** [src](https://kirgroup.com/projects/fabrixxm/harbour-friendly) - developed by [Fabio](https://kirgroup.com/profile/fabrixxm/?tab=profile)
* Windows: **Friendica Mobile** for Windows versions [before 8.1](http://windowsphone.com/s?appid=e3257730-c9cf-4935-9620-5261e3505c67) and [Windows 10](https://www.microsoft.com/store/apps/9nblggh0fhmn) - developed by [Gerhard Seeber](http://mozartweg.dyndns.org/friendica/profile/gerhard/?tab=profile)

View file

@ -11,8 +11,6 @@ Hot Keys
Friendica traps the following keyboard events: Friendica traps the following keyboard events:
* [Pause] - Pauses "Ajax" update activity. This is the process that provides updates without reloading the page. You may wish to pause it to reduce network usage and/or as a debugging aid for javascript developers. A pause indicator will appear at the lower right hand corner of the page. Hit the [pause] key once again to resume. * [Pause] - Pauses "Ajax" update activity. This is the process that provides updates without reloading the page. You may wish to pause it to reduce network usage and/or as a debugging aid for javascript developers. A pause indicator will appear at the lower right hand corner of the page. Hit the [pause] key once again to resume.
* [F8] - Displays a language selector
Birthday Notifications Birthday Notifications
--- ---

View file

@ -1,6 +1,6 @@
Friendica API Friendica API
=== ===
The Friendica API aims to be compatible to the [GNU Social API](http://skilledtests.com/wiki/Twitter-compatible_API) and the [Twitter API](https://dev.twitter.com/rest/public). The Friendica API aims to be compatible to the [GNU Social API](http://wiki.gnusocial.de/gnusocial:api) and the [Twitter API](https://dev.twitter.com/rest/public).
Please refer to the linked documentation for further information. Please refer to the linked documentation for further information.
@ -388,6 +388,18 @@ Friendica doesn't allow showing friends of other users.
--- ---
### statusnet/config (*) ### statusnet/config (*)
---
### statusnet/conversation (*; AUTH)
It shows all direct answers (excluding the original post) to a given id.
#### Parameter
* id: id of the post
* count: Items per page (default: 20)
* page: page number
* since_id: minimal id
* max_id: maximum id
* include_entities: "true" shows entities for pictures and links (Default: false)
--- ---
### statusnet/version (*) ### statusnet/version (*)

View file

@ -15,7 +15,6 @@ Database Tables
| [contact](help/database/db_contact) | contact table | | [contact](help/database/db_contact) | contact table |
| [conv](help/database/db_conv) | private messages | | [conv](help/database/db_conv) | private messages |
| [deliverq](help/database/db_deliverq) | | | [deliverq](help/database/db_deliverq) | |
| [dsprphotoq](help/database/db_dsprphotoq) | |
| [event](help/database/db_event) | Events | | [event](help/database/db_event) | Events |
| [fcontact](help/database/db_fcontact) | friend suggestion stuff | | [fcontact](help/database/db_fcontact) | friend suggestion stuff |
| [ffinder](help/database/db_ffinder) | friend suggestion stuff | | [ffinder](help/database/db_ffinder) | friend suggestion stuff |

View file

@ -1,11 +0,0 @@
Table dsprphotoq
================
| Field | Description | Type | Null | Key | Default | Extra |
|---------|------------------|------------------|------|-----|---------|----------------|
| id | sequential ID | int(10) unsigned | NO | PRI | NULL | auto_increment |
| uid | | int(11) | NO | | 0 | |
| msg | | mediumtext | NO | | NULL | |
| attempt | | tinyint(4) | NO | | 0 | |
Return to [database documentation](help/database)

View file

@ -5,7 +5,6 @@ Table sign
| ------------ | ------------- | ---------------- | ---- | --- | ------- | --------------- | | ------------ | ------------- | ---------------- | ---- | --- | ------- | --------------- |
| id | sequential ID | int(10) unsigned | NO | PRI | NULL | auto_increment | | id | sequential ID | int(10) unsigned | NO | PRI | NULL | auto_increment |
| iid | item.id | int(10) unsigned | NO | MUL | 0 | | | iid | item.id | int(10) unsigned | NO | MUL | 0 | |
| retract_iid | | int(10) unsigned | NO | MUL | 0 | |
| signed_text | | mediumtext | NO | | NULL | | | signed_text | | mediumtext | NO | | NULL | |
| signature | | text | NO | | NULL | | | signature | | text | NO | | NULL | |
| signer | | varchar(255) | NO | | | | | signer | | varchar(255) | NO | | | |

View file

@ -131,8 +131,7 @@ Au&szlig;erdem kann *url* die genaue url zu einer ogg Datei sein, die dann per H
<pre>[url]*url*[/url]</pre> <pre>[url]*url*[/url]</pre>
Wenn *url* entweder oembed oder opengraph unterstützt wird das eingebettete Wenn *url* entweder oembed oder opengraph unterstützt wird das eingebettete Objekt (z.B. ein Dokument von scribd) eingebunden.
Objekt (z.B. ein Dokument von scribd) eingebunden.
Der Titel der Seite mit einem Link zur *url* wird ebenfalls angezeigt. Der Titel der Seite mit einem Link zur *url* wird ebenfalls angezeigt.
Um eine Karte in einen Beitrag einzubinden, muss das *openstreetmap* Addon aktiviert werden. Ist dies der Fall, kann mit Um eine Karte in einen Beitrag einzubinden, muss das *openstreetmap* Addon aktiviert werden. Ist dies der Fall, kann mit
@ -145,11 +144,54 @@ eine Karte von [OpenStreetmap](http://openstreetmap.org) eingebettet werden. Zur
oder eine Adresse in obiger Form verwendet werden. oder eine Adresse in obiger Form verwendet werden.
Zusammenfassung für längere Beiträge
------------------------------------
Wenn man seine Beiträge über mehrere Netzwerke verbreiten möchte, hat man häufig das Problem, dass diese Netzwerke z.B. eine Längenbeschränkung haben.
(Z.B. Twitter).
Friendica benutzt zum Erzeugen eines Anreißtextes eine halbwegs intelligente Logik.
Es kann aber dennoch von Interesse sein, eine eigene Zusammenfassung zu erstellen, die nur auf dem Fremdnetzwerk dargestellt wird.
Dies geschieht mit dem [abstract]-Element.
Beispiel:
<pre>[abstract]Total spannend! Unbedingt diesen Link anklicken![/abstract]
Hier erzähle ich euch eine total langweilige Geschichte, die ihr noch
nie hören wolltet.</pre>
Auf Twitter würde das "Total spannend! Unbedingt diesen Link anklicken!" stehen, auf Friendica würde nur der Text nach "Hier erzähle ..." erscheinen.
Es ist sogar möglich, für einzelne Netzwerke eigene Zusammenfassungen zu erstellen:
<pre>
[abstract]Hallo Leute, hier meine neuesten Bilder![abstract]
[abstract=twit]Hallo Twitter-User, hier meine neuesten Bilder![abstract]
[abstract=apdn]Hallo App.net-User, hier meine neuesten Bilder![abstract]
Ich war heute wieder im Wald unterwegs und habe tolle Bilder geschossen ...
</pre>
Für Twitter und App.net nimmt das System die entsprechenden Texte.
Bei anderen Netzwerken, bei denen der Inhalt gekürzt wird (z.B. beim "statusnet"-Connector, der für das Posten nach GNU Social verwendet wird) wird dann die Zusammenfassung unter [abstract] verwendet.
Wenn man z.B. den "buffer"-Connector verwendet, um nach Facebook oder Google+ zu posten, kann man dieses Element ebenfalls verwenden, wenn man z.B. einen längeren Blogbeitrag erstellt hat, aber ihn nicht komplett in diese Netzwerke posten möchte.
Netzwerke wie Facebook oder Google+ sind nicht in der Postinglänge beschränkt.
Aus diesem Grund greift nicht die [abstract]-Zusammenfassung. Stattdessen muss man das Netzwerk explizit angeben:
<pre>
[abstract]Ich habe neulich wieder etwas erlebt, was ich euch mitteilen möchte.[abstract]
[abstract=goog]Hallo meine Google+-Kreislinge. Ich habe neulich wieder
etwas erlebt, was ich euch mitteilen möchte.[abstract]
[abstract=face]Hallo Facebook-Freunde! Ich habe neulich wieder etwas
erlebt, was ich euch mitteilen möchte.[abstract]
Beim Bildermachen im Wald habe ich neulich eine interessante Person
getroffen ... </pre>
Das [abstract]-Element greift nicht bei der nativen OStatus-Verbindung oder bei Connectoren, die den HTML-Text posten wie z.B. die Connectoren zu Tumblr, Wordpress oder Pump.io.
Spezielle Tags Spezielle Tags
------- -------
Wenn Du &uuml;ber BBCode Tags in einer Nachricht schreiben m&ouml;chtest, kannst Du [noparse], [nobb] oder [pre] verwenden um den BBCode Tags vor der Evaluierung zu sch&uuml;tzen: Wenn Du &uuml;ber BBCode Tags in einer Nachricht schreiben m&ouml;chtest, kannst Du [noparse], [nobb] oder [pre] verwenden um den BBCode Tags vor der Evaluierung zu sch&uuml;tzen:
<pre>[noparse][b]fett[/b][/noparse]</pre> : [b]fett[/b] <pre>[noparse][b]fett[/b][/noparse]</pre> : [b]fett[/b]

View file

@ -14,9 +14,6 @@ Friendica erfasst die folgenden Tastaturbefehle:
* [Pause] - Pausiert die Update-Aktivität via "Ajax". Das ist ein Prozess, der Updates durchführt, ohne die Seite neu zu laden. Du kannst diesen Prozess pausieren, um deine Netzwerkauslastung zu reduzieren und/oder um es in der Javascript-Programmierung zum Debuggen zu nutzen. Ein Pausenzeichen erscheint unten links im Fenster. Klicke die [Pause]-Taste ein weiteres Mal, um die Pause zu beenden. * [Pause] - Pausiert die Update-Aktivität via "Ajax". Das ist ein Prozess, der Updates durchführt, ohne die Seite neu zu laden. Du kannst diesen Prozess pausieren, um deine Netzwerkauslastung zu reduzieren und/oder um es in der Javascript-Programmierung zum Debuggen zu nutzen. Ein Pausenzeichen erscheint unten links im Fenster. Klicke die [Pause]-Taste ein weiteres Mal, um die Pause zu beenden.
* [F8] - Zeigt eine Sprachauswahl an
**Geburtstagsbenachrichtigung** **Geburtstagsbenachrichtigung**
Geburtstage erscheinen auf deiner Startseite für alle Freunde, die in den nächsten 6 Tagen Geburtstag haben. Geburtstage erscheinen auf deiner Startseite für alle Freunde, die in den nächsten 6 Tagen Geburtstag haben.

View file

@ -64,9 +64,6 @@ line to your .htconfig.php:
* throttle_limit_week - Maximum number of posts that a user can send per week with the API. * throttle_limit_week - Maximum number of posts that a user can send per week with the API.
* throttle_limit_month - Maximum number of posts that a user can send per month with the API. * throttle_limit_month - Maximum number of posts that a user can send per month with the API.
* wall-to-wall_share (Boolean) - Displays forwarded posts like "wall-to-wall" posts. * wall-to-wall_share (Boolean) - Displays forwarded posts like "wall-to-wall" posts.
* worker (Boolean) - (Experimental) Use the worker system instead of calling several background processes. Reduces the overall load and speeds up item delivery.
* worker_dont_fork (Boolean) - if enabled, the workers are only called from the poller process. Useful on systems that permit the use of "proc_open".
* worker_queues - Number of parallel workers. Default value is 10 queues.
* xrd_timeout - Timeout for fetching the XRD links. Default value is 20 seconds. * xrd_timeout - Timeout for fetching the XRD links. Default value is 20 seconds.
## service_class ## ## service_class ##

View file

@ -129,7 +129,7 @@ function terminate_friendship($user,$self,$contact) {
} }
elseif($contact['network'] === NETWORK_DIASPORA) { elseif($contact['network'] === NETWORK_DIASPORA) {
require_once('include/diaspora.php'); require_once('include/diaspora.php');
diaspora_unshare($user,$contact); diaspora::send_unshare($user,$contact);
} }
elseif($contact['network'] === NETWORK_DFRN) { elseif($contact['network'] === NETWORK_DFRN) {
require_once('include/dfrn.php'); require_once('include/dfrn.php');
@ -555,60 +555,6 @@ function posts_from_gcontact($a, $gcontact_id) {
return $o; return $o;
} }
/**
* @brief set the gcontact-id in all item entries
*
* This job has to be started multiple times until all entries are set.
* It isn't started in the update function since it would consume too much time and can be done in the background.
*/
function item_set_gcontact() {
define ('POST_UPDATE_VERSION', 1192);
// Was the script completed?
if (get_config("system", "post_update_version") >= POST_UPDATE_VERSION)
return;
// Check if the first step is done (Setting "gcontact-id" in the item table)
$r = q("SELECT `author-link`, `author-name`, `author-avatar`, `uid`, `network` FROM `item` WHERE `gcontact-id` = 0 LIMIT 1000");
if (!$r) {
// Are there unfinished entries in the thread table?
$r = q("SELECT COUNT(*) AS `total` FROM `thread`
INNER JOIN `item` ON `item`.`id` =`thread`.`iid`
WHERE `thread`.`gcontact-id` = 0 AND
(`thread`.`uid` IN (SELECT `uid` from `user`) OR `thread`.`uid` = 0)");
if ($r AND ($r[0]["total"] == 0)) {
set_config("system", "post_update_version", POST_UPDATE_VERSION);
return false;
}
// Update the thread table from the item table
q("UPDATE `thread` INNER JOIN `item` ON `item`.`id`=`thread`.`iid`
SET `thread`.`gcontact-id` = `item`.`gcontact-id`
WHERE `thread`.`gcontact-id` = 0 AND
(`thread`.`uid` IN (SELECT `uid` from `user`) OR `thread`.`uid` = 0)");
return false;
}
$item_arr = array();
foreach ($r AS $item) {
$index = $item["author-link"]."-".$item["uid"];
$item_arr[$index] = array("author-link" => $item["author-link"],
"uid" => $item["uid"],
"network" => $item["network"]);
}
// Set the "gcontact-id" in the item table and add a new gcontact entry if needed
foreach($item_arr AS $item) {
$gcontact_id = get_gcontact_id(array("url" => $item['author-link'], "network" => $item['network'],
"photo" => $item['author-avatar'], "name" => $item['author-name']));
q("UPDATE `item` SET `gcontact-id` = %d WHERE `uid` = %d AND `author-link` = '%s' AND `gcontact-id` = 0",
intval($gcontact_id), intval($item["uid"]), dbesc($item["author-link"]));
}
return true;
}
/** /**
* @brief Returns posts from a given contact * @brief Returns posts from a given contact
* *

View file

@ -95,12 +95,12 @@ class ForumManager {
$selected = (($cid == $contact['id']) ? ' forum-selected' : ''); $selected = (($cid == $contact['id']) ? ' forum-selected' : '');
$entry = array( $entry = array(
'url' => z_root() . '/network?f=&cid=' . $contact['id'], 'url' => 'network?f=&cid=' . $contact['id'],
'external_url' => z_root() . '/redir/' . $contact['id'], 'external_url' => 'redir/' . $contact['id'],
'name' => $contact['name'], 'name' => $contact['name'],
'cid' => $contact['id'], 'cid' => $contact['id'],
'selected' => $selected, 'selected' => $selected,
'micro' => proxy_url($contact['micro'], false, PROXY_SIZE_MICRO), 'micro' => App::remove_baseurl(proxy_url($contact['micro'], false, PROXY_SIZE_MICRO)),
'id' => ++$id, 'id' => ++$id,
); );
$entries[] = $entry; $entries[] = $entry;
@ -187,4 +187,4 @@ class ForumManager {
return $r; return $r;
} }
} }

View file

@ -23,13 +23,15 @@ function scrape_dfrn($url, $dont_probe = false) {
if (is_array($noscrapedata)) { if (is_array($noscrapedata)) {
if ($noscrapedata["nick"] != "") if ($noscrapedata["nick"] != "")
return($noscrapedata); return($noscrapedata);
else
unset($noscrapedata["nick"]);
} else } else
$noscrapedata = array(); $noscrapedata = array();
} }
$s = fetch_url($url); $s = fetch_url($url);
if(! $s) if (!$s)
return $ret; return $ret;
if (!$dont_probe) { if (!$dont_probe) {
@ -356,7 +358,7 @@ function probe_url($url, $mode = PROBE_NORMAL, $level = 1) {
$result = array(); $result = array();
if(! $url) if (!$url)
return $result; return $result;
$result = Cache::get("probe_url:".$mode.":".$url); $result = Cache::get("probe_url:".$mode.":".$url);
@ -365,6 +367,7 @@ function probe_url($url, $mode = PROBE_NORMAL, $level = 1) {
return $result; return $result;
} }
$original_url = $url;
$network = null; $network = null;
$diaspora = false; $diaspora = false;
$diaspora_base = ''; $diaspora_base = '';
@ -393,7 +396,12 @@ function probe_url($url, $mode = PROBE_NORMAL, $level = 1) {
else else
$links = lrdd($url); $links = lrdd($url);
if(count($links)) { if ((count($links) == 0) AND strstr($url, "/index.php")) {
$url = str_replace("/index.php", "", $url);
$links = lrdd($url);
}
if (count($links)) {
$has_lrdd = true; $has_lrdd = true;
logger('probe_url: found lrdd links: ' . print_r($links,true), LOGGER_DATA); logger('probe_url: found lrdd links: ' . print_r($links,true), LOGGER_DATA);
@ -440,12 +448,21 @@ function probe_url($url, $mode = PROBE_NORMAL, $level = 1) {
// aliases, let's hope we're lucky and get one that matches the feed author-uri because // aliases, let's hope we're lucky and get one that matches the feed author-uri because
// otherwise we're screwed. // otherwise we're screwed.
$backup_alias = "";
foreach($links as $link) { foreach($links as $link) {
if($link['@attributes']['rel'] === 'alias') { if($link['@attributes']['rel'] === 'alias') {
if(strpos($link['@attributes']['href'],'@') === false) { if(strpos($link['@attributes']['href'],'@') === false) {
if(isset($profile)) { if(isset($profile)) {
if($link['@attributes']['href'] !== $profile) $alias_url = $link['@attributes']['href'];
$alias = unamp($link['@attributes']['href']);
if(($alias_url !== $profile) AND ($backup_alias == "") AND
($alias_url !== str_replace("/index.php", "", $profile)))
$backup_alias = $alias_url;
if(($alias_url !== $profile) AND !strstr($alias_url, "index.php") AND
($alias_url !== str_replace("/index.php", "", $profile)))
$alias = $alias_url;
} }
else else
$profile = unamp($link['@attributes']['href']); $profile = unamp($link['@attributes']['href']);
@ -453,6 +470,9 @@ function probe_url($url, $mode = PROBE_NORMAL, $level = 1) {
} }
} }
if ($alias == "")
$alias = $backup_alias;
// If the profile is different from the url then the url is abviously an alias // If the profile is different from the url then the url is abviously an alias
if (($alias == "") AND ($profile != "") AND !$at_addr AND (normalise_link($profile) != normalise_link($url))) if (($alias == "") AND ($profile != "") AND !$at_addr AND (normalise_link($profile) != normalise_link($url)))
$alias = $url; $alias = $url;
@ -685,7 +705,14 @@ function probe_url($url, $mode = PROBE_NORMAL, $level = 1) {
if (($vcard["nick"] == "") AND ($data["header"]["author-nick"] != "")) if (($vcard["nick"] == "") AND ($data["header"]["author-nick"] != ""))
$vcard["nick"] = $data["header"]["author-nick"]; $vcard["nick"] = $data["header"]["author-nick"];
if(!$profile AND ($data["header"]["author-link"] != "") AND !in_array($network, array("", NETWORK_FEED))) if ($network == NETWORK_OSTATUS) {
if ($data["header"]["author-id"] != "")
$alias = $data["header"]["author-id"];
if ($data["header"]["author-link"] != "")
$profile = $data["header"]["author-link"];
} elseif(!$profile AND ($data["header"]["author-link"] != "") AND !in_array($network, array("", NETWORK_FEED)))
$profile = $data["header"]["author-link"]; $profile = $data["header"]["author-link"];
} }
} }
@ -769,6 +796,9 @@ function probe_url($url, $mode = PROBE_NORMAL, $level = 1) {
if (($baseurl == "") AND ($poll != "")) if (($baseurl == "") AND ($poll != ""))
$baseurl = matching_url(normalise_link($profile), normalise_link($poll)); $baseurl = matching_url(normalise_link($profile), normalise_link($poll));
if (substr($baseurl, -10) == "/index.php")
$baseurl = str_replace("/index.php", "", $baseurl);
$baseurl = rtrim($baseurl, "/"); $baseurl = rtrim($baseurl, "/");
if(strpos($url,'@') AND ($addr == "") AND ($network == NETWORK_DFRN)) if(strpos($url,'@') AND ($addr == "") AND ($network == NETWORK_DFRN))
@ -816,8 +846,28 @@ function probe_url($url, $mode = PROBE_NORMAL, $level = 1) {
} }
// Only store into the cache if the value seems to be valid // Only store into the cache if the value seems to be valid
if ($result['network'] != NETWORK_PHANTOM) if ($result['network'] != NETWORK_PHANTOM) {
Cache::set("probe_url:".$mode.":".$url,serialize($result), CACHE_DAY); Cache::set("probe_url:".$mode.":".$original_url,serialize($result), CACHE_DAY);
/// @todo temporary fix - we need a real contact update function that updates only changing fields
/// The biggest problem is the avatar picture that could have a reduced image size.
/// It should only be updated if the existing picture isn't existing anymore.
if (($result['network'] != NETWORK_FEED) AND ($mode == PROBE_NORMAL) AND
$result["name"] AND $result["nick"] AND $result["url"] AND $result["addr"] AND $result["poll"])
q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `url` = '%s', `addr` = '%s',
`notify` = '%s', `poll` = '%s', `alias` = '%s', `success_update` = '%s'
WHERE `nurl` = '%s' AND NOT `self` AND `uid` = 0",
dbesc($result["name"]),
dbesc($result["nick"]),
dbesc($result["url"]),
dbesc($result["addr"]),
dbesc($result["notify"]),
dbesc($result["poll"]),
dbesc($result["alias"]),
dbesc(datetime_convert()),
dbesc(normalise_link($result['url']))
);
}
return $result; return $result;
} }

View file

@ -161,10 +161,7 @@
if (!isset($_SERVER['PHP_AUTH_USER'])) { if (!isset($_SERVER['PHP_AUTH_USER'])) {
logger('API_login: ' . print_r($_SERVER,true), LOGGER_DEBUG); logger('API_login: ' . print_r($_SERVER,true), LOGGER_DEBUG);
header('WWW-Authenticate: Basic realm="Friendica"'); header('WWW-Authenticate: Basic realm="Friendica"');
header('HTTP/1.0 401 Unauthorized'); throw new UnauthorizedException("This API requires login");
die((api_error($a, 'json', "This api requires login")));
//die('This api requires login');
} }
$user = $_SERVER['PHP_AUTH_USER']; $user = $_SERVER['PHP_AUTH_USER'];
@ -216,8 +213,9 @@
if((! $record) || (! count($record))) { if((! $record) || (! count($record))) {
logger('API_login failure: ' . print_r($_SERVER,true), LOGGER_DEBUG); logger('API_login failure: ' . print_r($_SERVER,true), LOGGER_DEBUG);
header('WWW-Authenticate: Basic realm="Friendica"'); header('WWW-Authenticate: Basic realm="Friendica"');
header('HTTP/1.0 401 Unauthorized'); #header('HTTP/1.0 401 Unauthorized');
die('This api requires login'); #die('This api requires login');
throw new UnauthorizedException("This API requires login");
} }
authenticate_success($record); $_SESSION["allow_api"] = true; authenticate_success($record); $_SESSION["allow_api"] = true;
@ -332,7 +330,8 @@
* *
* @param Api $a * @param Api $a
* @param string $type Return type (xml, json, rss, as) * @param string $type Return type (xml, json, rss, as)
* @param string $error Error message * @param HTTPException $error Error object
* @return strin error message formatted as $type
*/ */
function api_error(&$a, $type, $e) { function api_error(&$a, $type, $e) {
$error = ($e->getMessage()!==""?$e->getMessage():$e->httpdesc); $error = ($e->getMessage()!==""?$e->getMessage():$e->httpdesc);
@ -904,7 +903,8 @@
if ($posts_day > $throttle_day) { if ($posts_day > $throttle_day) {
logger('Daily posting limit reached for user '.api_user(), LOGGER_DEBUG); logger('Daily posting limit reached for user '.api_user(), LOGGER_DEBUG);
die(api_error($a, $type, sprintf(t("Daily posting limit of %d posts reached. The post was rejected."), $throttle_day))); #die(api_error($a, $type, sprintf(t("Daily posting limit of %d posts reached. The post was rejected."), $throttle_day)));
throw new TooManyRequestsException(sprintf(t("Daily posting limit of %d posts reached. The post was rejected."), $throttle_day));
} }
} }
@ -923,7 +923,9 @@
if ($posts_week > $throttle_week) { if ($posts_week > $throttle_week) {
logger('Weekly posting limit reached for user '.api_user(), LOGGER_DEBUG); logger('Weekly posting limit reached for user '.api_user(), LOGGER_DEBUG);
die(api_error($a, $type, sprintf(t("Weekly posting limit of %d posts reached. The post was rejected."), $throttle_week))); #die(api_error($a, $type, sprintf(t("Weekly posting limit of %d posts reached. The post was rejected."), $throttle_week)));
throw new TooManyRequestsException(sprintf(t("Weekly posting limit of %d posts reached. The post was rejected."), $throttle_week));
} }
} }
@ -942,7 +944,8 @@
if ($posts_month > $throttle_month) { if ($posts_month > $throttle_month) {
logger('Monthly posting limit reached for user '.api_user(), LOGGER_DEBUG); logger('Monthly posting limit reached for user '.api_user(), LOGGER_DEBUG);
die(api_error($a, $type, sprintf(t("Monthly posting limit of %d posts reached. The post was rejected."), $throttle_month))); #die(api_error($a, $type, sprintf(t("Monthly posting limit of %d posts reached. The post was rejected."), $throttle_month)));
throw new TooManyRequestsException(sprintf(t("Monthly posting limit of %d posts reached. The post was rejected."), $throttle_month));
} }
} }
@ -1548,6 +1551,7 @@
return api_apply_template("timeline", $type, $data); return api_apply_template("timeline", $type, $data);
} }
api_register_func('api/conversation/show','api_conversation_show', true); api_register_func('api/conversation/show','api_conversation_show', true);
api_register_func('api/statusnet/conversation','api_conversation_show', true);
/** /**
@ -1689,13 +1693,13 @@
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
FROM `item`, `contact` FROM `item` FORCE INDEX (`uid_id`), `contact`
WHERE `item`.`uid` = %d AND `verb` = '%s' WHERE `item`.`uid` = %d AND `verb` = '%s'
AND NOT (`item`.`author-link` IN ('https://%s', 'http://%s')) AND NOT (`item`.`author-link` IN ('https://%s', 'http://%s'))
AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0 AND `item`.`visible` AND NOT `item`.`moderated` AND NOT `item`.`deleted`
AND `contact`.`id` = `item`.`contact-id` AND `contact`.`id` = `item`.`contact-id`
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND NOT `contact`.`blocked` AND NOT `contact`.`pending`
AND `item`.`parent` IN (SELECT `iid` from thread where uid = %d AND `mention` AND !`ignored`) AND `item`.`parent` IN (SELECT `iid` FROM `thread` WHERE `uid` = %d AND `mention` AND !`ignored`)
$sql_extra $sql_extra
AND `item`.`id`>%d AND `item`.`id`>%d
ORDER BY `item`.`id` DESC LIMIT %d ,%d ", ORDER BY `item`.`id` DESC LIMIT %d ,%d ",
@ -1810,7 +1814,7 @@
$action_argv_id=2; $action_argv_id=2;
if ($a->argv[1]=="1.1") $action_argv_id=3; if ($a->argv[1]=="1.1") $action_argv_id=3;
if ($a->argc<=$action_argv_id) die(api_error($a, $type, t("Invalid request."))); if ($a->argc<=$action_argv_id) throw new BadRequestException("Invalid request.");
$action = str_replace(".".$type,"",$a->argv[$action_argv_id]); $action = str_replace(".".$type,"",$a->argv[$action_argv_id]);
if ($a->argc==$action_argv_id+2) { if ($a->argc==$action_argv_id+2) {
$itemid = intval($a->argv[$action_argv_id+1]); $itemid = intval($a->argv[$action_argv_id+1]);

View file

@ -311,6 +311,9 @@ function tryoembed($match){
$o = oembed_fetch_url($url); $o = oembed_fetch_url($url);
if (!is_object($o))
return $match[0];
if (isset($match[2])) if (isset($match[2]))
$o->title = $match[2]; $o->title = $match[2];
@ -858,6 +861,8 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
$Text = preg_replace_callback("/\[nobb\](.*?)\[\/nobb\]/ism", 'bb_spacefy',$Text); $Text = preg_replace_callback("/\[nobb\](.*?)\[\/nobb\]/ism", 'bb_spacefy',$Text);
$Text = preg_replace_callback("/\[pre\](.*?)\[\/pre\]/ism", 'bb_spacefy',$Text); $Text = preg_replace_callback("/\[pre\](.*?)\[\/pre\]/ism", 'bb_spacefy',$Text);
// Remove the abstract element. It is a non visible element.
$Text = remove_abstract($Text);
// Move all spaces out of the tags // Move all spaces out of the tags
$Text = preg_replace("/\[(\w*)\](\s*)/ism", '$2[$1]', $Text); $Text = preg_replace("/\[(\w*)\](\s*)/ism", '$2[$1]', $Text);
@ -1300,4 +1305,43 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
return trim($Text); return trim($Text);
} }
/**
* @brief Removes the "abstract" element from the text
*
* @param string $text The text with BBCode
* @return string The same text - but without "abstract" element
*/
function remove_abstract($text) {
$text = preg_replace("/[\s|\n]*\[abstract\].*?\[\/abstract\][\s|\n]*/ism", '', $text);
$text = preg_replace("/[\s|\n]*\[abstract=.*?\].*?\[\/abstract][\s|\n]*/ism", '', $text);
return $text;
}
/**
* @brief Returns the value of the "abstract" element
*
* @param string $text The text that maybe contains the element
* @param string $addon The addon for which the abstract is meant for
* @return string The abstract
*/
function fetch_abstract($text, $addon = "") {
$abstract = "";
$abstracts = array();
$addon = strtolower($addon);
if (preg_match_all("/\[abstract=(.*?)\](.*?)\[\/abstract\]/ism",$text, $results, PREG_SET_ORDER))
foreach ($results AS $result)
$abstracts[strtolower($result[1])] = $result[2];
if (isset($abstracts[$addon]))
$abstract = $abstracts[$addon];
if ($abstract == "")
if (preg_match("/\[abstract\](.*?)\[\/abstract\]/ism",$text, $result))
$abstract = $result[1];
return $abstract;
}
?> ?>

View file

@ -99,7 +99,7 @@ function network_to_name($s, $profile = "") {
$networkname = str_replace($search,$replace,$s); $networkname = str_replace($search,$replace,$s);
if (($s == NETWORK_DIASPORA) AND ($profile != "") AND diaspora_is_redmatrix($profile)) { if (($s == NETWORK_DIASPORA) AND ($profile != "") AND diaspora::is_redmatrix($profile)) {
$networkname = t("Hubzilla/Redmatrix"); $networkname = t("Hubzilla/Redmatrix");
$r = q("SELECT `gserver`.`platform` FROM `gcontact` $r = q("SELECT `gserver`.`platform` FROM `gcontact`

View file

@ -614,7 +614,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
if(($normalised != 'mailbox') && (x($a->contacts[$normalised]))) if(($normalised != 'mailbox') && (x($a->contacts[$normalised])))
$profile_avatar = $a->contacts[$normalised]['thumb']; $profile_avatar = $a->contacts[$normalised]['thumb'];
else else
$profile_avatar = ((strlen($item['author-avatar'])) ? $a->get_cached_avatar_image($item['author-avatar']) : $item['thumb']); $profile_avatar = $a->remove_baseurl(((strlen($item['author-avatar'])) ? $item['author-avatar'] : $item['thumb']));
$locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => ''); $locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => '');
call_hooks('render_location',$locate); call_hooks('render_location',$locate);
@ -707,8 +707,8 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
'like' => '', 'like' => '',
'dislike' => '', 'dislike' => '',
'comment' => '', 'comment' => '',
//'conv' => (($preview) ? '' : array('href'=> $a->get_baseurl($ssl_state) . '/display/' . $nickname . '/' . $item['id'], 'title'=> t('View in context'))), //'conv' => (($preview) ? '' : array('href'=> 'display/' . $nickname . '/' . $item['id'], 'title'=> t('View in context'))),
'conv' => (($preview) ? '' : array('href'=> $a->get_baseurl($ssl_state) . '/display/'.$item['guid'], 'title'=> t('View in context'))), 'conv' => (($preview) ? '' : array('href'=> 'display/'.$item['guid'], 'title'=> t('View in context'))),
'previewing' => $previewing, 'previewing' => $previewing,
'wait' => t('Please wait'), 'wait' => t('Please wait'),
'thread_level' => 1, 'thread_level' => 1,
@ -868,7 +868,7 @@ function item_photo_menu($item){
$status_link = $profile_link . "?url=status"; $status_link = $profile_link . "?url=status";
$photos_link = $profile_link . "?url=photos"; $photos_link = $profile_link . "?url=photos";
$profile_link = $profile_link . "?url=profile"; $profile_link = $profile_link . "?url=profile";
$pm_url = $a->get_baseurl($ssl_state) . '/message/new/' . $cid; $pm_url = 'message/new/' . $cid;
$zurl = ''; $zurl = '';
} }
else { else {
@ -882,23 +882,23 @@ function item_photo_menu($item){
$cid = $r[0]["id"]; $cid = $r[0]["id"];
if ($r[0]["network"] == NETWORK_DIASPORA) if ($r[0]["network"] == NETWORK_DIASPORA)
$pm_url = $a->get_baseurl($ssl_state) . '/message/new/' . $cid; $pm_url = 'message/new/' . $cid;
} else } else
$cid = 0; $cid = 0;
} }
} }
if(($cid) && (! $item['self'])) { if(($cid) && (! $item['self'])) {
$poke_link = $a->get_baseurl($ssl_state) . '/poke/?f=&c=' . $cid; $poke_link = 'poke/?f=&c=' . $cid;
$contact_url = $a->get_baseurl($ssl_state) . '/contacts/' . $cid; $contact_url = 'contacts/' . $cid;
$posts_link = $a->get_baseurl($ssl_state) . '/contacts/' . $cid . '/posts'; $posts_link = 'contacts/' . $cid . '/posts';
$clean_url = normalise_link($item['author-link']); $clean_url = normalise_link($item['author-link']);
if((local_user()) && (local_user() == $item['uid'])) { if((local_user()) && (local_user() == $item['uid'])) {
if(isset($a->contacts) && x($a->contacts,$clean_url)) { if(isset($a->contacts) && x($a->contacts,$clean_url)) {
if($a->contacts[$clean_url]['network'] === NETWORK_DIASPORA) { if($a->contacts[$clean_url]['network'] === NETWORK_DIASPORA) {
$pm_url = $a->get_baseurl($ssl_state) . '/message/new/' . $cid; $pm_url = 'message/new/' . $cid;
} }
} }
} }
@ -921,7 +921,7 @@ function item_photo_menu($item){
if ((($cid == 0) OR ($a->contacts[$clean_url]['rel'] == CONTACT_IS_FOLLOWER)) AND if ((($cid == 0) OR ($a->contacts[$clean_url]['rel'] == CONTACT_IS_FOLLOWER)) AND
in_array($item['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA))) in_array($item['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA)))
$menu[t("Connect/Follow")] = $a->get_baseurl($ssl_state)."/follow?url=".urlencode($item['author-link']); $menu[t("Connect/Follow")] = "follow?url=".urlencode($item['author-link']);
} else } else
$menu = array(t("View Profile") => $item['author-link']); $menu = array(t("View Profile") => $item['author-link']);
@ -980,7 +980,7 @@ function builtin_activity_puller($item, &$conv_responses) {
if((activity_match($item['verb'], $verb)) && ($item['id'] != $item['parent'])) { if((activity_match($item['verb'], $verb)) && ($item['id'] != $item['parent'])) {
$url = $item['author-link']; $url = $item['author-link'];
if((local_user()) && (local_user() == $item['uid']) && ($item['network'] === NETWORK_DFRN) && (! $item['self']) && (link_compare($item['author-link'],$item['url']))) { if((local_user()) && (local_user() == $item['uid']) && ($item['network'] === NETWORK_DFRN) && (! $item['self']) && (link_compare($item['author-link'],$item['url']))) {
$url = z_root(true) . '/redir/' . $item['contact-id']; $url = 'redir/' . $item['contact-id'];
$sparkle = ' class="sparkle" '; $sparkle = ' class="sparkle" ';
} }
else else
@ -1178,7 +1178,7 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
$o .= replace_macros($tpl,array( $o .= replace_macros($tpl,array(
'$return_path' => $query_str, '$return_path' => $query_str,
'$action' => $a->get_baseurl(true) . '/item', '$action' => 'item',
'$share' => (x($x,'button') ? $x['button'] : t('Share')), '$share' => (x($x,'button') ? $x['button'] : t('Share')),
'$upload' => t('Upload photo'), '$upload' => t('Upload photo'),
'$shortupload' => t('upload photo'), '$shortupload' => t('upload photo'),

View file

@ -34,22 +34,18 @@ function cron_run(&$argv, &$argc){
require_once('include/Contact.php'); require_once('include/Contact.php');
require_once('include/email.php'); require_once('include/email.php');
require_once('include/socgraph.php'); require_once('include/socgraph.php');
require_once('include/pidfile.php');
require_once('mod/nodeinfo.php'); require_once('mod/nodeinfo.php');
require_once('include/post_update.php');
load_config('config'); load_config('config');
load_config('system'); load_config('system');
$maxsysload = intval(get_config('system','maxloadavg')); // Don't check this stuff if the function is called by the poller
if($maxsysload < 1) if (App::callstack() != "poller_run") {
$maxsysload = 50; if (App::maxload_reached())
return;
$load = current_load(); if (App::is_already_running('cron', 'include/cron.php', 540))
if($load) {
if(intval($load) > $maxsysload) {
logger('system: load ' . $load . ' too high. cron deferred to next scheduled run.');
return; return;
}
} }
$last = get_config('system','last_cron'); $last = get_config('system','last_cron');
@ -66,23 +62,6 @@ function cron_run(&$argv, &$argc){
} }
} }
$lockpath = get_lockpath();
if ($lockpath != '') {
$pidfile = new pidfile($lockpath, 'cron');
if($pidfile->is_already_running()) {
logger("cron: Already running");
if ($pidfile->running_time() > 9*60) {
$pidfile->kill();
logger("cron: killed stale process");
// Calling a new instance
proc_run('php','include/cron.php');
}
exit;
}
}
$a->set_baseurl(get_config('system','url')); $a->set_baseurl(get_config('system','url'));
load_hooks(); load_hooks();
@ -93,10 +72,6 @@ function cron_run(&$argv, &$argc){
proc_run('php',"include/queue.php"); proc_run('php',"include/queue.php");
// run diaspora photo queue process in the background
proc_run('php',"include/dsprphotoq.php");
// run the process to discover global contacts in the background // run the process to discover global contacts in the background
proc_run('php',"include/discover_poco.php"); proc_run('php',"include/discover_poco.php");
@ -127,13 +102,14 @@ function cron_run(&$argv, &$argc){
// Check OStatus conversations // Check OStatus conversations
// Check only conversations with mentions (for a longer time) // Check only conversations with mentions (for a longer time)
check_conversations(true); ostatus::check_conversations(true);
// Check every conversation // Check every conversation
check_conversations(false); ostatus::check_conversations(false);
// Set the gcontact-id in the item table if missing // Call possible post update functions
item_set_gcontact(); // see include/post_update.php for more details
post_update();
// update nodeinfo data // update nodeinfo data
nodeinfo_cron(); nodeinfo_cron();
@ -361,35 +337,37 @@ function cron_clear_cache(&$a) {
if ($max_tablesize == 0) if ($max_tablesize == 0)
$max_tablesize = 100 * 1000000; // Default are 100 MB $max_tablesize = 100 * 1000000; // Default are 100 MB
// Minimum fragmentation level in percent if ($max_tablesize > 0) {
$fragmentation_level = intval(get_config('system','optimize_fragmentation')) / 100; // Minimum fragmentation level in percent
if ($fragmentation_level == 0) $fragmentation_level = intval(get_config('system','optimize_fragmentation')) / 100;
$fragmentation_level = 0.3; // Default value is 30% if ($fragmentation_level == 0)
$fragmentation_level = 0.3; // Default value is 30%
// Optimize some tables that need to be optimized // Optimize some tables that need to be optimized
$r = q("SHOW TABLE STATUS"); $r = q("SHOW TABLE STATUS");
foreach($r as $table) { foreach($r as $table) {
// Don't optimize tables that are too large // Don't optimize tables that are too large
if ($table["Data_length"] > $max_tablesize) if ($table["Data_length"] > $max_tablesize)
continue; continue;
// Don't optimize empty tables // Don't optimize empty tables
if ($table["Data_length"] == 0) if ($table["Data_length"] == 0)
continue; continue;
// Calculate fragmentation // Calculate fragmentation
$fragmentation = $table["Data_free"] / $table["Data_length"]; $fragmentation = $table["Data_free"] / ($table["Data_length"] + $table["Index_length"]);
logger("Table ".$table["Name"]." - Fragmentation level: ".round($fragmentation * 100, 2), LOGGER_DEBUG); logger("Table ".$table["Name"]." - Fragmentation level: ".round($fragmentation * 100, 2), LOGGER_DEBUG);
// Don't optimize tables that needn't to be optimized // Don't optimize tables that needn't to be optimized
if ($fragmentation < $fragmentation_level) if ($fragmentation < $fragmentation_level)
continue; continue;
// So optimize it // So optimize it
logger("Optimize Table ".$table["Name"], LOGGER_DEBUG); logger("Optimize Table ".$table["Name"], LOGGER_DEBUG);
q("OPTIMIZE TABLE `%s`", dbesc($table["Name"])); q("OPTIMIZE TABLE `%s`", dbesc($table["Name"]));
}
} }
set_config('system','cache_last_cleared', time()); set_config('system','cache_last_cleared', time());
@ -429,6 +407,9 @@ function cron_repair_database() {
// This call is very "cheap" so we can do it at any time without a problem // This call is very "cheap" so we can do it at any time without a problem
q("UPDATE `item` INNER JOIN `item` AS `parent` ON `parent`.`uri` = `item`.`parent-uri` AND `parent`.`uid` = `item`.`uid` SET `item`.`parent` = `parent`.`id` WHERE `item`.`parent` = 0"); q("UPDATE `item` INNER JOIN `item` AS `parent` ON `parent`.`uri` = `item`.`parent-uri` AND `parent`.`uid` = `item`.`uid` SET `item`.`parent` = `parent`.`id` WHERE `item`.`parent` = 0");
// There was an issue where the nick vanishes from the contact table
q("UPDATE `contact` INNER JOIN `user` ON `contact`.`uid` = `user`.`uid` SET `nick` = `nickname` WHERE `self` AND `nick`=''");
/// @todo /// @todo
/// - remove thread entries without item /// - remove thread entries without item
/// - remove sign entries without item /// - remove sign entries without item

View file

@ -19,21 +19,16 @@ function cronhooks_run(&$argv, &$argc){
require_once('include/session.php'); require_once('include/session.php');
require_once('include/datetime.php'); require_once('include/datetime.php');
require_once('include/pidfile.php');
load_config('config'); load_config('config');
load_config('system'); load_config('system');
$maxsysload = intval(get_config('system','maxloadavg')); // Don't check this stuff if the function is called by the poller
if($maxsysload < 1) if (App::callstack() != "poller_run") {
$maxsysload = 50; if (App::maxload_reached())
return;
$load = current_load(); if (App::is_already_running('cronhooks', 'include/cronhooks.php', 1140))
if($load) {
if(intval($load) > $maxsysload) {
logger('system: load ' . $load . ' too high. Cronhooks deferred to next scheduled run.');
return; return;
}
} }
$last = get_config('system','last_cronhook'); $last = get_config('system','last_cronhook');
@ -50,21 +45,6 @@ function cronhooks_run(&$argv, &$argc){
} }
} }
$lockpath = get_lockpath();
if ($lockpath != '') {
$pidfile = new pidfile($lockpath, 'cronhooks');
if($pidfile->is_already_running()) {
logger("cronhooks: Already running");
if ($pidfile->running_time() > 19*60) {
$pidfile->kill();
logger("cronhooks: killed stale process");
// Calling a new instance
proc_run('php','include/cronhooks.php');
}
exit;
}
}
$a->set_baseurl(get_config('system','url')); $a->set_baseurl(get_config('system','url'));
load_hooks(); load_hooks();

View file

@ -537,17 +537,6 @@ function db_definition() {
"PRIMARY" => array("id"), "PRIMARY" => array("id"),
) )
); );
$database["dsprphotoq"] = array(
"fields" => array(
"id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
"uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
"msg" => array("type" => "mediumtext", "not null" => "1"),
"attempt" => array("type" => "tinyint(4)", "not null" => "1", "default" => "0"),
),
"indexes" => array(
"PRIMARY" => array("id"),
)
);
$database["event"] = array( $database["event"] = array(
"fields" => array( "fields" => array(
"id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
@ -1246,7 +1235,6 @@ function db_definition() {
"fields" => array( "fields" => array(
"id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
"iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"), "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
"retract_iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
"signed_text" => array("type" => "mediumtext", "not null" => "1"), "signed_text" => array("type" => "mediumtext", "not null" => "1"),
"signature" => array("type" => "text", "not null" => "1"), "signature" => array("type" => "text", "not null" => "1"),
"signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
@ -1254,7 +1242,6 @@ function db_definition() {
"indexes" => array( "indexes" => array(
"PRIMARY" => array("id"), "PRIMARY" => array("id"),
"iid" => array("iid"), "iid" => array("iid"),
"retract_iid" => array("retract_iid"),
) )
); );
$database["spam"] = array( $database["spam"] = array(

View file

@ -10,11 +10,11 @@ require_once("include/dfrn.php");
function delivery_run(&$argv, &$argc){ function delivery_run(&$argv, &$argc){
global $a, $db; global $a, $db;
if(is_null($a)){ if (is_null($a)){
$a = new App; $a = new App;
} }
if(is_null($db)) { if (is_null($db)) {
@include(".htconfig.php"); @include(".htconfig.php");
require_once("include/dba.php"); require_once("include/dba.php");
$db = new dba($db_host, $db_user, $db_pass, $db_data); $db = new dba($db_host, $db_user, $db_pass, $db_data);
@ -32,12 +32,12 @@ function delivery_run(&$argv, &$argc){
load_hooks(); load_hooks();
if($argc < 3) if ($argc < 3)
return; return;
$a->set_baseurl(get_config('system','url')); $a->set_baseurl(get_config('system','url'));
logger('delivery: invoked: ' . print_r($argv,true), LOGGER_DEBUG); logger('delivery: invoked: '. print_r($argv,true), LOGGER_DEBUG);
$cmd = $argv[1]; $cmd = $argv[1];
$item_id = intval($argv[2]); $item_id = intval($argv[2]);
@ -53,21 +53,12 @@ function delivery_run(&$argv, &$argc){
dbesc($item_id), dbesc($item_id),
dbesc($contact_id) dbesc($contact_id)
); );
if(! count($r)) { if (!count($r)) {
continue; continue;
} }
$maxsysload = intval(get_config('system','maxloadavg')); if (App::maxload_reached())
if($maxsysload < 1) return;
$maxsysload = 50;
$load = current_load();
if($load) {
if(intval($load) > $maxsysload) {
logger('system: load ' . $load . ' too high. Delivery deferred to next queue run.');
return;
}
}
// It's ours to deliver. Remove it from the queue. // It's ours to deliver. Remove it from the queue.
@ -77,7 +68,7 @@ function delivery_run(&$argv, &$argc){
dbesc($contact_id) dbesc($contact_id)
); );
if((! $item_id) || (! $contact_id)) if (!$item_id || !$contact_id)
continue; continue;
$expire = false; $expire = false;
@ -93,20 +84,20 @@ function delivery_run(&$argv, &$argc){
$recipients[] = $contact_id; $recipients[] = $contact_id;
if($cmd === 'mail') { if ($cmd === 'mail') {
$normal_mode = false; $normal_mode = false;
$mail = true; $mail = true;
$message = q("SELECT * FROM `mail` WHERE `id` = %d LIMIT 1", $message = q("SELECT * FROM `mail` WHERE `id` = %d LIMIT 1",
intval($item_id) intval($item_id)
); );
if(! count($message)){ if (!count($message)){
return; return;
} }
$uid = $message[0]['uid']; $uid = $message[0]['uid'];
$recipients[] = $message[0]['contact-id']; $recipients[] = $message[0]['contact-id'];
$item = $message[0]; $item = $message[0];
} }
elseif($cmd === 'expire') { elseif ($cmd === 'expire') {
$normal_mode = false; $normal_mode = false;
$expire = true; $expire = true;
$items = q("SELECT * FROM `item` WHERE `uid` = %d AND `wall` = 1 $items = q("SELECT * FROM `item` WHERE `uid` = %d AND `wall` = 1
@ -115,22 +106,22 @@ function delivery_run(&$argv, &$argc){
); );
$uid = $item_id; $uid = $item_id;
$item_id = 0; $item_id = 0;
if(! count($items)) if (!count($items))
continue; continue;
} }
elseif($cmd === 'suggest') { elseif ($cmd === 'suggest') {
$normal_mode = false; $normal_mode = false;
$fsuggest = true; $fsuggest = true;
$suggest = q("SELECT * FROM `fsuggest` WHERE `id` = %d LIMIT 1", $suggest = q("SELECT * FROM `fsuggest` WHERE `id` = %d LIMIT 1",
intval($item_id) intval($item_id)
); );
if(! count($suggest)) if (!count($suggest))
return; return;
$uid = $suggest[0]['uid']; $uid = $suggest[0]['uid'];
$recipients[] = $suggest[0]['cid']; $recipients[] = $suggest[0]['cid'];
$item = $suggest[0]; $item = $suggest[0];
} elseif($cmd === 'relocate') { } elseif ($cmd === 'relocate') {
$normal_mode = false; $normal_mode = false;
$relocate = true; $relocate = true;
$uid = $item_id; $uid = $item_id;
@ -140,7 +131,7 @@ function delivery_run(&$argv, &$argc){
intval($item_id) intval($item_id)
); );
if((! count($r)) || (! intval($r[0]['parent']))) { if ((!count($r)) || (!intval($r[0]['parent']))) {
continue; continue;
} }
@ -154,32 +145,32 @@ function delivery_run(&$argv, &$argc){
intval($parent_id) intval($parent_id)
); );
if(! count($items)) { if (!count($items)) {
continue; continue;
} }
$icontacts = null; $icontacts = null;
$contacts_arr = array(); $contacts_arr = array();
foreach($items as $item) foreach($items as $item)
if(! in_array($item['contact-id'],$contacts_arr)) if (!in_array($item['contact-id'],$contacts_arr))
$contacts_arr[] = intval($item['contact-id']); $contacts_arr[] = intval($item['contact-id']);
if(count($contacts_arr)) { if (count($contacts_arr)) {
$str_contacts = implode(',',$contacts_arr); $str_contacts = implode(',',$contacts_arr);
$icontacts = q("SELECT * FROM `contact` $icontacts = q("SELECT * FROM `contact`
WHERE `id` IN ( $str_contacts ) " WHERE `id` IN ( $str_contacts ) "
); );
} }
if( ! ($icontacts && count($icontacts))) if ( !($icontacts && count($icontacts)))
continue; continue;
// avoid race condition with deleting entries // avoid race condition with deleting entries
if($items[0]['deleted']) { if ($items[0]['deleted']) {
foreach($items as $item) foreach($items as $item)
$item['deleted'] = 1; $item['deleted'] = 1;
} }
if((count($items) == 1) && ($items[0]['uri'] === $items[0]['parent-uri'])) { if ((count($items) == 1) && ($items[0]['uri'] === $items[0]['parent-uri'])) {
logger('delivery: top level post'); logger('delivery: top level post');
$top_level = true; $top_level = true;
} }
@ -193,7 +184,7 @@ function delivery_run(&$argv, &$argc){
intval($uid) intval($uid)
); );
if(! count($r)) if (!count($r))
continue; continue;
$owner = $r[0]; $owner = $r[0];
@ -202,7 +193,7 @@ function delivery_run(&$argv, &$argc){
$public_message = true; $public_message = true;
if(! ($mail || $fsuggest || $relocate)) { if (!($mail || $fsuggest || $relocate)) {
require_once('include/group.php'); require_once('include/group.php');
$parent = $items[0]; $parent = $items[0];
@ -226,7 +217,7 @@ function delivery_run(&$argv, &$argc){
$localhost = $a->get_hostname(); $localhost = $a->get_hostname();
if(strpos($localhost,':')) if (strpos($localhost,':'))
$localhost = substr($localhost,0,strpos($localhost,':')); $localhost = substr($localhost,0,strpos($localhost,':'));
/** /**
@ -239,20 +230,21 @@ function delivery_run(&$argv, &$argc){
$relay_to_owner = false; $relay_to_owner = false;
if((! $top_level) && ($parent['wall'] == 0) && (! $expire) && (stristr($target_item['uri'],$localhost))) { if (!$top_level && ($parent['wall'] == 0) && !$expire && stristr($target_item['uri'],$localhost)) {
$relay_to_owner = true; $relay_to_owner = true;
} }
if($relay_to_owner) { if ($relay_to_owner) {
logger('followup '.$target_item["guid"], LOGGER_DEBUG); logger('followup '.$target_item["guid"], LOGGER_DEBUG);
// local followup to remote post // local followup to remote post
$followup = true; $followup = true;
} }
if((strlen($parent['allow_cid'])) if ((strlen($parent['allow_cid']))
|| (strlen($parent['allow_gid'])) || (strlen($parent['allow_gid']))
|| (strlen($parent['deny_cid'])) || (strlen($parent['deny_cid']))
|| (strlen($parent['deny_gid']))) { || (strlen($parent['deny_gid']))
|| $parent["private"]) {
$public_message = false; // private recipients, not public $public_message = false; // private recipients, not public
} }
@ -262,10 +254,10 @@ function delivery_run(&$argv, &$argc){
intval($contact_id) intval($contact_id)
); );
if(count($r)) if (count($r))
$contact = $r[0]; $contact = $r[0];
if($contact['self']) if ($contact['self'])
continue; continue;
$deliver_status = 0; $deliver_status = 0;
@ -275,7 +267,7 @@ function delivery_run(&$argv, &$argc){
switch($contact['network']) { switch($contact['network']) {
case NETWORK_DFRN: case NETWORK_DFRN:
logger('notifier: '.$target_item["guid"].' dfrndelivery: ' . $contact['name']); logger('notifier: '.$target_item["guid"].' dfrndelivery: '.$contact['name']);
if ($mail) { if ($mail) {
$item['body'] = fix_private_photos($item['body'],$owner['uid'],null,$message[0]['contact-id']); $item['body'] = fix_private_photos($item['body'],$owner['uid'],null,$message[0]['contact-id']);
@ -285,13 +277,13 @@ function delivery_run(&$argv, &$argc){
q("DELETE FROM `fsuggest` WHERE `id` = %d LIMIT 1", intval($item['id'])); q("DELETE FROM `fsuggest` WHERE `id` = %d LIMIT 1", intval($item['id']));
} elseif ($relocate) } elseif ($relocate)
$atom = dfrn::relocate($owner, $uid); $atom = dfrn::relocate($owner, $uid);
elseif($followup) { elseif ($followup) {
$msgitems = array(); $msgitems = array();
foreach($items as $item) { // there is only one item foreach($items as $item) { // there is only one item
if(!$item['parent']) if (!$item['parent'])
continue; continue;
if($item['id'] == $item_id) { if ($item['id'] == $item_id) {
logger('followup: item: ' . print_r($item,true), LOGGER_DATA); logger('followup: item: '. print_r($item,true), LOGGER_DATA);
$msgitems[] = $item; $msgitems[] = $item;
} }
} }
@ -299,19 +291,19 @@ function delivery_run(&$argv, &$argc){
} else { } else {
$msgitems = array(); $msgitems = array();
foreach($items as $item) { foreach($items as $item) {
if(!$item['parent']) if (!$item['parent'])
continue; continue;
// private emails may be in included in public conversations. Filter them. // private emails may be in included in public conversations. Filter them.
if(($public_message) && $item['private']) if ($public_message && $item['private'])
continue; continue;
$item_contact = get_item_contact($item,$icontacts); $item_contact = get_item_contact($item,$icontacts);
if(!$item_contact) if (!$item_contact)
continue; continue;
if($normal_mode) { if ($normal_mode) {
if($item_id == $item['id'] || $item['id'] == $item['parent']) { if ($item_id == $item['id'] || $item['id'] == $item['parent']) {
$item["entry:comment-allow"] = true; $item["entry:comment-allow"] = true;
$item["entry:cid"] = (($top_level) ? $contact['id'] : 0); $item["entry:cid"] = (($top_level) ? $contact['id'] : 0);
$msgitems[] = $item; $msgitems[] = $item;
@ -326,15 +318,15 @@ function delivery_run(&$argv, &$argc){
logger('notifier entry: '.$contact["url"].' '.$target_item["guid"].' entry: '.$atom, LOGGER_DEBUG); logger('notifier entry: '.$contact["url"].' '.$target_item["guid"].' entry: '.$atom, LOGGER_DEBUG);
logger('notifier: ' . $atom, LOGGER_DATA); logger('notifier: '.$atom, LOGGER_DATA);
$basepath = implode('/', array_slice(explode('/',$contact['url']),0,3)); $basepath = implode('/', array_slice(explode('/',$contact['url']),0,3));
// perform local delivery if we are on the same site // perform local delivery if we are on the same site
if(link_compare($basepath,$a->get_baseurl())) { if (link_compare($basepath,$a->get_baseurl())) {
$nickname = basename($contact['url']); $nickname = basename($contact['url']);
if($contact['issued-id']) if ($contact['issued-id'])
$sql_extra = sprintf(" AND `dfrn-id` = '%s' ", dbesc($contact['issued-id'])); $sql_extra = sprintf(" AND `dfrn-id` = '%s' ", dbesc($contact['issued-id']));
else else
$sql_extra = sprintf(" AND `issued-id` = '%s' ", dbesc($contact['dfrn-id'])); $sql_extra = sprintf(" AND `issued-id` = '%s' ", dbesc($contact['dfrn-id']));
@ -356,10 +348,10 @@ function delivery_run(&$argv, &$argc){
dbesc($nickname) dbesc($nickname)
); );
if($x && count($x)) { if ($x && count($x)) {
$write_flag = ((($x[0]['rel']) && ($x[0]['rel'] != CONTACT_IS_SHARING)) ? true : false); $write_flag = ((($x[0]['rel']) && ($x[0]['rel'] != CONTACT_IS_SHARING)) ? true : false);
if((($owner['page-flags'] == PAGE_COMMUNITY) || ($write_flag)) && (! $x[0]['writable'])) { if ((($owner['page-flags'] == PAGE_COMMUNITY) || $write_flag) && !$x[0]['writable']) {
q("update contact set writable = 1 where id = %d", q("UPDATE `contact` SET `writable` = 1 WHERE `id` = %d",
intval($x[0]['id']) intval($x[0]['id'])
); );
$x[0]['writable'] = 1; $x[0]['writable'] = 1;
@ -379,14 +371,14 @@ function delivery_run(&$argv, &$argc){
} }
} }
if(! was_recently_delayed($contact['id'])) if (!was_recently_delayed($contact['id']))
$deliver_status = dfrn::deliver($owner,$contact,$atom); $deliver_status = dfrn::deliver($owner,$contact,$atom);
else else
$deliver_status = (-1); $deliver_status = (-1);
logger('notifier: dfrn_delivery to '.$contact["url"].' with guid '.$target_item["guid"].' returns '.$deliver_status); logger('notifier: dfrn_delivery to '.$contact["url"].' with guid '.$target_item["guid"].' returns '.$deliver_status);
if($deliver_status == (-1)) { if ($deliver_status == (-1)) {
logger('notifier: delivery failed: queuing message'); logger('notifier: delivery failed: queuing message');
add_to_queue($contact['id'],NETWORK_DFRN,$atom); add_to_queue($contact['id'],NETWORK_DFRN,$atom);
} }
@ -394,9 +386,9 @@ function delivery_run(&$argv, &$argc){
case NETWORK_OSTATUS: case NETWORK_OSTATUS:
// Do not send to otatus if we are not configured to send to public networks // Do not send to otatus if we are not configured to send to public networks
if($owner['prvnets']) if ($owner['prvnets'])
break; break;
if(get_config('system','ostatus_disabled') || get_config('system','dfrn_only')) if (get_config('system','ostatus_disabled') || get_config('system','dfrn_only'))
break; break;
// There is currently no code here to distribute anything to OStatus. // There is currently no code here to distribute anything to OStatus.
@ -406,67 +398,67 @@ function delivery_run(&$argv, &$argc){
case NETWORK_MAIL: case NETWORK_MAIL:
case NETWORK_MAIL2: case NETWORK_MAIL2:
if(get_config('system','dfrn_only')) if (get_config('system','dfrn_only'))
break; break;
// WARNING: does not currently convert to RFC2047 header encodings, etc. // WARNING: does not currently convert to RFC2047 header encodings, etc.
$addr = $contact['addr']; $addr = $contact['addr'];
if(! strlen($addr)) if (!strlen($addr))
break; break;
if($cmd === 'wall-new' || $cmd === 'comment-new') { if ($cmd === 'wall-new' || $cmd === 'comment-new') {
$it = null; $it = null;
if($cmd === 'wall-new') if ($cmd === 'wall-new')
$it = $items[0]; $it = $items[0];
else { else {
$r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($argv[2]), intval($argv[2]),
intval($uid) intval($uid)
); );
if(count($r)) if (count($r))
$it = $r[0]; $it = $r[0];
} }
if(! $it) if (!$it)
break; break;
$local_user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", $local_user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
intval($uid) intval($uid)
); );
if(! count($local_user)) if (!count($local_user))
break; break;
$reply_to = ''; $reply_to = '';
$r1 = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", $r1 = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
intval($uid) intval($uid)
); );
if($r1 && $r1[0]['reply_to']) if ($r1 && $r1[0]['reply_to'])
$reply_to = $r1[0]['reply_to']; $reply_to = $r1[0]['reply_to'];
$subject = (($it['title']) ? email_header_encode($it['title'],'UTF-8') : t("\x28no subject\x29")) ; $subject = (($it['title']) ? email_header_encode($it['title'],'UTF-8') : t("\x28no subject\x29")) ;
// only expose our real email address to true friends // only expose our real email address to true friends
if(($contact['rel'] == CONTACT_IS_FRIEND) && (! $contact['blocked'])) { if (($contact['rel'] == CONTACT_IS_FRIEND) && !$contact['blocked']) {
if($reply_to) { if ($reply_to) {
$headers = 'From: '.email_header_encode($local_user[0]['username'],'UTF-8').' <'.$reply_to.'>'."\n"; $headers = 'From: '.email_header_encode($local_user[0]['username'],'UTF-8').' <'.$reply_to.'>'."\n";
$headers .= 'Sender: '.$local_user[0]['email']."\n"; $headers .= 'Sender: '.$local_user[0]['email']."\n";
} else } else
$headers = 'From: '.email_header_encode($local_user[0]['username'],'UTF-8').' <'.$local_user[0]['email'].'>'."\n"; $headers = 'From: '.email_header_encode($local_user[0]['username'],'UTF-8').' <'.$local_user[0]['email'].'>'."\n";
} else } else
$headers = 'From: ' . email_header_encode($local_user[0]['username'],'UTF-8') . ' <' . t('noreply') . '@' . $a->get_hostname() . '>' . "\n"; $headers = 'From: '. email_header_encode($local_user[0]['username'],'UTF-8') .' <'. t('noreply') .'@'.$a->get_hostname() .'>'. "\n";
//if($reply_to) //if ($reply_to)
// $headers .= 'Reply-to: ' . $reply_to . "\n"; // $headers .= 'Reply-to: '.$reply_to . "\n";
$headers .= 'Message-Id: <' . iri2msgid($it['uri']). '>' . "\n"; $headers .= 'Message-Id: <'. iri2msgid($it['uri']).'>'. "\n";
//logger("Mail: uri: ".$it['uri']." parent-uri ".$it['parent-uri'], LOGGER_DEBUG); //logger("Mail: uri: ".$it['uri']." parent-uri ".$it['parent-uri'], LOGGER_DEBUG);
//logger("Mail: Data: ".print_r($it, true), LOGGER_DEBUG); //logger("Mail: Data: ".print_r($it, true), LOGGER_DEBUG);
//logger("Mail: Data: ".print_r($it, true), LOGGER_DATA); //logger("Mail: Data: ".print_r($it, true), LOGGER_DATA);
if($it['uri'] !== $it['parent-uri']) { if ($it['uri'] !== $it['parent-uri']) {
$headers .= "References: <".iri2msgid($it["parent-uri"]).">"; $headers .= "References: <".iri2msgid($it["parent-uri"]).">";
// If Threading is enabled, write down the correct parent // If Threading is enabled, write down the correct parent
@ -474,23 +466,23 @@ function delivery_run(&$argv, &$argc){
$headers .= " <".iri2msgid($it["thr-parent"]).">"; $headers .= " <".iri2msgid($it["thr-parent"]).">";
$headers .= "\n"; $headers .= "\n";
if(!$it['title']) { if (!$it['title']) {
$r = q("SELECT `title` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", $r = q("SELECT `title` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($it['parent-uri']), dbesc($it['parent-uri']),
intval($uid)); intval($uid));
if(count($r) AND ($r[0]['title'] != '')) if (count($r) AND ($r[0]['title'] != ''))
$subject = $r[0]['title']; $subject = $r[0]['title'];
else { else {
$r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d LIMIT 1", $r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($it['parent-uri']), dbesc($it['parent-uri']),
intval($uid)); intval($uid));
if(count($r) AND ($r[0]['title'] != '')) if (count($r) AND ($r[0]['title'] != ''))
$subject = $r[0]['title']; $subject = $r[0]['title'];
} }
} }
if(strncasecmp($subject,'RE:',3)) if (strncasecmp($subject,'RE:',3))
$subject = 'Re: '.$subject; $subject = 'Re: '.$subject;
} }
email_send($addr, $subject, $headers, $it); email_send($addr, $subject, $headers, $it);
@ -498,60 +490,59 @@ function delivery_run(&$argv, &$argc){
break; break;
case NETWORK_DIASPORA: case NETWORK_DIASPORA:
if($public_message) if ($public_message)
$loc = 'public batch ' . $contact['batch']; $loc = 'public batch '.$contact['batch'];
else else
$loc = $contact['name']; $loc = $contact['name'];
logger('delivery: diaspora batch deliver: ' . $loc); logger('delivery: diaspora batch deliver: '.$loc);
if(get_config('system','dfrn_only') || (!get_config('system','diaspora_enabled'))) if (get_config('system','dfrn_only') || (!get_config('system','diaspora_enabled')))
break; break;
if($mail) { if ($mail) {
diaspora_send_mail($item,$owner,$contact); diaspora::send_mail($item,$owner,$contact);
break; break;
} }
if(!$normal_mode) if (!$normal_mode)
break; break;
if((! $contact['pubkey']) && (! $public_message)) if (!$contact['pubkey'] && !$public_message)
break; break;
$unsupported_activities = array(ACTIVITY_DISLIKE, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE); $unsupported_activities = array(ACTIVITY_DISLIKE, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE);
//don't transmit activities which are not supported by diaspora //don't transmit activities which are not supported by diaspora
foreach($unsupported_activities as $act) { foreach($unsupported_activities as $act) {
if(activity_match($target_item['verb'],$act)) { if (activity_match($target_item['verb'],$act)) {
break 2; break 2;
} }
} }
if(($target_item['deleted']) && (($target_item['uri'] === $target_item['parent-uri']) || $followup)) { if (($target_item['deleted']) && (($target_item['uri'] === $target_item['parent-uri']) || $followup)) {
// top-level retraction // top-level retraction
logger('delivery: diaspora retract: ' . $loc); logger('diaspora retract: '.$loc);
diaspora::send_retraction($target_item,$owner,$contact,$public_message);
diaspora_send_retraction($target_item,$owner,$contact,$public_message);
break; break;
} elseif($followup) { } elseif ($followup) {
// send comments and likes to owner to relay // send comments and likes to owner to relay
diaspora_send_followup($target_item,$owner,$contact,$public_message); logger('diaspora followup: '.$loc);
diaspora::send_followup($target_item,$owner,$contact,$public_message);
break; break;
} elseif($target_item['uri'] !== $target_item['parent-uri']) { } elseif ($target_item['uri'] !== $target_item['parent-uri']) {
// we are the relay - send comments, likes and relayable_retractions to our conversants // we are the relay - send comments, likes and relayable_retractions to our conversants
logger('delivery: diaspora relay: ' . $loc); logger('diaspora relay: '.$loc);
diaspora::send_relay($target_item,$owner,$contact,$public_message);
diaspora_send_relay($target_item,$owner,$contact,$public_message);
break; break;
} elseif(($top_level) && (! $walltowall)) { } elseif ($top_level && !$walltowall) {
// currently no workable solution for sending walltowall // currently no workable solution for sending walltowall
logger('delivery: diaspora status: ' . $loc); logger('diaspora status: '.$loc);
diaspora_send_status($target_item,$owner,$contact,$public_message); diaspora::send_status($target_item,$owner,$contact,$public_message);
break; break;
} }
logger('delivery: diaspora unknown mode: ' . $contact['name']); logger('delivery: diaspora unknown mode: '.$contact['name']);
break; break;

View file

@ -18,6 +18,8 @@ require_once("include/event.php");
require_once("include/text.php"); require_once("include/text.php");
require_once("include/oembed.php"); require_once("include/oembed.php");
require_once("include/html2bbcode.php"); require_once("include/html2bbcode.php");
require_once("include/bbcode.php");
require_once("include/xml.php");
/** /**
* @brief This class contain functions to create and send DFRN XML files * @brief This class contain functions to create and send DFRN XML files
@ -84,7 +86,7 @@ class dfrn {
$converse = true; $converse = true;
if($a->argv[$x] == 'starred') if($a->argv[$x] == 'starred')
$starred = true; $starred = true;
if($a->argv[$x] === 'category' && $a->argc > ($x + 1) && strlen($a->argv[$x+1])) if($a->argv[$x] == 'category' && $a->argc > ($x + 1) && strlen($a->argv[$x+1]))
$category = $a->argv[$x+1]; $category = $a->argv[$x+1];
} }
} }
@ -243,7 +245,7 @@ class dfrn {
foreach($items as $item) { foreach($items as $item) {
// prevent private email from leaking. // prevent private email from leaking.
if($item['network'] === NETWORK_MAIL) if($item['network'] == NETWORK_MAIL)
continue; continue;
// public feeds get html, our own nodes use bbcode // public feeds get html, our own nodes use bbcode
@ -285,17 +287,17 @@ class dfrn {
$mail = $doc->createElement("dfrn:mail"); $mail = $doc->createElement("dfrn:mail");
$sender = $doc->createElement("dfrn:sender"); $sender = $doc->createElement("dfrn:sender");
xml_add_element($doc, $sender, "dfrn:name", $owner['name']); xml::add_element($doc, $sender, "dfrn:name", $owner['name']);
xml_add_element($doc, $sender, "dfrn:uri", $owner['url']); xml::add_element($doc, $sender, "dfrn:uri", $owner['url']);
xml_add_element($doc, $sender, "dfrn:avatar", $owner['thumb']); xml::add_element($doc, $sender, "dfrn:avatar", $owner['thumb']);
$mail->appendChild($sender); $mail->appendChild($sender);
xml_add_element($doc, $mail, "dfrn:id", $item['uri']); xml::add_element($doc, $mail, "dfrn:id", $item['uri']);
xml_add_element($doc, $mail, "dfrn:in-reply-to", $item['parent-uri']); xml::add_element($doc, $mail, "dfrn:in-reply-to", $item['parent-uri']);
xml_add_element($doc, $mail, "dfrn:sentdate", datetime_convert('UTC', 'UTC', $item['created'] . '+00:00' , ATOM_TIME)); xml::add_element($doc, $mail, "dfrn:sentdate", datetime_convert('UTC', 'UTC', $item['created'] . '+00:00' , ATOM_TIME));
xml_add_element($doc, $mail, "dfrn:subject", $item['title']); xml::add_element($doc, $mail, "dfrn:subject", $item['title']);
xml_add_element($doc, $mail, "dfrn:content", $item['body']); xml::add_element($doc, $mail, "dfrn:content", $item['body']);
$root->appendChild($mail); $root->appendChild($mail);
@ -318,11 +320,11 @@ class dfrn {
$suggest = $doc->createElement("dfrn:suggest"); $suggest = $doc->createElement("dfrn:suggest");
xml_add_element($doc, $suggest, "dfrn:url", $item['url']); xml::add_element($doc, $suggest, "dfrn:url", $item['url']);
xml_add_element($doc, $suggest, "dfrn:name", $item['name']); xml::add_element($doc, $suggest, "dfrn:name", $item['name']);
xml_add_element($doc, $suggest, "dfrn:photo", $item['photo']); xml::add_element($doc, $suggest, "dfrn:photo", $item['photo']);
xml_add_element($doc, $suggest, "dfrn:request", $item['request']); xml::add_element($doc, $suggest, "dfrn:request", $item['request']);
xml_add_element($doc, $suggest, "dfrn:note", $item['note']); xml::add_element($doc, $suggest, "dfrn:note", $item['note']);
$root->appendChild($suggest); $root->appendChild($suggest);
@ -364,16 +366,16 @@ class dfrn {
$relocate = $doc->createElement("dfrn:relocate"); $relocate = $doc->createElement("dfrn:relocate");
xml_add_element($doc, $relocate, "dfrn:url", $owner['url']); xml::add_element($doc, $relocate, "dfrn:url", $owner['url']);
xml_add_element($doc, $relocate, "dfrn:name", $owner['name']); xml::add_element($doc, $relocate, "dfrn:name", $owner['name']);
xml_add_element($doc, $relocate, "dfrn:photo", $photos[4]); xml::add_element($doc, $relocate, "dfrn:photo", $photos[4]);
xml_add_element($doc, $relocate, "dfrn:thumb", $photos[5]); xml::add_element($doc, $relocate, "dfrn:thumb", $photos[5]);
xml_add_element($doc, $relocate, "dfrn:micro", $photos[6]); xml::add_element($doc, $relocate, "dfrn:micro", $photos[6]);
xml_add_element($doc, $relocate, "dfrn:request", $owner['request']); xml::add_element($doc, $relocate, "dfrn:request", $owner['request']);
xml_add_element($doc, $relocate, "dfrn:confirm", $owner['confirm']); xml::add_element($doc, $relocate, "dfrn:confirm", $owner['confirm']);
xml_add_element($doc, $relocate, "dfrn:notify", $owner['notify']); xml::add_element($doc, $relocate, "dfrn:notify", $owner['notify']);
xml_add_element($doc, $relocate, "dfrn:poll", $owner['poll']); xml::add_element($doc, $relocate, "dfrn:poll", $owner['poll']);
xml_add_element($doc, $relocate, "dfrn:sitepubkey", get_config('system','site_pubkey')); xml::add_element($doc, $relocate, "dfrn:sitepubkey", get_config('system','site_pubkey'));
$root->appendChild($relocate); $root->appendChild($relocate);
@ -409,39 +411,39 @@ class dfrn {
$root->setAttribute("xmlns:ostatus", NAMESPACE_OSTATUS); $root->setAttribute("xmlns:ostatus", NAMESPACE_OSTATUS);
$root->setAttribute("xmlns:statusnet", NAMESPACE_STATUSNET); $root->setAttribute("xmlns:statusnet", NAMESPACE_STATUSNET);
xml_add_element($doc, $root, "id", app::get_baseurl()."/profile/".$owner["nick"]); xml::add_element($doc, $root, "id", app::get_baseurl()."/profile/".$owner["nick"]);
xml_add_element($doc, $root, "title", $owner["name"]); xml::add_element($doc, $root, "title", $owner["name"]);
$attributes = array("uri" => "https://friendi.ca", "version" => FRIENDICA_VERSION."-".DB_UPDATE_VERSION); $attributes = array("uri" => "https://friendi.ca", "version" => FRIENDICA_VERSION."-".DB_UPDATE_VERSION);
xml_add_element($doc, $root, "generator", FRIENDICA_PLATFORM, $attributes); xml::add_element($doc, $root, "generator", FRIENDICA_PLATFORM, $attributes);
$attributes = array("rel" => "license", "href" => "http://creativecommons.org/licenses/by/3.0/"); $attributes = array("rel" => "license", "href" => "http://creativecommons.org/licenses/by/3.0/");
xml_add_element($doc, $root, "link", "", $attributes); xml::add_element($doc, $root, "link", "", $attributes);
$attributes = array("rel" => "alternate", "type" => "text/html", "href" => $alternatelink); $attributes = array("rel" => "alternate", "type" => "text/html", "href" => $alternatelink);
xml_add_element($doc, $root, "link", "", $attributes); xml::add_element($doc, $root, "link", "", $attributes);
if ($public) { if ($public) {
// DFRN itself doesn't uses this. But maybe someone else wants to subscribe to the public feed. // DFRN itself doesn't uses this. But maybe someone else wants to subscribe to the public feed.
ostatus_hublinks($doc, $root); ostatus::hublinks($doc, $root);
$attributes = array("rel" => "salmon", "href" => app::get_baseurl()."/salmon/".$owner["nick"]); $attributes = array("rel" => "salmon", "href" => app::get_baseurl()."/salmon/".$owner["nick"]);
xml_add_element($doc, $root, "link", "", $attributes); xml::add_element($doc, $root, "link", "", $attributes);
$attributes = array("rel" => "http://salmon-protocol.org/ns/salmon-replies", "href" => app::get_baseurl()."/salmon/".$owner["nick"]); $attributes = array("rel" => "http://salmon-protocol.org/ns/salmon-replies", "href" => app::get_baseurl()."/salmon/".$owner["nick"]);
xml_add_element($doc, $root, "link", "", $attributes); xml::add_element($doc, $root, "link", "", $attributes);
$attributes = array("rel" => "http://salmon-protocol.org/ns/salmon-mention", "href" => app::get_baseurl()."/salmon/".$owner["nick"]); $attributes = array("rel" => "http://salmon-protocol.org/ns/salmon-mention", "href" => app::get_baseurl()."/salmon/".$owner["nick"]);
xml_add_element($doc, $root, "link", "", $attributes); xml::add_element($doc, $root, "link", "", $attributes);
} }
if ($owner['page-flags'] == PAGE_COMMUNITY) if ($owner['page-flags'] == PAGE_COMMUNITY)
xml_add_element($doc, $root, "dfrn:community", 1); xml::add_element($doc, $root, "dfrn:community", 1);
/// @todo We need a way to transmit the different page flags like "PAGE_PRVGROUP" /// @todo We need a way to transmit the different page flags like "PAGE_PRVGROUP"
xml_add_element($doc, $root, "updated", datetime_convert("UTC", "UTC", "now", ATOM_TIME)); xml::add_element($doc, $root, "updated", datetime_convert("UTC", "UTC", "now", ATOM_TIME));
$author = self::add_author($doc, $owner, $authorelement, $public); $author = self::add_author($doc, $owner, $authorelement, $public);
$root->appendChild($author); $root->appendChild($author);
@ -467,26 +469,26 @@ class dfrn {
$picdate = datetime_convert('UTC', 'UTC', $owner['avatar-date'].'+00:00', ATOM_TIME); $picdate = datetime_convert('UTC', 'UTC', $owner['avatar-date'].'+00:00', ATOM_TIME);
$attributes = array("dfrn:updated" => $namdate); $attributes = array("dfrn:updated" => $namdate);
xml_add_element($doc, $author, "name", $owner["name"], $attributes); xml::add_element($doc, $author, "name", $owner["name"], $attributes);
$attributes = array("dfrn:updated" => $namdate); $attributes = array("dfrn:updated" => $namdate);
xml_add_element($doc, $author, "uri", app::get_baseurl().'/profile/'.$owner["nickname"], $attributes); xml::add_element($doc, $author, "uri", app::get_baseurl().'/profile/'.$owner["nickname"], $attributes);
$attributes = array("dfrn:updated" => $namdate); $attributes = array("dfrn:updated" => $namdate);
xml_add_element($doc, $author, "dfrn:handle", $owner["addr"], $attributes); xml::add_element($doc, $author, "dfrn:handle", $owner["addr"], $attributes);
$attributes = array("rel" => "photo", "type" => "image/jpeg", "dfrn:updated" => $picdate, $attributes = array("rel" => "photo", "type" => "image/jpeg", "dfrn:updated" => $picdate,
"media:width" => 175, "media:height" => 175, "href" => $owner['photo']); "media:width" => 175, "media:height" => 175, "href" => $owner['photo']);
xml_add_element($doc, $author, "link", "", $attributes); xml::add_element($doc, $author, "link", "", $attributes);
$attributes = array("rel" => "avatar", "type" => "image/jpeg", "dfrn:updated" => $picdate, $attributes = array("rel" => "avatar", "type" => "image/jpeg", "dfrn:updated" => $picdate,
"media:width" => 175, "media:height" => 175, "href" => $owner['photo']); "media:width" => 175, "media:height" => 175, "href" => $owner['photo']);
xml_add_element($doc, $author, "link", "", $attributes); xml::add_element($doc, $author, "link", "", $attributes);
$birthday = feed_birthday($owner['uid'], $owner['timezone']); $birthday = feed_birthday($owner['uid'], $owner['timezone']);
if ($birthday) if ($birthday)
xml_add_element($doc, $author, "dfrn:birthday", $birthday); xml::add_element($doc, $author, "dfrn:birthday", $birthday);
// The following fields will only be generated if this isn't for a public feed // The following fields will only be generated if this isn't for a public feed
if ($public) if ($public)
@ -501,25 +503,25 @@ class dfrn {
intval($owner['uid'])); intval($owner['uid']));
if ($r) { if ($r) {
$profile = $r[0]; $profile = $r[0];
xml_add_element($doc, $author, "poco:displayName", $profile["name"]); xml::add_element($doc, $author, "poco:displayName", $profile["name"]);
xml_add_element($doc, $author, "poco:updated", $namdate); xml::add_element($doc, $author, "poco:updated", $namdate);
if (trim($profile["dob"]) != "0000-00-00") if (trim($profile["dob"]) != "0000-00-00")
xml_add_element($doc, $author, "poco:birthday", "0000-".date("m-d", strtotime($profile["dob"]))); xml::add_element($doc, $author, "poco:birthday", "0000-".date("m-d", strtotime($profile["dob"])));
xml_add_element($doc, $author, "poco:note", $profile["about"]); xml::add_element($doc, $author, "poco:note", $profile["about"]);
xml_add_element($doc, $author, "poco:preferredUsername", $profile["nickname"]); xml::add_element($doc, $author, "poco:preferredUsername", $profile["nickname"]);
$savetz = date_default_timezone_get(); $savetz = date_default_timezone_get();
date_default_timezone_set($profile["timezone"]); date_default_timezone_set($profile["timezone"]);
xml_add_element($doc, $author, "poco:utcOffset", date("P")); xml::add_element($doc, $author, "poco:utcOffset", date("P"));
date_default_timezone_set($savetz); date_default_timezone_set($savetz);
if (trim($profile["homepage"]) != "") { if (trim($profile["homepage"]) != "") {
$urls = $doc->createElement("poco:urls"); $urls = $doc->createElement("poco:urls");
xml_add_element($doc, $urls, "poco:type", "homepage"); xml::add_element($doc, $urls, "poco:type", "homepage");
xml_add_element($doc, $urls, "poco:value", $profile["homepage"]); xml::add_element($doc, $urls, "poco:value", $profile["homepage"]);
xml_add_element($doc, $urls, "poco:primary", "true"); xml::add_element($doc, $urls, "poco:primary", "true");
$author->appendChild($urls); $author->appendChild($urls);
} }
@ -527,7 +529,7 @@ class dfrn {
$keywords = explode(",", $profile["pub_keywords"]); $keywords = explode(",", $profile["pub_keywords"]);
foreach ($keywords AS $keyword) foreach ($keywords AS $keyword)
xml_add_element($doc, $author, "poco:tags", trim($keyword)); xml::add_element($doc, $author, "poco:tags", trim($keyword));
} }
@ -535,25 +537,25 @@ class dfrn {
$xmpp = ""; $xmpp = "";
if (trim($xmpp) != "") { if (trim($xmpp) != "") {
$ims = $doc->createElement("poco:ims"); $ims = $doc->createElement("poco:ims");
xml_add_element($doc, $ims, "poco:type", "xmpp"); xml::add_element($doc, $ims, "poco:type", "xmpp");
xml_add_element($doc, $ims, "poco:value", $xmpp); xml::add_element($doc, $ims, "poco:value", $xmpp);
xml_add_element($doc, $ims, "poco:primary", "true"); xml::add_element($doc, $ims, "poco:primary", "true");
$author->appendChild($ims); $author->appendChild($ims);
} }
if (trim($profile["locality"].$profile["region"].$profile["country-name"]) != "") { if (trim($profile["locality"].$profile["region"].$profile["country-name"]) != "") {
$element = $doc->createElement("poco:address"); $element = $doc->createElement("poco:address");
xml_add_element($doc, $element, "poco:formatted", formatted_location($profile)); xml::add_element($doc, $element, "poco:formatted", formatted_location($profile));
if (trim($profile["locality"]) != "") if (trim($profile["locality"]) != "")
xml_add_element($doc, $element, "poco:locality", $profile["locality"]); xml::add_element($doc, $element, "poco:locality", $profile["locality"]);
if (trim($profile["region"]) != "") if (trim($profile["region"]) != "")
xml_add_element($doc, $element, "poco:region", $profile["region"]); xml::add_element($doc, $element, "poco:region", $profile["region"]);
if (trim($profile["country-name"]) != "") if (trim($profile["country-name"]) != "")
xml_add_element($doc, $element, "poco:country", $profile["country-name"]); xml::add_element($doc, $element, "poco:country", $profile["country-name"]);
$author->appendChild($element); $author->appendChild($element);
} }
@ -577,9 +579,9 @@ class dfrn {
$contact = get_contact_details_by_url($contact_url, $item["uid"]); $contact = get_contact_details_by_url($contact_url, $item["uid"]);
$author = $doc->createElement($element); $author = $doc->createElement($element);
xml_add_element($doc, $author, "name", $contact["name"]); xml::add_element($doc, $author, "name", $contact["name"]);
xml_add_element($doc, $author, "uri", $contact["url"]); xml::add_element($doc, $author, "uri", $contact["url"]);
xml_add_element($doc, $author, "dfrn:handle", $contact["addr"]); xml::add_element($doc, $author, "dfrn:handle", $contact["addr"]);
/// @Todo /// @Todo
/// - Check real image type and image size /// - Check real image type and image size
@ -590,7 +592,7 @@ class dfrn {
"media:width" => 80, "media:width" => 80,
"media:height" => 80, "media:height" => 80,
"href" => $contact["photo"]); "href" => $contact["photo"]);
xml_add_element($doc, $author, "link", "", $attributes); xml::add_element($doc, $author, "link", "", $attributes);
$attributes = array( $attributes = array(
"rel" => "avatar", "rel" => "avatar",
@ -598,7 +600,7 @@ class dfrn {
"media:width" => 80, "media:width" => 80,
"media:height" => 80, "media:height" => 80,
"href" => $contact["photo"]); "href" => $contact["photo"]);
xml_add_element($doc, $author, "link", "", $attributes); xml::add_element($doc, $author, "link", "", $attributes);
return $author; return $author;
} }
@ -621,13 +623,13 @@ class dfrn {
if(!$r) if(!$r)
return false; return false;
if($r->type) if($r->type)
xml_add_element($doc, $entry, "activity:object-type", $r->type); xml::add_element($doc, $entry, "activity:object-type", $r->type);
if($r->id) if($r->id)
xml_add_element($doc, $entry, "id", $r->id); xml::add_element($doc, $entry, "id", $r->id);
if($r->title) if($r->title)
xml_add_element($doc, $entry, "title", $r->title); xml::add_element($doc, $entry, "title", $r->title);
if($r->link) { if($r->link) {
if(substr($r->link,0,1) === '<') { if(substr($r->link,0,1) == '<') {
if(strstr($r->link,'&') && (! strstr($r->link,'&amp;'))) if(strstr($r->link,'&') && (! strstr($r->link,'&amp;')))
$r->link = str_replace('&','&amp;', $r->link); $r->link = str_replace('&','&amp;', $r->link);
@ -640,16 +642,16 @@ class dfrn {
$attributes = array(); $attributes = array();
foreach ($link->attributes() AS $parameter => $value) foreach ($link->attributes() AS $parameter => $value)
$attributes[$parameter] = $value; $attributes[$parameter] = $value;
xml_add_element($doc, $entry, "link", "", $attributes); xml::add_element($doc, $entry, "link", "", $attributes);
} }
} }
} else { } else {
$attributes = array("rel" => "alternate", "type" => "text/html", "href" => $r->link); $attributes = array("rel" => "alternate", "type" => "text/html", "href" => $r->link);
xml_add_element($doc, $entry, "link", "", $attributes); xml::add_element($doc, $entry, "link", "", $attributes);
} }
} }
if($r->content) if($r->content)
xml_add_element($doc, $entry, "content", bbcode($r->content), array("type" => "html")); xml::add_element($doc, $entry, "content", bbcode($r->content), array("type" => "html"));
return $entry; return $entry;
} }
@ -683,7 +685,7 @@ class dfrn {
if(trim($matches[4]) != "") if(trim($matches[4]) != "")
$attributes["title"] = trim($matches[4]); $attributes["title"] = trim($matches[4]);
xml_add_element($doc, $root, "link", "", $attributes); xml::add_element($doc, $root, "link", "", $attributes);
} }
} }
} }
@ -710,7 +712,7 @@ class dfrn {
if($item['deleted']) { if($item['deleted']) {
$attributes = array("ref" => $item['uri'], "when" => datetime_convert('UTC','UTC',$item['edited'] . '+00:00',ATOM_TIME)); $attributes = array("ref" => $item['uri'], "when" => datetime_convert('UTC','UTC',$item['edited'] . '+00:00',ATOM_TIME));
return xml_create_element($doc, "at:deleted-entry", "", $attributes); return xml::create_element($doc, "at:deleted-entry", "", $attributes);
} }
$entry = $doc->createElement("entry"); $entry = $doc->createElement("entry");
@ -720,6 +722,9 @@ class dfrn {
else else
$body = $item['body']; $body = $item['body'];
// Remove the abstract element. It is only locally important.
$body = remove_abstract($body);
if ($type == 'html') { if ($type == 'html') {
$htmlbody = $body; $htmlbody = $body;
@ -741,66 +746,66 @@ class dfrn {
$attributes = array("ref" => $parent_item, "type" => "text/html", $attributes = array("ref" => $parent_item, "type" => "text/html",
"href" => app::get_baseurl().'/display/'.$parent[0]['guid'], "href" => app::get_baseurl().'/display/'.$parent[0]['guid'],
"dfrn:diaspora_guid" => $parent[0]['guid']); "dfrn:diaspora_guid" => $parent[0]['guid']);
xml_add_element($doc, $entry, "thr:in-reply-to", "", $attributes); xml::add_element($doc, $entry, "thr:in-reply-to", "", $attributes);
} }
xml_add_element($doc, $entry, "id", $item["uri"]); xml::add_element($doc, $entry, "id", $item["uri"]);
xml_add_element($doc, $entry, "title", $item["title"]); xml::add_element($doc, $entry, "title", $item["title"]);
xml_add_element($doc, $entry, "published", datetime_convert("UTC","UTC",$item["created"]."+00:00",ATOM_TIME)); xml::add_element($doc, $entry, "published", datetime_convert("UTC","UTC",$item["created"]."+00:00",ATOM_TIME));
xml_add_element($doc, $entry, "updated", datetime_convert("UTC","UTC",$item["edited"]."+00:00",ATOM_TIME)); xml::add_element($doc, $entry, "updated", datetime_convert("UTC","UTC",$item["edited"]."+00:00",ATOM_TIME));
// "dfrn:env" is used to read the content // "dfrn:env" is used to read the content
xml_add_element($doc, $entry, "dfrn:env", base64url_encode($body, true)); xml::add_element($doc, $entry, "dfrn:env", base64url_encode($body, true));
// The "content" field is not read by the receiver. We could remove it when the type is "text" // The "content" field is not read by the receiver. We could remove it when the type is "text"
// We keep it at the moment, maybe there is some old version that doesn't read "dfrn:env" // We keep it at the moment, maybe there is some old version that doesn't read "dfrn:env"
xml_add_element($doc, $entry, "content", (($type === 'html') ? $htmlbody : $body), array("type" => $type)); xml::add_element($doc, $entry, "content", (($type == 'html') ? $htmlbody : $body), array("type" => $type));
// We save this value in "plink". Maybe we should read it from there as well? // We save this value in "plink". Maybe we should read it from there as well?
xml_add_element($doc, $entry, "link", "", array("rel" => "alternate", "type" => "text/html", xml::add_element($doc, $entry, "link", "", array("rel" => "alternate", "type" => "text/html",
"href" => app::get_baseurl()."/display/".$item["guid"])); "href" => app::get_baseurl()."/display/".$item["guid"]));
// "comment-allow" is some old fashioned stuff for old Friendica versions. // "comment-allow" is some old fashioned stuff for old Friendica versions.
// It is included in the rewritten code for completeness // It is included in the rewritten code for completeness
if ($comment) if ($comment)
xml_add_element($doc, $entry, "dfrn:comment-allow", intval($item['last-child'])); xml::add_element($doc, $entry, "dfrn:comment-allow", intval($item['last-child']));
if($item['location']) if($item['location'])
xml_add_element($doc, $entry, "dfrn:location", $item['location']); xml::add_element($doc, $entry, "dfrn:location", $item['location']);
if($item['coord']) if($item['coord'])
xml_add_element($doc, $entry, "georss:point", $item['coord']); xml::add_element($doc, $entry, "georss:point", $item['coord']);
if(($item['private']) || strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid'])) if(($item['private']) || strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid']))
xml_add_element($doc, $entry, "dfrn:private", (($item['private']) ? $item['private'] : 1)); xml::add_element($doc, $entry, "dfrn:private", (($item['private']) ? $item['private'] : 1));
if($item['extid']) if($item['extid'])
xml_add_element($doc, $entry, "dfrn:extid", $item['extid']); xml::add_element($doc, $entry, "dfrn:extid", $item['extid']);
if($item['bookmark']) if($item['bookmark'])
xml_add_element($doc, $entry, "dfrn:bookmark", "true"); xml::add_element($doc, $entry, "dfrn:bookmark", "true");
if($item['app']) if($item['app'])
xml_add_element($doc, $entry, "statusnet:notice_info", "", array("local_id" => $item['id'], "source" => $item['app'])); xml::add_element($doc, $entry, "statusnet:notice_info", "", array("local_id" => $item['id'], "source" => $item['app']));
xml_add_element($doc, $entry, "dfrn:diaspora_guid", $item["guid"]); xml::add_element($doc, $entry, "dfrn:diaspora_guid", $item["guid"]);
// The signed text contains the content in Markdown, the sender handle and the signatur for the content // The signed text contains the content in Markdown, the sender handle and the signatur for the content
// It is needed for relayed comments to Diaspora. // It is needed for relayed comments to Diaspora.
if($item['signed_text']) { if($item['signed_text']) {
$sign = base64_encode(json_encode(array('signed_text' => $item['signed_text'],'signature' => $item['signature'],'signer' => $item['signer']))); $sign = base64_encode(json_encode(array('signed_text' => $item['signed_text'],'signature' => $item['signature'],'signer' => $item['signer'])));
xml_add_element($doc, $entry, "dfrn:diaspora_signature", $sign); xml::add_element($doc, $entry, "dfrn:diaspora_signature", $sign);
} }
xml_add_element($doc, $entry, "activity:verb", construct_verb($item)); xml::add_element($doc, $entry, "activity:verb", construct_verb($item));
if ($item['object-type'] != "") if ($item['object-type'] != "")
xml_add_element($doc, $entry, "activity:object-type", $item['object-type']); xml::add_element($doc, $entry, "activity:object-type", $item['object-type']);
elseif ($item['id'] == $item['parent']) elseif ($item['id'] == $item['parent'])
xml_add_element($doc, $entry, "activity:object-type", ACTIVITY_OBJ_NOTE); xml::add_element($doc, $entry, "activity:object-type", ACTIVITY_OBJ_NOTE);
else else
xml_add_element($doc, $entry, "activity:object-type", ACTIVITY_OBJ_COMMENT); xml::add_element($doc, $entry, "activity:object-type", ACTIVITY_OBJ_COMMENT);
$actobj = self::create_activity($doc, "activity:object", $item['object']); $actobj = self::create_activity($doc, "activity:object", $item['object']);
if ($actobj) if ($actobj)
@ -815,7 +820,7 @@ class dfrn {
if(count($tags)) { if(count($tags)) {
foreach($tags as $t) foreach($tags as $t)
if (($type != 'html') OR ($t[0] != "@")) if (($type != 'html') OR ($t[0] != "@"))
xml_add_element($doc, $entry, "category", "", array("scheme" => "X-DFRN:".$t[0].":".$t[1], "term" => $t[2])); xml::add_element($doc, $entry, "category", "", array("scheme" => "X-DFRN:".$t[0].":".$t[1], "term" => $t[2]));
} }
if(count($tags)) if(count($tags))
@ -828,11 +833,11 @@ class dfrn {
intval($owner["uid"]), intval($owner["uid"]),
dbesc(normalise_link($mention))); dbesc(normalise_link($mention)));
if ($r[0]["forum"] OR $r[0]["prv"]) if ($r[0]["forum"] OR $r[0]["prv"])
xml_add_element($doc, $entry, "link", "", array("rel" => "mentioned", xml::add_element($doc, $entry, "link", "", array("rel" => "mentioned",
"ostatus:object-type" => ACTIVITY_OBJ_GROUP, "ostatus:object-type" => ACTIVITY_OBJ_GROUP,
"href" => $mention)); "href" => $mention));
else else
xml_add_element($doc, $entry, "link", "", array("rel" => "mentioned", xml::add_element($doc, $entry, "link", "", array("rel" => "mentioned",
"ostatus:object-type" => ACTIVITY_OBJ_PERSON, "ostatus:object-type" => ACTIVITY_OBJ_PERSON,
"href" => $mention)); "href" => $mention));
} }
@ -1319,7 +1324,7 @@ class dfrn {
$obj_element = $obj_doc->createElementNS(NAMESPACE_ATOM1, $element); $obj_element = $obj_doc->createElementNS(NAMESPACE_ATOM1, $element);
$activity_type = $xpath->query("activity:object-type/text()", $activity)->item(0)->nodeValue; $activity_type = $xpath->query("activity:object-type/text()", $activity)->item(0)->nodeValue;
xml_add_element($obj_doc, $obj_element, "type", $activity_type); xml::add_element($obj_doc, $obj_element, "type", $activity_type);
$id = $xpath->query("atom:id", $activity)->item(0); $id = $xpath->query("atom:id", $activity)->item(0);
if (is_object($id)) if (is_object($id))
@ -1769,6 +1774,9 @@ class dfrn {
* @return bool Should the processing of the entries be continued? * @return bool Should the processing of the entries be continued?
*/ */
private function process_verbs($entrytype, $importer, &$item, &$is_like) { private function process_verbs($entrytype, $importer, &$item, &$is_like) {
logger("Process verb ".$item["verb"]." and object-type ".$item["object-type"]." for entrytype ".$entrytype, LOGGER_DEBUG);
if (($entrytype == DFRN_TOP_LEVEL)) { if (($entrytype == DFRN_TOP_LEVEL)) {
// The filling of the the "contact" variable is done for legcy reasons // The filling of the the "contact" variable is done for legcy reasons
// The functions below are partly used by ostatus.php as well - where we have this variable // The functions below are partly used by ostatus.php as well - where we have this variable
@ -1799,11 +1807,11 @@ class dfrn {
return false; return false;
} }
} else { } else {
if(($item["verb"] === ACTIVITY_LIKE) if(($item["verb"] == ACTIVITY_LIKE)
|| ($item["verb"] === ACTIVITY_DISLIKE) || ($item["verb"] == ACTIVITY_DISLIKE)
|| ($item["verb"] === ACTIVITY_ATTEND) || ($item["verb"] == ACTIVITY_ATTEND)
|| ($item["verb"] === ACTIVITY_ATTENDNO) || ($item["verb"] == ACTIVITY_ATTENDNO)
|| ($item["verb"] === ACTIVITY_ATTENDMAYBE)) { || ($item["verb"] == ACTIVITY_ATTENDMAYBE)) {
$is_like = true; $is_like = true;
$item["type"] = "activity"; $item["type"] = "activity";
$item["gravity"] = GRAVITY_LIKE; $item["gravity"] = GRAVITY_LIKE;
@ -1829,7 +1837,7 @@ class dfrn {
} else } else
$is_like = false; $is_like = false;
if(($item["verb"] === ACTIVITY_TAG) && ($item["object-type"] === ACTIVITY_OBJ_TAGTERM)) { if(($item["verb"] == ACTIVITY_TAG) && ($item["object-type"] == ACTIVITY_OBJ_TAGTERM)) {
$xo = parse_xml_string($item["object"],false); $xo = parse_xml_string($item["object"],false);
$xt = parse_xml_string($item["target"],false); $xt = parse_xml_string($item["target"],false);
@ -2018,14 +2026,28 @@ class dfrn {
$categories = $xpath->query("atom:category", $entry); $categories = $xpath->query("atom:category", $entry);
if ($categories) { if ($categories) {
foreach ($categories AS $category) { foreach ($categories AS $category) {
foreach($category->attributes AS $attributes) $term = "";
if ($attributes->name == "term") { $scheme = "";
foreach($category->attributes AS $attributes) {
if ($attributes->name == "term")
$term = $attributes->textContent; $term = $attributes->textContent;
if ($attributes->name == "scheme")
$scheme = $attributes->textContent;
}
if (($term != "") AND ($scheme != "")) {
$parts = explode(":", $scheme);
if ((count($parts) >= 4) AND (array_shift($parts) == "X-DFRN")) {
$termhash = array_shift($parts);
$termurl = implode(":", $parts);
if(strlen($item["tag"])) if(strlen($item["tag"]))
$item["tag"] .= ","; $item["tag"] .= ",";
$item["tag"] .= "#[url=".App::get_baseurl()."/search?tag=".$term."]".$term."[/url]"; $item["tag"] .= $termhash."[url=".$termurl."]".$term."[/url]";
} }
}
} }
} }
@ -2243,15 +2265,17 @@ class dfrn {
else else
return; return;
if($item["object-type"] === ACTIVITY_OBJ_EVENT) { if($item["object-type"] == ACTIVITY_OBJ_EVENT) {
logger("Deleting event ".$item["event-id"], LOGGER_DEBUG); logger("Deleting event ".$item["event-id"], LOGGER_DEBUG);
event_delete($item["event-id"]); event_delete($item["event-id"]);
} }
if(($item["verb"] === ACTIVITY_TAG) && ($item["object-type"] === ACTIVITY_OBJ_TAGTERM)) { if(($item["verb"] == ACTIVITY_TAG) && ($item["object-type"] == ACTIVITY_OBJ_TAGTERM)) {
$xo = parse_xml_string($item["object"],false); $xo = parse_xml_string($item["object"],false);
$xt = parse_xml_string($item["target"],false); $xt = parse_xml_string($item["target"],false);
if($xt->type === ACTIVITY_OBJ_NOTE) {
if($xt->type == ACTIVITY_OBJ_NOTE) {
$i = q("SELECT `id`, `contact-id`, `tag` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", $i = q("SELECT `id`, `contact-id`, `tag` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($xt->id), dbesc($xt->id),
intval($importer["importer_uid"]) intval($importer["importer_uid"])

File diff suppressed because it is too large Load diff

View file

@ -20,22 +20,14 @@ function discover_poco_run(&$argv, &$argc){
require_once('include/session.php'); require_once('include/session.php');
require_once('include/datetime.php'); require_once('include/datetime.php');
require_once('include/pidfile.php');
load_config('config'); load_config('config');
load_config('system'); load_config('system');
$maxsysload = intval(get_config('system','maxloadavg')); // Don't check this stuff if the function is called by the poller
if($maxsysload < 1) if (App::callstack() != "poller_run")
$maxsysload = 50; if (App::maxload_reached())
$load = current_load();
if($load) {
if(intval($load) > $maxsysload) {
logger('system: load ' . $load . ' too high. discover_poco deferred to next scheduled run.');
return; return;
}
}
if(($argc > 2) && ($argv[1] == "dirsearch")) { if(($argc > 2) && ($argv[1] == "dirsearch")) {
$search = urldecode($argv[2]); $search = urldecode($argv[2]);
@ -50,21 +42,10 @@ function discover_poco_run(&$argv, &$argc){
} else } else
die("Unknown or missing parameter ".$argv[1]."\n"); die("Unknown or missing parameter ".$argv[1]."\n");
$lockpath = get_lockpath(); // Don't check this stuff if the function is called by the poller
if ($lockpath != '') { if (App::callstack() != "poller_run")
$pidfile = new pidfile($lockpath, 'discover_poco'.$mode.urlencode($search)); if (App::is_already_running('discover_poco'.$mode.urlencode($search), 'include/discover_poco.php', 1140))
if($pidfile->is_already_running()) { return;
logger("discover_poco: Already running");
if ($pidfile->running_time() > 19*60) {
$pidfile->kill();
logger("discover_poco: killed stale process");
// Calling a new instance
if ($mode == 0)
proc_run('php','include/discover_poco.php');
}
exit;
}
}
$a->set_baseurl(get_config('system','url')); $a->set_baseurl(get_config('system','url'));

View file

@ -1,55 +0,0 @@
<?php
require_once("boot.php");
require_once('include/diaspora.php');
function dsprphotoq_run($argv, $argc){
global $a, $db;
if(is_null($a)){
$a = new App;
}
if(is_null($db)){
@include(".htconfig.php");
require_once("include/dba.php");
$db = new dba($db_host, $db_user, $db_pass, $db_data);
unset($db_host, $db_user, $db_pass, $db_data);
};
logger("diaspora photo queue: running", LOGGER_DEBUG);
$r = q("SELECT * FROM dsprphotoq");
if(!$r)
return;
$dphotos = $r;
logger("diaspora photo queue: processing " . count($dphotos) . " photos");
foreach($dphotos as $dphoto) {
$r = array();
if ($dphoto['uid'] == 0)
$r[0] = array("uid" => 0, "page-flags" => PAGE_FREELOVE);
else
$r = q("SELECT * FROM user WHERE uid = %d",
intval($dphoto['uid']));
if(!$r) {
logger("diaspora photo queue: user " . $dphoto['uid'] . " not found");
return;
}
$ret = diaspora_dispatch($r[0],unserialize($dphoto['msg']),$dphoto['attempt']);
q("DELETE FROM dsprphotoq WHERE id = %d",
intval($dphoto['id'])
);
}
}
if (array_search(__file__,get_included_files())===0){
dsprphotoq_run($_SERVER["argv"],$_SERVER["argc"]);
killme();
}

View file

@ -54,8 +54,10 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
if ($attributes->name == "href") if ($attributes->name == "href")
$author["author-link"] = $attributes->textContent; $author["author-link"] = $attributes->textContent;
$author["author-id"] = $xpath->evaluate('/atom:feed/atom:author/atom:uri/text()')->item(0)->nodeValue;
if ($author["author-link"] == "") if ($author["author-link"] == "")
$author["author-link"] = $xpath->evaluate('/atom:feed/atom:author/atom:uri/text()')->item(0)->nodeValue; $author["author-link"] = $author["author-id"];
if ($author["author-link"] == "") { if ($author["author-link"] == "") {
$self = $xpath->query("atom:link[@rel='self']")->item(0)->attributes; $self = $xpath->query("atom:link[@rel='self']")->item(0)->attributes;
@ -127,6 +129,7 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
// This is no field in the item table. So we have to unset it. // This is no field in the item table. So we have to unset it.
unset($author["author-nick"]); unset($author["author-nick"]);
unset($author["author-id"]);
} }
$header = array(); $header = array();

View file

@ -258,12 +258,10 @@ function new_contact($uid,$url,$interactive = false) {
$contact_id = $r[0]['id']; $contact_id = $r[0]['id'];
$result['cid'] = $contact_id; $result['cid'] = $contact_id;
$g = q("select def_gid from user where uid = %d limit 1", $def_gid = get_default_group($uid, $contact["network"]);
intval($uid) if (intval($def_gid)) {
);
if($g && intval($g[0]['def_gid'])) {
require_once('include/group.php'); require_once('include/group.php');
group_add_member($uid,'',$contact_id,$g[0]['def_gid']); group_add_member($uid, '', $contact_id, $def_gid);
} }
require_once("include/Photo.php"); require_once("include/Photo.php");
@ -305,8 +303,8 @@ function new_contact($uid,$url,$interactive = false) {
} }
if($contact['network'] == NETWORK_DIASPORA) { if($contact['network'] == NETWORK_DIASPORA) {
require_once('include/diaspora.php'); require_once('include/diaspora.php');
$ret = diaspora_share($a->user,$contact); $ret = diaspora::send_share($a->user,$contact);
logger('mod_follow: diaspora_share returns: ' . $ret); logger('share returns: '.$ret);
} }
} }

View file

@ -188,7 +188,7 @@ function group_public_members($gid) {
} }
function mini_group_select($uid,$gid = 0) { function mini_group_select($uid,$gid = 0, $label = "") {
$grps = array(); $grps = array();
$o = ''; $o = '';
@ -205,8 +205,11 @@ function mini_group_select($uid,$gid = 0) {
} }
logger('groups: ' . print_r($grps,true)); logger('groups: ' . print_r($grps,true));
if ($label == "")
$label = t('Default privacy group for new contacts');
$o = replace_macros(get_markup_template('group_selection.tpl'), array( $o = replace_macros(get_markup_template('group_selection.tpl'), array(
'$label' => t('Default privacy group for new contacts'), '$label' => $label,
'$groups' => $grps '$groups' => $grps
)); ));
return $o; return $o;
@ -375,3 +378,28 @@ function groups_count_unseen() {
return $r; return $r;
} }
/**
* @brief Returns the default group for a given user and network
*
* @param int $uid User id
* @param string $network network name
*
* @return int group id
*/
function get_default_group($uid, $network = "") {
$default_group = 0;
if ($network == NETWORK_OSTATUS)
$default_group = get_pconfig($uid, "ostatus", "default_group");
if ($default_group != 0)
return $default_group;
$g = q("SELECT `def_gid` FROM `user` WHERE `uid` = %d LIMIT 1", intval($uid));
if($g && intval($g[0]["def_gid"]))
$default_group = $g[0]["def_gid"];
return $default_group;
}

View file

@ -237,6 +237,7 @@ function profile_sidebar($profile, $block = 0) {
if ($connect AND ($profile['network'] != NETWORK_DFRN) AND !isset($profile['remoteconnect'])) if ($connect AND ($profile['network'] != NETWORK_DFRN) AND !isset($profile['remoteconnect']))
$connect = false; $connect = false;
$remoteconnect = NULL;
if (isset($profile['remoteconnect'])) if (isset($profile['remoteconnect']))
$remoteconnect = $profile['remoteconnect']; $remoteconnect = $profile['remoteconnect'];
@ -292,9 +293,9 @@ function profile_sidebar($profile, $block = 0) {
// check if profile is a forum // check if profile is a forum
if((intval($profile['page-flags']) == PAGE_COMMUNITY) if((intval($profile['page-flags']) == PAGE_COMMUNITY)
|| (intval($profile['page-flags']) == PAGE_PRVGROUP) || (intval($profile['page-flags']) == PAGE_PRVGROUP)
|| (intval($profile['forum'])) || (isset($profile['forum']) && intval($profile['forum']))
|| (intval($profile['prv'])) || (isset($profile['prv']) && intval($profile['prv']))
|| (intval($profile['community']))) || (isset($profile['community']) && intval($profile['community'])))
$account_type = t('Forum'); $account_type = t('Forum');
else else
$account_type = ""; $account_type = "";
@ -332,9 +333,9 @@ function profile_sidebar($profile, $block = 0) {
'fullname' => $profile['name'], 'fullname' => $profile['name'],
'firstname' => $firstname, 'firstname' => $firstname,
'lastname' => $lastname, 'lastname' => $lastname,
'photo300' => $a->get_cached_avatar_image($a->get_baseurl() . '/photo/custom/300/' . $profile['uid'] . '.jpg'), 'photo300' => $a->get_baseurl() . '/photo/custom/300/' . $profile['uid'] . '.jpg',
'photo100' => $a->get_cached_avatar_image($a->get_baseurl() . '/photo/custom/100/' . $profile['uid'] . '.jpg'), 'photo100' => $a->get_baseurl() . '/photo/custom/100/' . $profile['uid'] . '.jpg',
'photo50' => $a->get_cached_avatar_image($a->get_baseurl() . '/photo/custom/50/' . $profile['uid'] . '.jpg'), 'photo50' => $a->get_baseurl() . '/photo/custom/50/' . $profile['uid'] . '.jpg',
); );
if (!$block){ if (!$block){

View file

@ -383,9 +383,9 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
// Converting the plink // Converting the plink
if ($arr['network'] == NETWORK_OSTATUS) { if ($arr['network'] == NETWORK_OSTATUS) {
if (isset($arr['plink'])) if (isset($arr['plink']))
$arr['plink'] = ostatus_convert_href($arr['plink']); $arr['plink'] = ostatus::convert_href($arr['plink']);
elseif (isset($arr['uri'])) elseif (isset($arr['uri']))
$arr['plink'] = ostatus_convert_href($arr['uri']); $arr['plink'] = ostatus::convert_href($arr['uri']);
} }
if(x($arr, 'gravity')) if(x($arr, 'gravity'))
@ -707,9 +707,9 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
if ($arr["uid"] == 0) { if ($arr["uid"] == 0) {
$arr["global"] = true; $arr["global"] = true;
q("UPDATE `item` SET `global` = 1 WHERE `guid` = '%s'", dbesc($arr["guid"])); q("UPDATE `item` SET `global` = 1 WHERE `uri` = '%s'", dbesc($arr["uri"]));
} else { } else {
$isglobal = q("SELECT `global` FROM `item` WHERE `uid` = 0 AND `guid` = '%s'", dbesc($arr["guid"])); $isglobal = q("SELECT `global` FROM `item` WHERE `uid` = 0 AND `uri` = '%s'", dbesc($arr["uri"]));
$arr["global"] = (count($isglobal) > 0); $arr["global"] = (count($isglobal) > 0);
} }
@ -1243,7 +1243,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
//$tempfile = tempnam(get_temppath(), "ostatus2"); //$tempfile = tempnam(get_temppath(), "ostatus2");
//file_put_contents($tempfile, $xml); //file_put_contents($tempfile, $xml);
logger("Consume OStatus messages ", LOGGER_DEBUG); logger("Consume OStatus messages ", LOGGER_DEBUG);
ostatus_import($xml,$importer,$contact, $hub); ostatus::import($xml,$importer,$contact, $hub);
} }
return; return;
} }
@ -1980,9 +1980,6 @@ function drop_item($id,$interactive = true) {
intval($r[0]['id']) intval($r[0]['id'])
); );
} }
// Add a relayable_retraction signature for Diaspora.
store_diaspora_retract_sig($item, $a->user, $a->get_baseurl());
} }
$drop_id = intval($item['id']); $drop_id = intval($item['id']);
@ -2115,51 +2112,3 @@ function posted_date_widget($url,$uid,$wall) {
)); ));
return $o; return $o;
} }
function store_diaspora_retract_sig($item, $user, $baseurl) {
// Note that we can't add a target_author_signature
// if the comment was deleted by a remote user. That should be ok, because if a remote user is deleting
// the comment, that means we're the home of the post, and Diaspora will only
// check the parent_author_signature of retractions that it doesn't have to relay further
//
// I don't think this function gets called for an "unlike," but I'll check anyway
$enabled = intval(get_config('system','diaspora_enabled'));
if(! $enabled) {
logger('drop_item: diaspora support disabled, not storing retraction signature', LOGGER_DEBUG);
return;
}
logger('drop_item: storing diaspora retraction signature');
$signed_text = $item['guid'] . ';' . ( ($item['verb'] === ACTIVITY_LIKE) ? 'Like' : 'Comment');
if(local_user() == $item['uid']) {
$handle = $user['nickname'] . '@' . substr($baseurl, strpos($baseurl,'://') + 3);
$authorsig = base64_encode(rsa_sign($signed_text,$user['prvkey'],'sha256'));
}
else {
$r = q("SELECT `nick`, `url` FROM `contact` WHERE `id` = '%d' LIMIT 1",
$item['contact-id'] // If this function gets called, drop_item() has already checked remote_user() == $item['contact-id']
);
if(count($r)) {
// The below handle only works for NETWORK_DFRN. I think that's ok, because this function
// only handles DFRN deletes
$handle_baseurl_start = strpos($r['url'],'://') + 3;
$handle_baseurl_length = strpos($r['url'],'/profile') - $handle_baseurl_start;
$handle = $r['nick'] . '@' . substr($r['url'], $handle_baseurl_start, $handle_baseurl_length);
$authorsig = '';
}
}
if(isset($handle))
q("insert into sign (`retract_iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ",
intval($item['id']),
dbesc($signed_text),
dbesc($authorsig),
dbesc($handle)
);
return;
}

View file

@ -1,4 +1,5 @@
<?php <?php
require_once("include/diaspora.php");
/** /**
* @brief add/remove activity to an item * @brief add/remove activity to an item
@ -151,9 +152,6 @@ function do_like($item_id, $verb) {
intval($like_item['id']) intval($like_item['id'])
); );
// Save the author information for the unlike in case we need to relay to Diaspora
store_diaspora_like_retract_sig($activity, $item, $like_item, $contact);
$like_item_id = $like_item['id']; $like_item_id = $like_item['id'];
proc_run('php',"include/notifier.php","like","$like_item_id"); proc_run('php',"include/notifier.php","like","$like_item_id");
@ -196,6 +194,7 @@ EOT;
$arr = array(); $arr = array();
$arr['guid'] = get_guid(32);
$arr['uri'] = $uri; $arr['uri'] = $uri;
$arr['uid'] = $owner_uid; $arr['uid'] = $owner_uid;
$arr['contact-id'] = $contact['id']; $arr['contact-id'] = $contact['id'];
@ -240,7 +239,7 @@ EOT;
// Save the author information for the like in case we need to relay to Diaspora // Save the author information for the like in case we need to relay to Diaspora
store_diaspora_like_sig($activity, $post_type, $contact, $post_id); diaspora::store_like_signature($contact, $post_id);
$arr['id'] = $post_id; $arr['id'] = $post_id;
@ -250,149 +249,3 @@ EOT;
return true; return true;
} }
function store_diaspora_like_retract_sig($activity, $item, $like_item, $contact) {
// Note that we can only create a signature for a user of the local server. We don't have
// a key for remote users. That is ok, because if a remote user is "unlike"ing a post, it
// means we are the relay, and for relayable_retractions, Diaspora
// only checks the parent_author_signature if it doesn't have to relay further
//
// If $item['resource-id'] exists, it means the item is a photo. Diaspora doesn't support
// likes on photos, so don't bother.
$enabled = intval(get_config('system','diaspora_enabled'));
if(! $enabled) {
logger('mod_like: diaspora support disabled, not storing like retraction signature', LOGGER_DEBUG);
return;
}
logger('mod_like: storing diaspora like retraction signature');
if(($activity === ACTIVITY_LIKE) && (! $item['resource-id'])) {
$signed_text = $like_item['guid'] . ';' . 'Like';
// Only works for NETWORK_DFRN
$contact_baseurl_start = strpos($contact['url'],'://') + 3;
$contact_baseurl_length = strpos($contact['url'],'/profile') - $contact_baseurl_start;
$contact_baseurl = substr($contact['url'], $contact_baseurl_start, $contact_baseurl_length);
$diaspora_handle = $contact['nick'] . '@' . $contact_baseurl;
// This code could never had worked (the return values form the queries were used in a wrong way.
// Additionally it is needlessly complicated. Either the contact is owner or not. And we have this data already.
/*
// Get contact's private key if he's a user of the local Friendica server
$r = q("SELECT `contact`.`uid` FROM `contact` WHERE `url` = '%s' AND `self` = 1 LIMIT 1",
dbesc($contact['url'])
);
if( $r) {
$contact_uid = $r['uid'];
$r = q("SELECT prvkey FROM user WHERE uid = %d LIMIT 1",
intval($contact_uid)
);
*/
// Is the contact the owner? Then fetch the private key
if ($contact['self'] AND ($contact['uid'] > 0)) {
$r = q("SELECT prvkey FROM user WHERE uid = %d LIMIT 1",
intval($contact['uid'])
);
if($r)
$authorsig = base64_encode(rsa_sign($signed_text,$r[0]['prvkey'],'sha256'));
}
if(! isset($authorsig))
$authorsig = '';
q("insert into sign (`retract_iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ",
intval($like_item['id']),
dbesc($signed_text),
dbesc($authorsig),
dbesc($diaspora_handle)
);
}
return;
}
function store_diaspora_like_sig($activity, $post_type, $contact, $post_id) {
// Note that we can only create a signature for a user of the local server. We don't have
// a key for remote users. That is ok, because if a remote user is "unlike"ing a post, it
// means we are the relay, and for relayable_retractions, Diaspora
// only checks the parent_author_signature if it doesn't have to relay further
$enabled = intval(get_config('system','diaspora_enabled'));
if(! $enabled) {
logger('mod_like: diaspora support disabled, not storing like signature', LOGGER_DEBUG);
return;
}
logger('mod_like: storing diaspora like signature');
if(($activity === ACTIVITY_LIKE) && ($post_type === t('status'))) {
// Only works for NETWORK_DFRN
$contact_baseurl_start = strpos($contact['url'],'://') + 3;
$contact_baseurl_length = strpos($contact['url'],'/profile') - $contact_baseurl_start;
$contact_baseurl = substr($contact['url'], $contact_baseurl_start, $contact_baseurl_length);
$diaspora_handle = $contact['nick'] . '@' . $contact_baseurl;
// This code could never had worked (the return values form the queries were used in a wrong way.
// Additionally it is needlessly complicated. Either the contact is owner or not. And we have this data already.
/*
// Get contact's private key if he's a user of the local Friendica server
$r = q("SELECT `contact`.`uid` FROM `contact` WHERE `url` = '%s' AND `self` = 1 LIMIT 1",
dbesc($contact['url'])
);
if( $r) {
$contact_uid = $r['uid'];
$r = q("SELECT prvkey FROM user WHERE uid = %d LIMIT 1",
intval($contact_uid)
);
if( $r)
$contact_uprvkey = $r['prvkey'];
}
*/
// Is the contact the owner? Then fetch the private key
if ($contact['self'] AND ($contact['uid'] > 0)) {
$r = q("SELECT prvkey FROM user WHERE uid = %d LIMIT 1",
intval($contact['uid'])
);
if($r)
$contact_uprvkey = $r[0]['prvkey'];
}
$r = q("SELECT guid, parent FROM `item` WHERE id = %d LIMIT 1",
intval($post_id)
);
if( $r) {
$p = q("SELECT guid FROM `item` WHERE id = %d AND parent = %d LIMIT 1",
intval($r[0]['parent']),
intval($r[0]['parent'])
);
if( $p) {
$signed_text = 'true;'.$r[0]['guid'].';Post;'.$p[0]['guid'].';'.$diaspora_handle;
if(isset($contact_uprvkey))
$authorsig = base64_encode(rsa_sign($signed_text,$contact_uprvkey,'sha256'));
else
$authorsig = '';
q("insert into sign (`iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ",
intval($post_id),
dbesc($signed_text),
dbesc($authorsig),
dbesc($diaspora_handle)
);
}
}
}
return;
}

View file

@ -82,7 +82,7 @@ function nav_info(&$a) {
// user info // user info
$r = q("SELECT micro FROM contact WHERE uid=%d AND self=1", intval($a->user['uid'])); $r = q("SELECT micro FROM contact WHERE uid=%d AND self=1", intval($a->user['uid']));
$userinfo = array( $userinfo = array(
'icon' => (count($r) ? $a->get_cached_avatar_image($r[0]['micro']) : $a->get_baseurl($ssl_state)."/images/person-48.jpg"), 'icon' => (count($r) ? $a->remove_baseurl($r[0]['micro']) : "images/person-48.jpg"),
'name' => $a->user['username'], 'name' => $a->user['username'],
); );
@ -107,7 +107,7 @@ function nav_info(&$a) {
if(($a->config['register_policy'] == REGISTER_OPEN) && (! local_user()) && (! remote_user())) if(($a->config['register_policy'] == REGISTER_OPEN) && (! local_user()) && (! remote_user()))
$nav['register'] = array('register',t('Register'), "", t('Create an account')); $nav['register'] = array('register',t('Register'), "", t('Create an account'));
$help_url = $a->get_baseurl($ssl_state) . '/help'; $help_url = 'help';
if(! get_config('system','hide_help')) if(! get_config('system','hide_help'))
$nav['help'] = array($help_url, t('Help'), "", t('Help and documentation')); $nav['help'] = array($help_url, t('Help'), "", t('Help and documentation'));

View file

@ -862,64 +862,6 @@ function parse_xml_string($s,$strict = true) {
return $x; return $x;
}} }}
function add_fcontact($arr,$update = false) {
if($update) {
$r = q("UPDATE `fcontact` SET
`name` = '%s',
`photo` = '%s',
`request` = '%s',
`nick` = '%s',
`addr` = '%s',
`batch` = '%s',
`notify` = '%s',
`poll` = '%s',
`confirm` = '%s',
`alias` = '%s',
`pubkey` = '%s',
`updated` = '%s'
WHERE `url` = '%s' AND `network` = '%s'",
dbesc($arr['name']),
dbesc($arr['photo']),
dbesc($arr['request']),
dbesc($arr['nick']),
dbesc($arr['addr']),
dbesc($arr['batch']),
dbesc($arr['notify']),
dbesc($arr['poll']),
dbesc($arr['confirm']),
dbesc($arr['alias']),
dbesc($arr['pubkey']),
dbesc(datetime_convert()),
dbesc($arr['url']),
dbesc($arr['network'])
);
}
else {
$r = q("insert into fcontact ( `url`,`name`,`photo`,`request`,`nick`,`addr`,
`batch`, `notify`,`poll`,`confirm`,`network`,`alias`,`pubkey`,`updated` )
values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')",
dbesc($arr['url']),
dbesc($arr['name']),
dbesc($arr['photo']),
dbesc($arr['request']),
dbesc($arr['nick']),
dbesc($arr['addr']),
dbesc($arr['batch']),
dbesc($arr['notify']),
dbesc($arr['poll']),
dbesc($arr['confirm']),
dbesc($arr['network']),
dbesc($arr['alias']),
dbesc($arr['pubkey']),
dbesc(datetime_convert())
);
}
return $r;
}
function scale_external_images($srctext, $include_link = true, $scale_replace = false) { function scale_external_images($srctext, $include_link = true, $scale_replace = false) {
// Suppress "view full size" // Suppress "view full size"

View file

@ -223,13 +223,13 @@ function notifier_run(&$argv, &$argc){
if(! ($mail || $fsuggest || $relocate)) { if(! ($mail || $fsuggest || $relocate)) {
$slap = ostatus_salmon($target_item,$owner); $slap = ostatus::salmon($target_item,$owner);
require_once('include/group.php'); require_once('include/group.php');
$parent = $items[0]; $parent = $items[0];
$thr_parent = q("SELECT `network` FROM `item` WHERE `uri` = '%s' AND `uid` = %d", $thr_parent = q("SELECT `network`, `author-link`, `owner-link` FROM `item` WHERE `uri` = '%s' AND `uid` = %d",
dbesc($target_item["thr-parent"]), intval($target_item["uid"])); dbesc($target_item["thr-parent"]), intval($target_item["uid"]));
logger('Parent is '.$parent['network'].'. Thread parent is '.$thr_parent[0]['network'], LOGGER_DEBUG); logger('Parent is '.$parent['network'].'. Thread parent is '.$thr_parent[0]['network'], LOGGER_DEBUG);
@ -390,6 +390,20 @@ function notifier_run(&$argv, &$argc){
logger('Some parent is OStatus for '.$target_item["guid"], LOGGER_DEBUG); logger('Some parent is OStatus for '.$target_item["guid"], LOGGER_DEBUG);
// Send a salmon to the parent author
$probed_contact = probe_url($thr_parent[0]['author-link']);
if ($probed_contact["notify"] != "") {
logger('Notify parent author '.$probed_contact["url"].': '.$probed_contact["notify"]);
$url_recipients[$probed_contact["notify"]] = $probed_contact["notify"];
}
// Send a salmon to the parent owner
$probed_contact = probe_url($thr_parent[0]['owner-link']);
if ($probed_contact["notify"] != "") {
logger('Notify parent owner '.$probed_contact["url"].': '.$probed_contact["notify"]);
$url_recipients[$probed_contact["notify"]] = $probed_contact["notify"];
}
// Send a salmon notification to every person we mentioned in the post // Send a salmon notification to every person we mentioned in the post
$arr = explode(',',$target_item['tag']); $arr = explode(',',$target_item['tag']);
foreach($arr as $x) { foreach($arr as $x) {
@ -536,7 +550,7 @@ function notifier_run(&$argv, &$argc){
if($public_message) { if($public_message) {
if (!$followup AND $top_level) if (!$followup AND $top_level)
$r0 = diaspora_fetch_relay(); $r0 = diaspora::relay_list();
else else
$r0 = array(); $r0 = array();
@ -628,13 +642,6 @@ function notifier_run(&$argv, &$argc){
proc_run('php','include/pubsubpublish.php'); proc_run('php','include/pubsubpublish.php');
} }
// If the item was deleted, clean up the `sign` table
if($target_item['deleted']) {
$r = q("DELETE FROM sign where `retract_iid` = %d",
intval($target_item['id'])
);
}
logger('notifier: calling hooks', LOGGER_DEBUG); logger('notifier: calling hooks', LOGGER_DEBUG);
if($normal_mode) if($normal_mode)

View file

@ -31,7 +31,6 @@ function onepoll_run(&$argv, &$argc){
require_once('include/Contact.php'); require_once('include/Contact.php');
require_once('include/email.php'); require_once('include/email.php');
require_once('include/socgraph.php'); require_once('include/socgraph.php');
require_once('include/pidfile.php');
require_once('include/queue_fn.php'); require_once('include/queue_fn.php');
load_config('config'); load_config('config');
@ -60,18 +59,10 @@ function onepoll_run(&$argv, &$argc){
return; return;
} }
$lockpath = get_lockpath(); // Don't check this stuff if the function is called by the poller
if ($lockpath != '') { if (App::callstack() != "poller_run")
$pidfile = new pidfile($lockpath, 'onepoll'.$contact_id); if (App::is_already_running('onepoll'.$contact_id, '', 540))
if ($pidfile->is_already_running()) { return;
logger("onepoll: Already running for contact ".$contact_id);
if ($pidfile->running_time() > 9*60) {
$pidfile->kill();
logger("killed stale process");
}
exit;
}
}
$d = datetime_convert(); $d = datetime_convert();

File diff suppressed because it is too large Load diff

View file

@ -132,7 +132,19 @@ function shortenmsg($msg, $limit, $twitter = false) {
return($msg); return($msg);
} }
function plaintext($a, $b, $limit = 0, $includedlinks = false, $htmlmode = 2) { /**
* @brief Convert a message into plaintext for connectors to other networks
*
* @param App $a The application class
* @param array $b The message array that is about to be posted
* @param int $limit The maximum number of characters when posting to that network
* @param bool $includedlinks Has an attached link to be included into the message?
* @param int $htmlmode This triggers the behaviour of the bbcode conversion
* @param string $target_network Name of the network where the post should go to.
*
* @return string The converted message
*/
function plaintext($a, $b, $limit = 0, $includedlinks = false, $htmlmode = 2, $target_network = "") {
require_once("include/bbcode.php"); require_once("include/bbcode.php");
require_once("include/html2plain.php"); require_once("include/html2plain.php");
require_once("include/network.php"); require_once("include/network.php");
@ -144,6 +156,9 @@ function plaintext($a, $b, $limit = 0, $includedlinks = false, $htmlmode = 2) {
// Add an URL element if the text contains a raw link // Add an URL element if the text contains a raw link
$body = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url]$2[/url]', $body); $body = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url]$2[/url]', $body);
// Remove the abstract
$body = remove_abstract($body);
// At first look at data that is attached via "type-..." stuff // At first look at data that is attached via "type-..." stuff
// This will hopefully replaced with a dedicated bbcode later // This will hopefully replaced with a dedicated bbcode later
//$post = get_attached_data($b["body"]); //$post = get_attached_data($b["body"]);
@ -154,6 +169,44 @@ function plaintext($a, $b, $limit = 0, $includedlinks = false, $htmlmode = 2) {
elseif ($b["title"] != "") elseif ($b["title"] != "")
$post["text"] = trim($b["title"]); $post["text"] = trim($b["title"]);
$abstract = "";
// Fetch the abstract from the given target network
if ($target_network != "") {
$default_abstract = fetch_abstract($b["body"]);
$abstract = fetch_abstract($b["body"], $target_network);
// If we post to a network with no limit we only fetch
// an abstract exactly for this network
if (($limit == 0) AND ($abstract == $default_abstract))
$abstract = "";
} else // Try to guess the correct target network
switch ($htmlmode) {
case 8:
$abstract = fetch_abstract($b["body"], NETWORK_TWITTER);
break;
case 7:
$abstract = fetch_abstract($b["body"], NETWORK_STATUSNET);
break;
case 6:
$abstract = fetch_abstract($b["body"], NETWORK_APPNET);
break;
default: // We don't know the exact target.
// We fetch an abstract since there is a posting limit.
if ($limit > 0)
$abstract = fetch_abstract($b["body"]);
}
if ($abstract != "") {
$post["text"] = $abstract;
if ($post["type"] == "text") {
$post["type"] = "link";
$post["url"] = $b["plink"];
}
}
$html = bbcode($post["text"], false, false, $htmlmode); $html = bbcode($post["text"], false, false, $htmlmode);
$msg = html2plain($html, 0, true); $msg = html2plain($html, 0, true);
$msg = trim(html_entity_decode($msg,ENT_QUOTES,'UTF-8')); $msg = trim(html_entity_decode($msg,ENT_QUOTES,'UTF-8'));

View file

@ -29,17 +29,8 @@ function poller_run(&$argv, &$argc){
if (poller_max_connections_reached()) if (poller_max_connections_reached())
return; return;
$load = current_load(); if (App::maxload_reached())
if($load) { return;
$maxsysload = intval(get_config('system','maxloadavg'));
if($maxsysload < 1)
$maxsysload = 50;
if(intval($load) > $maxsysload) {
logger('system: load ' . $load . ' too high. poller deferred to next scheduled run.');
return;
}
}
// Checking the number of workers // Checking the number of workers
if (poller_too_much_workers(1)) { if (poller_too_much_workers(1)) {
@ -205,6 +196,12 @@ function poller_max_connections_reached() {
*/ */
function poller_kill_stale_workers() { function poller_kill_stale_workers() {
$r = q("SELECT `pid`, `executed` FROM `workerqueue` WHERE `executed` != '0000-00-00 00:00:00'"); $r = q("SELECT `pid`, `executed` FROM `workerqueue` WHERE `executed` != '0000-00-00 00:00:00'");
if (!is_array($r) || count($r) == 0) {
// No processing here needed
return;
}
foreach($r AS $pid) foreach($r AS $pid)
if (!posix_kill($pid["pid"], 0)) if (!posix_kill($pid["pid"], 0))
q("UPDATE `workerqueue` SET `executed` = '0000-00-00 00:00:00', `pid` = 0 WHERE `pid` = %d", q("UPDATE `workerqueue` SET `executed` = '0000-00-00 00:00:00', `pid` = 0 WHERE `pid` = %d",

141
include/post_update.php Normal file
View file

@ -0,0 +1,141 @@
<?php
/**
* @file include/post_update.php
*/
/**
* @brief Calls the post update functions
*/
function post_update() {
if (!post_update_1192())
return;
if (!post_update_1194())
return;
}
/**
* @brief set the gcontact-id in all item entries
*
* This job has to be started multiple times until all entries are set.
* It isn't started in the update function since it would consume too much time and can be done in the background.
*
* @return bool "true" when the job is done
*/
function post_update_1192() {
// Was the script completed?
if (get_config("system", "post_update_version") >= 1192)
return true;
// Check if the first step is done (Setting "gcontact-id" in the item table)
$r = q("SELECT `author-link`, `author-name`, `author-avatar`, `uid`, `network` FROM `item` WHERE `gcontact-id` = 0 LIMIT 1000");
if (!$r) {
// Are there unfinished entries in the thread table?
$r = q("SELECT COUNT(*) AS `total` FROM `thread`
INNER JOIN `item` ON `item`.`id` =`thread`.`iid`
WHERE `thread`.`gcontact-id` = 0 AND
(`thread`.`uid` IN (SELECT `uid` from `user`) OR `thread`.`uid` = 0)");
if ($r AND ($r[0]["total"] == 0)) {
set_config("system", "post_update_version", 1192);
return true;
}
// Update the thread table from the item table
q("UPDATE `thread` INNER JOIN `item` ON `item`.`id`=`thread`.`iid`
SET `thread`.`gcontact-id` = `item`.`gcontact-id`
WHERE `thread`.`gcontact-id` = 0 AND
(`thread`.`uid` IN (SELECT `uid` from `user`) OR `thread`.`uid` = 0)");
return false;
}
$item_arr = array();
foreach ($r AS $item) {
$index = $item["author-link"]."-".$item["uid"];
$item_arr[$index] = array("author-link" => $item["author-link"],
"uid" => $item["uid"],
"network" => $item["network"]);
}
// Set the "gcontact-id" in the item table and add a new gcontact entry if needed
foreach($item_arr AS $item) {
$gcontact_id = get_gcontact_id(array("url" => $item['author-link'], "network" => $item['network'],
"photo" => $item['author-avatar'], "name" => $item['author-name']));
q("UPDATE `item` SET `gcontact-id` = %d WHERE `uid` = %d AND `author-link` = '%s' AND `gcontact-id` = 0",
intval($gcontact_id), intval($item["uid"]), dbesc($item["author-link"]));
}
return false;
}
/**
* @brief Updates the "global" field in the item table
*
* @return bool "true" when the job is done
*/
function post_update_1194() {
// Was the script completed?
if (get_config("system", "post_update_version") >= 1194)
return true;
logger("Start", LOGGER_DEBUG);
$end_id = get_config("system", "post_update_1194_end");
if (!$end_id) {
$r = q("SELECT `id` FROM `item` WHERE `uid` != 0 ORDER BY `id` DESC LIMIT 1");
if ($r) {
set_config("system", "post_update_1194_end", $r[0]["id"]);
$end_id = get_config("system", "post_update_1194_end");
}
}
logger("End ID: ".$end_id, LOGGER_DEBUG);
$start_id = get_config("system", "post_update_1194_start");
$query1 = "SELECT `item`.`id` FROM `item` ";
$query2 = "INNER JOIN `item` AS `shadow` ON `item`.`uri` = `shadow`.`uri` AND `shadow`.`uid` = 0 ";
$query3 = "WHERE `item`.`uid` != 0 AND `item`.`id` >= %d AND `item`.`id` <= %d
AND `item`.`visible` AND NOT `item`.`private`
AND NOT `item`.`deleted` AND NOT `item`.`moderated`
AND `item`.`network` IN ('%s', '%s', '%s', '')
AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
AND NOT `item`.`global`";
$r = q($query1.$query2.$query3." ORDER BY `item`.`id` LIMIT 1",
intval($start_id), intval($end_id),
dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_OSTATUS));
if (!$r) {
set_config("system", "post_update_version", 1194);
logger("Update is done", LOGGER_DEBUG);
return true;
} else {
set_config("system", "post_update_1194_start", $r[0]["id"]);
$start_id = get_config("system", "post_update_1194_start");
}
logger("Start ID: ".$start_id, LOGGER_DEBUG);
$r = q($query1.$query2.$query3." ORDER BY `item`.`id` LIMIT 1000,1",
intval($start_id), intval($end_id),
dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_OSTATUS));
if ($r)
$pos_id = $r[0]["id"];
else
$pos_id = $end_id;
logger("Progress: Start: ".$start_id." position: ".$pos_id." end: ".$end_id, LOGGER_DEBUG);
$r = q("UPDATE `item` ".$query2." SET `item`.`global` = 1 ".$query3,
intval($start_id), intval($pos_id),
dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_OSTATUS));
logger("Done", LOGGER_DEBUG);
}
?>

View file

@ -1,96 +1,6 @@
<?php <?php
require_once('include/datetime.php');
require_once('include/diaspora.php'); require_once('include/diaspora.php');
require_once('include/queue_fn.php');
require_once('include/Contact.php');
function profile_change() { function profile_change() {
diaspora::send_profile(local_user());
$a = get_app();
if(! local_user())
return;
// $url = $a->get_baseurl() . '/profile/' . $a->user['nickname'];
// if($url && strlen(get_config('system','directory')))
// proc_run('php',"include/directory.php","$url");
$recips = q("SELECT `id`,`name`,`network`,`pubkey`,`notify` FROM `contact` WHERE `network` = '%s'
AND `uid` = %d AND `rel` != %d ",
dbesc(NETWORK_DIASPORA),
intval(local_user()),
intval(CONTACT_IS_SHARING)
);
if(! count($recips))
return;
$r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `user`.* FROM `profile`
INNER JOIN `user` ON `profile`.`uid` = `user`.`uid`
WHERE `user`.`uid` = %d AND `profile`.`is-default` = 1 LIMIT 1",
intval(local_user())
);
if(! count($r))
return;
$profile = $r[0];
$handle = xmlify($a->user['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3));
$first = xmlify(((strpos($profile['name'],' '))
? trim(substr($profile['name'],0,strpos($profile['name'],' '))) : $profile['name']));
$last = xmlify((($first === $profile['name']) ? '' : trim(substr($profile['name'],strlen($first)))));
$large = xmlify($a->get_baseurl() . '/photo/custom/300/' . $profile['uid'] . '.jpg');
$medium = xmlify($a->get_baseurl() . '/photo/custom/100/' . $profile['uid'] . '.jpg');
$small = xmlify($a->get_baseurl() . '/photo/custom/50/' . $profile['uid'] . '.jpg');
$searchable = xmlify((($profile['publish'] && $profile['net-publish']) ? 'true' : 'false' ));
// $searchable = 'true';
if($searchable === 'true') {
$dob = '1000-00-00';
if(($profile['dob']) && ($profile['dob'] != '0000-00-00'))
$dob = ((intval($profile['dob'])) ? intval($profile['dob']) : '1000') . '-' . datetime_convert('UTC','UTC',$profile['dob'],'m-d');
$gender = xmlify($profile['gender']);
$about = xmlify($profile['about']);
require_once('include/bbcode.php');
$about = xmlify(strip_tags(bbcode($about)));
$location = formatted_location($profile);
$location = xmlify($location);
$tags = '';
if($profile['pub_keywords']) {
$kw = str_replace(',',' ',$profile['pub_keywords']);
$kw = str_replace(' ',' ',$kw);
$arr = explode(' ',$profile['pub_keywords']);
if(count($arr)) {
for($x = 0; $x < 5; $x ++) {
if(trim($arr[$x]))
$tags .= '#' . trim($arr[$x]) . ' ';
}
}
}
$tags = xmlify(trim($tags));
}
$tpl = get_markup_template('diaspora_profile.tpl');
$msg = replace_macros($tpl,array(
'$handle' => $handle,
'$first' => $first,
'$last' => $last,
'$large' => $large,
'$medium' => $medium,
'$small' => $small,
'$dob' => $dob,
'$gender' => $gender,
'$about' => $about,
'$location' => $location,
'$searchable' => $searchable,
'$tags' => $tags
));
logger('profile_change: ' . $msg, LOGGER_ALL);
foreach($recips as $recip) {
$msgtosend = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$a->user,$recip,$a->user['prvkey'],$recip['pubkey'],false)));
add_to_queue($recip['id'],NETWORK_DIASPORA,$msgtosend,false);
}
} }

View file

@ -16,7 +16,7 @@ function handle_pubsubhubbub() {
logger("Generate feed for user ".$rr['nickname']." - last updated ".$rr['last_update'], LOGGER_DEBUG); logger("Generate feed for user ".$rr['nickname']." - last updated ".$rr['last_update'], LOGGER_DEBUG);
$params = ostatus_feed($a, $rr['nickname'], $rr['last_update']); $params = ostatus::feed($a, $rr['nickname'], $rr['last_update']);
$hmac_sig = hash_hmac("sha1", $params, $rr['secret']); $hmac_sig = hash_hmac("sha1", $params, $rr['secret']);
$headers = array("Content-type: application/atom+xml", $headers = array("Content-type: application/atom+xml",
@ -74,25 +74,14 @@ function pubsubpublish_run(&$argv, &$argc){
}; };
require_once('include/items.php'); require_once('include/items.php');
require_once('include/pidfile.php');
load_config('config'); load_config('config');
load_config('system'); load_config('system');
$lockpath = get_lockpath(); // Don't check this stuff if the function is called by the poller
if ($lockpath != '') { if (App::callstack() != "poller_run")
$pidfile = new pidfile($lockpath, 'pubsubpublish'); if (App::is_already_running("pubsubpublish", "include/pubsubpublish.php", 540))
if($pidfile->is_already_running()) {
logger("Already running");
if ($pidfile->running_time() > 9*60) {
$pidfile->kill();
logger("killed stale process");
// Calling a new instance
proc_run('php',"include/pubsubpublish.php");
}
return; return;
}
}
$a->set_baseurl(get_config('system','url')); $a->set_baseurl(get_config('system','url'));

View file

@ -22,26 +22,15 @@ function queue_run(&$argv, &$argc){
require_once("include/datetime.php"); require_once("include/datetime.php");
require_once('include/items.php'); require_once('include/items.php');
require_once('include/bbcode.php'); require_once('include/bbcode.php');
require_once('include/pidfile.php');
require_once('include/socgraph.php'); require_once('include/socgraph.php');
load_config('config'); load_config('config');
load_config('system'); load_config('system');
$lockpath = get_lockpath(); // Don't check this stuff if the function is called by the poller
if ($lockpath != '') { if (App::callstack() != "poller_run")
$pidfile = new pidfile($lockpath, 'queue'); if (App::is_already_running('queue', 'include/queue.php', 540))
if($pidfile->is_already_running()) {
logger("queue: Already running");
if ($pidfile->running_time() > 9*60) {
$pidfile->kill();
logger("queue: killed stale process");
// Calling a new instance
proc_run('php',"include/queue.php");
}
return; return;
}
}
$a->set_baseurl(get_config('system','url')); $a->set_baseurl(get_config('system','url'));
@ -204,7 +193,7 @@ function queue_run(&$argv, &$argc){
case NETWORK_DIASPORA: case NETWORK_DIASPORA:
if($contact['notify']) { if($contact['notify']) {
logger('queue: diaspora_delivery: item '.$q_item['id'].' for '.$contact['name'].' <'.$contact['url'].'>'); logger('queue: diaspora_delivery: item '.$q_item['id'].' for '.$contact['name'].' <'.$contact['url'].'>');
$deliver_status = diaspora_transmit($owner,$contact,$data,$public,true); $deliver_status = diaspora::transmit($owner,$contact,$data,$public,true);
if($deliver_status == (-1)) { if($deliver_status == (-1)) {
update_queue_time($q_item['id']); update_queue_time($q_item['id']);

View file

@ -69,7 +69,7 @@ function ref_session_destroy ($id) {
if(! function_exists('ref_session_gc')) { if(! function_exists('ref_session_gc')) {
function ref_session_gc($expire) { function ref_session_gc($expire) {
q("DELETE FROM `session` WHERE `expire` < %d", dbesc(time())); q("DELETE FROM `session` WHERE `expire` < %d", dbesc(time()));
q("OPTIMIZE TABLE `sess_data`"); //q("OPTIMIZE TABLE `sess_data`");
return true; return true;
}} }}

View file

@ -438,44 +438,47 @@ function poco_last_updated($profile, $force = false) {
$noscrape = json_decode($noscraperet["body"], true); $noscrape = json_decode($noscraperet["body"], true);
$contact = array("url" => $profile, if (is_array($noscrape)) {
"network" => $server[0]["network"], $contact = array("url" => $profile,
"generation" => $gcontacts[0]["generation"]); "network" => $server[0]["network"],
"generation" => $gcontacts[0]["generation"]);
$contact["name"] = $noscrape["fn"]; $contact["name"] = $noscrape["fn"];
$contact["community"] = $noscrape["comm"]; $contact["community"] = $noscrape["comm"];
if (isset($noscrape["tags"])) { if (isset($noscrape["tags"])) {
$keywords = implode(" ", $noscrape["tags"]); $keywords = implode(" ", $noscrape["tags"]);
if ($keywords != "") if ($keywords != "")
$contact["keywords"] = $keywords; $contact["keywords"] = $keywords;
}
$location = formatted_location($noscrape);
if ($location)
$contact["location"] = $location;
$contact["notify"] = $noscrape["dfrn-notify"];
// Remove all fields that are not present in the gcontact table
unset($noscrape["fn"]);
unset($noscrape["key"]);
unset($noscrape["homepage"]);
unset($noscrape["comm"]);
unset($noscrape["tags"]);
unset($noscrape["locality"]);
unset($noscrape["region"]);
unset($noscrape["country-name"]);
unset($noscrape["contacts"]);
unset($noscrape["dfrn-request"]);
unset($noscrape["dfrn-confirm"]);
unset($noscrape["dfrn-notify"]);
unset($noscrape["dfrn-poll"]);
$contact = array_merge($contact, $noscrape);
update_gcontact($contact);
return $noscrape["updated"];
} }
$location = formatted_location($noscrape);
if ($location)
$contact["location"] = $location;
$contact["notify"] = $noscrape["dfrn-notify"];
// Remove all fields that are not present in the gcontact table
unset($noscrape["fn"]);
unset($noscrape["key"]);
unset($noscrape["homepage"]);
unset($noscrape["comm"]);
unset($noscrape["tags"]);
unset($noscrape["locality"]);
unset($noscrape["region"]);
unset($noscrape["country-name"]);
unset($noscrape["contacts"]);
unset($noscrape["dfrn-request"]);
unset($noscrape["dfrn-confirm"]);
unset($noscrape["dfrn-notify"]);
unset($noscrape["dfrn-poll"]);
$contact = array_merge($contact, $noscrape);
update_gcontact($contact);
return $noscrape["updated"];
} }
} }
} }
@ -719,7 +722,8 @@ function poco_check_server($server_url, $network = "", $force = false) {
// Will also return data for Friendica and GNU Social - but it will be overwritten later // Will also return data for Friendica and GNU Social - but it will be overwritten later
// The "not implemented" is a special treatment for really, really old Friendica versions // The "not implemented" is a special treatment for really, really old Friendica versions
$serverret = z_fetch_url($server_url."/api/statusnet/version.json"); $serverret = z_fetch_url($server_url."/api/statusnet/version.json");
if ($serverret["success"] AND ($serverret["body"] != '{"error":"not implemented"}') AND ($serverret["body"] != '') AND (strlen($serverret["body"]) < 250)) { if ($serverret["success"] AND ($serverret["body"] != '{"error":"not implemented"}') AND
($serverret["body"] != '') AND (strlen($serverret["body"]) < 30)) {
$platform = "StatusNet"; $platform = "StatusNet";
$version = trim($serverret["body"], '"'); $version = trim($serverret["body"], '"');
$network = NETWORK_OSTATUS; $network = NETWORK_OSTATUS;
@ -727,7 +731,8 @@ function poco_check_server($server_url, $network = "", $force = false) {
// Test for GNU Social // Test for GNU Social
$serverret = z_fetch_url($server_url."/api/gnusocial/version.json"); $serverret = z_fetch_url($server_url."/api/gnusocial/version.json");
if ($serverret["success"] AND ($serverret["body"] != '{"error":"not implemented"}') AND ($serverret["body"] != '') AND (strlen($serverret["body"]) < 250)) { if ($serverret["success"] AND ($serverret["body"] != '{"error":"not implemented"}') AND
($serverret["body"] != '') AND (strlen($serverret["body"]) < 30)) {
$platform = "GNU Social"; $platform = "GNU Social";
$version = trim($serverret["body"], '"'); $version = trim($serverret["body"], '"');
$network = NETWORK_OSTATUS; $network = NETWORK_OSTATUS;
@ -854,6 +859,11 @@ function poco_check_server($server_url, $network = "", $force = false) {
// Check again if the server exists // Check again if the server exists
$servers = q("SELECT `nurl` FROM `gserver` WHERE `nurl` = '%s'", dbesc(normalise_link($server_url))); $servers = q("SELECT `nurl` FROM `gserver` WHERE `nurl` = '%s'", dbesc(normalise_link($server_url)));
$version = strip_tags($version);
$site_name = strip_tags($site_name);
$info = strip_tags($info);
$platform = strip_tags($platform);
if ($servers) if ($servers)
q("UPDATE `gserver` SET `url` = '%s', `version` = '%s', `site_name` = '%s', `info` = '%s', `register_policy` = %d, `poco` = '%s', `noscrape` = '%s', q("UPDATE `gserver` SET `url` = '%s', `version` = '%s', `site_name` = '%s', `info` = '%s', `register_policy` = %d, `poco` = '%s', `noscrape` = '%s',
`network` = '%s', `platform` = '%s', `last_contact` = '%s', `last_failure` = '%s' WHERE `nurl` = '%s'", `network` = '%s', `platform` = '%s', `last_contact` = '%s', `last_failure` = '%s' WHERE `nurl` = '%s'",

View file

@ -285,7 +285,7 @@ function paginate_data(&$a, $count=null) {
if (($a->page_offset != "") AND !preg_match('/[?&].offset=/', $stripped)) if (($a->page_offset != "") AND !preg_match('/[?&].offset=/', $stripped))
$stripped .= "&offset=".urlencode($a->page_offset); $stripped .= "&offset=".urlencode($a->page_offset);
$url = z_root() . '/' . $stripped; $url = $stripped;
$data = array(); $data = array();
function _l(&$d, $name, $url, $text, $class="") { function _l(&$d, $name, $url, $text, $class="") {
@ -923,7 +923,7 @@ function micropro($contact, $redirect = false, $class = '', $textmode = false) {
if($redirect) { if($redirect) {
$a = get_app(); $a = get_app();
$redirect_url = z_root() . '/redir/' . $contact['id']; $redirect_url = 'redir/' . $contact['id'];
if(local_user() && ($contact['uid'] == local_user()) && ($contact['network'] === NETWORK_DFRN)) { if(local_user() && ($contact['uid'] == local_user()) && ($contact['network'] === NETWORK_DFRN)) {
$redir = true; $redir = true;
$url = $redirect_url; $url = $redirect_url;
@ -964,13 +964,13 @@ if(! function_exists('search')) {
* @param string $url search url * @param string $url search url
* @param boolean $savedsearch show save search button * @param boolean $savedsearch show save search button
*/ */
function search($s,$id='search-box',$url='/search',$save = false, $aside = true) { function search($s,$id='search-box',$url='search',$save = false, $aside = true) {
$a = get_app(); $a = get_app();
$values = array( $values = array(
'$s' => $s, '$s' => $s,
'$id' => $id, '$id' => $id,
'$action_url' => $a->get_baseurl((stristr($url,'network')) ? true : false) . $url, '$action_url' => $url,
'$search_label' => t('Search'), '$search_label' => t('Search'),
'$save_label' => t('Save'), '$save_label' => t('Save'),
'$savedsearch' => feature_enabled(local_user(),'savedsearch'), '$savedsearch' => feature_enabled(local_user(),'savedsearch'),
@ -1148,41 +1148,41 @@ function smilies($s, $sample = false) {
); );
$icons = array( $icons = array(
'<img class="smiley" src="' . z_root() . '/images/smiley-heart.gif" alt="&lt;3" />', '<img class="smiley" src="' . z_root() . '/images/smiley-heart.gif" alt="&lt;3" title="&lt;3" />',
'<img class="smiley" src="' . z_root() . '/images/smiley-brokenheart.gif" alt="&lt;/3" />', '<img class="smiley" src="' . z_root() . '/images/smiley-brokenheart.gif" alt="&lt;/3" title="&lt;/3" />',
'<img class="smiley" src="' . z_root() . '/images/smiley-brokenheart.gif" alt="&lt;\\3" />', '<img class="smiley" src="' . z_root() . '/images/smiley-brokenheart.gif" alt="&lt;\\3" title="&lt;\\3" />',
'<img class="smiley" src="' . z_root() . '/images/smiley-smile.gif" alt=":-)" />', '<img class="smiley" src="' . z_root() . '/images/smiley-smile.gif" alt=":-)" title=":-)" />',
'<img class="smiley" src="' . z_root() . '/images/smiley-wink.gif" alt=";-)" />', '<img class="smiley" src="' . z_root() . '/images/smiley-wink.gif" alt=";-)" title=";-)" />',
'<img class="smiley" src="' . z_root() . '/images/smiley-frown.gif" alt=":-(" />', '<img class="smiley" src="' . z_root() . '/images/smiley-frown.gif" alt=":-(" title=":-(" />',
'<img class="smiley" src="' . z_root() . '/images/smiley-tongue-out.gif" alt=":-P" />', '<img class="smiley" src="' . z_root() . '/images/smiley-tongue-out.gif" alt=":-P" title=":-P" />',
'<img class="smiley" src="' . z_root() . '/images/smiley-tongue-out.gif" alt=":-p" />', '<img class="smiley" src="' . z_root() . '/images/smiley-tongue-out.gif" alt=":-p" title=":-P" />',
'<img class="smiley" src="' . z_root() . '/images/smiley-kiss.gif" alt=":-\"" />', '<img class="smiley" src="' . z_root() . '/images/smiley-kiss.gif" alt=":-\" title=":-\" />',
'<img class="smiley" src="' . z_root() . '/images/smiley-kiss.gif" alt=":-\"" />', '<img class="smiley" src="' . z_root() . '/images/smiley-kiss.gif" alt=":-\" title=":-\" />',
'<img class="smiley" src="' . z_root() . '/images/smiley-kiss.gif" alt=":-x" />', '<img class="smiley" src="' . z_root() . '/images/smiley-kiss.gif" alt=":-x" title=":-x" />',
'<img class="smiley" src="' . z_root() . '/images/smiley-kiss.gif" alt=":-X" />', '<img class="smiley" src="' . z_root() . '/images/smiley-kiss.gif" alt=":-X" title=":-X" />',
'<img class="smiley" src="' . z_root() . '/images/smiley-laughing.gif" alt=":-D" />', '<img class="smiley" src="' . z_root() . '/images/smiley-laughing.gif" alt=":-D" title=":-D" />',
'<img class="smiley" src="' . z_root() . '/images/smiley-surprised.gif" alt="8-|" />', '<img class="smiley" src="' . z_root() . '/images/smiley-surprised.gif" alt="8-|" title="8-|" />',
'<img class="smiley" src="' . z_root() . '/images/smiley-surprised.gif" alt="8-O" />', '<img class="smiley" src="' . z_root() . '/images/smiley-surprised.gif" alt="8-O" title="8-O" />',
'<img class="smiley" src="' . z_root() . '/images/smiley-surprised.gif" alt=":-O" />', '<img class="smiley" src="' . z_root() . '/images/smiley-surprised.gif" alt=":-O" title="8-O" />',
'<img class="smiley" src="' . z_root() . '/images/smiley-thumbsup.gif" alt="\\o/" />', '<img class="smiley" src="' . z_root() . '/images/smiley-thumbsup.gif" alt="\\o/" title="\\o/" />',
'<img class="smiley" src="' . z_root() . '/images/smiley-Oo.gif" alt="o.O" />', '<img class="smiley" src="' . z_root() . '/images/smiley-Oo.gif" alt="o.O" title="o.O" />',
'<img class="smiley" src="' . z_root() . '/images/smiley-Oo.gif" alt="O.o" />', '<img class="smiley" src="' . z_root() . '/images/smiley-Oo.gif" alt="O.o" title="O.o" />',
'<img class="smiley" src="' . z_root() . '/images/smiley-Oo.gif" alt="o_O" />', '<img class="smiley" src="' . z_root() . '/images/smiley-Oo.gif" alt="o_O" title="o_O" />',
'<img class="smiley" src="' . z_root() . '/images/smiley-Oo.gif" alt="O_o" />', '<img class="smiley" src="' . z_root() . '/images/smiley-Oo.gif" alt="O_o" title="O_o" />',
'<img class="smiley" src="' . z_root() . '/images/smiley-cry.gif" alt=":\'(" />', '<img class="smiley" src="' . z_root() . '/images/smiley-cry.gif" alt=":\'(" title=":\'("/>',
'<img class="smiley" src="' . z_root() . '/images/smiley-foot-in-mouth.gif" alt=":-!" />', '<img class="smiley" src="' . z_root() . '/images/smiley-foot-in-mouth.gif" alt=":-!" title=":-!" />',
'<img class="smiley" src="' . z_root() . '/images/smiley-undecided.gif" alt=":-/" />', '<img class="smiley" src="' . z_root() . '/images/smiley-undecided.gif" alt=":-/" title=":-/" />',
'<img class="smiley" src="' . z_root() . '/images/smiley-embarassed.gif" alt=":-[" />', '<img class="smiley" src="' . z_root() . '/images/smiley-embarassed.gif" alt=":-[" title=":-[" />',
'<img class="smiley" src="' . z_root() . '/images/smiley-cool.gif" alt="8-)" />', '<img class="smiley" src="' . z_root() . '/images/smiley-cool.gif" alt="8-)" title="8-)" />',
'<img class="smiley" src="' . z_root() . '/images/beer_mug.gif" alt=":beer" />', '<img class="smiley" src="' . z_root() . '/images/beer_mug.gif" alt=":beer" title=":beer" />',
'<img class="smiley" src="' . z_root() . '/images/beer_mug.gif" alt=":homebrew" />', '<img class="smiley" src="' . z_root() . '/images/beer_mug.gif" alt=":homebrew" title=":homebrew" />',
'<img class="smiley" src="' . z_root() . '/images/coffee.gif" alt=":coffee" />', '<img class="smiley" src="' . z_root() . '/images/coffee.gif" alt=":coffee" title=":coffee" />',
'<img class="smiley" src="' . z_root() . '/images/smiley-facepalm.gif" alt=":facepalm" />', '<img class="smiley" src="' . z_root() . '/images/smiley-facepalm.gif" alt=":facepalm" title=":facepalm" />',
'<img class="smiley" src="' . z_root() . '/images/like.gif" alt=":like" />', '<img class="smiley" src="' . z_root() . '/images/like.gif" alt=":like" title=":like" />',
'<img class="smiley" src="' . z_root() . '/images/dislike.gif" alt=":dislike" />', '<img class="smiley" src="' . z_root() . '/images/dislike.gif" alt=":dislike" title=":dislike" />',
'<a href="http://friendica.com">~friendica <img class="smiley" src="' . z_root() . '/images/friendica-16.png" alt="~friendica" /></a>', '<a href="http://friendica.com">~friendica <img class="smiley" src="' . z_root() . '/images/friendica-16.png" alt="~friendica" title="~friendica" /></a>',
'<a href="http://redmatrix.me/">red<img class="smiley" src="' . z_root() . '/images/rm-16.png" alt="red" />matrix</a>', '<a href="http://redmatrix.me/">red<img class="smiley" src="' . z_root() . '/images/rm-16.png" alt="red#" title="red#" />matrix</a>',
'<a href="http://redmatrix.me/">red<img class="smiley" src="' . z_root() . '/images/rm-16.png" alt="red" />matrix</a>' '<a href="http://redmatrix.me/">red<img class="smiley" src="' . z_root() . '/images/rm-16.png" alt="red#matrix" title="red#matrix" />matrix</a>'
); );
$params = array('texts' => $texts, 'icons' => $icons, 'string' => $s); $params = array('texts' => $texts, 'icons' => $icons, 'string' => $s);
@ -1305,7 +1305,7 @@ function redir_private_images($a, &$item) {
if((local_user() == $item['uid']) && ($item['private'] != 0) && ($item['contact-id'] != $a->contact['id']) && ($item['network'] == NETWORK_DFRN)) { if((local_user() == $item['uid']) && ($item['private'] != 0) && ($item['contact-id'] != $a->contact['id']) && ($item['network'] == NETWORK_DFRN)) {
//logger("redir_private_images: redir"); //logger("redir_private_images: redir");
$img_url = z_root() . '/redir?f=1&quiet=1&url=' . $mtch[1] . '&conurl=' . $item['author-link']; $img_url = 'redir?f=1&quiet=1&url=' . $mtch[1] . '&conurl=' . $item['author-link'];
$item['body'] = str_replace($mtch[0], "[img]".$img_url."[/img]", $item['body']); $item['body'] = str_replace($mtch[0], "[img]".$img_url."[/img]", $item['body']);
} }
} }
@ -1421,7 +1421,7 @@ function prepare_body(&$item,$attach = false, $preview = false) {
$mime = $mtch[3]; $mime = $mtch[3];
if((local_user() == $item['uid']) && ($item['contact-id'] != $a->contact['id']) && ($item['network'] == NETWORK_DFRN)) if((local_user() == $item['uid']) && ($item['contact-id'] != $a->contact['id']) && ($item['network'] == NETWORK_DFRN))
$the_url = z_root() . '/redir/' . $item['contact-id'] . '?f=1&url=' . $mtch[1]; $the_url = 'redir/' . $item['contact-id'] . '?f=1&url=' . $mtch[1];
else else
$the_url = $mtch[1]; $the_url = $mtch[1];
@ -1596,7 +1596,7 @@ function get_cats_and_terms($item) {
$categories[] = array( $categories[] = array(
'name' => xmlify(file_tag_decode($mtch[1])), 'name' => xmlify(file_tag_decode($mtch[1])),
'url' => "#", 'url' => "#",
'removeurl' => ((local_user() == $item['uid'])?z_root() . '/filerm/' . $item['id'] . '?f=&cat=' . xmlify(file_tag_decode($mtch[1])):""), 'removeurl' => ((local_user() == $item['uid'])?'filerm/' . $item['id'] . '?f=&cat=' . xmlify(file_tag_decode($mtch[1])):""),
'first' => $first, 'first' => $first,
'last' => false 'last' => false
); );
@ -1614,7 +1614,7 @@ function get_cats_and_terms($item) {
$folders[] = array( $folders[] = array(
'name' => xmlify(file_tag_decode($mtch[1])), 'name' => xmlify(file_tag_decode($mtch[1])),
'url' => "#", 'url' => "#",
'removeurl' => ((local_user() == $item['uid'])?z_root() . '/filerm/' . $item['id'] . '?f=&term=' . xmlify(file_tag_decode($mtch[1])):""), 'removeurl' => ((local_user() == $item['uid'])?'filerm/' . $item['id'] . '?f=&term=' . xmlify(file_tag_decode($mtch[1])):""),
'first' => $first, 'first' => $first,
'last' => false 'last' => false
); );
@ -1639,15 +1639,15 @@ function get_plink($item) {
if ($a->user['nickname'] != "") { if ($a->user['nickname'] != "") {
$ret = array( $ret = array(
//'href' => z_root()."/display/".$a->user['nickname']."/".$item['id'], //'href' => "display/".$a->user['nickname']."/".$item['id'],
'href' => z_root()."/display/".$item['guid'], 'href' => "display/".$item['guid'],
'orig' => z_root()."/display/".$item['guid'], 'orig' => "display/".$item['guid'],
'title' => t('View on separate page'), 'title' => t('View on separate page'),
'orig_title' => t('view on separate page'), 'orig_title' => t('view on separate page'),
); );
if (x($item,'plink')) { if (x($item,'plink')) {
$ret["href"] = $item['plink']; $ret["href"] = $a->remove_baseurl($item['plink']);
$ret["title"] = t('link to source'); $ret["title"] = t('link to source');
} }

View file

@ -16,7 +16,6 @@ function update_gcontact_run(&$argv, &$argc){
unset($db_host, $db_user, $db_pass, $db_data); unset($db_host, $db_user, $db_pass, $db_data);
}; };
require_once('include/pidfile.php');
require_once('include/Scrape.php'); require_once('include/Scrape.php');
require_once("include/socgraph.php"); require_once("include/socgraph.php");
@ -37,18 +36,10 @@ function update_gcontact_run(&$argv, &$argc){
return; return;
} }
$lockpath = get_lockpath(); // Don't check this stuff if the function is called by the poller
if ($lockpath != '') { if (App::callstack() != "poller_run")
$pidfile = new pidfile($lockpath, 'update_gcontact'.$contact_id); if (App::is_already_running('update_gcontact'.$contact_id, '', 540))
if ($pidfile->is_already_running()) { return;
logger("update_gcontact: Already running for contact ".$contact_id);
if ($pidfile->running_time() > 9*60) {
$pidfile->kill();
logger("killed stale process");
}
exit;
}
}
$r = q("SELECT * FROM `gcontact` WHERE `id` = %d", intval($contact_id)); $r = q("SELECT * FROM `gcontact` WHERE `id` = %d", intval($contact_id));

131
include/xml.php Normal file
View file

@ -0,0 +1,131 @@
<?php
/**
* @file include/xml.php
*/
/**
* @brief This class contain functions to work with XML data
*
*/
class xml {
/**
* @brief Creates an XML structure out of a given array
*
* @param array $array The array of the XML structure that will be generated
* @param object $xml The createdXML will be returned by reference
* @param bool $remove_header Should the XML header be removed or not?
* @param array $namespaces List of namespaces
* @param bool $root - interally used parameter. Mustn't be used from outside.
*
* @return string The created XML
*/
public static function from_array($array, &$xml, $remove_header = false, $namespaces = array(), $root = true) {
if ($root) {
foreach($array as $key => $value) {
foreach ($namespaces AS $nskey => $nsvalue)
$key .= " xmlns".($nskey == "" ? "":":").$nskey.'="'.$nsvalue.'"';
$root = new SimpleXMLElement("<".$key."/>");
self::from_array($value, $root, $remove_header, $namespaces, false);
$dom = dom_import_simplexml($root)->ownerDocument;
$dom->formatOutput = true;
$xml = $dom;
$xml_text = $dom->saveXML();
if ($remove_header)
$xml_text = trim(substr($xml_text, 21));
return $xml_text;
}
}
foreach($array as $key => $value) {
if ($key == "@attributes") {
if (!isset($element) OR !is_array($value))
continue;
foreach ($value as $attr_key => $attr_value) {
$element_parts = explode(":", $attr_key);
if ((count($element_parts) > 1) AND isset($namespaces[$element_parts[0]]))
$namespace = $namespaces[$element_parts[0]];
else
$namespace = NULL;
$element->addAttribute ($attr_key, $attr_value, $namespace);
}
continue;
}
$element_parts = explode(":", $key);
if ((count($element_parts) > 1) AND isset($namespaces[$element_parts[0]]))
$namespace = $namespaces[$element_parts[0]];
else
$namespace = NULL;
if (!is_array($value))
$element = $xml->addChild($key, xmlify($value), $namespace);
elseif (is_array($value)) {
$element = $xml->addChild($key, NULL, $namespace);
self::from_array($value, $element, $remove_header, $namespaces, false);
}
}
}
/**
* @brief Copies an XML object
*
* @param object $source The XML source
* @param object $target The XML target
* @param string $elementname Name of the XML element of the target
*/
public static function copy(&$source, &$target, $elementname) {
if (count($source->children()) == 0)
$target->addChild($elementname, xmlify($source));
else {
$child = $target->addChild($elementname);
foreach ($source->children() AS $childfield => $childentry)
self::copy($childentry, $child, $childfield);
}
}
/**
* @brief Create an XML element
*
* @param object $doc XML root
* @param string $element XML element name
* @param string $value XML value
* @param array $attributes array containing the attributes
*
* @return object XML element object
*/
public static function create_element($doc, $element, $value = "", $attributes = array()) {
$element = $doc->createElement($element, xmlify($value));
foreach ($attributes AS $key => $value) {
$attribute = $doc->createAttribute($key);
$attribute->value = xmlify($value);
$element->appendChild($attribute);
}
return $element;
}
/**
* @brief Create an XML and append it to the parent object
*
* @param object $doc XML root
* @param object $parent parent object
* @param string $element XML element name
* @param string $value XML value
* @param array $attributes array containing the attributes
*/
public static function add_element($doc, $parent, $element, $value = "", $attributes = array()) {
$element = self::create_element($doc, $element, $value, $attributes);
$parent->appendChild($element);
}
}
?>

View file

@ -72,7 +72,8 @@ if(!$install) {
(intval(get_config('system','ssl_policy')) == SSL_POLICY_FULL) AND (intval(get_config('system','ssl_policy')) == SSL_POLICY_FULL) AND
(substr($a->get_baseurl(), 0, 8) == "https://")) { (substr($a->get_baseurl(), 0, 8) == "https://")) {
header("HTTP/1.1 302 Moved Temporarily"); header("HTTP/1.1 302 Moved Temporarily");
header("location: ".$a->get_baseurl()."/".$a->query_string); header("Location: ".$a->get_baseurl()."/".$a->query_string);
exit();
} }
require_once("include/session.php"); require_once("include/session.php");
@ -371,7 +372,7 @@ $a->init_page_end();
if(x($_SESSION,'visitor_home')) if(x($_SESSION,'visitor_home'))
$homebase = $_SESSION['visitor_home']; $homebase = $_SESSION['visitor_home'];
elseif(local_user()) elseif(local_user())
$homebase = $a->get_baseurl() . '/profile/' . $a->user['nickname']; $homebase = 'profile/' . $a->user['nickname'];
if(isset($homebase)) if(isset($homebase))
$a->page['content'] .= '<script>var homebase="' . $homebase . '" ; </script>'; $a->page['content'] .= '<script>var homebase="' . $homebase . '" ; </script>';
@ -423,10 +424,10 @@ if($a->module != 'install' && $a->module != 'maintenance') {
if($a->is_mobile || $a->is_tablet) { if($a->is_mobile || $a->is_tablet) {
if(isset($_SESSION['show-mobile']) && !$_SESSION['show-mobile']) { if(isset($_SESSION['show-mobile']) && !$_SESSION['show-mobile']) {
$link = $a->get_baseurl() . '/toggle_mobile?address=' . curPageURL(); $link = 'toggle_mobile?address=' . curPageURL();
} }
else { else {
$link = $a->get_baseurl() . '/toggle_mobile?off=1&address=' . curPageURL(); $link = 'toggle_mobile?off=1&address=' . curPageURL();
} }
$a->page['footer'] = replace_macros(get_markup_template("toggle_mobile_footer.tpl"), array( $a->page['footer'] = replace_macros(get_markup_template("toggle_mobile_footer.tpl"), array(
'$toggle_link' => $link, '$toggle_link' => $link,

View file

@ -55,13 +55,13 @@ function admin_post(&$a){
$func($a); $func($a);
} }
} }
goaway($a->get_baseurl(true) . '/admin/plugins/' . $a->argv[2] ); goaway('admin/plugins/'.$a->argv[2]);
return; // NOTREACHED return; // NOTREACHED
break; break;
case 'themes': case 'themes':
if($a->argc < 2) { if($a->argc < 2) {
if(is_ajax()) return; if(is_ajax()) return;
goaway($a->get_baseurl(true) . '/admin/' ); goaway('admin/');
return; return;
} }
@ -92,7 +92,7 @@ function admin_post(&$a){
info(t('Theme settings updated.')); info(t('Theme settings updated.'));
if(is_ajax()) return; if(is_ajax()) return;
goaway($a->get_baseurl(true) . '/admin/themes/' . $theme ); goaway('admin/themes/'.$theme);
return; return;
break; break;
case 'features': case 'features':
@ -107,7 +107,7 @@ function admin_post(&$a){
} }
} }
goaway($a->get_baseurl(true) . '/admin' ); goaway('admin');
return; // NOTREACHED return; // NOTREACHED
} }
@ -150,17 +150,17 @@ function admin_content(&$a) {
* Side bar links * Side bar links
*/ */
$aside_tools = array(); $aside_tools = array();
// array( url, name, extra css classes ) // array(url, name, extra css classes)
// not part of $aside to make the template more adjustable // not part of $aside to make the template more adjustable
$aside_sub = array( $aside_sub = array(
'site' => array($a->get_baseurl(true)."/admin/site/", t("Site") , "site"), 'site' => array("admin/site/", t("Site") , "site"),
'users' => array($a->get_baseurl(true)."/admin/users/", t("Users") , "users"), 'users' => array("admin/users/", t("Users") , "users"),
'plugins'=> array($a->get_baseurl(true)."/admin/plugins/", t("Plugins") , "plugins"), 'plugins'=> array("admin/plugins/", t("Plugins") , "plugins"),
'themes' => array($a->get_baseurl(true)."/admin/themes/", t("Themes") , "themes"), 'themes' => array("admin/themes/", t("Themes") , "themes"),
'features' => array($a->get_baseurl(true)."/admin/features/", t("Additional features") , "features"), 'features' => array("admin/features/", t("Additional features") , "features"),
'dbsync' => array($a->get_baseurl(true)."/admin/dbsync/", t('DB updates'), "dbsync"), 'dbsync' => array("admin/dbsync/", t('DB updates'), "dbsync"),
'queue' => array($a->get_baseurl(true)."/admin/queue/", t('Inspect Queue'), "queue"), 'queue' => array("admin/queue/", t('Inspect Queue'), "queue"),
'federation' => array($a->get_baseurl(true)."/admin/federation/", t('Federation Statistics'), "federation"), 'federation' => array("admin/federation/", t('Federation Statistics'), "federation"),
); );
/* get plugins admin page */ /* get plugins admin page */
@ -169,18 +169,18 @@ function admin_content(&$a) {
$aside_tools['plugins_admin']=array(); $aside_tools['plugins_admin']=array();
foreach ($r as $h){ foreach ($r as $h){
$plugin =$h['name']; $plugin =$h['name'];
$aside_tools['plugins_admin'][] = array($a->get_baseurl(true)."/admin/plugins/".$plugin, $plugin, "plugin"); $aside_tools['plugins_admin'][] = array("admin/plugins/".$plugin, $plugin, "plugin");
// temp plugins with admin // temp plugins with admin
$a->plugins_admin[] = $plugin; $a->plugins_admin[] = $plugin;
} }
$aside_tools['logs'] = array($a->get_baseurl(true)."/admin/logs/", t("Logs"), "logs"); $aside_tools['logs'] = array("admin/logs/", t("Logs"), "logs");
$aside_tools['viewlogs'] = array($a->get_baseurl(true)."/admin/viewlogs/", t("View Logs"), 'viewlogs'); $aside_tools['viewlogs'] = array("admin/viewlogs/", t("View Logs"), 'viewlogs');
$aside_tools['diagnostics_probe'] = array($a->get_baseurl(true).'/probe/', t('probe address'), 'probe'); $aside_tools['diagnostics_probe'] = array('probe/', t('probe address'), 'probe');
$aside_tools['diagnostics_webfinger'] = array($a->get_baseurl(true).'/webfinger/', t('check webfinger'), 'webfinger'); $aside_tools['diagnostics_webfinger'] = array('webfinger/', t('check webfinger'), 'webfinger');
$t = get_markup_template("admin_aside.tpl"); $t = get_markup_template("admin_aside.tpl");
$a->page['aside'] .= replace_macros( $t, array( $a->page['aside'] .= replace_macros($t, array(
'$admin' => $aside_tools, '$admin' => $aside_tools,
'$subpages' => $aside_sub, '$subpages' => $aside_sub,
'$admtxt' => t('Admin'), '$admtxt' => t('Admin'),
@ -188,7 +188,7 @@ function admin_content(&$a) {
'$logtxt' => t('Logs'), '$logtxt' => t('Logs'),
'$diagnosticstxt' => t('diagnostics'), '$diagnosticstxt' => t('diagnostics'),
'$h_pending' => t('User registrations waiting for confirmation'), '$h_pending' => t('User registrations waiting for confirmation'),
'$admurl'=> $a->get_baseurl(true)."/admin/" '$admurl'=> "admin/"
)); ));
@ -231,7 +231,7 @@ function admin_content(&$a) {
$o = admin_page_federation($a); $o = admin_page_federation($a);
break; break;
default: default:
notice( t("Item not found.") ); notice(t("Item not found."));
} }
} else { } else {
$o = admin_page_summary($a); $o = admin_page_summary($a);
@ -270,6 +270,12 @@ function admin_page_federation(&$a) {
// Add more platforms if you like, when one returns 0 known nodes it is not // Add more platforms if you like, when one returns 0 known nodes it is not
// displayed on the stats page. // displayed on the stats page.
$platforms = array('Friendica', 'Diaspora', '%%red%%', 'Hubzilla', 'GNU Social', 'StatusNet'); $platforms = array('Friendica', 'Diaspora', '%%red%%', 'Hubzilla', 'GNU Social', 'StatusNet');
$colors = array('Friendica' => '#ffc018', // orange from the logo
'Diaspora' => '#a1a1a1', // logo is black and white, makes a gray
'%%red%%' => '#c50001', // fire red from the logo
'Hubzilla' => '#43488a', // blue from the logo
'GNU Social'=> '#a22430', // dark red from the logo
'StatusNet' => '#789240'); // the green from the logo (red and blue have already others
$counts = array(); $counts = array();
$total = 0; $total = 0;
@ -277,14 +283,14 @@ function admin_page_federation(&$a) {
// get a total count for the platform, the name and version of the // get a total count for the platform, the name and version of the
// highest version and the protocol tpe // highest version and the protocol tpe
$c = q('SELECT count(*) AS total, platform, network, version FROM gserver $c = q('SELECT count(*) AS total, platform, network, version FROM gserver
WHERE platform LIKE "%s" AND last_contact > last_failure WHERE platform LIKE "%s" AND last_contact > last_failure AND `version` != ""
ORDER BY version ASC;', $p); ORDER BY version ASC;', $p);
$total = $total + $c[0]['total']; $total = $total + $c[0]['total'];
// what versions for that platform do we know at all? // what versions for that platform do we know at all?
// again only the active nodes // again only the active nodes
$v = q('SELECT count(*) AS total, version FROM gserver $v = q('SELECT count(*) AS total, version FROM gserver
WHERE last_contact > last_failure AND platform LIKE "%s" WHERE last_contact > last_failure AND platform LIKE "%s" AND `version` != ""
GROUP BY version GROUP BY version
ORDER BY version;', $p); ORDER BY version;', $p);
@ -338,9 +344,12 @@ function admin_page_federation(&$a) {
$v = $newVv; $v = $newVv;
} }
foreach ($v as $key => $vv)
$v[$key]["version"] = trim(strip_tags($vv["version"]));
// the 3rd array item is needed for the JavaScript graphs as JS does // the 3rd array item is needed for the JavaScript graphs as JS does
// not like some characters in the names of variables... // not like some characters in the names of variables...
$counts[$p]=array($c[0], $v, str_replace(array(' ','%'),'',$p)); $counts[$p]=array($c[0], $v, str_replace(array(' ','%'),'',$p), $colors[$p]);
} }
// some helpful text // some helpful text
@ -409,18 +418,18 @@ function admin_page_queue(&$a) {
function admin_page_summary(&$a) { function admin_page_summary(&$a) {
$r = q("SELECT `page-flags`, COUNT(uid) as `count` FROM `user` GROUP BY `page-flags`"); $r = q("SELECT `page-flags`, COUNT(uid) as `count` FROM `user` GROUP BY `page-flags`");
$accounts = array( $accounts = array(
array( t('Normal Account'), 0), array(t('Normal Account'), 0),
array( t('Soapbox Account'), 0), array(t('Soapbox Account'), 0),
array( t('Community/Celebrity Account'), 0), array(t('Community/Celebrity Account'), 0),
array( t('Automatic Friend Account'), 0), array(t('Automatic Friend Account'), 0),
array( t('Blog Account'), 0), array(t('Blog Account'), 0),
array( t('Private Forum'), 0) array(t('Private Forum'), 0)
); );
$users=0; $users=0;
foreach ($r as $u){ $accounts[$u['page-flags']][1] = $u['count']; $users+= $u['count']; } foreach ($r as $u){ $accounts[$u['page-flags']][1] = $u['count']; $users+= $u['count']; }
logger('accounts: ' . print_r($accounts,true),LOGGER_DATA); logger('accounts: '.print_r($accounts,true),LOGGER_DATA);
$r = q("SELECT COUNT(id) as `count` FROM `register`"); $r = q("SELECT COUNT(id) as `count` FROM `register`");
$pending = $r[0]['count']; $pending = $r[0]['count'];
@ -433,7 +442,7 @@ function admin_page_summary(&$a) {
// We can do better, but this is a quick queue status // We can do better, but this is a quick queue status
$queues = array( 'label' => t('Message queues'), 'deliverq' => $deliverq, 'queue' => $queue ); $queues = array('label' => t('Message queues'), 'deliverq' => $deliverq, 'queue' => $queue);
$t = get_markup_template("admin_summary.tpl"); $t = get_markup_template("admin_summary.tpl");
@ -441,15 +450,15 @@ function admin_page_summary(&$a) {
'$title' => t('Administration'), '$title' => t('Administration'),
'$page' => t('Summary'), '$page' => t('Summary'),
'$queues' => $queues, '$queues' => $queues,
'$users' => array( t('Registered users'), $users), '$users' => array(t('Registered users'), $users),
'$accounts' => $accounts, '$accounts' => $accounts,
'$pending' => array( t('Pending registrations'), $pending), '$pending' => array(t('Pending registrations'), $pending),
'$version' => array( t('Version'), FRIENDICA_VERSION), '$version' => array(t('Version'), FRIENDICA_VERSION),
'$baseurl' => $a->get_baseurl(), '$baseurl' => $a->get_baseurl(),
'$platform' => FRIENDICA_PLATFORM, '$platform' => FRIENDICA_PLATFORM,
'$codename' => FRIENDICA_CODENAME, '$codename' => FRIENDICA_CODENAME,
'$build' => get_config('system','build'), '$build' => get_config('system','build'),
'$plugins' => array( t('Active plugins'), $a->plugins ) '$plugins' => array(t('Active plugins'), $a->plugins)
)); ));
} }
@ -473,7 +482,7 @@ function admin_page_site_post(&$a) {
$parsed = @parse_url($new_url); $parsed = @parse_url($new_url);
if(!$parsed || (!x($parsed,'host') || !x($parsed,'scheme'))) { if(!$parsed || (!x($parsed,'host') || !x($parsed,'scheme'))) {
notice(t("Can not parse base url. Must have at least <scheme>://<domain>")); notice(t("Can not parse base url. Must have at least <scheme>://<domain>"));
goaway($a->get_baseurl(true) . '/admin/site' ); goaway('admin/site');
} }
/* steps: /* steps:
@ -483,6 +492,10 @@ function admin_page_site_post(&$a) {
$old_url = $a->get_baseurl(true); $old_url = $a->get_baseurl(true);
// Generate host names for relocation the addresses in the format user@address.tld
$new_host = str_replace("http://", "@", normalise_link($new_url));
$old_host = str_replace("http://", "@", normalise_link($old_url));
function update_table($table_name, $fields, $old_url, $new_url) { function update_table($table_name, $fields, $old_url, $new_url) {
global $db, $a; global $db, $a;
@ -501,17 +514,22 @@ function admin_page_site_post(&$a) {
$q = sprintf("UPDATE %s SET %s;", $table_name, $upds); $q = sprintf("UPDATE %s SET %s;", $table_name, $upds);
$r = q($q); $r = q($q);
if(!$r) { if(!$r) {
notice( "Failed updating '$table_name': " . $db->error ); notice("Failed updating '$table_name': ".$db->error);
goaway($a->get_baseurl(true) . '/admin/site' ); goaway('admin/site');
} }
} }
// update tables // update tables
// update profile links in the format "http://server.tld"
update_table("profile", array('photo', 'thumb'), $old_url, $new_url); update_table("profile", array('photo', 'thumb'), $old_url, $new_url);
update_table("term", array('url'), $old_url, $new_url); update_table("term", array('url'), $old_url, $new_url);
update_table("contact", array('photo','thumb','micro','url','nurl','request','notify','poll','confirm','poco'), $old_url, $new_url); update_table("contact", array('photo','thumb','micro','url','nurl','alias','request','notify','poll','confirm','poco', 'avatar'), $old_url, $new_url);
update_table("gcontact", array('photo','url','nurl','server_url'), $old_url, $new_url); update_table("gcontact", array('url','nurl','photo','server_url','notify','alias'), $old_url, $new_url);
update_table("item", array('owner-link','owner-avatar','author-name','author-link','author-avatar','body','plink','tag'), $old_url, $new_url); update_table("item", array('owner-link','owner-avatar','author-link','author-avatar','body','plink','tag'), $old_url, $new_url);
// update profile addresses in the format "user@server.tld"
update_table("contact", array('addr'), $old_host, $new_host);
update_table("gcontact", array('connect','addr'), $old_host, $new_host);
// update config // update config
$a->set_baseurl($new_url); $a->set_baseurl($new_url);
@ -526,7 +544,7 @@ function admin_page_site_post(&$a) {
info("Relocation started. Could take a while to complete."); info("Relocation started. Could take a while to complete.");
goaway($a->get_baseurl(true) . '/admin/site' ); goaway('admin/site');
} }
// end relocate // end relocate
@ -589,6 +607,7 @@ function admin_page_site_post(&$a) {
$dfrn_only = ((x($_POST,'dfrn_only')) ? True : False); $dfrn_only = ((x($_POST,'dfrn_only')) ? True : False);
$ostatus_disabled = !((x($_POST,'ostatus_disabled')) ? True : False); $ostatus_disabled = !((x($_POST,'ostatus_disabled')) ? True : False);
$ostatus_poll_interval = ((x($_POST,'ostatus_poll_interval')) ? intval(trim($_POST['ostatus_poll_interval'])) : 0); $ostatus_poll_interval = ((x($_POST,'ostatus_poll_interval')) ? intval(trim($_POST['ostatus_poll_interval'])) : 0);
$ostatus_full_threads = ((x($_POST,'ostatus_full_threads')) ? True : False);
$diaspora_enabled = ((x($_POST,'diaspora_enabled')) ? True : False); $diaspora_enabled = ((x($_POST,'diaspora_enabled')) ? True : False);
$ssl_policy = ((x($_POST,'ssl_policy')) ? intval($_POST['ssl_policy']) : 0); $ssl_policy = ((x($_POST,'ssl_policy')) ? intval($_POST['ssl_policy']) : 0);
$force_ssl = ((x($_POST,'force_ssl')) ? True : False); $force_ssl = ((x($_POST,'force_ssl')) ? True : False);
@ -609,6 +628,9 @@ function admin_page_site_post(&$a) {
$only_tag_search = ((x($_POST,'only_tag_search')) ? True : False); $only_tag_search = ((x($_POST,'only_tag_search')) ? True : False);
$rino = ((x($_POST,'rino')) ? intval($_POST['rino']) : 0); $rino = ((x($_POST,'rino')) ? intval($_POST['rino']) : 0);
$embedly = ((x($_POST,'embedly')) ? notags(trim($_POST['embedly'])) : ''); $embedly = ((x($_POST,'embedly')) ? notags(trim($_POST['embedly'])) : '');
$worker = ((x($_POST,'worker')) ? True : False);
$worker_queues = ((x($_POST,'worker_queues')) ? intval($_POST['worker_queues']) : 4);
$worker_dont_fork = ((x($_POST,'worker_dont_fork')) ? True : False);
if($a->get_path() != "") if($a->get_path() != "")
$diaspora_enabled = false; $diaspora_enabled = false;
@ -695,12 +717,12 @@ function admin_page_site_post(&$a) {
set_config('system','language', $language); set_config('system','language', $language);
set_config('system','theme', $theme); set_config('system','theme', $theme);
if( $theme_mobile === '---' ) { if($theme_mobile === '---') {
del_config('system','mobile-theme'); del_config('system','mobile-theme');
} else { } else {
set_config('system','mobile-theme', $theme_mobile); set_config('system','mobile-theme', $theme_mobile);
} }
if( $singleuser === '---' ) { if($singleuser === '---') {
del_config('system','singleuser'); del_config('system','singleuser');
} else { } else {
set_config('system','singleuser', $singleuser); set_config('system','singleuser', $singleuser);
@ -737,6 +759,7 @@ function admin_page_site_post(&$a) {
set_config('system','dfrn_only', $dfrn_only); set_config('system','dfrn_only', $dfrn_only);
set_config('system','ostatus_disabled', $ostatus_disabled); set_config('system','ostatus_disabled', $ostatus_disabled);
set_config('system','ostatus_poll_interval', $ostatus_poll_interval); set_config('system','ostatus_poll_interval', $ostatus_poll_interval);
set_config('system','ostatus_full_threads', $ostatus_full_threads);
set_config('system','diaspora_enabled', $diaspora_enabled); set_config('system','diaspora_enabled', $diaspora_enabled);
set_config('config','private_addons', $private_addons); set_config('config','private_addons', $private_addons);
@ -754,7 +777,9 @@ function admin_page_site_post(&$a) {
set_config('system','proxy_disabled', $proxy_disabled); set_config('system','proxy_disabled', $proxy_disabled);
set_config('system','old_pager', $old_pager); set_config('system','old_pager', $old_pager);
set_config('system','only_tag_search', $only_tag_search); set_config('system','only_tag_search', $only_tag_search);
set_config('system','worker', $worker);
set_config('system','worker_queues', $worker_queues);
set_config('system','worker_dont_fork', $worker_dont_fork);
if($rino==2 and !function_exists('mcrypt_create_iv')) { if($rino==2 and !function_exists('mcrypt_create_iv')) {
notice(t("RINO2 needs mcrypt php extension to work.")); notice(t("RINO2 needs mcrypt php extension to work."));
@ -765,8 +790,8 @@ function admin_page_site_post(&$a) {
set_config('system','embedly', $embedly); set_config('system','embedly', $embedly);
info( t('Site settings updated.') . EOL); info(t('Site settings updated.').EOL);
goaway($a->get_baseurl(true) . '/admin/site' ); goaway('admin/site');
return; // NOTREACHED return; // NOTREACHED
} }
@ -797,12 +822,12 @@ function admin_page_site(&$a) {
$files = glob('view/theme/*'); $files = glob('view/theme/*');
if($files) { if($files) {
foreach($files as $file) { foreach($files as $file) {
if(intval(file_exists($file . '/unsupported'))) if(intval(file_exists($file.'/unsupported')))
continue; continue;
$f = basename($file); $f = basename($file);
$theme_name = ((file_exists($file . '/experimental')) ? sprintf("%s - \x28Experimental\x29", $f) : $f); $theme_name = ((file_exists($file.'/experimental')) ? sprintf("%s - \x28Experimental\x29", $f) : $f);
if(file_exists($file . '/mobile')) { if(file_exists($file.'/mobile')) {
$theme_choices_mobile[$f] = $theme_name; $theme_choices_mobile[$f] = $theme_name;
} else { } else {
$theme_choices[$f] = $theme_name; $theme_choices[$f] = $theme_name;
@ -893,6 +918,7 @@ function admin_page_site(&$a) {
'$advanced' => t('Advanced'), '$advanced' => t('Advanced'),
'$portable_contacts' => t('Auto Discovered Contact Directory'), '$portable_contacts' => t('Auto Discovered Contact Directory'),
'$performance' => t('Performance'), '$performance' => t('Performance'),
'$worker_title' => t('Worker'),
'$relocate'=> t('Relocate - WARNING: advanced function. Could make this server unreachable.'), '$relocate'=> t('Relocate - WARNING: advanced function. Could make this server unreachable.'),
'$baseurl' => $a->get_baseurl(true), '$baseurl' => $a->get_baseurl(true),
// name, label, value, help string, extra data... // name, label, value, help string, extra data...
@ -938,6 +964,7 @@ function admin_page_site(&$a) {
'$max_author_posts_community_page' => array('max_author_posts_community_page', t("Posts per user on community page"), get_config('system','max_author_posts_community_page'), t("The maximum number of posts per user on the community page. (Not valid for 'Global Community')")), '$max_author_posts_community_page' => array('max_author_posts_community_page', t("Posts per user on community page"), get_config('system','max_author_posts_community_page'), t("The maximum number of posts per user on the community page. (Not valid for 'Global Community')")),
'$ostatus_disabled' => array('ostatus_disabled', t("Enable OStatus support"), !get_config('system','ostatus_disabled'), t("Provide built-in OStatus \x28StatusNet, GNU Social etc.\x29 compatibility. All communications in OStatus are public, so privacy warnings will be occasionally displayed.")), '$ostatus_disabled' => array('ostatus_disabled', t("Enable OStatus support"), !get_config('system','ostatus_disabled'), t("Provide built-in OStatus \x28StatusNet, GNU Social etc.\x29 compatibility. All communications in OStatus are public, so privacy warnings will be occasionally displayed.")),
'$ostatus_poll_interval' => array('ostatus_poll_interval', t("OStatus conversation completion interval"), (string) intval(get_config('system','ostatus_poll_interval')), t("How often shall the poller check for new entries in OStatus conversations? This can be a very ressource task."), $ostatus_poll_choices), '$ostatus_poll_interval' => array('ostatus_poll_interval', t("OStatus conversation completion interval"), (string) intval(get_config('system','ostatus_poll_interval')), t("How often shall the poller check for new entries in OStatus conversations? This can be a very ressource task."), $ostatus_poll_choices),
'$ostatus_full_threads' => array('ostatus_full_threads', t("Only import OStatus threads from our contacts"), get_config('system','ostatus_full_threads'), t("Normally we import every content from our OStatus contacts. With this option we only store threads that are started by a contact that is known on our system.")),
'$ostatus_not_able' => t("OStatus support can only be enabled if threading is enabled."), '$ostatus_not_able' => t("OStatus support can only be enabled if threading is enabled."),
'$diaspora_able' => $diaspora_able, '$diaspora_able' => $diaspora_able,
'$diaspora_not_able' => t("Diaspora support can't be enabled because Friendica was installed into a sub directory."), '$diaspora_not_able' => t("Diaspora support can't be enabled because Friendica was installed into a sub directory."),
@ -980,6 +1007,10 @@ function admin_page_site(&$a) {
'$rino' => array('rino', t("RINO Encryption"), intval(get_config('system','rino_encrypt')), t("Encryption layer between nodes."), array("Disabled", "RINO1 (deprecated)", "RINO2")), '$rino' => array('rino', t("RINO Encryption"), intval(get_config('system','rino_encrypt')), t("Encryption layer between nodes."), array("Disabled", "RINO1 (deprecated)", "RINO2")),
'$embedly' => array('embedly', t("Embedly API key"), get_config('system','embedly'), t("<a href='http://embed.ly'>Embedly</a> is used to fetch additional data for web pages. This is an optional parameter.")), '$embedly' => array('embedly', t("Embedly API key"), get_config('system','embedly'), t("<a href='http://embed.ly'>Embedly</a> is used to fetch additional data for web pages. This is an optional parameter.")),
'$worker' => array('worker', t("Enable 'worker' background processing"), get_config('system','worker'), t("The worker background processing limits the number of parallel background jobs to a maximum number and respects the system load.")),
'$worker_queues' => array('worker_queues', t("Maximum number of parallel workers"), get_config('system','worker_queues'), t("On shared hosters set this to 2. On larger systems, values of 10 are great. Default value is 4.")),
'$worker_dont_fork' => array('worker_dont_fork', t("Don't use 'proc_open' with the worker"), get_config('system','worker_dont_fork'), t("Enable this if your system doesn't allow the use of 'proc_open'. This can happen on shared hosters. If this is enabled you should increase the frequency of poller calls in your crontab.")),
'$form_security_token' => get_form_security_token("admin_site") '$form_security_token' => get_form_security_token("admin_site")
)); ));
@ -1003,12 +1034,12 @@ function admin_page_dbsync(&$a) {
$o = ''; $o = '';
if($a->argc > 3 && intval($a->argv[3]) && $a->argv[2] === 'mark') { if($a->argc > 3 && intval($a->argv[3]) && $a->argv[2] === 'mark') {
set_config('database', 'update_' . intval($a->argv[3]), 'success'); set_config('database', 'update_'.intval($a->argv[3]), 'success');
$curr = get_config('system','build'); $curr = get_config('system','build');
if(intval($curr) == intval($a->argv[3])) if(intval($curr) == intval($a->argv[3]))
set_config('system','build',intval($curr) + 1); set_config('system','build',intval($curr) + 1);
info( t('Update has been marked successful') . EOL); info(t('Update has been marked successful').EOL);
goaway($a->get_baseurl(true) . '/admin/dbsync'); goaway('admin/dbsync');
} }
if(($a->argc > 2) AND (intval($a->argv[2]) OR ($a->argv[2] === 'check'))) { if(($a->argc > 2) AND (intval($a->argv[2]) OR ($a->argv[2] === 'check'))) {
@ -1026,7 +1057,7 @@ function admin_page_dbsync(&$a) {
if($a->argc > 2 && intval($a->argv[2])) { if($a->argc > 2 && intval($a->argv[2])) {
require_once('update.php'); require_once('update.php');
$func = 'update_' . intval($a->argv[2]); $func = 'update_'.intval($a->argv[2]);
if(function_exists($func)) { if(function_exists($func)) {
$retval = $func(); $retval = $func();
if($retval === UPDATE_FAILED) { if($retval === UPDATE_FAILED) {
@ -1082,18 +1113,18 @@ function admin_page_dbsync(&$a) {
* @param App $a * @param App $a
*/ */
function admin_page_users_post(&$a){ function admin_page_users_post(&$a){
$pending = ( x($_POST, 'pending') ? $_POST['pending'] : array() ); $pending = (x($_POST, 'pending') ? $_POST['pending'] : array());
$users = ( x($_POST, 'user') ? $_POST['user'] : array() ); $users = (x($_POST, 'user') ? $_POST['user'] : array());
$nu_name = ( x($_POST, 'new_user_name') ? $_POST['new_user_name'] : ''); $nu_name = (x($_POST, 'new_user_name') ? $_POST['new_user_name'] : '');
$nu_nickname = ( x($_POST, 'new_user_nickname') ? $_POST['new_user_nickname'] : ''); $nu_nickname = (x($_POST, 'new_user_nickname') ? $_POST['new_user_nickname'] : '');
$nu_email = ( x($_POST, 'new_user_email') ? $_POST['new_user_email'] : ''); $nu_email = (x($_POST, 'new_user_email') ? $_POST['new_user_email'] : '');
check_form_security_token_redirectOnErr('/admin/users', 'admin_users'); check_form_security_token_redirectOnErr('/admin/users', 'admin_users');
if(!($nu_name==="") && !($nu_email==="") && !($nu_nickname==="")) { if(!($nu_name==="") && !($nu_email==="") && !($nu_nickname==="")) {
require_once('include/user.php'); require_once('include/user.php');
$result = create_user( array('username'=>$nu_name, 'email'=>$nu_email, 'nickname'=>$nu_nickname, 'verified'=>1) ); $result = create_user(array('username'=>$nu_name, 'email'=>$nu_email, 'nickname'=>$nu_nickname, 'verified'=>1));
if(! $result['success']) { if(! $result['success']) {
notice($result['message']); notice($result['message']);
return; return;
@ -1134,7 +1165,7 @@ function admin_page_users_post(&$a){
notification(array( notification(array(
'type' => "SYSTEM_EMAIL", 'type' => "SYSTEM_EMAIL",
'to_email' => $nu['email'], 'to_email' => $nu['email'],
'subject'=> sprintf( t('Registration details for %s'), $a->config['sitename']), 'subject'=> sprintf(t('Registration details for %s'), $a->config['sitename']),
'preamble'=> $preamble, 'preamble'=> $preamble,
'body' => $body)); 'body' => $body));
@ -1143,17 +1174,17 @@ function admin_page_users_post(&$a){
if(x($_POST,'page_users_block')) { if(x($_POST,'page_users_block')) {
foreach($users as $uid){ foreach($users as $uid){
q("UPDATE `user` SET `blocked`=1-`blocked` WHERE `uid`=%s", q("UPDATE `user` SET `blocked`=1-`blocked` WHERE `uid`=%s",
intval( $uid ) intval($uid)
); );
} }
notice( sprintf( tt("%s user blocked/unblocked", "%s users blocked/unblocked", count($users)), count($users)) ); notice(sprintf(tt("%s user blocked/unblocked", "%s users blocked/unblocked", count($users)), count($users)));
} }
if(x($_POST,'page_users_delete')) { if(x($_POST,'page_users_delete')) {
require_once("include/Contact.php"); require_once("include/Contact.php");
foreach($users as $uid){ foreach($users as $uid){
user_remove($uid); user_remove($uid);
} }
notice( sprintf( tt("%s user deleted", "%s users deleted", count($users)), count($users)) ); notice(sprintf(tt("%s user deleted", "%s users deleted", count($users)), count($users)));
} }
if(x($_POST,'page_users_approve')) { if(x($_POST,'page_users_approve')) {
@ -1168,7 +1199,7 @@ function admin_page_users_post(&$a){
user_deny($hash); user_deny($hash);
} }
} }
goaway($a->get_baseurl(true) . '/admin/users' ); goaway('admin/users');
return; // NOTREACHED return; // NOTREACHED
} }
@ -1189,8 +1220,8 @@ function admin_page_users(&$a){
$uid = $a->argv[3]; $uid = $a->argv[3];
$user = q("SELECT username, blocked FROM `user` WHERE `uid`=%d", intval($uid)); $user = q("SELECT username, blocked FROM `user` WHERE `uid`=%d", intval($uid));
if(count($user)==0) { if(count($user)==0) {
notice( 'User not found' . EOL); notice('User not found'.EOL);
goaway($a->get_baseurl(true) . '/admin/users' ); goaway('admin/users');
return ''; // NOTREACHED return ''; // NOTREACHED
} }
switch($a->argv[2]){ switch($a->argv[2]){
@ -1200,18 +1231,18 @@ function admin_page_users(&$a){
require_once("include/Contact.php"); require_once("include/Contact.php");
user_remove($uid); user_remove($uid);
notice( sprintf(t("User '%s' deleted"), $user[0]['username']) . EOL); notice(sprintf(t("User '%s' deleted"), $user[0]['username']).EOL);
}; break; }; break;
case "block":{ case "block":{
check_form_security_token_redirectOnErr('/admin/users', 'admin_users', 't'); check_form_security_token_redirectOnErr('/admin/users', 'admin_users', 't');
q("UPDATE `user` SET `blocked`=%d WHERE `uid`=%s", q("UPDATE `user` SET `blocked`=%d WHERE `uid`=%s",
intval( 1-$user[0]['blocked'] ), intval(1-$user[0]['blocked']),
intval( $uid ) intval($uid)
); );
notice( sprintf( ($user[0]['blocked']?t("User '%s' unblocked"):t("User '%s' blocked")) , $user[0]['username']) . EOL); notice(sprintf(($user[0]['blocked']?t("User '%s' unblocked"):t("User '%s' blocked")) , $user[0]['username']).EOL);
}; break; }; break;
} }
goaway($a->get_baseurl(true) . '/admin/users' ); goaway('admin/users');
return ''; // NOTREACHED return ''; // NOTREACHED
} }
@ -1230,7 +1261,7 @@ function admin_page_users(&$a){
$a->set_pager_itemspage(100); $a->set_pager_itemspage(100);
} }
$users = q("SELECT `user` . * , `contact`.`name` , `contact`.`url` , `contact`.`micro`, `lastitem`.`lastitem_date`, `user`.`account_expired` $users = q("SELECT `user`.* , `contact`.`name` , `contact`.`url` , `contact`.`micro`, `lastitem`.`lastitem_date`, `user`.`account_expired`
FROM FROM
(SELECT MAX(`item`.`changed`) as `lastitem_date`, `item`.`uid` (SELECT MAX(`item`.`changed`) as `lastitem_date`, `item`.`uid`
FROM `item` FROM `item`
@ -1277,7 +1308,7 @@ function admin_page_users(&$a){
while(count($users)) { while(count($users)) {
$new_user = array(); $new_user = array();
foreach( array_pop($users) as $k => $v) { foreach(array_pop($users) as $k => $v) {
$k = str_replace('-','_',$k); $k = str_replace('-','_',$k);
$new_user[$k] = $v; $new_user[$k] = $v;
} }
@ -1303,7 +1334,7 @@ function admin_page_users(&$a){
'$select_all' => t('select all'), '$select_all' => t('select all'),
'$h_pending' => t('User registrations waiting for confirm'), '$h_pending' => t('User registrations waiting for confirm'),
'$h_deleted' => t('User waiting for permanent deletion'), '$h_deleted' => t('User waiting for permanent deletion'),
'$th_pending' => array( t('Request date'), t('Name'), t('Email') ), '$th_pending' => array(t('Request date'), t('Name'), t('Email')),
'$no_pending' => t('No registrations.'), '$no_pending' => t('No registrations.'),
'$approve' => t('Approve'), '$approve' => t('Approve'),
'$deny' => t('Deny'), '$deny' => t('Deny'),
@ -1315,8 +1346,8 @@ function admin_page_users(&$a){
'$h_users' => t('Users'), '$h_users' => t('Users'),
'$h_newuser' => t('New User'), '$h_newuser' => t('New User'),
'$th_deleted' => array( t('Name'), t('Email'), t('Register date'), t('Last login'), t('Last item'), t('Deleted since') ), '$th_deleted' => array(t('Name'), t('Email'), t('Register date'), t('Last login'), t('Last item'), t('Deleted since')),
'$th_users' => array( t('Name'), t('Email'), t('Register date'), t('Last login'), t('Last item'), t('Account') ), '$th_users' => array(t('Name'), t('Email'), t('Register date'), t('Last login'), t('Last item'), t('Account')),
'$confirm_delete_multi' => t('Selected users will be deleted!\n\nEverything these users had posted on this site will be permanently deleted!\n\nAre you sure?'), '$confirm_delete_multi' => t('Selected users will be deleted!\n\nEverything these users had posted on this site will be permanently deleted!\n\nAre you sure?'),
'$confirm_delete' => t('The user {0} will be deleted!\n\nEverything this user has posted on this site will be permanently deleted!\n\nAre you sure?'), '$confirm_delete' => t('The user {0} will be deleted!\n\nEverything this user has posted on this site will be permanently deleted!\n\nAre you sure?'),
@ -1362,7 +1393,7 @@ function admin_page_plugins(&$a){
if($a->argc == 3) { if($a->argc == 3) {
$plugin = $a->argv[2]; $plugin = $a->argv[2];
if(!is_file("addon/$plugin/$plugin.php")) { if(!is_file("addon/$plugin/$plugin.php")) {
notice( t("Item not found.") ); notice(t("Item not found."));
return ''; return '';
} }
@ -1374,14 +1405,14 @@ function admin_page_plugins(&$a){
if($idx !== false) { if($idx !== false) {
unset($a->plugins[$idx]); unset($a->plugins[$idx]);
uninstall_plugin($plugin); uninstall_plugin($plugin);
info( sprintf( t("Plugin %s disabled."), $plugin ) ); info(sprintf(t("Plugin %s disabled."), $plugin));
} else { } else {
$a->plugins[] = $plugin; $a->plugins[] = $plugin;
install_plugin($plugin); install_plugin($plugin);
info( sprintf( t("Plugin %s enabled."), $plugin ) ); info(sprintf(t("Plugin %s enabled."), $plugin));
} }
set_config("system","addon", implode(", ",$a->plugins)); set_config("system","addon", implode(", ",$a->plugins));
goaway($a->get_baseurl(true) . '/admin/plugins' ); goaway('admin/plugins');
return ''; // NOTREACHED return ''; // NOTREACHED
} }
@ -1480,7 +1511,7 @@ function admin_page_plugins(&$a){
'$function' => 'plugins', '$function' => 'plugins',
'$plugins' => $plugins, '$plugins' => $plugins,
'$pcount' => count($plugins), '$pcount' => count($plugins),
'$noplugshint' => sprintf( t('There are currently no plugins available on your node. You can find the official plugin repository at %1$s and might find other interesting plugins in the open plugin registry at %2$s'), 'https://github.com/friendica/friendica-addons', 'http://addons.friendi.ca'), '$noplugshint' => sprintf(t('There are currently no plugins available on your node. You can find the official plugin repository at %1$s and might find other interesting plugins in the open plugin registry at %2$s'), 'https://github.com/friendica/friendica-addons', 'http://addons.friendi.ca'),
'$form_security_token' => get_form_security_token("admin_themes"), '$form_security_token' => get_form_security_token("admin_themes"),
)); ));
} }
@ -1575,8 +1606,8 @@ function admin_page_themes(&$a){
if($files) { if($files) {
foreach($files as $file) { foreach($files as $file) {
$f = basename($file); $f = basename($file);
$is_experimental = intval(file_exists($file . '/experimental')); $is_experimental = intval(file_exists($file.'/experimental'));
$is_supported = 1-(intval(file_exists($file . '/unsupported'))); $is_supported = 1-(intval(file_exists($file.'/unsupported')));
$is_allowed = intval(in_array($f,$allowed_themes)); $is_allowed = intval(in_array($f,$allowed_themes));
if($is_allowed OR $is_supported OR get_config("system", "show_unsupported_themes")) if($is_allowed OR $is_supported OR get_config("system", "show_unsupported_themes"))
@ -1585,7 +1616,7 @@ function admin_page_themes(&$a){
} }
if(! count($themes)) { if(! count($themes)) {
notice( t('No themes found.')); notice(t('No themes found.'));
return ''; return '';
} }
@ -1596,7 +1627,7 @@ function admin_page_themes(&$a){
if($a->argc == 3) { if($a->argc == 3) {
$theme = $a->argv[2]; $theme = $a->argv[2];
if(! is_dir("view/theme/$theme")) { if(! is_dir("view/theme/$theme")) {
notice( t("Item not found.") ); notice(t("Item not found."));
return ''; return '';
} }
@ -1609,15 +1640,15 @@ function admin_page_themes(&$a){
$s = rebuild_theme_table($themes); $s = rebuild_theme_table($themes);
if($result) { if($result) {
install_theme($theme); install_theme($theme);
info( sprintf('Theme %s enabled.',$theme)); info(sprintf('Theme %s enabled.',$theme));
} }
else { else {
uninstall_theme($theme); uninstall_theme($theme);
info( sprintf('Theme %s disabled.',$theme)); info(sprintf('Theme %s disabled.',$theme));
} }
set_config('system','allowed_themes',$s); set_config('system','allowed_themes',$s);
goaway($a->get_baseurl(true) . '/admin/themes' ); goaway('admin/themes');
return ''; // NOTREACHED return ''; // NOTREACHED
} }
@ -1663,7 +1694,7 @@ function admin_page_themes(&$a){
$admin_form = __get_theme_admin_form($a, $theme); $admin_form = __get_theme_admin_form($a, $theme);
} }
$screenshot = array( get_theme_screenshot($theme), t('Screenshot')); $screenshot = array(get_theme_screenshot($theme), t('Screenshot'));
if(! stristr($screenshot[0],$theme)) if(! stristr($screenshot[0],$theme))
$screenshot = null; $screenshot = null;
@ -1754,8 +1785,8 @@ function admin_page_logs_post(&$a) {
set_config('system','loglevel', $loglevel); set_config('system','loglevel', $loglevel);
} }
info( t("Log settings updated.") ); info(t("Log settings updated."));
goaway($a->get_baseurl(true) . '/admin/logs' ); goaway('admin/logs');
return; // NOTREACHED return; // NOTREACHED
} }
@ -1803,7 +1834,7 @@ function admin_page_logs(&$a){
'$form_security_token' => get_form_security_token("admin_logs"), '$form_security_token' => get_form_security_token("admin_logs"),
'$phpheader' => t("PHP logging"), '$phpheader' => t("PHP logging"),
'$phphint' => t("To enable logging of PHP errors and warnings you can add the following to the .htconfig.php file of your installation. The filename set in the 'error_log' line is relative to the friendica top-level directory and must be writeable by the web server. The option '1' for 'log_errors' and 'display_errors' is to enable these options, set to '0' to disable them."), '$phphint' => t("To enable logging of PHP errors and warnings you can add the following to the .htconfig.php file of your installation. The filename set in the 'error_log' line is relative to the friendica top-level directory and must be writeable by the web server. The option '1' for 'log_errors' and 'display_errors' is to enable these options, set to '0' to disable them."),
'$phplogcode' => "error_reporting(E_ERROR | E_WARNING | E_PARSE );\nini_set('error_log','php.out');\nini_set('log_errors','1');\nini_set('display_errors', '1');", '$phplogcode' => "error_reporting(E_ERROR | E_WARNING | E_PARSE);\nini_set('error_log','php.out');\nini_set('log_errors','1');\nini_set('display_errors', '1');",
)); ));
} }
@ -1871,7 +1902,7 @@ function admin_page_features_post(&$a) {
check_form_security_token_redirectOnErr('/admin/features', 'admin_manage_features'); check_form_security_token_redirectOnErr('/admin/features', 'admin_manage_features');
logger('postvars: ' . print_r($_POST,true),LOGGER_DATA); logger('postvars: '.print_r($_POST,true),LOGGER_DATA);
$arr = array(); $arr = array();
$features = get_features(false); $features = get_features(false);
@ -1879,11 +1910,11 @@ function admin_page_features_post(&$a) {
foreach($features as $fname => $fdata) { foreach($features as $fname => $fdata) {
foreach(array_slice($fdata,1) as $f) { foreach(array_slice($fdata,1) as $f) {
$feature = $f[0]; $feature = $f[0];
$feature_state = 'feature_' . $feature; $feature_state = 'feature_'.$feature;
$featurelock = 'featurelock_' . $feature; $featurelock = 'featurelock_'.$feature;
if(x($_POST[$feature_state])) if(x($_POST[$feature_state]))
$val = intval($_POST['feature_' . $feature]); $val = intval($_POST['feature_'.$feature]);
else else
$val = 0; $val = 0;
set_config('feature',$feature,$val); set_config('feature',$feature,$val);
@ -1895,7 +1926,7 @@ function admin_page_features_post(&$a) {
} }
} }
goaway($a->get_baseurl(true) . '/admin/features' ); goaway('admin/features');
return; // NOTREACHED return; // NOTREACHED
} }
@ -1929,7 +1960,7 @@ function admin_page_features(&$a) {
$set = $f[3]; $set = $f[3];
$arr[$fname][1][] = array( $arr[$fname][1][] = array(
array('feature_' .$f[0],$f[1],$set,$f[2],array(t('Off'),t('On'))), array('feature_' .$f[0],$f[1],$set,$f[2],array(t('Off'),t('On'))),
array('featurelock_' .$f[0],sprintf( t('Lock feature %s'),$f[1]),(($f[4] !== false) ? "1" : ''),'',array(t('Off'),t('On'))) array('featurelock_' .$f[0],sprintf(t('Lock feature %s'),$f[1]),(($f[4] !== false) ? "1" : ''),'',array(t('Off'),t('On')))
); );
} }
} }

View file

@ -40,7 +40,7 @@ function common_content(&$a) {
$vcard_widget .= replace_macros(get_markup_template("vcard-widget.tpl"),array( $vcard_widget .= replace_macros(get_markup_template("vcard-widget.tpl"),array(
'$name' => htmlentities($c[0]['name']), '$name' => htmlentities($c[0]['name']),
'$photo' => $c[0]['photo'], '$photo' => $c[0]['photo'],
'url' => z_root() . '/contacts/' . $cid 'url' => 'contacts/' . $cid
)); ));
if(! x($a->page,'aside')) if(! x($a->page,'aside'))

View file

@ -44,7 +44,7 @@ function contacts_init(&$a) {
$vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"),array( $vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"),array(
'$name' => htmlentities($a->data['contact']['name']), '$name' => htmlentities($a->data['contact']['name']),
'$photo' => $a->data['contact']['photo'], '$photo' => $a->data['contact']['photo'],
'$url' => ($a->data['contact']['network'] == NETWORK_DFRN) ? z_root()."/redir/".$a->data['contact']['id'] : $a->data['contact']['url'], '$url' => ($a->data['contact']['network'] == NETWORK_DFRN) ? "redir/".$a->data['contact']['id'] : $a->data['contact']['url'],
'$addr' => (($a->data['contact']['addr'] != "") ? ($a->data['contact']['addr']) : ""), '$addr' => (($a->data['contact']['addr'] != "") ? ($a->data['contact']['addr']) : ""),
'$network_name' => $networkname, '$network_name' => $networkname,
'$network' => t('Network:'), '$network' => t('Network:'),
@ -129,9 +129,9 @@ function contacts_batch_actions(&$a){
} }
if(x($_SESSION,'return_url')) if(x($_SESSION,'return_url'))
goaway($a->get_baseurl(true) . '/' . $_SESSION['return_url']); goaway('' . $_SESSION['return_url']);
else else
goaway($a->get_baseurl(true) . '/contacts'); goaway('contacts');
} }
@ -157,7 +157,7 @@ function contacts_post(&$a) {
if(! count($orig_record)) { if(! count($orig_record)) {
notice( t('Could not access contact record.') . EOL); notice( t('Could not access contact record.') . EOL);
goaway($a->get_baseurl(true) . '/contacts'); goaway('contacts');
return; // NOTREACHED return; // NOTREACHED
} }
@ -366,19 +366,19 @@ function contacts_content(&$a) {
if(! count($orig_record)) { if(! count($orig_record)) {
notice( t('Could not access contact record.') . EOL); notice( t('Could not access contact record.') . EOL);
goaway($a->get_baseurl(true) . '/contacts'); goaway('contacts');
return; // NOTREACHED return; // NOTREACHED
} }
if($cmd === 'update') { if($cmd === 'update') {
_contact_update($contact_id); _contact_update($contact_id);
goaway($a->get_baseurl(true) . '/contacts/' . $contact_id); goaway('contacts/' . $contact_id);
// NOTREACHED // NOTREACHED
} }
if($cmd === 'updateprofile') { if($cmd === 'updateprofile') {
_contact_update_profile($contact_id); _contact_update_profile($contact_id);
goaway($a->get_baseurl(true) . '/crepair/' . $contact_id); goaway('crepair/' . $contact_id);
// NOTREACHED // NOTREACHED
} }
@ -389,7 +389,7 @@ function contacts_content(&$a) {
info((($blocked) ? t('Contact has been blocked') : t('Contact has been unblocked')).EOL); info((($blocked) ? t('Contact has been blocked') : t('Contact has been unblocked')).EOL);
} }
goaway($a->get_baseurl(true) . '/contacts/' . $contact_id); goaway('contacts/' . $contact_id);
return; // NOTREACHED return; // NOTREACHED
} }
@ -400,7 +400,7 @@ function contacts_content(&$a) {
info((($readonly) ? t('Contact has been ignored') : t('Contact has been unignored')).EOL); info((($readonly) ? t('Contact has been ignored') : t('Contact has been unignored')).EOL);
} }
goaway($a->get_baseurl(true) . '/contacts/' . $contact_id); goaway('contacts/' . $contact_id);
return; // NOTREACHED return; // NOTREACHED
} }
@ -412,7 +412,7 @@ function contacts_content(&$a) {
info((($archived) ? t('Contact has been archived') : t('Contact has been unarchived')).EOL); info((($archived) ? t('Contact has been archived') : t('Contact has been unarchived')).EOL);
} }
goaway($a->get_baseurl(true) . '/contacts/' . $contact_id); goaway('contacts/' . $contact_id);
return; // NOTREACHED return; // NOTREACHED
} }
@ -447,17 +447,17 @@ function contacts_content(&$a) {
// Now check how the user responded to the confirmation query // Now check how the user responded to the confirmation query
if($_REQUEST['canceled']) { if($_REQUEST['canceled']) {
if(x($_SESSION,'return_url')) if(x($_SESSION,'return_url'))
goaway($a->get_baseurl(true) . '/' . $_SESSION['return_url']); goaway('' . $_SESSION['return_url']);
else else
goaway($a->get_baseurl(true) . '/contacts'); goaway('contacts');
} }
_contact_drop($contact_id, $orig_record[0]); _contact_drop($contact_id, $orig_record[0]);
info( t('Contact has been removed.') . EOL ); info( t('Contact has been removed.') . EOL );
if(x($_SESSION,'return_url')) if(x($_SESSION,'return_url'))
goaway($a->get_baseurl(true) . '/' . $_SESSION['return_url']); goaway('' . $_SESSION['return_url']);
else else
goaway($a->get_baseurl(true) . '/contacts'); goaway('contacts');
return; // NOTREACHED return; // NOTREACHED
} }
if($cmd === 'posts') { if($cmd === 'posts') {
@ -565,6 +565,9 @@ function contacts_content(&$a) {
($contact['rel'] == CONTACT_IS_FOLLOWER)) ($contact['rel'] == CONTACT_IS_FOLLOWER))
$follow = $a->get_baseurl(true)."/follow?url=".urlencode($contact["url"]); $follow = $a->get_baseurl(true)."/follow?url=".urlencode($contact["url"]);
// Load contactact related actions like hide, suggest, delete and others
$contact_actions = contact_actions($contact);
$o .= replace_macros($tpl, array( $o .= replace_macros($tpl, array(
//'$header' => t('Contact Editor'), //'$header' => t('Contact Editor'),
@ -575,7 +578,7 @@ function contacts_content(&$a) {
'$lbl_info1' => t('Contact Information / Notes'), '$lbl_info1' => t('Contact Information / Notes'),
'$infedit' => t('Edit contact notes'), '$infedit' => t('Edit contact notes'),
'$common_text' => $common_text, '$common_text' => $common_text,
'$common_link' => $a->get_baseurl(true) . '/common/loc/' . local_user() . '/' . $contact['id'], '$common_link' => 'common/loc/' . local_user() . '/' . $contact['id'],
'$all_friends' => $all_friends, '$all_friends' => $all_friends,
'$relation_text' => $relation_text, '$relation_text' => $relation_text,
'$visit' => sprintf( t('Visit %s\'s profile [%s]'),$contact['name'],$contact['url']), '$visit' => sprintf( t('Visit %s\'s profile [%s]'),$contact['name'],$contact['url']),
@ -584,7 +587,7 @@ function contacts_content(&$a) {
'$lblcrepair' => t("Repair URL settings"), '$lblcrepair' => t("Repair URL settings"),
'$lblrecent' => t('View conversations'), '$lblrecent' => t('View conversations'),
'$lblsuggest' => $lblsuggest, '$lblsuggest' => $lblsuggest,
'$delete' => t('Delete contact'), //'$delete' => t('Delete contact'),
'$nettype' => $nettype, '$nettype' => $nettype,
'$poll_interval' => $poll_interval, '$poll_interval' => $poll_interval,
'$poll_enabled' => $poll_enabled, '$poll_enabled' => $poll_enabled,
@ -622,7 +625,11 @@ function contacts_content(&$a) {
'$about' => bbcode($contact["about"], false, false), '$about' => bbcode($contact["about"], false, false),
'$about_label' => t("About:"), '$about_label' => t("About:"),
'$keywords' => $contact["keywords"], '$keywords' => $contact["keywords"],
'$keywords_label' => t("Tags:") '$keywords_label' => t("Tags:"),
'$contact_action_button' => t("Actions"),
'$contact_actions' => $contact_actions,
'$contact_status' => t("Status"),
'$contact_settings_label' => t('Contact Settings'),
)); ));
@ -668,7 +675,7 @@ function contacts_content(&$a) {
$tabs = array( $tabs = array(
array( array(
'label' => t('Suggestions'), 'label' => t('Suggestions'),
'url' => $a->get_baseurl(true) . '/suggest', 'url' => 'suggest',
'sel' => '', 'sel' => '',
'title' => t('Suggest potential friends'), 'title' => t('Suggest potential friends'),
'id' => 'suggestions-tab', 'id' => 'suggestions-tab',
@ -676,7 +683,7 @@ function contacts_content(&$a) {
), ),
array( array(
'label' => t('All Contacts'), 'label' => t('All Contacts'),
'url' => $a->get_baseurl(true) . '/contacts/all', 'url' => 'contacts/all',
'sel' => ($all) ? 'active' : '', 'sel' => ($all) ? 'active' : '',
'title' => t('Show all contacts'), 'title' => t('Show all contacts'),
'id' => 'showall-tab', 'id' => 'showall-tab',
@ -684,7 +691,7 @@ function contacts_content(&$a) {
), ),
array( array(
'label' => t('Unblocked'), 'label' => t('Unblocked'),
'url' => $a->get_baseurl(true) . '/contacts', 'url' => 'contacts',
'sel' => ((! $all) && (! $blocked) && (! $hidden) && (! $search) && (! $nets) && (! $ignored) && (! $archived)) ? 'active' : '', 'sel' => ((! $all) && (! $blocked) && (! $hidden) && (! $search) && (! $nets) && (! $ignored) && (! $archived)) ? 'active' : '',
'title' => t('Only show unblocked contacts'), 'title' => t('Only show unblocked contacts'),
'id' => 'showunblocked-tab', 'id' => 'showunblocked-tab',
@ -693,7 +700,7 @@ function contacts_content(&$a) {
array( array(
'label' => t('Blocked'), 'label' => t('Blocked'),
'url' => $a->get_baseurl(true) . '/contacts/blocked', 'url' => 'contacts/blocked',
'sel' => ($blocked) ? 'active' : '', 'sel' => ($blocked) ? 'active' : '',
'title' => t('Only show blocked contacts'), 'title' => t('Only show blocked contacts'),
'id' => 'showblocked-tab', 'id' => 'showblocked-tab',
@ -702,7 +709,7 @@ function contacts_content(&$a) {
array( array(
'label' => t('Ignored'), 'label' => t('Ignored'),
'url' => $a->get_baseurl(true) . '/contacts/ignored', 'url' => 'contacts/ignored',
'sel' => ($ignored) ? 'active' : '', 'sel' => ($ignored) ? 'active' : '',
'title' => t('Only show ignored contacts'), 'title' => t('Only show ignored contacts'),
'id' => 'showignored-tab', 'id' => 'showignored-tab',
@ -711,7 +718,7 @@ function contacts_content(&$a) {
array( array(
'label' => t('Archived'), 'label' => t('Archived'),
'url' => $a->get_baseurl(true) . '/contacts/archived', 'url' => 'contacts/archived',
'sel' => ($archived) ? 'active' : '', 'sel' => ($archived) ? 'active' : '',
'title' => t('Only show archived contacts'), 'title' => t('Only show archived contacts'),
'id' => 'showarchived-tab', 'id' => 'showarchived-tab',
@ -720,7 +727,7 @@ function contacts_content(&$a) {
array( array(
'label' => t('Hidden'), 'label' => t('Hidden'),
'url' => $a->get_baseurl(true) . '/contacts/hidden', 'url' => 'contacts/hidden',
'sel' => ($hidden) ? 'active' : '', 'sel' => ($hidden) ? 'active' : '',
'title' => t('Only show hidden contacts'), 'title' => t('Only show hidden contacts'),
'id' => 'showhidden-tab', 'id' => 'showhidden-tab',
@ -800,6 +807,17 @@ function contacts_content(&$a) {
return $o; return $o;
} }
/**
* @brief List of pages for the Contact TabBar
*
* Available Pages are 'Status', 'Profile', 'Contacts' and 'Common Friends'
*
* @param app $a
* @param int $contact_id The ID of the contact
* @param int $active_tab 1 if tab should be marked as active
*
* @return array with with contact TabBar data
*/
function contacts_tab($a, $contact_id, $active_tab) { function contacts_tab($a, $contact_id, $active_tab) {
// tabs // tabs
$tabs = array( $tabs = array(
@ -821,6 +839,7 @@ function contacts_tab($a, $contact_id, $active_tab) {
) )
); );
// Show this tab only if there is visible friend list
$x = count_all_friends(local_user(), $contact_id); $x = count_all_friends(local_user(), $contact_id);
if ($x) if ($x)
$tabs[] = array('label'=>t('Contacts'), $tabs[] = array('label'=>t('Contacts'),
@ -830,6 +849,7 @@ function contacts_tab($a, $contact_id, $active_tab) {
'id' => 'allfriends-tab', 'id' => 'allfriends-tab',
'accesskey' => 't'); 'accesskey' => 't');
// Show this tab only if there is visible common friend list
$common = count_common_friends(local_user(),$contact_id); $common = count_common_friends(local_user(),$contact_id);
if ($common) if ($common)
$tabs[] = array('label'=>t('Common Friends'), $tabs[] = array('label'=>t('Common Friends'),
@ -839,35 +859,13 @@ function contacts_tab($a, $contact_id, $active_tab) {
'id' => 'common-loc-tab', 'id' => 'common-loc-tab',
'accesskey' => 'd'); 'accesskey' => 'd');
$tabs[] = array('label' => t('Repair'), $tabs[] = array('label' => t('Advanced'),
'url' => $a->get_baseurl(true) . '/crepair/' . $contact_id, 'url' => 'crepair/' . $contact_id,
'sel' => (($active_tab == 5)?'active':''), 'sel' => (($active_tab == 5)?'active':''),
'title' => t('Advanced Contact Settings'), 'title' => t('Advanced Contact Settings'),
'id' => 'repair-tab', 'id' => 'advanced-tab',
'accesskey' => 'r'); 'accesskey' => 'r');
$tabs[] = array('label' => (($contact['blocked']) ? t('Unblock') : t('Block') ),
'url' => $a->get_baseurl(true) . '/contacts/' . $contact_id . '/block',
'sel' => '',
'title' => t('Toggle Blocked status'),
'id' => 'toggle-block-tab',
'accesskey' => 'b');
$tabs[] = array('label' => (($contact['readonly']) ? t('Unignore') : t('Ignore') ),
'url' => $a->get_baseurl(true) . '/contacts/' . $contact_id . '/ignore',
'sel' => '',
'title' => t('Toggle Ignored status'),
'id' => 'toggle-ignore-tab',
'accesskey' => 'i');
$tabs[] = array('label' => (($contact['archive']) ? t('Unarchive') : t('Archive') ),
'url' => $a->get_baseurl(true) . '/contacts/' . $contact_id . '/archive',
'sel' => '',
'title' => t('Toggle Archive status'),
'id' => 'toggle-archive-tab',
'accesskey' => 'v');
$tab_tpl = get_markup_template('common_tabs.tpl'); $tab_tpl = get_markup_template('common_tabs.tpl');
$tab_str = replace_macros($tab_tpl, array('$tabs' => $tabs)); $tab_str = replace_macros($tab_tpl, array('$tabs' => $tabs));
@ -954,3 +952,72 @@ function _contact_detail_for_template($rr){
); );
} }
/**
* @brief Gives a array with actions which can performed to a given contact
*
* This includes actions like e.g. 'block', 'hide', 'archive', 'delete' and others
*
* @param array $contact Data about the Contact
* @return array with contact related actions
*/
function contact_actions($contact) {
$poll_enabled = in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_FEED, NETWORK_MAIL, NETWORK_MAIL2));
$contact_action = array();
// Provide friend suggestion only for Friendica contacts
if($contact['network'] === NETWORK_DFRN) {
$contact_actions['suggest'] = array(
'label' => t('Suggest friends'),
'url' => 'fsuggest/' . $contact['id'],
'title' => '',
'sel' => '',
'id' => 'suggest',
);
}
if($poll_enabled) {
$contact_actions['update'] = array(
'label' => t('Update now'),
'url' => 'contacts/' . $contact['id'] . '/update',
'title' => '',
'sel' => '',
'id' => 'update',
);
}
$contact_actions['block'] = array(
'label' => (intval($contact['blocked']) ? t('Unblock') : t('Block') ),
'url' => 'contacts/' . $contact['id'] . '/block',
'title' => t('Toggle Blocked status'),
'sel' => (intval($contact['blocked']) ? 'active' : ''),
'id' => 'toggle-block',
);
$contact_actions['ignore'] = array(
'label' => (intval($contact['readonly']) ? t('Unignore') : t('Ignore') ),
'url' => 'contacts/' . $contact['id'] . '/ignore',
'title' => t('Toggle Ignored status'),
'sel' => (intval($contact['readonly']) ? 'active' : ''),
'id' => 'toggle-ignore',
);
$contact_actions['archive'] = array(
'label' => (intval($contact['archive']) ? t('Unarchive') : t('Archive') ),
'url' => 'contacts/' . $contact['id'] . '/archive',
'title' => t('Toggle Archive status'),
'sel' => (intval($contact['archive']) ? 'active' : ''),
'id' => 'toggle-archive',
);
$contact_actions['delete'] = array(
'label' => t('Delete'),
'url' => 'contacts/' . $contact['id'] . '/drop',
'title' => t('Delete contact'),
'sel' => '',
'id' => 'delete',
);
return $contact_actions;
}

View file

@ -420,7 +420,7 @@ function render_content(&$a, $items, $mode, $update, $preview = false) {
if(($normalised != 'mailbox') && (x($a->contacts[$normalised]))) if(($normalised != 'mailbox') && (x($a->contacts[$normalised])))
$profile_avatar = $a->contacts[$normalised]['thumb']; $profile_avatar = $a->contacts[$normalised]['thumb'];
else else
$profile_avatar = ((strlen($item['author-avatar'])) ? $a->get_cached_avatar_image($item['author-avatar']) : $item['thumb']); $profile_avatar = $a->remove_baseurl(((strlen($item['author-avatar'])) ? $item['author-avatar'] : $item['thumb']));
$locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => ''); $locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => '');
call_hooks('render_location',$locate); call_hooks('render_location',$locate);
@ -615,7 +615,7 @@ function render_content(&$a, $items, $mode, $update, $preview = false) {
$comment_lastcollapsed = true; $comment_lastcollapsed = true;
} }
$redirect_url = $a->get_baseurl($ssl_state) . '/redir/' . $item['cid'] ; $redirect_url = 'redir/' . $item['cid'] ;
$lock = ((($item['private'] == 1) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid']) $lock = ((($item['private'] == 1) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid'])
|| strlen($item['deny_cid']) || strlen($item['deny_gid'])))) || strlen($item['deny_cid']) || strlen($item['deny_gid']))))
@ -791,7 +791,7 @@ function render_content(&$a, $items, $mode, $update, $preview = false) {
if(($normalised != 'mailbox') && (x($a->contacts,$normalised))) if(($normalised != 'mailbox') && (x($a->contacts,$normalised)))
$profile_avatar = $a->contacts[$normalised]['thumb']; $profile_avatar = $a->contacts[$normalised]['thumb'];
else else
$profile_avatar = (((strlen($item['author-avatar'])) && $diff_author) ? $item['author-avatar'] : $a->get_cached_avatar_image($thumb)); $profile_avatar = $a->remove_baseurl(((strlen($item['author-avatar']) && $diff_author) ? $item['author-avatar'] : $thumb));
$like = ((x($alike,$item['uri'])) ? format_like($alike[$item['uri']],$alike[$item['uri'] . '-l'],'like',$item['uri']) : ''); $like = ((x($alike,$item['uri'])) ? format_like($alike[$item['uri']],$alike[$item['uri'] . '-l'],'like',$item['uri']) : '');
$dislike = ((x($dlike,$item['uri'])) ? format_like($dlike[$item['uri']],$dlike[$item['uri'] . '-l'],'dislike',$item['uri']) : ''); $dislike = ((x($dlike,$item['uri'])) ? format_like($dlike[$item['uri']],$dlike[$item['uri'] . '-l'],'dislike',$item['uri']) : '');

View file

@ -427,8 +427,8 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
if(($contact) && ($contact['network'] === NETWORK_DIASPORA)) { if(($contact) && ($contact['network'] === NETWORK_DIASPORA)) {
require_once('include/diaspora.php'); require_once('include/diaspora.php');
$ret = diaspora_share($user[0],$r[0]); $ret = diaspora::send_share($user[0],$r[0]);
logger('mod_follow: diaspora_share returns: ' . $ret); logger('share returns: ' . $ret);
} }
// Send a new friend post if we are allowed to... // Send a new friend post if we are allowed to...
@ -448,6 +448,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
if(count($self)) { if(count($self)) {
$arr = array(); $arr = array();
$arr['guid'] = get_guid(32);
$arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), $uid); $arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), $uid);
$arr['uid'] = $uid; $arr['uid'] = $uid;
$arr['contact-id'] = $self[0]['id']; $arr['contact-id'] = $self[0]['id'];
@ -466,7 +467,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
$BPhoto = '[url=' . $contact['url'] . ']' . '[img]' . $contact['thumb'] . '[/img][/url]'; $BPhoto = '[url=' . $contact['url'] . ']' . '[img]' . $contact['thumb'] . '[/img][/url]';
$arr['verb'] = ACTIVITY_FRIEND; $arr['verb'] = ACTIVITY_FRIEND;
$arr['object-type'] = ACTIVITY_OBJ_PERSON; $arr['object-type'] = ACTIVITY_OBJ_PERSON;
$arr['body'] = sprintf( t('%1$s is now friends with %2$s'), $A, $B)."\n\n\n".$BPhoto; $arr['body'] = sprintf( t('%1$s is now friends with %2$s'), $A, $B)."\n\n\n".$BPhoto;
$arr['object'] = '<object><type>' . ACTIVITY_OBJ_PERSON . '</type><title>' . $contact['name'] . '</title>' $arr['object'] = '<object><type>' . ACTIVITY_OBJ_PERSON . '</type><title>' . $contact['name'] . '</title>'
@ -489,13 +490,10 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
} }
} }
$def_gid = get_default_group($uid, $contact["network"]);
$g = q("select def_gid from user where uid = %d limit 1", if($contact && intval($def_gid)) {
intval($uid)
);
if($contact && $g && intval($g[0]['def_gid'])) {
require_once('include/group.php'); require_once('include/group.php');
group_add_member($uid,'',$contact['id'],$g[0]['def_gid']); group_add_member($uid, '', $contact['id'], $def_gid);
} }
// Let's send our user to the contact editor in case they want to // Let's send our user to the contact editor in case they want to

View file

@ -42,8 +42,10 @@ function dfrn_request_init(&$a) {
if(! function_exists('dfrn_request_post')) { if(! function_exists('dfrn_request_post')) {
function dfrn_request_post(&$a) { function dfrn_request_post(&$a) {
if(($a->argc != 2) || (! count($a->profile))) if(($a->argc != 2) || (! count($a->profile))) {
logger('Wrong count of argc or profiles: argc=' . $a->argc . ',profile()=' . count($a->profile));
return; return;
}
if(x($_POST, 'cancel')) { if(x($_POST, 'cancel')) {
@ -172,18 +174,16 @@ function dfrn_request_post(&$a) {
info( t("Introduction complete.") . EOL); info( t("Introduction complete.") . EOL);
} }
$r = q("select id from contact where uid = %d and url = '%s' and `site-pubkey` = '%s' limit 1", $r = q("SELECT `id`, `network` FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `site-pubkey` = '%s' LIMIT 1",
intval(local_user()), intval(local_user()),
dbesc($dfrn_url), dbesc($dfrn_url),
$parms['key'] // this was already escaped $parms['key'] // this was already escaped
); );
if(count($r)) { if(count($r)) {
$g = q("select def_gid from user where uid = %d limit 1", $def_gid = get_default_group(local_user(), $r[0]["network"]);
intval(local_user()) if(intval($def_gid)) {
);
if($g && intval($g[0]['def_gid'])) {
require_once('include/group.php'); require_once('include/group.php');
group_add_member(local_user(),'',$r[0]['id'],$g[0]['def_gid']); group_add_member(local_user(), '', $r[0]['id'], $def_gid);
} }
$forwardurl = $a->get_baseurl()."/contacts/".$r[0]['id']; $forwardurl = $a->get_baseurl()."/contacts/".$r[0]['id'];
} else } else
@ -386,19 +386,17 @@ function dfrn_request_post(&$a) {
intval($rel) intval($rel)
); );
$r = q("select id from contact where poll = '%s' and uid = %d limit 1", $r = q("SELECT `id`, `network` FROM `contact` WHERE `poll` = '%s' AND `uid` = %d LIMIT 1",
dbesc($poll), dbesc($poll),
intval($uid) intval($uid)
); );
if(count($r)) { if(count($r)) {
$contact_id = $r[0]['id']; $contact_id = $r[0]['id'];
$g = q("select def_gid from user where uid = %d limit 1", $def_gid = get_default_group($uid, $r[0]["network"]);
intval($uid) if (intval($def_gid)) {
);
if($g && intval($g[0]['def_gid'])) {
require_once('include/group.php'); require_once('include/group.php');
group_add_member($uid,'',$contact_id,$g[0]['def_gid']); group_add_member($uid, '', $contact_id, $def_gid);
} }
$photo = avatar_img($addr); $photo = avatar_img($addr);
@ -461,7 +459,7 @@ function dfrn_request_post(&$a) {
$network = NETWORK_DFRN; $network = NETWORK_DFRN;
} }
logger('dfrn_request: url: ' . $url); logger('dfrn_request: url: ' . $url . ',network=' . $network, LOGGER_DEBUG);
if($network === NETWORK_DFRN) { if($network === NETWORK_DFRN) {
$ret = q("SELECT * FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `self` = 0 LIMIT 1", $ret = q("SELECT * FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `self` = 0 LIMIT 1",
@ -825,7 +823,7 @@ function dfrn_request_content(&$a) {
else else
$tpl = get_markup_template('auto_request.tpl'); $tpl = get_markup_template('auto_request.tpl');
$page_desc .= t("Please enter your 'Identity Address' from one of the following supported communications networks:"); $page_desc = t("Please enter your 'Identity Address' from one of the following supported communications networks:");
// see if we are allowed to have NETWORK_MAIL2 contacts // see if we are allowed to have NETWORK_MAIL2 contacts
@ -850,7 +848,7 @@ function dfrn_request_content(&$a) {
get_server() get_server()
); );
$o .= replace_macros($tpl,array( $o = replace_macros($tpl,array(
'$header' => t('Friend/Connection Request'), '$header' => t('Friend/Connection Request'),
'$desc' => t('Examples: jojo@demo.friendica.com, http://demo.friendica.com/profile/jojo, testuser@identi.ca'), '$desc' => t('Examples: jojo@demo.friendica.com, http://demo.friendica.com/profile/jojo, testuser@identi.ca'),
'$pls_answer' => t('Please answer the following:'), '$pls_answer' => t('Please answer the following:'),

View file

@ -104,7 +104,7 @@ function directory_content(&$a) {
$itemurl = (($rr['addr'] != "") ? $rr['addr'] : $rr['profile_url']); $itemurl = (($rr['addr'] != "") ? $rr['addr'] : $rr['profile_url']);
$profile_link = z_root() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']); $profile_link = 'profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
$pdesc = (($rr['pdesc']) ? $rr['pdesc'] . '<br />' : ''); $pdesc = (($rr['pdesc']) ? $rr['pdesc'] . '<br />' : '');
@ -158,14 +158,14 @@ function directory_content(&$a) {
else { else {
$location_e = $location; $location_e = $location;
} }
$photo_menu = array(array(t("View Profile"), zrl($profile_link))); $photo_menu = array(array(t("View Profile"), zrl($profile_link)));
$entry = array( $entry = array(
'id' => $rr['id'], 'id' => $rr['id'],
'url' => $profile_link, 'url' => $profile_link,
'itemurl' => $itemurl, 'itemurl' => $itemurl,
'thumb' => proxy_url($a->get_cached_avatar_image($rr[$photo]), false, PROXY_SIZE_THUMB), 'thumb' => proxy_url($rr[$photo], false, PROXY_SIZE_THUMB),
'img_hover' => $rr['name'], 'img_hover' => $rr['name'],
'name' => $rr['name'], 'name' => $rr['name'],
'details' => $details, 'details' => $details,

View file

@ -17,7 +17,7 @@ function display_init(&$a) {
// Does the local user have this item? // Does the local user have this item?
if (local_user()) { if (local_user()) {
$r = q("SELECT `id`, `parent`, `author-name`, `author-link`, `author-avatar`, `network`, `body`, `uid` FROM `item` $r = q("SELECT `id`, `parent`, `author-name`, `author-link`, `author-avatar`, `network`, `body`, `uid` FROM `item`
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
AND `guid` = '%s' AND `uid` = %d", dbesc($a->argv[1]), local_user()); AND `guid` = '%s' AND `uid` = %d", dbesc($a->argv[1]), local_user());
if (count($r)) { if (count($r)) {
$nick = $a->user["nickname"]; $nick = $a->user["nickname"];
@ -30,12 +30,12 @@ function display_init(&$a) {
$r = q("SELECT `user`.`nickname`, `item`.`id`, `item`.`parent`, `item`.`author-name`, $r = q("SELECT `user`.`nickname`, `item`.`id`, `item`.`parent`, `item`.`author-name`,
`item`.`author-link`, `item`.`author-avatar`, `item`.`network`, `item`.`uid`, `item`.`body` `item`.`author-link`, `item`.`author-avatar`, `item`.`network`, `item`.`uid`, `item`.`body`
FROM `item` INNER JOIN `user` ON `user`.`uid` = `item`.`uid` FROM `item` INNER JOIN `user` ON `user`.`uid` = `item`.`uid`
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
AND `item`.`private` = 0 AND NOT `user`.`hidewall` AND NOT `item`.`private` AND NOT `user`.`hidewall`
AND `item`.`guid` = '%s'", dbesc($a->argv[1])); AND `item`.`guid` = '%s'", dbesc($a->argv[1]));
// AND `item`.`private` = 0 AND `item`.`wall` = 1 // AND NOT `item`.`private` AND `item`.`wall`
if (count($r)) { if (count($r)) {
$nick = $r[0]["nickname"]; $nick = $r[0]["nickname"];
$itemuid = $r[0]["uid"]; $itemuid = $r[0]["uid"];
@ -46,17 +46,17 @@ function display_init(&$a) {
if ($nick == "") { if ($nick == "") {
$r = q("SELECT `item`.`id`, `item`.`parent`, `item`.`author-name`, $r = q("SELECT `item`.`id`, `item`.`parent`, `item`.`author-name`,
`item`.`author-link`, `item`.`author-avatar`, `item`.`network`, `item`.`uid`, `item`.`body` `item`.`author-link`, `item`.`author-avatar`, `item`.`network`, `item`.`uid`, `item`.`body`
FROM `item` WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 FROM `item` WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
AND `item`.`private` = 0 AND `item`.`uid` = 0 AND NOT `item`.`private` AND `item`.`uid` = 0
AND `item`.`guid` = '%s'", dbesc($a->argv[1])); AND `item`.`guid` = '%s'", dbesc($a->argv[1]));
// AND `item`.`private` = 0 AND `item`.`wall` = 1 // AND NOT `item`.`private` AND `item`.`wall`
} }
if (count($r)) { if (count($r)) {
if ($r[0]["id"] != $r[0]["parent"]) if ($r[0]["id"] != $r[0]["parent"])
$r = q("SELECT `id`, `author-name`, `author-link`, `author-avatar`, `network`, `body`, `uid` FROM `item` $r = q("SELECT `id`, `author-name`, `author-link`, `author-avatar`, `network`, `body`, `uid` FROM `item`
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
AND `id` = %d", $r[0]["parent"]); AND `id` = %d", $r[0]["parent"]);
$profiledata = display_fetchauthor($a, $r[0]); $profiledata = display_fetchauthor($a, $r[0]);
@ -67,7 +67,7 @@ function display_init(&$a) {
if (($nickname != $a->user["nickname"])) { if (($nickname != $a->user["nickname"])) {
$r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile` $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile`
INNER JOIN `contact` on `contact`.`uid` = `profile`.`uid` INNER JOIN `user` ON `profile`.`uid` = `user`.`uid` INNER JOIN `contact` on `contact`.`uid` = `profile`.`uid` INNER JOIN `user` ON `profile`.`uid` = `user`.`uid`
WHERE `user`.`nickname` = '%s' AND `profile`.`is-default` = 1 and `contact`.`self` = 1 LIMIT 1", WHERE `user`.`nickname` = '%s' AND `profile`.`is-default` AND `contact`.`self` LIMIT 1",
dbesc($nickname) dbesc($nickname)
); );
if (count($r)) if (count($r))
@ -120,27 +120,27 @@ function display_fetchauthor($a, $item) {
} }
if (!$skip) { if (!$skip) {
$author = ""; $author = "";
preg_match("/author='(.*?)'/ism", $attributes, $matches); preg_match("/author='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "") if ($matches[1] != "")
$profiledata["name"] = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8'); $profiledata["name"] = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8');
preg_match('/author="(.*?)"/ism', $attributes, $matches); preg_match('/author="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "") if ($matches[1] != "")
$profiledata["name"] = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8'); $profiledata["name"] = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8');
$profile = ""; $profile = "";
preg_match("/profile='(.*?)'/ism", $attributes, $matches); preg_match("/profile='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "") if ($matches[1] != "")
$profiledata["url"] = $matches[1]; $profiledata["url"] = $matches[1];
preg_match('/profile="(.*?)"/ism', $attributes, $matches); preg_match('/profile="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "") if ($matches[1] != "")
$profiledata["url"] = $matches[1]; $profiledata["url"] = $matches[1];
$avatar = ""; $avatar = "";
preg_match("/avatar='(.*?)'/ism", $attributes, $matches); preg_match("/avatar='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "") if ($matches[1] != "")
$profiledata["photo"] = $matches[1]; $profiledata["photo"] = $matches[1];
preg_match('/avatar="(.*?)"/ism', $attributes, $matches); preg_match('/avatar="(.*?)"/ism', $attributes, $matches);
@ -257,7 +257,7 @@ function display_content(&$a, $update = 0) {
if (local_user()) { if (local_user()) {
$r = q("SELECT `id` FROM `item` $r = q("SELECT `id` FROM `item`
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
AND `guid` = '%s' AND `uid` = %d", dbesc($a->argv[1]), local_user()); AND `guid` = '%s' AND `uid` = %d", dbesc($a->argv[1]), local_user());
if (count($r)) { if (count($r)) {
$item_id = $r[0]["id"]; $item_id = $r[0]["id"];
@ -267,12 +267,12 @@ function display_content(&$a, $update = 0) {
if ($nick == "") { if ($nick == "") {
$r = q("SELECT `user`.`nickname`, `item`.`id` FROM `item` INNER JOIN `user` ON `user`.`uid` = `item`.`uid` $r = q("SELECT `user`.`nickname`, `item`.`id` FROM `item` INNER JOIN `user` ON `user`.`uid` = `item`.`uid`
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
AND `item`.`private` = 0 AND NOT `user`.`hidewall` AND NOT `item`.`private` AND NOT `user`.`hidewall`
AND `item`.`guid` = '%s'", dbesc($a->argv[1])); AND `item`.`guid` = '%s'", dbesc($a->argv[1]));
// AND `item`.`private` = 0 AND `item`.`wall` = 1 // AND NOT `item`.`private` AND `item`.`wall`
if (count($r)) { if (count($r)) {
$item_id = $r[0]["id"]; $item_id = $r[0]["id"];
$nick = $r[0]["nickname"]; $nick = $r[0]["nickname"];
@ -280,12 +280,12 @@ function display_content(&$a, $update = 0) {
} }
if ($nick == "") { if ($nick == "") {
$r = q("SELECT `item`.`id` FROM `item` $r = q("SELECT `item`.`id` FROM `item`
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
AND `item`.`private` = 0 AND `item`.`uid` = 0 AND NOT `item`.`private` AND `item`.`uid` = 0
AND `item`.`guid` = '%s'", dbesc($a->argv[1])); AND `item`.`guid` = '%s'", dbesc($a->argv[1]));
// AND `item`.`private` = 0 AND `item`.`wall` = 1 // AND NOT `item`.`private` AND `item`.`wall`
if (count($r)) { if (count($r)) {
$item_id = $r[0]["id"]; $item_id = $r[0]["id"];
} }
@ -293,12 +293,22 @@ function display_content(&$a, $update = 0) {
} }
} }
if(! $item_id) { if ($item_id AND !is_numeric($item_id)) {
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($item_id), intval($a->profile['uid']));
if ($r)
$item_id = $r[0]["id"];
else
$item_id = false;
}
if (!$item_id) {
$a->error = 404; $a->error = 404;
notice( t('Item not found.') . EOL); notice(t('Item not found.').EOL);
return; return;
} }
$groups = array(); $groups = array();
$contact = null; $contact = null;
@ -334,7 +344,7 @@ function display_content(&$a, $update = 0) {
} }
} }
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1", $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1",
intval($a->profile['uid']) intval($a->profile['uid'])
); );
if(count($r)) if(count($r))
@ -347,10 +357,8 @@ function display_content(&$a, $update = 0) {
return; return;
} }
// Why do we need this on the display page? We don't have the possibility to write new content here. // We need the editor here to be able to reshare an item.
// Ad editing of posts work without this as well.
// We should remove this completely for the 3.5.1 release.
/*
if ($is_owner) { if ($is_owner) {
$x = array( $x = array(
'is_owner' => true, 'is_owner' => true,
@ -366,66 +374,56 @@ function display_content(&$a, $update = 0) {
); );
$o .= status_editor($a,$x,0,true); $o .= status_editor($a,$x,0,true);
} }
*/
$sql_extra = item_permissions_sql($a->profile['uid'],$remote_contact,$groups); $sql_extra = item_permissions_sql($a->profile['uid'],$remote_contact,$groups);
// AND `item`.`parent` = ( SELECT `parent` FROM `item` FORCE INDEX (PRIMARY, `uri`) WHERE ( `id` = '%s' OR `uri` = '%s' ))
if($update) { if($update) {
$r = q("SELECT id FROM item WHERE item.uid = %d $r = q("SELECT `id` FROM `item` WHERE `item`.`uid` = %d
AND `item`.`parent` = (SELECT `parent` FROM `item` WHERE (`id` = '%s' OR `uri` = '%s')) AND `item`.`parent` = (SELECT `parent` FROM `item` WHERE `id` = %d)
$sql_extra AND unseen = 1", $sql_extra AND `unseen`",
intval($a->profile['uid']), intval($a->profile['uid']),
dbesc($item_id), intval($item_id)
dbesc($item_id)
); );
if(!$r) if(!$r)
return ''; return '';
} }
// AND `item`.`parent` = ( SELECT `parent` FROM `item` FORCE INDEX (PRIMARY, `uri`) WHERE ( `id` = '%s' OR `uri` = '%s' )
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
`contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND NOT `contact`.`blocked` AND NOT `contact`.`pending`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 WHERE `item`.`uid` = %d AND `item`.`visible` AND NOT `item`.`deleted`
and `item`.`moderated` = 0 AND NOT `item`.`moderated`
AND `item`.`parent` = (SELECT `parent` FROM `item` WHERE (`id` = '%s' OR `uri` = '%s') AND `item`.`parent` = (SELECT `parent` FROM `item` WHERE `id` = %d)
AND uid = %d)
$sql_extra $sql_extra
ORDER BY `parent` DESC, `gravity` ASC, `id` ASC", ORDER BY `parent` DESC, `gravity` ASC, `id` ASC",
intval($a->profile['uid']), intval($a->profile['uid']),
dbesc($item_id), intval($item_id)
dbesc($item_id),
intval($a->profile['uid'])
); );
if(!$r && local_user()) { if(!$r && local_user()) {
// Check if this is another person's link to a post that we have // Check if this is another person's link to a post that we have
$r = q("SELECT `item`.uri FROM `item` $r = q("SELECT `item`.uri FROM `item`
WHERE (`item`.`id` = '%s' OR `item`.`uri` = '%s' ) WHERE (`item`.`id` = %d OR `item`.`uri` = '%s')
LIMIT 1", LIMIT 1",
dbesc($item_id), intval($item_id),
dbesc($item_id) dbesc($item_id)
); );
if($r) { if($r) {
$item_uri = $r[0]['uri']; $item_uri = $r[0]['uri'];
// AND `item`.`parent` = ( SELECT `parent` FROM `item` FORCE INDEX (PRIMARY, `uri`) WHERE `uri` = '%s' AND uid = %d )
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
`contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND NOT `contact`.`blocked` AND NOT `contact`.`pending`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 WHERE `item`.`uid` = %d AND `item`.`visible` AND NOT `item`.`deleted`
and `item`.`moderated` = 0 AND NOT `item`.`moderated`
AND `item`.`parent` = (SELECT `parent` FROM `item` WHERE `uri` = '%s' AND uid = %d) AND `item`.`parent` = (SELECT `parent` FROM `item` WHERE `uri` = '%s' AND uid = %d)
ORDER BY `parent` DESC, `gravity` ASC, `id` ASC ", ORDER BY `parent` DESC, `gravity` ASC, `id` ASC ",
intval(local_user()), intval(local_user()),
@ -440,7 +438,7 @@ function display_content(&$a, $update = 0) {
if((local_user()) && (local_user() == $a->profile['uid'])) { if((local_user()) && (local_user() == $a->profile['uid'])) {
q("UPDATE `item` SET `unseen` = 0 q("UPDATE `item` SET `unseen` = 0
WHERE `parent` = %d AND `unseen` = 1", WHERE `parent` = %d AND `unseen`",
intval($r[0]['parent']) intval($r[0]['parent'])
); );
} }

View file

@ -74,10 +74,18 @@ function fbrowser_content($a){
$filename_e = $rr['filename']; $filename_e = $rr['filename'];
} }
// Take the second largest picture as preview
$p = q("SELECT `scale` FROM `photo` WHERE `resource-id` = '%s' AND `scale` > %d ORDER BY `resource-id`, `scale` LIMIT 1",
dbesc($rr['resource-id']), intval($rr['hiq']));
if ($p)
$scale = $p[0]["scale"];
else
$scale = $rr['loq'];
return array( return array(
$a->get_baseurl() . '/photos/' . $a->user['nickname'] . '/image/' . $rr['resource-id'], $a->get_baseurl() . '/photos/' . $a->user['nickname'] . '/image/' . $rr['resource-id'],
$filename_e, $filename_e,
$a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['loq'] . '.'. $ext $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $scale . '.'. $ext
); );
} }
$files = array_map("_map_files1", $r); $files = array_map("_map_files1", $r);

View file

@ -24,6 +24,7 @@ require_once('include/threads.php');
require_once('include/text.php'); require_once('include/text.php');
require_once('include/items.php'); require_once('include/items.php');
require_once('include/Scrape.php'); require_once('include/Scrape.php');
require_once('include/diaspora.php');
function item_post(&$a) { function item_post(&$a) {
@ -900,7 +901,7 @@ function item_post(&$a) {
// Store the comment signature information in case we need to relay to Diaspora // Store the comment signature information in case we need to relay to Diaspora
store_diaspora_comment_sig($datarray, $author, ($self ? $user['prvkey'] : false), $parent_item, $post_id); diaspora::store_comment_signature($datarray, $author, ($self ? $user['prvkey'] : false), $post_id);
} else { } else {
$parent = $post_id; $parent = $post_id;
@ -1245,42 +1246,3 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $netwo
return array('replaced' => $replaced, 'contact' => $r[0]); return array('replaced' => $replaced, 'contact' => $r[0]);
} }
function store_diaspora_comment_sig($datarray, $author, $uprvkey, $parent_item, $post_id) {
// We won't be able to sign Diaspora comments for authenticated visitors - we don't have their private key
$enabled = intval(get_config('system','diaspora_enabled'));
if(! $enabled) {
logger('mod_item: diaspora support disabled, not storing comment signature', LOGGER_DEBUG);
return;
}
logger('mod_item: storing diaspora comment signature');
require_once('include/bb2diaspora.php');
$signed_body = html_entity_decode(bb2diaspora($datarray['body']));
// Only works for NETWORK_DFRN
$contact_baseurl_start = strpos($author['url'],'://') + 3;
$contact_baseurl_length = strpos($author['url'],'/profile') - $contact_baseurl_start;
$contact_baseurl = substr($author['url'], $contact_baseurl_start, $contact_baseurl_length);
$diaspora_handle = $author['nick'] . '@' . $contact_baseurl;
$signed_text = $datarray['guid'] . ';' . $parent_item['guid'] . ';' . $signed_body . ';' . $diaspora_handle;
if( $uprvkey !== false )
$authorsig = rsa_sign($signed_text,$uprvkey,'sha256');
else
$authorsig = '';
q("insert into sign (`iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ",
intval($post_id),
dbesc($signed_text),
dbesc(base64_encode($authorsig)),
dbesc($diaspora_handle)
);
return;
}

View file

@ -13,7 +13,7 @@ function message_init(&$a) {
$new = array( $new = array(
'label' => t('New Message'), 'label' => t('New Message'),
'url' => $a->get_baseurl(true) . '/message/new', 'url' => 'message/new',
'sel'=> ($a->argv[1] == 'new'), 'sel'=> ($a->argv[1] == 'new'),
'accesskey' => 'm', 'accesskey' => 'm',
); );
@ -90,7 +90,7 @@ function message_post(&$a) {
$a->argv[1] = 'new'; $a->argv[1] = 'new';
} }
else else
goaway($a->get_baseurl(true) . '/' . $_SESSION['return_url']); goaway($_SESSION['return_url']);
} }
@ -182,7 +182,7 @@ function message_content(&$a) {
return; return;
} }
$myprofile = $a->get_baseurl(true) . '/profile/' . $a->user['nickname']; $myprofile = 'profile/' . $a->user['nickname'];
$tpl = get_markup_template('mail_head.tpl'); $tpl = get_markup_template('mail_head.tpl');
$header = replace_macros($tpl, array( $header = replace_macros($tpl, array(
@ -221,7 +221,7 @@ function message_content(&$a) {
} }
// Now check how the user responded to the confirmation query // Now check how the user responded to the confirmation query
if($_REQUEST['canceled']) { if($_REQUEST['canceled']) {
goaway($a->get_baseurl(true) . '/' . $_SESSION['return_url']); goaway($_SESSION['return_url']);
} }
$cmd = $a->argv[1]; $cmd = $a->argv[1];
@ -234,7 +234,7 @@ function message_content(&$a) {
info( t('Message deleted.') . EOL ); info( t('Message deleted.') . EOL );
} }
//goaway($a->get_baseurl(true) . '/message' ); //goaway($a->get_baseurl(true) . '/message' );
goaway($a->get_baseurl(true) . '/' . $_SESSION['return_url']); goaway($_SESSION['return_url']);
} }
else { else {
$r = q("SELECT `parent-uri`,`convid` FROM `mail` WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("SELECT `parent-uri`,`convid` FROM `mail` WHERE `id` = %d AND `uid` = %d LIMIT 1",
@ -265,7 +265,7 @@ function message_content(&$a) {
info( t('Conversation removed.') . EOL ); info( t('Conversation removed.') . EOL );
} }
//goaway($a->get_baseurl(true) . '/message' ); //goaway($a->get_baseurl(true) . '/message' );
goaway($a->get_baseurl(true) . '/' . $_SESSION['return_url']); goaway($_SESSION['return_url']);
} }
} }
@ -448,7 +448,7 @@ function message_content(&$a) {
$sparkle = ''; $sparkle = '';
} }
else { else {
$from_url = $a->get_baseurl(true) . '/redir/' . $message['contact-id']; $from_url = 'redir/' . $message['contact-id'];
$sparkle = ' sparkle'; $sparkle = ' sparkle';
} }
@ -549,7 +549,7 @@ function render_messages($msg, $t) {
$tpl = get_markup_template($t); $tpl = get_markup_template($t);
$rslt = ''; $rslt = '';
$myprofile = $a->get_baseurl(true) . '/profile/' . $a->user['nickname']; $myprofile = 'profile/' . $a->user['nickname'];
foreach($msg as $rr) { foreach($msg as $rr) {
@ -577,7 +577,7 @@ function render_messages($msg, $t) {
$rslt .= replace_macros($tpl, array( $rslt .= replace_macros($tpl, array(
'$id' => $rr['id'], '$id' => $rr['id'],
'$from_name' => $participants, '$from_name' => $participants,
'$from_url' => (($rr['network'] === NETWORK_DFRN) ? $a->get_baseurl(true) . '/redir/' . $rr['contact-id'] : $rr['url']), '$from_url' => (($rr['network'] === NETWORK_DFRN) ? 'redir/' . $rr['contact-id'] : $rr['url']),
'$sparkle' => ' sparkle', '$sparkle' => ' sparkle',
'$from_photo' => (($rr['thumb']) ? $rr['thumb'] : $rr['from-photo']), '$from_photo' => (($rr['thumb']) ? $rr['thumb'] : $rr['from-photo']),
'$subject' => $subject_e, '$subject' => $subject_e,

View file

@ -62,7 +62,7 @@ function mood_init(&$a) {
$action = sprintf( t('%1$s is currently %2$s'), '[url=' . $poster['url'] . ']' . $poster['name'] . '[/url]' , $verbs[$verb]); $action = sprintf( t('%1$s is currently %2$s'), '[url=' . $poster['url'] . ']' . $poster['name'] . '[/url]' , $verbs[$verb]);
$arr = array(); $arr = array();
$arr['guid'] = get_guid(32);
$arr['uid'] = $uid; $arr['uid'] = $uid;
$arr['uri'] = $uri; $arr['uri'] = $uri;
$arr['parent-uri'] = (($parent_uri) ? $parent_uri : $uri); $arr['parent-uri'] = (($parent_uri) ? $parent_uri : $uri);

View file

@ -149,10 +149,10 @@ function network_init(&$a) {
$a->page['aside'] .= (feature_enabled(local_user(),'groups') ? group_side('network/0','network','standard',$group_id) : ''); $a->page['aside'] .= (feature_enabled(local_user(),'groups') ? group_side('network/0','network','standard',$group_id) : '');
$a->page['aside'] .= (feature_enabled(local_user(),'forumlist_widget') ? ForumManager::widget(local_user(),$cid) : ''); $a->page['aside'] .= (feature_enabled(local_user(),'forumlist_widget') ? ForumManager::widget(local_user(),$cid) : '');
$a->page['aside'] .= posted_date_widget($a->get_baseurl() . '/network',local_user(),false); $a->page['aside'] .= posted_date_widget('network',local_user(),false);
$a->page['aside'] .= networks_widget($a->get_baseurl(true) . '/network',(x($_GET, 'nets') ? $_GET['nets'] : '')); $a->page['aside'] .= networks_widget('network',(x($_GET, 'nets') ? $_GET['nets'] : ''));
$a->page['aside'] .= saved_searches($search); $a->page['aside'] .= saved_searches($search);
$a->page['aside'] .= fileas_widget($a->get_baseurl(true) . '/network',(x($_GET, 'file') ? $_GET['file'] : '')); $a->page['aside'] .= fileas_widget('network',(x($_GET, 'file') ? $_GET['file'] : ''));
} }
@ -363,7 +363,7 @@ function network_content(&$a, $update = 0) {
$tabs = array( $tabs = array(
array( array(
'label' => t('Commented Order'), 'label' => t('Commented Order'),
'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . '?f=&order=comment' . ((x($_GET,'cid')) ? '&cid=' . $_GET['cid'] : ''), 'url' => str_replace('/new', '', $cmd) . '?f=&order=comment' . ((x($_GET,'cid')) ? '&cid=' . $_GET['cid'] : ''),
'sel' => $all_active, 'sel' => $all_active,
'title' => t('Sort by Comment Date'), 'title' => t('Sort by Comment Date'),
'id' => 'commented-order-tab', 'id' => 'commented-order-tab',
@ -371,7 +371,7 @@ function network_content(&$a, $update = 0) {
), ),
array( array(
'label' => t('Posted Order'), 'label' => t('Posted Order'),
'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . '?f=&order=post' . ((x($_GET,'cid')) ? '&cid=' . $_GET['cid'] : ''), 'url' => str_replace('/new', '', $cmd) . '?f=&order=post' . ((x($_GET,'cid')) ? '&cid=' . $_GET['cid'] : ''),
'sel' => $postord_active, 'sel' => $postord_active,
'title' => t('Sort by Post Date'), 'title' => t('Sort by Post Date'),
'id' => 'posted-order-tab', 'id' => 'posted-order-tab',
@ -382,7 +382,7 @@ function network_content(&$a, $update = 0) {
if(feature_enabled(local_user(),'personal_tab')) { if(feature_enabled(local_user(),'personal_tab')) {
$tabs[] = array( $tabs[] = array(
'label' => t('Personal'), 'label' => t('Personal'),
'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&conv=1', 'url' => str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&conv=1',
'sel' => $conv_active, 'sel' => $conv_active,
'title' => t('Posts that mention or involve you'), 'title' => t('Posts that mention or involve you'),
'id' => 'personal-tab', 'id' => 'personal-tab',
@ -393,7 +393,7 @@ function network_content(&$a, $update = 0) {
if(feature_enabled(local_user(),'new_tab')) { if(feature_enabled(local_user(),'new_tab')) {
$tabs[] = array( $tabs[] = array(
'label' => t('New'), 'label' => t('New'),
'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . ($len_naked_cmd ? '/' : '') . 'new' . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : ''), 'url' => str_replace('/new', '', $cmd) . ($len_naked_cmd ? '/' : '') . 'new' . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : ''),
'sel' => $new_active, 'sel' => $new_active,
'title' => t('Activity Stream - by date'), 'title' => t('Activity Stream - by date'),
'id' => 'activitiy-by-date-tab', 'id' => 'activitiy-by-date-tab',
@ -404,7 +404,7 @@ function network_content(&$a, $update = 0) {
if(feature_enabled(local_user(),'link_tab')) { if(feature_enabled(local_user(),'link_tab')) {
$tabs[] = array( $tabs[] = array(
'label' => t('Shared Links'), 'label' => t('Shared Links'),
'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&bmark=1', 'url' => str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&bmark=1',
'sel' => $bookmarked_active, 'sel' => $bookmarked_active,
'title' => t('Interesting Links'), 'title' => t('Interesting Links'),
'id' => 'shared-links-tab', 'id' => 'shared-links-tab',
@ -415,7 +415,7 @@ function network_content(&$a, $update = 0) {
if(feature_enabled(local_user(),'star_posts')) { if(feature_enabled(local_user(),'star_posts')) {
$tabs[] = array( $tabs[] = array(
'label' => t('Starred'), 'label' => t('Starred'),
'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&star=1', 'url' => str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&star=1',
'sel' => $starred_active, 'sel' => $starred_active,
'title' => t('Favourite Posts'), 'title' => t('Favourite Posts'),
'id' => 'starred-posts-tab', 'id' => 'starred-posts-tab',
@ -547,7 +547,7 @@ function network_content(&$a, $update = 0) {
if($update) if($update)
killme(); killme();
notice( t('No such group') . EOL ); notice( t('No such group') . EOL );
goaway($a->get_baseurl(true) . '/network/0'); goaway('network/0');
// NOTREACHED // NOTREACHED
} }
@ -611,7 +611,7 @@ function network_content(&$a, $update = 0) {
} }
else { else {
notice( t('Invalid contact.') . EOL); notice( t('Invalid contact.') . EOL);
goaway($a->get_baseurl(true) . '/network'); goaway('network');
// NOTREACHED // NOTREACHED
} }
} }

View file

@ -28,7 +28,7 @@ function noscrape_init(&$a) {
$json_info = array( $json_info = array(
'fn' => $a->profile['name'], 'fn' => $a->profile['name'],
'addr' => $a->profile['addr'], 'addr' => $a->profile['addr'],
'nick' => $a->user['nickname'], 'nick' => $which,
'key' => $a->profile['pubkey'], 'key' => $a->profile['pubkey'],
'homepage' => $a->get_baseurl()."/profile/{$which}", 'homepage' => $a->get_baseurl()."/profile/{$which}",
'comm' => (x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY), 'comm' => (x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY),

View file

@ -49,12 +49,12 @@ function notifications_post(&$a) {
intval(local_user()) intval(local_user())
); );
} }
goaway($a->get_baseurl(true) . '/notifications/intros'); goaway('notifications/intros');
} }
if($_POST['submit'] == t('Ignore')) { if($_POST['submit'] == t('Ignore')) {
$r = q("UPDATE `intro` SET `ignore` = 1 WHERE `id` = %d", $r = q("UPDATE `intro` SET `ignore` = 1 WHERE `id` = %d",
intval($intro_id)); intval($intro_id));
goaway($a->get_baseurl(true) . '/notifications/intros'); goaway('notifications/intros');
} }
} }
} }
@ -79,37 +79,37 @@ function notifications_content(&$a) {
$tabs = array( $tabs = array(
array( array(
'label' => t('System'), 'label' => t('System'),
'url'=>$a->get_baseurl(true) . '/notifications/system', 'url'=>'notifications/system',
'sel'=> (($a->argv[1] == 'system') ? 'active' : ''), 'sel'=> (($a->argv[1] == 'system') ? 'active' : ''),
'accesskey' => 'y', 'accesskey' => 'y',
), ),
array( array(
'label' => t('Network'), 'label' => t('Network'),
'url'=>$a->get_baseurl(true) . '/notifications/network', 'url'=>'notifications/network',
'sel'=> (($a->argv[1] == 'network') ? 'active' : ''), 'sel'=> (($a->argv[1] == 'network') ? 'active' : ''),
'accesskey' => 'w', 'accesskey' => 'w',
), ),
array( array(
'label' => t('Personal'), 'label' => t('Personal'),
'url'=>$a->get_baseurl(true) . '/notifications/personal', 'url'=>'notifications/personal',
'sel'=> (($a->argv[1] == 'personal') ? 'active' : ''), 'sel'=> (($a->argv[1] == 'personal') ? 'active' : ''),
'accesskey' => 'r', 'accesskey' => 'r',
), ),
array( array(
'label' => t('Home'), 'label' => t('Home'),
'url' => $a->get_baseurl(true) . '/notifications/home', 'url' => 'notifications/home',
'sel'=> (($a->argv[1] == 'home') ? 'active' : ''), 'sel'=> (($a->argv[1] == 'home') ? 'active' : ''),
'accesskey' => 'h', 'accesskey' => 'h',
), ),
array( array(
'label' => t('Introductions'), 'label' => t('Introductions'),
'url' => $a->get_baseurl(true) . '/notifications/intros', 'url' => 'notifications/intros',
'sel'=> (($a->argv[1] == 'intros') ? 'active' : ''), 'sel'=> (($a->argv[1] == 'intros') ? 'active' : ''),
'accesskey' => 'i', 'accesskey' => 'i',
), ),
/*array( /*array(
'label' => t('Messages'), 'label' => t('Messages'),
'url' => $a->get_baseurl(true) . '/message', 'url' => 'message',
'sel'=> '', 'sel'=> '',
),*/ /*while I can have notifications for messages, this tablist is not place for message page link */ ),*/ /*while I can have notifications for messages, this tablist is not place for message page link */
); );

View file

@ -28,14 +28,14 @@ function p_init($a){
$post = array(); $post = array();
$reshared = diaspora_is_reshare($item[0]["body"]); $reshared = diaspora::is_reshare($item[0]["body"]);
if ($reshared) { if ($reshared) {
$nodename = "reshare"; $nodename = "reshare";
$post["root_diaspora_id"] = $reshared["root_handle"]; $post["root_diaspora_id"] = $reshared["root_handle"];
$post["root_guid"] = $reshared["root_guid"]; $post["root_guid"] = $reshared["root_guid"];
$post["guid"] = $item[0]["guid"]; $post["guid"] = $item[0]["guid"];
$post["diaspora_handle"] = diaspora_handle_from_contact($item[0]["contact-id"]); $post["diaspora_handle"] = diaspora::handle_from_contact($item[0]["contact-id"]);
$post["public"] = (!$item[0]["private"] ? 'true':'false'); $post["public"] = (!$item[0]["private"] ? 'true':'false');
$post["created_at"] = datetime_convert('UTC','UTC',$item[0]["created"]); $post["created_at"] = datetime_convert('UTC','UTC',$item[0]["created"]);
} else { } else {
@ -48,7 +48,7 @@ function p_init($a){
$nodename = "status_message"; $nodename = "status_message";
$post["raw_message"] = str_replace("&", "&amp;", $body); $post["raw_message"] = str_replace("&", "&amp;", $body);
$post["guid"] = $item[0]["guid"]; $post["guid"] = $item[0]["guid"];
$post["diaspora_handle"] = diaspora_handle_from_contact($item[0]["contact-id"]); $post["diaspora_handle"] = diaspora::handle_from_contact($item[0]["contact-id"]);
$post["public"] = (!$item[0]["private"] ? 'true':'false'); $post["public"] = (!$item[0]["private"] ? 'true':'false');
$post["created_at"] = datetime_convert('UTC','UTC',$item[0]["created"]); $post["created_at"] = datetime_convert('UTC','UTC',$item[0]["created"]);
$post["provider_display_name"] = $item[0]["app"]; $post["provider_display_name"] = $item[0]["app"];

View file

@ -80,7 +80,7 @@ function photos_init(&$a) {
$entry = array( $entry = array(
'text' => $album['album'], 'text' => $album['album'],
'total' => $album['total'], 'total' => $album['total'],
'url' => z_root() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album['album']), 'url' => 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album['album']),
'urlencode' => urlencode($album['album']), 'urlencode' => urlencode($album['album']),
'bin2hex' => bin2hex($album['album']) 'bin2hex' => bin2hex($album['album'])
); );
@ -100,7 +100,7 @@ function photos_init(&$a) {
'$recent' => t('Recent Photos'), '$recent' => t('Recent Photos'),
'$albums' => $albums['albums'], '$albums' => $albums['albums'],
'$baseurl' => z_root(), '$baseurl' => z_root(),
'$upload' => array( t('Upload New Photos'), $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/upload'), '$upload' => array( t('Upload New Photos'), 'photos/' . $a->data['user']['nickname'] . '/upload'),
'$can_post' => $can_post '$can_post' => $can_post
)); ));
} }
@ -190,7 +190,7 @@ function photos_post(&$a) {
$album = hex2bin($a->argv[3]); $album = hex2bin($a->argv[3]);
if($album === t('Profile Photos') || $album === 'Contact Photos' || $album === t('Contact Photos')) { if($album === t('Profile Photos') || $album === 'Contact Photos' || $album === t('Contact Photos')) {
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']); goaway($_SESSION['photo_return']);
return; // NOTREACHED return; // NOTREACHED
} }
@ -200,13 +200,13 @@ function photos_post(&$a) {
); );
if(! count($r)) { if(! count($r)) {
notice( t('Album not found.') . EOL); notice( t('Album not found.') . EOL);
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']); goaway($_SESSION['photo_return']);
return; // NOTREACHED return; // NOTREACHED
} }
// Check if the user has responded to a delete confirmation query // Check if the user has responded to a delete confirmation query
if($_REQUEST['canceled']) { if($_REQUEST['canceled']) {
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']); goaway($_SESSION['photo_return']);
} }
/* /*
@ -221,7 +221,7 @@ function photos_post(&$a) {
intval($page_owner_uid) intval($page_owner_uid)
); );
$newurl = str_replace(bin2hex($album),bin2hex($newalbum),$_SESSION['photo_return']); $newurl = str_replace(bin2hex($album),bin2hex($newalbum),$_SESSION['photo_return']);
goaway($a->get_baseurl() . '/' . $newurl); goaway($newurl);
return; // NOTREACHED return; // NOTREACHED
} }
@ -273,7 +273,7 @@ function photos_post(&$a) {
} }
} }
else { else {
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']); goaway($_SESSION['photo_return']);
return; // NOTREACHED return; // NOTREACHED
} }
@ -309,14 +309,14 @@ function photos_post(&$a) {
} }
} }
} }
goaway($a->get_baseurl() . '/photos/' . $a->data['user']['nickname']); goaway('photos/' . $a->data['user']['nickname']);
return; // NOTREACHED return; // NOTREACHED
} }
// Check if the user has responded to a delete confirmation query for a single photo // Check if the user has responded to a delete confirmation query for a single photo
if(($a->argc > 2) && $_REQUEST['canceled']) { if(($a->argc > 2) && $_REQUEST['canceled']) {
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']); goaway($_SESSION['photo_return']);
} }
if(($a->argc > 2) && (x($_POST,'delete')) && ($_POST['delete'] == t('Delete Photo'))) { if(($a->argc > 2) && (x($_POST,'delete')) && ($_POST['delete'] == t('Delete Photo'))) {
@ -379,7 +379,7 @@ function photos_post(&$a) {
} }
} }
goaway($a->get_baseurl() . '/photos/' . $a->data['user']['nickname']); goaway('photos/' . $a->data['user']['nickname']);
return; // NOTREACHED return; // NOTREACHED
} }
@ -488,7 +488,7 @@ function photos_post(&$a) {
$uri = item_new_uri($a->get_hostname(),$page_owner_uid); $uri = item_new_uri($a->get_hostname(),$page_owner_uid);
$arr = array(); $arr = array();
$arr['guid'] = get_guid(32);
$arr['uid'] = $page_owner_uid; $arr['uid'] = $page_owner_uid;
$arr['uri'] = $uri; $arr['uri'] = $uri;
$arr['parent-uri'] = $uri; $arr['parent-uri'] = $uri;
@ -677,7 +677,7 @@ function photos_post(&$a) {
$uri = item_new_uri($a->get_hostname(),$page_owner_uid); $uri = item_new_uri($a->get_hostname(),$page_owner_uid);
$arr = array(); $arr = array();
$arr['guid'] = get_guid(32);
$arr['uid'] = $page_owner_uid; $arr['uid'] = $page_owner_uid;
$arr['uri'] = $uri; $arr['uri'] = $uri;
$arr['parent-uri'] = $uri; $arr['parent-uri'] = $uri;
@ -718,12 +718,6 @@ function photos_post(&$a) {
$item_id = item_store($arr); $item_id = item_store($arr);
if($item_id) { if($item_id) {
//q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d",
// dbesc($a->get_baseurl() . '/display/' . $owner_record['nickname'] . '/' . $item_id),
// intval($page_owner_uid),
// intval($item_id)
//);
proc_run('php',"include/notifier.php","tag","$item_id"); proc_run('php',"include/notifier.php","tag","$item_id");
} }
} }
@ -731,7 +725,7 @@ function photos_post(&$a) {
} }
} }
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']); goaway($_SESSION['photo_return']);
return; // NOTREACHED return; // NOTREACHED
} }
@ -910,6 +904,7 @@ function photos_post(&$a) {
if($lat && $lon) if($lat && $lon)
$arr['coord'] = $lat . ' ' . $lon; $arr['coord'] = $lat . ' ' . $lon;
$arr['guid'] = get_guid(32);
$arr['uid'] = $page_owner_uid; $arr['uid'] = $page_owner_uid;
$arr['uri'] = $uri; $arr['uri'] = $uri;
$arr['parent-uri'] = $uri; $arr['parent-uri'] = $uri;
@ -938,14 +933,6 @@ function photos_post(&$a) {
$item_id = item_store($arr); $item_id = item_store($arr);
//if($item_id) {
// q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d",
// dbesc($a->get_baseurl() . '/display/' . $owner_record['nickname'] . '/' . $item_id),
// intval($page_owner_uid),
// intval($item_id)
// );
//}
if($visible) if($visible)
proc_run('php', "include/notifier.php", 'wall-new', $item_id); proc_run('php', "include/notifier.php", 'wall-new', $item_id);
@ -954,7 +941,7 @@ function photos_post(&$a) {
// addon uploaders should call "killme()" [e.g. exit] within the photo_post_end hook // addon uploaders should call "killme()" [e.g. exit] within the photo_post_end hook
// if they do not wish to be redirected // if they do not wish to be redirected
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']); goaway($_SESSION['photo_return']);
// NOTREACHED // NOTREACHED
} }
@ -1125,7 +1112,7 @@ function photos_content(&$a) {
$uploader = ''; $uploader = '';
$ret = array('post_url' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'], $ret = array('post_url' => 'photos/' . $a->data['user']['nickname'],
'addon_text' => $uploader, 'addon_text' => $uploader,
'default_upload' => true); 'default_upload' => true);
@ -1267,15 +1254,15 @@ function photos_content(&$a) {
else { else {
if(($album !== t('Profile Photos')) && ($album !== 'Contact Photos') && ($album !== t('Contact Photos'))) { if(($album !== t('Profile Photos')) && ($album !== 'Contact Photos') && ($album !== t('Contact Photos'))) {
if($can_post) { if($can_post) {
$edit = array(t('Edit Album'), $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '/edit'); $edit = array(t('Edit Album'), 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '/edit');
} }
} }
} }
if($_GET['order'] === 'posted') if($_GET['order'] === 'posted')
$order = array(t('Show Newest First'), $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album)); $order = array(t('Show Newest First'), 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album));
else else
$order = array(t('Show Oldest First'), $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '?f=&order=posted'); $order = array(t('Show Oldest First'), 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '?f=&order=posted');
$photos = array(); $photos = array();
@ -1301,10 +1288,10 @@ function photos_content(&$a) {
$photos[] = array( $photos[] = array(
'id' => $rr['id'], 'id' => $rr['id'],
'twist' => ' ' . $twist . rand(2,4), 'twist' => ' ' . $twist . rand(2,4),
'link' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id'] 'link' => 'photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id']
. (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''), . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''),
'title' => t('View Photo'), 'title' => t('View Photo'),
'src' => $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['scale'] . '.' .$ext, 'src' => 'photo/' . $rr['resource-id'] . '-' . $rr['scale'] . '.' .$ext,
'alt' => $imgalt_e, 'alt' => $imgalt_e,
'desc'=> $desc_e, 'desc'=> $desc_e,
'ext' => $ext, 'ext' => $ext,
@ -1317,7 +1304,7 @@ function photos_content(&$a) {
'$photos' => $photos, '$photos' => $photos,
'$album' => $album, '$album' => $album,
'$can_post' => $can_post, '$can_post' => $can_post,
'$upload' => array(t('Upload New Photos'), $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/upload/' . bin2hex($album)), '$upload' => array(t('Upload New Photos'), 'photos/' . $a->data['user']['nickname'] . '/upload/' . bin2hex($album)),
'$order' => $order, '$order' => $order,
'$edit' => $edit '$edit' => $edit
)); ));
@ -1384,8 +1371,8 @@ function photos_content(&$a) {
} }
} }
$edit_suffix = ((($cmd === 'edit') && ($can_post)) ? '/edit' : ''); $edit_suffix = ((($cmd === 'edit') && ($can_post)) ? '/edit' : '');
$prevlink = $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''); $prevlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : '');
$nextlink = $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''); $nextlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : '');
} }
@ -1402,14 +1389,14 @@ function photos_content(&$a) {
} }
} }
$album_link = $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($ph[0]['album']); $album_link = 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($ph[0]['album']);
$tools = Null; $tools = Null;
$lock = Null; $lock = Null;
if($can_post && ($ph[0]['uid'] == $owner_uid)) { if($can_post && ($ph[0]['uid'] == $owner_uid)) {
$tools = array( $tools = array(
'edit' => array($a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $datum . (($cmd === 'edit') ? '' : '/edit'), (($cmd === 'edit') ? t('View photo') : t('Edit photo'))), 'edit' => array('photos/' . $a->data['user']['nickname'] . '/image/' . $datum . (($cmd === 'edit') ? '' : '/edit'), (($cmd === 'edit') ? t('View photo') : t('Edit photo'))),
'profile'=>array($a->get_baseurl() . '/profile_photo/use/'.$ph[0]['resource-id'], t('Use as profile photo')), 'profile'=>array('profile_photo/use/'.$ph[0]['resource-id'], t('Use as profile photo')),
); );
// lock // lock
@ -1433,9 +1420,9 @@ function photos_content(&$a) {
$prevlink = array($prevlink, '<div class="icon prev"></div>') ; $prevlink = array($prevlink, '<div class="icon prev"></div>') ;
$photo = array( $photo = array(
'href' => $a->get_baseurl() . '/photo/' . $hires['resource-id'] . '-' . $hires['scale'] . '.' . $phototypes[$hires['type']], 'href' => 'photo/' . $hires['resource-id'] . '-' . $hires['scale'] . '.' . $phototypes[$hires['type']],
'title'=> t('View Full Size'), 'title'=> t('View Full Size'),
'src' => $a->get_baseurl() . '/photo/' . $lores['resource-id'] . '-' . $lores['scale'] . '.' . $phototypes[$lores['type']] . '?f=&_u=' . datetime_convert('','','','ymdhis'), 'src' => 'photo/' . $lores['resource-id'] . '-' . $lores['scale'] . '.' . $phototypes[$lores['type']] . '?f=&_u=' . datetime_convert('','','','ymdhis'),
'height' => $hires['height'], 'height' => $hires['height'],
'width' => $hires['width'], 'width' => $hires['width'],
'album' => $hires['album'], 'album' => $hires['album'],
@ -1522,7 +1509,7 @@ function photos_content(&$a) {
} }
$tags = array(t('Tags: '), $tag_str); $tags = array(t('Tags: '), $tag_str);
if($cmd === 'edit') { if($cmd === 'edit') {
$tags[] = $a->get_baseurl() . '/tagrm/' . $link_item['id']; $tags[] = 'tagrm/' . $link_item['id'];
$tags[] = t('[Remove any tag]'); $tags[] = t('[Remove any tag]');
} }
} }
@ -1693,7 +1680,7 @@ function photos_content(&$a) {
if(((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE))) && ($item['id'] != $item['parent'])) if(((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE))) && ($item['id'] != $item['parent']))
continue; continue;
$redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ; $redirect_url = 'redir/' . $item['cid'] ;
if(local_user() && ($item['contact-uid'] == local_user()) if(local_user() && ($item['contact-uid'] == local_user())
@ -1880,12 +1867,12 @@ function photos_content(&$a) {
$photos[] = array( $photos[] = array(
'id' => $rr['id'], 'id' => $rr['id'],
'twist' => ' ' . $twist . rand(2,4), 'twist' => ' ' . $twist . rand(2,4),
'link' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id'], 'link' => 'photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id'],
'title' => t('View Photo'), 'title' => t('View Photo'),
'src' => $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . ((($rr['scale']) == 6) ? 4 : $rr['scale']) . '.' . $ext, 'src' => 'photo/' . $rr['resource-id'] . '-' . ((($rr['scale']) == 6) ? 4 : $rr['scale']) . '.' . $ext,
'alt' => $alt_e, 'alt' => $alt_e,
'album' => array( 'album' => array(
'link' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($rr['album']), 'link' => 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($rr['album']),
'name' => $name_e, 'name' => $name_e,
'alt' => t('View Album'), 'alt' => t('View Album'),
), ),
@ -1898,7 +1885,7 @@ function photos_content(&$a) {
$o .= replace_macros($tpl, array( $o .= replace_macros($tpl, array(
'$title' => t('Recent Photos'), '$title' => t('Recent Photos'),
'$can_post' => $can_post, '$can_post' => $can_post,
'$upload' => array(t('Upload New Photos'), $a->get_baseurl().'/photos/'.$a->data['user']['nickname'].'/upload'), '$upload' => array(t('Upload New Photos'), 'photos/'.$a->data['user']['nickname'].'/upload'),
'$photos' => $photos, '$photos' => $photos,
)); ));

View file

@ -207,7 +207,7 @@ function ping_init(&$a) {
call_hooks('ping_xmlize', $n); call_hooks('ping_xmlize', $n);
$notsxml = '<note id="%d" href="%s" name="%s" url="%s" photo="%s" date="%s" seen="%s" timestamp="%s" >%s</note>'."\n"; $notsxml = '<note id="%d" href="%s" name="%s" url="%s" photo="%s" date="%s" seen="%s" timestamp="%s" >%s</note>'."\n";
return sprintf ( $notsxml, intval($n['id']), return sprintf ( $notsxml, intval($n['id']),
xmlify($n['href']), xmlify($n['name']), xmlify($n['url']), xmlify($n['photo']), xmlify($n['href']), xmlify(xmlify($n['name'])), xmlify($n['url']), xmlify($n['photo']),
xmlify(relative_date($n['date'])), xmlify($n['seen']), xmlify(strtotime($local_time)), xmlify(relative_date($n['date'])), xmlify($n['seen']), xmlify(strtotime($local_time)),
xmlify($n['message']) xmlify($n['message'])
); );

View file

@ -91,6 +91,7 @@ function poke_init(&$a) {
$arr = array(); $arr = array();
$arr['guid'] = get_guid(32);
$arr['uid'] = $uid; $arr['uid'] = $uid;
$arr['uri'] = $uri; $arr['uri'] = $uri;
$arr['parent-uri'] = (($parent_uri) ? $parent_uri : $uri); $arr['parent-uri'] = (($parent_uri) ? $parent_uri : $uri);

View file

@ -16,7 +16,7 @@ function profiles_init(&$a) {
); );
if(! count($r)) { if(! count($r)) {
notice( t('Profile not found.') . EOL); notice( t('Profile not found.') . EOL);
goaway($a->get_baseurl(true) . '/profiles'); goaway('profiles');
return; // NOTREACHED return; // NOTREACHED
} }
@ -34,9 +34,9 @@ function profiles_init(&$a) {
intval(local_user()) intval(local_user())
); );
if($r) if($r)
info( t('Profile deleted.') . EOL); info(t('Profile deleted.').EOL);
goaway($a->get_baseurl(true) . '/profiles'); goaway('profiles');
return; // NOTREACHED return; // NOTREACHED
} }
@ -73,9 +73,9 @@ function profiles_init(&$a) {
info( t('New profile created.') . EOL); info( t('New profile created.') . EOL);
if(count($r3) == 1) if(count($r3) == 1)
goaway($a->get_baseurl(true) . '/profiles/' . $r3[0]['id']); goaway('profiles/'.$r3[0]['id']);
goaway($a->get_baseurl(true) . '/profiles'); goaway('profiles');
} }
if(($a->argc > 2) && ($a->argv[1] === 'clone')) { if(($a->argc > 2) && ($a->argv[1] === 'clone')) {
@ -116,9 +116,9 @@ function profiles_init(&$a) {
); );
info( t('New profile created.') . EOL); info( t('New profile created.') . EOL);
if(count($r3) == 1) if(count($r3) == 1)
goaway($a->get_baseurl(true) . '/profiles/' . $r3[0]['id']); goaway('profiles/'.$r3[0]['id']);
goaway($a->get_baseurl(true) . '/profiles'); goaway('profiles');
return; // NOTREACHED return; // NOTREACHED
} }
@ -526,6 +526,8 @@ function profile_activity($changed, $value) {
return; return;
$arr = array(); $arr = array();
$arr['guid'] = get_guid(32);
$arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), local_user()); $arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), local_user());
$arr['uid'] = local_user(); $arr['uid'] = local_user();
$arr['contact-id'] = $self[0]['id']; $arr['contact-id'] = $self[0]['id'];
@ -582,15 +584,7 @@ function profile_activity($changed, $value) {
$i = item_store($arr); $i = item_store($arr);
if($i) { if($i) {
// give it a permanent link
//q("update item set plink = '%s' where id = %d",
// dbesc($a->get_baseurl() . '/display/' . $a->user['nickname'] . '/' . $i),
// intval($i)
//);
proc_run('php',"include/notifier.php","activity","$i"); proc_run('php',"include/notifier.php","activity","$i");
} }
} }
@ -786,7 +780,7 @@ function profiles_content(&$a) {
); );
if(count($r)){ if(count($r)){
//Go to the default profile. //Go to the default profile.
goaway($a->get_baseurl(true) . '/profiles/'.$r[0]['id']); goaway('profiles/'.$r[0]['id']);
} }
} }
@ -807,12 +801,12 @@ function profiles_content(&$a) {
foreach($r as $rr) { foreach($r as $rr) {
$o .= replace_macros($tpl, array( $o .= replace_macros($tpl, array(
'$photo' => $a->get_cached_avatar_image($rr['thumb']), '$photo' => $a->remove_baseurl($rr['thumb']),
'$id' => $rr['id'], '$id' => $rr['id'],
'$alt' => t('Profile Image'), '$alt' => t('Profile Image'),
'$profile_name' => $rr['profile-name'], '$profile_name' => $rr['profile-name'],
'$visible' => (($rr['is-default']) ? '<strong>' . t('visible to everybody') . '</strong>' '$visible' => (($rr['is-default']) ? '<strong>' . t('visible to everybody') . '</strong>'
: '<a href="' . $a->get_baseurl(true) . '/profperm/' . $rr['id'] . '" />' . t('Edit visibility') . '</a>') : '<a href="'.'profperm/'.$rr['id'].'" />' . t('Edit visibility') . '</a>')
)); ));
} }
} }

View file

@ -53,7 +53,7 @@ function receive_post(&$a) {
logger('mod-diaspora: message is okay', LOGGER_DEBUG); logger('mod-diaspora: message is okay', LOGGER_DEBUG);
$msg = diaspora_decode($importer,$xml); $msg = diaspora::decode($importer,$xml);
logger('mod-diaspora: decoded', LOGGER_DEBUG); logger('mod-diaspora: decoded', LOGGER_DEBUG);
@ -65,10 +65,11 @@ function receive_post(&$a) {
logger('mod-diaspora: dispatching', LOGGER_DEBUG); logger('mod-diaspora: dispatching', LOGGER_DEBUG);
$ret = 0; $ret = 0;
if($public) if($public) {
diaspora_dispatch_public($msg); diaspora::dispatch_public($msg);
else } else {
$ret = diaspora_dispatch($importer,$msg); $ret = diaspora::dispatch($importer,$msg);
}
http_status_exit(($ret) ? $ret : 200); http_status_exit(($ret) ? $ret : 200);
// NOTREACHED // NOTREACHED

View file

@ -84,7 +84,7 @@ function salmon_post(&$a) {
// decode the data // decode the data
$data = base64url_decode($data); $data = base64url_decode($data);
$author = ostatus_salmon_author($data,$importer); $author = ostatus::salmon_author($data,$importer);
$author_link = $author["author-link"]; $author_link = $author["author-link"];
if(! $author_link) { if(! $author_link) {
@ -181,7 +181,7 @@ function salmon_post(&$a) {
$contact_rec = ((count($r)) ? $r[0] : null); $contact_rec = ((count($r)) ? $r[0] : null);
ostatus_import($data,$importer,$contact_rec, $hub); ostatus::import($data,$importer,$contact_rec, $hub);
http_status_exit(200); http_status_exit(200);
} }

View file

@ -147,7 +147,7 @@ function search_content(&$a) {
} }
$o .= search($search,'search-box','/search',((local_user()) ? true : false), false); $o .= search($search,'search-box','search',((local_user()) ? true : false), false);
if(strpos($search,'#') === 0) { if(strpos($search,'#') === 0) {
$tag = true; $tag = true;
@ -217,11 +217,10 @@ function search_content(&$a) {
FROM `item` FROM `item`
INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND NOT `contact`.`blocked` AND NOT `contact`.`pending` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND NOT `contact`.`blocked` AND NOT `contact`.`pending`
WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated` WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
AND (`item`.`uid` = 0 OR (`item`.`uid` = %s AND (`item`.`private` OR NOT `item`.`network` IN ('%s', '%s', '%s')))) AND (`item`.`uid` = 0 OR (`item`.`uid` = %s AND NOT `item`.`global`))
$sql_extra $sql_extra
GROUP BY `item`.`uri` ORDER BY `item`.`id` DESC LIMIT %d , %d ", GROUP BY `item`.`uri` ORDER BY `item`.`id` DESC LIMIT %d , %d ",
intval(local_user()), dbesc(NETWORK_DFRN), dbesc(NETWORK_OSTATUS), dbesc(NETWORK_DIASPORA), intval(local_user()), intval($a->pager['start']), intval($a->pager['itemspage']));
intval($a->pager['start']), intval($a->pager['itemspage']));
} }
if(! count($r)) { if(! count($r)) {

View file

@ -1,5 +1,6 @@
<?php <?php
require_once('include/group.php');
function get_theme_config_file($theme){ function get_theme_config_file($theme){
$a = get_app(); $a = get_app();
@ -39,7 +40,7 @@ function settings_init(&$a) {
$tabs = array( $tabs = array(
array( array(
'label' => t('Account'), 'label' => t('Account'),
'url' => $a->get_baseurl(true).'/settings', 'url' => 'settings',
'selected' => (($a->argc == 1) && ($a->argv[0] === 'settings')?'active':''), 'selected' => (($a->argc == 1) && ($a->argv[0] === 'settings')?'active':''),
'accesskey' => 'o', 'accesskey' => 'o',
), ),
@ -48,7 +49,7 @@ function settings_init(&$a) {
if(get_features()) { if(get_features()) {
$tabs[] = array( $tabs[] = array(
'label' => t('Additional features'), 'label' => t('Additional features'),
'url' => $a->get_baseurl(true).'/settings/features', 'url' => 'settings/features',
'selected' => (($a->argc > 1) && ($a->argv[1] === 'features') ? 'active' : ''), 'selected' => (($a->argc > 1) && ($a->argv[1] === 'features') ? 'active' : ''),
'accesskey' => 't', 'accesskey' => 't',
); );
@ -56,49 +57,49 @@ function settings_init(&$a) {
$tabs[] = array( $tabs[] = array(
'label' => t('Display'), 'label' => t('Display'),
'url' => $a->get_baseurl(true).'/settings/display', 'url' => 'settings/display',
'selected' => (($a->argc > 1) && ($a->argv[1] === 'display')?'active':''), 'selected' => (($a->argc > 1) && ($a->argv[1] === 'display')?'active':''),
'accesskey' => 'i', 'accesskey' => 'i',
); );
$tabs[] = array( $tabs[] = array(
'label' => t('Social Networks'), 'label' => t('Social Networks'),
'url' => $a->get_baseurl(true).'/settings/connectors', 'url' => 'settings/connectors',
'selected' => (($a->argc > 1) && ($a->argv[1] === 'connectors')?'active':''), 'selected' => (($a->argc > 1) && ($a->argv[1] === 'connectors')?'active':''),
'accesskey' => 'w', 'accesskey' => 'w',
); );
$tabs[] = array( $tabs[] = array(
'label' => t('Plugins'), 'label' => t('Plugins'),
'url' => $a->get_baseurl(true).'/settings/addon', 'url' => 'settings/addon',
'selected' => (($a->argc > 1) && ($a->argv[1] === 'addon')?'active':''), 'selected' => (($a->argc > 1) && ($a->argv[1] === 'addon')?'active':''),
'accesskey' => 'l', 'accesskey' => 'l',
); );
$tabs[] = array( $tabs[] = array(
'label' => t('Delegations'), 'label' => t('Delegations'),
'url' => $a->get_baseurl(true).'/delegate', 'url' => 'delegate',
'selected' => (($a->argc == 1) && ($a->argv[0] === 'delegate')?'active':''), 'selected' => (($a->argc == 1) && ($a->argv[0] === 'delegate')?'active':''),
'accesskey' => 'd', 'accesskey' => 'd',
); );
$tabs[] = array( $tabs[] = array(
'label' => t('Connected apps'), 'label' => t('Connected apps'),
'url' => $a->get_baseurl(true) . '/settings/oauth', 'url' => 'settings/oauth',
'selected' => (($a->argc > 1) && ($a->argv[1] === 'oauth')?'active':''), 'selected' => (($a->argc > 1) && ($a->argv[1] === 'oauth')?'active':''),
'accesskey' => 'b', 'accesskey' => 'b',
); );
$tabs[] = array( $tabs[] = array(
'label' => t('Export personal data'), 'label' => t('Export personal data'),
'url' => $a->get_baseurl(true) . '/uexport', 'url' => 'uexport',
'selected' => (($a->argc == 1) && ($a->argv[0] === 'uexport')?'active':''), 'selected' => (($a->argc == 1) && ($a->argv[0] === 'uexport')?'active':''),
'accesskey' => 'e', 'accesskey' => 'e',
); );
$tabs[] = array( $tabs[] = array(
'label' => t('Remove account'), 'label' => t('Remove account'),
'url' => $a->get_baseurl(true) . '/removeme', 'url' => 'removeme',
'selected' => (($a->argc == 1) && ($a->argv[0] === 'removeme')?'active':''), 'selected' => (($a->argc == 1) && ($a->argv[0] === 'removeme')?'active':''),
'accesskey' => 'r', 'accesskey' => 'r',
); );
@ -199,6 +200,7 @@ function settings_post(&$a) {
if(x($_POST, 'general-submit')) { if(x($_POST, 'general-submit')) {
set_pconfig(local_user(), 'system', 'no_intelligent_shortening', intval($_POST['no_intelligent_shortening'])); set_pconfig(local_user(), 'system', 'no_intelligent_shortening', intval($_POST['no_intelligent_shortening']));
set_pconfig(local_user(), 'system', 'ostatus_autofriend', intval($_POST['snautofollow'])); set_pconfig(local_user(), 'system', 'ostatus_autofriend', intval($_POST['snautofollow']));
set_pconfig(local_user(), 'ostatus', 'default_group', $_POST['group-selection']);
set_pconfig(local_user(), 'ostatus', 'legacy_contact', $_POST['legacy_contact']); set_pconfig(local_user(), 'ostatus', 'legacy_contact', $_POST['legacy_contact']);
} elseif(x($_POST, 'imap-submit')) { } elseif(x($_POST, 'imap-submit')) {
@ -342,7 +344,7 @@ function settings_post(&$a) {
); );
call_hooks('display_settings_post', $_POST); call_hooks('display_settings_post', $_POST);
goaway($a->get_baseurl(true) . '/settings/display' ); goaway('settings/display' );
return; // NOTREACHED return; // NOTREACHED
} }
@ -351,7 +353,7 @@ function settings_post(&$a) {
if (x($_POST,'resend_relocate')) { if (x($_POST,'resend_relocate')) {
proc_run('php', 'include/notifier.php', 'relocate', local_user()); proc_run('php', 'include/notifier.php', 'relocate', local_user());
info(t("Relocate message has been send to your contacts")); info(t("Relocate message has been send to your contacts"));
goaway($a->get_baseurl(true) . '/settings'); goaway('settings');
} }
call_hooks('settings_post', $_POST); call_hooks('settings_post', $_POST);
@ -627,7 +629,7 @@ function settings_post(&$a) {
} }
goaway($a->get_baseurl(true) . '/settings' ); goaway('settings' );
return; // NOTREACHED return; // NOTREACHED
} }
@ -797,8 +799,11 @@ function settings_content(&$a) {
$settings_connectors .= '<span class="field_help">'.t('If you receive a message from an unknown OStatus user, this option decides what to do. If it is checked, a new contact will be created for every unknown user.').'</span>'; $settings_connectors .= '<span class="field_help">'.t('If you receive a message from an unknown OStatus user, this option decides what to do. If it is checked, a new contact will be created for every unknown user.').'</span>';
$settings_connectors .= '</div>'; $settings_connectors .= '</div>';
$default_group = get_pconfig(local_user(), 'ostatus', 'default_group');
$legacy_contact = get_pconfig(local_user(), 'ostatus', 'legacy_contact'); $legacy_contact = get_pconfig(local_user(), 'ostatus', 'legacy_contact');
$settings_connectors .= mini_group_select(local_user(), $default_group, t("Default group for OStatus contacts"));
if ($legacy_contact != "") if ($legacy_contact != "")
$a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL='.$a->get_baseurl().'/ostatus_subscribe?url='.urlencode($legacy_contact).'">'; $a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL='.$a->get_baseurl().'/ostatus_subscribe?url='.urlencode($legacy_contact).'">';
@ -1152,7 +1157,7 @@ function settings_content(&$a) {
info( t('Profile is <strong>not published</strong>.') . EOL ); info( t('Profile is <strong>not published</strong>.') . EOL );
//$subdir = ((strlen($a->get_path())) ? '<br />' . t('or') . ' ' . $a->get_baseurl(true) . '/profile/' . $nickname : ''); //$subdir = ((strlen($a->get_path())) ? '<br />' . t('or') . ' ' . 'profile/' . $nickname : '');
$tpl_addr = get_markup_template("settings_nick_set.tpl"); $tpl_addr = get_markup_template("settings_nick_set.tpl");

View file

@ -103,10 +103,11 @@ EOT;
$bodyverb = t('%1$s is following %2$s\'s %3$s'); $bodyverb = t('%1$s is following %2$s\'s %3$s');
if(! isset($bodyverb)) if(! isset($bodyverb))
return; return;
$arr = array(); $arr = array();
$arr['guid'] = get_guid(32);
$arr['uri'] = $uri; $arr['uri'] = $uri;
$arr['uid'] = $owner_uid; $arr['uid'] = $owner_uid;
$arr['contact-id'] = $contact['id']; $arr['contact-id'] = $contact['id'];
@ -123,7 +124,7 @@ EOT;
$arr['author-name'] = $contact['name']; $arr['author-name'] = $contact['name'];
$arr['author-link'] = $contact['url']; $arr['author-link'] = $contact['url'];
$arr['author-avatar'] = $contact['thumb']; $arr['author-avatar'] = $contact['thumb'];
$ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]'; $ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]';
$alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]'; $alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
$plink = '[url=' . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]'; $plink = '[url=' . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]';

View file

@ -95,12 +95,13 @@ EOT;
$bodyverb = t('%1$s tagged %2$s\'s %3$s with %4$s'); $bodyverb = t('%1$s tagged %2$s\'s %3$s with %4$s');
if(! isset($bodyverb)) if(! isset($bodyverb))
return; return;
$termlink = html_entity_decode('&#x2317;') . '[url=' . $a->get_baseurl() . '/search?tag=' . urlencode($term) . ']'. $term . '[/url]'; $termlink = html_entity_decode('&#x2317;') . '[url=' . $a->get_baseurl() . '/search?tag=' . urlencode($term) . ']'. $term . '[/url]';
$arr = array(); $arr = array();
$arr['guid'] = get_guid(32);
$arr['uri'] = $uri; $arr['uri'] = $uri;
$arr['uid'] = $owner_uid; $arr['uid'] = $owner_uid;
$arr['contact-id'] = $contact['id']; $arr['contact-id'] = $contact['id'];
@ -115,7 +116,7 @@ EOT;
$arr['author-name'] = $contact['name']; $arr['author-name'] = $contact['name'];
$arr['author-link'] = $contact['url']; $arr['author-link'] = $contact['url'];
$arr['author-avatar'] = $contact['thumb']; $arr['author-avatar'] = $contact['thumb'];
$ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]'; $ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]';
$alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]'; $alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
$plink = '[url=' . $item['plink'] . ']' . $post_type . '[/url]'; $plink = '[url=' . $item['plink'] . ']' . $post_type . '[/url]';

View file

@ -6,54 +6,6 @@ function uexport_init(&$a){
require_once("mod/settings.php"); require_once("mod/settings.php");
settings_init($a); settings_init($a);
/*
$tabs = array(
array(
'label' => t('Account settings'),
'url' => $a->get_baseurl(true).'/settings',
'selected' => '',
),
array(
'label' => t('Display settings'),
'url' => $a->get_baseurl(true).'/settings/display',
'selected' =>'',
),
array(
'label' => t('Connector settings'),
'url' => $a->get_baseurl(true).'/settings/connectors',
'selected' => '',
),
array(
'label' => t('Plugin settings'),
'url' => $a->get_baseurl(true).'/settings/addon',
'selected' => '',
),
array(
'label' => t('Connected apps'),
'url' => $a->get_baseurl(true) . '/settings/oauth',
'selected' => '',
),
array(
'label' => t('Export personal data'),
'url' => $a->get_baseurl(true) . '/uexport',
'selected' => 'active'
),
array(
'label' => t('Remove account'),
'url' => $a->get_baseurl(true) . '/removeme',
'selected' => ''
)
);
$tabtpl = get_markup_template("generic_links_widget.tpl");
$a->page['aside'] = replace_macros($tabtpl, array(
'$title' => t('Settings'),
'$class' => 'settings-widget',
'$items' => $tabs,
));
*/
} }
function uexport_content(&$a){ function uexport_content(&$a){
@ -74,8 +26,8 @@ function uexport_content(&$a){
* list of array( 'link url', 'link text', 'help text' ) * list of array( 'link url', 'link text', 'help text' )
*/ */
$options = array( $options = array(
array('/uexport/account',t('Export account'),t('Export your account info and contacts. Use this to make a backup of your account and/or to move it to another server.')), array('uexport/account',t('Export account'),t('Export your account info and contacts. Use this to make a backup of your account and/or to move it to another server.')),
array('/uexport/backup',t('Export all'),t('Export your accout info, contacts and all your items as json. Could be a very big file, and could take a lot of time. Use this to make a full backup of your account (photos are not exported)')), array('uexport/backup',t('Export all'),t('Export your accout info, contacts and all your items as json. Could be a very big file, and could take a lot of time. Use this to make a full backup of your account (photos are not exported)')),
); );
call_hooks('uexport_options', $options); call_hooks('uexport_options', $options);
@ -153,9 +105,9 @@ function uexport_account($a){
'version' => FRIENDICA_VERSION, 'version' => FRIENDICA_VERSION,
'schema' => DB_UPDATE_VERSION, 'schema' => DB_UPDATE_VERSION,
'baseurl' => $a->get_baseurl(), 'baseurl' => $a->get_baseurl(),
'user' => $user, 'user' => $user,
'contact' => $contact, 'contact' => $contact,
'profile' => $profile, 'profile' => $profile,
'photo' => $photo, 'photo' => $photo,
'pconfig' => $pconfig, 'pconfig' => $pconfig,
'group' => $group, 'group' => $group,
@ -171,8 +123,8 @@ function uexport_account($a){
* echoes account data and items as separated json, one per line * echoes account data and items as separated json, one per line
*/ */
function uexport_all(&$a) { function uexport_all(&$a) {
uexport_account($a); uexport_account($a);
echo "\n"; echo "\n";
$r = q("SELECT count(*) as `total` FROM `item` WHERE `uid` = %d ", $r = q("SELECT count(*) as `total` FROM `item` WHERE `uid` = %d ",

View file

@ -50,7 +50,7 @@ class Item extends BaseObject {
$this->writable = ($this->get_data_value('writable') || $this->get_data_value('self')); $this->writable = ($this->get_data_value('writable') || $this->get_data_value('self'));
$ssl_state = ((local_user()) ? true : false); $ssl_state = ((local_user()) ? true : false);
$this->redirect_url = $a->get_baseurl($ssl_state) . '/redir/' . $this->get_data_value('cid') ; $this->redirect_url = 'redir/' . $this->get_data_value('cid') ;
if(get_config('system','thread_allow') && $a->theme_thread_allow && !$this->is_toplevel()) if(get_config('system','thread_allow') && $a->theme_thread_allow && !$this->is_toplevel())
$this->threaded = true; $this->threaded = true;
@ -119,9 +119,9 @@ class Item extends BaseObject {
$shareable = ((($conv->get_profile_owner() == local_user()) && ($item['private'] != 1)) ? true : false); $shareable = ((($conv->get_profile_owner() == local_user()) && ($item['private'] != 1)) ? true : false);
if(local_user() && link_compare($a->contact['url'],$item['author-link'])) { if(local_user() && link_compare($a->contact['url'],$item['author-link'])) {
if ($item["event-id"] != 0) if ($item["event-id"] != 0)
$edpost = array($a->get_baseurl($ssl_state)."/events/event/".$item['event-id'], t("Edit")); $edpost = array("events/event/".$item['event-id'], t("Edit"));
else else
$edpost = array($a->get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit")); $edpost = array("editpost/".$item['id'], t("Edit"));
} else } else
$edpost = false; $edpost = false;
if(($this->get_data_value('uid') == local_user()) || $this->is_visiting()) if(($this->get_data_value('uid') == local_user()) || $this->is_visiting())
@ -154,13 +154,13 @@ class Item extends BaseObject {
if(($normalised != 'mailbox') && (x($a->contacts,$normalised))) if(($normalised != 'mailbox') && (x($a->contacts,$normalised)))
$profile_avatar = $a->contacts[$normalised]['thumb']; $profile_avatar = $a->contacts[$normalised]['thumb'];
else else
$profile_avatar = (((strlen($item['author-avatar'])) && $diff_author) ? $item['author-avatar'] : $a->get_cached_avatar_image($this->get_data_value('thumb'))); $profile_avatar = (((strlen($item['author-avatar'])) && $diff_author) ? $item['author-avatar'] : $a->remove_baseurl($this->get_data_value('thumb')));
$locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => ''); $locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => '');
call_hooks('render_location',$locate); call_hooks('render_location',$locate);
$location = ((strlen($locate['html'])) ? $locate['html'] : render_location_dummy($locate)); $location = ((strlen($locate['html'])) ? $locate['html'] : render_location_dummy($locate));
$searchpath = $a->get_baseurl()."/search?tag="; $searchpath = "search?tag=";
$tags=array(); $tags=array();
$hashtags = array(); $hashtags = array();
$mentions = array(); $mentions = array();
@ -324,7 +324,7 @@ class Item extends BaseObject {
// Diaspora isn't able to do likes on comments - but red does // Diaspora isn't able to do likes on comments - but red does
if (($item["item_network"] == NETWORK_DIASPORA) AND ($indent == 'comment') AND if (($item["item_network"] == NETWORK_DIASPORA) AND ($indent == 'comment') AND
!diaspora_is_redmatrix($item["owner-link"]) AND isset($buttons["like"])) !diaspora::is_redmatrix($item["owner-link"]) AND isset($buttons["like"]))
unset($buttons["like"]); unset($buttons["like"]);
// Diaspora doesn't has multithreaded comments // Diaspora doesn't has multithreaded comments
@ -703,9 +703,9 @@ class Item extends BaseObject {
'$parent' => $this->get_id(), '$parent' => $this->get_id(),
'$qcomment' => $qcomment, '$qcomment' => $qcomment,
'$profile_uid' => $conv->get_profile_owner(), '$profile_uid' => $conv->get_profile_owner(),
'$mylink' => $a->contact['url'], '$mylink' => $a->remove_baseurl($a->contact['url']),
'$mytitle' => t('This is you'), '$mytitle' => t('This is you'),
'$myphoto' => $a->contact['thumb'], '$myphoto' => $a->remove_baseurl($a->contact['thumb']),
'$comment' => t('Comment'), '$comment' => t('Comment'),
'$submit' => t('Submit'), '$submit' => t('Submit'),
'$edbold' => t('Bold'), '$edbold' => t('Bold'),

94
util/createdoxygen.php Normal file
View file

@ -0,0 +1,94 @@
#!/usr/bin/php
<?php
/**
* @file util/createdoxygen.php
* @brief Adds a doxygen header to functions
*/
if (count($_SERVER["argv"]) < 2)
die("usage: createdoxygen.php file\n");
$file = $_SERVER["argv"][1];
$data = file_get_contents($file);
$lines = explode("\n", $data);
$previous = "";
foreach ($lines AS $line) {
$line = rtrim(trim($line, "\r"));
if (strstr(strtolower($line), "function")) {
$detect = strtolower(trim($line));
$detect = implode(" ", explode(" ", $detect));
$found = false;
if (substr($detect, 0, 9) == "function ")
$found = true;
if (substr($detect, 0, 17) == "private function ")
$found = true;
if (substr($detect, 0, 23) == "public static function ")
$found = true;
if (substr($detect, 0, 10) == "function (")
$found = false;
if ($found and (trim($previous) == "*/"))
$found = false;
if ($found and !strstr($detect, "{"))
$found = false;
if ($found) {
echo add_documentation($line);
}
}
echo $line."\n";
$previous = $line;
}
/**
* @brief Adds a doxygen header
*
* @param string $line The current line of the document
*
* @return string added doxygen header
*/
function add_documentation($line) {
$trimmed = ltrim($line);
$length = strlen($line) - strlen($trimmed);
$space = substr($line, 0, $length);
$block = $space."/**\n".
$space." * @brief \n".
$space." *\n"; /**/
$left = strpos($line, "(");
$line = substr($line, $left + 1);
$right = strpos($line, ")");
$line = trim(substr($line, 0, $right));
if ($line != "") {
$parameters = explode(",", $line);
foreach ($parameters AS $parameter) {
$parameter = trim($parameter);
$splitted = explode("=", $parameter);
$block .= $space." * @param ".trim($splitted[0], "& ")."\n";
}
if (count($parameters) > 0)
$block .= $space." *\n";
}
$block .= $space." * @return \n".
$space." */\n";
return $block;
}
?>

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,32 @@
/* General style rules .*/ /* General style rules .*/
.pull-right { float: right } .pull-right { float: right }
/* General designing elements */
.btn {
outline: none;
-moz-box-shadow: inset 0px 1px 0px 0px #ffffff;
-webkit-box-shadow: inset 0px 1px 0px 0px #ffffff;
box-shadow: inset 0px 1px 0px 0px #ffffff;
background-color: #ededed;
text-indent: 0;
border: 1px solid #dcdcdc;
display: inline-block;
color: #777777;
padding: 5px 10px;
text-align: center;
}
a.btn, a.btn:hover {
text-decoration: none;
color: inherit;
}
.menu-popup .divider {
height: 1px;
margin: 3px 0;
overflow: hidden;
background-color: #2d2d2d;
}
/* List of social Networks */ /* List of social Networks */
img.connector, img.connector-disabled { img.connector, img.connector-disabled {
height: 40px; height: 40px;
@ -277,20 +303,20 @@ a {
margin: 10px 0 10px; margin: 10px 0 10px;
} }
.version-match { .version-match {
font-weight: bold; font-weight: bold;
color: #00a700; color: #00a700;
} }
.federation-graph { .federation-graph {
width: 400px; width: 400px;
height: 400px; height: 400px;
float: right; float: right;
margin: 20px; margin: 20px;
} }
.federation-network-graph { .federation-network-graph {
width: 240px; width: 240px;
height: 240px; height: 240px;
float: left; float: left;
margin: 20px; margin: 20px;
} }
ul.federation-stats, ul.federation-stats,
ul.credits { ul.credits {
@ -302,10 +328,10 @@ ul.credits li {
width: 240px; width: 240px;
} }
table#federation-stats { table#federation-stats {
width: 100%; width: 100%;
} }
td.federation-data { td.federation-data {
border-bottom: 1px solid #000; border-bottom: 1px solid #000;
} }
.contact-entry-photo img { .contact-entry-photo img {
@ -329,25 +355,48 @@ td.federation-data {
} }
.crepair-label { .crepair-label {
margin-top: 10px; margin-top: 10px;
float: left; float: left;
width: 250px; width: 250px;
} }
.crepair-input { .crepair-input {
margin-top: 10px; margin-top: 10px;
float: left; float: left;
width: 200px; width: 200px;
} }
.renderinfo { .renderinfo {
clear: both; clear: both;
} }
.p-addr { .p-addr {
clear: both; clear: both;
} }
#live-community { #live-community {
clear: both; clear: both;
}
/* contact-edit */
#contact-edit-status-wrapper {
border: 1px solid;
padding: 10px;
}
#contact-edit-actions {
float: right;
display: inline-block;
position: relative;
}
#contact-edit-actions > .menu-popup {
right: 0;
left: auto;
}
#contact-edit-settings-label:after {
content: ' »';
}
#contact-edit-settings {
display: none;
} }

View file

@ -16,7 +16,7 @@ msgstr ""
"Project-Id-Version: friendica\n" "Project-Id-Version: friendica\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-01-24 06:49+0100\n" "POT-Creation-Date: 2016-01-24 06:49+0100\n"
"PO-Revision-Date: 2016-01-30 08:43+0000\n" "PO-Revision-Date: 2016-02-16 10:29+0000\n"
"Last-Translator: Sandro Santilli <strk@keybit.net>\n" "Last-Translator: Sandro Santilli <strk@keybit.net>\n"
"Language-Team: Italian (http://www.transifex.com/Friendica/friendica/language/it/)\n" "Language-Team: Italian (http://www.transifex.com/Friendica/friendica/language/it/)\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
@ -41,8 +41,8 @@ msgstr "Forum"
#, php-format #, php-format
msgid "%d contact edited." msgid "%d contact edited."
msgid_plural "%d contacts edited." msgid_plural "%d contacts edited."
msgstr[0] "" msgstr[0] "%d contatto modificato."
msgstr[1] "" msgstr[1] "%d contatti modificati"
#: mod/contacts.php:159 mod/contacts.php:383 #: mod/contacts.php:159 mod/contacts.php:383
msgid "Could not access contact record." msgid "Could not access contact record."
@ -887,7 +887,7 @@ msgstr "Rimuovi"
#: mod/ostatus_subscribe.php:14 #: mod/ostatus_subscribe.php:14
msgid "Subscribing to OStatus contacts" msgid "Subscribing to OStatus contacts"
msgstr "" msgstr "Iscrizione a contatti OStatus"
#: mod/ostatus_subscribe.php:25 #: mod/ostatus_subscribe.php:25
msgid "No contact provided." msgid "No contact provided."
@ -1943,7 +1943,7 @@ msgstr "Ispeziona Coda di invio"
#: mod/admin.php:163 mod/admin.php:354 #: mod/admin.php:163 mod/admin.php:354
msgid "Federation Statistics" msgid "Federation Statistics"
msgstr "" msgstr "Statistiche sulla Federazione"
#: mod/admin.php:177 mod/admin.php:188 mod/admin.php:1792 #: mod/admin.php:177 mod/admin.php:188 mod/admin.php:1792
msgid "Logs" msgid "Logs"
@ -1951,7 +1951,7 @@ msgstr "Log"
#: mod/admin.php:178 mod/admin.php:1859 #: mod/admin.php:178 mod/admin.php:1859
msgid "View Logs" msgid "View Logs"
msgstr "" msgstr "Vedi i log"
#: mod/admin.php:179 #: mod/admin.php:179
msgid "probe address" msgid "probe address"
@ -1982,7 +1982,7 @@ msgid ""
"This page offers you some numbers to the known part of the federated social " "This page offers you some numbers to the known part of the federated social "
"network your Friendica node is part of. These numbers are not complete but " "network your Friendica node is part of. These numbers are not complete but "
"only reflect the part of the network your node is aware of." "only reflect the part of the network your node is aware of."
msgstr "" msgstr "Questa pagina offre alcuni numeri riguardo la porzione del social network federato di cui il tuo nodo Friendica fa parte. Questi numeri non sono completi ma riflettono esclusivamente la porzione di rete di cui il tuo nodo e' a conoscenza."
#: mod/admin.php:348 #: mod/admin.php:348
msgid "" msgid ""

View file

@ -8,8 +8,8 @@ function string_plural_select_it($n){
$a->strings["Network:"] = "Rete:"; $a->strings["Network:"] = "Rete:";
$a->strings["Forum"] = "Forum"; $a->strings["Forum"] = "Forum";
$a->strings["%d contact edited."] = array( $a->strings["%d contact edited."] = array(
0 => "", 0 => "%d contatto modificato.",
1 => "", 1 => "%d contatti modificati",
); );
$a->strings["Could not access contact record."] = "Non è possibile accedere al contatto."; $a->strings["Could not access contact record."] = "Non è possibile accedere al contatto.";
$a->strings["Could not locate selected profile."] = "Non riesco a trovare il profilo selezionato."; $a->strings["Could not locate selected profile."] = "Non riesco a trovare il profilo selezionato.";
@ -186,7 +186,7 @@ $a->strings["Tag removed"] = "Tag rimosso";
$a->strings["Remove Item Tag"] = "Rimuovi il tag"; $a->strings["Remove Item Tag"] = "Rimuovi il tag";
$a->strings["Select a tag to remove: "] = "Seleziona un tag da rimuovere: "; $a->strings["Select a tag to remove: "] = "Seleziona un tag da rimuovere: ";
$a->strings["Remove"] = "Rimuovi"; $a->strings["Remove"] = "Rimuovi";
$a->strings["Subscribing to OStatus contacts"] = ""; $a->strings["Subscribing to OStatus contacts"] = "Iscrizione a contatti OStatus";
$a->strings["No contact provided."] = "Nessun contatto disponibile."; $a->strings["No contact provided."] = "Nessun contatto disponibile.";
$a->strings["Couldn't fetch information for contact."] = "Non è stato possibile recuperare le informazioni del contatto."; $a->strings["Couldn't fetch information for contact."] = "Non è stato possibile recuperare le informazioni del contatto.";
$a->strings["Couldn't fetch friends for contact."] = "Non è stato possibile recuperare gli amici del contatto."; $a->strings["Couldn't fetch friends for contact."] = "Non è stato possibile recuperare gli amici del contatto.";
@ -419,16 +419,16 @@ $a->strings["Themes"] = "Temi";
$a->strings["Additional features"] = "Funzionalità aggiuntive"; $a->strings["Additional features"] = "Funzionalità aggiuntive";
$a->strings["DB updates"] = "Aggiornamenti Database"; $a->strings["DB updates"] = "Aggiornamenti Database";
$a->strings["Inspect Queue"] = "Ispeziona Coda di invio"; $a->strings["Inspect Queue"] = "Ispeziona Coda di invio";
$a->strings["Federation Statistics"] = ""; $a->strings["Federation Statistics"] = "Statistiche sulla Federazione";
$a->strings["Logs"] = "Log"; $a->strings["Logs"] = "Log";
$a->strings["View Logs"] = ""; $a->strings["View Logs"] = "Vedi i log";
$a->strings["probe address"] = "controlla indirizzo"; $a->strings["probe address"] = "controlla indirizzo";
$a->strings["check webfinger"] = "verifica webfinger"; $a->strings["check webfinger"] = "verifica webfinger";
$a->strings["Admin"] = "Amministrazione"; $a->strings["Admin"] = "Amministrazione";
$a->strings["Plugin Features"] = "Impostazioni Plugins"; $a->strings["Plugin Features"] = "Impostazioni Plugins";
$a->strings["diagnostics"] = "diagnostiche"; $a->strings["diagnostics"] = "diagnostiche";
$a->strings["User registrations waiting for confirmation"] = "Utenti registrati in attesa di conferma"; $a->strings["User registrations waiting for confirmation"] = "Utenti registrati in attesa di conferma";
$a->strings["This page offers you some numbers to the known part of the federated social network your Friendica node is part of. These numbers are not complete but only reflect the part of the network your node is aware of."] = ""; $a->strings["This page offers you some numbers to the known part of the federated social network your Friendica node is part of. These numbers are not complete but only reflect the part of the network your node is aware of."] = "Questa pagina offre alcuni numeri riguardo la porzione del social network federato di cui il tuo nodo Friendica fa parte. Questi numeri non sono completi ma riflettono esclusivamente la porzione di rete di cui il tuo nodo e' a conoscenza.";
$a->strings["The <em>Auto Discovered Contact Directory</em> feature is not enabled, it will improve the data displayed here."] = ""; $a->strings["The <em>Auto Discovered Contact Directory</em> feature is not enabled, it will improve the data displayed here."] = "";
$a->strings["Administration"] = "Amministrazione"; $a->strings["Administration"] = "Amministrazione";
$a->strings["Currently this node is aware of %d nodes from the following platforms:"] = ""; $a->strings["Currently this node is aware of %d nodes from the following platforms:"] = "";

View file

@ -19,7 +19,7 @@
<script> <script>
var FedData = [ var FedData = [
{{foreach $counts as $c}} {{foreach $counts as $c}}
{ value: {{$c[0]['total']}}, label: "{{$c[0]['platform']}}", color: "#90EE90", highlight: "#EE90A1", }, { value: {{$c[0]['total']}}, label: "{{$c[0]['platform']}}", color: '{{$c[3]}}', highlight: "#EE90A1", },
{{/foreach}} {{/foreach}}
]; ];
var ctx = document.getElementById("FederationChart").getContext("2d"); var ctx = document.getElementById("FederationChart").getContext("2d");
@ -40,7 +40,7 @@ var myDoughnutChart = new Chart(ctx).Doughnut(FedData, { animateRotate : false,
<script> <script>
var {{$c[2]}}data = [ var {{$c[2]}}data = [
{{foreach $c[1] as $v}} {{foreach $c[1] as $v}}
{ value: {{$v['total']}}, label: '{{$v['version']}}', color: "#90EE90", highlight: "#EE90A1",}, { value: {{$v['total']}}, label: '{{$v['version']}}', color: "{{$c[3]}}", highlight: "#EE90A1",},
{{/foreach}} {{/foreach}}
]; ];
var ctx = document.getElementById("{{$c[2]}}Chart").getContext("2d"); var ctx = document.getElementById("{{$c[2]}}Chart").getContext("2d");

View file

@ -87,6 +87,7 @@
{{if $thread_allow.2}} {{if $thread_allow.2}}
{{include file="field_checkbox.tpl" field=$ostatus_disabled}} {{include file="field_checkbox.tpl" field=$ostatus_disabled}}
{{include file="field_select.tpl" field=$ostatus_poll_interval}} {{include file="field_select.tpl" field=$ostatus_poll_interval}}
{{include file="field_checkbox.tpl" field=$ostatus_full_threads}}
{{else}} {{else}}
<div class='field checkbox' id='div_id_{{$ostatus_disabled.0}}'> <div class='field checkbox' id='div_id_{{$ostatus_disabled.0}}'>
<label for='id_{{$ostatus_disabled.0}}'>{{$ostatus_disabled.1}}</label> <label for='id_{{$ostatus_disabled.0}}'>{{$ostatus_disabled.1}}</label>
@ -153,6 +154,12 @@
{{include file="field_checkbox.tpl" field=$old_pager}} {{include file="field_checkbox.tpl" field=$old_pager}}
<div class="submit"><input type="submit" name="page_site" value="{{$submit|escape:'html'}}" /></div> <div class="submit"><input type="submit" name="page_site" value="{{$submit|escape:'html'}}" /></div>
<h3>{{$worker_title}}</h3>
{{include file="field_checkbox.tpl" field=$worker}}
{{include file="field_input.tpl" field=$worker_queues}}
{{include file="field_checkbox.tpl" field=$worker_dont_fork}}
<div class="submit"><input type="submit" name="page_site" value="{{$submit|escape:'html'}}" /></div>
</form> </form>
{{* separate form for relocate... *}} {{* separate form for relocate... *}}

View file

@ -1,104 +1,98 @@
{{if $header}}<h2>{{$header}}</h2>{{/if}} {{if $header}}<h2>{{$header}}</h2>{{/if}}
<div id="contact-edit-wrapper" > <div id="contact-edit-wrapper" >
{{* Insert Tab-Nav *}}
{{$tab_str}} {{$tab_str}}
<div id="contact-edit-drop-link" >
<a href="contacts/{{$contact_id}}/drop" class="icon drophide" id="contact-edit-drop-link" onclick="return confirmDelete();" title="{{$delete}}" onmouseover="imgbright(this);" onmouseout="imgdull(this);"></a>
</div>
<div id="contact-edit-drop-link-end"></div>
<div id="contact-edit-nav-wrapper" > <div id="contact-edit-nav-wrapper" >
<div id="contact-edit-links"> <div id="contact-edit-links">
<ul> <div id="contact-edit-status-wrapper">
{{if $relation_text}} <span id="contact-edit-contact-status">{{$contact_status}}</span>
<li><div id="contact-edit-rel">{{$relation_text}}</div></li>
{{/if}}
{{if $lost_contact}}
<li><div id="lost-contact-message">{{$lost_contact}}</div></li>
{{/if}}
{{if $insecure}}
<li><div id="insecure-message">{{$insecure}}</div></li>
{{/if}}
{{if $blocked}}
<li><div id="block-message">{{$blocked}}</div></li>
{{/if}}
{{if $ignored}}
<li><div id="ignore-message">{{$ignored}}</div></li>
{{/if}}
{{if $archived}}
<li><div id="archive-message">{{$archived}}</div></li>
{{/if}}
</ul>
<ul> {{* This is the Action menu where contact related actions like 'ignore', 'hide' can be performed *}}
<div id="contact-edit-actions">
<a class="btn" rel="#contact-actions-menu" href="#" id="contact-edit-actions-button">{{$contact_action_button}}</a>
{{if $common_text}} <ul role="menu" aria-haspopup="true" id="contact-actions-menu" class="menu-popup" >
<li><div id="contact-edit-common"><a href="{{$common_link}}">{{$common_text}}</a></div></li> {{if $lblsuggest}}<li role="menuitem"><a href="#" title="{{$contact_actions.suggest.title}}" onclick="window.location.href='{{$contact_actions.suggest.url}}'; return false;">{{$contact_actions.suggest.label}}</a></li>{{/if}}
{{/if}} {{if $poll_enabled}}<li role="menuitem"><a href="#" title="{{$contact_actions.update.title}}" onclick="window.location.href='{{$contact_actions.update.url}}'; return false;">{{$contact_actions.update.label}}</a></li>{{/if}}
{{if $all_friends}} <li class="divider"></li>
<li><div id="contact-edit-allfriends"><a href="allfriends/{{$contact_id}}">{{$all_friends}}</a></div></li> <li role="menuitem"><a href="#" title="{{$contact_actions.block.title}}" onclick="window.location.href='{{$contact_actions.block.url}}'; return false;">{{$contact_actions.block.label}}</a></li>
{{/if}} <li role="menuitem"><a href="#" title="{{$contact_actions.ignore.title}}" onclick="window.location.href='{{$contact_actions.ignore.url}}'; return false;">{{$contact_actions.ignore.label}}</a></li>
<li role="menuitem"><a href="#" title="{{$contact_actions.archive.title}}" onclick="window.location.href='{{$contact_actions.archive.url}}'; return false;">{{$contact_actions.archive.label}}</a></li>
<li role="menuitem"><a href="#" title="{{$contact_actions.delete.title}}" onclick="return confirmDelete();">{{$contact_actions.delete.label}}</a></li>
</ul>
</div>
{{* Block with status information about the contact *}}
<ul>
{{if $relation_text}}<li><div id="contact-edit-rel">{{$relation_text}}</div></li>{{/if}}
<!-- <li><a href="network/0?nets=all&cid={{$contact_id}}" id="contact-edit-view-recent">{{$lblrecent}}</a></li> --> {{if $poll_enabled}}
{{if $lblsuggest}} <li><div id="contact-edit-last-update-text">{{$lastupdtext}} <span id="contact-edit-last-updated">{{$last_update}}</span></div>
<li><a href="fsuggest/{{$contact_id}}" id="contact-edit-suggest">{{$lblsuggest}}</a></li> {{if $poll_interval}}
{{/if}} <span id="contact-edit-poll-text">{{$updpub}}</span> {{$poll_interval}}
{{if $follow}} {{/if}}
<li><div id="contact-edit-follow"><a href="{{$follow}}">{{$follow_text}}</a></div></li> </li>
{{/if}} {{/if}}
</ul> {{if $lost_contact}}<li><div id="lost-contact-message">{{$lost_contact}}</div></li>{{/if}}
{{if $insecure}}<li><div id="insecure-message">{{$insecure}}</div></li> {{/if}}
{{if $blocked}}<li><div id="block-message">{{$blocked}}</div></li>{{/if}}
{{if $ignored}}<li><div id="ignore-message">{{$ignored}}</div></li>{{/if}}
{{if $archived}}<li><div id="archive-message">{{$archived}}</div></li>{{/if}}
</ul>
<ul>
<!-- <li><a href="network/0?nets=all&cid={{$contact_id}}" id="contact-edit-view-recent">{{$lblrecent}}</a></li> -->
{{if $follow}}<li><div id="contact-edit-follow"><a href="{{$follow}}">{{$follow_text}}</a></div></li>{{/if}}
</ul>
</div> {{* End of contact-edit-status-wrapper *}}
{{* Some information about the contact from the profile *}}
<dl><dt>{{$profileurllabel}}</dt><dd><a target="blank" href="{{$url}}">{{$profileurl}}</a></dd></dl> <dl><dt>{{$profileurllabel}}</dt><dd><a target="blank" href="{{$url}}">{{$profileurl}}</a></dd></dl>
{{if $location}}<dl><dt>{{$location_label}}</dt><dd>{{$location}}</dd></dl>{{/if}} {{if $location}}<dl><dt>{{$location_label}}</dt><dd>{{$location}}</dd></dl>{{/if}}
{{if $keywords}}<dl><dt>{{$keywords_label}}</dt><dd>{{$keywords}}</dd></dl>{{/if}} {{if $keywords}}<dl><dt>{{$keywords_label}}</dt><dd>{{$keywords}}</dd></dl>{{/if}}
{{if $about}}<dl><dt>{{$about_label}}</dt><dd>{{$about}}</dd></dl>{{/if}} {{if $about}}<dl><dt>{{$about_label}}</dt><dd>{{$about}}</dd></dl>{{/if}}
</div> </div>{{* End of contact-edit-links *}}
</div>
<div id="contact-edit-nav-end"></div>
<hr /> <div id="contact-edit-links-end"></div>
<form action="contacts/{{$contact_id}}" method="post" > <hr />
<input type="hidden" name="contact_id" value="{{$contact_id}}">
<div id="contact-edit-poll-wrapper"> <h4 id="contact-edit-settings-label" class="fakelink" onclick="openClose('contact-edit-settings')">{{$contact_settings_label}}</h4>
{{if $poll_enabled}} <div id="contact-edit-settings">
<div id="contact-edit-last-update-text">{{$lastupdtext}} <span id="contact-edit-last-updated">{{$last_update}}</span></div> <form action="contacts/{{$contact_id}}" method="post" >
{{if $poll_interval}} <input type="hidden" name="contact_id" value="{{$contact_id}}">
<span id="contact-edit-poll-text">{{$updpub}}</span> {{$poll_interval}}
<div id="contact-edit-end" ></div>
{{include file="field_checkbox.tpl" field=$notify}}
{{if $fetch_further_information}}
{{include file="field_select.tpl" field=$fetch_further_information}}
{{if $fetch_further_information.2 == 2 }} {{include file="field_textarea.tpl" field=$ffi_keyword_blacklist}} {{/if}}
{{/if}}
{{include file="field_checkbox.tpl" field=$hidden}}
<div id="contact-edit-info-wrapper">
<h4>{{$lbl_info1}}</h4>
<textarea id="contact-edit-info" rows="8" cols="60" name="info">{{$info}}</textarea>
<input class="contact-edit-submit" type="submit" name="submit" value="{{$submit|escape:'html'}}" />
</div>
<div id="contact-edit-info-end"></div>
{{if $profile_select}}
<div id="contact-edit-profile-select-text">
<h4>{{$lbl_vis1}}</h4>
<p>{{$lbl_vis2}}</p>
</div>
{{$profile_select}}
<div id="contact-edit-profile-select-end"></div>
<input class="contact-edit-submit" type="submit" name="submit" value="{{$submit|escape:'html'}}" />
{{/if}} {{/if}}
<span id="contact-edit-update-now" class="button"><a href="contacts/{{$contact_id}}/update" >{{$udnow}}</a></span> </form>
{{/if}} </div>
</div> </div>{{* End of contact-edit-nav-wrapper *}}
<div id="contact-edit-end" ></div>
{{include file="field_checkbox.tpl" field=$notify}}
{{if $fetch_further_information}}
{{include file="field_select.tpl" field=$fetch_further_information}}
{{if $fetch_further_information.2 == 2 }} {{include file="field_textarea.tpl" field=$ffi_keyword_blacklist}} {{/if}}
{{/if}}
{{include file="field_checkbox.tpl" field=$hidden}}
<div id="contact-edit-info-wrapper">
<h4>{{$lbl_info1}}</h4>
<textarea id="contact-edit-info" rows="8" cols="60" name="info">{{$info}}</textarea>
<input class="contact-edit-submit" type="submit" name="submit" value="{{$submit|escape:'html'}}" />
</div>
<div id="contact-edit-info-end"></div>
{{if $profile_select}}
<div id="contact-edit-profile-select-text">
<h4>{{$lbl_vis1}}</h4>
<p>{{$lbl_vis2}}</p>
</div>
{{$profile_select}}
<div id="contact-edit-profile-select-end"></div>
<input class="contact-edit-submit" type="submit" name="submit" value="{{$submit|escape:'html'}}" />
{{/if}}
</form>
</div> </div>

View file

@ -18,13 +18,13 @@
{{/if}} {{/if}}
{{if $request}} {{if $request}}
<form action="{{$request}}" method="post" /> <form action="{{$request}}" method="post">
{{else}} {{else}}
<form action="dfrn_request/{{$nickname}}" method="post" /> <form action="dfrn_request/{{$nickname}}" method="post">
{{/if}} {{/if}}
{{if $photo}} {{if $photo}}
<img src="{{$photo}}" alt="" id="dfrn-request-photo"> <img src="{{$photo}}" alt="" id="dfrn-request-photo" />
{{/if}} {{/if}}
{{if $url}}<dl><dt>{{$url_label}}</dt><dd><a target="blank" href="{{$zrl}}">{{$url}}</a></dd></dl>{{/if}} {{if $url}}<dl><dt>{{$url_label}}</dt><dd><a target="blank" href="{{$zrl}}">{{$url}}</a></dd></dl>{{/if}}

View file

@ -1,9 +0,0 @@
<decrypted_hdeader>
<iv>{{$inner_iv}}</iv>
<aes_key>{{$inner_key}}</aes_key>
<author>
<name>{{$author_name}}</name>
<uri>{{$author_uri}}</uri>
</author>
</decrypted_header>

View file

@ -1,12 +0,0 @@
<XML>
<post>
<comment>
<guid>{{$guid}}</guid>
<parent_guid>{{$parent_guid}}</parent_guid>
<author_signature>{{$authorsig}}</author_signature>
<text>{{$body}}</text>
<diaspora_handle>{{$handle}}</diaspora_handle>
</comment>
</post>
</XML>

View file

@ -1,13 +0,0 @@
<XML>
<post>
<comment>
<guid>{{$guid}}</guid>
<parent_guid>{{$parent_guid}}</parent_guid>
<parent_author_signature>{{$parentsig}}</parent_author_signature>
<author_signature>{{$authorsig}}</author_signature>
<text>{{$body}}</text>
<diaspora_handle>{{$handle}}</diaspora_handle>
</comment>
</post>
</XML>

View file

@ -1,30 +0,0 @@
<XML>
<post>
<conversation>
<guid>{{$conv.guid}}</guid>
<subject>{{$conv.subject}}</subject>
<created_at>{{$conv.created_at}}</created_at>
{{foreach $conv.messages as $msg}}
<message>
<guid>{{$msg.guid}}</guid>
<parent_guid>{{$msg.parent_guid}}</parent_guid>
{{if $msg.parent_author_signature}}
<parent_author_signature>{{$msg.parent_author_signature}}</parent_author_signature>
{{/if}}
<author_signature>{{$msg.author_signature}}</author_signature>
<text>{{$msg.text}}</text>
<created_at>{{$msg.created_at}}</created_at>
<diaspora_handle>{{$msg.diaspora_handle}}</diaspora_handle>
<conversation_guid>{{$msg.conversation_guid}}</conversation_guid>
</message>
{{/foreach}}
<diaspora_handle>{{$conv.diaspora_handle}}</diaspora_handle>
<participant_handles>{{$conv.participant_handles}}</participant_handles>
</conversation>
</post>
</XML>

View file

@ -1,13 +0,0 @@
<XML>
<post>
<like>
<positive>{{$positive}}</positive>
<guid>{{$guid}}</guid>
<target_type>{{$target_type}}</target_type>
<parent_guid>{{$parent_guid}}</parent_guid>
<author_signature>{{$authorsig}}</author_signature>
<diaspora_handle>{{$handle}}</diaspora_handle>
</like>
</post>
</XML>

View file

@ -1,14 +0,0 @@
<XML>
<post>
<like>
<positive>{{$positive}}</positive>
<guid>{{$guid}}</guid>
<target_type>{{$target_type}}</target_type>
<parent_guid>{{$parent_guid}}</parent_guid>
<parent_author_signature>{{$parentsig}}</parent_author_signature>
<author_signature>{{$authorsig}}</author_signature>
<diaspora_handle>{{$handle}}</diaspora_handle>
</like>
</post>
</XML>

View file

@ -1,17 +0,0 @@
<XML>
<post>
<message>
<guid>{{$msg.guid}}</guid>
<parent_guid>{{$msg.parent_guid}}</parent_guid>
{{if $msg.parent_author_signature}}
<parent_author_signature>{{$msg.parent_author_signature}}</parent_author_signature>
{{/if}}
<author_signature>{{$msg.author_signature}}</author_signature>
<text>{{$msg.text}}</text>
<created_at>{{$msg.created_at}}</created_at>
<diaspora_handle>{{$msg.diaspora_handle}}</diaspora_handle>
<conversation_guid>{{$msg.conversation_guid}}</conversation_guid>
</message>
</post>
</XML>

View file

@ -1,14 +0,0 @@
<XML>
<post>
<photo>
<guid>{{$guid}}</guid>
<diaspora_handle>{{$handle}}</diaspora_handle>
<public>{{$public}}</public>
<created_at>{{$created_at}}</created_at>
<remote_photo_path>{{$path}}</remote_photo_path>
<remote_photo_name>{{$filename}}</remote_photo_name>
<status_message_guid>{{$msg_guid}}</status_message_guid>
</photo>
</post>
</XML>

View file

@ -1,13 +0,0 @@
<XML>
<post>
<status_message>
<raw_message>{{$body}}</raw_message>
<guid>{{$guid}}</guid>
<diaspora_handle>{{$handle}}</diaspora_handle>
<public>{{$public}}</public>
<created_at>{{$created}}</created_at>
<provider_display_name>{{$provider}}</provider_display_name>
</status_message>
</post>
</XML>

View file

@ -1,17 +0,0 @@
<XML>
<post><profile>
<diaspora_handle>{{$handle}}</diaspora_handle>
<first_name>{{$first}}</first_name>
<last_name>{{$last}}</last_name>
<image_url>{{$large}}</image_url>
<image_url_medium>{{$medium}}</image_url_medium>
<image_url_small>{{$small}}</image_url_small>
<birthday>{{$dob}}</birthday>
<gender>{{$gender}}</gender>
<bio>{{$about}}</bio>
<location>{{$location}}</location>
<searchable>{{$searchable}}</searchable>
<tag_string>{{$tags}}</tag_string>
</profile></post>
</XML>

Some files were not shown because too many files have changed in this diff Show more