Merge remote-tracking branch 'upstream/develop' into develop
This commit is contained in:
commit
ab87f1215a
|
@ -37,7 +37,7 @@ local .htaccess file
|
|||
- PHP *command line* access with register_argc_argv set to true in the
|
||||
php.ini file [or see 'poormancron' in section 8]
|
||||
|
||||
- curl, gd (with at least jpeg support), mysql, mbstring and openssl extensions
|
||||
- curl, gd (with at least jpeg support), mysql, mbstring, xml and openssl extensions
|
||||
|
||||
- some form of email server or email gateway such that PHP mail() works
|
||||
|
||||
|
|
8
boot.php
8
boot.php
|
@ -229,8 +229,9 @@ define('PROTOCOL_UNKNOWN', 0);
|
|||
define('PROTOCOL_DFRN', 1);
|
||||
define('PROTOCOL_DIASPORA', 2);
|
||||
define('PROTOCOL_OSTATUS_SALMON', 3);
|
||||
define('PROTOCOL_OSTATUS_FEED', 4);
|
||||
define('PROTOCOL_GS_CONVERSATION', 5);
|
||||
define('PROTOCOL_OSTATUS_FEED', 4); // Deprecated
|
||||
define('PROTOCOL_GS_CONVERSATION', 5); // Deprecated
|
||||
define('PROTOCOL_SPLITTED_CONV', 6);
|
||||
/** @}*/
|
||||
|
||||
/**
|
||||
|
@ -320,6 +321,8 @@ define ( 'NOTIFY_TAGSHARE', 0x0100 );
|
|||
define ( 'NOTIFY_POKE', 0x0200 );
|
||||
define ( 'NOTIFY_SHARE', 0x0400 );
|
||||
|
||||
define ( 'SYSTEM_EMAIL', 0x4000 );
|
||||
|
||||
define ( 'NOTIFY_SYSTEM', 0x8000 );
|
||||
/* @}*/
|
||||
|
||||
|
@ -391,6 +394,7 @@ define ( 'ACTIVITY_POST', NAMESPACE_ACTIVITY_SCHEMA . 'post' );
|
|||
define ( 'ACTIVITY_UPDATE', NAMESPACE_ACTIVITY_SCHEMA . 'update' );
|
||||
define ( 'ACTIVITY_TAG', NAMESPACE_ACTIVITY_SCHEMA . 'tag' );
|
||||
define ( 'ACTIVITY_FAVORITE', NAMESPACE_ACTIVITY_SCHEMA . 'favorite' );
|
||||
define ( 'ACTIVITY_UNFAVORITE', NAMESPACE_ACTIVITY_SCHEMA . 'unfavorite' );
|
||||
define ( 'ACTIVITY_SHARE', NAMESPACE_ACTIVITY_SCHEMA . 'share' );
|
||||
define ( 'ACTIVITY_DELETE', NAMESPACE_ACTIVITY_SCHEMA . 'delete' );
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ Requirements
|
|||
* Apache with mod-rewrite enabled and "Options All" so you can use a local .htaccess file
|
||||
* PHP 5.4+.
|
||||
* PHP *command line* access with register_argc_argv set to true in the php.ini file
|
||||
* Curl, GD, PDO, MySQLi, hash and OpenSSL extensions
|
||||
* Curl, GD, PDO, MySQLi, hash, xml and OpenSSL extensions
|
||||
* some form of email server or email gateway such that PHP mail() works
|
||||
* Mysql 5.5.3+ or an equivalant alternative for MySQL (MariaDB, Percona Server etc.)
|
||||
* the ability to schedule jobs with cron (Linux/Mac) or Scheduled Tasks (Windows) (Note: other options are presented in Section 7 of this document.)
|
||||
|
|
|
@ -24,7 +24,7 @@ Wir planen, diese Einschränkung in einer zukünftigen Version zu beheben.
|
|||
- Apache mit einer aktiverten mod-rewrite-Funktion und dem Eintrag "Options All", so dass du die lokale .htaccess-Datei nutzen kannst
|
||||
- PHP 5.2+. Je neuer, desto besser. Du benötigst 5.3 für die Authentifizierung untereinander. In einer Windows-Umgebung arbeitet die Version 5.2+ möglicherweise nicht, da die Funktion dns_get_record() erst ab Version 5.3 verfügbar ist.
|
||||
- PHP *Kommandozeilen*-Zugang mit register_argc_argv auf "true" gesetzt in der php.ini-Datei
|
||||
- Curl, GD, PDO, MySQLi und OpenSSL-Erweiterung
|
||||
- Curl, GD, PDO, MySQLi, xml und OpenSSL-Erweiterung
|
||||
- etwas in der Art eines Email-Servers oder eines Gateways wie PHP mail()
|
||||
- Mysql 5.x
|
||||
- die Möglichkeit, wiederkehrende Aufgaben mit cron (Linux/Mac) oder "Scheduled Tasks" einzustellen (Windows) [Beachte: andere Optionen sind in Abschnitt 7 dieser Dokumentation zu finden]
|
||||
|
|
|
@ -44,6 +44,7 @@ Example: To set the directory value please add this line to your .htconfig.php:
|
|||
* **dlogfile - location of the developer log file
|
||||
* **event_input_format** - Default value is "ymd".
|
||||
* **frontend_worker_timeout** - Value in minutes after we think that a frontend task was killed by the webserver. Default value is 10.
|
||||
* **hsts** (Boolean) - Enables the sending of HTTP Strict Transport Security headers
|
||||
* **ignore_cache** (Boolean) - For development only. Disables the item cache.
|
||||
* **like_no_comment** (Boolean) - Don't update the "commented" value of an item when it is liked.
|
||||
* **local_block** (Boolean) - Used in conjunction with "block_public".
|
||||
|
|
|
@ -9,27 +9,27 @@ use Friendica\Network\Probe;
|
|||
// authorisation to do this.
|
||||
|
||||
function user_remove($uid) {
|
||||
if(! $uid)
|
||||
if (!$uid) {
|
||||
return;
|
||||
}
|
||||
|
||||
logger('Removing user: ' . $uid);
|
||||
|
||||
$r = q("select * from user where uid = %d limit 1", intval($uid));
|
||||
$r = dba::select('user', array(), array('uid' => $uid), array("limit" => 1));
|
||||
|
||||
call_hooks('remove_user',$r[0]);
|
||||
call_hooks('remove_user',$r);
|
||||
|
||||
// save username (actually the nickname as it is guaranteed
|
||||
// unique), so it cannot be re-registered in the future.
|
||||
|
||||
q("insert into userd ( username ) values ( '%s' )",
|
||||
$r[0]['nickname']
|
||||
);
|
||||
dba::insert('userd', array('username' => $r['nickname']));
|
||||
|
||||
// The user and related data will be deleted in "cron_expire_and_remove_users" (cronjobs.php)
|
||||
q("UPDATE `user` SET `account_removed` = 1, `account_expires_on` = UTC_TIMESTAMP() WHERE `uid` = %d", intval($uid));
|
||||
proc_run(PRIORITY_HIGH, "include/notifier.php", "removeme", $uid);
|
||||
|
||||
// Send an update to the directory
|
||||
proc_run(PRIORITY_LOW, "include/directory.php", $r[0]['url']);
|
||||
proc_run(PRIORITY_LOW, "include/directory.php", $r['url']);
|
||||
|
||||
if($uid == local_user()) {
|
||||
unset($_SESSION['authenticated']);
|
||||
|
@ -206,6 +206,8 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) {
|
|||
return $cache[$url][$uid];
|
||||
}
|
||||
|
||||
$ssl_url = str_replace('http://', 'https://', $url);
|
||||
|
||||
// Fetch contact data from the contact table for the given user
|
||||
$s = dba::p("SELECT `id`, `id` AS `cid`, 0 AS `gid`, 0 AS `zid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
|
||||
`keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `contact-type`, `bd` AS `birthday`, `self`
|
||||
|
@ -213,6 +215,15 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) {
|
|||
normalise_link($url), $uid);
|
||||
$r = dba::inArray($s);
|
||||
|
||||
// Fetch contact data from the contact table for the given user, checking with the alias
|
||||
if (!dbm::is_result($r)) {
|
||||
$s = dba::p("SELECT `id`, `id` AS `cid`, 0 AS `gid`, 0 AS `zid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
|
||||
`keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `contact-type`, `bd` AS `birthday`, `self`
|
||||
FROM `contact` WHERE `alias` IN (?, ?, ?) AND `uid` = ?",
|
||||
normalise_link($url), $url, $ssl_url, $uid);
|
||||
$r = dba::inArray($s);
|
||||
}
|
||||
|
||||
// Fetch the data from the contact table with "uid=0" (which is filled automatically)
|
||||
if (!dbm::is_result($r)) {
|
||||
$s = dba::p("SELECT `id`, 0 AS `cid`, `id` AS `zid`, 0 AS `gid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
|
||||
|
@ -222,6 +233,15 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) {
|
|||
$r = dba::inArray($s);
|
||||
}
|
||||
|
||||
// Fetch the data from the contact table with "uid=0" (which is filled automatically) - checked with the alias
|
||||
if (!dbm::is_result($r)) {
|
||||
$s = dba::p("SELECT `id`, 0 AS `cid`, `id` AS `zid`, 0 AS `gid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
|
||||
`keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `contact-type`, `bd` AS `birthday`, 0 AS `self`
|
||||
FROM `contact` WHERE `alias` IN (?, ?, ?) AND `uid` = 0",
|
||||
normalise_link($url), $url, $ssl_url);
|
||||
$r = dba::inArray($s);
|
||||
}
|
||||
|
||||
// Fetch the data from the gcontact table
|
||||
if (!dbm::is_result($r)) {
|
||||
$s = dba::p("SELECT 0 AS `id`, 0 AS `cid`, `id` AS `gid`, 0 AS `zid`, 0 AS `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, '' AS `xmpp`,
|
||||
|
@ -542,8 +562,10 @@ function get_contact($url, $uid = 0, $no_update = false) {
|
|||
|
||||
// Then the alias (which could be anything)
|
||||
if (!dbm::is_result($contact)) {
|
||||
$r = dba::p("SELECT `id`, `avatar-date` FROM `contact` WHERE `alias` IN (?, ?) AND `uid` = ? LIMIT 1",
|
||||
$url, normalise_link($url), $uid);
|
||||
// The link could be provided as http although we stored it as https
|
||||
$ssl_url = str_replace('http://', 'https://', $url);
|
||||
$r = dba::p("SELECT `id`, `avatar-date` FROM `contact` WHERE `alias` IN (?, ?, ?) AND `uid` = ? LIMIT 1",
|
||||
$url, normalise_link($url), $ssl_url, $uid);
|
||||
$contact = dba::fetch($r);
|
||||
dba::close($r);
|
||||
}
|
||||
|
|
|
@ -628,92 +628,24 @@ class Photo {
|
|||
|
||||
public function store($uid, $cid, $rid, $filename, $album, $scale, $profile = 0, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '', $desc = '') {
|
||||
|
||||
$r = q("SELECT `guid` FROM `photo` WHERE `resource-id` = '%s' AND `guid` != '' LIMIT 1",
|
||||
dbesc($rid)
|
||||
);
|
||||
$r = dba::select('photo', array('guid'), array("`resource-id` = ? AND `guid` != ?", $rid, ''), array('limit' => 1));
|
||||
if (dbm::is_result($r)) {
|
||||
$guid = $r[0]['guid'];
|
||||
$guid = $r['guid'];
|
||||
} else {
|
||||
$guid = get_guid();
|
||||
}
|
||||
|
||||
$x = q("SELECT `id` FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d AND `contact-id` = %d AND `scale` = %d LIMIT 1",
|
||||
dbesc($rid),
|
||||
intval($uid),
|
||||
intval($cid),
|
||||
intval($scale)
|
||||
);
|
||||
if (dbm::is_result($x)) {
|
||||
$r = q("UPDATE `photo`
|
||||
SET `uid` = %d,
|
||||
`contact-id` = %d,
|
||||
`guid` = '%s',
|
||||
`resource-id` = '%s',
|
||||
`created` = '%s',
|
||||
`edited` = '%s',
|
||||
`filename` = '%s',
|
||||
`type` = '%s',
|
||||
`album` = '%s',
|
||||
`height` = %d,
|
||||
`width` = %d,
|
||||
`datasize` = %d,
|
||||
`data` = '%s',
|
||||
`scale` = %d,
|
||||
`profile` = %d,
|
||||
`allow_cid` = '%s',
|
||||
`allow_gid` = '%s',
|
||||
`deny_cid` = '%s',
|
||||
`deny_gid` = '%s',
|
||||
`desc` = '%s'
|
||||
WHERE `id` = %d",
|
||||
$x = dba::select('photo', array('id'), array('resource-id' => $rid, 'uid' => $uid, 'contact-id' => $cid, 'scale' => $scale), array('limit' => 1));
|
||||
|
||||
intval($uid),
|
||||
intval($cid),
|
||||
dbesc($guid),
|
||||
dbesc($rid),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(basename($filename)),
|
||||
dbesc($this->getType()),
|
||||
dbesc($album),
|
||||
intval($this->getHeight()),
|
||||
intval($this->getWidth()),
|
||||
dbesc(strlen($this->imageString())),
|
||||
dbesc($this->imageString()),
|
||||
intval($scale),
|
||||
intval($profile),
|
||||
dbesc($allow_cid),
|
||||
dbesc($allow_gid),
|
||||
dbesc($deny_cid),
|
||||
dbesc($deny_gid),
|
||||
dbesc($desc),
|
||||
intval($x[0]['id'])
|
||||
);
|
||||
$fields = array('uid' => $uid, 'contact-id' => $cid, 'guid' => $guid, 'resource-id' => $rid, 'created' => datetime_convert(), 'edited' => datetime_convert(),
|
||||
'filename' => basename($filename), 'type' => $this->getType(), 'album' => $album, 'height' => $this->getHeight(), 'width' => $this->getWidth(),
|
||||
'datasize' => strlen($this->imageString()), 'data' => $this->imageString(), 'scale' => $scale, 'profile' => $profile,
|
||||
'allow_cid' => $allow_cid, 'allow_gid' => $allow_gid, 'deny_cid' => $deny_cid, 'deny_gid' => $deny_gid, 'desc' => $desc);
|
||||
|
||||
if (dbm::is_result($x)) {
|
||||
$r = dba::update('photo', $fields, array('id' => $x['id']));
|
||||
} else {
|
||||
$r = q("INSERT INTO `photo`
|
||||
(`uid`, `contact-id`, `guid`, `resource-id`, `created`, `edited`, `filename`, type, `album`, `height`, `width`, `datasize`, `data`, `scale`, `profile`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `desc`)
|
||||
VALUES (%d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, '%s', %d, %d, '%s', '%s', '%s', '%s', '%s')",
|
||||
intval($uid),
|
||||
intval($cid),
|
||||
dbesc($guid),
|
||||
dbesc($rid),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(basename($filename)),
|
||||
dbesc($this->getType()),
|
||||
dbesc($album),
|
||||
intval($this->getHeight()),
|
||||
intval($this->getWidth()),
|
||||
dbesc(strlen($this->imageString())),
|
||||
dbesc($this->imageString()),
|
||||
intval($scale),
|
||||
intval($profile),
|
||||
dbesc($allow_cid),
|
||||
dbesc($allow_gid),
|
||||
dbesc($deny_cid),
|
||||
dbesc($deny_gid),
|
||||
dbesc($desc)
|
||||
);
|
||||
$r = dba::insert('photo', $fields);
|
||||
}
|
||||
|
||||
return $r;
|
||||
|
|
|
@ -2276,18 +2276,32 @@ $called_api = null;
|
|||
|
||||
$statushtml = trim(bbcode($body, false, false));
|
||||
|
||||
// Workaround for clients with limited HTML parser functionality
|
||||
$search = array("<br>", "<blockquote>", "</blockquote>",
|
||||
"<h1>", "</h1>", "<h2>", "</h2>",
|
||||
"<h3>", "</h3>", "<h4>", "</h4>",
|
||||
"<h5>", "</h5>", "<h6>", "</h6>");
|
||||
$replace = array("<br>\n", "\n<blockquote>", "</blockquote>\n",
|
||||
"\n<h1>", "</h1>\n", "\n<h2>", "</h2>\n",
|
||||
"\n<h3>", "</h3>\n", "\n<h4>", "</h4>\n",
|
||||
"\n<h5>", "</h5>\n", "\n<h6>", "</h6>\n");
|
||||
$replace = array("<br>", "<br><blockquote>", "</blockquote><br>",
|
||||
"<br><h1>", "</h1><br>", "<br><h2>", "</h2><br>",
|
||||
"<br><h3>", "</h3><br>", "<br><h4>", "</h4><br>",
|
||||
"<br><h5>", "</h5><br>", "<br><h6>", "</h6><br>");
|
||||
$statushtml = str_replace($search, $replace, $statushtml);
|
||||
|
||||
if ($item['title'] != "") {
|
||||
$statushtml = "<h4>" . bbcode($item['title']) . "</h4>\n" . $statushtml;
|
||||
$statushtml = "<br><h4>" . bbcode($item['title']) . "</h4><br>" . $statushtml;
|
||||
}
|
||||
|
||||
do {
|
||||
$oldtext = $statushtml;
|
||||
$statushtml = str_replace("<br><br>", "<br>", $statushtml);
|
||||
} while ($oldtext != $statushtml);
|
||||
|
||||
if (substr($statushtml, 0, 4) == '<br>') {
|
||||
$statushtml = substr($statushtml, 4);
|
||||
}
|
||||
|
||||
if (substr($statushtml, 0, -4) == '<br>') {
|
||||
$statushtml = substr($statushtml, -4);
|
||||
}
|
||||
|
||||
// feeds without body should contain the link
|
||||
|
|
|
@ -987,7 +987,8 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = fa
|
|||
|
||||
// Server independent link to posts and comments
|
||||
// See issue: https://github.com/diaspora/diaspora_federation/issues/75
|
||||
$Text = preg_replace("=diaspora://(.*?)/([^\s\]]*)=ism", System::baseUrl()."/display/$2", $Text);
|
||||
$expression = "=diaspora://.*?/post/([0-9A-Za-z\-_@.:]{15,254}[0-9A-Za-z])=ism";
|
||||
$Text = preg_replace($expression, System::baseUrl()."/display/$1", $Text);
|
||||
|
||||
// if the HTML is used to generate plain text, then don't do this search, but replace all URL of that kind to text
|
||||
// if ($simplehtml != 7) {
|
||||
|
|
|
@ -42,12 +42,6 @@ function cron_run(&$argv, &$argc){
|
|||
// Expire and remove user entries
|
||||
proc_run(PRIORITY_MEDIUM, "include/cronjobs.php", "expire_and_remove_users");
|
||||
|
||||
// Check OStatus conversations
|
||||
proc_run(PRIORITY_MEDIUM, "include/cronjobs.php", "ostatus_mentions");
|
||||
|
||||
// Check every conversation
|
||||
proc_run(PRIORITY_MEDIUM, "include/cronjobs.php", "ostatus_conversations");
|
||||
|
||||
// Call possible post update functions
|
||||
proc_run(PRIORITY_LOW, "include/cronjobs.php", "post_update");
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ function cronjobs_run(&$argv, &$argc){
|
|||
global $a;
|
||||
|
||||
require_once 'include/datetime.php';
|
||||
require_once 'include/ostatus.php';
|
||||
require_once 'include/post_update.php';
|
||||
require_once 'mod/nodeinfo.php';
|
||||
require_once 'include/photos.php';
|
||||
|
@ -22,19 +21,6 @@ function cronjobs_run(&$argv, &$argc){
|
|||
|
||||
logger("Starting cronjob ".$argv[1], LOGGER_DEBUG);
|
||||
|
||||
// Check OStatus conversations
|
||||
// Check only conversations with mentions (for a longer time)
|
||||
if ($argv[1] == 'ostatus_mentions') {
|
||||
ostatus::check_conversations(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check every conversation
|
||||
if ($argv[1] == 'ostatus_conversations') {
|
||||
ostatus::check_conversations(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// Call possible post update functions
|
||||
// see include/post_update.php for more details
|
||||
if ($argv[1] == 'post_update') {
|
||||
|
|
358
include/dba.php
358
include/dba.php
|
@ -7,11 +7,6 @@ require_once('include/datetime.php');
|
|||
/**
|
||||
* @class MySQL database class
|
||||
*
|
||||
* For debugging, insert 'dbg(1);' anywhere in the program flow.
|
||||
* dbg(0); will turn it off. Logging is performed at LOGGER_DATA level.
|
||||
* When logging, all binary info is converted to text and html entities are escaped so that
|
||||
* the debugging stream is safe to view within both terminals and web pages.
|
||||
*
|
||||
* This class is for the low level database stuff that does driver specific things.
|
||||
*/
|
||||
|
||||
|
@ -214,175 +209,32 @@ class dba {
|
|||
}
|
||||
}
|
||||
|
||||
public function q($sql, $onlyquery = false) {
|
||||
$a = get_app();
|
||||
|
||||
if (!$this->db || !$this->connected) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->error = '';
|
||||
|
||||
$connstr = ($this->connected() ? "Connected" : "Disonnected");
|
||||
|
||||
$stamp1 = microtime(true);
|
||||
|
||||
$orig_sql = $sql;
|
||||
|
||||
if (x($a->config,'system') && x($a->config['system'], 'db_callstack')) {
|
||||
$sql = "/*".System::callstack()." */ ".$sql;
|
||||
}
|
||||
|
||||
$columns = 0;
|
||||
|
||||
switch ($this->driver) {
|
||||
case 'pdo':
|
||||
$result = @$this->db->query($sql);
|
||||
// Is used to separate between queries that returning data - or not
|
||||
if (!is_bool($result)) {
|
||||
$columns = $result->columnCount();
|
||||
}
|
||||
break;
|
||||
case 'mysqli':
|
||||
$result = @$this->db->query($sql);
|
||||
break;
|
||||
case 'mysql':
|
||||
$result = @mysql_query($sql,$this->db);
|
||||
break;
|
||||
}
|
||||
$stamp2 = microtime(true);
|
||||
$duration = (float)($stamp2 - $stamp1);
|
||||
|
||||
$a->save_timestamp($stamp1, "database");
|
||||
|
||||
if (strtolower(substr($orig_sql, 0, 6)) != "select") {
|
||||
$a->save_timestamp($stamp1, "database_write");
|
||||
}
|
||||
if (x($a->config,'system') && x($a->config['system'],'db_log')) {
|
||||
if (($duration > $a->config["system"]["db_loglimit"])) {
|
||||
$duration = round($duration, 3);
|
||||
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||
@file_put_contents($a->config["system"]["db_log"], datetime_convert()."\t".$duration."\t".
|
||||
basename($backtrace[1]["file"])."\t".
|
||||
$backtrace[1]["line"]."\t".$backtrace[2]["function"]."\t".
|
||||
substr($sql, 0, 2000)."\n", FILE_APPEND);
|
||||
}
|
||||
}
|
||||
|
||||
switch ($this->driver) {
|
||||
case 'pdo':
|
||||
$errorInfo = $this->db->errorInfo();
|
||||
if ($errorInfo) {
|
||||
$this->error = $errorInfo[2];
|
||||
$this->errorno = $errorInfo[1];
|
||||
}
|
||||
break;
|
||||
case 'mysqli':
|
||||
if ($this->db->errno) {
|
||||
$this->error = $this->db->error;
|
||||
$this->errorno = $this->db->errno;
|
||||
}
|
||||
break;
|
||||
case 'mysql':
|
||||
if (mysql_errno($this->db)) {
|
||||
$this->error = mysql_error($this->db);
|
||||
$this->errorno = mysql_errno($this->db);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (strlen($this->error)) {
|
||||
logger('DB Error ('.$connstr.') '.$this->errorno.': '.$this->error);
|
||||
}
|
||||
|
||||
if ($this->debug) {
|
||||
|
||||
$mesg = '';
|
||||
|
||||
if ($result === false) {
|
||||
$mesg = 'false';
|
||||
} elseif ($result === true) {
|
||||
$mesg = 'true';
|
||||
} else {
|
||||
switch ($this->driver) {
|
||||
case 'pdo':
|
||||
$mesg = $result->rowCount().' results'.EOL;
|
||||
break;
|
||||
case 'mysqli':
|
||||
$mesg = $result->num_rows.' results'.EOL;
|
||||
break;
|
||||
case 'mysql':
|
||||
$mesg = mysql_num_rows($result).' results'.EOL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$str = 'SQL = ' . printable($sql) . EOL . 'SQL returned ' . $mesg
|
||||
. (($this->error) ? ' error: ' . $this->error : '')
|
||||
. EOL;
|
||||
|
||||
logger('dba: ' . $str );
|
||||
}
|
||||
|
||||
/**
|
||||
* If dbfail.out exists, we will write any failed calls directly to it,
|
||||
* regardless of any logging that may or may nor be in effect.
|
||||
* These usually indicate SQL syntax errors that need to be resolved.
|
||||
* @brief execute SQL query - deprecated
|
||||
*
|
||||
* Please use the dba:: functions instead:
|
||||
* dba::select, dba::exists, dba::insert
|
||||
* dba::delete, dba::update, dba::p, dba::e
|
||||
*
|
||||
* @param string $sql SQL query
|
||||
* @return array Query array
|
||||
*/
|
||||
public function q($sql) {
|
||||
$ret = self::p($sql);
|
||||
|
||||
if ($result === false) {
|
||||
logger('dba: ' . printable($sql) . ' returned false.' . "\n" . $this->error);
|
||||
if (file_exists('dbfail.out')) {
|
||||
file_put_contents('dbfail.out', datetime_convert() . "\n" . printable($sql) . ' returned false' . "\n" . $this->error . "\n", FILE_APPEND);
|
||||
}
|
||||
if (is_bool($ret)) {
|
||||
return $ret;
|
||||
}
|
||||
|
||||
if (is_bool($result)) {
|
||||
return $result;
|
||||
}
|
||||
if ($onlyquery) {
|
||||
$this->result = $result;
|
||||
$columns = self::columnCount($ret);
|
||||
|
||||
$data = self::inArray($ret);
|
||||
|
||||
if ((count($data) == 0) && ($columns == 0)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$r = array();
|
||||
switch ($this->driver) {
|
||||
case 'pdo':
|
||||
while ($x = $result->fetch(PDO::FETCH_ASSOC)) {
|
||||
$r[] = $x;
|
||||
}
|
||||
$result->closeCursor();
|
||||
break;
|
||||
case 'mysqli':
|
||||
while ($x = $result->fetch_array(MYSQLI_ASSOC)) {
|
||||
$r[] = $x;
|
||||
}
|
||||
$result->free_result();
|
||||
break;
|
||||
case 'mysql':
|
||||
while ($x = mysql_fetch_array($result, MYSQL_ASSOC)) {
|
||||
$r[] = $x;
|
||||
}
|
||||
mysql_free_result($result);
|
||||
break;
|
||||
}
|
||||
|
||||
// PDO doesn't return "true" on successful operations - like mysqli does
|
||||
// Emulate this behaviour by checking if the query returned data and had columns
|
||||
// This should be reliable enough
|
||||
if (($this->driver == 'pdo') && (count($r) == 0) && ($columns == 0)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
//$a->save_timestamp($stamp1, "database");
|
||||
|
||||
if ($this->debug) {
|
||||
logger('dba: ' . printable(print_r($r, true)));
|
||||
}
|
||||
return($r);
|
||||
}
|
||||
|
||||
public function dbg($dbg) {
|
||||
$this->debug = $dbg;
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function escape($str) {
|
||||
|
@ -515,6 +367,10 @@ class dba {
|
|||
/**
|
||||
* @brief Executes a prepared statement that returns data
|
||||
* @usage Example: $r = p("SELECT * FROM `item` WHERE `guid` = ?", $guid);
|
||||
*
|
||||
* Please only use it with complicated queries.
|
||||
* For all regular queries please use dba::select or dba::exists
|
||||
*
|
||||
* @param string $sql SQL statement
|
||||
* @return object statement object
|
||||
*/
|
||||
|
@ -540,7 +396,7 @@ class dba {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (substr_count($sql, '?') != count($args)) {
|
||||
if ((substr_count($sql, '?') != count($args)) && (count($args) > 0)) {
|
||||
// Question: Should we continue or stop the query here?
|
||||
logger('Parameter mismatch. Query "'.$sql.'" - Parameters '.print_r($args, true), LOGGER_DEBUG);
|
||||
}
|
||||
|
@ -572,6 +428,19 @@ class dba {
|
|||
|
||||
switch (self::$dbo->driver) {
|
||||
case 'pdo':
|
||||
// If there are no arguments we use "query"
|
||||
if (count($args) == 0) {
|
||||
if (!$retval = self::$dbo->db->query($sql)) {
|
||||
$errorInfo = self::$dbo->db->errorInfo();
|
||||
self::$dbo->error = $errorInfo[2];
|
||||
self::$dbo->errorno = $errorInfo[1];
|
||||
$retval = false;
|
||||
break;
|
||||
}
|
||||
self::$dbo->affected_rows = $retval->rowCount();
|
||||
break;
|
||||
}
|
||||
|
||||
if (!$stmt = self::$dbo->db->prepare($sql)) {
|
||||
$errorInfo = self::$dbo->db->errorInfo();
|
||||
self::$dbo->error = $errorInfo[2];
|
||||
|
@ -600,8 +469,8 @@ class dba {
|
|||
$command = strtolower($parts[0]);
|
||||
$can_be_prepared = in_array($command, array('select', 'update', 'insert', 'delete'));
|
||||
|
||||
// The fallback routine currently only works with statements that doesn't return values
|
||||
if (!$can_be_prepared && $called_from_e) {
|
||||
// The fallback routine is called as well when there are no arguments
|
||||
if (!$can_be_prepared || (count($args) == 0)) {
|
||||
$retval = self::$dbo->db->query(self::replace_parameters($sql, $args));
|
||||
if (self::$dbo->db->errno) {
|
||||
self::$dbo->error = self::$dbo->db->error;
|
||||
|
@ -710,6 +579,8 @@ class dba {
|
|||
/**
|
||||
* @brief Executes a prepared statement like UPDATE or INSERT that doesn't return data
|
||||
*
|
||||
* Please use dba::delete, dba::insert, dba::update, ... instead
|
||||
*
|
||||
* @param string $sql SQL statement
|
||||
* @return boolean Was the query successfull? False is returned only if an error occurred
|
||||
*/
|
||||
|
@ -792,6 +663,8 @@ class dba {
|
|||
/**
|
||||
* @brief Fetches the first row
|
||||
*
|
||||
* Please use dba::select or dba::exists whenever this is possible.
|
||||
*
|
||||
* @param string $sql SQL statement
|
||||
* @return array first row of query
|
||||
*/
|
||||
|
@ -820,6 +693,26 @@ class dba {
|
|||
return self::$dbo->affected_rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the number of columns of a statement
|
||||
*
|
||||
* @param object Statement object
|
||||
* @return int Number of columns
|
||||
*/
|
||||
public static function columnCount($stmt) {
|
||||
if (!is_object($stmt)) {
|
||||
return 0;
|
||||
}
|
||||
switch (self::$dbo->driver) {
|
||||
case 'pdo':
|
||||
return $stmt->columnCount();
|
||||
case 'mysqli':
|
||||
return $stmt->field_count;
|
||||
case 'mysql':
|
||||
return mysql_affected_rows($stmt);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* @brief Returns the number of rows of a statement
|
||||
*
|
||||
|
@ -856,6 +749,10 @@ class dba {
|
|||
case 'pdo':
|
||||
return $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
case 'mysqli':
|
||||
if (get_class($stmt) == 'mysqli_result') {
|
||||
return $stmt->fetch_assoc();
|
||||
}
|
||||
|
||||
// This code works, but is slow
|
||||
|
||||
// Bind the result to a result array
|
||||
|
@ -1271,7 +1168,11 @@ class dba {
|
|||
* Example:
|
||||
* $table = "item";
|
||||
* $fields = array("id", "uri", "uid", "network");
|
||||
*
|
||||
* $condition = array("uid" => 1, "network" => 'dspr');
|
||||
* or:
|
||||
* $condition = array("`uid` = ? AND `network` IN (?, ?)", 1, 'dfrn', 'dspr');
|
||||
*
|
||||
* $params = array("order" => array("id", "received" => true), "limit" => 1);
|
||||
*
|
||||
* $data = dba::select($table, $fields, $condition, $params);
|
||||
|
@ -1381,24 +1282,6 @@ class dba {
|
|||
}
|
||||
}
|
||||
|
||||
function printable($s) {
|
||||
$s = preg_replace("~([\x01-\x08\x0E-\x0F\x10-\x1F\x7F-\xFF])~",".", $s);
|
||||
$s = str_replace("\x00",'.',$s);
|
||||
if (x($_SERVER,'SERVER_NAME')) {
|
||||
$s = escape_tags($s);
|
||||
}
|
||||
return $s;
|
||||
}
|
||||
|
||||
// Procedural functions
|
||||
function dbg($state) {
|
||||
global $db;
|
||||
|
||||
if ($db) {
|
||||
$db->dbg($state);
|
||||
}
|
||||
}
|
||||
|
||||
function dbesc($str) {
|
||||
global $db;
|
||||
|
||||
|
@ -1409,107 +1292,46 @@ function dbesc($str) {
|
|||
}
|
||||
}
|
||||
|
||||
// Function: q($sql,$args);
|
||||
// Description: execute SQL query with printf style args.
|
||||
// Example: $r = q("SELECT * FROM `%s` WHERE `uid` = %d",
|
||||
// 'user', 1);
|
||||
function q($sql) {
|
||||
global $db;
|
||||
$args = func_get_args();
|
||||
unset($args[0]);
|
||||
|
||||
if ($db && $db->connected) {
|
||||
$sql = $db->clean_query($sql);
|
||||
$sql = $db->any_value_fallback($sql);
|
||||
$stmt = @vsprintf($sql,$args); // Disabled warnings
|
||||
//logger("dba: q: $stmt", LOGGER_ALL);
|
||||
if ($stmt === false)
|
||||
logger('dba: vsprintf error: ' . print_r(debug_backtrace(),true), LOGGER_DEBUG);
|
||||
|
||||
$db->log_index($stmt);
|
||||
|
||||
return $db->q($stmt);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief execute SQL query with printf style args - deprecated
|
||||
*
|
||||
* This will happen occasionally trying to store the
|
||||
* session data after abnormal program termination
|
||||
*
|
||||
*/
|
||||
logger('dba: no database: ' . print_r($args,true));
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Performs a query with "dirty reads"
|
||||
*
|
||||
* By doing dirty reads (reading uncommitted data) no locks are performed
|
||||
* This function can be used to fetch data that doesn't need to be reliable.
|
||||
* Please use the dba:: functions instead:
|
||||
* dba::select, dba::exists, dba::insert
|
||||
* dba::delete, dba::update, dba::p, dba::e
|
||||
*
|
||||
* @param $args Query parameters (1 to N parameters of different types)
|
||||
* @return array Query array
|
||||
*/
|
||||
function qu($sql) {
|
||||
function q($sql) {
|
||||
global $db;
|
||||
|
||||
$args = func_get_args();
|
||||
unset($args[0]);
|
||||
|
||||
if ($db && $db->connected) {
|
||||
$sql = $db->clean_query($sql);
|
||||
$sql = $db->any_value_fallback($sql);
|
||||
$stmt = @vsprintf($sql,$args); // Disabled warnings
|
||||
if ($stmt === false)
|
||||
logger('dba: vsprintf error: ' . print_r(debug_backtrace(),true), LOGGER_DEBUG);
|
||||
|
||||
$db->log_index($stmt);
|
||||
|
||||
$db->q("SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;");
|
||||
$retval = $db->q($stmt);
|
||||
$db->q("SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;");
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* This will happen occasionally trying to store the
|
||||
* session data after abnormal program termination
|
||||
*
|
||||
*/
|
||||
logger('dba: no database: ' . print_r($args,true));
|
||||
if (!$db || !$db->connected) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Raw db query, no arguments
|
||||
*
|
||||
*/
|
||||
function dbq($sql) {
|
||||
global $db;
|
||||
$sql = $db->clean_query($sql);
|
||||
$sql = $db->any_value_fallback($sql);
|
||||
|
||||
if ($db && $db->connected) {
|
||||
$ret = $db->q($sql);
|
||||
} else {
|
||||
$ret = false;
|
||||
}
|
||||
$stmt = @vsprintf($sql, $args);
|
||||
|
||||
$ret = dba::p($stmt);
|
||||
|
||||
if (is_bool($ret)) {
|
||||
return $ret;
|
||||
}
|
||||
|
||||
// Caller is responsible for ensuring that any integer arguments to
|
||||
// dbesc_array are actually integers and not malformed strings containing
|
||||
// SQL injection vectors. All integer array elements should be specifically
|
||||
// cast to int to avoid trouble.
|
||||
function dbesc_array_cb(&$item, $key) {
|
||||
if (is_string($item))
|
||||
$item = dbesc($item);
|
||||
$columns = dba::columnCount($ret);
|
||||
|
||||
$data = dba::inArray($ret);
|
||||
|
||||
if ((count($data) == 0) && ($columns == 0)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function dbesc_array(&$arr) {
|
||||
if (is_array($arr) && count($arr)) {
|
||||
array_walk($arr,'dbesc_array_cb');
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
function dba_timer() {
|
||||
|
|
|
@ -31,7 +31,7 @@ function convert_to_innodb() {
|
|||
$sql = sprintf("ALTER TABLE `%s` engine=InnoDB;", dbesc($table['TABLE_NAME']));
|
||||
echo $sql."\n";
|
||||
|
||||
$result = $db->q($sql);
|
||||
$result = dba::e($sql);
|
||||
if (!dbm::is_result($result)) {
|
||||
print_update_error($db, $sql);
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ function update_fail($update_id, $error_message) {
|
|||
$body = sprintf($body, $error_message);
|
||||
|
||||
notification(array(
|
||||
'type' => "SYSTEM_EMAIL",
|
||||
'type' => SYSTEM_EMAIL,
|
||||
'to_email' => $admin['email'],
|
||||
'preamble' => $preamble,
|
||||
'body' => $body,
|
||||
|
@ -442,9 +442,9 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
|
|||
// Ensure index conversion to unique removes duplicates
|
||||
if ($is_unique) {
|
||||
if ($ignore != "") {
|
||||
$db->q("SET session old_alter_table=1;");
|
||||
dba::e("SET session old_alter_table=1;");
|
||||
} else {
|
||||
$r = $db->q("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
|
||||
$r = dba::e("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
|
||||
if (!dbm::is_result($r)) {
|
||||
$errors .= print_update_error($db, $sql3);
|
||||
return $errors;
|
||||
|
@ -452,25 +452,25 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
|
|||
}
|
||||
}
|
||||
|
||||
$r = @$db->q($sql3);
|
||||
$r = @dba::e($sql3);
|
||||
if (!dbm::is_result($r)) {
|
||||
$errors .= print_update_error($db, $sql3);
|
||||
}
|
||||
if ($is_unique) {
|
||||
if ($ignore != "") {
|
||||
$db->q("SET session old_alter_table=0;");
|
||||
dba::e("SET session old_alter_table=0;");
|
||||
} else {
|
||||
$r = $db->q("INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";");
|
||||
$r = dba::e("INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";");
|
||||
if (!dbm::is_result($r)) {
|
||||
$errors .= print_update_error($db, $sql3);
|
||||
return $errors;
|
||||
}
|
||||
$r = $db->q("DROP TABLE `".$name."`;");
|
||||
$r = dba::e("DROP TABLE `".$name."`;");
|
||||
if (!dbm::is_result($r)) {
|
||||
$errors .= print_update_error($db, $sql3);
|
||||
return $errors;
|
||||
}
|
||||
$r = $db->q("RENAME TABLE `".$temp_name."` TO `".$name."`;");
|
||||
$r = dba::e("RENAME TABLE `".$temp_name."` TO `".$name."`;");
|
||||
if (!dbm::is_result($r)) {
|
||||
$errors .= print_update_error($db, $sql3);
|
||||
return $errors;
|
||||
|
@ -551,7 +551,7 @@ function db_create_table($name, $fields, $verbose, $action, $indexes=null) {
|
|||
echo $sql.";\n";
|
||||
|
||||
if ($action)
|
||||
$r = @$db->q($sql);
|
||||
$r = @dba::e($sql);
|
||||
|
||||
return $r;
|
||||
}
|
||||
|
|
|
@ -303,7 +303,7 @@ class dfrn {
|
|||
AND (NOT `contact`.`blocked` OR `contact`.`pending`)
|
||||
LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id`
|
||||
WHERE `item`.`id` = %d AND `item`.`visible` AND NOT `item`.`moderated` AND `item`.`parent` != 0
|
||||
AND `item`.`wall` AND NOT `item`.`private`",
|
||||
AND NOT `item`.`private`",
|
||||
intval($item_id)
|
||||
);
|
||||
|
||||
|
@ -330,12 +330,9 @@ class dfrn {
|
|||
|
||||
$alternatelink = $owner['url'];
|
||||
|
||||
$root = self::add_header($doc, $owner, 'dfrn:owner', $alternatelink, true);
|
||||
|
||||
$type = 'html';
|
||||
|
||||
$entry = self::entry($doc, $type, $item, $owner, true);
|
||||
$root->appendChild($entry);
|
||||
$root = self::entry($doc, $type, $item, $owner, true, 0, true);
|
||||
|
||||
$atom = trim($doc->saveXML());
|
||||
return $atom;
|
||||
|
@ -823,11 +820,12 @@ class dfrn {
|
|||
* @param array $owner Owner record
|
||||
* @param bool $comment Trigger the sending of the "comment" element
|
||||
* @param int $cid Contact ID of the recipient
|
||||
* @param bool $single If set, the entry is created as an XML document with a single "entry" element
|
||||
*
|
||||
* @return object XML entry object
|
||||
* @todo Add type-hints
|
||||
*/
|
||||
private static function entry($doc, $type, $item, $owner, $comment = false, $cid = 0) {
|
||||
private static function entry($doc, $type, $item, $owner, $comment = false, $cid = 0, $single = false) {
|
||||
|
||||
$mentioned = array();
|
||||
|
||||
|
@ -840,7 +838,22 @@ class dfrn {
|
|||
return xml::create_element($doc, "at:deleted-entry", "", $attributes);
|
||||
}
|
||||
|
||||
if (!$single) {
|
||||
$entry = $doc->createElement("entry");
|
||||
} else {
|
||||
$entry = $doc->createElementNS(NAMESPACE_ATOM1, 'entry');
|
||||
$doc->appendChild($entry);
|
||||
|
||||
$entry->setAttribute("xmlns:thr", NAMESPACE_THREAD);
|
||||
$entry->setAttribute("xmlns:at", NAMESPACE_TOMB);
|
||||
$entry->setAttribute("xmlns:media", NAMESPACE_MEDIA);
|
||||
$entry->setAttribute("xmlns:dfrn", NAMESPACE_DFRN);
|
||||
$entry->setAttribute("xmlns:activity", NAMESPACE_ACTIVITY);
|
||||
$entry->setAttribute("xmlns:georss", NAMESPACE_GEORSS);
|
||||
$entry->setAttribute("xmlns:poco", NAMESPACE_POCO);
|
||||
$entry->setAttribute("xmlns:ostatus", NAMESPACE_OSTATUS);
|
||||
$entry->setAttribute("xmlns:statusnet", NAMESPACE_STATUSNET);
|
||||
}
|
||||
|
||||
if ($item['allow_cid'] || $item['allow_gid'] || $item['deny_cid'] || $item['deny_gid']) {
|
||||
$body = fix_private_photos($item['body'],$owner['uid'],$item,$cid);
|
||||
|
@ -868,10 +881,10 @@ class dfrn {
|
|||
$entry->appendChild($dfrnowner);
|
||||
|
||||
if (($item['parent'] != $item['id']) || ($item['parent-uri'] !== $item['uri']) || (($item['thr-parent'] !== '') && ($item['thr-parent'] !== $item['uri']))) {
|
||||
$parent = q("SELECT `guid` FROM `item` WHERE `id` = %d", intval($item["parent"]));
|
||||
$parent_item = (($item['thr-parent']) ? $item['thr-parent'] : $item['parent-uri']);
|
||||
$parent = q("SELECT `guid`,`plink` FROM `item` WHERE `uri` = '%s' AND `uid` = %d", dbesc($parent_item), intval($item['uid']));
|
||||
$attributes = array("ref" => $parent_item, "type" => "text/html",
|
||||
"href" => System::baseUrl().'/display/'.$parent[0]['guid'],
|
||||
"href" => $parent[0]['plink'],
|
||||
"dfrn:diaspora_guid" => $parent[0]['guid']);
|
||||
xml::add_element($doc, $entry, "thr:in-reply-to", "", $attributes);
|
||||
}
|
||||
|
@ -1656,9 +1669,7 @@ class dfrn {
|
|||
$msg["seen"] = 0;
|
||||
$msg["replied"] = 0;
|
||||
|
||||
dbm::esc_array($msg, true);
|
||||
|
||||
$r = dbq("INSERT INTO `mail` (`".implode("`, `", array_keys($msg))."`) VALUES (".implode(", ", array_values($msg)).")");
|
||||
dba::insert('mail', $msg);
|
||||
|
||||
// send notifications.
|
||||
/// @TODO Arange this mess
|
||||
|
|
|
@ -1013,7 +1013,8 @@ class Diaspora {
|
|||
* @param array $item The item array
|
||||
*/
|
||||
private static function fetch_guid($item) {
|
||||
preg_replace_callback("=diaspora://.*?/([^\s\]]*)=ism",
|
||||
$expression = "=diaspora://.*?/post/([0-9A-Za-z\-_@.:]{15,254}[0-9A-Za-z])=ism";
|
||||
preg_replace_callback($expression,
|
||||
function ($match) use ($item) {
|
||||
return self::fetch_guid_sub($match, $item);
|
||||
}, $item["body"]);
|
||||
|
@ -1182,7 +1183,7 @@ class Diaspora {
|
|||
* @return array the item record
|
||||
*/
|
||||
private static function parent_item($uid, $guid, $author, $contact) {
|
||||
$r = q("SELECT `id`, `body`, `wall`, `uri`, `private`, `origin`,
|
||||
$r = q("SELECT `id`, `parent`, `body`, `wall`, `uri`, `private`, `origin`,
|
||||
`author-name`, `author-link`, `author-avatar`,
|
||||
`owner-name`, `owner-link`, `owner-avatar`
|
||||
FROM `item` WHERE `uid` = %d AND `guid` = '%s' LIMIT 1",
|
||||
|
@ -1776,8 +1777,16 @@ class Diaspora {
|
|||
logger("Stored like ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG);
|
||||
}
|
||||
|
||||
// like on comments have the comment as parent. So we need to fetch the toplevel parent
|
||||
if ($parent_item["id"] != $parent_item["parent"]) {
|
||||
$toplevel = dba::select('item', array('origin'), array('id' => $parent_item["parent"]), array('limit' => 1));
|
||||
$origin = $toplevel["origin"];
|
||||
} else {
|
||||
$origin = $parent_item["origin"];
|
||||
}
|
||||
|
||||
// If we are the origin of the parent we store the original data and notify our followers
|
||||
if ($message_id && $parent_item["origin"]) {
|
||||
if ($message_id && $origin) {
|
||||
|
||||
// Formerly we stored the signed text, the signature and the author in different fields.
|
||||
// We now store the raw data so that we are more flexible.
|
||||
|
@ -3517,7 +3526,14 @@ class Diaspora {
|
|||
$itemaddr = self::handle_from_contact($item["contact-id"], $item["gcontact-id"]);
|
||||
|
||||
$msg_type = "retraction";
|
||||
|
||||
if ($item['id'] == $item['parent']) {
|
||||
$target_type = "Post";
|
||||
} elseif ($item["verb"] == ACTIVITY_LIKE) {
|
||||
$target_type = "Like";
|
||||
} else {
|
||||
$target_type = "Comment";
|
||||
}
|
||||
|
||||
$message = array("author" => $itemaddr,
|
||||
"target_guid" => $item['guid'],
|
||||
|
|
|
@ -46,6 +46,7 @@ function notification($params) {
|
|||
if (empty($sender_email))
|
||||
$sender_email = t('noreply').'@'.$hostname;
|
||||
|
||||
if ($params['type'] != SYSTEM_EMAIL) {
|
||||
$user = dba::select('user', array('nickname', 'page-flags'),
|
||||
array('uid' => $params['uid']), array('limit' => 1));
|
||||
|
||||
|
@ -53,6 +54,7 @@ function notification($params) {
|
|||
if (!dbm::is_result($user) || in_array($user["page-flags"], array(PAGE_COMMUNITY, PAGE_PRVGROUP))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
$nickname = $user["nickname"];
|
||||
|
||||
// with $params['show_in_notification_page'] == false, the notification isn't inserted into
|
||||
|
@ -366,7 +368,7 @@ function notification($params) {
|
|||
}
|
||||
}
|
||||
|
||||
if ($params['type'] == "SYSTEM_EMAIL") {
|
||||
if ($params['type'] == SYSTEM_EMAIL) {
|
||||
// not part of the notifications.
|
||||
// it just send a mail to the user.
|
||||
// It will be used by the system to send emails to users (like
|
||||
|
@ -517,7 +519,7 @@ function notification($params) {
|
|||
// send email notification if notification preferences permit
|
||||
if ((intval($params['notify_flags']) & intval($params['type']))
|
||||
|| $params['type'] == NOTIFY_SYSTEM
|
||||
|| $params['type'] == "SYSTEM_EMAIL") {
|
||||
|| $params['type'] == SYSTEM_EMAIL) {
|
||||
|
||||
logger('sending notification email');
|
||||
|
||||
|
@ -586,8 +588,8 @@ function notification($params) {
|
|||
call_hooks('enotify_mail', $datarray);
|
||||
|
||||
// check whether sending post content in email notifications is allowed
|
||||
// always true for "SYSTEM_EMAIL"
|
||||
$content_allowed = ((!get_config('system', 'enotify_no_content')) || ($params['type'] == "SYSTEM_EMAIL"));
|
||||
// always true for SYSTEM_EMAIL
|
||||
$content_allowed = ((!get_config('system', 'enotify_no_content')) || ($params['type'] == SYSTEM_EMAIL));
|
||||
|
||||
// load the template for private message notifications
|
||||
$tpl = get_markup_template('email_notify_html.tpl');
|
||||
|
|
|
@ -534,6 +534,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
|
|||
}
|
||||
|
||||
// Converting the plink
|
||||
/// @todo Check if this is really still needed
|
||||
if ($arr['network'] == NETWORK_OSTATUS) {
|
||||
if (isset($arr['plink'])) {
|
||||
$arr['plink'] = ostatus::convert_href($arr['plink']);
|
||||
|
@ -954,7 +955,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
|
|||
* An unique index would help - but the limitations of MySQL (maximum size of index values) prevent this.
|
||||
*/
|
||||
if ($arr["uid"] == 0) {
|
||||
$r = qu("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = 0 LIMIT 1", dbesc(trim($arr['uri'])));
|
||||
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = 0 LIMIT 1", dbesc(trim($arr['uri'])));
|
||||
if (dbm::is_result($r)) {
|
||||
logger('Global item already stored. URI: '.$arr['uri'].' on network '.$arr['network'], LOGGER_DEBUG);
|
||||
return 0;
|
||||
|
@ -1595,9 +1596,6 @@ function item_is_remote_self($contact, &$datarray) {
|
|||
$datarray['author-link'] = $datarray['owner-link'];
|
||||
$datarray['author-avatar'] = $datarray['owner-avatar'];
|
||||
|
||||
// Trigger automatic reactions for addons
|
||||
$datarray['api_source'] = true;
|
||||
|
||||
unset($datarray['created']);
|
||||
unset($datarray['edited']);
|
||||
}
|
||||
|
@ -1623,6 +1621,13 @@ function item_is_remote_self($contact, &$datarray) {
|
|||
$datarray["app"] = "Feed";
|
||||
}
|
||||
|
||||
// Trigger automatic reactions for addons
|
||||
$datarray['api_source'] = true;
|
||||
|
||||
// We have to tell the hooks who we are - this really should be improved
|
||||
$_SESSION["authenticated"] = true;
|
||||
$_SESSION["uid"] = $contact['uid'];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,22 +60,14 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
|
|||
|
||||
$handles = $recip_handle . ';' . $sender_handle;
|
||||
|
||||
$r = q("insert into conv (uid,guid,creator,created,updated,subject,recips) values(%d, '%s', '%s', '%s', '%s', '%s', '%s') ",
|
||||
intval(local_user()),
|
||||
dbesc($conv_guid),
|
||||
dbesc($sender_handle),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc($subject),
|
||||
dbesc($handles)
|
||||
);
|
||||
$fields = array('uid' => local_user(), 'guid' => $conv_guid, 'creator' => $sender_handle,
|
||||
'created' => datetime_convert(), 'updated' => datetime_convert(),
|
||||
'subject' => $subject, 'recips' => $handles);
|
||||
$r = dba::insert('conv', $fields);
|
||||
|
||||
$r = q("select * from conv where guid = '%s' and uid = %d limit 1",
|
||||
dbesc($conv_guid),
|
||||
intval(local_user())
|
||||
);
|
||||
$r = dba::select('conv', array('id'), array('guid' => $conv_guid, 'uid' => local_user()), array('limit' => 1));
|
||||
if (dbm::is_result($r))
|
||||
$convid = $r[0]['id'];
|
||||
$convid = $r['id'];
|
||||
}
|
||||
|
||||
if (! $convid) {
|
||||
|
@ -194,28 +186,18 @@ function send_wallmessage($recipient='', $body='', $subject='', $replyto=''){
|
|||
|
||||
$handles = $recip_handle . ';' . $sender_handle;
|
||||
|
||||
$r = q("INSERT INTO `conv` (`uid`,`guid`,`creator`,`created`,`updated`,`subject`,`recips`) values(%d, '%s', '%s', '%s', '%s', '%s', '%s') ",
|
||||
intval($recipient['uid']),
|
||||
dbesc($conv_guid),
|
||||
dbesc($sender_handle),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc($subject),
|
||||
dbesc($handles)
|
||||
);
|
||||
|
||||
$r = q("SELECT * FROM `conv` WHERE `guid` = '%s' AND `uid` = %d LIMIT 1",
|
||||
dbesc($conv_guid),
|
||||
intval($recipient['uid'])
|
||||
);
|
||||
|
||||
$fields = array('uid' => $recipient['uid'], 'guid' => $conv_guid, 'creator' => $sender_handle,
|
||||
'created' => datetime_convert(), 'updated' => datetime_convert(),
|
||||
'subject' => $subject, 'recips' => $handles);
|
||||
$r = dba::insert('conv', $fields);
|
||||
|
||||
$r = dba::select('conv', array('id'), array('guid' => $conv_guid, 'uid' => $recipient['uid']), array('limit' => 1));
|
||||
if (!dbm::is_result($r)) {
|
||||
logger('send message: conversation not found.');
|
||||
return -4;
|
||||
}
|
||||
|
||||
$convid = $r[0]['id'];
|
||||
$convid = $r['id'];
|
||||
|
||||
$r = q("INSERT INTO `mail` ( `uid`, `guid`, `convid`, `from-name`, `from-photo`, `from-url`,
|
||||
`contact-id`, `title`, `body`, `seen`, `reply`, `replied`, `uri`, `parent-uri`, `created`, `unknown`)
|
||||
|
|
1542
include/ostatus.php
1542
include/ostatus.php
File diff suppressed because it is too large
Load diff
|
@ -48,7 +48,7 @@ function photo_albums($uid, $update = false) {
|
|||
if (!Config::get('system', 'no_count', false)) {
|
||||
/// @todo This query needs to be renewed. It is really slow
|
||||
// At this time we just store the data in the cache
|
||||
$albums = qu("SELECT COUNT(DISTINCT `resource-id`) AS `total`, `album`, ANY_VALUE(`created`) AS `created`
|
||||
$albums = q("SELECT COUNT(DISTINCT `resource-id`) AS `total`, `album`, ANY_VALUE(`created`) AS `created`
|
||||
FROM `photo`
|
||||
WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' $sql_extra
|
||||
GROUP BY `album` ORDER BY `created` DESC",
|
||||
|
@ -58,7 +58,7 @@ function photo_albums($uid, $update = false) {
|
|||
);
|
||||
} else {
|
||||
// This query doesn't do the count and is much faster
|
||||
$albums = qu("SELECT DISTINCT(`album`), '' AS `total`
|
||||
$albums = q("SELECT DISTINCT(`album`), '' AS `total`
|
||||
FROM `photo` USE INDEX (`uid_album_scale_created`)
|
||||
WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' $sql_extra",
|
||||
intval($uid),
|
||||
|
|
|
@ -303,6 +303,9 @@ function poller_exec_function($queue, $funcname, $argv) {
|
|||
|
||||
$up_duration = number_format(microtime(true) - $poller_up_start, 3);
|
||||
|
||||
// Reset global data to avoid interferences
|
||||
unset($_SESSION);
|
||||
|
||||
$funcname($argv, $argc);
|
||||
|
||||
$a->process_id = $old_process_id;
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// Session management functions. These provide database storage of PHP
|
||||
// session info.
|
||||
|
||||
use Friendica\Core\Config;
|
||||
|
||||
require_once('include/cache.php');
|
||||
|
||||
$session_exists = 0;
|
||||
|
@ -114,6 +116,10 @@ ini_set('session.gc_probability', $gc_probability);
|
|||
ini_set('session.use_only_cookies', 1);
|
||||
ini_set('session.cookie_httponly', 1);
|
||||
|
||||
if (Config::get('system', 'ssl_policy') == SSL_POLICY_FULL) {
|
||||
ini_set('session.cookie_secure', 1);
|
||||
}
|
||||
|
||||
if (!get_config('system', 'disable_database_session')) {
|
||||
session_set_save_handler('ref_session_open', 'ref_session_close',
|
||||
'ref_session_read', 'ref_session_write',
|
||||
|
|
|
@ -1158,8 +1158,9 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
|||
$network = NETWORK_OSTATUS;
|
||||
}
|
||||
}
|
||||
if (strstr($orig_version, 'Pleroma')) {
|
||||
if (strstr($orig_version.$version, 'Pleroma')) {
|
||||
$platform = 'Pleroma';
|
||||
$version = trim(str_replace('Pleroma', '', $version));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2238,22 +2239,22 @@ function update_gcontact($contact) {
|
|||
|
||||
if ($update) {
|
||||
logger("Update gcontact for ".$contact["url"], LOGGER_DEBUG);
|
||||
$condition = array('`nurl` = ? AND (`generation` = 0 OR `generation` >= ?)',
|
||||
normalise_link($contact["url"]), $contact["generation"]);
|
||||
$contact["updated"] = dbm::date($contact["updated"]);
|
||||
|
||||
q("UPDATE `gcontact` SET `photo` = '%s', `name` = '%s', `nick` = '%s', `addr` = '%s', `network` = '%s',
|
||||
`birthday` = '%s', `gender` = '%s', `keywords` = '%s', `hide` = %d, `nsfw` = %d,
|
||||
`contact-type` = %d, `alias` = '%s', `notify` = '%s', `url` = '%s',
|
||||
`location` = '%s', `about` = '%s', `generation` = %d, `updated` = '%s',
|
||||
`server_url` = '%s', `connect` = '%s'
|
||||
WHERE `nurl` = '%s' AND (`generation` = 0 OR `generation` >= %d)",
|
||||
dbesc($contact["photo"]), dbesc($contact["name"]), dbesc($contact["nick"]),
|
||||
dbesc($contact["addr"]), dbesc($contact["network"]), dbesc($contact["birthday"]),
|
||||
dbesc($contact["gender"]), dbesc($contact["keywords"]), intval($contact["hide"]),
|
||||
intval($contact["nsfw"]), intval($contact["contact-type"]), dbesc($contact["alias"]),
|
||||
dbesc($contact["notify"]), dbesc($contact["url"]), dbesc($contact["location"]),
|
||||
dbesc($contact["about"]), intval($contact["generation"]), dbesc(dbm::date($contact["updated"])),
|
||||
dbesc($contact["server_url"]), dbesc($contact["connect"]),
|
||||
dbesc(normalise_link($contact["url"])), intval($contact["generation"]));
|
||||
$updated = array('photo' => $contact['photo'], 'name' => $contact['name'],
|
||||
'nick' => $contact['nick'], 'addr' => $contact['addr'],
|
||||
'network' => $contact['network'], 'birthday' => $contact['birthday'],
|
||||
'gender' => $contact['gender'], 'keywords' => $contact['keywords'],
|
||||
'hide' => $contact['hide'], 'nsfw' => $contact['nsfw'],
|
||||
'contact-type' => $contact['contact-type'], 'alias' => $contact['alias'],
|
||||
'notify' => $contact['notify'], 'url' => $contact['url'],
|
||||
'location' => $contact['location'], 'about' => $contact['about'],
|
||||
'generation' => $contact['generation'], 'updated' => $contact['updated'],
|
||||
'server_url' => $contact['server_url'], 'connect' => $contact['connect']);
|
||||
|
||||
dba::update('gcontact', $updated, $condition, $fields);
|
||||
|
||||
// Now update the contact entry with the user id "0" as well.
|
||||
// This is used for the shadow copies of public items.
|
||||
|
@ -2261,20 +2262,25 @@ function update_gcontact($contact) {
|
|||
dbesc(normalise_link($contact["url"])));
|
||||
|
||||
if (dbm::is_result($r)) {
|
||||
logger("Update shadow contact ".$r[0]["id"], LOGGER_DEBUG);
|
||||
logger("Update public contact ".$r[0]["id"], LOGGER_DEBUG);
|
||||
|
||||
update_contact_avatar($contact["photo"], 0, $r[0]["id"]);
|
||||
|
||||
q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `addr` = '%s',
|
||||
`network` = '%s', `bd` = '%s', `gender` = '%s',
|
||||
`keywords` = '%s', `alias` = '%s', `contact-type` = %d,
|
||||
`url` = '%s', `location` = '%s', `about` = '%s'
|
||||
WHERE `id` = %d",
|
||||
dbesc($contact["name"]), dbesc($contact["nick"]), dbesc($contact["addr"]),
|
||||
dbesc($contact["network"]), dbesc($contact["birthday"]), dbesc($contact["gender"]),
|
||||
dbesc($contact["keywords"]), dbesc($contact["alias"]), intval($contact["contact-type"]),
|
||||
dbesc($contact["url"]), dbesc($contact["location"]), dbesc($contact["about"]),
|
||||
intval($r[0]["id"]));
|
||||
$fields = array('name', 'nick', 'addr',
|
||||
'network', 'bd', 'gender',
|
||||
'keywords', 'alias', 'contact-type',
|
||||
'url', 'location', 'about');
|
||||
$old_contact = dba::select('contact', $fields, array('id' => $r[0]["id"]), array('limit' => 1));
|
||||
|
||||
// Update it with the current values
|
||||
$fields = array('name' => $contact['name'], 'nick' => $contact['nick'],
|
||||
'addr' => $contact['addr'], 'network' => $contact['network'],
|
||||
'bd' => $contact['birthday'], 'gender' => $contact['gender'],
|
||||
'keywords' => $contact['keywords'], 'alias' => $contact['alias'],
|
||||
'contact-type' => $contact['contact-type'], 'url' => $contact['url'],
|
||||
'location' => $contact['location'], 'about' => $contact['about']);
|
||||
|
||||
dba::update('contact', $fields, array('id' => $r[0]["id"]), $old_contact);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -748,7 +748,7 @@ function logger($msg, $level = 0) {
|
|||
|
||||
$callers = debug_backtrace();
|
||||
$logline = sprintf("%s@%s\t[%s]:%s:%s:%s\t%s\n",
|
||||
datetime_convert(),
|
||||
datetime_convert('UTC', 'UTC', 'now', 'Y-m-d\TH:i:s\Z'),
|
||||
$process_id,
|
||||
$LOGGER_LEVELS[$level],
|
||||
basename($callers[0]['file']),
|
||||
|
@ -1424,16 +1424,9 @@ function prepare_body(&$item, $attach = false, $preview = false) {
|
|||
$title = ((strlen(trim($mtch[4]))) ? escape_tags(trim($mtch[4])) : escape_tags($mtch[1]));
|
||||
$title .= ' ' . $mtch[2] . ' ' . t('bytes');
|
||||
|
||||
if (($filetype == 'image') AND ($item['network'] == NETWORK_OSTATUS)) {
|
||||
/// @todo Respect the spoiler for mastodon
|
||||
$icon = '<img class="attached" src="'.$the_url.'" alt="" title="'.$title.'">';
|
||||
$s .= '<br><a href="' . strip_tags($the_url) . '" title="' . $title . '" class="attached" target="_blank" >' . $icon . '</a>';
|
||||
} else {
|
||||
$icon = '<div class="attachtype icon s22 type-' . $filetype . ' subtype-' . $filesubtype . '"></div>';
|
||||
$as .= '<a href="' . strip_tags($the_url) . '" title="' . $title . '" class="attachlink" target="_blank" >' . $icon . '</a>';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,11 +16,7 @@ function add_thread($itemid, $onlyshadow = false) {
|
|||
$item['iid'] = $itemid;
|
||||
|
||||
if (!$onlyshadow) {
|
||||
$result = dbq("INSERT INTO `thread` (`"
|
||||
.implode("`, `", array_keys($item))
|
||||
."`) VALUES ('"
|
||||
.implode("', '", array_values($item))
|
||||
."')");
|
||||
$result = dba::insert('thread', $item);
|
||||
|
||||
logger("Add thread for item ".$itemid." - ".print_r($result, true), LOGGER_DEBUG);
|
||||
}
|
||||
|
@ -244,18 +240,19 @@ function delete_thread_uri($itemuri, $uid) {
|
|||
function delete_thread($itemid, $itemuri = "") {
|
||||
$item = q("SELECT `uid` FROM `thread` WHERE `iid` = %d", intval($itemid));
|
||||
|
||||
// Using dba::delete at this time could delete the associated item entries
|
||||
$result = q("DELETE FROM `thread` WHERE `iid` = %d", intval($itemid));
|
||||
|
||||
logger("delete_thread: Deleted thread for item ".$itemid." - ".print_r($result, true), LOGGER_DEBUG);
|
||||
|
||||
if ($itemuri != "") {
|
||||
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND NOT (`uid` IN (%d, 0))",
|
||||
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND NOT `deleted` AND NOT (`uid` IN (%d, 0))",
|
||||
dbesc($itemuri),
|
||||
intval($item["uid"])
|
||||
);
|
||||
if (!dbm::is_result($r)) {
|
||||
dba::delete('item', array('uri' => $itemuri, 'uid' => 0));
|
||||
logger("delete_thread: Deleted shadow for item ".$itemuri." - ".print_r($result, true), LOGGER_DEBUG);
|
||||
logger("delete_thread: Deleted shadow for item ".$itemuri, LOGGER_DEBUG);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -404,7 +404,7 @@ function send_register_pending_eml($email, $sitename, $username) {
|
|||
$body = sprintf($body, $username, $sitename);
|
||||
|
||||
return notification(array(
|
||||
'type' => "SYSTEM_EMAIL",
|
||||
'type' => SYSTEM_EMAIL,
|
||||
'to_email' => $email,
|
||||
'subject'=> sprintf( t('Registration at %s'), $sitename),
|
||||
'body' => $body));
|
||||
|
@ -450,7 +450,7 @@ function send_register_open_eml($email, $sitename, $siteurl, $username, $passwor
|
|||
$body = sprintf($body, $email, $sitename, $siteurl, $username, $password);
|
||||
|
||||
return notification(array(
|
||||
'type' => "SYSTEM_EMAIL",
|
||||
'type' => SYSTEM_EMAIL,
|
||||
'to_email' => $email,
|
||||
'subject'=> sprintf( t('Registration details for %s'), $sitename),
|
||||
'preamble'=> $preamble,
|
||||
|
|
13
index.php
13
index.php
|
@ -489,6 +489,19 @@ $profile = $a->profile;
|
|||
header("X-Friendica-Version: " . FRIENDICA_VERSION);
|
||||
header("Content-type: text/html; charset=utf-8");
|
||||
|
||||
if (Config::get('system', 'hsts') && (Config::get('system', 'ssl_policy') == SSL_POLICY_FULL)) {
|
||||
header("Strict-Transport-Security: max-age=31536000");
|
||||
}
|
||||
|
||||
// Some security stuff
|
||||
header('X-Content-Type-Options: nosniff');
|
||||
header('X-XSS-Protection: 1; mode=block');
|
||||
header('X-Permitted-Cross-Domain-Policies: none');
|
||||
header('X-Frame-Options: sameorigin');
|
||||
|
||||
// Things like embedded OSM maps don't work, when this is enabled
|
||||
// header("Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; connect-src 'self'; style-src 'self' 'unsafe-inline'; font-src 'self'; img-src 'self' https: data:; media-src 'self' https:; child-src 'self' https:; object-src 'none'");
|
||||
|
||||
/*
|
||||
* We use $_GET["mode"] for special page templates. So we will check if we have
|
||||
* to load another page template than the default one.
|
||||
|
|
|
@ -457,7 +457,7 @@ function admin_page_federation(App $a) {
|
|||
foreach ($platforms as $p) {
|
||||
// get a total count for the platform, the name and version of the
|
||||
// highest version and the protocol tpe
|
||||
$c = qu('SELECT COUNT(*) AS `total`, ANY_VALUE(`platform`) AS `platform`,
|
||||
$c = q('SELECT COUNT(*) AS `total`, ANY_VALUE(`platform`) AS `platform`,
|
||||
ANY_VALUE(`network`) AS `network`, MAX(`version`) AS `version` FROM `gserver`
|
||||
WHERE `platform` LIKE "%s" AND `last_contact` >= `last_failure`
|
||||
ORDER BY `version` ASC;', $p);
|
||||
|
@ -465,7 +465,7 @@ function admin_page_federation(App $a) {
|
|||
|
||||
// what versions for that platform do we know at all?
|
||||
// again only the active nodes
|
||||
$v = qu('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"
|
||||
GROUP BY `version`
|
||||
ORDER BY `version`;', $p);
|
||||
|
@ -644,13 +644,13 @@ function admin_page_summary(App $a) {
|
|||
|
||||
logger('accounts: '.print_r($accounts,true),LOGGER_DATA);
|
||||
|
||||
$r = qu("SELECT COUNT(`id`) AS `count` FROM `register`");
|
||||
$r = q("SELECT COUNT(`id`) AS `count` FROM `register`");
|
||||
$pending = $r[0]['count'];
|
||||
|
||||
$r = qu("SELECT COUNT(*) AS `total` FROM `queue` WHERE 1");
|
||||
$r = q("SELECT COUNT(*) AS `total` FROM `queue` WHERE 1");
|
||||
$queue = (($r) ? $r[0]['total'] : 0);
|
||||
|
||||
$r = qu("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE NOT `done`");
|
||||
$r = q("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE NOT `done`");
|
||||
$workerqueue = (($r) ? $r[0]['total'] : 0);
|
||||
|
||||
// We can do better, but this is a quick queue status
|
||||
|
@ -1395,7 +1395,7 @@ function admin_page_users_post(App $a) {
|
|||
$body = sprintf($body, System::baseUrl(), $nu['email'], $result['password'], $a->config['sitename']);
|
||||
|
||||
notification(array(
|
||||
'type' => "SYSTEM_EMAIL",
|
||||
'type' => SYSTEM_EMAIL,
|
||||
'to_email' => $nu['email'],
|
||||
'subject'=> sprintf(t('Registration details for %s'), $a->config['sitename']),
|
||||
'preamble'=> $preamble,
|
||||
|
@ -1487,7 +1487,7 @@ function admin_page_users(App $a) {
|
|||
|
||||
|
||||
/* get users */
|
||||
$total = qu("SELECT COUNT(*) AS `total` FROM `user` WHERE 1");
|
||||
$total = q("SELECT COUNT(*) AS `total` FROM `user` WHERE 1");
|
||||
if (count($total)) {
|
||||
$a->set_pager_total($total[0]['total']);
|
||||
$a->set_pager_itemspage(100);
|
||||
|
@ -1522,7 +1522,7 @@ function admin_page_users(App $a) {
|
|||
$sql_order = "`".str_replace('.','`.`',$order)."`";
|
||||
$sql_order_direction = ($order_direction === "+")?"ASC":"DESC";
|
||||
|
||||
$users = qu("SELECT `user`.*, `contact`.`name`, `contact`.`url`, `contact`.`micro`, `user`.`account_expired`, `contact`.`last-item` AS `lastitem_date`
|
||||
$users = q("SELECT `user`.*, `contact`.`name`, `contact`.`url`, `contact`.`micro`, `user`.`account_expired`, `contact`.`last-item` AS `lastitem_date`
|
||||
FROM `user`
|
||||
INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
|
||||
WHERE `user`.`verified`
|
||||
|
|
|
@ -574,9 +574,15 @@ function contacts_content(App $a) {
|
|||
if ($contact['network'] == NETWORK_DFRN)
|
||||
$profile_select = contact_profile_assign($contact['profile-id'],(($contact['network'] !== NETWORK_DFRN) ? true : false));
|
||||
|
||||
if (in_array($contact['network'], array(NETWORK_DIASPORA, NETWORK_OSTATUS)) &&
|
||||
($contact['rel'] == CONTACT_IS_FOLLOWER))
|
||||
if (in_array($contact['network'], array(NETWORK_DIASPORA, NETWORK_OSTATUS))) {
|
||||
if ($contact['rel'] == CONTACT_IS_FOLLOWER) {
|
||||
$follow = System::baseUrl(true)."/follow?url=".urlencode($contact["url"]);
|
||||
$follow_text = t("Connect/Follow");
|
||||
} elseif ($contact['rel'] == CONTACT_IS_FRIEND) {
|
||||
$follow = System::baseUrl(true)."/unfollow?url=".urlencode($contact["url"]);
|
||||
$follow_text = t("Disconnect/Unfollow");
|
||||
}
|
||||
}
|
||||
|
||||
// Load contactact related actions like hide, suggest, delete and others
|
||||
$contact_actions = contact_actions($contact);
|
||||
|
@ -613,7 +619,7 @@ function contacts_content(App $a) {
|
|||
'$last_update' => $last_update,
|
||||
'$udnow' => t('Update now'),
|
||||
'$follow' => $follow,
|
||||
'$follow_text' => t("Connect/Follow"),
|
||||
'$follow_text' => $follow_text,
|
||||
'$profile_select' => $profile_select,
|
||||
'$contact_id' => $contact['id'],
|
||||
'$block_text' => (($contact['blocked']) ? t('Unblock') : t('Block') ),
|
||||
|
|
|
@ -35,10 +35,7 @@ function delegate_content(App $a) {
|
|||
dbesc(normalise_link(System::baseUrl() . '/profile/' . $r[0]['nickname']))
|
||||
);
|
||||
if (dbm::is_result($r)) {
|
||||
q("insert into manage ( uid, mid ) values ( %d , %d ) ",
|
||||
intval($a->argv[2]),
|
||||
intval(local_user())
|
||||
);
|
||||
dba::insert('manage', array('uid' => $a->argv[2], 'mid' => local_user()));
|
||||
}
|
||||
}
|
||||
goaway(System::baseUrl() . '/delegate');
|
||||
|
|
|
@ -352,8 +352,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
|
|||
dbesc(NETWORK_DFRN),
|
||||
intval($contact_id)
|
||||
);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
// $network !== NETWORK_DFRN
|
||||
|
||||
|
@ -361,18 +360,16 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
|
|||
$notify = (($contact['notify']) ? $contact['notify'] : '');
|
||||
$poll = (($contact['poll']) ? $contact['poll'] : '');
|
||||
|
||||
if((! $contact['notify']) || (! $contact['poll'])) {
|
||||
$arr = Probe::lrdd($contact['url']);
|
||||
if(count($arr)) {
|
||||
foreach($arr as $link) {
|
||||
if($link['@attributes']['rel'] === 'salmon')
|
||||
$notify = $link['@attributes']['href'];
|
||||
if($link['@attributes']['rel'] === NAMESPACE_FEED)
|
||||
$poll = $link['@attributes']['href'];
|
||||
}
|
||||
$arr = Probe::uri($contact['url']);
|
||||
if (empty($contact['notify'])) {
|
||||
$notify = $arr['notify'];
|
||||
}
|
||||
if (empty($contact['poll'])) {
|
||||
$poll = $arr['poll'];
|
||||
}
|
||||
|
||||
$addr = $arr['addr'];
|
||||
|
||||
$new_relation = $contact['rel'];
|
||||
$writable = $contact['writable'];
|
||||
|
||||
|
@ -394,6 +391,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
|
|||
|
||||
$r = q("UPDATE `contact` SET `name-date` = '%s',
|
||||
`uri-date` = '%s',
|
||||
`addr` = '%s',
|
||||
`notify` = '%s',
|
||||
`poll` = '%s',
|
||||
`blocked` = 0,
|
||||
|
@ -406,6 +404,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
|
|||
",
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc($addr),
|
||||
dbesc($notify),
|
||||
dbesc($poll),
|
||||
dbesc($network),
|
||||
|
|
|
@ -71,7 +71,7 @@ function directory_content(App $a) {
|
|||
$publish = ((get_config('system','publish_all')) ? '' : " AND `publish` = 1 " );
|
||||
|
||||
|
||||
$r = $db->q("SELECT COUNT(*) AS `total` FROM `profile`
|
||||
$r = q("SELECT COUNT(*) AS `total` FROM `profile`
|
||||
LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
|
||||
WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra ");
|
||||
if (dbm::is_result($r))
|
||||
|
@ -81,11 +81,11 @@ function directory_content(App $a) {
|
|||
|
||||
$limit = intval($a->pager['start']).",".intval($a->pager['itemspage']);
|
||||
|
||||
$r = $db->q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` , `user`.`page-flags`,
|
||||
$r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` , `user`.`page-flags`,
|
||||
`contact`.`addr`, `contact`.`url` AS profile_url FROM `profile`
|
||||
LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
|
||||
LEFT JOIN `contact` ON `contact`.`uid` = `user`.`uid`
|
||||
WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 AND `contact`.`self` $sql_extra $order LIMIT ".$limit);
|
||||
WHERE `is-default` $publish AND `user`.`blocked` = 0 AND `contact`.`self` $sql_extra $order LIMIT ".$limit);
|
||||
if (dbm::is_result($r)) {
|
||||
|
||||
if (in_array('small', $a->argv)) {
|
||||
|
|
|
@ -17,13 +17,7 @@ function display_init(App $a) {
|
|||
if ($a->argc == 3) {
|
||||
if (substr($a->argv[2], -5) == '.atom') {
|
||||
$item_id = substr($a->argv[2], 0, -5);
|
||||
$xml = dfrn::itemFeed($item_id);
|
||||
if ($xml == '') {
|
||||
http_status_exit(500);
|
||||
}
|
||||
header("Content-type: application/atom+xml");
|
||||
echo $xml;
|
||||
killme();
|
||||
displayShowFeed($item_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,6 +64,12 @@ function display_init(App $a) {
|
|||
AND `item`.`guid` = ? LIMIT 1", $a->argv[1]);
|
||||
}
|
||||
if (dbm::is_result($r)) {
|
||||
|
||||
if (strstr($_SERVER['HTTP_ACCEPT'], 'application/atom+xml')) {
|
||||
logger('Directly serving XML for id '.$r["id"], LOGGER_DEBUG);
|
||||
displayShowFeed($r["id"]);
|
||||
}
|
||||
|
||||
if ($r["id"] != $r["parent"]) {
|
||||
$r = dba::fetch_first("SELECT `id`, `author-name`, `author-link`, `author-avatar`, `network`, `body`, `uid`, `owner-link` FROM `item`
|
||||
WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
|
||||
|
@ -293,7 +293,7 @@ function display_content(App $a, $update = 0) {
|
|||
}
|
||||
|
||||
// We are displaying an "alternate" link if that post was public. See issue 2864
|
||||
$is_public = dba::exists('item', array('id' => $item_id, 'private' => false, 'wall' => true));
|
||||
$is_public = dba::exists('item', array('id' => $item_id, 'private' => false));
|
||||
if ($is_public) {
|
||||
$alternate = System::baseUrl().'/display/'.$nick.'/'.$item_id.'.atom';
|
||||
} else {
|
||||
|
@ -499,3 +499,12 @@ function display_content(App $a, $update = 0) {
|
|||
return $o;
|
||||
}
|
||||
|
||||
function displayShowFeed($item_id) {
|
||||
$xml = dfrn::itemFeed($item_id);
|
||||
if ($xml == '') {
|
||||
http_status_exit(500);
|
||||
}
|
||||
header("Content-type: application/atom+xml");
|
||||
echo $xml;
|
||||
killme();
|
||||
}
|
||||
|
|
|
@ -8,6 +8,47 @@ require_once 'include/follow.php';
|
|||
require_once 'include/Contact.php';
|
||||
require_once 'include/contact_selectors.php';
|
||||
|
||||
function follow_post(App $a) {
|
||||
|
||||
if (! local_user()) {
|
||||
notice( t('Permission denied.') . EOL);
|
||||
goaway($_SESSION['return_url']);
|
||||
// NOTREACHED
|
||||
}
|
||||
|
||||
if ($_REQUEST['cancel']) {
|
||||
goaway($_SESSION['return_url']);
|
||||
}
|
||||
|
||||
$uid = local_user();
|
||||
$url = notags(trim($_REQUEST['url']));
|
||||
$return_url = $_SESSION['return_url'];
|
||||
|
||||
// Makes the connection request for friendica contacts easier
|
||||
// This is just a precaution if maybe this page is called somewhere directly via POST
|
||||
$_SESSION["fastlane"] = $url;
|
||||
|
||||
$result = new_contact($uid,$url,true);
|
||||
|
||||
if ($result['success'] == false) {
|
||||
if ($result['message']) {
|
||||
notice($result['message']);
|
||||
}
|
||||
goaway($return_url);
|
||||
} elseif ($result['cid']) {
|
||||
goaway(System::baseUrl().'/contacts/'.$result['cid']);
|
||||
}
|
||||
|
||||
info( t('Contact added').EOL);
|
||||
|
||||
if (strstr($return_url,'contacts')) {
|
||||
goaway(System::baseUrl().'/contacts/'.$contact_id);
|
||||
}
|
||||
|
||||
goaway($return_url);
|
||||
// NOTREACHED
|
||||
}
|
||||
|
||||
function follow_content(App $a) {
|
||||
|
||||
if (! local_user()) {
|
||||
|
@ -99,13 +140,6 @@ function follow_content(App $a) {
|
|||
$r[0]["about"] = "";
|
||||
}
|
||||
|
||||
$header = $ret["name"];
|
||||
|
||||
if ($ret["addr"] != "") {
|
||||
$header .= " <".$ret["addr"].">";
|
||||
}
|
||||
|
||||
//$header .= " (".network_to_name($ret['network'], $ret['url']).")";
|
||||
$header = t("Connect/Follow");
|
||||
|
||||
$o = replace_macros($tpl,array(
|
||||
|
@ -154,44 +188,3 @@ function follow_content(App $a) {
|
|||
|
||||
return $o;
|
||||
}
|
||||
|
||||
function follow_post(App $a) {
|
||||
|
||||
if (! local_user()) {
|
||||
notice( t('Permission denied.') . EOL);
|
||||
goaway($_SESSION['return_url']);
|
||||
// NOTREACHED
|
||||
}
|
||||
|
||||
if ($_REQUEST['cancel']) {
|
||||
goaway($_SESSION['return_url']);
|
||||
}
|
||||
|
||||
$uid = local_user();
|
||||
$url = notags(trim($_REQUEST['url']));
|
||||
$return_url = $_SESSION['return_url'];
|
||||
|
||||
// Makes the connection request for friendica contacts easier
|
||||
// This is just a precaution if maybe this page is called somewhere directly via POST
|
||||
$_SESSION["fastlane"] = $url;
|
||||
|
||||
$result = new_contact($uid,$url,true);
|
||||
|
||||
if ($result['success'] == false) {
|
||||
if ($result['message']) {
|
||||
notice($result['message']);
|
||||
}
|
||||
goaway($return_url);
|
||||
} elseif ($result['cid']) {
|
||||
goaway(System::baseUrl().'/contacts/'.$result['cid']);
|
||||
}
|
||||
|
||||
info( t('Contact added').EOL);
|
||||
|
||||
if (strstr($return_url,'contacts')) {
|
||||
goaway(System::baseUrl().'/contacts/'.$contact_id);
|
||||
}
|
||||
|
||||
goaway($return_url);
|
||||
// NOTREACHED
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ function lostpass_post(App $a) {
|
|||
$body = sprintf($body, $resetlink, System::baseUrl(), $email);
|
||||
|
||||
notification(array(
|
||||
'type' => "SYSTEM_EMAIL",
|
||||
'type' => SYSTEM_EMAIL,
|
||||
'to_email' => $email,
|
||||
'subject'=> sprintf( t('Password reset requested at %s'),$sitename),
|
||||
'preamble'=> $preamble,
|
||||
|
@ -145,7 +145,7 @@ function lostpass_content(App $a) {
|
|||
$body = sprintf($body, System::baseUrl(), $email, $new_password);
|
||||
|
||||
notification(array(
|
||||
'type' => "SYSTEM_EMAIL",
|
||||
'type' => SYSTEM_EMAIL,
|
||||
'to_email' => $email,
|
||||
'subject'=> sprintf( t('Your password has been changed at %s'),$sitename),
|
||||
'preamble'=> $preamble,
|
||||
|
|
557
mod/network.php
557
mod/network.php
|
@ -2,6 +2,15 @@
|
|||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\PConfig;
|
||||
|
||||
require_once 'include/conversation.php';
|
||||
require_once 'include/group.php';
|
||||
require_once 'include/contact_widgets.php';
|
||||
require_once 'include/items.php';
|
||||
require_once 'include/ForumManager.php';
|
||||
require_once 'include/acl_selectors.php';
|
||||
|
||||
function network_init(App $a) {
|
||||
if (!local_user()) {
|
||||
|
@ -9,6 +18,22 @@ function network_init(App $a) {
|
|||
return;
|
||||
}
|
||||
|
||||
$search = (x($_GET, 'search') ? escape_tags($_GET['search']) : '');
|
||||
|
||||
if (($search != '') && !empty($_GET['submit'])) {
|
||||
goaway('search?search='.urlencode($search));
|
||||
}
|
||||
|
||||
if (x($_GET, 'save')) {
|
||||
$exists = dba::exists('search', array('uid' => local_user(), 'term' => $search));
|
||||
if (!$exists) {
|
||||
dba::insert('search', array('uid' => local_user(), 'term' => $search));
|
||||
}
|
||||
}
|
||||
if (x($_GET, 'remove')) {
|
||||
dba::delete('search', array('uid' => local_user(), 'term' => $search));
|
||||
}
|
||||
|
||||
$is_a_date_query = false;
|
||||
if (x($_GET, 'cid') && intval($_GET['cid']) != 0) {
|
||||
$cid = $_GET['cid'];
|
||||
|
@ -34,9 +59,9 @@ function network_init(App $a) {
|
|||
$sel_tabs = network_query_get_sel_tab($a);
|
||||
$sel_nets = network_query_get_sel_net();
|
||||
$sel_groups = network_query_get_sel_group($a);
|
||||
$last_sel_tabs = get_pconfig(local_user(), 'network.view','tab.selected');
|
||||
$last_sel_nets = get_pconfig(local_user(), 'network.view', 'net.selected');
|
||||
$last_sel_groups = get_pconfig(local_user(), 'network.view', 'group.selected');
|
||||
$last_sel_tabs = PConfig::get(local_user(), 'network.view','tab.selected');
|
||||
$last_sel_nets = PConfig::get(local_user(), 'network.view', 'net.selected');
|
||||
$last_sel_groups = PConfig::get(local_user(), 'network.view', 'group.selected');
|
||||
|
||||
$remember_tab = ($sel_tabs[0] === 'active' && is_array($last_sel_tabs) && $last_sel_tabs[0] !== 'active');
|
||||
$remember_net = ($sel_nets === false && $last_sel_nets && $last_sel_nets !== 'all');
|
||||
|
@ -95,8 +120,7 @@ function network_init(App $a) {
|
|||
|
||||
if ($remember_net) {
|
||||
$net_args['nets'] = $last_sel_nets;
|
||||
}
|
||||
else if($sel_nets!==false) {
|
||||
} elseif ($sel_nets!==false) {
|
||||
$net_args['nets'] = $sel_nets;
|
||||
}
|
||||
|
||||
|
@ -117,52 +141,18 @@ function network_init(App $a) {
|
|||
|
||||
$group_id = (($a->argc > 1 && is_numeric($a->argv[1])) ? intval($a->argv[1]) : 0);
|
||||
|
||||
set_pconfig(local_user(), 'network.view', 'group.selected', $group_id);
|
||||
|
||||
require_once 'include/group.php';
|
||||
require_once 'include/contact_widgets.php';
|
||||
require_once 'include/items.php';
|
||||
require_once 'include/ForumManager.php';
|
||||
PConfig::set(local_user(), 'network.view', 'group.selected', $group_id);
|
||||
|
||||
if (!x($a->page, 'aside')) {
|
||||
$a->page['aside'] = '';
|
||||
}
|
||||
|
||||
$search = ((x($_GET, 'search')) ? escape_tags($_GET['search']) : '');
|
||||
|
||||
if (x($_GET, 'save')) {
|
||||
$r = q("SELECT * FROM `search` WHERE `uid` = %d AND `term` = '%s' LIMIT 1",
|
||||
intval(local_user()),
|
||||
dbesc($search)
|
||||
);
|
||||
if (! dbm::is_result($r)) {
|
||||
q("INSERT INTO `search` ( `uid`,`term` ) VALUES ( %d, '%s') ",
|
||||
intval(local_user()),
|
||||
dbesc($search)
|
||||
);
|
||||
}
|
||||
}
|
||||
if (x($_GET, 'remove')) {
|
||||
q("DELETE FROM `search` WHERE `uid` = %d AND `term` = '%s'",
|
||||
intval(local_user()),
|
||||
dbesc($search)
|
||||
);
|
||||
}
|
||||
|
||||
// search terms header
|
||||
if (x($_GET, 'search')) {
|
||||
$a->page['content'] .= replace_macros(get_markup_template("section_title.tpl"),array(
|
||||
'$title' => sprintf( t('Results for: %s'), $search)
|
||||
));
|
||||
}
|
||||
|
||||
$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'] .= posted_date_widget('network',local_user(),false);
|
||||
$a->page['aside'] .= networks_widget('network',(x($_GET, 'nets') ? $_GET['nets'] : ''));
|
||||
$a->page['aside'] .= saved_searches($search);
|
||||
$a->page['aside'] .= fileas_widget('network',(x($_GET, 'file') ? $_GET['file'] : ''));
|
||||
|
||||
}
|
||||
|
||||
function saved_searches($search) {
|
||||
|
@ -186,14 +176,10 @@ function saved_searches($search) {
|
|||
|
||||
$o = '';
|
||||
|
||||
$r = q("SELECT `id`,`term` FROM `search` WHERE `uid` = %d",
|
||||
intval(local_user())
|
||||
);
|
||||
|
||||
$terms = dba::select('search', array('id', 'term'), array('uid' => local_user()));
|
||||
$saved = array();
|
||||
|
||||
if (dbm::is_result($r)) {
|
||||
foreach ($r as $rr) {
|
||||
while ($rr = dba::fetch($terms)) {
|
||||
$saved[] = array(
|
||||
'id' => $rr['id'],
|
||||
'term' => $rr['term'],
|
||||
|
@ -202,8 +188,6 @@ function saved_searches($search) {
|
|||
'selected' => ($search==$rr['term']),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$tpl = get_markup_template("saved_searches_aside.tpl");
|
||||
$o = replace_macros($tpl, array(
|
||||
|
@ -214,7 +198,6 @@ function saved_searches($search) {
|
|||
));
|
||||
|
||||
return $o;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -238,7 +221,6 @@ function network_query_get_sel_tab(App $a) {
|
|||
$new_active = '';
|
||||
$bookmarked_active = '';
|
||||
$all_active = '';
|
||||
$search_active = '';
|
||||
$conv_active = '';
|
||||
$spam_active = '';
|
||||
$postord_active = '';
|
||||
|
@ -248,10 +230,6 @@ function network_query_get_sel_tab(App $a) {
|
|||
$new_active = 'active';
|
||||
}
|
||||
|
||||
if(x($_GET,'search')) {
|
||||
$search_active = 'active';
|
||||
}
|
||||
|
||||
if (x($_GET,'star')) {
|
||||
$starred_active = 'active';
|
||||
}
|
||||
|
@ -274,7 +252,6 @@ function network_query_get_sel_tab(App $a) {
|
|||
&& ($starred_active == '')
|
||||
&& ($bookmarked_active == '')
|
||||
&& ($conv_active == '')
|
||||
&& ($search_active == '')
|
||||
&& ($spam_active == '')) {
|
||||
$no_active = 'active';
|
||||
}
|
||||
|
@ -313,16 +290,207 @@ function network_query_get_sel_group(App $a) {
|
|||
return $group;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets the pager data and returns SQL
|
||||
*
|
||||
* @param App $a The global App
|
||||
* @param integer $update Used for the automatic reloading
|
||||
* @return string SQL with the appropriate LIMIT clause
|
||||
*/
|
||||
function networkPager($a, $update) {
|
||||
if ($update) {
|
||||
// only setup pagination on initial page view
|
||||
return ' LIMIT 100';
|
||||
|
||||
}
|
||||
|
||||
// check if we serve a mobile device and get the user settings
|
||||
// accordingly
|
||||
if ($a->is_mobile) {
|
||||
$itemspage_network = PConfig::get(local_user(),'system','itemspage_mobile_network');
|
||||
$itemspage_network = ((intval($itemspage_network)) ? $itemspage_network : 20);
|
||||
} else {
|
||||
$itemspage_network = PConfig::get(local_user(),'system','itemspage_network');
|
||||
$itemspage_network = ((intval($itemspage_network)) ? $itemspage_network : 40);
|
||||
}
|
||||
|
||||
// now that we have the user settings, see if the theme forces
|
||||
// a maximum item number which is lower then the user choice
|
||||
if (($a->force_max_items > 0) && ($a->force_max_items < $itemspage_network)) {
|
||||
$itemspage_network = $a->force_max_items;
|
||||
}
|
||||
|
||||
$a->set_pager_itemspage($itemspage_network);
|
||||
|
||||
return sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets items as seen
|
||||
*
|
||||
* @param array $condition The array with the SQL condition
|
||||
*/
|
||||
function networkSetSeen($condition) {
|
||||
if (empty($condition)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$unseen = dba::exists('item', $condition);
|
||||
|
||||
if ($unseen) {
|
||||
$r = dba::update('item', array('unseen' => false), $condition);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Create the conversation HTML
|
||||
*
|
||||
* @param App $a The global App
|
||||
* @param array $items Items of the conversation
|
||||
* @param string $mode Display mode for the conversation
|
||||
* @param integer $update Used for the automatic reloading
|
||||
* @return string HTML of the conversation
|
||||
*/
|
||||
function networkConversation($a, $items, $mode, $update) {
|
||||
// Set this so that the conversation function can find out contact info for our wall-wall items
|
||||
$a->page_contact = $a->contact;
|
||||
|
||||
$o .= conversation($a, $items, $mode, $update);
|
||||
|
||||
if (!$update) {
|
||||
if (PConfig::get(local_user(), 'system', 'infinite_scroll')) {
|
||||
$o .= scroll_loader();
|
||||
} else {
|
||||
$o .= alt_pager($a, count($items));
|
||||
}
|
||||
}
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
function network_content(App $a, $update = 0) {
|
||||
|
||||
require_once('include/conversation.php');
|
||||
|
||||
if (!local_user()) {
|
||||
$_SESSION['return_url'] = $a->query_string;
|
||||
return login(false);
|
||||
}
|
||||
|
||||
/// @TODO Is this really necessary? $a is already available to hooks
|
||||
$arr = array('query' => $a->query_string);
|
||||
call_hooks('network_content_init', $arr);
|
||||
|
||||
$nouveau = false;
|
||||
|
||||
if ($a->argc > 1) {
|
||||
for ($x = 1; $x < $a->argc; $x ++) {
|
||||
if ($a->argv[$x] === 'new') {
|
||||
$nouveau = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (x($_GET,'file')) {
|
||||
$nouveau = true;
|
||||
}
|
||||
|
||||
if ($nouveau) {
|
||||
$o = networkFlatView($a, $update);
|
||||
} else {
|
||||
$o = networkThreadedView($a, $update);
|
||||
}
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the network content in flat view
|
||||
*
|
||||
* @param App $a The global App
|
||||
* @param integer $update Used for the automatic reloading
|
||||
* @return string HTML of the network content in flat view
|
||||
*/
|
||||
function networkFlatView(App $a, $update = 0) {
|
||||
|
||||
// Rawmode is used for fetching new content at the end of the page
|
||||
$rawmode = (isset($_GET["mode"]) AND ($_GET["mode"] == "raw"));
|
||||
|
||||
if (isset($_GET["last_id"])) {
|
||||
$last_id = intval($_GET["last_id"]);
|
||||
} else {
|
||||
$last_id = 0;
|
||||
}
|
||||
|
||||
$o = '';
|
||||
|
||||
$file = ((x($_GET,'file')) ? $_GET['file'] : '');
|
||||
|
||||
PConfig::set(local_user(), 'network.view', 'net.selected', 'all');
|
||||
|
||||
if (!$update && !$rawmode) {
|
||||
$tabs = network_tabs($a);
|
||||
$o .= $tabs;
|
||||
|
||||
nav_set_selected('network');
|
||||
|
||||
$x = array(
|
||||
'is_owner' => true,
|
||||
'allow_location' => $a->user['allow_location'],
|
||||
'default_location' => $a->user['default-location'],
|
||||
'nickname' => $a->user['nickname'],
|
||||
'lockstate'=> (((is_array($a->user) &&
|
||||
((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) ||
|
||||
(strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid']))))) ? 'lock' : 'unlock'),
|
||||
'default_perms' => get_acl_permissions($a->user),
|
||||
'acl' => populate_acl($a->user, true),
|
||||
'bang' => '',
|
||||
'visitor' => 'block',
|
||||
'profile_uid' => local_user(),
|
||||
'acl_data' => construct_acl_data($a, $a->user), // For non-Javascript ACL selector
|
||||
'content' => '',
|
||||
);
|
||||
|
||||
$o .= status_editor($a,$x);
|
||||
|
||||
if (!Config::get('theme','hide_eventlist')) {
|
||||
$o .= get_birthdays();
|
||||
$o .= get_events();
|
||||
}
|
||||
}
|
||||
|
||||
if (strlen($file)) {
|
||||
$sql_post_table .= sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
|
||||
dbesc(protect_sprintf($file)), intval(TERM_OBJ_POST), intval(TERM_FILE), intval(local_user()));
|
||||
} else {
|
||||
$sql_post_table = " INNER JOIN `thread` ON `thread`.`iid` = `item`.`parent`";
|
||||
}
|
||||
|
||||
$pager_sql = networkPager($a, $update);
|
||||
|
||||
// show all items unthreaded in reverse created date order
|
||||
$items = q("SELECT %s FROM `item` $sql_post_table %s
|
||||
WHERE %s AND `item`.`uid` = %d
|
||||
ORDER BY `item`.`id` DESC $pager_sql ",
|
||||
item_fieldlists(), item_joins(), item_condition(),
|
||||
intval($_SESSION['uid'])
|
||||
);
|
||||
|
||||
$condition = array('unseen' => true, 'uid' => local_user());
|
||||
networkSetSeen($condition);
|
||||
|
||||
$mode = 'network-new';
|
||||
$o .= networkConversation($a, $items, $mode, $update);
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the network content in threaded view
|
||||
*
|
||||
* @param App $a The global App
|
||||
* @param integer $update Used for the automatic reloading
|
||||
* @return string HTML of the network content in flat view
|
||||
*/
|
||||
function networkThreadedView(App $a, $update = 0) {
|
||||
|
||||
// Rawmode is used for fetching new content at the end of the page
|
||||
$rawmode = (isset($_GET["mode"]) AND ($_GET["mode"] == "raw"));
|
||||
|
||||
|
@ -338,31 +506,20 @@ function network_content(App $a, $update = 0) {
|
|||
$last_id = 0;
|
||||
}
|
||||
|
||||
/// @TODO Is this really necessary? $a is already available to hooks
|
||||
$arr = array('query' => $a->query_string);
|
||||
call_hooks('network_content_init', $arr);
|
||||
|
||||
|
||||
$datequery = $datequery2 = '';
|
||||
|
||||
$group = 0;
|
||||
|
||||
$nouveau = false;
|
||||
|
||||
if ($a->argc > 1) {
|
||||
for ($x = 1; $x < $a->argc; $x ++) {
|
||||
if (is_a_date_arg($a->argv[$x])) {
|
||||
if($datequery)
|
||||
if ($datequery) {
|
||||
$datequery2 = escape_tags($a->argv[$x]);
|
||||
else {
|
||||
} else {
|
||||
$datequery = escape_tags($a->argv[$x]);
|
||||
$_GET['order'] = 'post';
|
||||
}
|
||||
}
|
||||
elseif($a->argv[$x] === 'new') {
|
||||
$nouveau = true;
|
||||
}
|
||||
elseif(intval($a->argv[$x])) {
|
||||
} elseif (intval($a->argv[$x])) {
|
||||
$group = intval($a->argv[$x]);
|
||||
$def_acl = array('allow_gid' => '<' . $group . '>');
|
||||
}
|
||||
|
@ -371,52 +528,36 @@ function network_content(App $a, $update = 0) {
|
|||
|
||||
$o = '';
|
||||
|
||||
|
||||
|
||||
$contact_id = $a->cid;
|
||||
|
||||
require_once('include/acl_selectors.php');
|
||||
|
||||
$cid = ((x($_GET,'cid')) ? intval($_GET['cid']) : 0);
|
||||
$star = ((x($_GET,'star')) ? intval($_GET['star']) : 0);
|
||||
$bmark = ((x($_GET,'bmark')) ? intval($_GET['bmark']) : 0);
|
||||
$order = ((x($_GET,'order')) ? notags($_GET['order']) : 'comment');
|
||||
$liked = ((x($_GET,'liked')) ? intval($_GET['liked']) : 0);
|
||||
$conv = ((x($_GET,'conv')) ? intval($_GET['conv']) : 0);
|
||||
$spam = ((x($_GET,'spam')) ? intval($_GET['spam']) : 0);
|
||||
$nets = ((x($_GET,'nets')) ? $_GET['nets'] : '');
|
||||
$cmin = ((x($_GET,'cmin')) ? intval($_GET['cmin']) : 0);
|
||||
$cmax = ((x($_GET,'cmax')) ? intval($_GET['cmax']) : 99);
|
||||
$file = ((x($_GET,'file')) ? $_GET['file'] : '');
|
||||
|
||||
|
||||
|
||||
if(x($_GET,'search') || x($_GET,'file'))
|
||||
$nouveau = true;
|
||||
if($cid)
|
||||
if ($cid) {
|
||||
$def_acl = array('allow_cid' => '<' . intval($cid) . '>');
|
||||
}
|
||||
|
||||
if ($nets) {
|
||||
$r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND network = '%s' AND `self` = 0",
|
||||
intval(local_user()),
|
||||
dbesc($nets)
|
||||
);
|
||||
$r = dba::select('contact', array('id'), array('uid' => local_user(), 'network' => $nets), array('self' => false));
|
||||
|
||||
$str = '';
|
||||
if (dbm::is_result($r))
|
||||
foreach($r as $rr)
|
||||
while ($rr = dba::fetch($r)) {
|
||||
$str .= '<' . $rr['id'] . '>';
|
||||
if(strlen($str))
|
||||
}
|
||||
if (strlen($str)) {
|
||||
$def_acl = array('allow_cid' => $str);
|
||||
}
|
||||
set_pconfig(local_user(), 'network.view', 'net.selected', ($nets ? $nets : 'all'));
|
||||
}
|
||||
PConfig::set(local_user(), 'network.view', 'net.selected', ($nets ? $nets : 'all'));
|
||||
|
||||
if (!$update && !$rawmode) {
|
||||
$tabs = network_tabs($a);
|
||||
$o .= $tabs;
|
||||
|
||||
if ($group) {
|
||||
if(($t = group_public_members($group)) && (! get_pconfig(local_user(),'system','nowarn_insecure'))) {
|
||||
if (($t = group_public_members($group)) && !PConfig::get(local_user(),'system','nowarn_insecure')) {
|
||||
notice(sprintf(tt("Warning: This group contains %s member from a network that doesn't allow non public messages.",
|
||||
"Warning: This group contains %s members from a network that doesn't allow non public messages.",
|
||||
$t), $t).EOL);
|
||||
|
@ -430,12 +571,15 @@ function network_content(App $a, $update = 0) {
|
|||
|
||||
if ($cid) {
|
||||
// If $cid belongs to a communitity forum or a privat goup,.add a mention to the status editor
|
||||
$contact = q("SELECT `nick` FROM `contact` WHERE `id` = %d AND `uid` = %d AND (`forum` OR `prv`) ",
|
||||
intval($cid),
|
||||
intval(local_user())
|
||||
);
|
||||
if ($contact)
|
||||
$content = "@".$contact[0]["nick"]."+".$cid;
|
||||
$condition = array("`id` = ? AND (`forum` OR `prv`)", $cid);
|
||||
$contact = dba::select('contact', array('addr', 'nick'), $condition, array('limit' => 1));
|
||||
if (dbm::is_result($contact)) {
|
||||
if ($contact["addr"] != '') {
|
||||
$content = "@".$contact["addr"];
|
||||
} else {
|
||||
$content = "@".$contact["nick"]."+".$cid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$x = array(
|
||||
|
@ -472,7 +616,7 @@ function network_content(App $a, $update = 0) {
|
|||
$sql_table = "`thread`";
|
||||
$sql_parent = "`iid`";
|
||||
|
||||
if ($nouveau || strlen($file) || $update) {
|
||||
if ($update) {
|
||||
$sql_table = "`item`";
|
||||
$sql_parent = "`parent`";
|
||||
$sql_post_table = " INNER JOIN `thread` ON `thread`.`iid` = `item`.`parent`";
|
||||
|
@ -481,10 +625,7 @@ function network_content(App $a, $update = 0) {
|
|||
$sql_nets = (($nets) ? sprintf(" and $sql_table.`network` = '%s' ", dbesc($nets)) : '');
|
||||
|
||||
if ($group) {
|
||||
$r = q("SELECT `name`, `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||
intval($group),
|
||||
intval($_SESSION['uid'])
|
||||
);
|
||||
$r = dba::select('group', array('name'), array('id' => $group, 'uid' => $_SESSION['uid']), array('limit' => 1));
|
||||
if (!dbm::is_result($r)) {
|
||||
if ($update)
|
||||
killme();
|
||||
|
@ -494,20 +635,14 @@ function network_content(App $a, $update = 0) {
|
|||
}
|
||||
|
||||
$contacts = expand_groups(array($group));
|
||||
$gcontacts = expand_groups(array($group), false, true);
|
||||
|
||||
if ((is_array($contacts)) && count($contacts)) {
|
||||
$contact_str_self = "";
|
||||
$gcontact_str_self = "";
|
||||
|
||||
$contact_str = implode(',',$contacts);
|
||||
$gcontact_str = implode(',',$gcontacts);
|
||||
$self = q("SELECT `contact`.`id`, `gcontact`.`id` AS `gid` FROM `contact`
|
||||
INNER JOIN `gcontact` ON `gcontact`.`nurl` = `contact`.`nurl`
|
||||
WHERE `uid` = %d AND `self`", intval($_SESSION['uid']));
|
||||
if (count($self)) {
|
||||
$contact_str_self = $self[0]["id"];
|
||||
$gcontact_str_self = $self[0]["gid"];
|
||||
$self = dba::select('contact', array('id'), array('uid' => $_SESSION['uid'], 'self' => true), array('limit' => 1));
|
||||
if (dbm::is_result($self)) {
|
||||
$contact_str_self = $self["id"];
|
||||
}
|
||||
|
||||
$sql_post_table .= " INNER JOIN `item` AS `temp1` ON `temp1`.`id` = ".$sql_table.".".$sql_parent;
|
||||
|
@ -519,47 +654,44 @@ function network_content(App $a, $update = 0) {
|
|||
}
|
||||
|
||||
$o = replace_macros(get_markup_template("section_title.tpl"),array(
|
||||
'$title' => sprintf( t('Group: %s'), $r[0]['name'])
|
||||
'$title' => sprintf(t('Group: %s'), $r['name'])
|
||||
)) . $o;
|
||||
|
||||
}
|
||||
elseif($cid) {
|
||||
|
||||
$r = q("SELECT `id`,`name`,`network`,`writable`,`nurl`, `forum`, `prv`, `contact-type`, `addr`, `thumb`, `location` FROM `contact` WHERE `id` = %d
|
||||
AND (NOT `blocked` OR `pending`) LIMIT 1",
|
||||
intval($cid)
|
||||
);
|
||||
} elseif ($cid) {
|
||||
$fields = array('id', 'name', 'network', 'writable', 'nurl',
|
||||
'forum', 'prv', 'contact-type', 'addr', 'thumb', 'location');
|
||||
$condition = array("`id` = ? AND (NOT `blocked` OR `pending`)", $cid);
|
||||
$r = dba::select('contact', $fields, $condition, array('limit' => 1));
|
||||
if (dbm::is_result($r)) {
|
||||
$sql_extra = " AND ".$sql_table.".`contact-id` = ".intval($cid);
|
||||
|
||||
$entries[0] = array(
|
||||
'id' => 'network',
|
||||
'name' => htmlentities($r[0]['name']),
|
||||
'itemurl' => (($r[0]['addr']) ? ($r[0]['addr']) : ($r[0]['nurl'])),
|
||||
'thumb' => proxy_url($r[0]['thumb'], false, PROXY_SIZE_THUMB),
|
||||
'details' => $r[0]['location'],
|
||||
'name' => htmlentities($r['name']),
|
||||
'itemurl' => (($r['addr']) ? ($r['addr']) : ($r['nurl'])),
|
||||
'thumb' => proxy_url($r['thumb'], false, PROXY_SIZE_THUMB),
|
||||
'details' => $r['location'],
|
||||
);
|
||||
|
||||
$entries[0]["account_type"] = account_type($r[0]);
|
||||
$entries[0]["account_type"] = account_type($r);
|
||||
|
||||
$o = replace_macros(get_markup_template("viewcontact_template.tpl"),array(
|
||||
'contacts' => $entries,
|
||||
'id' => 'network',
|
||||
)) . $o;
|
||||
|
||||
if($r[0]['network'] === NETWORK_OSTATUS && $r[0]['writable'] && (! get_pconfig(local_user(),'system','nowarn_insecure'))) {
|
||||
if ($r['network'] === NETWORK_OSTATUS && $r['writable'] && !PConfig::get(local_user(),'system','nowarn_insecure')) {
|
||||
notice(t('Private messages to this person are at risk of public disclosure.') . EOL);
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
notice(t('Invalid contact.') . EOL);
|
||||
goaway('network');
|
||||
// NOTREACHED
|
||||
}
|
||||
}
|
||||
|
||||
if((! $group) && (! $cid) && (! $update) && (! get_config('theme','hide_eventlist'))) {
|
||||
if (!$group && !$cid && !$update && !Config::get('theme','hide_eventlist')) {
|
||||
$o .= get_birthdays();
|
||||
$o .= get_events();
|
||||
}
|
||||
|
@ -571,37 +703,9 @@ function network_content(App $a, $update = 0) {
|
|||
$sql_extra3 .= protect_sprintf(sprintf(" AND $sql_table.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery2))));
|
||||
}
|
||||
|
||||
//$sql_extra2 = (($nouveau) ? '' : " AND `item`.`parent` = `item`.`id` ");
|
||||
$sql_extra2 = (($nouveau) ? '' : $sql_extra2);
|
||||
$sql_extra3 = (($nouveau) ? '' : $sql_extra3);
|
||||
$sql_order = "";
|
||||
$order_mode = "received";
|
||||
$tag = false;
|
||||
|
||||
if(x($_GET,'search')) {
|
||||
$search = escape_tags($_GET['search']);
|
||||
|
||||
if(strpos($search,'#') === 0) {
|
||||
$tag = true;
|
||||
$search = substr($search,1);
|
||||
}
|
||||
|
||||
if (get_config('system','only_tag_search'))
|
||||
$tag = true;
|
||||
|
||||
if($tag) {
|
||||
$sql_extra = "";
|
||||
|
||||
$sql_post_table .= sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
|
||||
dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG), intval(local_user()));
|
||||
$sql_order = "`item`.`id`";
|
||||
$order_mode = "id";
|
||||
} else {
|
||||
$sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search))));
|
||||
$sql_order = "`item`.`id`";
|
||||
$order_mode = "id";
|
||||
}
|
||||
}
|
||||
if (strlen($file)) {
|
||||
$sql_post_table .= sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
|
||||
dbesc(protect_sprintf($file)), intval(TERM_OBJ_POST), intval(TERM_FILE), intval(local_user()));
|
||||
|
@ -612,64 +716,29 @@ function network_content(App $a, $update = 0) {
|
|||
if ($conv) {
|
||||
$sql_extra3 .= " AND $sql_table.`mention`";
|
||||
}
|
||||
if ($update) {
|
||||
// only setup pagination on initial page view
|
||||
$pager_sql = '';
|
||||
} else {
|
||||
// check if we serve a mobile device and get the user settings
|
||||
// accordingly
|
||||
if ($a->is_mobile) {
|
||||
$itemspage_network = get_pconfig(local_user(),'system','itemspage_mobile_network');
|
||||
$itemspage_network = ((intval($itemspage_network)) ? $itemspage_network : 20);
|
||||
} else {
|
||||
$itemspage_network = get_pconfig(local_user(),'system','itemspage_network');
|
||||
$itemspage_network = ((intval($itemspage_network)) ? $itemspage_network : 40);
|
||||
}
|
||||
|
||||
// now that we have the user settings, see if the theme forces
|
||||
// a maximum item number which is lower then the user choice
|
||||
if(($a->force_max_items > 0) && ($a->force_max_items < $itemspage_network))
|
||||
$itemspage_network = $a->force_max_items;
|
||||
|
||||
$a->set_pager_itemspage($itemspage_network);
|
||||
$pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
|
||||
}
|
||||
|
||||
if ($nouveau) {
|
||||
$simple_update = (($update) ? " AND `item`.`unseen` " : '');
|
||||
|
||||
if ($sql_order == "")
|
||||
$sql_order = "`item`.`id`";
|
||||
|
||||
// "New Item View" - show all items unthreaded in reverse created date order
|
||||
$items = q("SELECT %s FROM $sql_table $sql_post_table %s
|
||||
WHERE %s AND `item`.`uid` = %d
|
||||
$simple_update
|
||||
$sql_extra $sql_nets
|
||||
ORDER BY $sql_order DESC $pager_sql ",
|
||||
item_fieldlists(), item_joins(), item_condition(),
|
||||
intval($_SESSION['uid'])
|
||||
);
|
||||
|
||||
$update_unseen = ' WHERE uid = ' . intval($_SESSION['uid']) . " AND unseen = 1 $sql_extra $sql_nets";
|
||||
} else {
|
||||
|
||||
// Normal conversation view
|
||||
if ($order === 'post') {
|
||||
$ordering = "`created`";
|
||||
if ($sql_order == "")
|
||||
if ($sql_order == "") {
|
||||
$order_mode = "created";
|
||||
}
|
||||
} else {
|
||||
$ordering = "`commented`";
|
||||
if ($sql_order == "")
|
||||
if ($sql_order == "") {
|
||||
$order_mode = "commented";
|
||||
}
|
||||
}
|
||||
|
||||
if ($sql_order == "")
|
||||
if ($sql_order == "") {
|
||||
$sql_order = "$sql_table.$ordering";
|
||||
}
|
||||
|
||||
if (($_GET["offset"] != ""))
|
||||
if (($_GET["offset"] != "")) {
|
||||
$sql_extra3 .= sprintf(" AND $sql_order <= '%s'", dbesc($_GET["offset"]));
|
||||
}
|
||||
|
||||
$pager_sql = networkPager($a, $update);
|
||||
|
||||
switch ($order_mode) {
|
||||
case 'received':
|
||||
|
@ -704,10 +773,11 @@ function network_content(App $a, $update = 0) {
|
|||
|
||||
// Fetch a page full of parent items for this page
|
||||
if ($update) {
|
||||
if (get_config("system", "like_no_comment"))
|
||||
if (Config::get("system", "like_no_comment")) {
|
||||
$sql_extra4 = " AND `item`.`verb` = '".ACTIVITY_POST."'";
|
||||
else
|
||||
} else {
|
||||
$sql_extra4 = "";
|
||||
}
|
||||
|
||||
$r = q("SELECT `item`.`parent` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`uid` AS `contact_uid`
|
||||
FROM $sql_table $sql_post_table INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
|
||||
|
@ -737,18 +807,21 @@ function network_content(App $a, $update = 0) {
|
|||
$date_offset = "";
|
||||
|
||||
if (dbm::is_result($r)) {
|
||||
foreach($r as $rr)
|
||||
if(! in_array($rr['item_id'],$parents_arr))
|
||||
foreach ($r as $rr) {
|
||||
if (!in_array($rr['item_id'],$parents_arr)) {
|
||||
$parents_arr[] = $rr['item_id'];
|
||||
}
|
||||
}
|
||||
|
||||
$parents_str = implode(", ", $parents_arr);
|
||||
|
||||
// splitted into separate queries to avoid the problem with very long threads
|
||||
// so always the last X comments are loaded
|
||||
// This problem can occur expecially with imported facebook posts
|
||||
$max_comments = get_config("system", "max_comments");
|
||||
if ($max_comments == 0)
|
||||
$max_comments = Config::get("system", "max_comments");
|
||||
if ($max_comments == 0) {
|
||||
$max_comments = 100;
|
||||
}
|
||||
|
||||
$items = array();
|
||||
|
||||
|
@ -760,67 +833,37 @@ function network_content(App $a, $update = 0) {
|
|||
$parents
|
||||
);
|
||||
|
||||
if (dbm::is_result($thread_items))
|
||||
if (dbm::is_result($thread_items)) {
|
||||
$items = array_merge($items, dba::inArray($thread_items));
|
||||
}
|
||||
}
|
||||
$items = conv_sort($items,$ordering);
|
||||
} else {
|
||||
$items = array();
|
||||
}
|
||||
|
||||
if ($_GET["offset"] == "")
|
||||
if ($_GET["offset"] == "") {
|
||||
$date_offset = $items[0][$order_mode];
|
||||
else
|
||||
} else {
|
||||
$date_offset = $_GET["offset"];
|
||||
}
|
||||
|
||||
$a->page_offset = $date_offset;
|
||||
|
||||
if($parents_str)
|
||||
$update_unseen = ' WHERE uid = ' . intval(local_user()) . ' AND unseen = 1 AND parent IN ( ' . dbesc($parents_str) . ' )';
|
||||
}
|
||||
|
||||
// We aren't going to try and figure out at the item, group, and page
|
||||
// level which items you've seen and which you haven't. If you're looking
|
||||
// at the top level network page just mark everything seen.
|
||||
|
||||
|
||||
// The $update_unseen is a bit unreliable if you have stuff coming into your stream from a new contact -
|
||||
// and other feeds that bring in stuff from the past. One can't find it all.
|
||||
// I'm reviving this block to mark everything seen on page 1 of the network as a temporary measure.
|
||||
// The correct solution is to implement a network notifications box just like the system notifications popup
|
||||
// with the ability in the popup to "mark all seen".
|
||||
// Several people are complaining because there are unseen messages they can't find and as time goes
|
||||
// on they just get buried deeper. It has happened to me a couple of times also.
|
||||
|
||||
|
||||
if (!$group && !$cid && !$star) {
|
||||
$unseen = dba::exists('item', array('unseen' => true, 'uid' => local_user()));
|
||||
|
||||
if ($unseen) {
|
||||
$r = dba::update('item', array('unseen' => false), array('uid' => local_user(), 'unseen' => true));
|
||||
}
|
||||
} elseif ($update_unseen) {
|
||||
$unseen = q("SELECT `id` FROM `item` ".$update_unseen. " LIMIT 1");
|
||||
|
||||
if (dbm::is_result($unseen)) {
|
||||
$r = q("UPDATE `item` SET `unseen` = 0 $update_unseen");
|
||||
}
|
||||
$condition = array('unseen' => true, 'uid' => local_user());
|
||||
} elseif ($parents_str) {
|
||||
$condition = array("`uid` = ? AND `unseen` AND `parent` IN (" . dbesc($parents_str) . ")", local_user());
|
||||
}
|
||||
|
||||
// Set this so that the conversation function can find out contact info for our wall-wall items
|
||||
$a->page_contact = $a->contact;
|
||||
networkSetSeen($condition);
|
||||
|
||||
$mode = (($nouveau) ? 'network-new' : 'network');
|
||||
|
||||
$o .= conversation($a, $items, $mode, $update);
|
||||
|
||||
if (!$update) {
|
||||
if (get_pconfig(local_user(), 'system', 'infinite_scroll')) {
|
||||
$o .= scroll_loader();
|
||||
} else {
|
||||
$o .= alt_pager($a, count($items));
|
||||
}
|
||||
}
|
||||
$mode = 'network';
|
||||
$o .= networkConversation($a, $items, $mode, $update);
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
@ -907,9 +950,9 @@ function network_tabs(App $a) {
|
|||
);
|
||||
}
|
||||
|
||||
// save selected tab, but only if not in search or file mode
|
||||
if(!x($_GET,'search') && !x($_GET,'file')) {
|
||||
set_pconfig( local_user(), 'network.view','tab.selected',array($all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active) );
|
||||
// save selected tab, but only if not in file mode
|
||||
if (!x($_GET,'file')) {
|
||||
PConfig::set(local_user(), 'network.view','tab.selected',array($all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active));
|
||||
}
|
||||
|
||||
$arr = array('tabs' => $tabs);
|
||||
|
|
|
@ -188,7 +188,7 @@ function nodeinfo_cron() {
|
|||
}
|
||||
logger('cron_start');
|
||||
|
||||
$users = qu("SELECT `user`.`uid`, `user`.`login_date`, `contact`.`last-item`
|
||||
$users = q("SELECT `user`.`uid`, `user`.`login_date`, `contact`.`last-item`
|
||||
FROM `user`
|
||||
INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid` AND `profile`.`is-default`
|
||||
INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
|
||||
|
@ -220,7 +220,7 @@ function nodeinfo_cron() {
|
|||
Config::set('nodeinfo', 'active_users_monthly', $active_users_monthly);
|
||||
}
|
||||
|
||||
$posts = qu("SELECT COUNT(*) AS local_posts FROM `thread` WHERE `thread`.`wall` AND `thread`.`uid` != 0");
|
||||
$posts = q("SELECT COUNT(*) AS local_posts FROM `thread` WHERE `thread`.`wall` AND `thread`.`uid` != 0");
|
||||
|
||||
if (!is_array($posts)) {
|
||||
$local_posts = -1;
|
||||
|
@ -231,7 +231,7 @@ function nodeinfo_cron() {
|
|||
|
||||
logger('local_posts: '.$local_posts, LOGGER_DEBUG);
|
||||
|
||||
$posts = qu("SELECT COUNT(*) FROM `contact`
|
||||
$posts = q("SELECT COUNT(*) FROM `contact`
|
||||
INNER JOIN `item` ON `item`.`contact-id` = `contact`.`id` AND `item`.`uid` = `contact`.`uid` AND
|
||||
`item`.`id` != `item`.`parent` AND `item`.`network` IN ('%s', '%s', '%s')
|
||||
WHERE `contact`.`self`",
|
||||
|
|
|
@ -74,7 +74,7 @@ function photo_init(App $a) {
|
|||
|
||||
$uid = str_replace(array('.jpg','.png'),array('',''), $person);
|
||||
|
||||
$r = qu("SELECT * FROM `photo` WHERE `scale` = %d AND `uid` = %d AND `profile` = 1 LIMIT 1",
|
||||
$r = q("SELECT * FROM `photo` WHERE `scale` = %d AND `uid` = %d AND `profile` = 1 LIMIT 1",
|
||||
intval($resolution),
|
||||
intval($uid)
|
||||
);
|
||||
|
@ -104,7 +104,7 @@ function photo_init(App $a) {
|
|||
}
|
||||
|
||||
// check if the photo exists and get the owner of the photo
|
||||
$r = qu("SELECT `uid` FROM `photo` WHERE `resource-id` = '%s' LIMIT 1",
|
||||
$r = q("SELECT `uid` FROM `photo` WHERE `resource-id` = '%s' LIMIT 1",
|
||||
dbesc($photo),
|
||||
intval($resolution)
|
||||
);
|
||||
|
@ -114,7 +114,7 @@ function photo_init(App $a) {
|
|||
|
||||
// Now we'll see if we can access the photo
|
||||
|
||||
$r = qu("SELECT * FROM `photo` WHERE `resource-id` = '%s' AND `scale` <= %d $sql_extra ORDER BY scale DESC LIMIT 1",
|
||||
$r = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' AND `scale` <= %d $sql_extra ORDER BY scale DESC LIMIT 1",
|
||||
dbesc($photo),
|
||||
intval($resolution)
|
||||
);
|
||||
|
|
|
@ -29,7 +29,7 @@ function photos_init(App $a) {
|
|||
|
||||
if ($a->argc > 1) {
|
||||
$nick = $a->argv[1];
|
||||
$user = qu("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1",
|
||||
$user = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1",
|
||||
dbesc($nick)
|
||||
);
|
||||
|
||||
|
@ -153,7 +153,7 @@ function photos_post(App $a) {
|
|||
}
|
||||
if ($contact_id) {
|
||||
|
||||
$r = qu("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
|
||||
$r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
|
||||
intval($contact_id),
|
||||
intval($page_owner_uid)
|
||||
);
|
||||
|
@ -170,7 +170,7 @@ function photos_post(App $a) {
|
|||
killme();
|
||||
}
|
||||
|
||||
$r = qu("SELECT `contact`.*, `user`.`nickname` FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid`
|
||||
$r = q("SELECT `contact`.*, `user`.`nickname` FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid`
|
||||
WHERE `user`.`uid` = %d AND `self` = 1 LIMIT 1",
|
||||
intval($page_owner_uid)
|
||||
);
|
||||
|
@ -192,7 +192,7 @@ function photos_post(App $a) {
|
|||
return; // NOTREACHED
|
||||
}
|
||||
|
||||
$r = qu("SELECT `album` FROM `photo` WHERE `album` = '%s' AND `uid` = %d",
|
||||
$r = q("SELECT `album` FROM `photo` WHERE `album` = '%s' AND `uid` = %d",
|
||||
dbesc($album),
|
||||
intval($page_owner_uid)
|
||||
);
|
||||
|
@ -1378,7 +1378,7 @@ function photos_content(App $a) {
|
|||
else
|
||||
$order = 'DESC';
|
||||
|
||||
$prvnxt = qu("SELECT `resource-id` FROM `photo` WHERE `album` = '%s' AND `uid` = %d AND `scale` = 0
|
||||
$prvnxt = q("SELECT `resource-id` FROM `photo` WHERE `album` = '%s' AND `uid` = %d AND `scale` = 0
|
||||
$sql_extra ORDER BY `created` $order ",
|
||||
dbesc($ph[0]['album']),
|
||||
intval($owner_uid)
|
||||
|
@ -1478,7 +1478,7 @@ function photos_content(App $a) {
|
|||
if (dbm::is_result($linked_items)) {
|
||||
$link_item = $linked_items[0];
|
||||
|
||||
$r = qu("SELECT COUNT(*) AS `total`
|
||||
$r = q("SELECT COUNT(*) AS `total`
|
||||
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
|
||||
WHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0 and `item`.`moderated` = 0
|
||||
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
||||
|
@ -1495,7 +1495,7 @@ function photos_content(App $a) {
|
|||
}
|
||||
|
||||
|
||||
$r = qu("SELECT `item`.*, `item`.`id` AS `item_id`,
|
||||
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
|
||||
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`network`,
|
||||
`contact`.`rel`, `contact`.`thumb`, `contact`.`self`,
|
||||
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
|
||||
|
@ -1835,7 +1835,7 @@ function photos_content(App $a) {
|
|||
// Default - show recent photos with upload link (if applicable)
|
||||
//$o = '';
|
||||
|
||||
$r = qu("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s'
|
||||
$r = q("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s'
|
||||
$sql_extra GROUP BY `resource-id`",
|
||||
intval($a->data['user']['uid']),
|
||||
dbesc('Contact Photos'),
|
||||
|
@ -1846,7 +1846,7 @@ function photos_content(App $a) {
|
|||
$a->set_pager_itemspage(20);
|
||||
}
|
||||
|
||||
$r = qu("SELECT `resource-id`, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`filename`) AS `filename`,
|
||||
$r = q("SELECT `resource-id`, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`filename`) AS `filename`,
|
||||
ANY_VALUE(`type`) AS `type`, ANY_VALUE(`album`) AS `album`, max(`scale`) AS `scale`,
|
||||
ANY_VALUE(`created`) AS `created` FROM `photo`
|
||||
WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s'
|
||||
|
|
14
mod/ping.php
14
mod/ping.php
|
@ -118,7 +118,7 @@ function ping_init(App $a)
|
|||
|
||||
$notifs = ping_get_notifications(local_user());
|
||||
|
||||
$items_unseen = qu("SELECT `item`.`id`, `item`.`parent`, `item`.`verb`, `item`.`wall`, `item`.`author-name`,
|
||||
$items_unseen = q("SELECT `item`.`id`, `item`.`parent`, `item`.`verb`, `item`.`wall`, `item`.`author-name`,
|
||||
`item`.`contact-id`, `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`,
|
||||
`pitem`.`author-name` AS `pname`, `pitem`.`author-link` AS `plink`
|
||||
FROM `item` INNER JOIN `item` AS `pitem` ON `pitem`.`id` = `item`.`parent`
|
||||
|
@ -167,13 +167,13 @@ function ping_init(App $a)
|
|||
}
|
||||
}
|
||||
|
||||
$intros1 = qu("SELECT `intro`.`id`, `intro`.`datetime`,
|
||||
$intros1 = q("SELECT `intro`.`id`, `intro`.`datetime`,
|
||||
`fcontact`.`name`, `fcontact`.`url`, `fcontact`.`photo`
|
||||
FROM `intro` LEFT JOIN `fcontact` ON `intro`.`fid` = `fcontact`.`id`
|
||||
WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`fid` != 0",
|
||||
intval(local_user())
|
||||
);
|
||||
$intros2 = qu("SELECT `intro`.`id`, `intro`.`datetime`,
|
||||
$intros2 = q("SELECT `intro`.`id`, `intro`.`datetime`,
|
||||
`contact`.`name`, `contact`.`url`, `contact`.`photo`
|
||||
FROM `intro` LEFT JOIN `contact` ON `intro`.`contact-id` = `contact`.`id`
|
||||
WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`contact-id` != 0",
|
||||
|
@ -184,7 +184,7 @@ function ping_init(App $a)
|
|||
$intros = $intros1 + $intros2;
|
||||
|
||||
$myurl = System::baseUrl() . '/profile/' . $a->user['nickname'] ;
|
||||
$mails = qu("SELECT `id`, `from-name`, `from-url`, `from-photo`, `created` FROM `mail`
|
||||
$mails = q("SELECT `id`, `from-name`, `from-url`, `from-photo`, `created` FROM `mail`
|
||||
WHERE `uid` = %d AND `seen` = 0 AND `from-url` != '%s' ",
|
||||
intval(local_user()),
|
||||
dbesc($myurl)
|
||||
|
@ -192,7 +192,7 @@ function ping_init(App $a)
|
|||
$mail_count = count($mails);
|
||||
|
||||
if ($a->config['register_policy'] == REGISTER_APPROVE && is_site_admin()){
|
||||
$regs = qu("SELECT `contact`.`name`, `contact`.`url`, `contact`.`micro`, `register`.`created`, COUNT(*) AS `total`
|
||||
$regs = q("SELECT `contact`.`name`, `contact`.`url`, `contact`.`micro`, `register`.`created`, COUNT(*) AS `total`
|
||||
FROM `contact` RIGHT JOIN `register` ON `register`.`uid` = `contact`.`uid`
|
||||
WHERE `contact`.`self` = 1");
|
||||
|
||||
|
@ -204,7 +204,7 @@ function ping_init(App $a)
|
|||
$cachekey = "ping_init:".local_user();
|
||||
$ev = Cache::get($cachekey);
|
||||
if (is_null($ev)) {
|
||||
$ev = qu("SELECT type, start, adjust FROM `event`
|
||||
$ev = q("SELECT type, start, adjust FROM `event`
|
||||
WHERE `event`.`uid` = %d AND `start` < '%s' AND `finish` > '%s' and `ignore` = 0
|
||||
ORDER BY `start` ASC ",
|
||||
intval(local_user()),
|
||||
|
@ -424,7 +424,7 @@ function ping_get_notifications($uid)
|
|||
$a = get_app();
|
||||
|
||||
do {
|
||||
$r = qu("SELECT `notify`.*, `item`.`visible`, `item`.`spam`, `item`.`deleted`
|
||||
$r = q("SELECT `notify`.*, `item`.`visible`, `item`.`spam`, `item`.`deleted`
|
||||
FROM `notify` LEFT JOIN `item` ON `item`.`id` = `notify`.`iid`
|
||||
WHERE `notify`.`uid` = %d AND `notify`.`msg` != ''
|
||||
AND NOT (`notify`.`type` IN (%d, %d))
|
||||
|
|
|
@ -108,13 +108,7 @@ function profiles_init(App $a) {
|
|||
$r1[0]['net-publish'] = 0;
|
||||
$r1[0]['profile-name'] = dbesc($name);
|
||||
|
||||
dbm::esc_array($r1[0], true);
|
||||
|
||||
$r2 = dbq("INSERT INTO `profile` (`"
|
||||
. implode("`, `", array_keys($r1[0]))
|
||||
. "`) VALUES ("
|
||||
. implode(", ", array_values($r1[0]))
|
||||
. ")" );
|
||||
dba::insert('profile', $r1[0]);
|
||||
|
||||
$r3 = q("SELECT `id` FROM `profile` WHERE `uid` = %d AND `profile-name` = '%s' LIMIT 1",
|
||||
intval(local_user()),
|
||||
|
|
|
@ -142,10 +142,10 @@ function proxy_init(App $a) {
|
|||
$r = array();
|
||||
|
||||
if (!$direct_cache && ($cachefile == '')) {
|
||||
$r = qu("SELECT * FROM `photo` WHERE `resource-id` = '%s' LIMIT 1", $urlhash);
|
||||
$r = dba::select('photo', array('data', 'desc'), array('resource-id' => $urlhash), array('limit' => 1));
|
||||
if (dbm::is_result($r)) {
|
||||
$img_str = $r[0]['data'];
|
||||
$mime = $r[0]['desc'];
|
||||
$img_str = $r['data'];
|
||||
$mime = $r['desc'];
|
||||
if ($mime == '') {
|
||||
$mime = 'image/jpeg';
|
||||
}
|
||||
|
@ -181,23 +181,11 @@ function proxy_init(App $a) {
|
|||
die();
|
||||
}
|
||||
|
||||
q("INSERT INTO `photo`
|
||||
( `uid`, `contact-id`, `guid`, `resource-id`, `created`, `edited`, `filename`, `album`, `height`, `width`, `desc`, `data`, `scale`, `profile`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` )
|
||||
VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, %d, '%s', '%s', '%s', '%s' )",
|
||||
0, 0, get_guid(), dbesc($urlhash),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(basename(dbesc($_REQUEST['url']))),
|
||||
dbesc(''),
|
||||
intval(imagesy($image)),
|
||||
intval(imagesx($image)),
|
||||
$mime,
|
||||
dbesc($img_str),
|
||||
100,
|
||||
intval(0),
|
||||
dbesc(''), dbesc(''), dbesc(''), dbesc('')
|
||||
);
|
||||
|
||||
$fields = array('uid' => 0, 'contact-id' => 0, 'guid' => get_guid(), 'resource-id' => $urlhash, 'created' => datetime_convert(), 'edited' => datetime_convert(),
|
||||
'filename' => basename($_REQUEST['url']), 'type' => '', 'album' => '', 'height' => imagesy($image), 'width' => imagesx($image),
|
||||
'datasize' => 0, 'data' => $img_str, 'scale' => 100, 'profile' => 0,
|
||||
'allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '', 'desc' => $mime);
|
||||
dba::insert('photo', $fields);
|
||||
} else {
|
||||
$img = new Photo($img_str, $mime);
|
||||
if ($img->is_valid() && !$direct_cache && ($cachefile == '')) {
|
||||
|
|
|
@ -57,23 +57,16 @@ function search_init(App $a) {
|
|||
dbesc($search)
|
||||
);
|
||||
if (!dbm::is_result($r)) {
|
||||
q("INSERT INTO `search` (`uid`,`term`) VALUES ( %d, '%s')",
|
||||
intval(local_user()),
|
||||
dbesc($search)
|
||||
);
|
||||
dbm::insert('search', array('uid' => local_user(), 'term' => $search));
|
||||
}
|
||||
}
|
||||
if (x($_GET,'remove') && $search) {
|
||||
q("DELETE FROM `search` WHERE `uid` = %d AND `term` = '%s' LIMIT 1",
|
||||
intval(local_user()),
|
||||
dbesc($search)
|
||||
);
|
||||
dbm::delete('search', array('uid' => local_user(), 'term' => $search));
|
||||
}
|
||||
|
||||
$a->page['aside'] .= search_saved_searches();
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
unset($_SESSION['theme']);
|
||||
unset($_SESSION['mobile-theme']);
|
||||
}
|
||||
|
|
|
@ -231,17 +231,12 @@ function settings_post(App $a) {
|
|||
intval(local_user())
|
||||
);
|
||||
if (! dbm::is_result($r)) {
|
||||
q("INSERT INTO `mailacct` (`uid`) VALUES (%d)",
|
||||
intval(local_user())
|
||||
);
|
||||
dba::insert('mailacct', array('uid' => local_user()));
|
||||
}
|
||||
if(strlen($mail_pass)) {
|
||||
$pass = '';
|
||||
openssl_public_encrypt($mail_pass,$pass,$a->user['pubkey']);
|
||||
q("UPDATE `mailacct` SET `pass` = '%s' WHERE `uid` = %d",
|
||||
dbesc(bin2hex($pass)),
|
||||
intval(local_user())
|
||||
);
|
||||
dba::update('mailacct', array('pass' => bin2hex($pass)), array('uid' => local_user()));
|
||||
}
|
||||
$r = q("UPDATE `mailacct` SET `server` = '%s', `port` = %d, `ssltype` = '%s', `user` = '%s',
|
||||
`action` = %d, `movetofolder` = '%s',
|
||||
|
|
|
@ -39,10 +39,7 @@ function suggest_init(App $a) {
|
|||
}
|
||||
// Now check how the user responded to the confirmation query
|
||||
if (!$_REQUEST['canceled']) {
|
||||
q("INSERT INTO `gcign` ( `uid`, `gcid` ) VALUES ( %d, %d ) ",
|
||||
intval(local_user()),
|
||||
intval($_GET['ignore'])
|
||||
);
|
||||
dba::insert('gcign', array('uid' => local_user(), 'gcid' => $_GET['ignore']));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
140
mod/unfollow.php
Normal file
140
mod/unfollow.php
Normal file
|
@ -0,0 +1,140 @@
|
|||
<?php
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\System;
|
||||
|
||||
require_once 'include/probe.php';
|
||||
require_once 'include/follow.php';
|
||||
require_once 'include/Contact.php';
|
||||
require_once 'include/contact_selectors.php';
|
||||
|
||||
function unfollow_post(App $a) {
|
||||
|
||||
if (!local_user()) {
|
||||
notice(t('Permission denied.') . EOL);
|
||||
goaway($_SESSION['return_url']);
|
||||
// NOTREACHED
|
||||
}
|
||||
|
||||
if ($_REQUEST['cancel']) {
|
||||
goaway($_SESSION['return_url']);
|
||||
}
|
||||
|
||||
$uid = local_user();
|
||||
$url = notags(trim($_REQUEST['url']));
|
||||
$return_url = $_SESSION['return_url'];
|
||||
|
||||
$condition = array("`uid` = ? AND `rel` = ? AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?",
|
||||
$uid, CONTACT_IS_FRIEND, normalise_link($url),
|
||||
normalise_link($url), $url, NETWORK_STATUSNET);
|
||||
$contact = dba::select('contact', array(), $condition, array('limit' => 1));
|
||||
|
||||
if (!dbm::is_result($contact)) {
|
||||
notice(t("Contact wasn't found or can't be unfollowed."));
|
||||
} else {
|
||||
if (in_array($contact['network'], array(NETWORK_OSTATUS))) {
|
||||
$r = q("SELECT `contact`.*, `user`.* FROM `contact` INNER JOIN `user` ON `contact`.`uid` = `user`.`uid`
|
||||
WHERE `user`.`uid` = %d AND `contact`.`self` LIMIT 1",
|
||||
intval($uid)
|
||||
);
|
||||
if (dbm::is_result($r)) {
|
||||
$self = ""; // Unused parameter
|
||||
terminate_friendship($r[0], $self, $contact);
|
||||
}
|
||||
}
|
||||
dba::update('contact', array('rel' => CONTACT_IS_FOLLOWER), array('id' => $contact['id']));
|
||||
|
||||
info(t('Contact unfollowed').EOL);
|
||||
goaway(System::baseUrl().'/contacts/'.$contact['id']);
|
||||
}
|
||||
goaway($return_url);
|
||||
// NOTREACHED
|
||||
}
|
||||
|
||||
function unfollow_content(App $a) {
|
||||
|
||||
if (! local_user()) {
|
||||
notice(t('Permission denied.') . EOL);
|
||||
goaway($_SESSION['return_url']);
|
||||
// NOTREACHED
|
||||
}
|
||||
|
||||
$uid = local_user();
|
||||
$url = notags(trim($_REQUEST['url']));
|
||||
|
||||
$submit = t('Submit Request');
|
||||
|
||||
$condition = array("`uid` = ? AND `rel` = ? AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?",
|
||||
local_user(), CONTACT_IS_FRIEND, normalise_link($url),
|
||||
normalise_link($url), $url, NETWORK_STATUSNET);
|
||||
$contact = dba::select('contact', array('url', 'network', 'addr', 'name'), $condition, array('limit' => 1));
|
||||
|
||||
if (!dbm::is_result($contact)) {
|
||||
notice(t("You aren't a friend of this contact.").EOL);
|
||||
$submit = "";
|
||||
// NOTREACHED
|
||||
}
|
||||
|
||||
if (!in_array($contact['network'], array(NETWORK_DIASPORA, NETWORK_OSTATUS))) {
|
||||
notice(t("Unfollowing is currently not supported by your network.").EOL);
|
||||
$submit = "";
|
||||
// NOTREACHED
|
||||
}
|
||||
|
||||
$request = System::baseUrl()."/unfollow";
|
||||
$tpl = get_markup_template('auto_request.tpl');
|
||||
|
||||
$r = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1", intval($uid));
|
||||
|
||||
if (!$r) {
|
||||
notice(t('Permission denied.') . EOL);
|
||||
goaway($_SESSION['return_url']);
|
||||
// NOTREACHED
|
||||
}
|
||||
|
||||
$myaddr = $r[0]["url"];
|
||||
|
||||
// Makes the connection request for friendica contacts easier
|
||||
$_SESSION["fastlane"] = $contact["url"];
|
||||
|
||||
$header = t("Disconnect/Unfollow");
|
||||
|
||||
$o = replace_macros($tpl,array(
|
||||
'$header' => htmlentities($header),
|
||||
'$desc' => "",
|
||||
'$pls_answer' => "",
|
||||
'$does_know_you' => "",
|
||||
'$add_note' => "",
|
||||
'$page_desc' => "",
|
||||
'$friendica' => "",
|
||||
'$statusnet' => "",
|
||||
'$diaspora' => "",
|
||||
'$diasnote' => "",
|
||||
'$your_address' => t('Your Identity Address:'),
|
||||
'$invite_desc' => "",
|
||||
'$emailnet' => "",
|
||||
'$submit' => $submit,
|
||||
'$cancel' => t('Cancel'),
|
||||
'$nickname' => "",
|
||||
'$name' => $contact["name"],
|
||||
'$url' => $contact["url"],
|
||||
'$zrl' => zrl($contact["url"]),
|
||||
'$url_label' => t("Profile URL"),
|
||||
'$myaddr' => $myaddr,
|
||||
'$request' => $request,
|
||||
'$keywords' => "",
|
||||
'$keywords_label' => ""
|
||||
));
|
||||
|
||||
$a->page['aside'] = "";
|
||||
profile_load($a, "", 0, get_contact_details_by_url($contact["url"]));
|
||||
|
||||
$o .= replace_macros(get_markup_template('section_title.tpl'),
|
||||
array('$title' => t('Status Messages and Posts')
|
||||
));
|
||||
|
||||
// Show last public posts
|
||||
$o .= posts_from_contact_url($a, $contact["url"]);
|
||||
|
||||
return $o;
|
||||
}
|
|
@ -138,21 +138,12 @@ function wall_attach_post(App $a) {
|
|||
$mimetype = z_mime_content_type($filename);
|
||||
$hash = get_guid(64);
|
||||
$created = datetime_convert();
|
||||
$r = q("INSERT INTO `attach` ( `uid`, `hash`, `filename`, `filetype`, `filesize`, `data`, `created`, `edited`, `allow_cid`, `allow_gid`,`deny_cid`, `deny_gid` )
|
||||
VALUES ( %d, '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ",
|
||||
intval($page_owner_uid),
|
||||
dbesc($hash),
|
||||
dbesc($filename),
|
||||
dbesc($mimetype),
|
||||
intval($filesize),
|
||||
dbesc($filedata),
|
||||
dbesc($created),
|
||||
dbesc($created),
|
||||
dbesc('<' . $page_owner_cid . '>'),
|
||||
dbesc(''),
|
||||
dbesc(''),
|
||||
dbesc('')
|
||||
);
|
||||
|
||||
$fields = array('uid' => $page_owner_uid, 'hash' => $hash, 'filename' => $filename, 'filetype' => $mimetype,
|
||||
'filesize' => $filesize, 'data' => $filedata, 'created' => $created, 'edited' => $created,
|
||||
'allow_cid' => '<' . $page_owner_cid . '>', 'allow_gid' => '','deny_cid' => '', 'deny_gid' => '');
|
||||
|
||||
$r = dba::insert('attach', $fields);
|
||||
|
||||
@unlink($src);
|
||||
|
||||
|
|
|
@ -129,9 +129,8 @@ server {
|
|||
# With php5-fpm:
|
||||
fastcgi_pass unix:/var/run/php5-fpm.sock;
|
||||
|
||||
include fastcgi_params;
|
||||
include fastcgi.conf;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
}
|
||||
|
||||
# deny access to all dot files
|
||||
|
|
|
@ -68,6 +68,11 @@ class Item extends BaseObject {
|
|||
continue;
|
||||
}
|
||||
|
||||
// You can always comment on Diaspora items
|
||||
if (($item['network'] == NETWORK_DIASPORA) && (local_user() == $item['uid'])) {
|
||||
$item['writable'] = true;
|
||||
}
|
||||
|
||||
$item['pagedrop'] = $data['pagedrop'];
|
||||
$child = new Item($item);
|
||||
$this->add_child($child);
|
||||
|
@ -319,18 +324,6 @@ class Item extends BaseObject {
|
|||
unset($buttons["like"]);
|
||||
}
|
||||
|
||||
// Diaspora isn't able to do likes on comments - but Hubzilla does
|
||||
/// @todo When Diaspora will pass this information we will remove these lines
|
||||
if (($item["item_network"] == NETWORK_DIASPORA) && ($indent == 'comment') &&
|
||||
!Diaspora::is_redmatrix($item["owner-link"]) && isset($buttons["like"])) {
|
||||
unset($buttons["like"]);
|
||||
}
|
||||
|
||||
// Facebook can like comments - but it isn't programmed in the connector yet.
|
||||
if (($item["item_network"] == NETWORK_FACEBOOK) && ($indent == 'comment') && isset($buttons["like"])) {
|
||||
unset($buttons["like"]);
|
||||
}
|
||||
|
||||
$tmp_item = array(
|
||||
'template' => $this->get_template(),
|
||||
'type' => implode("",array_slice(explode("/",$item['verb']),-1)),
|
||||
|
|
11087
util/messages.po
11087
util/messages.po
File diff suppressed because it is too large
Load diff
|
@ -7,7 +7,7 @@
|
|||
{{foreach $saved as $search}}
|
||||
<li role="menuitem" class="saved-search-li clear">
|
||||
<a title="{{$search.delete}}" onclick="return confirmDelete();" id="drop-saved-search-term-{{$search.id}}" class="iconspacer savedsearchdrop " href="network/?f=&remove=1&search={{$search.encodedterm}}"></a>
|
||||
<a id="saved-search-term-{{$search.id}}" class="savedsearchterm" href="network/?f=&search={{$search.encodedterm}}">{{$search.term}}</a>
|
||||
<a id="saved-search-term-{{$search.id}}" class="savedsearchterm" href="search?search={{$search.encodedterm}}">{{$search.term}}</a>
|
||||
</li>
|
||||
{{/foreach}}
|
||||
</ul>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
{{foreach $saved as $search}}
|
||||
<li role="menuitem" class="saved-search-li clear">
|
||||
<a title="{{$search.delete}}" onclick="return confirmDelete();" id="drop-saved-search-term-{{$search.id}}" class="savedsearchdrop pull-right" href="network/?f=&remove=1&search={{$search.encodedterm}}"><i class="fa fa-trash" aria-hidden="true"></i></a>
|
||||
<a id="saved-search-term-{{$search.id}}" class="savedsearchterm" href="network/?f=&search={{$search.encodedterm}}">{{$search.term}}</a>
|
||||
<a id="saved-search-term-{{$search.id}}" class="savedsearchterm" href="search?search={{$search.encodedterm}}">{{$search.term}}</a>
|
||||
</li>
|
||||
{{/foreach}}
|
||||
</ul>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<ul id="saved-search-ul">
|
||||
{{foreach $saved as $search}}
|
||||
<li class="tool {{if $search.selected}}selected{{/if}}">
|
||||
<a href="network/?f=&search={{$search.encodedterm}}" class="label" >{{$search.term}}</a>
|
||||
<a href="search?search={{$search.encodedterm}}" class="label" >{{$search.term}}</a>
|
||||
<a href="network/?f=&remove=1&search={{$search.encodedterm}}" class="action icon s10 delete" title="{{$search.delete}}" onclick="return confirmDelete();"></a>
|
||||
</li>
|
||||
{{/foreach}}
|
||||
|
|
Loading…
Reference in a new issue