$seconds = 300;
break;
case CACHE_MINUTE:
+ default:
$seconds = 60;
break;
}
if (Config::get("system", "profiler")) {
$duration = microtime(true)-$a->performance["start"];
+ $o = '';
if (Config::get("rendertime", "callstack")) {
if (isset($a->callstack["database"])) {
- $o = "\nDatabase Read:\n";
+ $o .= "\nDatabase Read:\n";
foreach ($a->callstack["database"] as $func => $time) {
$time = round($time, 3);
if ($time > 0) {
}
}
}
- } else {
- $o = '';
}
logger(
// We killed the stale process.
// To avoid a blocking situation we reschedule the process at the beginning of the queue.
// Additionally we are lowering the priority. (But not PRIORITY_CRITICAL)
+ $new_priority = $entry["priority"];
if ($entry["priority"] == PRIORITY_HIGH) {
$new_priority = PRIORITY_MEDIUM;
} elseif ($entry["priority"] == PRIORITY_MEDIUM) {
$limit = min($queue_length, ceil($slope * pow($jobs, $exponent)));
logger('Total: '.$jobs.' - Maximum: '.$queue_length.' - jobs per queue: '.$limit, LOGGER_DEBUG);
-
+ $ids = [];
if (self::passingSlow($highest_priority)) {
// Are there waiting processes with a higher priority than the currently highest?
$result = dba::select(
// Compare it
foreach ($definition AS $name => $structure) {
- $is_new_table = False;
+ $is_new_table = false;
$group_by = "";
$sql3 = "";
+ $is_unique = false;
+ $temp_name = $name;
if (!isset($database[$name])) {
$r = self::createTable($name, $structure["fields"], $verbose, $action, $structure['indexes']);
if (!DBM::is_result($r)) {
$errors .= self::printUpdateError($name);
}
- $is_new_table = True;
+ $is_new_table = true;
} else {
- $is_unique = false;
- $temp_name = $name;
-
foreach ($structure["indexes"] AS $indexname => $fieldnames) {
if (isset($database[$name]["indexes"][$indexname])) {
$current_index_definition = implode(",",$database[$name]["indexes"][$indexname]);
if ($ignore != "") {
dba::e("SET session old_alter_table=1;");
} else {
- dba::e("DROP TABLE IF EXISTS `".$temp_name."`;");
+ $r = dba::e("DROP TABLE IF EXISTS `".$temp_name."`;");
if (!DBM::is_result($r)) {
$errors .= self::printUpdateError($sql3);
return $errors;
$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');
intval(CONTACT_IS_FOLLOWER)
);
- $r = q("SELECT `id`, `network` FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `pending` = 1 LIMIT 1",
- intval($importer['uid']),
- dbesc($url)
- );
- if (DBM::is_result($r)) {
- $contact_record = $r[0];
- Contact::updateAvatar($photo, $importer["uid"], $contact_record["id"], true);
- }
+ $contact_record = [
+ 'id' => dba::lastInsertId(),
+ 'network' => NETWORK_OSTATUS
+ ];
+ Contact::updateAvatar($photo, $importer["uid"], $contact_record["id"], true);
/// @TODO Encapsulate this into a function/method
- $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
- intval($importer['uid'])
- );
- if (DBM::is_result($r) && !in_array($r[0]['page-flags'], [PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_COMMUNITY])) {
+ $fields = ['uid', 'username', 'email', 'page-flags', 'notify-flags', 'language'];
+ $user = dba::selectFirst('user', $fields, ['uid' => $importer['uid']]);
+ if (DBM::is_result($user) && !in_array($user['page-flags'], [PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_COMMUNITY])) {
// create notification
$hash = random_string();
Group::addMember(User::getDefaultGroup($importer['uid'], $contact_record["network"]), $contact_record['id']);
- if (($r[0]['notify-flags'] & NOTIFY_INTRO) &&
- in_array($r[0]['page-flags'], [PAGE_NORMAL])) {
+ if (($user['notify-flags'] & NOTIFY_INTRO) &&
+ in_array($user['page-flags'], [PAGE_NORMAL])) {
notification([
'type' => NOTIFY_INTRO,
- 'notify_flags' => $r[0]['notify-flags'],
- 'language' => $r[0]['language'],
- 'to_name' => $r[0]['username'],
- 'to_email' => $r[0]['email'],
- 'uid' => $r[0]['uid'],
+ 'notify_flags' => $user['notify-flags'],
+ 'language' => $user['language'],
+ 'to_name' => $user['username'],
+ 'to_email' => $user['email'],
+ 'uid' => $user['uid'],
'link' => System::baseUrl() . '/notifications/intro',
'source_name' => ((strlen(stripslashes($contact_record['name']))) ? stripslashes($contact_record['name']) : L10n::t('[Name Withheld]')),
'source_link' => $contact_record['url'],
]);
}
- } elseif (DBM::is_result($r) && in_array($r[0]['page-flags'], [PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_COMMUNITY])) {
+ } elseif (DBM::is_result($user) && in_array($user['page-flags'], [PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_COMMUNITY])) {
q("UPDATE `contact` SET `pending` = 0 WHERE `uid` = %d AND `url` = '%s' AND `pending` LIMIT 1",
intval($importer['uid']),
dbesc($url)
);
}
-
}
}
{
$gcontact_id = 0;
$doprobing = false;
+ $last_failure_str = '';
+ $last_contact_str = '';
if (in_array($contact["network"], [NETWORK_PHANTOM])) {
logger("Invalid network for contact url ".$contact["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG);
$arr['network'] = trim(defaults($arr, 'network', NETWORK_PHANTOM));
}
- if ($notify) {
- $guid_prefix = "";
- } elseif ((trim($arr['guid']) == "") && (trim($arr['plink']) != "")) {
+ $guid_prefix = '';
+ if ((trim($arr['guid']) == "") && (trim($arr['plink']) != "")) {
$arr['guid'] = self::guidFromUri($arr['plink']);
} elseif ((trim($arr['guid']) == "") && (trim($arr['uri']) != "")) {
$arr['guid'] = self::guidFromUri($arr['uri']);
$arr['thr-parent'] = $arr['parent-uri'];
+ $notify_type = '';
+ $allow_cid = '';
+ $allow_gid = '';
+ $deny_cid = '';
+ $deny_gid = '';
if ($arr['parent-uri'] === $arr['uri']) {
$parent_id = 0;
$parent_deleted = 0;
}
}
+ $convuri = '';
if (!$convid) {
// create a new conversation
$recip_host = substr($contact['url'], strpos($contact['url'], '://') + 3);
*/
public static function importProfilePhoto($image_url, $uid, $cid, $quit_on_error = false)
{
+ $thumb = '';
+ $micro = '';
+
$photo = dba::selectFirst(
'photo', ['resource-id'], ['uid' => $uid, 'contact-id' => $cid, 'scale' => 4, 'album' => 'Contact Photos']
);
Cache::set($cachekey, $r, CACHE_HOUR);
}
}
+
+ $total = 0;
+ $classtoday = '';
if (DBM::is_result($r)) {
- $total = 0;
$now = strtotime('now');
$cids = [];
*/
private static function getAuthenticationInfo($user_info)
{
+ $user = null;
+
if (is_object($user_info) || is_array($user_info)) {
if (is_object($user_info)) {
$user = (array) $user_info;
return false;
}
- if ($uid != 0) {
- $x = q("SELECT `prvkey` FROM `user` WHERE `uid` = %d LIMIT 1", intval($uid));
-
- $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1", intval($uid));
-
- if (DBM::is_result($x) && DBM::is_result($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 ($uid == 0) {
+ return false;
+ }
+
+ $x = q("SELECT `prvkey` FROM `user` WHERE `uid` = %d LIMIT 1", intval($uid));
- $msgs = Email::poll($mbox, $uri);
- logger('searching '.$uri.', '.count($msgs).' messages found.', LOGGER_DEBUG);
+ $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1", intval($uid));
- if (!count($msgs)) {
+ if (DBM::is_result($x) && DBM::is_result($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;
}
}
+ $msgs = Email::poll($mbox, $uri);
+ logger('searching '.$uri.', '.count($msgs).' messages found.', LOGGER_DEBUG);
+
+ if (!count($msgs)) {
+ return false;
+ }
+
$phost = substr($uri, strpos($uri, '@') + 1);
$data = [];
return false;
}
- $r = q(
- "SELECT * FROM `parsed_url` WHERE `url` = '%s' AND `guessing` = %d AND `oembed` = %d",
- dbesc(normalise_link($url)),
- intval(!$no_guessing),
- intval($do_oembed)
+ $parsed_url = dba::selectFirst('parsed_url', ['content'],
+ ['url' => normalise_link($url), 'guessing' => !$no_guessing, 'oembed' => $do_oembed]
);
-
- if ($r) {
- $data = $r[0]["content"];
- }
-
- if (!is_null($data)) {
- $data = unserialize($data);
+ if (!empty($parsed_url['content'])) {
+ $data = unserialize($parsed_url['content']);
return $data;
}
}
}
+ $element = null;
foreach ($array as $key => $value) {
if (!isset($element) && isset($xml)) {
$element = $xml;
return(null);
}
+ $xml_element_copy = '';
if (!is_string($xml_element)
&& !is_array($xml_element)
&& (get_class($xml_element) == 'SimpleXMLElement')
) {
- $xml_element_copy = $xml_element;
- $xml_element = get_object_vars($xml_element);
+ $xml_element_copy = $xml_element;
+ $xml_element = get_object_vars($xml_element);
}
if (is_array($xml_element)) {
$relocate = false;
$top_level = false;
$recipients = [];
- $url_recipients = [];
$followup = false;
$normal_mode = true;
+ $item = null;
+
$recipients[] = $contact_id;
if ($cmd === 'mail') {
}
- $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `blocked` = 0 AND `pending` = 0",
- intval($contact_id)
+ // We don't deliver our items to blocked or pending contacts, and not to ourselves either
+ $contact = dba::selectFirst('contact', [],
+ ['id' => $contact_id, 'blocked' => false, 'pending' => false, 'self' => false]
);
-
- if (DBM::is_result($r)) {
- $contact = $r[0];
- }
- if ($contact['self']) {
+ if (!DBM::is_result($contact)) {
return;
}
+
$deliver_status = 0;
// Transmit via Diaspora if not possible via Friendica
logger('notifier: '.$target_item["guid"].' dfrndelivery: '.$contact['name']);
if ($mail) {
- $item['body'] = Item::fixPrivatePhotos($item['body'],$owner['uid'],null,$message[0]['contact-id']);
+ $item['body'] = Item::fixPrivatePhotos($item['body'], $owner['uid'], null, $item['contact-id']);
$atom = DFRN::mail($item, $owner);
} elseif ($fsuggest) {
$atom = DFRN::fsuggest($item, $owner);
- check_profile: Update remote profile data
*/
+ $search = "";
+ $mode = 0;
if ($command == "dirsearch") {
$search = urldecode($param1);
$mode = 1;
$mode = 7;
} elseif ($command == "check_profile") {
$mode = 8;
- } elseif ($command == '') {
- $search = "";
- $mode = 0;
- } else {
+ } elseif ($command !== "") {
logger("Unknown or missing parameter ".$command."\n");
return;
}
$url_recipients = [];
$normal_mode = true;
+ $recipients_relocate = [];
if ($cmd === 'mail') {
$normal_mode = false;
// fill this in with a single salmon slap if applicable
$slap = '';
+ $followup = false;
+ $recipients_followup = [];
+ $conversants = [];
+ $sql_extra = '';
if (! ($mail || $fsuggest || $relocate)) {
$slap = OStatus::salmon($target_item, $owner);
Worker::add($a->queue['priority'], 'Notifier', 'uplink', $item_id);
}
- $conversants = [];
-
foreach ($items as $item) {
$recipients[] = $item['contact-id'];
$conversants[] = $item['contact-id'];
// except for Diaspora batch jobs
// Don't deliver to folks who have already been delivered to
- if (($rr['network'] !== NETWORK_DIASPORA) && (in_array($rr['id'],$conversants))) {
+ if (($rr['network'] !== NETWORK_DIASPORA) && (in_array($rr['id'], $conversants))) {
logger('notifier: already delivered id=' . $rr['id']);
continue;
}
}
$importer = $r[0];
+ $url = '';
logger("poll: ({$contact['network']}-{$contact['id']}) IMPORTER: {$importer['name']}, CONTACT: {$contact['name']}");