]> git.mxchange.org Git - friendica.git/commitdiff
Notices again (#5543)
authorMichael Vogel <icarus@dabo.de>
Thu, 2 Aug 2018 05:21:01 +0000 (07:21 +0200)
committerTobias Diekershoff <tobias.diekershoff@gmx.net>
Thu, 2 Aug 2018 05:21:01 +0000 (07:21 +0200)
* 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

17 files changed:
include/enotify.php
index.php
mod/dfrn_poll.php
mod/dfrn_request.php
mod/directory.php
mod/group.php
mod/ping.php
mod/probe.php
src/Content/Text/BBCode.php
src/Model/Contact.php
src/Model/Event.php
src/Model/User.php
src/Module/Proxy.php
src/Network/Probe.php
src/Protocol/Email.php
view/theme/duepuntozero/style.php
view/theme/frio/style.php

index 35f984b0ecf6bed23d8dd7c233f8b201ed3665fa..6d27aa8897136fecf5f9e0ea76563d7a21ad2acf 100644 (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>';
index 8d40dbf85f2dfbfca4d8657c1e4053cd33068485..41e177ce3bedf76da20f0d9b46a0d78287ed5c8e 100644 (file)
--- a/index.php
+++ b/index.php
@@ -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'];
+               }
        }
 }
 
index 943ddddecc53623fe1b10c23f3e8f28fbd55c7f9..5e5540be140a65db3a28e51e25362347f9563370 100644 (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);
index 9696e059a9aec48c9135399c4628a2b96c6bf981..21c5d2c0fc118927c2b96840b4da07e2e72bec1f 100644 (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())
                                );
index 9cddf3b4b54369c382c624292f67ec3ee12756da..411024dc1aace31a38e12b6f735d5a693a5a0fd7 100644 (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);
index 71a84a80ca5f2420b21e2c853374fce684112e13..88b9830626de2ab79e7006b8affc58017b88b7b0 100644 (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)
index 2ac4924a96336de428503fbae967209a225d1f34..99ebde70c183a2367d8a19406b51436e66a95748 100644 (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) {
index 5e7a5253fda20ed6c6733ce038ce88b8cdc5af38..fb85de91bdeadec495f3ae6887f65bef6606e98c 100644 (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>';
index 801e7054b2c447fb78d2449e9db2f44d3e7b9dc4..76f8a8c2d81ee954b6ab5fad86e14ff737a7fc11 100644 (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]";
index 52eaa437f143d390e17ba69c8ff9489c794fc487..6f83dba0193c51cb4732a0a4b3e3c0f3427266b1 100644 (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
index c705a6ca7d928d593a82ac5cbd4de9a37ae2cfe8..1bc922b4653ab73144d0ecc52f95a73ab0468841 100644 (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";
index c272d4c6cea6e1c2cc0ebfdc7827d8c7bf8da3be..3fbbc6e86b13496f27e86595451ff20e4ddc386e 100644 (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']);
index 6287727dce630438d7bbc52ffa3008d956d416d9..bf6d6b6d03e5e7559997f51dad73a8765ddab825 100644 (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
index 8f236796a90ed30d99b4ee72124bc790e8adfde4..c515e066a2888ddb1b124ea6567e0b622a188e7d 100644 (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);
index c3825a16bd1fa5f26e578fa15237f5083da13d25..0963feb0d214db7e48c461bcf997ba629a26793e 100644 (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;
        }
 
index 5d841f1084b85af746d6ef90f655878e6aa223b5..ff55f462f12649aeba346213302230ede911f751 100644 (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');
        }
index 621f5d0ccec8ef6f749ff7257dce52179b8bb042..30f8a0d77145e88627925bc1cb999d56ee48bc90 100644 (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);