1
1
Fork 0

Notices again (#5543)

* And again notices

* Notices in the directory

* Much more places

* Fix some double $

* Notice in ping

* Missing field

* Fix: We now remove deleted users from the directory

* Some more stuff

* Notices when removing users

* Added logging

* More logging

* Two more
This commit is contained in:
Michael Vogel 2018-08-02 07:21:01 +02:00 committed by Tobias Diekershoff
parent c960a97682
commit c72c64a6d8
17 changed files with 95 additions and 57 deletions

View file

@ -27,6 +27,11 @@ function notification($params)
{ {
$a = get_app(); $a = get_app();
// Temporary logging for finding the origin
if (!isset($params['language']) || !isset($params['uid'])) {
logger('Missing parameters.' . System::callstack());
}
// from here on everything is in the recipients language // from here on everything is in the recipients language
L10n::pushLang($params['language']); L10n::pushLang($params['language']);
@ -57,8 +62,10 @@ function notification($params)
if (!DBA::isResult($user) || in_array($user["page-flags"], [Contact::PAGE_COMMUNITY, Contact::PAGE_PRVGROUP])) { if (!DBA::isResult($user) || in_array($user["page-flags"], [Contact::PAGE_COMMUNITY, Contact::PAGE_PRVGROUP])) {
return; return;
} }
}
$nickname = $user["nickname"]; $nickname = $user["nickname"];
} else {
$nickname = '';
}
// with $params['show_in_notification_page'] == false, the notification isn't inserted into // with $params['show_in_notification_page'] == false, the notification isn't inserted into
// the database, and an email is sent if applicable. // the database, and an email is sent if applicable.
@ -93,6 +100,8 @@ function notification($params)
$parent_id = 0; $parent_id = 0;
} }
$epreamble = '';
if ($params['type'] == NOTIFY_MAIL) { if ($params['type'] == NOTIFY_MAIL) {
$itemlink = $siteurl.'/message/'.$params['item']['id']; $itemlink = $siteurl.'/message/'.$params['item']['id'];
$params["link"] = $itemlink; $params["link"] = $itemlink;
@ -529,7 +538,7 @@ function notification($params)
} }
// send email notification if notification preferences permit // send email notification if notification preferences permit
if ((intval($params['notify_flags']) & intval($params['type'])) if ((!empty($params['notify_flags']) & intval($params['type']))
|| $params['type'] == NOTIFY_SYSTEM || $params['type'] == NOTIFY_SYSTEM
|| $params['type'] == SYSTEM_EMAIL) { || $params['type'] == SYSTEM_EMAIL) {
@ -577,11 +586,11 @@ function notification($params)
$datarray['siteurl'] = $siteurl; $datarray['siteurl'] = $siteurl;
$datarray['type'] = $params['type']; $datarray['type'] = $params['type'];
$datarray['parent'] = $parent_id; $datarray['parent'] = $parent_id;
$datarray['source_name'] = $params['source_name']; $datarray['source_name'] = defaults($params, 'source_name', '');
$datarray['source_link'] = $params['source_link']; $datarray['source_link'] = defaults($params, 'source_link', '');
$datarray['source_photo'] = $params['source_photo']; $datarray['source_photo'] = defaults($params, 'source_photo', '');
$datarray['uid'] = $params['uid']; $datarray['uid'] = $params['uid'];
$datarray['username'] = $params['to_name']; $datarray['username'] = defaults($params, 'to_name', '');
$datarray['hsitelink'] = $hsitelink; $datarray['hsitelink'] = $hsitelink;
$datarray['tsitelink'] = $tsitelink; $datarray['tsitelink'] = $tsitelink;
$datarray['hitemlink'] = '<a href="'.$itemlink.'">'.$itemlink.'</a>'; $datarray['hitemlink'] = '<a href="'.$itemlink.'">'.$itemlink.'</a>';

View file

@ -92,13 +92,15 @@ if (!$a->is_backend()) {
* We have to do it here because the session was just now opened. * We have to do it here because the session was just now opened.
*/ */
if (x($_SESSION, 'authenticated') && !x($_SESSION, 'language')) { if (x($_SESSION, 'authenticated') && !x($_SESSION, 'language')) {
// we haven't loaded user data yet, but we need user language
$user = DBA::selectFirst('user', ['language'], ['uid' => $_SESSION['uid']]);
$_SESSION['language'] = $lang; $_SESSION['language'] = $lang;
// we haven't loaded user data yet, but we need user language
if (!empty($_SESSION['uid'])) {
$user = DBA::selectFirst('user', ['language'], ['uid' => $_SESSION['uid']]);
if (DBA::isResult($user)) { if (DBA::isResult($user)) {
$_SESSION['language'] = $user['language']; $_SESSION['language'] = $user['language'];
} }
} }
}
if (x($_SESSION, 'language') && ($_SESSION['language'] !== $lang)) { if (x($_SESSION, 'language') && ($_SESSION['language'] !== $lang)) {
$lang = $_SESSION['language']; $lang = $_SESSION['language'];

View file

@ -32,7 +32,8 @@ function dfrn_poll_init(App $a)
$quiet = x($_GET, 'quiet'); $quiet = x($_GET, 'quiet');
// Possibly it is an OStatus compatible server that requests a user feed // Possibly it is an OStatus compatible server that requests a user feed
if (($a->argc > 1) && ($dfrn_id == '') && !strstr($_SERVER["HTTP_USER_AGENT"], 'Friendica')) { $user_agent = defaults($_SERVER, 'HTTP_USER_AGENT', '');
if (($a->argc > 1) && ($dfrn_id == '') && !strstr($user_agent, 'Friendica')) {
$nickname = $a->argv[1]; $nickname = $a->argv[1];
header("Content-type: application/atom+xml"); header("Content-type: application/atom+xml");
echo OStatus::feed($nickname, $last_update, 10); echo OStatus::feed($nickname, $last_update, 10);

View file

@ -422,7 +422,7 @@ function dfrn_request_post(App $a)
intval($uid), intval($uid),
intval($contact_record['id']), intval($contact_record['id']),
((x($_POST,'knowyou') && ($_POST['knowyou'] == 1)) ? 1 : 0), ((x($_POST,'knowyou') && ($_POST['knowyou'] == 1)) ? 1 : 0),
DBA::escape(notags(trim($_POST['dfrn-request-message']))), DBA::escape(notags(trim(defaults($_POST, 'dfrn-request-message', '')))),
DBA::escape($hash), DBA::escape($hash),
DBA::escape(DateTimeFormat::utcNow()) DBA::escape(DateTimeFormat::utcNow())
); );

View file

@ -76,6 +76,8 @@ function directory_content(App $a)
(`profile`.`education` LIKE '%$search%') OR (`profile`.`education` LIKE '%$search%') OR
(`profile`.`pub_keywords` LIKE '%$search%') OR (`profile`.`pub_keywords` LIKE '%$search%') OR
(`profile`.`prv_keywords` LIKE '%$search%'))"; (`profile`.`prv_keywords` LIKE '%$search%'))";
} else {
$sql_extra = '';
} }
$publish = (Config::get('system', 'publish_all') ? '' : " AND `publish` = 1 " ); $publish = (Config::get('system', 'publish_all') ? '' : " AND `publish` = 1 " );
@ -147,6 +149,8 @@ function directory_content(App $a)
|| (x($profile, 'country-name') == 1) || (x($profile, 'country-name') == 1)
) { ) {
$location = L10n::t('Location:'); $location = L10n::t('Location:');
} else {
$location = '';
} }
$gender = ((x($profile, 'gender') == 1) ? L10n::t('Gender:') : false); $gender = ((x($profile, 'gender') == 1) ? L10n::t('Gender:') : false);

View file

@ -45,7 +45,7 @@ function group_post(App $a) {
return; // NOTREACHED return; // NOTREACHED
} }
if (($a->argc == 2) && (intval($a->argv[1]))) { if (($a->argc == 2) && intval($a->argv[1])) {
check_form_security_token_redirectOnErr('/group', 'group_edit'); check_form_security_token_redirectOnErr('/group', 'group_edit');
$r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1",
@ -59,7 +59,7 @@ function group_post(App $a) {
} }
$group = $r[0]; $group = $r[0];
$groupname = notags(trim($_POST['groupname'])); $groupname = notags(trim($_POST['groupname']));
if ((strlen($groupname)) && ($groupname != $group['name'])) { if (strlen($groupname) && ($groupname != $group['name'])) {
$r = q("UPDATE `group` SET `name` = '%s' WHERE `uid` = %d AND `id` = %d", $r = q("UPDATE `group` SET `name` = '%s' WHERE `uid` = %d AND `id` = %d",
DBA::escape($groupname), DBA::escape($groupname),
intval(local_user()), intval(local_user()),
@ -113,11 +113,13 @@ function group_content(App $a) {
} }
$nogroup = false;
if (($a->argc == 2) && ($a->argv[1] === 'none')) { if (($a->argc == 2) && ($a->argv[1] === 'none')) {
require_once 'mod/contacts.php'; require_once 'mod/contacts.php';
$id = -1; $id = -1;
$nogroup = True; $nogroup = true;
$group = [ $group = [
'id' => $id, 'id' => $id,
'name' => L10n::t('Contacts not in any group'), 'name' => L10n::t('Contacts not in any group'),
@ -173,7 +175,7 @@ function group_content(App $a) {
} }
} }
if (($a->argc > 1) && (intval($a->argv[1]))) { if (($a->argc > 1) && intval($a->argv[1])) {
require_once 'mod/contacts.php'; require_once 'mod/contacts.php';
$r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d AND `deleted` = 0 LIMIT 1", $r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d AND `deleted` = 0 LIMIT 1",

View file

@ -108,7 +108,7 @@ function ping_init(App $a)
if (local_user()) { if (local_user()) {
// Different login session than the page that is calling us. // Different login session than the page that is calling us.
if (intval($_GET['uid']) && intval($_GET['uid']) != local_user()) { if (!empty($_GET['uid']) && intval($_GET['uid']) != local_user()) {
$data = ['result' => ['invalid' => 1]]; $data = ['result' => ['invalid' => 1]];
if ($format == 'json') { if ($format == 'json') {
@ -347,7 +347,7 @@ function ping_init(App $a)
if (DBA::isResult($notifs)) { if (DBA::isResult($notifs)) {
// Are the nofications called from the regular process or via the friendica app? // Are the nofications called from the regular process or via the friendica app?
$regularnotifications = (intval($_GET['uid']) && intval($_GET['_'])); $regularnotifications = (!empty($_GET['uid']) && !empty($_GET['_']));
foreach ($notifs as $notif) { foreach ($notifs as $notif) {
if ($a->is_friendica_app() || !$regularnotifications) { if ($a->is_friendica_app() || !$regularnotifications) {

View file

@ -23,7 +23,7 @@ function probe_content(App $a)
$o .= '<br /><br />'; $o .= '<br /><br />';
if (x($_GET, 'addr')) { if (!empty($_GET['addr'])) {
$addr = trim($_GET['addr']); $addr = trim($_GET['addr']);
$res = Probe::uri($addr, "", 0, false); $res = Probe::uri($addr, "", 0, false);
$o .= '<pre>'; $o .= '<pre>';

View file

@ -86,7 +86,7 @@ class BBCode extends BaseObject
$post["url"] = $matches[1]; $post["url"] = $matches[1];
$post["title"] = $matches[2]; $post["title"] = $matches[2];
} }
if (($post["url"] == "") && (in_array($post["type"], ["link", "video"])) if (!empty($post["url"] == "") && (in_array($post["type"], ["link", "video"]))
&& preg_match("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", $attacheddata, $matches)) { && preg_match("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", $attacheddata, $matches)) {
$post["url"] = $matches[1]; $post["url"] = $matches[1];
} }
@ -609,7 +609,7 @@ class BBCode extends BaseObject
if (!$data) { if (!$data) {
return $Text; return $Text;
} elseif ($nolink) { } elseif ($nolink) {
return $data["text"] . $data["after"]; return $data["text"] . defaults($data, 'after', '');
} }
$title = htmlentities(defaults($data, 'title', ''), ENT_QUOTES, 'UTF-8', false); $title = htmlentities(defaults($data, 'title', ''), ENT_QUOTES, 'UTF-8', false);
@ -632,7 +632,7 @@ class BBCode extends BaseObject
$text = $data["text"]; $text = $data["text"];
if (!empty($data["url"]) && ($data["title"] != "")) { if (!empty($data["url"]) && !empty($data["title"])) {
$text .= "\n[url=" . $data["url"] . "]" . $data["title"] . "[/url]"; $text .= "\n[url=" . $data["url"] . "]" . $data["title"] . "[/url]";
} elseif (!empty($data["url"])) { } elseif (!empty($data["url"])) {
$text .= "\n[url]" . $data["url"] . "[/url]"; $text .= "\n[url]" . $data["url"] . "[/url]";

View file

@ -1563,20 +1563,24 @@ class Contact extends BaseObject
} }
public static function addRelationship($importer, $contact, $datarray, $item, $sharing = false) { public static function addRelationship($importer, $contact, $datarray, $item, $sharing = false) {
$url = notags(trim($datarray['author-link'])); // Should always be set
$name = notags(trim($datarray['author-name'])); if (empty($datarray['author-id'])) {
$photo = notags(trim($datarray['author-avatar'])); return;
$nick = ''; }
if (is_object($item)) { $fields = ['url', 'name', 'nick', 'photo', 'network'];
$rawtag = $item->get_item_tags(NAMESPACE_ACTIVITY,'actor'); $pub_contact = DBA::selectFirst('contact', $fields, ['id' => $datarray['author-id']]);
if ($rawtag && $rawtag[0]['child'][NAMESPACE_POCO]['preferredUsername'][0]['data']) { if (!DBA::isResult($pub_contact)) {
$nick = $rawtag[0]['child'][NAMESPACE_POCO]['preferredUsername'][0]['data']; // Should never happen
} return;
} else {
$nick = $item;
} }
$url = $pub_contact['url'];
$name = $pub_contact['name'];
$photo = $pub_contact['photo'];
$nick = $pub_contact['nick'];
$network = $pub_contact['network'];
if (is_array($contact)) { if (is_array($contact)) {
if (($contact['rel'] == self::SHARING) if (($contact['rel'] == self::SHARING)
|| ($sharing && $contact['rel'] == self::FOLLOWER)) { || ($sharing && $contact['rel'] == self::FOLLOWER)) {
@ -1601,13 +1605,13 @@ class Contact extends BaseObject
DBA::escape($name), DBA::escape($name),
DBA::escape($nick), DBA::escape($nick),
DBA::escape($photo), DBA::escape($photo),
DBA::escape(NETWORK_OSTATUS), DBA::escape($network),
intval(self::FOLLOWER) intval(self::FOLLOWER)
); );
$contact_record = [ $contact_record = [
'id' => DBA::lastInsertId(), 'id' => DBA::lastInsertId(),
'network' => NETWORK_OSTATUS, 'network' => $network,
'name' => $name, 'name' => $name,
'url' => $url, 'url' => $url,
'photo' => $photo 'photo' => $photo

View file

@ -89,7 +89,7 @@ class Event extends BaseObject
$o .= '<div class="description event-description">' . BBCode::convert($event['desc'], false, $simple) . '</div>' . "\r\n"; $o .= '<div class="description event-description">' . BBCode::convert($event['desc'], false, $simple) . '</div>' . "\r\n";
} }
if (strlen($event['location'])) { if (!empty($event['location'])) {
$o .= '<div class="event-location"><span class="event-label">' . L10n::t('Location:') . '</span>&nbsp;<span class="location">' $o .= '<div class="event-location"><span class="event-label">' . L10n::t('Location:') . '</span>&nbsp;<span class="location">'
. BBCode::convert($event['location'], false, $simple) . BBCode::convert($event['location'], false, $simple)
. '</span></div>' . "\r\n"; . '</span></div>' . "\r\n";

View file

@ -729,7 +729,8 @@ class User
Worker::add(PRIORITY_HIGH, "Notifier", "removeme", $uid); Worker::add(PRIORITY_HIGH, "Notifier", "removeme", $uid);
// Send an update to the directory // Send an update to the directory
Worker::add(PRIORITY_LOW, "Directory", $user['url']); $self = DBA::selectFirst('contact', ['url'], ['uid' => $uid, 'self' => true]);
Worker::add(PRIORITY_LOW, "Directory", $self['url']);
if ($uid == local_user()) { if ($uid == local_user()) {
unset($_SESSION['authenticated']); unset($_SESSION['authenticated']);

View file

@ -139,7 +139,7 @@ class Proxy extends BaseModule
$cachefile = get_cachefile(hash('md5', $_REQUEST['url'])); $cachefile = get_cachefile(hash('md5', $_REQUEST['url']));
if ($cachefile != '' && file_exists($cachefile)) { if ($cachefile != '' && file_exists($cachefile)) {
$img_str = file_get_contents($cachefile); $img_str = file_get_contents($cachefile);
$mime = image_type_to_mime_type(exif_imagetype($cachefile)); $mime = mime_content_type($cachefile);
header('Content-type: ' . $mime); header('Content-type: ' . $mime);
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
@ -187,7 +187,7 @@ class Proxy extends BaseModule
$tempfile = tempnam(get_temppath(), 'cache'); $tempfile = tempnam(get_temppath(), 'cache');
file_put_contents($tempfile, $img_str); file_put_contents($tempfile, $img_str);
$mime = image_type_to_mime_type(exif_imagetype($tempfile)); $mime = mime_content_type($tempfile);
unlink($tempfile); unlink($tempfile);
// If there is an error then return a blank image // If there is an error then return a blank image

View file

@ -946,7 +946,7 @@ class Probe
// This logging is for temporarily debugging reasons // This logging is for temporarily debugging reasons
if (!isset($data["poco"])) { if (!isset($data["poco"])) {
logger('POCO not defined for ' . profile_link, LOGGER_DEBUG); logger('POCO not defined for ' . $profile_link . ' - ' . System::callstack(), LOGGER_DEBUG);
} }
logger("Result for profile ".$profile_link.": ".print_r($prof_data, true), LOGGER_DEBUG); logger("Result for profile ".$profile_link.": ".print_r($prof_data, true), LOGGER_DEBUG);
@ -1603,7 +1603,10 @@ class Probe
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1", intval($uid)); $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1", intval($uid));
if (DBA::isResult($x) && DBA::isResult($r)) { if (!DBA::isResult($x) || !DBA::isResult($r)) {
return false;
}
$mailbox = Email::constructMailboxName($r[0]); $mailbox = Email::constructMailboxName($r[0]);
$password = ''; $password = '';
openssl_private_decrypt(hex2bin($r[0]['pass']), $password, $x[0]['prvkey']); openssl_private_decrypt(hex2bin($r[0]['pass']), $password, $x[0]['prvkey']);
@ -1611,7 +1614,6 @@ class Probe
if (!$mbox) { if (!$mbox) {
return false; return false;
} }
}
$msgs = Email::poll($mbox, $uri); $msgs = Email::poll($mbox, $uri);
logger('searching '.$uri.', '.count($msgs).' messages found.', LOGGER_DEBUG); logger('searching '.$uri.', '.count($msgs).' messages found.', LOGGER_DEBUG);

View file

@ -25,6 +25,16 @@ class Email
$mbox = @imap_open($mailbox, $username, $password); $mbox = @imap_open($mailbox, $username, $password);
$errors = imap_errors();
if (!empty($errors)) {
logger('IMAP Errors occured: ' . json_encode($errors));
}
$alerts = imap_alerts();
if (!empty($alerts)) {
logger('IMAP Alerts occured: ' . json_encode($alerts));
}
return $mbox; return $mbox;
} }

View file

@ -19,6 +19,8 @@ if (!x($colorset)) {
$colorset = $s_colorset; $colorset = $s_colorset;
} }
$setcss = '';
if ($colorset) { if ($colorset) {
if ($colorset == 'greenzero') { if ($colorset == 'greenzero') {
$setcss = file_get_contents('view/theme/duepuntozero/deriv/greenzero.css'); $setcss = file_get_contents('view/theme/duepuntozero/deriv/greenzero.css');

View file

@ -110,6 +110,7 @@ if (empty($login_bg_image) && empty($login_bg_color)) {
$login_bg_image = 'img/login_bg.jpg'; $login_bg_image = 'img/login_bg.jpg';
} }
$login_bg_color = (empty($login_bg_color) ? '#ededed' : $login_bg_color); $login_bg_color = (empty($login_bg_color) ? '#ededed' : $login_bg_color);
$login_bg_image = (empty($login_bg_image) ? '' : $login_bg_image);
$contentbg_transp = ((isset($contentbg_transp) && $contentbg_transp != '') ? $contentbg_transp : 100); $contentbg_transp = ((isset($contentbg_transp) && $contentbg_transp != '') ? $contentbg_transp : 100);