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();
// 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
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])) {
return;
}
$nickname = $user["nickname"];
} else {
$nickname = '';
}
$nickname = $user["nickname"];
// with $params['show_in_notification_page'] == false, the notification isn't inserted into
// the database, and an email is sent if applicable.
@ -93,6 +100,8 @@ function notification($params)
$parent_id = 0;
}
$epreamble = '';
if ($params['type'] == NOTIFY_MAIL) {
$itemlink = $siteurl.'/message/'.$params['item']['id'];
$params["link"] = $itemlink;
@ -529,7 +538,7 @@ function notification($params)
}
// 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'] == SYSTEM_EMAIL) {
@ -577,11 +586,11 @@ function notification($params)
$datarray['siteurl'] = $siteurl;
$datarray['type'] = $params['type'];
$datarray['parent'] = $parent_id;
$datarray['source_name'] = $params['source_name'];
$datarray['source_link'] = $params['source_link'];
$datarray['source_photo'] = $params['source_photo'];
$datarray['source_name'] = defaults($params, 'source_name', '');
$datarray['source_link'] = defaults($params, 'source_link', '');
$datarray['source_photo'] = defaults($params, 'source_photo', '');
$datarray['uid'] = $params['uid'];
$datarray['username'] = $params['to_name'];
$datarray['username'] = defaults($params, 'to_name', '');
$datarray['hsitelink'] = $hsitelink;
$datarray['tsitelink'] = $tsitelink;
$datarray['hitemlink'] = '<a href="'.$itemlink.'">'.$itemlink.'</a>';

View file

@ -92,11 +92,13 @@ if (!$a->is_backend()) {
* We have to do it here because the session was just now opened.
*/
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;
if (DBA::isResult($user)) {
$_SESSION['language'] = $user['language'];
// 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)) {
$_SESSION['language'] = $user['language'];
}
}
}

View file

@ -32,7 +32,8 @@ function dfrn_poll_init(App $a)
$quiet = x($_GET, 'quiet');
// 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];
header("Content-type: application/atom+xml");
echo OStatus::feed($nickname, $last_update, 10);

View file

@ -422,7 +422,7 @@ function dfrn_request_post(App $a)
intval($uid),
intval($contact_record['id']),
((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(DateTimeFormat::utcNow())
);

View file

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

View file

@ -22,7 +22,7 @@ function group_init(App $a) {
function group_post(App $a) {
if (! local_user()) {
if (!local_user()) {
notice(L10n::t('Permission denied.') . EOL);
return;
}
@ -45,21 +45,21 @@ function group_post(App $a) {
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');
$r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($a->argv[1]),
intval(local_user())
);
if (! DBA::isResult($r)) {
if (!DBA::isResult($r)) {
notice(L10n::t('Group not found.') . EOL);
goaway(System::baseUrl() . '/contacts');
return; // NOTREACHED
}
$group = $r[0];
$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",
DBA::escape($groupname),
intval(local_user()),
@ -79,13 +79,13 @@ function group_post(App $a) {
function group_content(App $a) {
$change = false;
if (! local_user()) {
if (!local_user()) {
notice(L10n::t('Permission denied') . EOL);
return;
}
// Switch to text mode interface if we have more than 'n' contacts or group members
if ($a->argc == 1) {
goaway(System::baseUrl() . '/contacts');
}
@ -113,11 +113,13 @@ function group_content(App $a) {
}
$nogroup = false;
if (($a->argc == 2) && ($a->argv[1] === 'none')) {
require_once 'mod/contacts.php';
$id = -1;
$nogroup = True;
$nogroup = true;
$group = [
'id' => $id,
'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';
$r = q("SELECT * FROM `group` WHERE `id` = %d AND `uid` = %d AND `deleted` = 0 LIMIT 1",
@ -181,7 +183,7 @@ function group_content(App $a) {
intval(local_user())
);
if (! DBA::isResult($r)) {
if (!DBA::isResult($r)) {
notice(L10n::t('Group not found.') . EOL);
goaway(System::baseUrl() . '/contacts');
}
@ -234,7 +236,7 @@ function group_content(App $a) {
}
if (! isset($group)) {
if (!isset($group)) {
return;
}
@ -279,7 +281,7 @@ function group_content(App $a) {
if (DBA::isResult($r)) {
// Format the data of the contacts who aren't in the contact group
foreach ($r as $member) {
if (! in_array($member['id'], $preselected)) {
if (!in_array($member['id'], $preselected)) {
$entry = _contact_detail_for_template($member);
$entry['label'] = 'contacts';
if (!$nogroup)

View file

@ -108,7 +108,7 @@ function ping_init(App $a)
if (local_user()) {
// 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]];
if ($format == 'json') {
@ -347,7 +347,7 @@ function ping_init(App $a)
if (DBA::isResult($notifs)) {
// 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) {
if ($a->is_friendica_app() || !$regularnotifications) {

View file

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

View file

@ -86,7 +86,7 @@ class BBCode extends BaseObject
$post["url"] = $matches[1];
$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)) {
$post["url"] = $matches[1];
}
@ -609,7 +609,7 @@ class BBCode extends BaseObject
if (!$data) {
return $Text;
} elseif ($nolink) {
return $data["text"] . $data["after"];
return $data["text"] . defaults($data, 'after', '');
}
$title = htmlentities(defaults($data, 'title', ''), ENT_QUOTES, 'UTF-8', false);
@ -632,7 +632,7 @@ class BBCode extends BaseObject
$text = $data["text"];
if (!empty($data["url"]) && ($data["title"] != "")) {
if (!empty($data["url"]) && !empty($data["title"])) {
$text .= "\n[url=" . $data["url"] . "]" . $data["title"] . "[/url]";
} elseif (!empty($data["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) {
$url = notags(trim($datarray['author-link']));
$name = notags(trim($datarray['author-name']));
$photo = notags(trim($datarray['author-avatar']));
$nick = '';
if (is_object($item)) {
$rawtag = $item->get_item_tags(NAMESPACE_ACTIVITY,'actor');
if ($rawtag && $rawtag[0]['child'][NAMESPACE_POCO]['preferredUsername'][0]['data']) {
$nick = $rawtag[0]['child'][NAMESPACE_POCO]['preferredUsername'][0]['data'];
}
} else {
$nick = $item;
// Should always be set
if (empty($datarray['author-id'])) {
return;
}
$fields = ['url', 'name', 'nick', 'photo', 'network'];
$pub_contact = DBA::selectFirst('contact', $fields, ['id' => $datarray['author-id']]);
if (!DBA::isResult($pub_contact)) {
// Should never happen
return;
}
$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 (($contact['rel'] == self::SHARING)
|| ($sharing && $contact['rel'] == self::FOLLOWER)) {
@ -1601,13 +1605,13 @@ class Contact extends BaseObject
DBA::escape($name),
DBA::escape($nick),
DBA::escape($photo),
DBA::escape(NETWORK_OSTATUS),
DBA::escape($network),
intval(self::FOLLOWER)
);
$contact_record = [
'id' => DBA::lastInsertId(),
'network' => NETWORK_OSTATUS,
'network' => $network,
'name' => $name,
'url' => $url,
'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";
}
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">'
. BBCode::convert($event['location'], false, $simple)
. '</span></div>' . "\r\n";

View file

@ -729,7 +729,8 @@ class User
Worker::add(PRIORITY_HIGH, "Notifier", "removeme", $uid);
// 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()) {
unset($_SESSION['authenticated']);

View file

@ -139,7 +139,7 @@ class Proxy extends BaseModule
$cachefile = get_cachefile(hash('md5', $_REQUEST['url']));
if ($cachefile != '' && file_exists($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('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');
file_put_contents($tempfile, $img_str);
$mime = image_type_to_mime_type(exif_imagetype($tempfile));
$mime = mime_content_type($tempfile);
unlink($tempfile);
// 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
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);
@ -1603,14 +1603,16 @@ class Probe
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1", intval($uid));
if (DBA::isResult($x) && DBA::isResult($r)) {
$mailbox = Email::constructMailboxName($r[0]);
$password = '';
openssl_private_decrypt(hex2bin($r[0]['pass']), $password, $x[0]['prvkey']);
$mbox = Email::connect($mailbox, $r[0]['user'], $password);
if (!$mbox) {
return false;
}
if (!DBA::isResult($x) || !DBA::isResult($r)) {
return false;
}
$mailbox = Email::constructMailboxName($r[0]);
$password = '';
openssl_private_decrypt(hex2bin($r[0]['pass']), $password, $x[0]['prvkey']);
$mbox = Email::connect($mailbox, $r[0]['user'], $password);
if (!$mbox) {
return false;
}
$msgs = Email::poll($mbox, $uri);

View file

@ -25,6 +25,16 @@ class Email
$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;
}

View file

@ -19,6 +19,8 @@ if (!x($colorset)) {
$colorset = $s_colorset;
}
$setcss = '';
if ($colorset) {
if ($colorset == 'greenzero') {
$setcss = file_get_contents('view/theme/duepuntozero/deriv/greenzero.css');
@ -27,7 +29,7 @@ if ($colorset) {
if ($colorset == 'purplezero') {
$setcss = file_get_contents('view/theme/duepuntozero/deriv/purplezero.css');
}
if ($colorset == 'easterbunny') {
$setcss = file_get_contents('view/theme/duepuntozero/deriv/easterbunny.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_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);