{
$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']);
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.
$parent_id = 0;
}
+ $epreamble = '';
+
if ($params['type'] == NOTIFY_MAIL) {
$itemlink = $siteurl.'/message/'.$params['item']['id'];
$params["link"] = $itemlink;
}
// 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) {
$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>';
* 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'];
+ }
}
}
$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);
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())
);
(`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 " );
|| (x($profile, 'country-name') == 1)
) {
$location = L10n::t('Location:');
+ } else {
+ $location = '';
}
$gender = ((x($profile, 'gender') == 1) ? L10n::t('Gender:') : false);
function group_post(App $a) {
- if (! local_user()) {
+ if (!local_user()) {
notice(L10n::t('Permission denied.') . EOL);
return;
}
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()),
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');
}
}
+ $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'),
}
}
- 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",
intval(local_user())
);
- if (! DBA::isResult($r)) {
+ if (!DBA::isResult($r)) {
notice(L10n::t('Group not found.') . EOL);
goaway(System::baseUrl() . '/contacts');
}
}
- if (! isset($group)) {
+ if (!isset($group)) {
return;
}
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)
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') {
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) {
$o .= '<br /><br />';
- if (x($_GET, 'addr')) {
+ if (!empty($_GET['addr'])) {
$addr = trim($_GET['addr']);
$res = Probe::uri($addr, "", 0, false);
$o .= '<pre>';
$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];
}
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);
$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]";
}
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)) {
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
$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> <span class="location">'
. BBCode::convert($event['location'], false, $simple)
. '</span></div>' . "\r\n";
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']);
$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');
$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
// 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);
$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);
$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;
}
$colorset = $s_colorset;
}
+$setcss = '';
+
if ($colorset) {
if ($colorset == 'greenzero') {
$setcss = file_get_contents('view/theme/duepuntozero/deriv/greenzero.css');
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');
}
$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);