use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\Worker;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
// Ensure that daemon.php is executed from the base path of the installation
if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) {
// fclose(STDOUT); // file descriptors as we
// fclose(STDERR); // are running as a daemon.
- dba::disconnect();
+ DBA::disconnect();
register_shutdown_function('shutdown');
if ($do_cron) {
// We force a reconnect of the database connection.
// This is done to ensure that the connection don't get lost over time.
- dba::reconnect();
+ DBA::reconnect();
$last_cron = time();
}
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Core\Worker;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Group;
} else {
$user_id = User::authenticate(trim($user), trim($password));
if ($user_id !== false) {
- $record = dba::selectFirst('user', [], ['uid' => $user_id]);
+ $record = DBA::selectFirst('user', [], ['uid' => $user_id]);
}
}
*/
function api_unique_id_to_nurl($id)
{
- $r = dba::selectFirst('contact', ['nurl'], ['id' => $id]);
+ $r = DBA::selectFirst('contact', ['nurl'], ['id' => $id]);
if (DBM::is_result($r)) {
return $r["nurl"];
$uinfo[0]['network'] = NETWORK_DFRN;
}
- $usr = dba::selectFirst('user', ['default-location'], ['uid' => api_user()]);
- $profile = dba::selectFirst('profile', ['about'], ['uid' => api_user(), 'is-default' => true]);
+ $usr = DBA::selectFirst('user', ['default-location'], ['uid' => api_user()]);
+ $profile = DBA::selectFirst('profile', ['about'], ['uid' => api_user(), 'is-default' => true]);
}
$countitems = 0;
$countfriends = 0;
// If this is a local user and it uses Frio, we can get its color preferences.
if ($ret['self']) {
- $theme_info = dba::selectFirst('user', ['theme'], ['uid' => $ret['uid']]);
+ $theme_info = DBA::selectFirst('user', ['theme'], ['uid' => $ret['uid']]);
if ($theme_info['theme'] === 'frio') {
$schema = PConfig::get($ret['uid'], 'frio', 'schema');
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60);
$condition = ["`uid` = ? AND `wall` AND `created` > ? AND `id` = `parent`", api_user(), $datefrom];
- $posts_day = dba::count('item', $condition);
+ $posts_day = DBA::count('item', $condition);
if ($posts_day > $throttle_day) {
logger('Daily posting limit reached for user '.api_user(), LOGGER_DEBUG);
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*7);
$condition = ["`uid` = ? AND `wall` AND `created` > ? AND `id` = `parent`", api_user(), $datefrom];
- $posts_week = dba::count('item', $condition);
+ $posts_week = DBA::count('item', $condition);
if ($posts_week > $throttle_week) {
logger('Weekly posting limit reached for user '.api_user(), LOGGER_DEBUG);
$datefrom = date(DateTimeFormat::MYSQL, time() - 24*60*60*30);
$condition = ["`uid` = ? AND `wall` AND `created` > ? AND `id` = `parent`", api_user(), $datefrom];
- $posts_month = dba::count('item', $condition);
+ $posts_month = DBA::count('item', $condition);
if ($posts_month > $throttle_month) {
logger('Monthly posting limit reached for user '.api_user(), LOGGER_DEBUG);
}
}
- dba::close($ret);
+ DBA::close($ret);
if ($type == "xml") {
$xml_activities = [];
$user_info = api_get_user($a);
$uid = $user_info['uid'];
- $groups = dba::select('group', [], ['deleted' => 0, 'uid' => $uid]);
+ $groups = DBA::select('group', [], ['deleted' => 0, 'uid' => $uid]);
// loop through all groups
$lists = [];
}
// now let's delete all photos from the album
- $result = dba::delete('photo', ['uid' => api_user(), 'album' => $album]);
+ $result = DBA::delete('photo', ['uid' => api_user(), 'album' => $album]);
// return success of deletion or error message
if ($result) {
throw new BadRequestException("no new albumname specified");
}
// check if album is existing
- if (!dba::exists('photo', ['uid' => api_user(), 'album' => $album])) {
+ if (!DBA::exists('photo', ['uid' => api_user(), 'album' => $album])) {
throw new BadRequestException("album not available");
}
// now let's update all photos to the albumname
- $result = dba::update('photo', ['album' => $album_new], ['uid' => api_user(), 'album' => $album]);
+ $result = DBA::update('photo', ['album' => $album_new], ['uid' => api_user(), 'album' => $album]);
// return success of updating or error message
if ($result) {
throw new BadRequestException("photo not available");
}
// now we can perform on the deletion of the photo
- $result = dba::delete('photo', ['uid' => api_user(), 'resource-id' => $photo_id]);
+ $result = DBA::delete('photo', ['uid' => api_user(), 'resource-id' => $photo_id]);
// return success of deletion or error message
if ($result) {
// check if specified profile id is valid
if ($profile_id != 0) {
- $profile = dba::selectFirst('profile', ['is-default'], ['uid' => api_user(), 'id' => $profile_id]);
+ $profile = DBA::selectFirst('profile', ['is-default'], ['uid' => api_user(), 'id' => $profile_id]);
// error message if specified profile id is not in database
if (!DBM::is_result($profile)) {
throw new BadRequestException("profile_id not available");
// change specified profile or all profiles to the new resource-id
if ($is_default_profile) {
$condition = ["`profile` AND `resource-id` != ? AND `uid` = ?", $data['photo']['id'], api_user()];
- dba::update('photo', ['profile' => false], $condition);
+ DBA::update('photo', ['profile' => false], $condition);
} else {
$fields = ['photo' => System::baseUrl() . '/photo/' . $data['photo']['id'] . '-4.' . $filetype,
'thumb' => System::baseUrl() . '/photo/' . $data['photo']['id'] . '-5.' . $filetype];
- dba::update('profile', $fields, ['id' => $_REQUEST['profile'], 'uid' => api_user()]);
+ DBA::update('profile', $fields, ['id' => $_REQUEST['profile'], 'uid' => api_user()]);
}
Contact::updateSelfFromUserID(api_user(), true);
$api_user = api_get_user(get_app());
if (!empty($_POST['name'])) {
- dba::update('profile', ['name' => $_POST['name']], ['uid' => $local_user]);
- dba::update('user', ['username' => $_POST['name']], ['uid' => $local_user]);
- dba::update('contact', ['name' => $_POST['name']], ['uid' => $local_user, 'self' => 1]);
- dba::update('contact', ['name' => $_POST['name']], ['id' => $api_user['id']]);
+ DBA::update('profile', ['name' => $_POST['name']], ['uid' => $local_user]);
+ DBA::update('user', ['username' => $_POST['name']], ['uid' => $local_user]);
+ DBA::update('contact', ['name' => $_POST['name']], ['uid' => $local_user, 'self' => 1]);
+ DBA::update('contact', ['name' => $_POST['name']], ['id' => $api_user['id']]);
}
if (isset($_POST['description'])) {
- dba::update('profile', ['about' => $_POST['description']], ['uid' => $local_user]);
- dba::update('contact', ['about' => $_POST['description']], ['uid' => $local_user, 'self' => 1]);
- dba::update('contact', ['about' => $_POST['description']], ['id' => $api_user['id']]);
+ DBA::update('profile', ['about' => $_POST['description']], ['uid' => $local_user]);
+ DBA::update('contact', ['about' => $_POST['description']], ['uid' => $local_user, 'self' => 1]);
+ DBA::update('contact', ['about' => $_POST['description']], ['id' => $api_user['id']]);
}
Worker::add(PRIORITY_LOW, 'ProfileUpdate', $local_user);
// traditional DFRN
- $contact = dba::selectFirst('contact', [], ['uid' => api_user(), 'nurl' => $c_url]);
+ $contact = DBA::selectFirst('contact', [], ['uid' => api_user(), 'nurl' => $c_url]);
if (!DBM::is_result($contact) || ($contact['network'] !== NETWORK_DFRN)) {
throw new BadRequestException("Unknown contact");
$fields = ['uid' => api_user(), 'cid' => $cid, 'dfrn_id' => $dfrn_id,
'sec' => $sec, 'expire' => time() + 45];
- dba::insert('profile_check', $fields);
+ DBA::insert('profile_check', $fields);
logger($contact['name'] . ' ' . $sec, LOGGER_DEBUG);
$dest = ($url ? '&destination_url=' . $url : '');
}
// get data of the specified group id
- $group = dba::selectFirst('group', [], ['uid' => $uid, 'id' => $gid]);
+ $group = DBA::selectFirst('group', [], ['uid' => $uid, 'id' => $gid]);
// error message if specified gid is not in database
if (!$group) {
throw new BadRequestException('gid not available');
}
// get data of the specified group id
- $group = dba::selectFirst('group', [], ['uid' => $uid, 'id' => $gid]);
+ $group = DBA::selectFirst('group', [], ['uid' => $uid, 'id' => $gid]);
// error message if specified gid is not in database
if (!$group) {
throw new BadRequestException('gid not available');
}
// error message if specified id is not in database
- if (!dba::exists('mail', ['id' => $id, 'uid' => $uid])) {
+ if (!DBA::exists('mail', ['id' => $id, 'uid' => $uid])) {
$answer = ['result' => 'error', 'message' => 'message id not in database'];
return api_format_data("direct_messages_setseen", $type, ['$result' => $answer]);
}
// update seen indicator
- $result = dba::update('mail', ['seen' => true], ['id' => $id]);
+ $result = DBA::update('mail', ['seen' => true], ['id' => $id]);
if ($result) {
// return success
*/
function api_saved_searches_list($type)
{
- $terms = dba::select('search', ['id', 'term'], ['uid' => local_user()]);
+ $terms = DBA::select('search', ['id', 'term'], ['uid' => local_user()]);
$result = [];
while ($term = $terms->fetch()) {
];
}
- dba::close($terms);
+ DBA::close($terms);
return api_format_data("terms", $type, ['terms' => $result]);
}
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Item;
$network = '';
$rel = 0;
$condition = ['uid' => local_user(), 'nurl' => normalise_link($item['author-link'])];
- $contact = dba::selectFirst('contact', ['id', 'network', 'rel'], $condition);
+ $contact = DBA::selectFirst('contact', ['id', 'network', 'rel'], $condition);
if (DBM::is_result($contact)) {
$cid = $contact['id'];
$network = $contact['network'];
<?php
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
function dbesc($str) {
- if (dba::$connected) {
- return(dba::escape($str));
+ if (DBA::$connected) {
+ return(DBA::escape($str));
} else {
return(str_replace("'","\\'",$str));
}
$args = func_get_args();
unset($args[0]);
- if (!dba::$connected) {
+ if (!DBA::$connected) {
return false;
}
- $sql = dba::clean_query($sql);
- $sql = dba::any_value_fallback($sql);
+ $sql = DBA::clean_query($sql);
+ $sql = DBA::any_value_fallback($sql);
$stmt = @vsprintf($sql, $args);
- $ret = dba::p($stmt);
+ $ret = DBA::p($stmt);
if (is_bool($ret)) {
return $ret;
}
- $columns = dba::columnCount($ret);
+ $columns = DBA::columnCount($ret);
- $data = dba::inArray($ret);
+ $data = DBA::inArray($ret);
if ((count($data) == 0) && ($columns == 0)) {
return true;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Item;
use Friendica\Util\DateTimeFormat;
$sender_email = $a->getSenderEmailAddress();
if ($params['type'] != SYSTEM_EMAIL) {
- $user = dba::selectFirst('user', ['nickname', 'page-flags'],
+ $user = DBA::selectFirst('user', ['nickname', 'page-flags'],
['uid' => $params['uid']]);
// There is no need to create notifications for forum accounts
}
if ($params['type'] == NOTIFY_COMMENT) {
- $thread = dba::selectFirst('thread', ['ignored'], ['iid' => $parent_id]);
+ $thread = DBA::selectFirst('thread', ['ignored'], ['iid' => $parent_id]);
if (DBM::is_result($thread) && $thread["ignored"]) {
logger("Thread ".$parent_id." will be ignored", LOGGER_DEBUG);
return;
);
if ($p && (count($p) > 1)) {
for ($d = 1; $d < count($p); $d ++) {
- dba::delete('notify', ['id' => $p[$d]['id']]);
+ DBA::delete('notify', ['id' => $p[$d]['id']]);
}
// only continue on if we stored the first one
*/
function check_user_notification($itemid) {
// fetch all users in the thread
- $users = dba::p("SELECT DISTINCT(`contact`.`uid`) FROM `item`
+ $users = DBA::p("SELECT DISTINCT(`contact`.`uid`) FROM `item`
INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` != 0
WHERE `parent` IN (SELECT `parent` FROM `item` WHERE `id`=?)", $itemid);
- while ($user = dba::fetch($users)) {
+ while ($user = DBA::fetch($users)) {
check_item_notification($itemid, $user['uid']);
}
- dba::close($users);
+ DBA::close($users);
}
/**
$profiles = $notification_data["profiles"];
$fields = ['notify-flags', 'language', 'username', 'email', 'nickname'];
- $user = dba::selectFirst('user', $fields, ['uid' => $uid]);
+ $user = DBA::selectFirst('user', $fields, ['uid' => $uid]);
if (!DBM::is_result($user)) {
return false;
}
- $owner = dba::selectFirst('contact', ['url'], ['self' => true, 'uid' => $uid]);
+ $owner = DBA::selectFirst('contact', ['url'], ['self' => true, 'uid' => $uid]);
if (!DBM::is_result($owner)) {
return false;
}
$profiles = $profiles2;
- $ret = dba::select('contact', ['id'], ['uid' => 0, 'nurl' => $profiles]);
+ $ret = DBA::select('contact', ['id'], ['uid' => 0, 'nurl' => $profiles]);
$contacts = [];
- while ($contact = dba::fetch($ret)) {
+ while ($contact = DBA::fetch($ret)) {
$contacts[] = $contact['id'];
}
$contact_list = implode(',', $contacts);
- dba::close($ret);
+ DBA::close($ret);
// Only act if it is a "real" post
// We need the additional check for the "local_profile" because of mixed situations on connector networks
if ($item["parent-uri"] === $item["uri"]) {
// Send a notification for every new post?
- $send_notification = dba::exists('contact', ['id' => $item['contact-id'], 'notify_new_posts' => true]);
+ $send_notification = DBA::exists('contact', ['id' => $item['contact-id'], 'notify_new_posts' => true]);
if (!$send_notification) {
$tags = q("SELECT `url` FROM `term` WHERE `otype` = %d AND `oid` = %d AND `type` = %d AND `uid` = %d",
if (DBM::is_result($tags)) {
foreach ($tags AS $tag) {
$condition = ['nurl' => normalise_link($tag["url"]), 'uid' => $uid, 'notify_new_posts' => true];
- $r = dba::exists('contact', $condition);
+ $r = DBA::exists('contact', $condition);
if ($r) {
$send_notification = true;
}
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Item;
use Friendica\Protocol\DFRN;
logger('subscribe_to_hub: ' . $hubmode . ' ' . $contact['name'] . ' to hub ' . $url . ' endpoint: ' . $push_url . ' with verifier ' . $verify_token);
if (!strlen($contact['hub-verify']) || ($contact['hub-verify'] != $verify_token)) {
- dba::update('contact', ['hub-verify' => $verify_token], ['id' => $contact['id']]);
+ DBA::update('contact', ['hub-verify' => $verify_token], ['id' => $contact['id']]);
}
Network::post($url, $params);
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Group;
use Friendica\Util\DateTimeFormat;
$master_record = $a->user;
if ((x($_SESSION, 'submanage')) && intval($_SESSION['submanage'])) {
- $user = dba::selectFirst('user', [], ['uid' => $_SESSION['submanage']]);
+ $user = DBA::selectFirst('user', [], ['uid' => $_SESSION['submanage']]);
if (DBM::is_result($user)) {
$master_record = $user;
}
'nickname' => $master_record['nickname']]];
// Then add all the children
- $r = dba::select('user', ['uid', 'username', 'nickname'],
+ $r = DBA::select('user', ['uid', 'username', 'nickname'],
['parent-uid' => $master_record['uid'], 'account_removed' => false]);
if (DBM::is_result($r)) {
- $a->identities = array_merge($a->identities, dba::inArray($r));
+ $a->identities = array_merge($a->identities, DBA::inArray($r));
}
} else {
// Just ensure that the array is always defined
$a->identities = [];
// First entry is our parent
- $r = dba::select('user', ['uid', 'username', 'nickname'],
+ $r = DBA::select('user', ['uid', 'username', 'nickname'],
['uid' => $master_record['parent-uid'], 'account_removed' => false]);
if (DBM::is_result($r)) {
- $a->identities = dba::inArray($r);
+ $a->identities = DBA::inArray($r);
}
// Then add all siblings
- $r = dba::select('user', ['uid', 'username', 'nickname'],
+ $r = DBA::select('user', ['uid', 'username', 'nickname'],
['parent-uid' => $master_record['parent-uid'], 'account_removed' => false]);
if (DBM::is_result($r)) {
- $a->identities = array_merge($a->identities, dba::inArray($r));
+ $a->identities = array_merge($a->identities, DBA::inArray($r));
}
}
- $r = dba::p("SELECT `user`.`uid`, `user`.`username`, `user`.`nickname`
+ $r = DBA::p("SELECT `user`.`uid`, `user`.`username`, `user`.`nickname`
FROM `manage`
INNER JOIN `user` ON `manage`.`mid` = `user`.`uid`
WHERE `user`.`account_removed` = 0 AND `manage`.`uid` = ?",
$master_record['uid']
);
if (DBM::is_result($r)) {
- $a->identities = array_merge($a->identities, dba::inArray($r));
+ $a->identities = array_merge($a->identities, DBA::inArray($r));
}
if ($login_initial) {
logger('auth_identities refresh: ' . print_r($a->identities, true), LOGGER_DEBUG);
}
- $contact = dba::selectFirst('contact', [], ['uid' => $_SESSION['uid'], 'self' => true]);
+ $contact = DBA::selectFirst('contact', [], ['uid' => $_SESSION['uid'], 'self' => true]);
if (DBM::is_result($contact)) {
$a->contact = $contact;
$a->cid = $contact['id'];
header('X-Account-Management-Status: active; name="' . $a->user['username'] . '"; id="' . $a->user['nickname'] . '"');
if ($login_initial || $login_refresh) {
- dba::update('user', ['login_date' => DateTimeFormat::utcNow()], ['uid' => $_SESSION['uid']]);
+ DBA::update('user', ['login_date' => DateTimeFormat::utcNow()], ['uid' => $_SESSION['uid']]);
// Set the login date for all identities of the user
- dba::update('user', ['login_date' => DateTimeFormat::utcNow()],
+ DBA::update('user', ['login_date' => DateTimeFormat::utcNow()],
['parent-uid' => $master_record['uid'], 'account_removed' => false]);
}
use Friendica\Core\System;
use Friendica\Core\Theme;
use Friendica\Core\Worker;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Profile;
use Friendica\Module\Login;
*/
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']]);
+ $user = DBA::selectFirst('user', ['language'], ['uid' => $_SESSION['uid']]);
$_SESSION['language'] = $lang;
if (DBM::is_result($user)) {
$_SESSION['language'] = $user['language'];
use Friendica\Content\Widget;
use Friendica\Core\ACL;
use Friendica\Core\Addon;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Item;
while ($author = Item::fetch($authors)) {
$item_authors[$author['author-link']] = $author['author-link'];
}
- dba::close($authors);
+ DBA::close($authors);
foreach ($item_authors as $author) {
if (in_array($author, $known_contacts)) {
use Friendica\Core\System;
use Friendica\Core\Theme;
use Friendica\Core\Worker;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Database\DBStructure;
use Friendica\Model\Contact;
{
$condition = ['uid' => 0, 'blocked' => true];
- $total = dba::count('contact', $condition);
+ $total = DBA::count('contact', $condition);
$a->set_pager_total($total);
$a->set_pager_itemspage(30);
- $statement = dba::select('contact', [], $condition, ['limit' => [$a->pager['start'], $a->pager['itemspage']]]);
+ $statement = DBA::select('contact', [], $condition, ['limit' => [$a->pager['start'], $a->pager['itemspage']]]);
- $contacts = dba::inArray($statement);
+ $contacts = DBA::inArray($statement);
$t = get_markup_template('admin/contactblock.tpl');
$o = replace_macros($t, [
function admin_page_workerqueue(App $a)
{
// get jobs from the workerqueue table
- $statement = dba::select('workerqueue', ['id', 'parameter', 'created', 'priority'], ['done' => 0], ['order'=> ['priority']]);
- $r = dba::inArray($statement);
+ $statement = DBA::select('workerqueue', ['id', 'parameter', 'created', 'priority'], ['done' => 0], ['order'=> ['priority']]);
+ $r = DBA::inArray($statement);
for($i = 0; $i < count($r); $i++) {
$r[$i]['parameter'] = stripslashes(implode(': ', explode('","', $r[$i]['parameter'])));
function admin_page_summary(App $a)
{
// are there MyISAM tables in the DB? If so, trigger a warning message
- $r = q("SELECT `engine` FROM `information_schema`.`tables` WHERE `engine` = 'myisam' AND `table_schema` = '%s' LIMIT 1", dbesc(dba::database_name()));
+ $r = q("SELECT `engine` FROM `information_schema`.`tables` WHERE `engine` = 'myisam' AND `table_schema` = '%s' LIMIT 1", dbesc(DBA::database_name()));
$showwarning = false;
$warningtext = [];
if (DBM::is_result($r)) {
$r = q("UPDATE %s SET %s;", $table_name, $upds);
if (!DBM::is_result($r)) {
- notice("Failed updating '$table_name': " . dba::errorMessage());
+ notice("Failed updating '$table_name': " . DBA::errorMessage());
goaway('admin/site');
}
}
{
if ($a->argc > 2) {
$uid = $a->argv[3];
- $user = dba::selectFirst('user', ['username', 'blocked'], ['uid' => $uid]);
+ $user = DBA::selectFirst('user', ['username', 'blocked'], ['uid' => $uid]);
if (!DBM::is_result($user)) {
notice('User not found' . EOL);
goaway('admin/users');
use Friendica\Content\ContactSelector;
use Friendica\Core\L10n;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
$uid = $a->user['uid'];
- $contact = dba::selectFirst('contact', ['name', 'url', 'photo'], ['id' => $cid, 'uid' => local_user()]);
+ $contact = DBA::selectFirst('contact', ['name', 'url', 'photo'], ['id' => $cid, 'uid' => local_user()]);
if (!DBM::is_result($contact)) {
return;
use Friendica\App;
use Friendica\Core\L10n;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
require_once 'include/dba.php';
// Check for existence, which will also provide us the owner uid
- $r = dba::selectFirst('attach', [], ['id' => $item_id]);
+ $r = DBA::selectFirst('attach', [], ['id' => $item_id]);
if (!DBM::is_result($r)) {
notice(L10n::t('Item was not found.'). EOL);
return;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Event;
if ($a->argc > 1) {
$nick = $a->argv[1];
- $user = dba::selectFirst('user', [], ['nickname' => $nick, 'blocked' => false]);
+ $user = DBA::selectFirst('user', [], ['nickname' => $nick, 'blocked' => false]);
if (!DBM::is_result($user)) {
return;
}
use Friendica\App;
use Friendica\Content\ContactSelector;
use Friendica\Core\L10n;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
}
if ($cmd === 'loc' && $cid) {
- $contact = dba::selectFirst('contact', ['name', 'url', 'photo'], ['id' => $cid, 'uid' => $uid]);
+ $contact = DBA::selectFirst('contact', ['name', 'url', 'photo'], ['id' => $cid, 'uid' => $uid]);
if (DBM::is_result($contact)) {
$a->page['aside'] = "";
Profile::load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
}
} else {
- $contact = dba::selectFirst('contact', ['name', 'url', 'photo'], ['self' => true, 'uid' => $uid]);
+ $contact = DBA::selectFirst('contact', ['name', 'url', 'photo'], ['self' => true, 'uid' => $uid]);
if (DBM::is_result($contact)) {
$vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"), [
}
if (!$cid && Profile::getMyURL()) {
- $contact = dba::selectFirst('contact', ['id'], ['nurl' => normalise_link(Profile::getMyURL()), 'uid' => $uid]);
+ $contact = DBA::selectFirst('contact', ['id'], ['nurl' => normalise_link(Profile::getMyURL()), 'uid' => $uid]);
if (DBM::is_result($contact)) {
$cid = $contact['id'];
} else {
- $gcontact = dba::selectFirst('gcontact', ['id'], ['nurl' => normalise_link(Profile::getMyURL())]);
+ $gcontact = DBA::selectFirst('gcontact', ['id'], ['nurl' => normalise_link(Profile::getMyURL())]);
if (DBM::is_result($gcontact)) {
$zcid = $gcontact['id'];
}
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
function community_init(App $a)
function community_getitems($start, $itemspage, $content)
{
if ($content == 'local') {
- $r = dba::p("SELECT `item`.`uri`, `author`.`url` AS `author-link` FROM `thread`
+ $r = DBA::p("SELECT `item`.`uri`, `author`.`url` AS `author-link` FROM `thread`
INNER JOIN `user` ON `user`.`uid` = `thread`.`uid` AND NOT `user`.`hidewall`
INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
INNER JOIN `contact` AS `author` ON `author`.`id`=`item`.`author-id`
AND NOT `thread`.`private` AND `thread`.`wall` AND `thread`.`origin`
ORDER BY `thread`.`commented` DESC LIMIT " . intval($start) . ", " . intval($itemspage)
);
- return dba::inArray($r);
+ return DBA::inArray($r);
} elseif ($content == 'global') {
- $r = dba::p("SELECT `uri` FROM `thread`
+ $r = DBA::p("SELECT `uri` FROM `thread`
INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
INNER JOIN `contact` AS `author` ON `author`.`id`=`item`.`author-id`
WHERE `thread`.`uid` = 0 AND NOT `author`.`hidden` AND NOT `author`.`blocked`
ORDER BY `thread`.`commented` DESC LIMIT " . intval($start) . ", " . intval($itemspage));
- return dba::inArray($r);
+ return DBA::inArray($r);
}
// Should never happen
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Core\Worker;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
$contact = null;
if ((($a->argc == 2) && intval($a->argv[1])) || (($a->argc == 3) && intval($a->argv[1]) && ($a->argv[2] == "posts"))) {
$contact_id = intval($a->argv[1]);
- $contact = dba::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user()]);
+ $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user()]);
}
if (DBM::is_result($contact)) {
return;
}
- if (!dba::exists('contact', ['id' => $contact_id, 'uid' => local_user()])) {
+ if (!DBA::exists('contact', ['id' => $contact_id, 'uid' => local_user()])) {
notice(L10n::t('Could not access contact record.') . EOL);
goaway('contacts');
return; // NOTREACHED
$profile_id = intval($_POST['profile-assign']);
if ($profile_id) {
- if (!dba::exists('profile', ['id' => $profile_id, 'uid' => local_user()])) {
+ if (!DBA::exists('profile', ['id' => $profile_id, 'uid' => local_user()])) {
notice(L10n::t('Could not locate selected profile.') . EOL);
return;
}
notice(L10n::t('Failed to update contact record.') . EOL);
}
- $contact = dba::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user()]);
+ $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user()]);
if (DBM::is_result($contact)) {
$a->data['contact'] = $contact;
}
function _contact_update($contact_id)
{
- $contact = dba::selectFirst('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => local_user()]);
+ $contact = DBA::selectFirst('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => local_user()]);
if (!DBM::is_result($contact)) {
return;
}
function _contact_update_profile($contact_id)
{
- $contact = dba::selectFirst('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => local_user()]);
+ $contact = DBA::selectFirst('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => local_user()]);
if (!DBM::is_result($contact)) {
return;
}
$cmd = $a->argv[2];
- $orig_record = dba::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user(), 'self' => false]);
+ $orig_record = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user(), 'self' => false]);
if (!DBM::is_result($orig_record)) {
notice(L10n::t('Could not access contact record.') . EOL);
goaway('contacts');
{
$o = contacts_tab($a, $contact_id, 1);
- $contact = dba::selectFirst('contact', ['url'], ['id' => $contact_id]);
+ $contact = DBA::selectFirst('contact', ['url'], ['id' => $contact_id]);
if (DBM::is_result($contact)) {
$a->page['aside'] = "";
Profile::load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\L10n;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
$contact = null;
if (($a->argc == 2) && intval($a->argv[1])) {
- $contact = dba::selectFirst('contact', [], ['uid' => local_user(), 'id' => $a->argv[1]]);
+ $contact = DBA::selectFirst('contact', [], ['uid' => local_user(), 'id' => $a->argv[1]]);
}
if (!x($a->page, 'aside')) {
$contact = null;
if ($cid) {
- $contact = dba::selectFirst('contact', [], ['id' => $cid, 'uid' => local_user()]);
+ $contact = DBA::selectFirst('contact', [], ['id' => $cid, 'uid' => local_user()]);
}
if (!DBM::is_result($contact)) {
$contact = null;
if ($cid) {
- $contact = dba::selectFirst('contact', [], ['id' => $cid, 'uid' => local_user()]);
+ $contact = DBA::selectFirst('contact', [], ['id' => $cid, 'uid' => local_user()]);
}
if (!DBM::is_result($contact)) {
use Friendica\App;
use Friendica\Core\L10n;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\User;
$parent_password = defaults($_POST, 'parent_password', '');
if ($parent_uid != 0) {
- $user = dba::selectFirst('user', ['nickname'], ['uid' => $parent_uid]);
+ $user = DBA::selectFirst('user', ['nickname'], ['uid' => $parent_uid]);
if (!DBM::is_result($user)) {
notice(L10n::t('Parent user not found.') . EOL);
return;
}
}
- dba::update('user', ['parent-uid' => $parent_uid], ['uid' => local_user()]);
+ DBA::update('user', ['parent-uid' => $parent_uid], ['uid' => local_user()]);
}
function delegate_content(App $a)
$user_id = $a->argv[2];
- $user = dba::selectFirst('user', ['nickname'], ['uid' => $user_id]);
+ $user = DBA::selectFirst('user', ['nickname'], ['uid' => $user_id]);
if (DBM::is_result($user)) {
$condition = [
'uid' => local_user(),
'nurl' => normalise_link(System::baseUrl() . '/profile/' . $user['nickname'])
];
- if (dba::exists('contact', $condition)) {
- dba::insert('manage', ['uid' => $user_id, 'mid' => local_user()]);
+ if (DBA::exists('contact', $condition)) {
+ DBA::insert('manage', ['uid' => $user_id, 'mid' => local_user()]);
}
}
goaway(System::baseUrl() . '/delegate');
goaway(System::baseUrl() . '/delegate');
}
- dba::delete('manage', ['uid' => $a->argv[2], 'mid' => local_user()]);
+ DBA::delete('manage', ['uid' => $a->argv[2], 'mid' => local_user()]);
goaway(System::baseUrl() . '/delegate');
}
settings_init($a);
- $user = dba::selectFirst('user', ['parent-uid', 'email'], ['uid' => local_user()]);
+ $user = DBA::selectFirst('user', ['parent-uid', 'email'], ['uid' => local_user()]);
$parent_user = null;
if (DBM::is_result($user)) {
- if (!dba::exists('user', ['parent-uid' => local_user()])) {
+ if (!DBA::exists('user', ['parent-uid' => local_user()])) {
$parent_uid = $user['parent-uid'];
$parents = [0 => L10n::t('No parent user')];
$fields = ['uid', 'username', 'nickname'];
$condition = ['email' => $user['email'], 'verified' => true, 'blocked' => false, 'parent-uid' => 0];
- $parent_users = dba::select('user', $fields, $condition);
- while ($parent = dba::fetch($parent_users)) {
+ $parent_users = DBA::select('user', $fields, $condition);
+ while ($parent = DBA::fetch($parent_users)) {
if ($parent['uid'] != local_user()) {
$parents[$parent['uid']] = sprintf('%s (%s)', $parent['username'], $parent['nickname']);
}
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Group;
return;
}
- $user = dba::selectFirst('user', [], ['uid' => $uid]);
+ $user = DBA::selectFirst('user', [], ['uid' => $uid]);
if (!DBM::is_result($user)) {
notice(L10n::t('Profile not found.') . EOL);
return;
}
if (($status == 0) && $intro_id) {
- $intro = dba::selectFirst('intro', ['note'], ['id' => $intro_id]);
+ $intro = DBA::selectFirst('intro', ['note'], ['id' => $intro_id]);
if (DBM::is_result($intro)) {
- dba::update('contact', ['reason' => $intro['note']], ['id' => $contact_id]);
+ DBA::update('contact', ['reason' => $intro['note']], ['id' => $contact_id]);
}
// Success. Delete the notification.
- dba::delete('intro', ['id' => $intro_id]);
+ DBA::delete('intro', ['id' => $intro_id]);
}
if ($status != 0) {
}
}
- dba::delete('intro', ['id' => $intro_id]);
+ DBA::delete('intro', ['id' => $intro_id]);
$r = q("UPDATE `contact` SET `name-date` = '%s',
`uri-date` = '%s',
}
// reload contact info
- $contact = dba::selectFirst('contact', [], ['id' => $contact_id]);
+ $contact = DBA::selectFirst('contact', [], ['id' => $contact_id]);
if ((isset($new_relation) && $new_relation == CONTACT_IS_FRIEND)) {
if (DBM::is_result($contact) && ($contact['network'] === NETWORK_DIASPORA)) {
$ret = Diaspora::sendShare($user, $contact);
}
// Find our user's account
- $user = dba::selectFirst('user', [], ['nickname' => $node]);
+ $user = DBA::selectFirst('user', [], ['nickname' => $node]);
if (!DBM::is_result($user)) {
$message = L10n::t('No user record found for \'%s\' ', $node);
System::xmlExit(3, $message); // failure
// NOTREACHED
}
- $contact = dba::selectFirst('contact', [], ['url' => $decrypted_source_url, 'uid' => $local_uid]);
+ $contact = DBA::selectFirst('contact', [], ['url' => $decrypted_source_url, 'uid' => $local_uid]);
if (!DBM::is_result($contact)) {
if (strstr($decrypted_source_url, 'http:')) {
$newurl = str_replace('http:', 'https:', $decrypted_source_url);
$newurl = str_replace('https:', 'http:', $decrypted_source_url);
}
- $contact = dba::selectFirst('contact', [], ['url' => $newurl, 'uid' => $local_uid]);
+ $contact = DBA::selectFirst('contact', [], ['url' => $newurl, 'uid' => $local_uid]);
if (!DBM::is_result($contact)) {
// this is either a bogus confirmation (?) or we deleted the original introduction.
$message = L10n::t('Contact record was not found for you on our site.');
$dfrn_pubkey = $public_key;
}
- if (dba::exists('contact', ['dfrn-id' => $decrypted_dfrn_id])) {
+ if (DBA::exists('contact', ['dfrn-id' => $decrypted_dfrn_id])) {
$message = L10n::t('The ID provided by your system is a duplicate on our system. It should work if you try again.');
System::xmlExit(1, $message); // Birthday paradox - duplicate dfrn-id
// NOTREACHED
}
// We're good but now we have to scrape the profile photo and send notifications.
- $contact = dba::selectFirst('contact', ['photo'], ['id' => $dfrn_record]);
+ $contact = DBA::selectFirst('contact', ['photo'], ['id' => $dfrn_record]);
if (DBM::is_result($contact)) {
$photo = $contact['photo'];
} else {
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Protocol\DFRN;
if (is_object($data)) {
$nick = defaults($a->argv, 1, '');
- $user = dba::selectFirst('user', [], ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false]);
+ $user = DBA::selectFirst('user', [], ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false]);
if (!DBM::is_result($user)) {
System::httpExit(500);
}
$dfrn_id = substr($dfrn_id, 2);
}
- if (!dba::exists('challenge', ['dfrn-id' => $dfrn_id, 'challenge' => $challenge])) {
+ if (!DBA::exists('challenge', ['dfrn-id' => $dfrn_id, 'challenge' => $challenge])) {
logger('could not match challenge to dfrn_id ' . $dfrn_id . ' challenge=' . $challenge);
System::xmlExit(3, 'Could not match challenge');
}
- dba::delete('challenge', ['dfrn-id' => $dfrn_id, 'challenge' => $challenge]);
+ DBA::delete('challenge', ['dfrn-id' => $dfrn_id, 'challenge' => $challenge]);
// find the local user who owns this relationship.
if ((($writable != (-1)) && ($writable != $importer['writable'])) || ($importer['forum'] != $forum) || ($importer['prv'] != $prv)) {
$fields = ['writable' => ($writable == (-1)) ? $importer['writable'] : $writable,
'forum' => $forum, 'prv' => $prv];
- dba::update('contact', $fields, ['id' => $importer['id']]);
+ DBA::update('contact', $fields, ['id' => $importer['id']]);
if ($writable != (-1)) {
$importer['writable'] = $writable;
}
// We now have some contact, so we fetch it
- $importer = dba::fetch_first("SELECT *, `name` as `senderName`
+ $importer = DBA::fetch_first("SELECT *, `name` as `senderName`
FROM `contact`
WHERE NOT `blocked` AND `id` = ? LIMIT 1",
$contact['id']);
}
// We now have some contact, so we fetch it
- $importer = dba::fetch_first("SELECT *, `name` as `senderName`
+ $importer = DBA::fetch_first("SELECT *, `name` as `senderName`
FROM `contact`
WHERE NOT `blocked` AND `id` = ? LIMIT 1",
$cid);
$status = 0;
- dba::delete('challenge', ["`expire` < ?", time()]);
+ DBA::delete('challenge', ["`expire` < ?", time()]);
$fields = ['challenge' => $hash, 'dfrn-id' => $dfrn_id, 'expire' => time() + 90,
'type' => $type, 'last_update' => $last_update];
- dba::insert('challenge', $fields);
+ DBA::insert('challenge', $fields);
logger('challenge=' . $hash, LOGGER_DATA);
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Module\Login;
use Friendica\Protocol\DFRN;
if ($type === 'profile-check' && $dfrn_version < 2.2) {
if ((strlen($challenge)) && (strlen($sec))) {
- dba::delete('profile_check', ["`expire` < ?", time()]);
+ DBA::delete('profile_check', ["`expire` < ?", time()]);
$r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1",
dbesc($sec)
);
break;
}
- dba::delete('profile_check', ["`expire` < ?", time()]);
+ DBA::delete('profile_check', ["`expire` < ?", time()]);
$r = q("SELECT * FROM `profile_check` WHERE `dfrn_id` = '%s' ORDER BY `expire` DESC",
dbesc($dfrn_id));
if (DBM::is_result($r)) {
if (strlen($challenge) && strlen($sec)) {
logger('dfrn_poll: POST: profile-check');
- dba::delete('profile_check', ["`expire` < ?", time()]);
+ DBA::delete('profile_check', ["`expire` < ?", time()]);
$r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1",
dbesc($sec)
);
$type = $r[0]['type'];
$last_update = $r[0]['last_update'];
- dba::delete('challenge', ['dfrn-id' => $dfrn_id, 'challenge' => $challenge]);
+ DBA::delete('challenge', ['dfrn-id' => $dfrn_id, 'challenge' => $challenge]);
$sql_extra = '';
switch ($direction) {
$status = 0;
- dba::delete('challenge', ["`expire` < ?", time()]);
+ DBA::delete('challenge', ["`expire` < ?", time()]);
if ($type !== 'profile') {
$r = q("INSERT INTO `challenge` ( `challenge`, `dfrn-id`, `expire` , `type`, `last_update` )
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Group;
if (DBM::is_result($r)) {
foreach ($r as $rr) {
if (!$rr['rel']) {
- dba::delete('contact', ['id' => $rr['cid'], 'self' => false]);
+ DBA::delete('contact', ['id' => $rr['cid'], 'self' => false]);
}
- dba::delete('intro', ['id' => $rr['iid']]);
+ DBA::delete('intro', ['id' => $rr['iid']]);
}
}
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
$publish = (Config::get('system', 'publish_all') ? '' : " AND `publish` = 1 " );
- $cnt = dba::fetch_first("SELECT COUNT(*) AS `total` FROM `profile`
+ $cnt = DBA::fetch_first("SELECT COUNT(*) AS `total` FROM `profile`
LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
WHERE `is-default` $publish AND NOT `user`.`blocked` AND NOT `user`.`account_removed` $sql_extra");
if (DBM::is_result($cnt)) {
$limit = intval($a->pager['start'])."," . intval($a->pager['itemspage']);
- $r = dba::p("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` , `user`.`page-flags`,
+ $r = DBA::p("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` , `user`.`page-flags`,
`contact`.`addr`, `contact`.`url` AS profile_url FROM `profile`
LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
LEFT JOIN `contact` ON `contact`.`uid` = `user`.`uid`
$photo = 'photo';
}
- while ($rr = dba::fetch($r)) {
+ while ($rr = DBA::fetch($r)) {
$itemurl= '';
$itemurl = (($rr['addr'] != "") ? $rr['addr'] : $rr['profile_url']);
$entries[] = $arr['entry'];
}
- dba::close($r);
+ DBA::close($r);
$tpl = get_markup_template('directory_header.tpl');
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Core\Worker;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
if ($jj->cid > 0) {
$connlnk = "";
$conntxt = "";
- $contact = dba::selectFirst('contact', [], ['id' => $jj->cid]);
+ $contact = DBA::selectFirst('contact', [], ['id' => $jj->cid]);
if (DBM::is_result($contact)) {
$photo_menu = Contact::photoMenu($contact);
$details = _contact_detail_for_template($contact);
use Friendica\Core\L10n;
use Friendica\Core\Protocol;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Group;
$nickname = str_replace(normalise_link(System::baseUrl())."/profile/", "", normalise_link($profiledata["url"]));
if (($nickname != $a->user["nickname"])) {
- $profile = dba::fetch_first("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile`
+ $profile = DBA::fetch_first("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile`
INNER JOIN `contact` on `contact`.`uid` = `profile`.`uid` INNER JOIN `user` ON `profile`.`uid` = `user`.`uid`
WHERE `user`.`nickname` = ? AND `profile`.`is-default` AND `contact`.`self` LIMIT 1",
$nickname
function display_fetchauthor($a, $item)
{
- $author = dba::selectFirst('contact', ['name', 'nick', 'photo', 'network', 'url'], ['id' => $item['author-id']]);
+ $author = DBA::selectFirst('contact', ['name', 'nick', 'photo', 'network', 'url'], ['id' => $item['author-id']]);
$profiledata = [];
$profiledata['uid'] = -1;
}
// We are displaying an "alternate" link if that post was public. See issue 2864
- $is_public = dba::exists('item', ['id' => $item_id, 'private' => [0, 2]]);
+ $is_public = DBA::exists('item', ['id' => $item_id, 'private' => [0, 2]]);
if ($is_public) {
// For the atom feed the nickname doesn't matter at all, we only need the item id.
$alternate = System::baseUrl().'/display/feed-item/'.$item_id.'.atom';
if ($contact_id) {
$groups = Group::getIdsByContactId($contact_id);
- $remote_contact = dba::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $a->profile['uid']]);
+ $remote_contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $a->profile['uid']]);
if (DBM::is_result($remote_contact)) {
$contact = $remote_contact;
$is_remote_contact = true;
}
}
- $page_contact = dba::selectFirst('contact', [], ['self' => true, 'uid' => $a->profile['uid']]);
+ $page_contact = DBA::selectFirst('contact', [], ['self' => true, 'uid' => $a->profile['uid']]);
if (DBM::is_result($page_contact)) {
$a->page_contact = $page_contact;
}
if (local_user() && (local_user() == $a->profile['uid'])) {
$condition = ['parent-uri' => $item_parent_uri, 'uid' => local_user(), 'unseen' => true];
- $unseen = dba::exists('item', $condition);
+ $unseen = DBA::exists('item', $condition);
} else {
$unseen = false;
}
use Friendica\App;
use Friendica\Core\L10n;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Protocol\Feed;
use Friendica\Util\Network;
if (!empty($_REQUEST['url'])) {
$url = $_REQUEST['url'];
- $importer = dba::selectFirst('user', [], ['uid' => local_user()]);
+ $importer = DBA::selectFirst('user', [], ['uid' => local_user()]);
$contact_id = Contact::getIdForURL($url, local_user(), true);
- $contact = dba::selectFirst('contact', [], ['id' => $contact_id]);
+ $contact = DBA::selectFirst('contact', [], ['id' => $contact_id]);
$ret = Network::curl($contact['poll']);
$xml = $ret['body'];
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
$cid = 0;
if (strpos($profileurl, 'redir/') === 0) {
$cid = intval(substr($profileurl, 6));
- $remote_contact = dba::selectFirst('contact', ['nurl'], ['id' => $cid]);
+ $remote_contact = DBA::selectFirst('contact', ['nurl'], ['id' => $cid]);
$profileurl = defaults($remote_contact, 'nurl', '');
}
use Friendica\Core\Install;
use Friendica\Core\L10n;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Util\Temporal;
$phpath = notags(trim($_POST['phpath']));
require_once("include/dba.php");
- if (!dba::connect($dbhost, $dbuser, $dbpass, $dbdata)) {
+ if (!DBA::connect($dbhost, $dbuser, $dbpass, $dbdata)) {
$a->data['db_conn_failed'] = true;
}
$adminmail = notags(trim($_POST['adminmail']));
// connect to db
- dba::connect($dbhost, $dbuser, $dbpass, $dbdata);
+ DBA::connect($dbhost, $dbuser, $dbpass, $dbdata);
Install::install($urlpath, $dbhost, $dbuser, $dbpass, $dbdata, $phpath, $timezone, $language, $adminmail);
$db_return_text .= $txt;
}
- if (dba::$connected) {
+ if (DBA::$connected) {
$r = q("SELECT COUNT(*) as `total` FROM `user`");
if (DBM::is_result($r) && $r[0]['total']) {
$tpl = get_markup_template('install.tpl');
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Core\Worker;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Item;
// Check for multiple posts with the same message id (when the post was created via API)
if (($message_id != '') && ($profile_uid != 0)) {
- if (dba::exists('item', ['uri' => $message_id, 'uid' => $profile_uid])) {
+ if (DBA::exists('item', ['uri' => $message_id, 'uid' => $profile_uid])) {
logger("Message with URI ".$message_id." already exists for user ".$profile_uid, LOGGER_DEBUG);
return;
}
$orig_post = Item::selectFirst(Item::ITEM_FIELDLIST, ['id' => $post_id]);
}
- $user = dba::selectFirst('user', [], ['uid' => $profile_uid]);
+ $user = DBA::selectFirst('user', [], ['uid' => $profile_uid]);
if (!DBM::is_result($user) && !$parent) {
return;
// if using the API, we won't see pubmail_enable - figure out if it should be set
if ($api_source && $profile_uid && $profile_uid == local_user() && !$private) {
if (function_exists('imap_open') && !Config::get('system', 'imap_disabled')) {
- $pubmail_enabled = dba::exists('mailacct', ["`uid` = ? AND `server` != ? AND `pubmail`", local_user(), '']);
+ $pubmail_enabled = DBA::exists('mailacct', ["`uid` = ? AND `server` != ? AND `pubmail`", local_user(), '']);
}
}
if (local_user() && ((local_user() == $profile_uid) || $allow_comment)) {
$self = true;
- $author = dba::selectFirst('contact', [], ['uid' => local_user(), 'self' => true]);
+ $author = DBA::selectFirst('contact', [], ['uid' => local_user(), 'self' => true]);
} elseif (remote_user()) {
if (x($_SESSION, 'remote') && is_array($_SESSION['remote'])) {
foreach ($_SESSION['remote'] as $v) {
}
}
if ($contact_id) {
- $author = dba::selectFirst('contact', [], ['id' => $contact_id]);
+ $author = DBA::selectFirst('contact', [], ['id' => $contact_id]);
}
}
if ($profile_uid == local_user() || $allow_comment) {
$contact_record = $author;
} else {
- $contact_record = dba::selectFirst('contact', [], ['uid' => $profile_uid, 'self' => true]);
+ $contact_record = DBA::selectFirst('contact', [], ['uid' => $profile_uid, 'self' => true]);
}
// Look for any tags and linkify them
$condition = ['allow_cid' => $srch, 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '',
'resource-id' => $image_uri, 'uid' => $profile_uid];
- if (!dba::exists('photo', $condition)) {
+ if (!DBA::exists('photo', $condition)) {
continue;
}
$fields = ['allow_cid' => $str_contact_allow, 'allow_gid' => $str_group_allow,
'deny_cid' => $str_contact_deny, 'deny_gid' => $str_group_deny];
$condition = ['resource-id' => $image_uri, 'uid' => $profile_uid, 'album' => L10n::t('Wall Photos')];
- dba::update('photo', $fields, $condition);
+ DBA::update('photo', $fields, $condition);
}
}
}
$condition = ['allow_cid' => $srch, 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '',
'id' => $attach];
- if (!dba::exists('attach', $condition)) {
+ if (!DBA::exists('attach', $condition)) {
continue;
}
$fields = ['allow_cid' => $str_contact_allow, 'allow_gid' => $str_group_allow,
'deny_cid' => $str_contact_deny, 'deny_gid' => $str_group_deny];
$condition = ['id' => $attach];
- dba::update('attach', $fields, $condition);
+ DBA::update('attach', $fields, $condition);
}
}
}
if (preg_match_all('/(\[attachment\]([0-9]+)\[\/attachment\])/',$body,$match)) {
foreach ($match[2] as $mtch) {
$fields = ['id', 'filename', 'filesize', 'filetype'];
- $attachment = dba::selectFirst('attach', $fields, ['id' => $mtch]);
+ $attachment = DBA::selectFirst('attach', $fields, ['id' => $mtch]);
if (DBM::is_result($attachment)) {
if (strlen($attachments)) {
$attachments .= ',';
// This field is for storing the raw conversation data
$datarray['protocol'] = PROTOCOL_DFRN;
- $conversation = dba::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $datarray['parent-uri']]);
+ $conversation = DBA::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $datarray['parent-uri']]);
if (DBM::is_result($conversation)) {
if ($conversation['conversation-uri'] != '') {
$datarray['conversation-uri'] = $conversation['conversation-uri'];
if (strrpos($name, '+')) {
// Is it in format @nick+number?
$tagcid = intval(substr($name, strrpos($name, '+') + 1));
- $contact = dba::selectFirst('contact', $fields, ['id' => $tagcid, 'uid' => $profile_uid]);
+ $contact = DBA::selectFirst('contact', $fields, ['id' => $tagcid, 'uid' => $profile_uid]);
}
// select someone by nick or attag in the current network
if (!DBM::is_result($contact) && ($network != "")) {
$condition = ["(`nick` = ? OR `attag` = ?) AND `network` = ? AND `uid` = ?",
$name, $name, $network, $profile_uid];
- $contact = dba::selectFirst('contact', $fields, $condition);
+ $contact = DBA::selectFirst('contact', $fields, $condition);
}
//select someone by name in the current network
if (!DBM::is_result($contact) && ($network != "")) {
$condition = ['name' => $name, 'network' => $network, 'uid' => $profile_uid];
- $contact = dba::selectFirst('contact', $fields, $condition);
+ $contact = DBA::selectFirst('contact', $fields, $condition);
}
// select someone by nick or attag in any network
if (!DBM::is_result($contact)) {
$condition = ["(`nick` = ? OR `attag` = ?) AND `uid` = ?", $name, $name, $profile_uid];
- $contact = dba::selectFirst('contact', $fields, $condition);
+ $contact = DBA::selectFirst('contact', $fields, $condition);
}
// select someone by name in any network
if (!DBM::is_result($contact)) {
$condition = ['name' => $name, 'uid' => $profile_uid];
- $contact = dba::selectFirst('contact', $fields, $condition);
+ $contact = DBA::selectFirst('contact', $fields, $condition);
}
}
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\User;
use Friendica\Util\DateTimeFormat;
}
$condition = ['(`email` = ? OR `nickname` = ?) AND `verified` = 1 AND `blocked` = 0', $loginame, $loginame];
- $user = dba::selectFirst('user', ['uid', 'username', 'email'], $condition);
+ $user = DBA::selectFirst('user', ['uid', 'username', 'email'], $condition);
if (!DBM::is_result($user)) {
notice(L10n::t('No valid account found.') . EOL);
goaway(System::baseUrl());
'pwdreset' => $pwdreset_token,
'pwdreset_time' => DateTimeFormat::utcNow()
];
- $result = dba::update('user', $fields, ['uid' => $user['uid']]);
+ $result = DBA::update('user', $fields, ['uid' => $user['uid']]);
if ($result) {
info(L10n::t('Password reset request issued. Check your email.') . EOL);
}
if ($a->argc > 1) {
$pwdreset_token = $a->argv[1];
- $user = dba::selectFirst('user', ['uid', 'username', 'email', 'pwdreset_time'], ['pwdreset' => $pwdreset_token]);
+ $user = DBA::selectFirst('user', ['uid', 'username', 'email', 'pwdreset_time'], ['pwdreset' => $pwdreset_token]);
if (!DBM::is_result($user)) {
notice(L10n::t("Request could not be verified. \x28You may have previously submitted it.\x29 Password reset failed."));
'pwdreset' => null,
'pwdreset_time' => null
];
- dba::update('user', $fields, ['uid' => $user['uid']]);
+ DBA::update('user', $fields, ['uid' => $user['uid']]);
notice(L10n::t('Request has expired, please make a new one.'));
use Friendica\Core\ACL;
use Friendica\Core\L10n;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Mail;
$cmd = $a->argv[1];
if ($cmd === 'drop') {
- if (dba::delete('mail', ['id' => $a->argv[2], 'uid' => local_user()])) {
+ if (DBA::delete('mail', ['id' => $a->argv[2], 'uid' => local_user()])) {
info(L10n::t('Message deleted.') . EOL);
}
$parent = $r[0]['parent-uri'];
$convid = $r[0]['convid'];
- if (dba::delete('mail', ['parent-uri' => $parent, 'uid' => local_user()])) {
+ if (DBA::delete('mail', ['parent-uri' => $parent, 'uid' => local_user()])) {
info(L10n::t('Conversation removed.') . EOL);
}
}
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Group;
}
if (x($_GET, 'save')) {
- $exists = dba::exists('search', ['uid' => local_user(), 'term' => $search]);
+ $exists = DBA::exists('search', ['uid' => local_user(), 'term' => $search]);
if (!$exists) {
- dba::insert('search', ['uid' => local_user(), 'term' => $search]);
+ DBA::insert('search', ['uid' => local_user(), 'term' => $search]);
}
}
if (x($_GET, 'remove')) {
- dba::delete('search', ['uid' => local_user(), 'term' => $search]);
+ DBA::delete('search', ['uid' => local_user(), 'term' => $search]);
}
$is_a_date_query = false;
$o = '';
- $terms = dba::select('search', ['id', 'term'], ['uid' => local_user()]);
+ $terms = DBA::select('search', ['id', 'term'], ['uid' => local_user()]);
$saved = [];
- while ($rr = dba::fetch($terms)) {
+ while ($rr = DBA::fetch($terms)) {
$saved[] = [
'id' => $rr['id'],
'term' => $rr['term'],
return;
}
- $unseen = dba::exists('item', $condition);
+ $unseen = DBA::exists('item', $condition);
if ($unseen) {
$r = Item::update(['unseen' => false], $condition);
$condition = ["`term` = ? AND `otype` = ? AND `type` = ? AND `uid` = ?",
$file, TERM_OBJ_POST, TERM_FILE, local_user()];
$params = ['order' => ['tid' => true], 'limit' => [$a->pager['start'], $a->pager['itemspage']]];
- $result = dba::select('term', ['oid'], $condition);
+ $result = DBA::select('term', ['oid'], $condition);
$posts = [];
- while ($term = dba::fetch($result)) {
+ while ($term = DBA::fetch($result)) {
$posts[] = $term['oid'];
}
- dba::close($terms);
+ DBA::close($terms);
$condition = ['uid' => local_user(), 'id' => $posts];
} else {
}
if ($nets) {
- $r = dba::select('contact', ['id'], ['uid' => local_user(), 'network' => $nets], ['self' => false]);
+ $r = DBA::select('contact', ['id'], ['uid' => local_user(), 'network' => $nets], ['self' => false]);
$str = '';
- while ($rr = dba::fetch($r)) {
+ while ($rr = DBA::fetch($r)) {
$str .= '<' . $rr['id'] . '>';
}
if (strlen($str)) {
if ($cid) {
// If $cid belongs to a communitity forum or a privat goup,.add a mention to the status editor
$condition = ["`id` = ? AND (`forum` OR `prv`)", $cid];
- $contact = dba::selectFirst('contact', ['addr', 'nick'], $condition);
+ $contact = DBA::selectFirst('contact', ['addr', 'nick'], $condition);
if (DBM::is_result($contact)) {
if ($contact['addr'] != '') {
$content = '!' . $contact['addr'];
$sql_tag_nets = (($nets) ? sprintf(" AND `item`.`network` = '%s' ", dbesc($nets)) : '');
if ($gid) {
- $group = dba::selectFirst('group', ['name'], ['id' => $gid, 'uid' => local_user()]);
+ $group = DBA::selectFirst('group', ['name'], ['id' => $gid, 'uid' => local_user()]);
if (!DBM::is_result($group)) {
if ($update) {
killme();
$contact_str_self = '';
$contact_str = implode(',', $contacts);
- $self = dba::selectFirst('contact', ['id'], ['uid' => local_user(), 'self' => true]);
+ $self = DBA::selectFirst('contact', ['id'], ['uid' => local_user(), 'self' => true]);
if (DBM::is_result($self)) {
$contact_str_self = $self['id'];
}
$fields = ['id', 'name', 'network', 'writable', 'nurl',
'forum', 'prv', 'contact-type', 'addr', 'thumb', 'location'];
$condition = ["`id` = ? AND (NOT `blocked` OR `pending`)", $cid];
- $contact = dba::selectFirst('contact', $fields, $condition);
+ $contact = DBA::selectFirst('contact', $fields, $condition);
if (DBM::is_result($contact)) {
$sql_extra = " AND " . $sql_table . ".`contact-id` = " . intval($cid);
$top_limit = DateTimeFormat::utcNow();
}
- $items = dba::p("SELECT `item`.`parent-uri` AS `uri`, 0 AS `item_id`, `item`.$ordering AS `order_date`, `author`.`url` AS `author-link` FROM `item`
+ $items = DBA::p("SELECT `item`.`parent-uri` AS `uri`, 0 AS `item_id`, `item`.$ordering AS `order_date`, `author`.`url` AS `author-link` FROM `item`
STRAIGHT_JOIN (SELECT `oid` FROM `term` WHERE `term` IN
(SELECT SUBSTR(`term`, 2) FROM `search` WHERE `uid` = ? AND `term` LIKE '#%') AND `otype` = ? AND `type` = ? AND `uid` = 0) AS `term`
ON `item`.`id` = `term`.`oid`
local_user(), TERM_OBJ_POST, TERM_HASHTAG,
$top_limit, $bottom_limit);
- $data = dba::inArray($items);
+ $data = DBA::inArray($items);
if (count($data) > 0) {
$tag_top_limit = current($data)['order_date'];
// Don't show hash tag posts from blocked or ignored contacts
$condition = ["`nurl` = ? AND `uid` = ? AND (`blocked` OR `readonly`)",
normalise_link($item['author-link']), local_user()];
- if (!dba::exists('contact', $condition)) {
+ if (!DBA::exists('contact', $condition)) {
$s[$item['uri']] = $item;
}
}
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Util\Network;
require_once 'include/dba.php';
logger('total_users: ' . $total_users . '/' . $active_users_halfyear. '/' . $active_users_monthly, LOGGER_DEBUG);
}
- $local_posts = dba::count('thread', ["`wall` AND NOT `deleted` AND `uid` != 0"]);
+ $local_posts = DBA::count('thread', ["`wall` AND NOT `deleted` AND `uid` != 0"]);
Config::set('nodeinfo', 'local_posts', $local_posts);
logger('local_posts: ' . $local_posts, LOGGER_DEBUG);
- $local_comments = dba::count('item', ["`origin` AND `id` != `parent` AND NOT `deleted` AND `uid` != 0"]);
+ $local_comments = DBA::count('item', ["`origin` AND `id` != `parent` AND NOT `deleted` AND `uid` != 0"]);
Config::set('nodeinfo', 'local_comments', $local_comments);
logger('local_comments: ' . $local_comments, LOGGER_DEBUG);
use Friendica\App;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Profile;
$keywords = str_replace(['#',',',' ',',,'], ['',' ',',',','], $keywords);
$keywords = explode(',', $keywords);
- $contactPhoto = dba::selectFirst('contact', ['photo'], ['self' => true, 'uid' => $a->profile['uid']]);
+ $contactPhoto = DBA::selectFirst('contact', ['photo'], ['self' => true, 'uid' => $a->profile['uid']]);
$json_info['fn'] = $a->profile['name'];
$json_info['photo'] = $contactPhoto["photo"];
// We display the last activity (post or login), reduced to year and week number
$last_active = 0;
$condition = ['uid' => $a->profile['uid'], 'self' => true];
- $contact = dba::selectFirst('contact', ['last-item'], $condition);
+ $contact = DBA::selectFirst('contact', ['last-item'], $condition);
if (DBM::is_result($contact)) {
$last_active = strtotime($contact['last-item']);
}
$condition = ['uid' => $a->profile['uid']];
- $user = dba::selectFirst('user', ['login_date'], $condition);
+ $user = DBA::selectFirst('user', ['login_date'], $condition);
if (DBM::is_result($user)) {
if ($last_active < strtotime($user['login_date'])) {
$last_active = strtotime($user['login_date']);
use Friendica\App;
use Friendica\Content\Nav;
use Friendica\Core\L10n;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Item;
use Friendica\Model\Profile;
while ($rr = Item::fetch($r)) {
$parents_arr[] = $rr['id'];
}
- dba::close($r);
+ DBA::close($r);
$condition = ['uid' => local_user(), 'parent' => $parents_arr];
$result = Item::selectForUser(local_user(), [], $condition);
use Friendica\Core\L10n;
use Friendica\Core\NotificationsManager;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
function notifications_post(App $a)
}
if ($request_id) {
- $intro = dba::selectFirst('intro', ['id', 'contact-id', 'fid'], ['id' => $request_id, 'uid' => local_user()]);
+ $intro = DBA::selectFirst('intro', ['id', 'contact-id', 'fid'], ['id' => $request_id, 'uid' => local_user()]);
if (DBM::is_result($intro)) {
$intro_id = $intro['id'];
$fid = $intro['fid'];
if ($_POST['submit'] == L10n::t('Discard')) {
- dba::delete('intro', ['id' => $intro_id]);
+ DBA::delete('intro', ['id' => $intro_id]);
if (!$fid) {
// The check for blocked and pending is in case the friendship was already approved
// and we just want to get rid of the now pointless notification
$condition = ['id' => $contact_id, 'uid' => local_user(),
'self' => false, 'blocked' => true, 'pending' => true];
- dba::delete('contact', $condition);
+ DBA::delete('contact', $condition);
}
goaway('notifications/intros');
}
if ($_POST['submit'] == L10n::t('Ignore')) {
- dba::update('intro', ['ignore' => true], ['id' => $intro_id]);
+ DBA::update('intro', ['ignore' => true], ['id' => $intro_id]);
goaway('notifications/intros');
}
}
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Core\Worker;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Group;
$link_item = Item::selectFirst([], ['id' => $linked_items[0]['id']]);
$condition = ["`parent` = ? AND `parent` != `id`", $link_item['parent']];
- $a->set_pager_total(dba::count('item', $condition));
+ $a->set_pager_total(DBA::count('item', $condition));
$params = ['order' => ['id'], 'limit' => [$a->pager['start'], $a->pager['itemspage']]];
$result = Item::selectForUser($link_item['uid'], [], $condition, $params);
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Group;
use Friendica\Model\Item;
if ($is_owner) {
- $unseen = dba::exists('item', ['wall' => true, 'unseen' => true, 'uid' => local_user()]);
+ $unseen = DBA::exists('item', ['wall' => true, 'unseen' => true, 'uid' => local_user()]);
if ($unseen) {
$r = Item::update(['unseen' => false],
['wall' => true, 'unseen' => true, 'uid' => local_user()]);
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Core\Worker;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
$r1[0]['net-publish'] = 0;
$r1[0]['profile-name'] = dbesc($name);
- dba::insert('profile', $r1[0]);
+ DBA::insert('profile', $r1[0]);
$r3 = q("SELECT `id` FROM `profile` WHERE `uid` = %d AND `profile-name` = '%s' LIMIT 1",
intval(local_user()),
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Photo;
use Friendica\Object\Image;
$valid = true;
$photo = null;
if (!$direct_cache && ($cachefile == '')) {
- $photo = dba::selectFirst('photo', ['data', 'desc'], ['resource-id' => $urlhash]);
+ $photo = DBA::selectFirst('photo', ['data', 'desc'], ['resource-id' => $urlhash]);
if (DBM::is_result($photo)) {
$img_str = $photo['data'];
$mime = $photo['desc'];
'filename' => basename($_REQUEST['url']), 'type' => '', 'album' => '', 'height' => imagesy($image), 'width' => imagesx($image),
'datasize' => 0, 'data' => $img_str, 'scale' => 100, 'profile' => 0,
'allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '', 'desc' => $mime];
- dba::insert('photo', $fields);
+ DBA::insert('photo', $fields);
} else {
$Image = new Image($img_str, $mime);
if ($Image->isValid() && !$direct_cache && ($cachefile == '')) {
<?php
use Friendica\App;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Protocol\OStatus;
$subscribe = (($hub_mode === 'subscribe') ? 1 : 0);
- $owner = dba::selectFirst('user', ['uid'], ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false]);
+ $owner = DBA::selectFirst('user', ['uid'], ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false]);
if (!DBM::is_result($owner)) {
logger('Local account not found: ' . $nick);
hub_return(false, '');
$condition['hub-verify'] = $hub_verify;
}
- $contact = dba::selectFirst('contact', ['id', 'poll'], $condition);
+ $contact = DBA::selectFirst('contact', ['id', 'poll'], $condition);
if (!DBM::is_result($contact)) {
logger('Contact ' . $contact_id . ' not found.');
hub_return(false, '');
}
if (!empty($hub_mode)) {
- dba::update('contact', ['subhub' => $subscribe], ['id' => $contact['id']]);
+ DBA::update('contact', ['subhub' => $subscribe], ['id' => $contact['id']]);
logger($hub_mode . ' success for contact ' . $contact_id . '.');
}
hub_return(true, $hub_challenge);
$nick = (($a->argc > 1) ? notags(trim($a->argv[1])) : '');
$contact_id = (($a->argc > 2) ? intval($a->argv[2]) : 0 );
- $importer = dba::selectFirst('user', [], ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false]);
+ $importer = DBA::selectFirst('user', [], ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false]);
if (!DBM::is_result($importer)) {
hub_post_return();
}
$condition = ['id' => $contact_id, 'uid' => $importer['uid'], 'subhub' => true, 'blocked' => false];
- $contact = dba::selectFirst('contact', [], $condition);
+ $contact = DBA::selectFirst('contact', [], $condition);
if (!DBM::is_result($contact)) {
$author = OStatus::salmonAuthor($xml, $importer);
if (!empty($author['contact-id'])) {
$condition = ['id' => $author['contact-id'], 'uid' => $importer['uid'], 'subhub' => true, 'blocked' => false];
- $contact = dba::selectFirst('contact', [], $condition);
+ $contact = DBA::selectFirst('contact', [], $condition);
logger('No record for ' . $nick .' with contact id ' . $contact_id . ' - using '.$author['contact-id'].' instead.');
}
if (!DBM::is_result($contact)) {
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\PushSubscriber;
use Friendica\Util\Network;
// fetch user from database given the nickname
$condition = ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false];
- $owner = dba::selectFirst('user', ['uid', 'hidewall'], $condition);
+ $owner = DBA::selectFirst('user', ['uid', 'hidewall'], $condition);
if (!DBM::is_result($owner)) {
logger('Local account not found: ' . $nick . ' - topic: ' . $hub_topic . ' - callback: ' . $hub_callback);
System::httpExit(404);
// get corresponding row from contact table
$condition = ['uid' => $owner['uid'], 'blocked' => false,
'pending' => false, 'self' => true];
- $contact = dba::selectFirst('contact', ['poll'], $condition);
+ $contact = DBA::selectFirst('contact', ['poll'], $condition);
if (!DBM::is_result($contact)) {
logger('Self contact for user ' . $owner['uid'] . ' not found.');
System::httpExit(404);
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Protocol\Diaspora;
}
$guid = $a->argv[2];
- $importer = dba::selectFirst('user', [], ['guid' => $guid, 'account_expired' => false, 'account_removed' => false]);
+ $importer = DBA::selectFirst('user', [], ['guid' => $guid, 'account_expired' => false, 'account_removed' => false]);
if (!DBM::is_result($importer)) {
System::httpExit(500);
}
use Friendica\App;
use Friendica\Core\L10n;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
if (!empty($cid)) {
$fields = ['id', 'uid', 'nurl', 'url', 'addr', 'name', 'network', 'poll', 'issued-id', 'dfrn-id', 'duplex'];
- $contact = dba::selectFirst('contact', $fields, ['id' => $cid, 'uid' => [0, local_user()]]);
+ $contact = DBA::selectFirst('contact', $fields, ['id' => $cid, 'uid' => [0, local_user()]]);
if (!DBM::is_result($contact)) {
notice(L10n::t('Contact not found.'));
goaway(System::baseUrl());
if ($contact['uid'] == 0 && local_user()) {
// Let's have a look if there is an established connection
// between the puplic contact we have found and the local user.
- $contact = dba::selectFirst('contact', $fields, ['nurl' => $contact['nurl'], 'uid' => local_user()]);
+ $contact = DBA::selectFirst('contact', $fields, ['nurl' => $contact['nurl'], 'uid' => local_user()]);
if (DBM::is_result($contact)) {
$cid = $contact['id'];
$fields = ['uid' => local_user(), 'cid' => $cid, 'dfrn_id' => $dfrn_id,
'sec' => $sec, 'expire' => time() + 45];
- dba::insert('profile_check', $fields);
+ DBA::insert('profile_check', $fields);
logger('mod_redir: ' . $contact['name'] . ' ' . $sec, LOGGER_DEBUG);
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Core\Worker;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\User;
use Friendica\Module\Login;
intval($register[0]['uid'])
);
- dba::delete('user', ['uid' => $register[0]['uid']]);
- dba::delete('register', ['hash' => $register[0]['hash']]);
+ DBA::delete('user', ['uid' => $register[0]['uid']]);
+ DBA::delete('register', ['hash' => $register[0]['hash']]);
notice(L10n::t('Registration revoked for %s', $user[0]['username']) . EOL);
return true;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\User;
// send email to admins
$admin_mails = explode(",", str_replace(" ", "", Config::get('config', 'admin_email')));
foreach ($admin_mails as $mail) {
- $admin = dba::selectFirst('user', ['uid', 'language', 'email'], ['email' => $mail]);
+ $admin = DBA::selectFirst('user', ['uid', 'language', 'email'], ['email' => $mail]);
if (!DBM::is_result($admin)) {
continue;
}
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Item;
dbesc($search)
);
if (!DBM::is_result($r)) {
- dba::insert('search', ['uid' => local_user(), 'term' => $search]);
+ DBA::insert('search', ['uid' => local_user(), 'term' => $search]);
}
}
if (x($_GET,'remove') && $search) {
- dba::delete('search', ['uid' => local_user(), 'term' => $search]);
+ DBA::delete('search', ['uid' => local_user(), 'term' => $search]);
}
/// @todo Check if there is a case at all that "aside" is prefilled here
local_user(), TERM_OBJ_POST, TERM_HASHTAG, $search];
$params = ['order' => ['created' => true],
'limit' => [$a->pager['start'], $a->pager['itemspage']]];
- $terms = dba::select('term', ['oid'], $condition, $params);
+ $terms = DBA::select('term', ['oid'], $condition, $params);
$itemids = [];
- while ($term = dba::fetch($terms)) {
+ while ($term = DBA::fetch($terms)) {
$itemids[] = $term['oid'];
}
- dba::close($terms);
+ DBA::close($terms);
if (!empty($itemids)) {
$params = ['order' => ['id' => true]];
use Friendica\Core\System;
use Friendica\Core\Theme;
use Friendica\Core\Worker;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth');
$key = $_POST['remove'];
- dba::delete('tokens', ['id' => $key, 'uid' => local_user()]);
+ DBA::delete('tokens', ['id' => $key, 'uid' => local_user()]);
goaway(System::baseUrl(true)."/settings/oauth/");
return;
}
intval(local_user())
);
if (!DBM::is_result($r)) {
- dba::insert('mailacct', ['uid' => local_user()]);
+ DBA::insert('mailacct', ['uid' => local_user()]);
}
if (strlen($mail_pass)) {
$pass = '';
openssl_public_encrypt($mail_pass, $pass, $a->user['pubkey']);
- dba::update('mailacct', ['pass' => bin2hex($pass)], ['uid' => local_user()]);
+ DBA::update('mailacct', ['pass' => bin2hex($pass)], ['uid' => local_user()]);
}
$r = q("UPDATE `mailacct` SET `server` = '%s', `port` = %d, `ssltype` = '%s', `user` = '%s',
`action` = %d, `movetofolder` = '%s',
if (($a->argc > 3) && ($a->argv[2] === 'delete')) {
check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth', 't');
- dba::delete('clients', ['client_id' => $a->argv[3], 'uid' => local_user()]);
+ DBA::delete('clients', ['client_id' => $a->argv[3], 'uid' => local_user()]);
goaway(System::baseUrl(true)."/settings/oauth/");
return;
}
* ACCOUNT SETTINGS
*/
- $profile = dba::selectFirst('profile', [], ['is-default' => true, 'uid' => local_user()]);
+ $profile = DBA::selectFirst('profile', [], ['is-default' => true, 'uid' => local_user()]);
if (!DBM::is_result($profile)) {
notice(L10n::t('Unable to find your profile. Please contact your admin.') . EOL);
return;
use Friendica\Content\Widget;
use Friendica\Core\L10n;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
}
// Now check how the user responded to the confirmation query
if (!$_REQUEST['canceled']) {
- dba::insert('gcign', ['uid' => local_user(), 'gcid' => $_GET['ignore']]);
+ DBA::insert('gcign', ['uid' => local_user(), 'gcid' => $_GET['ignore']]);
}
}
use Friendica\App;
use Friendica\Core\L10n;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
$condition = ["`uid` = ? AND `rel` = ? AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?",
$uid, CONTACT_IS_FRIEND, normalise_link($url),
normalise_link($url), $url, NETWORK_STATUSNET];
- $contact = dba::selectFirst('contact', [], $condition);
+ $contact = DBA::selectFirst('contact', [], $condition);
if (!DBM::is_result($contact)) {
notice(L10n::t("Contact wasn't found or can't be unfollowed."));
Contact::terminateFriendship($r[0], $contact);
}
}
- dba::update('contact', ['rel' => CONTACT_IS_FOLLOWER], ['id' => $contact['id']]);
+ DBA::update('contact', ['rel' => CONTACT_IS_FOLLOWER], ['id' => $contact['id']]);
info(L10n::t('Contact unfollowed').EOL);
goaway(System::baseUrl().'/contacts/'.$contact['id']);
$condition = ["`uid` = ? AND `rel` = ? AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?",
local_user(), CONTACT_IS_FRIEND, normalise_link($url),
normalise_link($url), $url, NETWORK_STATUSNET];
- $contact = dba::selectFirst('contact', ['url', 'network', 'addr', 'name'], $condition);
+ $contact = DBA::selectFirst('contact', ['url', 'network', 'addr', 'name'], $condition);
if (!DBM::is_result($contact)) {
notice(L10n::t("You aren't a friend of this contact.").EOL);
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Mimetype;
'filesize' => $filesize, 'data' => $filedata, 'created' => $created, 'edited' => $created,
'allow_cid' => '<' . $page_owner_cid . '>', 'allow_gid' => '','deny_cid' => '', 'deny_gid' => ''];
- $r = dba::insert('attach', $fields);
+ $r = DBA::insert('attach', $fields);
@unlink($src);
use Friendica\Core\Config;
use Friendica\Core\Worker;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Util\DateTimeFormat;
function worker_init()
$fields = ['executed' => DateTimeFormat::utcNow(), 'pid' => getmypid(), 'done' => false];
$condition = ['id' => $r[0]["id"], 'pid' => 0];
- if (dba::update('workerqueue', $fields, $condition)) {
+ if (DBA::update('workerqueue', $fields, $condition)) {
Worker::execute($r[0]);
}
}
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Protocol\Salmon;
$name = substr($local, 0, strpos($local, '@'));
}
- $user = dba::selectFirst('user', [], ['nickname' => $name]);
+ $user = DBA::selectFirst('user', [], ['nickname' => $name]);
if (!DBM::is_result($user)) {
killme();
}
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
require_once 'boot.php';
$this->mode |= App::MODE_LOCALCONFIGPRESENT;
- if (!dba::connected()) {
+ if (!DBA::connected()) {
return;
}
$this->mode |= App::MODE_DBAVAILABLE;
- if (dba::fetch_first("SHOW TABLES LIKE 'config'") === false) {
+ if (DBA::fetch_first("SHOW TABLES LIKE 'config'") === false) {
return;
}
public function loadDatabase()
{
- if (dba::connected()) {
+ if (DBA::connected()) {
return;
}
$stamp1 = microtime(true);
- dba::connect($db_host, $db_user, $db_pass, $db_data, $charset);
+ DBA::connect($db_host, $db_user, $db_pass, $db_data, $charset);
unset($db_host, $db_user, $db_pass, $db_data, $charset);
$this->save_timestamp($stamp1, 'network');
if ($this->profile_uid && ($this->profile_uid != local_user())) {
// Allow folks to override user themes and always use their own on their own site.
// This works only if the user is on the same server
- $user = dba::selectFirst('user', ['theme'], ['uid' => $this->profile_uid]);
+ $user = DBA::selectFirst('user', ['theme'], ['uid' => $this->profile_uid]);
if (DBM::is_result($user) && !PConfig::get(local_user(), 'system', 'always_my_theme')) {
$page_theme = $user['theme'];
}
use Friendica\Core\Addon;
use Friendica\Core\L10n;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
/**
$o .= "<select id=\"contact-profile-selector\" class=\"form-control\" $disabled name=\"profile-assign\" >\r\n";
- $s = dba::select('profile', ['id', 'profile-name', 'is-default'], ['uid' => $_SESSION['uid']]);
- $r = dba::inArray($s);
+ $s = DBA::select('profile', ['id', 'profile-name', 'is-default'], ['uid' => $_SESSION['uid']]);
+ $r = DBA::inArray($s);
if (DBM::is_result($r)) {
foreach ($r as $rr) {
$networkname = str_replace($search, $replace, $s);
if ((in_array($s, [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS])) && ($profile != "")) {
- $r = dba::fetch_first("SELECT `gserver`.`platform` FROM `gcontact`
+ $r = DBA::fetch_first("SELECT `gserver`.`platform` FROM `gcontact`
INNER JOIN `gserver` ON `gserver`.`nurl` = `gcontact`.`server_url`
WHERE `gcontact`.`nurl` = ? AND `platform` != ''", normalise_link($profile));
use Friendica\Content\Feature;
use Friendica\Core\L10n;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
$select = '(`forum` OR `prv`)';
}
- $contacts = dba::p(
+ $contacts = DBA::p(
"SELECT `contact`.`id`, `contact`.`url`, `contact`.`name`, `contact`.`micro`, `contact`.`thumb`
FROM `contact`
WHERE `network`= 'dfrn' AND $select AND `uid` = ?
return($forumlist);
}
- while ($contact = dba::fetch($contacts)) {
+ while ($contact = DBA::fetch($contacts)) {
$forumlist[] = [
'url' => $contact['url'],
'name' => $contact['name'],
'thumb' => $contact['thumb'],
];
}
- dba::close($contacts);
+ DBA::close($contacts);
return($forumlist);
}
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Profile;
$nav['usermenu'][] = ['notes/', L10n::t('Personal notes'), '', L10n::t('Your personal notes')];
// user info
- $contact = dba::selectFirst('contact', ['micro'], ['uid' => $a->user['uid'], 'self' => true]);
+ $contact = DBA::selectFirst('contact', ['micro'], ['uid' => $a->user['uid'], 'self' => true]);
$userinfo = [
'icon' => (DBM::is_result($contact) ? $a->remove_baseurl($contact['micro']) : 'images/person-48.jpg'),
'name' => $a->user['username'],
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
$a = get_app();
$condition = ['url' => normalise_link($embedurl), 'maxwidth' => $a->videowidth];
- $oembed = dba::selectFirst('oembed', ['content'], $condition);
+ $oembed = DBA::selectFirst('oembed', ['content'], $condition);
if (DBM::is_result($oembed)) {
$txt = $oembed["content"];
} else {
} else { //save in cache
$j = json_decode($txt);
if (!empty($j->type) && $j->type != "error") {
- dba::insert('oembed', [
+ DBA::insert('oembed', [
'url' => normalise_link($embedurl),
'maxwidth' => $a->videowidth,
'content' => $txt,
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
$extra_sql = self::unavailableNetworks();
- $r = dba::p("SELECT DISTINCT(`network`) FROM `contact` WHERE `uid` = ? AND `network` != '' $extra_sql ORDER BY `network`",
+ $r = DBA::p("SELECT DISTINCT(`network`) FROM `contact` WHERE `uid` = ? AND `network` != '' $extra_sql ORDER BY `network`",
local_user()
);
$nets = array();
- while ($rr = dba::fetch($r)) {
+ while ($rr = DBA::fetch($r)) {
/// @TODO If 'network' is not there, this triggers an E_NOTICE
if ($rr['network']) {
$nets[] = array('ref' => $rr['network'], 'name' => ContactSelector::networkToName($rr['network']), 'selected' => (($selected == $rr['network']) ? 'selected' : '' ));
}
}
- dba::close($r);
+ DBA::close($r);
if (count($nets) < 2) {
return '';
if (!$cid) {
if (Profile::getMyURL()) {
- $contact = dba::selectFirst('contact', ['id'],
+ $contact = DBA::selectFirst('contact', ['id'],
['nurl' => normalise_link(Profile::getMyURL()), 'uid' => $profile_uid]);
if (DBM::is_result($contact)) {
$cid = $contact['id'];
} else {
- $gcontact = dba::selectFirst('gcontact', ['id'], ['nurl' => normalise_link(Profile::getMyURL())]);
+ $gcontact = DBA::selectFirst('gcontact', ['id'], ['nurl' => normalise_link(Profile::getMyURL())]);
if (DBM::is_result($gcontact)) {
$zcid = $gcontact['id'];
}
use Friendica\Core\L10n;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
require_once 'include/dba.php';
$o = '';
$r = self::tagadelic($uid, $count, $owner_id, $flags, $type);
if (count($r)) {
- $contact = dba::selectFirst('contact', ['url'], ['uid' => $uid, 'self' => true]);
+ $contact = DBA::selectFirst('contact', ['url'], ['uid' => $uid, 'self' => true]);
$url = System::removedBaseUrl($contact['url']);
foreach ($r as $rr) {
}
// Fetch tags
- $r = dba::p("SELECT `term`, COUNT(`term`) AS `total` FROM `term`
+ $r = DBA::p("SELECT `term`, COUNT(`term`) AS `total` FROM `term`
LEFT JOIN `item` ON `term`.`oid` = `item`.`id`
WHERE `term`.`uid` = ? AND `term`.`type` = ?
AND `term`.`otype` = ?
use Friendica\BaseObject;
use Friendica\Content\Feature;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
$o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"" . $x['size'] . "$\" $tabindex >\r\n";
}
- $stmt = dba::p("SELECT `id`, `name`, `url`, `network` FROM `contact`
+ $stmt = DBA::p("SELECT `id`, `name`, `url`, `network` FROM `contact`
WHERE `uid` = ? AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
$sql_extra
ORDER BY `name` ASC ", intval(local_user())
);
- $contacts = dba::inArray($stmt);
+ $contacts = DBA::inArray($stmt);
$arr = ['contact' => $contacts, 'entry' => $o];
$o .= "<select name=\"$selname\" id=\"$selclass\" class=\"$selclass\" size=\"$size\"$tabindex_attr$hidepreselected>\r\n";
- $stmt = dba::p("SELECT `id`, `name`, `url`, `network` FROM `contact`
+ $stmt = DBA::p("SELECT `id`, `name`, `url`, `network` FROM `contact`
WHERE `uid` = ? AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
$sql_extra
ORDER BY `name` ASC ", intval(local_user())
);
- $contacts = dba::inArray($stmt);
+ $contacts = DBA::inArray($stmt);
$arr = ['contact' => $contacts, 'entry' => $o];
$pubmail_enabled = false;
if (!$imap_disabled) {
- $mailacct = dba::selectFirst('mailacct', ['pubmail'], ['`uid` = ? AND `server` != ""', local_user()]);
+ $mailacct = DBA::selectFirst('mailacct', ['pubmail'], ['`uid` = ? AND `server` != ""', local_user()]);
if (DBM::is_result($mailacct)) {
$mail_enabled = true;
$pubmail_enabled = !empty($mailacct['pubmail']);
namespace Friendica\Core;
use Friendica\App;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
require_once 'include/dba.php';
public static function uninstall($addon)
{
logger("Addons: uninstalling " . $addon);
- dba::delete('addon', ['name' => $addon]);
+ DBA::delete('addon', ['name' => $addon]);
@include_once('addon/' . $addon . '/' . $addon . '.php');
if (function_exists($addon . '_uninstall')) {
$addon_admin = (function_exists($addon."_addon_admin") ? 1 : 0);
- dba::insert('addon', ['name' => $addon, 'installed' => true,
+ DBA::insert('addon', ['name' => $addon, 'installed' => true,
'timestamp' => $t, 'plugin_admin' => $addon_admin]);
// we can add the following with the previous SQL
// This way the system won't fall over dead during the update.
if (file_exists('addon/' . $addon . '/.hidden')) {
- dba::update('addon', ['hidden' => true], ['name' => $addon]);
+ DBA::update('addon', ['hidden' => true], ['name' => $addon]);
}
return true;
} else {
{
$addons = Config::get('system', 'addon');
if (strlen($addons)) {
- $r = dba::select('addon', [], ['installed' => 1]);
+ $r = DBA::select('addon', [], ['installed' => 1]);
if (DBM::is_result($r)) {
- $installed = dba::inArray($r);
+ $installed = DBA::inArray($r);
} else {
$installed = [];
}
$func = $addon . '_install';
$func();
}
- dba::update('addon', ['timestamp' => $t], ['id' => $i['id']]);
+ DBA::update('addon', ['timestamp' => $t], ['id' => $i['id']]);
}
}
}
*/
public static function isEnabled($addon)
{
- return dba::exists('addon', ['installed' => true, 'name' => $addon]);
+ return DBA::exists('addon', ['installed' => true, 'name' => $addon]);
}
public static function registerHook($hook, $file, $function, $priority = 0)
{
$condition = ['hook' => $hook, 'file' => $file, 'function' => $function];
- $exists = dba::exists('hook', $condition);
+ $exists = DBA::exists('hook', $condition);
if ($exists) {
return true;
}
- $r = dba::insert('hook', ['hook' => $hook, 'file' => $file, 'function' => $function, 'priority' => $priority]);
+ $r = DBA::insert('hook', ['hook' => $hook, 'file' => $file, 'function' => $function, 'priority' => $priority]);
return $r;
}
public static function unregisterHook($hook, $file, $function)
{
$condition = ['hook' => $hook, 'file' => $file, 'function' => $function];
- $r = dba::delete('hook', $condition);
+ $r = DBA::delete('hook', $condition);
return $r;
}
{
$a = get_app();
$a->hooks = [];
- $r = dba::select('hook', ['hook', 'file', 'function'], [], ['order' => ['priority' => 'desc', 'file']]);
+ $r = DBA::select('hook', ['hook', 'file', 'function'], [], ['order' => ['priority' => 'desc', 'file']]);
- while ($rr = dba::fetch($r)) {
+ while ($rr = DBA::fetch($r)) {
if (! array_key_exists($rr['hook'], $a->hooks)) {
$a->hooks[$rr['hook']] = [];
}
$a->hooks[$rr['hook']][] = [$rr['file'],$rr['function']];
}
- dba::close($r);
+ DBA::close($r);
}
/**
} else {
// remove orphan hooks
$condition = ['hook' => $name, 'file' => $hook[0], 'function' => $hook[1]];
- dba::delete('hook', $condition, ['cascade' => false]);
+ DBA::delete('hook', $condition, ['cascade' => false]);
}
}
namespace Friendica\Core\Cache;
use Friendica\Core\Cache;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Util\DateTimeFormat;
{
public function get($key)
{
- $cache = dba::selectFirst('cache', ['v'], ['`k` = ? AND `expires` >= ?', $key, DateTimeFormat::utcNow()]);
+ $cache = DBA::selectFirst('cache', ['v'], ['`k` = ? AND `expires` >= ?', $key, DateTimeFormat::utcNow()]);
if (DBM::is_result($cache)) {
$cached = $cache['v'];
'updated' => DateTimeFormat::utcNow()
];
- return dba::update('cache', $fields, ['k' => $key], true);
+ return DBA::update('cache', $fields, ['k' => $key], true);
}
public function delete($key)
{
- return dba::delete('cache', ['k' => $key]);
+ return DBA::delete('cache', ['k' => $key]);
}
public function clear($outdated = true)
{
if ($outdated) {
- return dba::delete('cache', ['`expires` < NOW()']);
+ return DBA::delete('cache', ['`expires` < NOW()']);
} else {
- return dba::delete('cache', ['`k` IS NOT NULL ']);
+ return DBA::delete('cache', ['`k` IS NOT NULL ']);
}
}
}
namespace Friendica\Core\Config;
use Friendica\BaseObject;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
require_once 'include/dba.php';
return;
}
- $configs = dba::select('config', ['v', 'k'], ['cat' => $cat]);
- while ($config = dba::fetch($configs)) {
+ $configs = DBA::select('config', ['v', 'k'], ['cat' => $cat]);
+ while ($config = DBA::fetch($configs)) {
$k = $config['k'];
self::getApp()->setConfigValue($cat, $k, $config['v']);
$this->in_db[$cat][$k] = true;
}
}
- dba::close($configs);
+ DBA::close($configs);
}
public function get($cat, $k, $default_value = null, $refresh = false)
}
}
- $config = dba::selectFirst('config', ['v'], ['cat' => $cat, 'k' => $k]);
+ $config = DBA::selectFirst('config', ['v'], ['cat' => $cat, 'k' => $k]);
if (DBM::is_result($config)) {
// manage array value
$value = (preg_match("|^a:[0-9]+:{.*}$|s", $config['v']) ? unserialize($config['v']) : $config['v']);
// manage array value
$dbvalue = (is_array($value) ? serialize($value) : $dbvalue);
- $result = dba::update('config', ['v' => $dbvalue], ['cat' => $cat, 'k' => $k], true);
+ $result = DBA::update('config', ['v' => $dbvalue], ['cat' => $cat, 'k' => $k], true);
if ($result) {
$this->in_db[$cat][$k] = true;
unset($this->in_db[$cat][$k]);
}
- $result = dba::delete('config', ['cat' => $cat, 'k' => $k]);
+ $result = DBA::delete('config', ['cat' => $cat, 'k' => $k]);
return $result;
}
namespace Friendica\Core\Config;
use Friendica\BaseObject;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
require_once 'include/dba.php';
{
$a = self::getApp();
- $pconfigs = dba::select('pconfig', ['v', 'k'], ['cat' => $cat, 'uid' => $uid]);
+ $pconfigs = DBA::select('pconfig', ['v', 'k'], ['cat' => $cat, 'uid' => $uid]);
if (DBM::is_result($pconfigs)) {
- while ($pconfig = dba::fetch($pconfigs)) {
+ while ($pconfig = DBA::fetch($pconfigs)) {
$k = $pconfig['k'];
self::getApp()->setPConfigValue($uid, $cat, $k, $pconfig['v']);
// Negative caching
$a->config[$uid][$cat] = "!<unset>!";
}
- dba::close($pconfigs);
+ DBA::close($pconfigs);
}
public function get($uid, $cat, $k, $default_value = null, $refresh = false)
}
}
- $pconfig = dba::selectFirst('pconfig', ['v'], ['uid' => $uid, 'cat' => $cat, 'k' => $k]);
+ $pconfig = DBA::selectFirst('pconfig', ['v'], ['uid' => $uid, 'cat' => $cat, 'k' => $k]);
if (DBM::is_result($pconfig)) {
$val = (preg_match("|^a:[0-9]+:{.*}$|s", $pconfig['v']) ? unserialize($pconfig['v']) : $pconfig['v']);
// manage array value
$dbvalue = (is_array($value) ? serialize($value) : $dbvalue);
- $result = dba::update('pconfig', ['v' => $dbvalue], ['uid' => $uid, 'cat' => $cat, 'k' => $k], true);
+ $result = DBA::update('pconfig', ['v' => $dbvalue], ['uid' => $uid, 'cat' => $cat, 'k' => $k], true);
if ($result) {
$this->in_db[$uid][$cat][$k] = true;
unset($this->in_db[$uid][$cat][$k]);
}
- $result = dba::delete('pconfig', ['uid' => $uid, 'cat' => $cat, 'k' => $k]);
+ $result = DBA::delete('pconfig', ['uid' => $uid, 'cat' => $cat, 'k' => $k]);
return $result;
}
use Exception;
use Friendica\BaseObject;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
require_once 'include/dba.php';
return;
}
- $configs = dba::select('config', ['cat', 'v', 'k']);
- while ($config = dba::fetch($configs)) {
+ $configs = DBA::select('config', ['cat', 'v', 'k']);
+ while ($config = DBA::fetch($configs)) {
self::getApp()->setConfigValue($config['cat'], $config['k'], $config['v']);
}
- dba::close($configs);
+ DBA::close($configs);
$this->config_loaded = true;
}
public function get($cat, $k, $default_value = null, $refresh = false)
{
if ($refresh) {
- $config = dba::selectFirst('config', ['v'], ['cat' => $cat, 'k' => $k]);
+ $config = DBA::selectFirst('config', ['v'], ['cat' => $cat, 'k' => $k]);
if (DBM::is_result($config)) {
self::getApp()->setConfigValue($cat, $k, $config['v']);
}
// manage array value
$dbvalue = is_array($value) ? serialize($value) : $value;
- $result = dba::update('config', ['v' => $dbvalue], ['cat' => $cat, 'k' => $k], true);
+ $result = DBA::update('config', ['v' => $dbvalue], ['cat' => $cat, 'k' => $k], true);
if (!$result) {
throw new Exception('Unable to store config value in [' . $cat . '][' . $k . ']');
}
{
self::getApp()->deleteConfigValue($cat, $k);
- $result = dba::delete('config', ['cat' => $cat, 'k' => $k]);
+ $result = DBA::delete('config', ['cat' => $cat, 'k' => $k]);
return $result;
}
use Exception;
use Friendica\BaseObject;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
require_once 'include/dba.php';
return;
}
- $pconfigs = dba::select('pconfig', ['cat', 'v', 'k'], ['uid' => $uid]);
- while ($pconfig = dba::fetch($pconfigs)) {
+ $pconfigs = DBA::select('pconfig', ['cat', 'v', 'k'], ['uid' => $uid]);
+ while ($pconfig = DBA::fetch($pconfigs)) {
self::getApp()->setPConfigValue($uid, $pconfig['cat'], $pconfig['k'], $pconfig['v']);
}
- dba::close($pconfigs);
+ DBA::close($pconfigs);
$this->config_loaded = true;
}
}
if ($refresh) {
- $config = dba::selectFirst('pconfig', ['v'], ['uid' => $uid, 'cat' => $cat, 'k' => $k]);
+ $config = DBA::selectFirst('pconfig', ['v'], ['uid' => $uid, 'cat' => $cat, 'k' => $k]);
if (DBM::is_result($config)) {
self::getApp()->setPConfigValue($uid, $cat, $k, $config['v']);
} else {
// manage array value
$dbvalue = is_array($value) ? serialize($value) : $value;
- $result = dba::update('pconfig', ['v' => $dbvalue], ['uid' => $uid, 'cat' => $cat, 'k' => $k], true);
+ $result = DBA::update('pconfig', ['v' => $dbvalue], ['uid' => $uid, 'cat' => $cat, 'k' => $k], true);
if (!$result) {
throw new Exception('Unable to store config value in [' . $uid . '][' . $cat . '][' . $k . ']');
}
self::getApp()->deletePConfigValue($uid, $cat, $k);
- $result = dba::delete('pconfig', ['uid' => $uid, 'cat' => $cat, 'k' => $k]);
+ $result = DBA::delete('pconfig', ['uid' => $uid, 'cat' => $cat, 'k' => $k]);
return $result;
}
use Friendica\App;
use Friendica\Core\L10n;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use RuntimeException;
/**
}
$nurl = normalise_link($this->getArgument(0));
- if (!dba::exists('contact', ['nurl' => $nurl, 'archive' => false])) {
+ if (!DBA::exists('contact', ['nurl' => $nurl, 'archive' => false])) {
throw new RuntimeException(L10n::t('Could not find any unarchived contact entry for this URL (%s)', $nurl));
}
- if (dba::update('contact', ['archive' => true], ['nurl' => $nurl])) {
+ if (DBA::update('contact', ['archive' => true], ['nurl' => $nurl])) {
$condition = ["`cid` IN (SELECT `id` FROM `contact` WHERE `archive`)"];
- dba::delete('queue', $condition);
+ DBA::delete('queue', $condition);
$this->out(L10n::t('The contact entries have been archived'));
} else {
throw new RuntimeException('The contact archival failed.');
use Friendica\Core\Config;
use Friendica\Core\Install;
use Friendica\Core\Theme;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use RuntimeException;
require_once 'mod/install.php';
);
- if (!dba::connect($db_host, $db_user, $db_pass, $db_data)) {
+ if (!DBA::connect($db_host, $db_user, $db_pass, $db_data)) {
$result['status'] = false;
$result['help'] = 'Failed, please check your MySQL settings and credentials.';
}
namespace Friendica\Core\Console;
use Friendica\Core;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBStructure;
use RuntimeException;
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
}
- if (!dba::connected()) {
+ if (!DBA::connected()) {
throw new RuntimeException('Unable to connect to database');
}
namespace Friendica\Core\Console;
use Friendica\Core\Protocol;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Network\Probe;
use RuntimeException;
}
$nurl = normalise_link($net['url']);
- $contact = dba::selectFirst("contact", ["id"], ["nurl" => $nurl, "uid" => 0]);
+ $contact = DBA::selectFirst("contact", ["id"], ["nurl" => $nurl, "uid" => 0]);
if (DBM::is_result($contact)) {
- dba::update("contact", ["hidden" => true], ["id" => $contact["id"]]);
+ DBA::update("contact", ["hidden" => true], ["id" => $contact["id"]]);
$this->out('NOTICE: The account should be silenced from the global community page');
} else {
throw new RuntimeException('NOTICE: Could not find any entry for this URL (' . $nurl . ')');
use Friendica\Core\Config;
use Friendica\Core\L10n;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\User;
use RuntimeException;
$nick = $this->getArgument(0);
- $user = dba::selectFirst('user', ['uid'], ['nickname' => $nick]);
+ $user = DBA::selectFirst('user', ['uid'], ['nickname' => $nick]);
if (!DBM::is_result($user)) {
throw new RuntimeException(L10n::t('User not found'));
}
namespace Friendica\Core;
use Friendica\BaseObject;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
require_once 'boot.php';
require_once 'include/dba.php';
$a->strings = [];
// load enabled addons strings
- $addons = dba::select('addon', ['name'], ['installed' => true]);
- while ($p = dba::fetch($addons)) {
+ $addons = DBA::select('addon', ['name'], ['installed' => true]);
+ while ($p = DBA::fetch($addons)) {
$name = $p['name'];
if (file_exists("addon/$name/lang/$lang/strings.php")) {
include "addon/$name/lang/$lang/strings.php";
namespace Friendica\Core\Lock;
use Friendica\Core\Cache;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Util\DateTimeFormat;
$start = time();
do {
- dba::lock('locks');
- $lock = dba::selectFirst('locks', ['locked', 'pid'], ['`name` = ? AND `expires` >= ?', $key, DateTimeFormat::utcNow()]);
+ DBA::lock('locks');
+ $lock = DBA::selectFirst('locks', ['locked', 'pid'], ['`name` = ? AND `expires` >= ?', $key, DateTimeFormat::utcNow()]);
if (DBM::is_result($lock)) {
if ($lock['locked']) {
}
}
if (!$lock['locked']) {
- dba::update('locks', ['locked' => true, 'pid' => getmypid(), 'expires' => DateTimeFormat::utc('now + ' . $ttl . 'seconds')], ['name' => $key]);
+ DBA::update('locks', ['locked' => true, 'pid' => getmypid(), 'expires' => DateTimeFormat::utc('now + ' . $ttl . 'seconds')], ['name' => $key]);
$got_lock = true;
}
} else {
- dba::insert('locks', ['name' => $key, 'locked' => true, 'pid' => getmypid(), 'expires' => DateTimeFormat::utc('now + ' . $ttl . 'seconds')]);
+ DBA::insert('locks', ['name' => $key, 'locked' => true, 'pid' => getmypid(), 'expires' => DateTimeFormat::utc('now + ' . $ttl . 'seconds')]);
$got_lock = true;
$this->markAcquire($key);
}
- dba::unlock();
+ DBA::unlock();
if (!$got_lock && ($timeout > 0)) {
usleep(rand(100000, 2000000));
*/
public function releaseLock($key)
{
- dba::delete('locks', ['name' => $key, 'pid' => getmypid()]);
+ DBA::delete('locks', ['name' => $key, 'pid' => getmypid()]);
$this->markRelease($key);
*/
public function releaseAll()
{
- dba::delete('locks', ['pid' => getmypid()]);
+ DBA::delete('locks', ['pid' => getmypid()]);
$this->acquiredLocks = [];
}
*/
public function isLocked($key)
{
- $lock = dba::selectFirst('locks', ['locked'], ['`name` = ? AND `expires` >= ?', $key, DateTimeFormat::utcNow()]);
+ $lock = DBA::selectFirst('locks', ['locked'], ['`name` = ? AND `expires` >= ?', $key, DateTimeFormat::utcNow()]);
if (DBM::is_result($lock)) {
return $lock['locked'] !== false;
use Friendica\BaseObject;
use Friendica\Core\Session;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use SessionHandlerInterface;
return '';
}
- $session = dba::selectFirst('session', ['data'], ['sid' => $session_id]);
+ $session = DBA::selectFirst('session', ['data'], ['sid' => $session_id]);
if (DBM::is_result($session)) {
Session::$exists = true;
return $session['data'];
if (Session::$exists) {
$fields = ['data' => $session_data, 'expire' => $expire];
$condition = ["`sid` = ? AND (`data` != ? OR `expire` != ?)", $session_id, $session_data, $expire];
- dba::update('session', $fields, $condition);
+ DBA::update('session', $fields, $condition);
} else {
$fields = ['sid' => $session_id, 'expire' => $default_expire, 'data' => $session_data];
- dba::insert('session', $fields);
+ DBA::insert('session', $fields);
}
return true;
public function destroy($id)
{
- dba::delete('session', ['sid' => $id]);
+ DBA::delete('session', ['sid' => $id]);
return true;
}
public function gc($maxlifetime)
{
- dba::delete('session', ["`expire` < ?", time()]);
+ DBA::delete('session', ["`expire` < ?", time()]);
return true;
}
}
namespace Friendica\Core;
use Friendica\App;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Model\Photo;
use Friendica\Object\Image;
return 1;
}
- return dba::lastInsertId();
+ return DBA::lastInsertId();
}
/**
// check for username
// check if username matches deleted account
- if (dba::exists('user', ['nickname' => $account['user']['nickname']])
- || dba::exists('userd', ['username' => $account['user']['nickname']])) {
+ if (DBA::exists('user', ['nickname' => $account['user']['nickname']])
+ || DBA::exists('userd', ['username' => $account['user']['nickname']])) {
notice(L10n::t("User '%s' already exists on this server!", $account['user']['nickname']));
return;
}
// import user
$r = self::dbImportAssoc('user', $account['user']);
if ($r === false) {
- logger("uimport:insert user : ERROR : " . dba::errorMessage(), LOGGER_NORMAL);
+ logger("uimport:insert user : ERROR : " . DBA::errorMessage(), LOGGER_NORMAL);
notice(L10n::t("User creation error"));
return;
}
$profile['uid'] = $newuid;
$r = self::dbImportAssoc('profile', $profile);
if ($r === false) {
- logger("uimport:insert profile " . $profile['profile-name'] . " : ERROR : " . dba::errorMessage(), LOGGER_NORMAL);
+ logger("uimport:insert profile " . $profile['profile-name'] . " : ERROR : " . DBA::errorMessage(), LOGGER_NORMAL);
info(L10n::t("User profile creation error"));
- dba::delete('user', ['uid' => $newuid]);
+ DBA::delete('user', ['uid' => $newuid]);
return;
}
}
$contact['uid'] = $newuid;
$r = self::dbImportAssoc('contact', $contact);
if ($r === false) {
- logger("uimport:insert contact " . $contact['nick'] . "," . $contact['network'] . " : ERROR : " . dba::errorMessage(), LOGGER_NORMAL);
+ logger("uimport:insert contact " . $contact['nick'] . "," . $contact['network'] . " : ERROR : " . DBA::errorMessage(), LOGGER_NORMAL);
$errorcount++;
} else {
$contact['newid'] = self::lastInsertId();
$group['uid'] = $newuid;
$r = self::dbImportAssoc('group', $group);
if ($r === false) {
- logger("uimport:insert group " . $group['name'] . " : ERROR : " . dba::errorMessage(), LOGGER_NORMAL);
+ logger("uimport:insert group " . $group['name'] . " : ERROR : " . DBA::errorMessage(), LOGGER_NORMAL);
} else {
$group['newid'] = self::lastInsertId();
}
if ($import == 2) {
$r = self::dbImportAssoc('group_member', $group_member);
if ($r === false) {
- logger("uimport:insert group member " . $group_member['id'] . " : ERROR : " . dba::errorMessage(), LOGGER_NORMAL);
+ logger("uimport:insert group member " . $group_member['id'] . " : ERROR : " . DBA::errorMessage(), LOGGER_NORMAL);
}
}
}
);
if ($r === false) {
- logger("uimport:insert photo " . $photo['resource-id'] . "," . $photo['scale'] . " : ERROR : " . dba::errorMessage(), LOGGER_NORMAL);
+ logger("uimport:insert photo " . $photo['resource-id'] . "," . $photo['scale'] . " : ERROR : " . DBA::errorMessage(), LOGGER_NORMAL);
}
}
$pconfig['uid'] = $newuid;
$r = self::dbImportAssoc('pconfig', $pconfig);
if ($r === false) {
- logger("uimport:insert pconfig " . $pconfig['id'] . " : ERROR : " . dba::errorMessage(), LOGGER_NORMAL);
+ logger("uimport:insert pconfig " . $pconfig['id'] . " : ERROR : " . DBA::errorMessage(), LOGGER_NORMAL);
}
}
*/
namespace Friendica\Core;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Process;
use Friendica\Util\DateTimeFormat;
*/
private static function totalEntries()
{
- return dba::count('workerqueue', ["`executed` <= ? AND NOT `done`", NULL_DATE]);
+ return DBA::count('workerqueue', ["`executed` <= ? AND NOT `done`", NULL_DATE]);
}
/**
private static function highestPriority()
{
$condition = ["`executed` <= ? AND NOT `done`", NULL_DATE];
- $workerqueue = dba::selectFirst('workerqueue', ['priority'], $condition, ['order' => ['priority']]);
+ $workerqueue = DBA::selectFirst('workerqueue', ['priority'], $condition, ['order' => ['priority']]);
if (DBM::is_result($workerqueue)) {
return $workerqueue["priority"];
} else {
private static function processWithPriorityActive($priority)
{
$condition = ["`priority` <= ? AND `executed` > ? AND NOT `done`", $priority, NULL_DATE];
- return dba::exists('workerqueue', $condition);
+ return DBA::exists('workerqueue', $condition);
}
/**
if ($age > 1) {
$stamp = (float)microtime(true);
- dba::update('workerqueue', ['executed' => DateTimeFormat::utcNow()], ['pid' => $mypid, 'done' => false]);
+ DBA::update('workerqueue', ['executed' => DateTimeFormat::utcNow()], ['pid' => $mypid, 'done' => false]);
self::$db_duration += (microtime(true) - $stamp);
}
self::execFunction($queue, $include, $argv, true);
$stamp = (float)microtime(true);
- if (dba::update('workerqueue', ['done' => true], ['id' => $queue["id"]])) {
+ if (DBA::update('workerqueue', ['done' => true], ['id' => $queue["id"]])) {
Config::set('system', 'last_worker_execution', DateTimeFormat::utcNow());
}
self::$db_duration = (microtime(true) - $stamp);
if (!validate_include($include)) {
logger("Include file ".$argv[0]." is not valid!");
- dba::delete('workerqueue', ['id' => $queue["id"]]);
+ DBA::delete('workerqueue', ['id' => $queue["id"]]);
return true;
}
if ($age > 1) {
$stamp = (float)microtime(true);
- dba::update('workerqueue', ['executed' => DateTimeFormat::utcNow()], ['pid' => $mypid, 'done' => false]);
+ DBA::update('workerqueue', ['executed' => DateTimeFormat::utcNow()], ['pid' => $mypid, 'done' => false]);
self::$db_duration += (microtime(true) - $stamp);
}
self::execFunction($queue, $funcname, $argv, false);
$stamp = (float)microtime(true);
- if (dba::update('workerqueue', ['done' => true], ['id' => $queue["id"]])) {
+ if (DBA::update('workerqueue', ['done' => true], ['id' => $queue["id"]])) {
Config::set('system', 'last_worker_execution', DateTimeFormat::utcNow());
}
self::$db_duration = (microtime(true) - $stamp);
} else {
logger("Function ".$funcname." does not exist");
- dba::delete('workerqueue', ['id' => $queue["id"]]);
+ DBA::delete('workerqueue', ['id' => $queue["id"]]);
}
return true;
if ($max == 0) {
// the maximum number of possible user connections can be a system variable
- $r = dba::fetch_first("SHOW VARIABLES WHERE `variable_name` = 'max_user_connections'");
+ $r = DBA::fetch_first("SHOW VARIABLES WHERE `variable_name` = 'max_user_connections'");
if (DBM::is_result($r)) {
$max = $r["Value"];
}
// Or it can be granted. This overrides the system variable
- $r = dba::p('SHOW GRANTS');
- while ($grants = dba::fetch($r)) {
+ $r = DBA::p('SHOW GRANTS');
+ while ($grants = DBA::fetch($r)) {
$grant = array_pop($grants);
if (stristr($grant, "GRANT USAGE ON")) {
if (preg_match("/WITH MAX_USER_CONNECTIONS (\d*)/", $grant, $match)) {
}
}
}
- dba::close($r);
+ DBA::close($r);
}
// If $max is set we will use the processlist to determine the current number of connections
// The processlist only shows entries of the current user
if ($max != 0) {
- $r = dba::p('SHOW PROCESSLIST');
- $used = dba::num_rows($r);
- dba::close($r);
+ $r = DBA::p('SHOW PROCESSLIST');
+ $used = DBA::num_rows($r);
+ DBA::close($r);
logger("Connection usage (user values): ".$used."/".$max, LOGGER_DEBUG);
// We will now check for the system values.
// This limit could be reached although the user limits are fine.
- $r = dba::fetch_first("SHOW VARIABLES WHERE `variable_name` = 'max_connections'");
+ $r = DBA::fetch_first("SHOW VARIABLES WHERE `variable_name` = 'max_connections'");
if (!DBM::is_result($r)) {
return false;
}
if ($max == 0) {
return false;
}
- $r = dba::fetch_first("SHOW STATUS WHERE `variable_name` = 'Threads_connected'");
+ $r = DBA::fetch_first("SHOW STATUS WHERE `variable_name` = 'Threads_connected'");
if (!DBM::is_result($r)) {
return false;
}
*/
private static function killStaleWorkers()
{
- $entries = dba::select(
+ $entries = DBA::select(
'workerqueue',
['id', 'pid', 'executed', 'priority', 'parameter'],
['`executed` > ? AND NOT `done` AND `pid` != 0', NULL_DATE],
['order' => ['priority', 'created']]
);
- while ($entry = dba::fetch($entries)) {
+ while ($entry = DBA::fetch($entries)) {
if (!posix_kill($entry["pid"], 0)) {
- dba::update(
+ DBA::update(
'workerqueue',
['executed' => NULL_DATE, 'pid' => 0],
['id' => $entry["id"]]
} elseif ($entry["priority"] != PRIORITY_CRITICAL) {
$new_priority = PRIORITY_NEGLIGIBLE;
}
- dba::update(
+ DBA::update(
'workerqueue',
['executed' => NULL_DATE, 'created' => DateTimeFormat::utcNow(), 'priority' => $new_priority, 'pid' => 0],
['id' => $entry["id"]]
$listitem = [];
// Adding all processes with no workerqueue entry
- $processes = dba::p(
+ $processes = DBA::p(
"SELECT COUNT(*) AS `running` FROM `process` WHERE NOT EXISTS
(SELECT id FROM `workerqueue`
WHERE `workerqueue`.`pid` = `process`.`pid` AND NOT `done` AND `pid` != ?)",
getmypid()
);
- if ($process = dba::fetch($processes)) {
+ if ($process = DBA::fetch($processes)) {
$listitem[0] = "0:".$process["running"];
}
- dba::close($processes);
+ DBA::close($processes);
// Now adding all processes with workerqueue entries
- $entries = dba::p("SELECT COUNT(*) AS `entries`, `priority` FROM `workerqueue` WHERE NOT `done` GROUP BY `priority`");
- while ($entry = dba::fetch($entries)) {
- $processes = dba::p("SELECT COUNT(*) AS `running` FROM `process` INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid` AND NOT `done` WHERE `priority` = ?", $entry["priority"]);
- if ($process = dba::fetch($processes)) {
+ $entries = DBA::p("SELECT COUNT(*) AS `entries`, `priority` FROM `workerqueue` WHERE NOT `done` GROUP BY `priority`");
+ while ($entry = DBA::fetch($entries)) {
+ $processes = DBA::p("SELECT COUNT(*) AS `running` FROM `process` INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid` AND NOT `done` WHERE `priority` = ?", $entry["priority"]);
+ if ($process = DBA::fetch($processes)) {
$listitem[$entry["priority"]] = $entry["priority"].":".$process["running"]."/".$entry["entries"];
}
- dba::close($processes);
+ DBA::close($processes);
}
- dba::close($entries);
+ DBA::close($entries);
$intervals = [1, 10, 60];
$jobs_per_minute = [];
foreach ($intervals as $interval) {
- $jobs = dba::p("SELECT COUNT(*) AS `jobs` FROM `workerqueue` WHERE `done` AND `executed` > UTC_TIMESTAMP() - INTERVAL ".intval($interval)." MINUTE");
- if ($job = dba::fetch($jobs)) {
+ $jobs = DBA::p("SELECT COUNT(*) AS `jobs` FROM `workerqueue` WHERE `done` AND `executed` > UTC_TIMESTAMP() - INTERVAL ".intval($interval)." MINUTE");
+ if ($job = DBA::fetch($jobs)) {
$jobs_per_minute[$interval] = number_format($job['jobs'] / $interval, 0);
}
- dba::close($jobs);
+ DBA::close($jobs);
}
$processlist = ' - jpm: '.implode('/', $jobs_per_minute).' ('.implode(', ', $listitem).')';
}
*/
private static function activeWorkers()
{
- return dba::count('process', ['command' => 'Worker.php']);
+ return DBA::count('process', ['command' => 'Worker.php']);
}
/**
{
$highest_priority = 0;
- $r = dba::p(
+ $r = DBA::p(
"SELECT `priority`
FROM `process`
INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid` AND NOT `done`"
return false;
}
$priorities = [];
- while ($line = dba::fetch($r)) {
+ while ($line = DBA::fetch($r)) {
$priorities[] = $line["priority"];
}
- dba::close($r);
+ DBA::close($r);
// Should not happen
if (count($priorities) == 0) {
$ids = [];
if (self::passingSlow($highest_priority)) {
// Are there waiting processes with a higher priority than the currently highest?
- $result = dba::select(
+ $result = DBA::select(
'workerqueue',
['id'],
["`executed` <= ? AND `priority` < ? AND NOT `done`", NULL_DATE, $highest_priority],
['limit' => $limit, 'order' => ['priority', 'created']]
);
- while ($id = dba::fetch($result)) {
+ while ($id = DBA::fetch($result)) {
$ids[] = $id["id"];
}
- dba::close($result);
+ DBA::close($result);
$found = (count($ids) > 0);
if (!$found) {
// Give slower processes some processing time
- $result = dba::select(
+ $result = DBA::select(
'workerqueue',
['id'],
["`executed` <= ? AND `priority` > ? AND NOT `done`", NULL_DATE, $highest_priority],
['limit' => $limit, 'order' => ['priority', 'created']]
);
- while ($id = dba::fetch($result)) {
+ while ($id = DBA::fetch($result)) {
$ids[] = $id["id"];
}
- dba::close($result);
+ DBA::close($result);
$found = (count($ids) > 0);
$passing_slow = $found;
// If there is no result (or we shouldn't pass lower processes) we check without priority limit
if (!$found) {
- $result = dba::select(
+ $result = DBA::select(
'workerqueue',
['id'],
["`executed` <= ? AND NOT `done`", NULL_DATE],
['limit' => $limit, 'order' => ['priority', 'created']]
);
- while ($id = dba::fetch($result)) {
+ while ($id = DBA::fetch($result)) {
$ids[] = $id["id"];
}
- dba::close($result);
+ DBA::close($result);
$found = (count($ids) > 0);
}
if ($found) {
$condition = "`id` IN (".substr(str_repeat("?, ", count($ids)), 0, -2).") AND `pid` = 0 AND NOT `done`";
array_unshift($ids, $condition);
- dba::update('workerqueue', ['executed' => DateTimeFormat::utcNow(), 'pid' => $mypid], $ids);
+ DBA::update('workerqueue', ['executed' => DateTimeFormat::utcNow(), 'pid' => $mypid], $ids);
}
return $found;
$stamp = (float)microtime(true);
// There can already be jobs for us in the queue.
- $r = dba::select('workerqueue', [], ['pid' => getmypid(), 'done' => false]);
+ $r = DBA::select('workerqueue', [], ['pid' => getmypid(), 'done' => false]);
if (DBM::is_result($r)) {
self::$db_duration += (microtime(true) - $stamp);
- return dba::inArray($r);
+ return DBA::inArray($r);
}
- dba::close($r);
+ DBA::close($r);
$stamp = (float)microtime(true);
if (!Lock::acquire('worker_process')) {
Lock::release('worker_process');
if ($found) {
- $r = dba::select('workerqueue', [], ['pid' => getmypid(), 'done' => false]);
- return dba::inArray($r);
+ $r = DBA::select('workerqueue', [], ['pid' => getmypid(), 'done' => false]);
+ return DBA::inArray($r);
}
return false;
}
{
$mypid = getmypid();
- dba::update('workerqueue', ['executed' => NULL_DATE, 'pid' => 0], ['pid' => $mypid, 'done' => false]);
+ DBA::update('workerqueue', ['executed' => NULL_DATE, 'pid' => 0], ['pid' => $mypid, 'done' => false]);
}
/**
/// @todo We should clean up the corresponding workerqueue entries as well
$condition = ["`created` < ? AND `command` = 'worker.php'",
DateTimeFormat::utc("now - ".$timeout." minutes")];
- dba::delete('process', $condition);
+ DBA::delete('process', $condition);
}
/**
}
$parameters = json_encode($args);
- $found = dba::exists('workerqueue', ['parameter' => $parameters, 'done' => false]);
+ $found = DBA::exists('workerqueue', ['parameter' => $parameters, 'done' => false]);
// Quit if there was a database error - a precaution for the update process to 3.5.3
- if (dba::errorNo() != 0) {
+ if (DBA::errorNo() != 0) {
return false;
}
if (!$found) {
- dba::insert('workerqueue', ['parameter' => $parameters, 'created' => $created, 'priority' => $priority]);
+ DBA::insert('workerqueue', ['parameter' => $parameters, 'created' => $created, 'priority' => $priority]);
}
// Should we quit and wait for the worker to be called as a cronjob?
*/
public static function IPCSetJobState($jobs)
{
- dba::update('worker-ipc', ['jobs' => $jobs], ['key' => 1], true);
+ DBA::update('worker-ipc', ['jobs' => $jobs], ['key' => 1], true);
}
/**
*/
public static function IPCJobsExists()
{
- $row = dba::selectFirst('worker-ipc', ['jobs'], ['key' => 1]);
+ $row = DBA::selectFirst('worker-ipc', ['jobs'], ['key' => 1]);
// When we don't have a row, no job is running
if (!DBM::is_result($row)) {
*
* This class is for the low level database stuff that does driver specific things.
*/
-class dba
+class DBA
{
public static $connected = false;
}
if (is_object($array)) {
- return dba::num_rows($array) > 0;
+ return DBA::num_rows($array) > 0;
}
return (is_array($array) && (count($array) > 0));
*/
public static function convertToInnoDB() {
$r = q("SELECT `TABLE_NAME` FROM `information_schema`.`tables` WHERE `engine` = 'MyISAM' AND `table_schema` = '%s'",
- dbesc(dba::database_name()));
+ dbesc(DBA::database_name()));
if (!DBM::is_result($r)) {
echo L10n::t('There are no tables on MyISAM.')."\n";
$sql = sprintf("ALTER TABLE `%s` engine=InnoDB;", dbesc($table['TABLE_NAME']));
echo $sql."\n";
- $result = dba::e($sql);
+ $result = DBA::e($sql);
if (!DBM::is_result($result)) {
self::printUpdateError($sql);
}
*/
private static function printUpdateError($message) {
echo L10n::t("\nError %d occurred during database update:\n%s\n",
- dba::errorNo(), dba::errorMessage());
+ DBA::errorNo(), DBA::errorMessage());
return L10n::t('Errors encountered performing database changes: ').$message.EOL;
}
}
// MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
- if ((version_compare(dba::server_info(), '5.7.4') >= 0) &&
- !(strpos(dba::server_info(), 'MariaDB') !== false)) {
+ if ((version_compare(DBA::server_info(), '5.7.4') >= 0) &&
+ !(strpos(DBA::server_info(), 'MariaDB') !== false)) {
$ignore = '';
} else {
$ignore = ' IGNORE';
$parameters['comment'] = "";
}
- $current_field_definition = dba::clean_query(implode(",", $field_definition));
- $new_field_definition = dba::clean_query(implode(",", $parameters));
+ $current_field_definition = DBA::clean_query(implode(",", $field_definition));
+ $new_field_definition = DBA::clean_query(implode(",", $parameters));
if ($current_field_definition != $new_field_definition) {
$sql2 = self::modifyTableField($fieldname, $parameters);
if ($sql3 == "") {
if ($ignore != "") {
echo "SET session old_alter_table=0;\n";
} else {
- echo "INSERT INTO `".$temp_name."` SELECT ".dba::any_value_fallback($field_list)." FROM `".$name."`".$group_by.";\n";
+ echo "INSERT INTO `".$temp_name."` SELECT ".DBA::any_value_fallback($field_list)." FROM `".$name."`".$group_by.";\n";
echo "DROP TABLE `".$name."`;\n";
echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
}
// Ensure index conversion to unique removes duplicates
if ($is_unique && ($temp_name != $name)) {
if ($ignore != "") {
- dba::e("SET session old_alter_table=1;");
+ DBA::e("SET session old_alter_table=1;");
} else {
- $r = 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;
}
- $r = dba::e("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
+ $r = DBA::e("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
if (!DBM::is_result($r)) {
$errors .= self::printUpdateError($sql3);
return $errors;
}
}
- $r = dba::e($sql3);
+ $r = DBA::e($sql3);
if (!DBM::is_result($r)) {
$errors .= self::printUpdateError($sql3);
}
if ($is_unique && ($temp_name != $name)) {
if ($ignore != "") {
- dba::e("SET session old_alter_table=0;");
+ DBA::e("SET session old_alter_table=0;");
} else {
- $r = dba::e("INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";");
+ $r = DBA::e("INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";");
if (!DBM::is_result($r)) {
$errors .= self::printUpdateError($sql3);
return $errors;
}
- $r = dba::e("DROP TABLE `".$name."`;");
+ $r = DBA::e("DROP TABLE `".$name."`;");
if (!DBM::is_result($r)) {
$errors .= self::printUpdateError($sql3);
return $errors;
}
- $r = dba::e("RENAME TABLE `".$temp_name."` TO `".$name."`;");
+ $r = DBA::e("RENAME TABLE `".$temp_name."` TO `".$name."`;");
if (!DBM::is_result($r)) {
$errors .= self::printUpdateError($sql3);
return $errors;
}
if ($action) {
- $r = dba::e($sql);
+ $r = DBA::e($sql);
}
return $r;
// Check if the first step is done (Setting "author-id" and "owner-id" in the item table)
$fields = ['author-link', 'author-name', 'author-avatar', 'owner-link', 'owner-name', 'owner-avatar', 'network', 'uid'];
- $r = dba::select('item', $fields, ['author-id' => 0, 'owner-id' => 0], ['limit' => 1000]);
+ $r = DBA::select('item', $fields, ['author-id' => 0, 'owner-id' => 0], ['limit' => 1000]);
if (!$r) {
// Are there unfinished entries in the thread table?
$r = q("SELECT COUNT(*) AS `total` FROM `thread`
if ($owner_id == 0) {
$owner_id = -1;
}
- dba::update('item', ['author-id' => $author_id, 'owner-id' => $owner_id], ['uid' => $item['uid'], 'author-link' => $item['author-link'], 'owner-link' => $item['owner-link'], 'author-id' => 0, 'owner-id' => 0]);
+ DBA::update('item', ['author-id' => $author_id, 'owner-id' => $owner_id], ['uid' => $item['uid'], 'author-link' => $item['author-link'], 'owner-link' => $item['owner-link'], 'author-id' => 0, 'owner-id' => 0]);
}
logger("Updated items", LOGGER_DEBUG);
}
foreach ($r as $user) {
if (!empty($user["lastitem_date"]) && ($user["lastitem_date"] > $user["last-item"])) {
- dba::update('contact', ['last-item' => $user['lastitem_date']], ['id' => $user['id']]);
+ DBA::update('contact', ['last-item' => $user['lastitem_date']], ['id' => $user['id']]);
}
}
++$rows;
}
- dba::close($items);
+ DBA::close($items);
Config::set("system", "post_update_version_1279_id", $id);
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Core\Worker;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Network\Probe;
use Friendica\Object\Image;
{
$return = [];
if (intval($gid)) {
- $stmt = dba::p('SELECT `group_member`.`contact-id`, `contact`.*
+ $stmt = DBA::p('SELECT `group_member`.`contact-id`, `contact`.*
FROM `contact`
INNER JOIN `group_member`
ON `contact`.`id` = `group_member`.`contact-id`
local_user()
);
if (DBM::is_result($stmt)) {
- $return = dba::inArray($stmt);
+ $return = DBA::inArray($stmt);
}
}
{
$return = 0;
if (intval($gid)) {
- $contacts = dba::fetch_first('SELECT COUNT(*) AS `count`
+ $contacts = DBA::fetch_first('SELECT COUNT(*) AS `count`
FROM `contact`
INNER JOIN `group_member`
ON `contact`.`id` = `group_member`.`contact-id`
public static function createSelfFromUserId($uid)
{
// Only create the entry if it doesn't exist yet
- if (dba::exists('contact', ['uid' => $uid, 'self' => true])) {
+ if (DBA::exists('contact', ['uid' => $uid, 'self' => true])) {
return true;
}
- $user = dba::selectFirst('user', ['uid', 'username', 'nickname'], ['uid' => $uid]);
+ $user = DBA::selectFirst('user', ['uid', 'username', 'nickname'], ['uid' => $uid]);
if (!DBM::is_result($user)) {
return false;
}
- $return = dba::insert('contact', [
+ $return = DBA::insert('contact', [
'uid' => $user['uid'],
'created' => DateTimeFormat::utcNow(),
'self' => 1,
{
$fields = ['id', 'name', 'nick', 'location', 'about', 'keywords', 'gender', 'avatar',
'xmpp', 'contact-type', 'forum', 'prv', 'avatar-date', 'nurl'];
- $self = dba::selectFirst('contact', $fields, ['uid' => $uid, 'self' => true]);
+ $self = DBA::selectFirst('contact', $fields, ['uid' => $uid, 'self' => true]);
if (!DBM::is_result($self)) {
return;
}
$fields = ['nickname', 'page-flags', 'account-type'];
- $user = dba::selectFirst('user', $fields, ['uid' => $uid]);
+ $user = DBA::selectFirst('user', $fields, ['uid' => $uid]);
if (!DBM::is_result($user)) {
return;
}
$fields = ['name', 'photo', 'thumb', 'about', 'address', 'locality', 'region',
'country-name', 'gender', 'pub_keywords', 'xmpp'];
- $profile = dba::selectFirst('profile', $fields, ['uid' => $uid, 'is-default' => true]);
+ $profile = DBA::selectFirst('profile', $fields, ['uid' => $uid, 'is-default' => true]);
if (!DBM::is_result($profile)) {
return;
}
'gender' => $profile['gender'], 'avatar' => $profile['photo'],
'contact-type' => $user['account-type'], 'xmpp' => $profile['xmpp']];
- $avatar = dba::selectFirst('photo', ['resource-id', 'type'], ['uid' => $uid, 'profile' => true]);
+ $avatar = DBA::selectFirst('photo', ['resource-id', 'type'], ['uid' => $uid, 'profile' => true]);
if (DBM::is_result($avatar)) {
if ($update_avatar) {
$fields['avatar-date'] = DateTimeFormat::utcNow();
if ($update) {
$fields['name-date'] = DateTimeFormat::utcNow();
- dba::update('contact', $fields, ['id' => $self['id']]);
+ DBA::update('contact', $fields, ['id' => $self['id']]);
// Update the public contact as well
- dba::update('contact', $fields, ['uid' => 0, 'nurl' => $self['nurl']]);
+ DBA::update('contact', $fields, ['uid' => 0, 'nurl' => $self['nurl']]);
// Update the profile
$fields = ['photo' => System::baseUrl() . '/photo/profile/' .$uid . '.jpg',
'thumb' => System::baseUrl() . '/photo/avatar/' . $uid .'.jpg'];
- dba::update('profile', $fields, ['uid' => $uid, 'is-default' => true]);
+ DBA::update('profile', $fields, ['uid' => $uid, 'is-default' => true]);
}
}
public static function remove($id)
{
// We want just to make sure that we don't delete our "self" contact
- $contact = dba::selectFirst('contact', ['uid'], ['id' => $id, 'self' => false]);
+ $contact = DBA::selectFirst('contact', ['uid'], ['id' => $id, 'self' => false]);
if (!DBM::is_result($contact) || !intval($contact['uid'])) {
return;
}
$archive = PConfig::get($contact['uid'], 'system', 'archive_removed_contacts');
if ($archive) {
- dba::update('contact', ['archive' => true, 'network' => 'none', 'writable' => false], ['id' => $id]);
+ DBA::update('contact', ['archive' => true, 'network' => 'none', 'writable' => false], ['id' => $id]);
return;
}
- dba::delete('contact', ['id' => $id]);
+ DBA::delete('contact', ['id' => $id]);
// Delete the rest in the background
Worker::add(PRIORITY_LOW, 'RemoveContact', $id);
}
if ($contact['term-date'] <= NULL_DATE) {
- dba::update('contact', ['term-date' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
+ DBA::update('contact', ['term-date' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
if ($contact['url'] != '') {
- dba::update('contact', ['term-date' => DateTimeFormat::utcNow()], ['`nurl` = ? AND `term-date` <= ? AND NOT `self`', normalise_link($contact['url']), NULL_DATE]);
+ DBA::update('contact', ['term-date' => DateTimeFormat::utcNow()], ['`nurl` = ? AND `term-date` <= ? AND NOT `self`', normalise_link($contact['url']), NULL_DATE]);
}
} else {
/* @todo
* delete, though if the owner tries to unarchive them we'll start
* the whole process over again.
*/
- dba::update('contact', ['archive' => 1], ['id' => $contact['id']]);
+ DBA::update('contact', ['archive' => 1], ['id' => $contact['id']]);
if ($contact['url'] != '') {
- dba::update('contact', ['archive' => 1], ['nurl' => normalise_link($contact['url']), 'self' => false]);
+ DBA::update('contact', ['archive' => 1], ['nurl' => normalise_link($contact['url']), 'self' => false]);
}
}
}
public static function unmarkForArchival(array $contact)
{
$condition = ['`id` = ? AND (`term-date` > ? OR `archive`)', $contact['id'], NULL_DATE];
- $exists = dba::exists('contact', $condition);
+ $exists = DBA::exists('contact', $condition);
// We don't need to update, we never marked this contact for archival
if (!$exists) {
// It's a miracle. Our dead contact has inexplicably come back to life.
$fields = ['term-date' => NULL_DATE, 'archive' => false];
- dba::update('contact', $fields, ['id' => $contact['id']]);
+ DBA::update('contact', $fields, ['id' => $contact['id']]);
if (!empty($contact['url'])) {
- dba::update('contact', $fields, ['nurl' => normalise_link($contact['url'])]);
+ DBA::update('contact', $fields, ['nurl' => normalise_link($contact['url'])]);
}
if (!empty($contact['batch'])) {
$condition = ['batch' => $contact['batch'], 'contact-type' => ACCOUNT_TYPE_RELAY];
- dba::update('contact', $fields, $condition);
+ DBA::update('contact', $fields, $condition);
}
}
$ssl_url = str_replace('http://', 'https://', $url);
// Fetch contact data from the contact table for the given user
- $s = dba::p("SELECT `id`, `id` AS `cid`, 0 AS `gid`, 0 AS `zid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
+ $s = DBA::p("SELECT `id`, `id` AS `cid`, 0 AS `gid`, 0 AS `zid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
`keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `contact-type`, `bd` AS `birthday`, `self`
FROM `contact` WHERE `nurl` = ? AND `uid` = ?", normalise_link($url), $uid);
- $r = dba::inArray($s);
+ $r = DBA::inArray($s);
// Fetch contact data from the contact table for the given user, checking with the alias
if (!DBM::is_result($r)) {
- $s = dba::p("SELECT `id`, `id` AS `cid`, 0 AS `gid`, 0 AS `zid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
+ $s = DBA::p("SELECT `id`, `id` AS `cid`, 0 AS `gid`, 0 AS `zid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
`keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `contact-type`, `bd` AS `birthday`, `self`
FROM `contact` WHERE `alias` IN (?, ?, ?) AND `uid` = ?", normalise_link($url), $url, $ssl_url, $uid);
- $r = dba::inArray($s);
+ $r = DBA::inArray($s);
}
// Fetch the data from the contact table with "uid=0" (which is filled automatically)
if (!DBM::is_result($r)) {
- $s = dba::p("SELECT `id`, 0 AS `cid`, `id` AS `zid`, 0 AS `gid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
+ $s = DBA::p("SELECT `id`, 0 AS `cid`, `id` AS `zid`, 0 AS `gid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
`keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `contact-type`, `bd` AS `birthday`, 0 AS `self`
FROM `contact` WHERE `nurl` = ? AND `uid` = 0", normalise_link($url));
- $r = dba::inArray($s);
+ $r = DBA::inArray($s);
}
// Fetch the data from the contact table with "uid=0" (which is filled automatically) - checked with the alias
if (!DBM::is_result($r)) {
- $s = dba::p("SELECT `id`, 0 AS `cid`, `id` AS `zid`, 0 AS `gid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
+ $s = DBA::p("SELECT `id`, 0 AS `cid`, `id` AS `zid`, 0 AS `gid`, `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, `xmpp`,
`keywords`, `gender`, `photo`, `thumb`, `micro`, `forum`, `prv`, (`forum` | `prv`) AS `community`, `contact-type`, `bd` AS `birthday`, 0 AS `self`
FROM `contact` WHERE `alias` IN (?, ?, ?) AND `uid` = 0", normalise_link($url), $url, $ssl_url);
- $r = dba::inArray($s);
+ $r = DBA::inArray($s);
}
// Fetch the data from the gcontact table
if (!DBM::is_result($r)) {
- $s = dba::p("SELECT 0 AS `id`, 0 AS `cid`, `id` AS `gid`, 0 AS `zid`, 0 AS `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, '' AS `xmpp`,
+ $s = DBA::p("SELECT 0 AS `id`, 0 AS `cid`, `id` AS `gid`, 0 AS `zid`, 0 AS `uid`, `url`, `nurl`, `alias`, `network`, `name`, `nick`, `addr`, `location`, `about`, '' AS `xmpp`,
`keywords`, `gender`, `photo`, `photo` AS `thumb`, `photo` AS `micro`, 0 AS `forum`, 0 AS `prv`, `community`, `contact-type`, `birthday`, 0 AS `self`
FROM `gcontact` WHERE `nurl` = ?", normalise_link($url));
- $r = dba::inArray($s);
+ $r = DBA::inArray($s);
}
if (DBM::is_result($r)) {
}
// Look for our own contact if the uid doesn't match and isn't public
- $contact_own = dba::selectFirst('contact', [], ['nurl' => $contact['nurl'], 'network' => $contact['network'], 'uid' => $uid]);
+ $contact_own = DBA::selectFirst('contact', [], ['nurl' => $contact['nurl'], 'network' => $contact['network'], 'uid' => $uid]);
if (DBM::is_result($contact_own)) {
return self::photoMenu($contact_own, $uid);
} else {
/// @todo Verify if we can't use Contact::getDetailsByUrl instead of the following
// We first try the nurl (http://server.tld/nick), most common case
- $contact = dba::selectFirst('contact', ['id', 'avatar', 'avatar-date'], ['nurl' => normalise_link($url), 'uid' => $uid]);
+ $contact = DBA::selectFirst('contact', ['id', 'avatar', 'avatar-date'], ['nurl' => normalise_link($url), 'uid' => $uid]);
// Then the addr (nick@server.tld)
if (!DBM::is_result($contact)) {
- $contact = dba::selectFirst('contact', ['id', 'avatar', 'avatar-date'], ['addr' => $url, 'uid' => $uid]);
+ $contact = DBA::selectFirst('contact', ['id', 'avatar', 'avatar-date'], ['addr' => $url, 'uid' => $uid]);
}
// Then the alias (which could be anything)
// The link could be provided as http although we stored it as https
$ssl_url = str_replace('http://', 'https://', $url);
$condition = ['`alias` IN (?, ?, ?) AND `uid` = ?', $url, normalise_link($url), $ssl_url, $uid];
- $contact = dba::selectFirst('contact', ['id', 'avatar', 'avatar-date'], $condition);
+ $contact = DBA::selectFirst('contact', ['id', 'avatar', 'avatar-date'], $condition);
}
if (DBM::is_result($contact)) {
// Get data from the gcontact table
$fields = ['name', 'nick', 'url', 'photo', 'addr', 'alias', 'network'];
- $contact = dba::selectFirst('gcontact', $fields, ['nurl' => normalise_link($url)]);
+ $contact = DBA::selectFirst('gcontact', $fields, ['nurl' => normalise_link($url)]);
if (!DBM::is_result($contact)) {
- $contact = dba::selectFirst('contact', $fields, ['nurl' => normalise_link($url)]);
+ $contact = DBA::selectFirst('contact', $fields, ['nurl' => normalise_link($url)]);
}
if (!DBM::is_result($contact)) {
$fields = ['url', 'addr', 'alias', 'notify', 'poll', 'name', 'nick',
'photo', 'keywords', 'location', 'about', 'network',
'priority', 'batch', 'request', 'confirm', 'poco'];
- $contact = dba::selectFirst('contact', $fields, ['addr' => $url]);
+ $contact = DBA::selectFirst('contact', $fields, ['addr' => $url]);
}
if (!DBM::is_result($contact)) {
// The link could be provided as http although we stored it as https
$ssl_url = str_replace('http://', 'https://', $url);
$condition = ['alias' => [$url, normalise_link($url), $ssl_url]];
- $contact = dba::selectFirst('contact', $fields, $condition);
+ $contact = DBA::selectFirst('contact', $fields, $condition);
}
if (!DBM::is_result($contact)) {
$fields = ['url', 'addr', 'alias', 'notify', 'poll', 'name', 'nick',
'photo', 'network', 'priority', 'batch', 'request', 'confirm'];
$condition = ['url' => [$url, normalise_link($url), $ssl_url]];
- $contact = dba::selectFirst('fcontact', $fields, $condition);
+ $contact = DBA::selectFirst('fcontact', $fields, $condition);
}
if (!empty($default)) {
$url = $data["url"];
if (!$contact_id) {
- dba::insert('contact', [
+ DBA::insert('contact', [
'uid' => $uid,
'created' => DateTimeFormat::utcNow(),
'url' => $data["url"],
'pending' => 0]
);
- $s = dba::select('contact', ['id'], ['nurl' => normalise_link($data["url"]), 'uid' => $uid], ['order' => ['id'], 'limit' => 2]);
- $contacts = dba::inArray($s);
+ $s = DBA::select('contact', ['id'], ['nurl' => normalise_link($data["url"]), 'uid' => $uid], ['order' => ['id'], 'limit' => 2]);
+ $contacts = DBA::inArray($s);
if (!DBM::is_result($contacts)) {
return 0;
}
$contact_id = $contacts[0]["id"];
// Update the newly created contact from data in the gcontact table
- $gcontact = dba::selectFirst('gcontact', ['location', 'about', 'keywords', 'gender'], ['nurl' => normalise_link($data["url"])]);
+ $gcontact = DBA::selectFirst('gcontact', ['location', 'about', 'keywords', 'gender'], ['nurl' => normalise_link($data["url"])]);
if (DBM::is_result($gcontact)) {
// Only use the information when the probing hadn't fetched these values
if ($data['keywords'] != '') {
if ($data['about'] != '') {
unset($gcontact['about']);
}
- dba::update('contact', $gcontact, ['id' => $contact_id]);
+ DBA::update('contact', $gcontact, ['id' => $contact_id]);
}
if (count($contacts) > 1 && $uid == 0 && $contact_id != 0 && $data["url"] != "") {
- dba::delete('contact', ["`nurl` = ? AND `uid` = 0 AND `id` != ? AND NOT `self`",
+ DBA::delete('contact', ["`nurl` = ? AND `uid` = 0 AND `id` != ? AND NOT `self`",
normalise_link($data["url"]), $contact_id]);
}
}
self::updateAvatar($data["photo"], $uid, $contact_id);
$fields = ['url', 'nurl', 'addr', 'alias', 'name', 'nick', 'keywords', 'location', 'about', 'avatar-date', 'pubkey'];
- $contact = dba::selectFirst('contact', $fields, ['id' => $contact_id]);
+ $contact = DBA::selectFirst('contact', $fields, ['id' => $contact_id]);
// This condition should always be true
if (!DBM::is_result($contact)) {
$updated['avatar-date'] = DateTimeFormat::utcNow();
- dba::update('contact', $updated, ['id' => $contact_id], $contact);
+ DBA::update('contact', $updated, ['id' => $contact_id], $contact);
return $contact_id;
}
return false;
}
- $blocked = dba::selectFirst('contact', ['blocked'], ['id' => $cid]);
+ $blocked = DBA::selectFirst('contact', ['blocked'], ['id' => $cid]);
if (!DBM::is_result($blocked)) {
return false;
}
return false;
}
- $hidden = dba::selectFirst('contact', ['hidden'], ['id' => $cid]);
+ $hidden = DBA::selectFirst('contact', ['hidden'], ['id' => $cid]);
if (!DBM::is_result($hidden)) {
return false;
}
*/
public static function block($uid)
{
- $return = dba::update('contact', ['blocked' => true], ['id' => $uid]);
+ $return = DBA::update('contact', ['blocked' => true], ['id' => $uid]);
return $return;
}
*/
public static function unblock($uid)
{
- $return = dba::update('contact', ['blocked' => false], ['id' => $uid]);
+ $return = DBA::update('contact', ['blocked' => false], ['id' => $uid]);
return $return;
}
*/
public static function updateAvatar($avatar, $uid, $cid, $force = false)
{
- $contact = dba::selectFirst('contact', ['avatar', 'photo', 'thumb', 'micro', 'nurl'], ['id' => $cid]);
+ $contact = DBA::selectFirst('contact', ['avatar', 'photo', 'thumb', 'micro', 'nurl'], ['id' => $cid]);
if (!DBM::is_result($contact)) {
return false;
} else {
$photos = Photo::importProfilePhoto($avatar, $uid, $cid, true);
if ($photos) {
- dba::update(
+ DBA::update(
'contact',
['avatar' => $avatar, 'photo' => $photos[0], 'thumb' => $photos[1], 'micro' => $photos[2], 'avatar-date' => DateTimeFormat::utcNow()],
['id' => $cid]
// Update the public contact (contact id = 0)
if ($uid != 0) {
- $pcontact = dba::selectFirst('contact', ['id'], ['nurl' => $contact['nurl'], 'uid' => 0]);
+ $pcontact = DBA::selectFirst('contact', ['id'], ['nurl' => $contact['nurl'], 'uid' => 0]);
if (DBM::is_result($pcontact)) {
self::updateAvatar($avatar, 0, $pcontact['id'], $force);
}
*/
$fields = ['url', 'nurl', 'addr', 'alias', 'batch', 'notify', 'poll', 'poco', 'network'];
- $contact = dba::selectFirst('contact', $fields, ['id' => $id]);
+ $contact = DBA::selectFirst('contact', $fields, ['id' => $id]);
if (!DBM::is_result($contact)) {
return false;
}
return true;
}
- dba::update(
+ DBA::update(
'contact', [
'url' => $ret['url'],
'nurl' => normalise_link($ret['url']),
$new_relation = (($r[0]['rel'] == CONTACT_IS_FOLLOWER) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING);
$fields = ['rel' => $new_relation, 'subhub' => $subhub, 'readonly' => false];
- dba::update('contact', $fields, ['id' => $r[0]['id']]);
+ DBA::update('contact', $fields, ['id' => $r[0]['id']]);
} else {
$new_relation = ((in_array($ret['network'], [NETWORK_MAIL])) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING);
// create contact record
- dba::insert('contact', [
+ DBA::insert('contact', [
'uid' => $uid,
'created' => DateTimeFormat::utcNow(),
'url' => $ret['url'],
]);
}
- $contact = dba::selectFirst('contact', [], ['url' => $ret['url'], 'network' => $ret['network'], 'uid' => $uid]);
+ $contact = DBA::selectFirst('contact', [], ['url' => $ret['url'], 'network' => $ret['network'], 'uid' => $uid]);
if (!DBM::is_result($contact)) {
$result['message'] .= L10n::t('Unable to retrieve contact information.') . EOL;
return $result;
$fields = ['url' => $contact['url'], 'request' => $contact['request'],
'notify' => $contact['notify'], 'poll' => $contact['poll'],
'confirm' => $contact['confirm'], 'poco' => $contact['poco']];
- dba::update('contact', $fields, ['id' => $contact['id']]);
+ DBA::update('contact', $fields, ['id' => $contact['id']]);
}
return $contact;
if (is_array($contact)) {
if (($contact['rel'] == CONTACT_IS_SHARING)
|| ($sharing && $contact['rel'] == CONTACT_IS_FOLLOWER)) {
- dba::update('contact', ['rel' => CONTACT_IS_FRIEND, 'writable' => true],
+ DBA::update('contact', ['rel' => CONTACT_IS_FRIEND, 'writable' => true],
['id' => $contact['id'], 'uid' => $importer['uid']]);
}
// send email notification to owner?
} else {
- if (dba::exists('contact', ['nurl' => normalise_link($url), 'uid' => $importer['uid'], 'pending' => true])) {
+ if (DBA::exists('contact', ['nurl' => normalise_link($url), 'uid' => $importer['uid'], 'pending' => true])) {
logger('ignoring duplicated connection request from pending contact ' . $url);
return;
}
);
$contact_record = [
- 'id' => dba::lastInsertId(),
+ 'id' => DBA::lastInsertId(),
'network' => NETWORK_OSTATUS,
'name' => $name,
'url' => $url,
/// @TODO Encapsulate this into a function/method
$fields = ['uid', 'username', 'email', 'page-flags', 'notify-flags', 'language'];
- $user = dba::selectFirst('user', $fields, ['uid' => $importer['uid']]);
+ $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();
if (is_array($contact_record)) {
- dba::insert('intro', ['uid' => $importer['uid'], 'contact-id' => $contact_record['id'],
+ DBA::insert('intro', ['uid' => $importer['uid'], 'contact-id' => $contact_record['id'],
'blocked' => false, 'knowyou' => false,
'hash' => $hash, 'datetime' => DateTimeFormat::utcNow()]);
}
public static function removeFollower($importer, $contact, array $datarray = [], $item = "") {
if (($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_SHARING)) {
- dba::update('contact', ['rel' => CONTACT_IS_SHARING], ['id' => $contact['id']]);
+ DBA::update('contact', ['rel' => CONTACT_IS_SHARING], ['id' => $contact['id']]);
} else {
Contact::remove($contact['id']);
}
public static function removeSharer($importer, $contact, array $datarray = [], $item = "") {
if (($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_FOLLOWER)) {
- dba::update('contact', ['rel' => CONTACT_IS_FOLLOWER], ['id' => $contact['id']]);
+ DBA::update('contact', ['rel' => CONTACT_IS_FOLLOWER], ['id' => $contact['id']]);
} else {
Contact::remove($contact['id']);
}
$str = dbesc(implode(',', $contact_ids));
- $stmt = dba::p("SELECT `id` FROM `contact` WHERE `id` IN ( " . $str . ") AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0");
+ $stmt = DBA::p("SELECT `id` FROM `contact` WHERE `id` IN ( " . $str . ") AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0");
$return = [];
- while($contact = dba::fetch($stmt)) {
+ while($contact = DBA::fetch($stmt)) {
$return[] = $contact['id'];
}
- dba::close($stmt);
+ DBA::close($stmt);
$contact_ids = $return;
}
*/
public static function magicLinkbyId($cid, $url = '')
{
- $contact = dba::selectFirst('contact', ['id', 'network', 'url', 'uid'], ['id' => $cid]);
+ $contact = DBA::selectFirst('contact', ['id', 'network', 'url', 'uid'], ['id' => $cid]);
return self::magicLinkbyContact($contact, $url);
}
*/
namespace Friendica\Model;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
require_once "include/dba.php";
}
$fields = ['item-uri', 'reply-to-uri', 'conversation-uri', 'conversation-href', 'protocol', 'source'];
- $old_conv = dba::selectFirst('conversation', $fields, ['item-uri' => $conversation['item-uri']]);
+ $old_conv = DBA::selectFirst('conversation', $fields, ['item-uri' => $conversation['item-uri']]);
if (DBM::is_result($old_conv)) {
// Don't update when only the source has changed.
// Only do this when there had been no source before.
unset($conversation['protocol']);
unset($conversation['source']);
}
- if (!dba::update('conversation', $conversation, ['item-uri' => $conversation['item-uri']], $old_conv)) {
+ if (!DBA::update('conversation', $conversation, ['item-uri' => $conversation['item-uri']], $old_conv)) {
logger('Conversation: update for '.$conversation['item-uri'].' from '.$old_conv['protocol'].' to '.$conversation['protocol'].' failed', LOGGER_DEBUG);
}
} else {
- if (!dba::insert('conversation', $conversation, true)) {
+ if (!DBA::insert('conversation', $conversation, true)) {
logger('Conversation: insert for '.$conversation['item-uri'].' (protocol '.$conversation['protocol'].') failed', LOGGER_DEBUG);
}
}
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Map;
return;
}
- dba::delete('event', ['id' => $event_id]);
+ DBA::delete('event', ['id' => $event_id]);
logger("Deleted event ".$event_id, LOGGER_DEBUG);
}
$conditions['self'] = true;
}
- $contact = dba::selectFirst('contact', [], $conditions);
+ $contact = DBA::selectFirst('contact', [], $conditions);
// Existing event being modified.
if ($event['id']) {
// has the event actually changed?
- $existing_event = dba::selectFirst('event', ['edited'], ['id' => $event['id'], 'uid' => $event['uid']]);
+ $existing_event = DBA::selectFirst('event', ['edited'], ['id' => $event['id'], 'uid' => $event['uid']]);
if (!DBM::is_result($existing_event) || ($existing_event['edited'] === $event['edited'])) {
$item = Item::selectFirst(['id'], ['event-id' => $event['id'], 'uid' => $event['uid']]);
'nofinish' => $event['nofinish'],
];
- dba::update('event', $updated_fields, ['id' => $event['id'], 'uid' => $event['uid']]);
+ DBA::update('event', $updated_fields, ['id' => $event['id'], 'uid' => $event['uid']]);
$item = Item::selectFirst(['id'], ['event-id' => $event['id'], 'uid' => $event['uid']]);
if (DBM::is_result($item)) {
$event['guid'] = System::createGUID(32);
// New event. Store it.
- dba::insert('event', $event);
+ DBA::insert('event', $event);
- $event['id'] = dba::lastInsertId();
+ $event['id'] = DBA::lastInsertId();
$item_arr = [];
$conditions += ['allow_cid' => '', 'allow_gid' => ''];
}
- $events = dba::select('event', $fields, $conditions);
+ $events = DBA::select('event', $fields, $conditions);
if (DBM::is_result($events)) {
- $return = dba::inArray($events);
+ $return = DBA::inArray($events);
}
return $return;
{
$process = false;
- $user = dba::selectFirst('user', ['timezone'], ['uid' => $uid]);
+ $user = DBA::selectFirst('user', ['timezone'], ['uid' => $uid]);
if (DBM::is_result($user)) {
$timezone = $user['timezone'];
}
use Friendica\Core\Config;
use Friendica\Core\System;
use Friendica\Core\Worker;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Network\Probe;
use Friendica\Protocol\PortableContact;
$search .= "%";
- $results = dba::p("SELECT `nurl` FROM `gcontact`
+ $results = DBA::p("SELECT `nurl` FROM `gcontact`
WHERE NOT `hide` AND `network` IN (?, ?, ?) AND
((`last_contact` >= `last_failure`) OR (`updated` >= `last_failure`)) AND
(`addr` LIKE ? OR `name` LIKE ? OR `nick` LIKE ?) $extra_sql
);
$gcontacts = [];
- while ($result = dba::fetch($results)) {
+ while ($result = DBA::fetch($results)) {
$urlparts = parse_url($result["nurl"]);
// Ignore results that look strange.
if ($alternate && ($gcontact['network'] == NETWORK_OSTATUS)) {
// Delete the old entry - if it exists
- if (dba::exists('gcontact', ['nurl' => normalise_link($orig_profile)])) {
- dba::delete('gcontact', ['nurl' => normalise_link($orig_profile)]);
+ if (DBA::exists('gcontact', ['nurl' => normalise_link($orig_profile)])) {
+ DBA::delete('gcontact', ['nurl' => normalise_link($orig_profile)]);
}
}
}
$contact["url"] = self::cleanContactUrl($contact["url"]);
}
- dba::lock('gcontact');
+ DBA::lock('gcontact');
$r = q(
"SELECT `id`, `last_contact`, `last_failure`, `network` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
dbesc(normalise_link($contact["url"]))
$doprobing = in_array($r[0]["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, ""]);
}
}
- dba::unlock();
+ DBA::unlock();
if ($doprobing) {
logger("Last Contact: ". $last_contact_str." - Last Failure: ".$last_failure_str." - Checking: ".$contact["url"], LOGGER_DEBUG);
'generation' => $contact['generation'], 'updated' => $contact['updated'],
'server_url' => $contact['server_url'], 'connect' => $contact['connect']];
- dba::update('gcontact', $updated, $condition, $fields);
+ DBA::update('gcontact', $updated, $condition, $fields);
// Now update the contact entry with the user id "0" as well.
// This is used for the shadow copies of public items.
/// @todo Check if we really should do this.
// The quality of the gcontact table is mostly lower than the public contact
- $public_contact = dba::selectFirst('contact', ['id'], ['nurl' => normalise_link($contact["url"]), 'uid' => 0]);
+ $public_contact = DBA::selectFirst('contact', ['id'], ['nurl' => normalise_link($contact["url"]), 'uid' => 0]);
if (DBM::is_result($public_contact)) {
logger("Update public contact ".$public_contact["id"], LOGGER_DEBUG);
'network', 'bd', 'gender',
'keywords', 'alias', 'contact-type',
'url', 'location', 'about'];
- $old_contact = dba::selectFirst('contact', $fields, ['id' => $public_contact["id"]]);
+ $old_contact = DBA::selectFirst('contact', $fields, ['id' => $public_contact["id"]]);
// Update it with the current values
$fields = ['name' => $contact['name'], 'nick' => $contact['nick'],
}
- dba::update('contact', $fields, ['id' => $public_contact["id"]], $old_contact);
+ DBA::update('contact', $fields, ['id' => $public_contact["id"]], $old_contact);
}
}
use Friendica\BaseObject;
use Friendica\Core\L10n;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
require_once 'boot.php';
// all the old members are gone, but the group remains so we don't break any security
// access lists. What we're doing here is reviving the dead group, but old content which
// was restricted to this group may now be seen by the new group members.
- $group = dba::selectFirst('group', ['deleted'], ['id' => $gid]);
+ $group = DBA::selectFirst('group', ['deleted'], ['id' => $gid]);
if (DBM::is_result($group) && $group['deleted']) {
- dba::update('group', ['deleted' => 0], ['id' => $gid]);
+ DBA::update('group', ['deleted' => 0], ['id' => $gid]);
notice(L10n::t('A deleted group with this name was revived. Existing item permissions <strong>may</strong> apply to this group and any future members. If this is not what you intended, please create another group with a different name.') . EOL);
}
return true;
}
- $return = dba::insert('group', ['uid' => $uid, 'name' => $name]);
+ $return = DBA::insert('group', ['uid' => $uid, 'name' => $name]);
if ($return) {
- $return = dba::lastInsertId();
+ $return = DBA::lastInsertId();
}
}
return $return;
*/
public static function update($id, $name)
{
- return dba::update('group', ['name' => $name], ['id' => $id]);
+ return DBA::update('group', ['name' => $name], ['id' => $id]);
}
/**
public static function getIdsByContactId($cid)
{
$condition = ['contact-id' => $cid];
- $stmt = dba::select('group_member', ['gid'], $condition);
+ $stmt = DBA::select('group_member', ['gid'], $condition);
$return = [];
- while ($group = dba::fetch($stmt)) {
+ while ($group = DBA::fetch($stmt)) {
$return[] = $group['gid'];
}
*/
public static function countUnseen()
{
- $stmt = dba::p("SELECT `group`.`id`, `group`.`name`,
+ $stmt = DBA::p("SELECT `group`.`id`, `group`.`name`,
(SELECT COUNT(*) FROM `item` FORCE INDEX (`uid_unseen_contactid`)
WHERE `uid` = ?
AND `unseen`
local_user()
);
- return dba::inArray($stmt);
+ return DBA::inArray($stmt);
}
/**
return false;
}
- $group = dba::selectFirst('group', ['id'], ['uid' => $uid, 'name' => $name]);
+ $group = DBA::selectFirst('group', ['id'], ['uid' => $uid, 'name' => $name]);
if (DBM::is_result($group)) {
return $group['id'];
}
return false;
}
- $group = dba::selectFirst('group', ['uid'], ['id' => $gid]);
+ $group = DBA::selectFirst('group', ['uid'], ['id' => $gid]);
if (!DBM::is_result($group)) {
return false;
}
// remove group from default posting lists
- $user = dba::selectFirst('user', ['def_gid', 'allow_gid', 'deny_gid'], ['uid' => $group['uid']]);
+ $user = DBA::selectFirst('user', ['def_gid', 'allow_gid', 'deny_gid'], ['uid' => $group['uid']]);
if (DBM::is_result($user)) {
$change = false;
}
if ($change) {
- dba::update('user', $user, ['uid' => $group['uid']]);
+ DBA::update('user', $user, ['uid' => $group['uid']]);
}
}
// remove all members
- dba::delete('group_member', ['gid' => $gid]);
+ DBA::delete('group_member', ['gid' => $gid]);
// remove group
- $return = dba::update('group', ['deleted' => 1], ['id' => $gid]);
+ $return = DBA::update('group', ['deleted' => 1], ['id' => $gid]);
return $return;
}
return false;
}
- $row_exists = dba::exists('group_member', ['gid' => $gid, 'contact-id' => $cid]);
+ $row_exists = DBA::exists('group_member', ['gid' => $gid, 'contact-id' => $cid]);
if ($row_exists) {
// Row already existing, nothing to do
$return = true;
} else {
- $return = dba::insert('group_member', ['gid' => $gid, 'contact-id' => $cid]);
+ $return = DBA::insert('group_member', ['gid' => $gid, 'contact-id' => $cid]);
}
return $return;
return false;
}
- $return = dba::delete('group_member', ['gid' => $gid, 'contact-id' => $cid]);
+ $return = DBA::delete('group_member', ['gid' => $gid, 'contact-id' => $cid]);
return $return;
}
$stmt = call_user_func_array('dba::p', $param_arr);
} else {
$condition_array = array_merge([$condition], $group_ids);
- $stmt = dba::select('group_member', ['contact-id'], $condition_array);
+ $stmt = DBA::select('group_member', ['contact-id'], $condition_array);
}
$return = [];
- while($group_member = dba::fetch($stmt)) {
+ while($group_member = DBA::fetch($stmt)) {
$return[] = $group_member['contact-id'];
}
{
$o = '';
- $stmt = dba::select('group', [], ['deleted' => 0, 'uid' => $uid], ['order' => ['name']]);
+ $stmt = DBA::select('group', [], ['deleted' => 0, 'uid' => $uid], ['order' => ['name']]);
$display_groups = [
[
'selected' => ''
]
];
- while ($group = dba::fetch($stmt)) {
+ while ($group = DBA::fetch($stmt)) {
$display_groups[] = [
'name' => $group['name'],
'id' => $group['id'],
]
];
- $stmt = dba::select('group', [], ['deleted' => 0, 'uid' => local_user()], ['order' => ['name']]);
+ $stmt = DBA::select('group', [], ['deleted' => 0, 'uid' => local_user()], ['order' => ['name']]);
$member_of = [];
if ($cid) {
$member_of = self::getIdsByContactId($cid);
}
- while ($group = dba::fetch($stmt)) {
+ while ($group = DBA::fetch($stmt)) {
$selected = (($group_id == $group['id']) ? ' group-selected' : '');
if ($editmode == 'full') {
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Core\Worker;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Object\Image;
use Friendica\Protocol\Diaspora;
*/
public static function fetch($stmt)
{
- $row = dba::fetch($stmt);
+ $row = DBA::fetch($stmt);
if (is_bool($row)) {
return $row;
$data[] = $row;
}
if ($do_close) {
- dba::close($stmt);
+ DBA::close($stmt);
}
return $data;
}
if (is_bool($stmt)) {
$retval = $stmt;
} else {
- $retval = (dba::num_rows($stmt) > 0);
+ $retval = (DBA::num_rows($stmt) > 0);
}
- dba::close($stmt);
+ DBA::close($stmt);
return $retval;
}
* @param array $condition
* @param array $params
* @return bool|array
- * @see dba::select
+ * @see DBA::select
*/
public static function selectFirstForUser($uid, array $selected = [], array $condition = [], $params = [])
{
* @param array $condition
* @param array $params
* @return bool|array
- * @see dba::select
+ * @see DBA::select
*/
public static function selectFirst(array $fields = [], array $condition = [], $params = [])
{
return $result;
} else {
$row = self::fetch($result);
- dba::close($result);
+ DBA::close($result);
return $row;
}
}
$select_fields = self::constructSelectFields($fields, $selected);
- $condition_string = dba::buildCondition($condition);
+ $condition_string = DBA::buildCondition($condition);
$condition_string = self::addTablesToFields($condition_string, $fields);
$condition_string = $condition_string . ' AND ' . self::condition(false);
}
- $param_string = self::addTablesToFields(dba::buildParameter($params), $fields);
+ $param_string = self::addTablesToFields(DBA::buildParameter($params), $fields);
$table = "`item` " . self::constructJoins($uid, $select_fields . $condition_string . $param_string, false, $usermode);
$sql = "SELECT " . $select_fields . " FROM " . $table . $condition_string . $param_string;
- return dba::p($sql, $condition);
+ return DBA::p($sql, $condition);
}
/**
* @param array $condition
* @param array $params
* @return bool|array
- * @see dba::select
+ * @see DBA::select
*/
public static function selectFirstThreadForUser($uid, array $selected = [], array $condition = [], $params = [])
{
* @param array $condition
* @param array $params
* @return bool|array
- * @see dba::select
+ * @see DBA::select
*/
public static function selectFirstThread(array $fields = [], array $condition = [], $params = [])
{
return $result;
} else {
$row = self::fetch($result);
- dba::close($result);
+ DBA::close($result);
return $row;
}
}
$select_fields = self::constructSelectFields($fields, $selected);
- $condition_string = dba::buildCondition($condition);
+ $condition_string = DBA::buildCondition($condition);
$condition_string = self::addTablesToFields($condition_string, $threadfields);
$condition_string = self::addTablesToFields($condition_string, $fields);
$condition_string = $condition_string . ' AND ' . self::condition(true);
}
- $param_string = dba::buildParameter($params);
+ $param_string = DBA::buildParameter($params);
$param_string = self::addTablesToFields($param_string, $threadfields);
$param_string = self::addTablesToFields($param_string, $fields);
$sql = "SELECT " . $select_fields . " FROM " . $table . $condition_string . $param_string;
- return dba::p($sql, $condition);
+ return DBA::p($sql, $condition);
}
/**
}
// To ensure the data integrity we do it in an transaction
- dba::transaction();
+ DBA::transaction();
// We cannot simply expand the condition to check for origin entries
// The condition needn't to be a simple array but could be a complex condition.
// And we have to execute this query before the update to ensure to fetch the same data.
- $items = dba::select('item', ['id', 'origin', 'uri', 'created', 'uri-hash', 'iaid', 'icid', 'tag', 'file'], $condition);
+ $items = DBA::select('item', ['id', 'origin', 'uri', 'created', 'uri-hash', 'iaid', 'icid', 'tag', 'file'], $condition);
$content_fields = [];
foreach (array_merge(self::CONTENT_FIELDLIST, self::MIXED_CONTENT_FIELDLIST) as $field) {
$fields['inform'] = null;
if (!empty($fields)) {
- $success = dba::update('item', $fields, $condition);
+ $success = DBA::update('item', $fields, $condition);
if (!$success) {
- dba::close($items);
- dba::rollback();
+ DBA::close($items);
+ DBA::rollback();
return false;
}
}
// When there is no content for the "old" item table, this will count the fetched items
- $rows = dba::affected_rows();
+ $rows = DBA::affected_rows();
- while ($item = dba::fetch($items)) {
+ while ($item = DBA::fetch($items)) {
// This part here can safely be removed when the legacy fields in the item had been removed
if (empty($item['uri-hash']) && !empty($item['uri']) && !empty($item['created'])) {
// Fetch the uri-hash from an existing item entry if there is one
$item_condition = ["`uri` = ? AND `uri-hash` != ''", $item['uri']];
- $existing = dba::selectfirst('item', ['uri-hash'], $item_condition);
+ $existing = DBA::selectfirst('item', ['uri-hash'], $item_condition);
if (DBM::is_result($existing)) {
$item['uri-hash'] = $existing['uri-hash'];
} else {
$item['uri-hash'] = self::itemHash($item['uri'], $item['created']);
}
- dba::update('item', ['uri-hash' => $item['uri-hash']], ['id' => $item['id']]);
- dba::update('item-activity', ['uri-hash' => $item['uri-hash']], ["`uri` = ? AND `uri-hash` = ''", $item['uri']]);
- dba::update('item-content', ['uri-plink-hash' => $item['uri-hash']], ["`uri` = ? AND `uri-plink-hash` = ''", $item['uri']]);
+ DBA::update('item', ['uri-hash' => $item['uri-hash']], ['id' => $item['id']]);
+ DBA::update('item-activity', ['uri-hash' => $item['uri-hash']], ["`uri` = ? AND `uri-hash` = ''", $item['uri']]);
+ DBA::update('item-content', ['uri-plink-hash' => $item['uri-hash']], ["`uri` = ? AND `uri-plink-hash` = ''", $item['uri']]);
}
if (!empty($item['iaid']) || (!empty($content_fields['verb']) && (self::activityToIndex($content_fields['verb']) >= 0))) {
self::updateActivity($content_fields, $update_condition);
if (empty($item['iaid'])) {
- $item_activity = dba::selectFirst('item-activity', ['id'], ['uri-hash' => $item['uri-hash']]);
+ $item_activity = DBA::selectFirst('item-activity', ['id'], ['uri-hash' => $item['uri-hash']]);
if (DBM::is_result($item_activity)) {
$item_fields = ['iaid' => $item_activity['id'], 'icid' => null];
foreach (self::MIXED_CONTENT_FIELDLIST as $field) {
unset($item_fields[$field]);
}
}
- dba::update('item', $item_fields, ['id' => $item['id']]);
+ DBA::update('item', $item_fields, ['id' => $item['id']]);
- if (!empty($item['icid']) && !dba::exists('item', ['icid' => $item['icid']])) {
- dba::delete('item-content', ['id' => $item['icid']]);
+ if (!empty($item['icid']) && !DBA::exists('item', ['icid' => $item['icid']])) {
+ DBA::delete('item-content', ['id' => $item['icid']]);
}
}
} elseif (!empty($item['icid'])) {
- dba::update('item', ['icid' => null], ['id' => $item['id']]);
+ DBA::update('item', ['icid' => null], ['id' => $item['id']]);
- if (!dba::exists('item', ['icid' => $item['icid']])) {
- dba::delete('item-content', ['id' => $item['icid']]);
+ if (!DBA::exists('item', ['icid' => $item['icid']])) {
+ DBA::delete('item-content', ['id' => $item['icid']]);
}
}
} else {
self::updateContent($content_fields, $update_condition);
if (empty($item['icid'])) {
- $item_content = dba::selectFirst('item-content', [], ['uri-plink-hash' => $item['uri-hash']]);
+ $item_content = DBA::selectFirst('item-content', [], ['uri-plink-hash' => $item['uri-hash']]);
if (DBM::is_result($item_content)) {
$item_fields = ['icid' => $item_content['id']];
// Clear all fields in the item table that have a content in the item-content table
}
}
}
- dba::update('item', $item_fields, ['id' => $item['id']]);
+ DBA::update('item', $item_fields, ['id' => $item['id']]);
}
}
}
if (!empty($tags)) {
Term::insertFromTagFieldByItemId($item['id'], $tags);
if (!empty($item['tag'])) {
- dba::update('item', ['tag' => ''], ['id' => $item['id']]);
+ DBA::update('item', ['tag' => ''], ['id' => $item['id']]);
}
}
if (!empty($files)) {
Term::insertFromFileFieldByItemId($item['id'], $files);
if (!empty($item['file'])) {
- dba::update('item', ['file' => ''], ['id' => $item['id']]);
+ DBA::update('item', ['file' => ''], ['id' => $item['id']]);
}
}
}
}
- dba::close($items);
- dba::commit();
+ DBA::close($items);
+ DBA::commit();
return $rows;
}
*/
public static function delete($condition, $priority = PRIORITY_HIGH)
{
- $items = dba::select('item', ['id'], $condition);
- while ($item = dba::fetch($items)) {
+ $items = DBA::select('item', ['id'], $condition);
+ while ($item = DBA::fetch($items)) {
self::deleteById($item['id'], $priority);
}
- dba::close($items);
+ DBA::close($items);
}
/**
return;
}
- $items = dba::select('item', ['id', 'uid'], $condition);
- while ($item = dba::fetch($items)) {
+ $items = DBA::select('item', ['id', 'uid'], $condition);
+ while ($item = DBA::fetch($items)) {
// "Deleting" global items just means hiding them
if ($item['uid'] == 0) {
- dba::update('user-item', ['hidden' => true], ['iid' => $item['id'], 'uid' => $uid], true);
+ DBA::update('user-item', ['hidden' => true], ['iid' => $item['id'], 'uid' => $uid], true);
} elseif ($item['uid'] == $uid) {
self::deleteById($item['id'], PRIORITY_HIGH);
} else {
logger('Wrong ownership. Not deleting item ' . $item['id']);
}
}
- dba::close($items);
+ DBA::close($items);
}
/**
* generate a resource-id and therefore aren't intimately linked to the item.
*/
if (strlen($item['resource-id'])) {
- dba::delete('photo', ['resource-id' => $item['resource-id'], 'uid' => $item['uid']]);
+ DBA::delete('photo', ['resource-id' => $item['resource-id'], 'uid' => $item['uid']]);
}
// If item is a link to an event, delete the event.
foreach (explode(", ", $item['attach']) as $attach) {
preg_match("|attach/(\d+)|", $attach, $matches);
if (is_array($matches) && count($matches) > 1) {
- dba::delete('attach', ['id' => $matches[1], 'uid' => $item['uid']]);
+ DBA::delete('attach', ['id' => $matches[1], 'uid' => $item['uid']]);
}
}
$item_fields = ['deleted' => true, 'edited' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow(),
'body' => '', 'title' => '', 'content-warning' => '', 'rendered-hash' => '', 'rendered-html' => '',
'object' => '', 'target' => '', 'tag' => '', 'postopts' => '', 'attach' => '', 'file' => ''];
- dba::update('item', $item_fields, ['id' => $item['id']]);
+ DBA::update('item', $item_fields, ['id' => $item['id']]);
Term::insertFromTagFieldByItemId($item['id'], '');
Term::insertFromFileFieldByItemId($item['id'], '');
self::delete(['uri' => $item['uri'], 'uid' => 0, 'deleted' => false], $priority);
}
- dba::delete('item-delivery-data', ['iid' => $item['id']]);
+ DBA::delete('item-delivery-data', ['iid' => $item['id']]);
// If it's the parent of a comment thread, kill all the kids
if ($item['id'] == $item['parent']) {
// When we delete just our local user copy of an item, we have to set a marker to hide it
$global_item = self::selectFirst(['id'], ['uri' => $item['uri'], 'uid' => 0, 'deleted' => false]);
if (DBM::is_result($global_item)) {
- dba::update('user-item', ['hidden' => true], ['iid' => $global_item['id'], 'uid' => $item['uid']], true);
+ DBA::update('user-item', ['hidden' => true], ['iid' => $global_item['id'], 'uid' => $item['uid']], true);
}
}
// Still missing? Then use the "self" contact of the current user
if ($contact_id == 0) {
- $self = dba::selectFirst('contact', ['id'], ['self' => true, 'uid' => $item['uid']]);
+ $self = DBA::selectFirst('contact', ['id'], ['self' => true, 'uid' => $item['uid']]);
if (DBM::is_result($self)) {
$contact_id = $self["id"];
}
// check for create date and expire time
$expire_interval = Config::get('system', 'dbclean-expire-days', 0);
- $user = dba::selectFirst('user', ['expire'], ['uid' => $uid]);
+ $user = DBA::selectFirst('user', ['expire'], ['uid' => $uid]);
if (DBM::is_result($user) && ($user['expire'] > 0) && (($user['expire'] < $expire_interval) || ($expire_interval == 0))) {
$expire_interval = $user['expire'];
}
}
// Ensure to always have the same creation date.
- $existing = dba::selectfirst('item', ['created', 'uri-hash'], ['uri' => $item['uri']]);
+ $existing = DBA::selectfirst('item', ['created', 'uri-hash'], ['uri' => $item['uri']]);
if (DBM::is_result($existing)) {
$item['created'] = $existing['created'];
$item['uri-hash'] = $existing['uri-hash'];
// If its a post from myself then tag the thread as "mention"
logger("Checking if parent ".$parent_id." has to be tagged as mention for user ".$item['uid'], LOGGER_DEBUG);
- $user = dba::selectFirst('user', ['nickname'], ['uid' => $item['uid']]);
+ $user = DBA::selectFirst('user', ['nickname'], ['uid' => $item['uid']]);
if (DBM::is_result($user)) {
$self = normalise_link(System::baseUrl() . '/profile/' . $user['nickname']);
$self_id = Contact::getIdForURL($self, 0, true);
logger("'myself' is ".$self_id." for parent ".$parent_id." checking against ".$item['author-id']." and ".$item['owner-id'], LOGGER_DEBUG);
if (($item['author-id'] == $self_id) || ($item['owner-id'] == $self_id)) {
- dba::update('thread', ['mention' => true], ['iid' => $parent_id]);
+ DBA::update('thread', ['mention' => true], ['iid' => $parent_id]);
logger("tagged thread ".$parent_id." as mention for user ".$self, LOGGER_DEBUG);
}
}
$item["global"] = true;
// Set the global flag on all items if this was a global item entry
- dba::update('item', ['global' => true], ['uri' => $item["uri"]]);
+ DBA::update('item', ['global' => true], ['uri' => $item["uri"]]);
} else {
$item["global"] = self::exists(['uid' => 0, 'uri' => $item["uri"]]);
}
unset($item['postopts']);
unset($item['inform']);
- dba::transaction();
- $ret = dba::insert('item', $item);
+ DBA::transaction();
+ $ret = DBA::insert('item', $item);
// When the item was successfully stored we fetch the ID of the item.
if (DBM::is_result($ret)) {
- $current_post = dba::lastInsertId();
+ $current_post = DBA::lastInsertId();
} else {
// This can happen - for example - if there are locking timeouts.
- dba::rollback();
+ DBA::rollback();
// Store the data into a spool file so that we can try again later.
if ($current_post == 0) {
// This is one of these error messages that never should occur.
logger("couldn't find created item - we better quit now.");
- dba::rollback();
+ DBA::rollback();
return 0;
}
// How much entries have we created?
// We wouldn't need this query when we could use an unique index - but MySQL has length problems with them.
- $entries = dba::count('item', ['uri' => $item['uri'], 'uid' => $item['uid'], 'network' => $item['network']]);
+ $entries = DBA::count('item', ['uri' => $item['uri'], 'uid' => $item['uid'], 'network' => $item['network']]);
if ($entries > 1) {
// There are duplicates. We delete our just created entry.
logger('Duplicated post occurred. uri = ' . $item['uri'] . ' uid = ' . $item['uid']);
// Yes, we could do a rollback here - but we are having many users with MyISAM.
- dba::delete('item', ['id' => $current_post]);
- dba::commit();
+ DBA::delete('item', ['id' => $current_post]);
+ DBA::commit();
return 0;
} elseif ($entries == 0) {
// This really should never happen since we quit earlier if there were problems.
logger("Something is terribly wrong. We haven't found our created entry.");
- dba::rollback();
+ DBA::rollback();
return 0;
}
}
// Set parent id
- dba::update('item', ['parent' => $parent_id], ['id' => $current_post]);
+ DBA::update('item', ['parent' => $parent_id], ['id' => $current_post]);
$item['id'] = $current_post;
$item['parent'] = $parent_id;
// update the commented timestamp on the parent
// Only update "commented" if it is really a comment
if (($item['gravity'] != GRAVITY_ACTIVITY) || !Config::get("system", "like_no_comment")) {
- dba::update('item', ['commented' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]);
+ DBA::update('item', ['commented' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]);
} else {
- dba::update('item', ['changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]);
+ DBA::update('item', ['changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]);
}
if ($dsprsig) {
logger("Repaired double encoded signature from handle ".$dsprsig->signer, LOGGER_DEBUG);
}
- dba::insert('sign', ['iid' => $current_post, 'signed_text' => $dsprsig->signed_text,
+ DBA::insert('sign', ['iid' => $current_post, 'signed_text' => $dsprsig->signed_text,
'signature' => $dsprsig->signature, 'signer' => $dsprsig->signer]);
}
if (!empty($diaspora_signed_text)) {
// Formerly we stored the signed text, the signature and the author in different fields.
// We now store the raw data so that we are more flexible.
- dba::insert('sign', ['iid' => $current_post, 'signed_text' => $diaspora_signed_text]);
+ DBA::insert('sign', ['iid' => $current_post, 'signed_text' => $diaspora_signed_text]);
}
$deleted = self::tagDeliver($item['uid'], $current_post);
self::insertDeliveryData($delivery_data);
- dba::commit();
+ DBA::commit();
/*
* Due to deadlock issues with the "term" table we are doing these steps after the commit.
return;
}
- dba::insert('item-delivery-data', $delivery_data);
+ DBA::insert('item-delivery-data', $delivery_data);
}
/**
return;
}
- dba::update('item-delivery-data', $delivery_data, ['iid' => $id], true);
+ DBA::update('item-delivery-data', $delivery_data, ['iid' => $id], true);
}
/**
}
// Do we already have this content?
- $item_activity = dba::selectFirst('item-activity', ['id'], ['uri-hash' => $item['uri-hash']]);
+ $item_activity = DBA::selectFirst('item-activity', ['id'], ['uri-hash' => $item['uri-hash']]);
if (DBM::is_result($item_activity)) {
$item['iaid'] = $item_activity['id'];
logger('Fetched activity for URI ' . $item['uri'] . ' (' . $item['iaid'] . ')');
- } elseif (dba::insert('item-activity', $fields)) {
- $item['iaid'] = dba::lastInsertId();
+ } elseif (DBA::insert('item-activity', $fields)) {
+ $item['iaid'] = DBA::lastInsertId();
logger('Inserted activity for URI ' . $item['uri'] . ' (' . $item['iaid'] . ')');
} else {
// This shouldn't happen.
}
// Do we already have this content?
- $item_content = dba::selectFirst('item-content', ['id'], ['uri-plink-hash' => $item['uri-hash']]);
+ $item_content = DBA::selectFirst('item-content', ['id'], ['uri-plink-hash' => $item['uri-hash']]);
if (DBM::is_result($item_content)) {
$item['icid'] = $item_content['id'];
logger('Fetched content for URI ' . $item['uri'] . ' (' . $item['icid'] . ')');
- } elseif (dba::insert('item-content', $fields)) {
- $item['icid'] = dba::lastInsertId();
+ } elseif (DBA::insert('item-content', $fields)) {
+ $item['icid'] = DBA::lastInsertId();
logger('Inserted content for URI ' . $item['uri'] . ' (' . $item['icid'] . ')');
} else {
// This shouldn't happen.
logger('Update activity for ' . json_encode($condition));
- dba::update('item-activity', $fields, $condition, true);
+ DBA::update('item-activity', $fields, $condition, true);
return true;
}
logger('Update content for ' . json_encode($condition));
- dba::update('item-content', $fields, $condition, true);
+ DBA::update('item-content', $fields, $condition, true);
}
/**
$condition = ["`nurl` IN (SELECT `nurl` FROM `contact` WHERE `id` = ?) AND `uid` != 0 AND NOT `blocked` AND `rel` IN (?, ?)",
$parent['owner-id'], CONTACT_IS_SHARING, CONTACT_IS_FRIEND];
- $contacts = dba::select('contact', ['uid'], $condition);
- while ($contact = dba::fetch($contacts)) {
+ $contacts = DBA::select('contact', ['uid'], $condition);
+ while ($contact = DBA::fetch($contacts)) {
$users[$contact['uid']] = $contact['uid'];
}
if ($item['uri'] != $item['parent-uri']) {
$parents = self::select(['uid', 'origin'], ["`uri` = ? AND `uid` != 0", $item['parent-uri']]);
- while ($parent = dba::fetch($parents)) {
+ while ($parent = DBA::fetch($parents)) {
$users[$parent['uid']] = $parent['uid'];
if ($parent['origin'] && !$origin) {
$origin_uid = $parent['uid'];
}
if (empty($item['contact-id'])) {
- $self = dba::selectFirst('contact', ['id'], ['self' => true, 'uid' => $uid]);
+ $self = DBA::selectFirst('contact', ['id'], ['self' => true, 'uid' => $uid]);
if (!DBM::is_result($self)) {
return;
}
$notify = false;
if ($item['uri'] == $item['parent-uri']) {
- $contact = dba::selectFirst('contact', [], ['id' => $item['contact-id'], 'self' => false]);
+ $contact = DBA::selectFirst('contact', [], ['id' => $item['contact-id'], 'self' => false]);
if (DBM::is_result($contact)) {
$notify = self::isRemoteSelf($contact, $item);
}
$hostname = self::getApp()->get_hostname();
- $user = dba::selectFirst('user', ['nickname'], ['uid' => $uid]);
+ $user = DBA::selectFirst('user', ['nickname'], ['uid' => $uid]);
$uri = "urn:X-dfrn:" . $hostname . ':' . $user['nickname'] . ':' . $guid;
private static function updateContact($arr)
{
// Unarchive the author
- $contact = dba::selectFirst('contact', [], ['id' => $arr["author-id"]]);
+ $contact = DBA::selectFirst('contact', [], ['id' => $arr["author-id"]]);
if (DBM::is_result($contact)) {
Contact::unmarkForArchival($contact);
}
// Unarchive the contact if it's not our own contact
- $contact = dba::selectFirst('contact', [], ['id' => $arr["contact-id"], 'self' => false]);
+ $contact = DBA::selectFirst('contact', [], ['id' => $arr["contact-id"], 'self' => false]);
if (DBM::is_result($contact)) {
Contact::unmarkForArchival($contact);
}
// Is it a forum? Then we don't care about the rules from above
if (!$update && ($arr["network"] == NETWORK_DFRN) && ($arr["parent-uri"] === $arr["uri"])) {
- if (dba::exists('contact', ['id' => $arr['contact-id'], 'forum' => true])) {
+ if (DBA::exists('contact', ['id' => $arr['contact-id'], 'forum' => true])) {
$update = true;
}
}
if ($update) {
- dba::update('contact', ['success_update' => $arr['received'], 'last-item' => $arr['received']],
+ DBA::update('contact', ['success_update' => $arr['received'], 'last-item' => $arr['received']],
['id' => $arr['contact-id']]);
}
// Now do the same for the system wide contacts with uid=0
if (!$arr['private']) {
- dba::update('contact', ['success_update' => $arr['received'], 'last-item' => $arr['received']],
+ DBA::update('contact', ['success_update' => $arr['received'], 'last-item' => $arr['received']],
['id' => $arr['owner-id']]);
if ($arr['owner-id'] != $arr['author-id']) {
- dba::update('contact', ['success_update' => $arr['received'], 'last-item' => $arr['received']],
+ DBA::update('contact', ['success_update' => $arr['received'], 'last-item' => $arr['received']],
['id' => $arr['author-id']]);
}
}
// Does the given user have this item?
if ($uid) {
- $item = dba::fetch_first("SELECT `item`.`id`, `user`.`nickname` FROM `item`
+ $item = DBA::fetch_first("SELECT `item`.`id`, `user`.`nickname` FROM `item`
INNER JOIN `user` ON `user`.`uid` = `item`.`uid`
WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
AND `item`.`guid` = ? AND `item`.`uid` = ?", $guid, $uid);
// Or is it anywhere on the server?
if ($nick == "") {
- $item = dba::fetch_first("SELECT `item`.`id`, `user`.`nickname` FROM `item`
+ $item = DBA::fetch_first("SELECT `item`.`id`, `user`.`nickname` FROM `item`
INNER JOIN `user` ON `user`.`uid` = `item`.`uid`
WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
AND NOT `item`.`private` AND `item`.`wall`
{
$mention = false;
- $user = dba::selectFirst('user', [], ['uid' => $uid]);
+ $user = DBA::selectFirst('user', [], ['uid' => $uid]);
if (!DBM::is_result($user)) {
return;
}
// mmh.. no mention.. community page or private group... no wall.. no origin.. top-post (not a comment)
// delete it!
logger("no-mention top-level post to community or private group. delete.");
- dba::delete('item', ['id' => $item_id]);
+ DBA::delete('item', ['id' => $item_id]);
return true;
}
return;
}
// now change this copy of the post to a forum head message and deliver to all the tgroup members
- $self = dba::selectFirst('contact', ['id', 'name', 'url', 'thumb'], ['uid' => $uid, 'self' => true]);
+ $self = DBA::selectFirst('contact', ['id', 'name', 'url', 'thumb'], ['uid' => $uid, 'self' => true]);
if (!DBM::is_result($self)) {
return;
}
$fields = ['wall' => true, 'origin' => true, 'forum_mode' => $forum_mode, 'contact-id' => $self['id'],
'owner-id' => $owner_id, 'owner-link' => $self['url'], 'private' => $private, 'allow_cid' => $user['allow_cid'],
'allow_gid' => $user['allow_gid'], 'deny_cid' => $user['deny_cid'], 'deny_gid' => $user['deny_gid']];
- dba::update('item', $fields, ['id' => $item_id]);
+ DBA::update('item', $fields, ['id' => $item_id]);
self::updateThread($item_id);
$datarray2 = $datarray;
logger('remote-self start - Contact '.$contact['url'].' - '.$contact['remote_self'].' Item '.print_r($datarray, true), LOGGER_DEBUG);
if ($contact['remote_self'] == 2) {
- $self = dba::selectFirst('contact', ['id', 'name', 'url', 'thumb'],
+ $self = DBA::selectFirst('contact', ['id', 'name', 'url', 'thumb'],
['uid' => $contact['uid'], 'self' => true]);
if (DBM::is_result($self)) {
$datarray['contact-id'] = $self["id"];
$res = substr($i, $x + 1);
$i = substr($i, 0, $x);
$fields = ['data', 'type', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'];
- $photo = dba::selectFirst('photo', $fields, ['resource-id' => $i, 'scale' => $res, 'uid' => $uid]);
+ $photo = DBA::selectFirst('photo', $fields, ['resource-id' => $i, 'scale' => $res, 'uid' => $uid]);
if (DBM::is_result($photo)) {
/*
* Check to see if we should replace this photo link with an embedded image
++$expired;
}
- dba::close($items);
+ DBA::close($items);
logger('User ' . $uid . ": expired $expired items; expire items: $expire_items, expire notes: $expire_notes, expire starred: $expire_starred, expire photos: $expire_photos");
}
{
$condition = ['uid' => $uid, 'wall' => $wall, 'deleted' => false, 'visible' => true, 'moderated' => false];
$params = ['order' => ['created' => false]];
- $thread = dba::selectFirst('thread', ['created'], $condition, $params);
+ $thread = DBA::selectFirst('thread', ['created'], $condition, $params);
if (DBM::is_result($thread)) {
return substr(DateTimeFormat::local($thread['created']), 0, 10);
}
}
// Retrieves the local post owner
- $owner_self_contact = dba::selectFirst('contact', [], ['uid' => $uid, 'self' => true]);
+ $owner_self_contact = DBA::selectFirst('contact', [], ['uid' => $uid, 'self' => true]);
if (!DBM::is_result($owner_self_contact)) {
logger('like: unknown owner ' . $uid);
return false;
// Retrieve the current logged in user's public contact
$author_id = public_contact();
- $author_contact = dba::selectFirst('contact', ['url'], ['id' => $author_id]);
+ $author_contact = DBA::selectFirst('contact', ['url'], ['id' => $author_id]);
if (!DBM::is_result($author_contact)) {
logger('like: unknown author ' . $author_id);
return false;
$item_contact = $owner_self_contact;
} else {
$item_contact_id = Contact::getIdForURL($author_contact['url'], $uid, true);
- $item_contact = dba::selectFirst('contact', [], ['id' => $item_contact_id]);
+ $item_contact = DBA::selectFirst('contact', [], ['id' => $item_contact_id]);
if (!DBM::is_result($item_contact)) {
logger('like: unknown item contact ' . $item_contact_id);
return false;
// Already voted, undo it
$fields = ['deleted' => true, 'unseen' => true, 'changed' => DateTimeFormat::utcNow()];
/// @todo Consider using self::update - but before doing so, check the side effects
- dba::update('item', $fields, ['id' => $like_item['id']]);
+ DBA::update('item', $fields, ['id' => $like_item['id']]);
// Clean up the Diaspora signatures for this like
- dba::delete('sign', ['iid' => $like_item['id']]);
+ DBA::delete('sign', ['iid' => $like_item['id']]);
Worker::add(PRIORITY_HIGH, "Notifier", "like", $like_item['id']);
$item['iid'] = $itemid;
if (!$onlyshadow) {
- $result = dba::insert('thread', $item);
+ $result = DBA::insert('thread', $item);
logger("Add thread for item ".$itemid." - ".print_r($result, true), LOGGER_DEBUG);
}
}
}
- $result = dba::update('thread', $fields, ['iid' => $itemid]);
+ $result = DBA::update('thread', $fields, ['iid' => $itemid]);
logger("Update thread for item ".$itemid." - guid ".$item["guid"]." - ".(int)$result, LOGGER_DEBUG);
}
private static function deleteThread($itemid, $itemuri = "")
{
- $item = dba::selectFirst('thread', ['uid'], ['iid' => $itemid]);
+ $item = DBA::selectFirst('thread', ['uid'], ['iid' => $itemid]);
if (!DBM::is_result($item)) {
logger('No thread found for id '.$itemid, LOGGER_DEBUG);
return;
}
// Using dba::delete at this time could delete the associated item entries
- $result = dba::e("DELETE FROM `thread` WHERE `iid` = ?", $itemid);
+ $result = DBA::e("DELETE FROM `thread` WHERE `iid` = ?", $itemid);
logger("deleteThread: Deleted thread for item ".$itemid." - ".print_r($result, true), LOGGER_DEBUG);
if ($itemuri != "") {
$condition = ["`uri` = ? AND NOT `deleted` AND NOT (`uid` IN (?, 0))", $itemuri, $item["uid"]];
if (!self::exists($condition)) {
- dba::delete('item', ['uri' => $itemuri, 'uid' => 0]);
+ DBA::delete('item', ['uri' => $itemuri, 'uid' => 0]);
logger("deleteThread: Deleted shadow for item ".$itemuri, LOGGER_DEBUG);
}
}
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Core\Worker;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Network\Probe;
use Friendica\Util\DateTimeFormat;
$subject = L10n::t('[no subject]');
}
- $me = dba::selectFirst('contact', [], ['uid' => local_user(), 'self' => true]);
- $contact = dba::selectFirst('contact', [], ['id' => $recipient, 'uid' => local_user()]);
+ $me = DBA::selectFirst('contact', [], ['uid' => local_user(), 'self' => true]);
+ $contact = DBA::selectFirst('contact', [], ['id' => $recipient, 'uid' => local_user()]);
if (!(count($me) && (count($contact)))) {
return -2;
$fields = ['uid' => local_user(), 'guid' => $conv_guid, 'creator' => $sender_handle,
'created' => DateTimeFormat::utcNow(), 'updated' => DateTimeFormat::utcNow(),
'subject' => $subject, 'recips' => $handles];
- if (dba::insert('conv', $fields)) {
- $convid = dba::lastInsertId();
+ if (DBA::insert('conv', $fields)) {
+ $convid = DBA::lastInsertId();
}
}
}
$post_id = null;
- $success = dba::insert(
+ $success = DBA::insert(
'mail',
[
'uid' => local_user(),
);
if ($success) {
- $post_id = dba::lastInsertId();
+ $post_id = DBA::lastInsertId();
}
/**
}
$image_uri = substr($image, strrpos($image, '/') + 1);
$image_uri = substr($image_uri, 0, strpos($image_uri, '-'));
- dba::update('photo', ['allow-cid' => '<' . $recipient . '>'], ['resource-id' => $image_uri, 'album' => 'Wall Photos', 'uid' => local_user()]);
+ DBA::update('photo', ['allow-cid' => '<' . $recipient . '>'], ['resource-id' => $image_uri, 'album' => 'Wall Photos', 'uid' => local_user()]);
}
}
}
$fields = ['uid' => $recipient['uid'], 'guid' => $conv_guid, 'creator' => $sender_handle,
'created' => DateTimeFormat::utcNow(), 'updated' => DateTimeFormat::utcNow(),
'subject' => $subject, 'recips' => $handles];
- if (dba::insert('conv', $fields)) {
- $convid = dba::lastInsertId();
+ if (DBA::insert('conv', $fields)) {
+ $convid = DBA::lastInsertId();
}
if (!$convid) {
return -4;
}
- dba::insert(
+ DBA::insert(
'mail',
[
'uid' => $recipient['uid'],
*/
namespace Friendica\Model;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Util\DateTimeFormat;
"meta" => $meta,
"created" => DateTimeFormat::utcNow()
];
- return dba::insert("openwebauth-token", $fields);
+ return DBA::insert("openwebauth-token", $fields);
}
/**
{
$condition = ["type" => $type, "uid" => $uid, "token" => $token];
- $entry = dba::selectFirst("openwebauth-token", ["id", "meta"], $condition);
+ $entry = DBA::selectFirst("openwebauth-token", ["id", "meta"], $condition);
if (DBM::is_result($entry)) {
- dba::delete("openwebauth-token", ["id" => $entry["id"]]);
+ DBA::delete("openwebauth-token", ["id" => $entry["id"]]);
return $entry["meta"];
}
public static function purge($type, $interval)
{
$condition = ["`type` = ? AND `created` < ?", $type, DateTimeFormat::utcNow() . " - INTERVAL " . $interval];
- dba::delete("openwebauth-token", $condition);
+ DBA::delete("openwebauth-token", $condition);
}
}
namespace Friendica\Model;
use Friendica\BaseObject;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
require_once 'include/dba.php';
'deny_cid' => self::sortPermissions(defaults($postarray, 'deny_cid', '')),
'deny_gid' => self::sortPermissions(defaults($postarray, 'deny_gid', ''))];
- $set = dba::selectFirst('permissionset', ['id'], $condition);
+ $set = DBA::selectFirst('permissionset', ['id'], $condition);
if (!DBM::is_result($set)) {
- dba::insert('permissionset', $condition, true);
+ DBA::insert('permissionset', $condition, true);
- $set = dba::selectFirst('permissionset', ['id'], $condition);
+ $set = DBA::selectFirst('permissionset', ['id'], $condition);
}
return $set['id'];
}
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Object\Image;
use Friendica\Util\DateTimeFormat;
*/
public static function store(Image $Image, $uid, $cid, $rid, $filename, $album, $scale, $profile = 0, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '', $desc = '')
{
- $photo = dba::selectFirst('photo', ['guid'], ["`resource-id` = ? AND `guid` != ?", $rid, '']);
+ $photo = DBA::selectFirst('photo', ['guid'], ["`resource-id` = ? AND `guid` != ?", $rid, '']);
if (DBM::is_result($photo)) {
$guid = $photo['guid'];
} else {
$guid = System::createGUID();
}
- $existing_photo = dba::selectFirst('photo', ['id'], ['resource-id' => $rid, 'uid' => $uid, 'contact-id' => $cid, 'scale' => $scale]);
+ $existing_photo = DBA::selectFirst('photo', ['id'], ['resource-id' => $rid, 'uid' => $uid, 'contact-id' => $cid, 'scale' => $scale]);
$fields = [
'uid' => $uid,
];
if (DBM::is_result($existing_photo)) {
- $r = dba::update('photo', $fields, ['id' => $existing_photo['id']]);
+ $r = DBA::update('photo', $fields, ['id' => $existing_photo['id']]);
} else {
- $r = dba::insert('photo', $fields);
+ $r = DBA::insert('photo', $fields);
}
return $r;
$thumb = '';
$micro = '';
- $photo = dba::selectFirst(
+ $photo = DBA::selectFirst(
'photo', ['resource-id'], ['uid' => $uid, 'contact-id' => $cid, 'scale' => 4, 'album' => 'Contact Photos']
);
if (x($photo['resource-id'])) {
namespace Friendica\Model;
use Friendica\BaseObject;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Util\DateTimeFormat;
require_once 'include/dba.php';
$pid = getmypid();
}
- dba::transaction();
+ DBA::transaction();
- if (!dba::exists('process', ['pid' => $pid])) {
- $return = dba::insert('process', ['pid' => $pid, 'command' => $command, 'created' => DateTimeFormat::utcNow()]);
+ if (!DBA::exists('process', ['pid' => $pid])) {
+ $return = DBA::insert('process', ['pid' => $pid, 'command' => $command, 'created' => DateTimeFormat::utcNow()]);
}
- dba::commit();
+ DBA::commit();
return $return;
}
$pid = getmypid();
}
- return dba::delete('process', ['pid' => $pid]);
+ return DBA::delete('process', ['pid' => $pid]);
}
/**
*/
public static function deleteInactive()
{
- dba::transaction();
+ DBA::transaction();
- $processes = dba::select('process', ['pid']);
- while($process = dba::fetch($processes)) {
+ $processes = DBA::select('process', ['pid']);
+ while($process = DBA::fetch($processes)) {
if (!posix_kill($process['pid'], 0)) {
self::deleteByPid($process['pid']);
}
}
- dba::commit();
+ DBA::commit();
}
}
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Core\Worker;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Protocol\Diaspora;
use Friendica\Util\DateTimeFormat;
*/
public static function load(App $a, $nickname, $profile = 0, array $profiledata = [], $show_connect = true)
{
- $user = dba::selectFirst('user', ['uid'], ['nickname' => $nickname, 'account_removed' => false]);
+ $user = DBA::selectFirst('user', ['uid'], ['nickname' => $nickname, 'account_removed' => false]);
if (!DBM::is_result($user) && empty($profiledata)) {
logger('profile error: ' . $a->query_string, LOGGER_DEBUG);
if (remote_user() && count($_SESSION['remote'])) {
foreach ($_SESSION['remote'] as $visitor) {
if ($visitor['uid'] == $uid) {
- $contact = dba::selectFirst('contact', ['profile-id'], ['id' => $visitor['cid']]);
+ $contact = DBA::selectFirst('contact', ['profile-id'], ['id' => $visitor['cid']]);
if (DBM::is_result($contact)) {
$profile_id = $contact['profile-id'];
}
$profile = null;
if ($profile_id) {
- $profile = dba::fetch_first(
+ $profile = DBA::fetch_first(
"SELECT `contact`.`id` AS `contact_id`, `contact`.`photo` AS `contact_photo`,
`contact`.`thumb` AS `contact_thumb`, `contact`.`micro` AS `contact_micro`,
`profile`.`uid` AS `profile_uid`, `profile`.*,
);
}
if (!DBM::is_result($profile)) {
- $profile = dba::fetch_first(
+ $profile = DBA::fetch_first(
"SELECT `contact`.`id` AS `contact_id`, `contact`.`photo` as `contact_photo`,
`contact`.`thumb` AS `contact_thumb`, `contact`.`micro` AS `contact_micro`,
`profile`.`uid` AS `profile_uid`, `profile`.*,
$profile_url = normalise_link(System::baseUrl() . '/profile/' . $profile['nickname']);
}
- if (dba::exists('contact', ['pending' => false, 'uid' => local_user(), 'nurl' => $profile_url])) {
+ if (DBA::exists('contact', ['pending' => false, 'uid' => local_user(), 'nurl' => $profile_url])) {
$connect = false;
}
}
$cachekey = 'get_birthdays:' . local_user();
$r = Cache::get($cachekey);
if (is_null($r)) {
- $s = dba::p(
+ $s = DBA::p(
"SELECT `event`.*, `event`.`id` AS `eid`, `contact`.* FROM `event`
INNER JOIN `contact` ON `contact`.`id` = `event`.`cid`
WHERE `event`.`uid` = ? AND `type` = 'birthday' AND `start` < ? AND `finish` > ?
DateTimeFormat::utcNow()
);
if (DBM::is_result($s)) {
- $r = dba::inArray($s);
+ $r = DBA::inArray($s);
Cache::set($cachekey, $r, CACHE_HOUR);
}
}
$bd_format = L10n::t('g A l F d'); // 8 AM Friday January 18
$classtoday = '';
- $s = dba::p(
+ $s = DBA::p(
"SELECT `event`.*
FROM `event`
INNER JOIN `item`
if (DBM::is_result($s)) {
$istoday = false;
- while ($rr = dba::fetch($s)) {
+ while ($rr = DBA::fetch($s)) {
if (strlen($rr['name'])) {
$total ++;
}
$r[] = $rr;
}
- dba::close($s);
+ DBA::close($s);
$classtoday = (($istoday) ? 'event-today' : '');
}
$tpl = get_markup_template('events_reminder.tpl');
return;
}
- $contact = dba::selectFirst('contact',['id', 'url'], ['id' => $cid]);
+ $contact = DBA::selectFirst('contact',['id', 'url'], ['id' => $cid]);
if (DBM::is_result($contact) && remote_user() && remote_user() == $contact['id']) {
// The visitor is already authenticated.
return;
}
- $visitor = dba::selectFirst('contact', [], ['id' => $cid]);
+ $visitor = DBA::selectFirst('contact', [], ['id' => $cid]);
// Authenticate the visitor.
$_SESSION['authenticated'] = 1;
namespace Friendica\Model;
use Friendica\Core\Worker;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Util\DateTimeFormat;
public static function publishFeed($uid, $default_priority = PRIORITY_HIGH)
{
$condition = ['push' => 0, 'uid' => $uid];
- dba::update('push_subscriber', ['push' => 1, 'next_try' => NULL_DATE], $condition);
+ DBA::update('push_subscriber', ['push' => 1, 'next_try' => NULL_DATE], $condition);
self::requeue($default_priority);
}
{
// We'll push to each subscriber that has push > 0,
// i.e. there has been an update (set in notifier.php).
- $subscribers = dba::select('push_subscriber', ['id', 'push', 'callback_url', 'nickname'], ["`push` > 0 AND `next_try` < UTC_TIMESTAMP()"]);
+ $subscribers = DBA::select('push_subscriber', ['id', 'push', 'callback_url', 'nickname'], ["`push` > 0 AND `next_try` < UTC_TIMESTAMP()"]);
- while ($subscriber = dba::fetch($subscribers)) {
+ while ($subscriber = DBA::fetch($subscribers)) {
// We always handle retries with low priority
if ($subscriber['push'] > 1) {
$priority = PRIORITY_LOW;
Worker::add($priority, 'PubSubPublish', (int)$subscriber['id']);
}
- dba::close($subscribers);
+ DBA::close($subscribers);
}
/**
public static function renew($uid, $nick, $subscribe, $hub_callback, $hub_topic, $hub_secret)
{
// fetch the old subscription if it exists
- $subscriber = dba::selectFirst('push_subscriber', ['last_update', 'push'], ['callback_url' => $hub_callback]);
+ $subscriber = DBA::selectFirst('push_subscriber', ['last_update', 'push'], ['callback_url' => $hub_callback]);
// delete old subscription if it exists
- dba::delete('push_subscriber', ['callback_url' => $hub_callback]);
+ DBA::delete('push_subscriber', ['callback_url' => $hub_callback]);
if ($subscribe) {
// if we are just updating an old subscription, keep the
'topic' => $hub_topic, 'nickname' => $nick, 'push' => $push_flag,
'last_update' => $last_update, 'renewed' => DateTimeFormat::utcNow(),
'secret' => $hub_secret];
- dba::insert('push_subscriber', $fields);
+ DBA::insert('push_subscriber', $fields);
logger("Successfully subscribed [$hub_callback] for $nick");
} else {
*/
public static function delay($id)
{
- $subscriber = dba::selectFirst('push_subscriber', ['push', 'callback_url', 'renewed', 'nickname'], ['id' => $id]);
+ $subscriber = DBA::selectFirst('push_subscriber', ['push', 'callback_url', 'renewed', 'nickname'], ['id' => $id]);
if (!DBM::is_result($subscriber)) {
return;
}
$days = round((time() - strtotime($subscriber['renewed'])) / (60 * 60 * 24));
if ($days > 60) {
- dba::update('push_subscriber', ['push' => -1, 'next_try' => NULL_DATE], ['id' => $id]);
+ DBA::update('push_subscriber', ['push' => -1, 'next_try' => NULL_DATE], ['id' => $id]);
logger('Delivery error: Subscription ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' is marked as ended.', LOGGER_DEBUG);
} else {
- dba::update('push_subscriber', ['push' => 0, 'next_try' => NULL_DATE], ['id' => $id]);
+ DBA::update('push_subscriber', ['push' => 0, 'next_try' => NULL_DATE], ['id' => $id]);
logger('Delivery error: Giving up ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' for now.', LOGGER_DEBUG);
}
} else {
$retrial = $retrial + 1;
- dba::update('push_subscriber', ['push' => $retrial, 'next_try' => $next], ['id' => $id]);
+ DBA::update('push_subscriber', ['push' => $retrial, 'next_try' => $next], ['id' => $id]);
logger('Delivery error: Next try (' . $retrial . ') ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' at ' . $next, LOGGER_DEBUG);
}
}
*/
public static function reset($id, $last_update)
{
- $subscriber = dba::selectFirst('push_subscriber', ['callback_url', 'nickname'], ['id' => $id]);
+ $subscriber = DBA::selectFirst('push_subscriber', ['callback_url', 'nickname'], ['id' => $id]);
if (!DBM::is_result($subscriber)) {
return;
}
// set last_update to the 'created' date of the last item, and reset push=0
$fields = ['push' => 0, 'next_try' => NULL_DATE, 'last_update' => $last_update];
- dba::update('push_subscriber', $fields, ['id' => $id]);
+ DBA::update('push_subscriber', $fields, ['id' => $id]);
logger('Subscriber ' . $subscriber['callback_url'] . ' for ' . $subscriber['nickname'] . ' is marked as vital', LOGGER_DEBUG);
}
}
namespace Friendica\Model;
use Friendica\Core\Config;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Util\DateTimeFormat;
public static function updateTime($id)
{
logger('queue: requeue item ' . $id);
- $queue = dba::selectFirst('queue', ['retrial'], ['id' => $id]);
+ $queue = DBA::selectFirst('queue', ['retrial'], ['id' => $id]);
if (!DBM::is_result($queue)) {
return;
}
$delay = (($retrial + 3) ** 4) + (rand(1, 30) * ($retrial + 1));
$next = DateTimeFormat::utc('now + ' . $delay . ' seconds');
- dba::update('queue', ['last' => DateTimeFormat::utcNow(), 'retrial' => $retrial + 1, 'next' => $next], ['id' => $id]);
+ DBA::update('queue', ['last' => DateTimeFormat::utcNow(), 'retrial' => $retrial + 1, 'next' => $next], ['id' => $id]);
}
/**
public static function removeItem($id)
{
logger('queue: remove queue item ' . $id);
- dba::delete('queue', ['id' => $id]);
+ DBA::delete('queue', ['id' => $id]);
}
/**
}
}
- dba::insert('queue', [
+ DBA::insert('queue', [
'cid' => $cid,
'network' => $network,
'guid' => $guid,
namespace Friendica\Model;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
require_once 'boot.php';
{
$tag_text = '';
$condition = ['otype' => TERM_OBJ_POST, 'oid' => $itemid, 'type' => [TERM_HASHTAG, TERM_MENTION]];
- $tags = dba::select('term', [], $condition);
- while ($tag = dba::fetch($tags)) {
+ $tags = DBA::select('term', [], $condition);
+ while ($tag = DBA::fetch($tags)) {
if ($tag_text != '') {
$tag_text .= ',';
}
{
$file_text = '';
$condition = ['otype' => TERM_OBJ_POST, 'oid' => $itemid, 'type' => [TERM_FILE, TERM_CATEGORY]];
- $tags = dba::select('term', [], $condition);
- while ($tag = dba::fetch($tags)) {
+ $tags = DBA::select('term', [], $condition);
+ while ($tag = DBA::fetch($tags)) {
if ($tag['type'] == TERM_CATEGORY) {
$file_text .= '<' . $tag['term'] . '>';
} else {
$message['tag'] = $tags;
// Clean up all tags
- dba::delete('term', ['otype' => TERM_OBJ_POST, 'oid' => $itemid, 'type' => [TERM_HASHTAG, TERM_MENTION]]);
+ DBA::delete('term', ['otype' => TERM_OBJ_POST, 'oid' => $itemid, 'type' => [TERM_HASHTAG, TERM_MENTION]]);
if ($message['deleted']) {
return;
if ($message['uid'] == 0) {
$global = true;
- dba::update('term', ['global' => true], ['otype' => TERM_OBJ_POST, 'guid' => $message['guid']]);
+ DBA::update('term', ['global' => true], ['otype' => TERM_OBJ_POST, 'guid' => $message['guid']]);
} else {
- $global = dba::exists('term', ['uid' => 0, 'otype' => TERM_OBJ_POST, 'guid' => $message['guid']]);
+ $global = DBA::exists('term', ['uid' => 0, 'otype' => TERM_OBJ_POST, 'guid' => $message['guid']]);
}
- dba::insert('term', [
+ DBA::insert('term', [
'uid' => $message['uid'],
'oid' => $itemid,
'otype' => TERM_OBJ_POST,
foreach ($users AS $user) {
if ($user['uid'] == $message['uid']) {
/// @todo This function is called frim Item::update - so we mustn't call that function here
- dba::update('item', ['mention' => true], ['id' => $itemid]);
- dba::update('thread', ['mention' => true], ['iid' => $message['parent']]);
+ DBA::update('item', ['mention' => true], ['id' => $itemid]);
+ DBA::update('thread', ['mention' => true], ['iid' => $message['parent']]);
}
}
}
}
// Clean up all tags
- dba::delete('term', ['otype' => TERM_OBJ_POST, 'oid' => $itemid, 'type' => [TERM_FILE, TERM_CATEGORY]]);
+ DBA::delete('term', ['otype' => TERM_OBJ_POST, 'oid' => $itemid, 'type' => [TERM_FILE, TERM_CATEGORY]]);
if ($message["deleted"]) {
return;
if (preg_match_all("/\[(.*?)\]/ism", $message["file"], $files)) {
foreach ($files[1] as $file) {
- dba::insert('term', [
+ DBA::insert('term', [
'uid' => $message["uid"],
'oid' => $itemid,
'otype' => TERM_OBJ_POST,
if (preg_match_all("/\<(.*?)\>/ism", $message["file"], $files)) {
foreach ($files[1] as $file) {
- dba::insert('term', [
+ DBA::insert('term', [
'uid' => $message["uid"],
'oid' => $itemid,
'otype' => TERM_OBJ_POST,
$searchpath = System::baseUrl() . "/search?tag=";
- $taglist = dba::select(
+ $taglist = DBA::select(
'term',
['type', 'term', 'url'],
["`otype` = ? AND `oid` = ? AND `type` IN (?, ?)", TERM_OBJ_POST, $item['id'], TERM_HASHTAG, TERM_MENTION],
['order' => ['tid']]
);
- while ($tag = dba::fetch($taglist)) {
+ while ($tag = DBA::fetch($taglist)) {
if ($tag["url"] == "") {
$tag["url"] = $searchpath . $tag["term"];
}
$return['tags'][] = $prefix . "<a href=\"" . $tag["url"] . "\" target=\"_blank\">" . $tag["term"] . "</a>";
}
- dba::close($taglist);
+ DBA::close($taglist);
return $return;
}
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Core\Worker;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Object\Image;
use Friendica\Util\Crypto;
* @return boolean|array
*/
public static function getOwnerDataById($uid) {
- $r = dba::fetch_first("SELECT
+ $r = DBA::fetch_first("SELECT
`contact`.*,
`user`.`prvkey` AS `uprvkey`,
`user`.`timezone`,
*/
public static function getOwnerDataByNick($nick)
{
- $user = dba::selectFirst('user', ['uid'], ['nickname' => $nick]);
+ $user = DBA::selectFirst('user', ['uid'], ['nickname' => $nick]);
if (!DBM::is_result($user)) {
return false;
}
return $default_group;
}
- $user = dba::selectFirst('user', ['def_gid'], ['uid' => $uid]);
+ $user = DBA::selectFirst('user', ['def_gid'], ['uid' => $uid]);
if (DBM::is_result($user)) {
$default_group = $user["def_gid"];
}
} elseif (is_int($user_info) || is_string($user_info)) {
if (is_int($user_info)) {
- $user = dba::selectFirst('user', ['uid', 'password', 'legacy_password'],
+ $user = DBA::selectFirst('user', ['uid', 'password', 'legacy_password'],
[
'uid' => $user_info,
'blocked' => 0,
$condition = ["(`email` = ? OR `username` = ? OR `nickname` = ?)
AND NOT `blocked` AND NOT `account_expired` AND NOT `account_removed` AND `verified`",
$user_info, $user_info, $user_info];
- $user = dba::selectFirst('user', $fields, $condition);
+ $user = DBA::selectFirst('user', $fields, $condition);
}
if (!DBM::is_result($user)) {
'pwdreset_time' => null,
'legacy_password' => false
];
- return dba::update('user', $fields, ['uid' => $uid]);
+ return DBA::update('user', $fields, ['uid' => $uid]);
}
/**
throw new Exception(L10n::t('An invitation is required.'));
}
- if (!dba::exists('register', ['hash' => $invite_id])) {
+ if (!DBA::exists('register', ['hash' => $invite_id])) {
throw new Exception(L10n::t('Invitation could not be verified.'));
}
}
throw new Exception(L10n::t('The nickname was blocked from registration by the nodes admin.'));
}
- if (Config::get('system', 'block_extended_register', false) && dba::exists('user', ['email' => $email])) {
+ if (Config::get('system', 'block_extended_register', false) && DBA::exists('user', ['email' => $email])) {
throw new Exception(L10n::t('Cannot use that email.'));
}
}
// Check existing and deleted accounts for this nickname.
- if (dba::exists('user', ['nickname' => $nickname])
- || dba::exists('userd', ['username' => $nickname])
+ if (DBA::exists('user', ['nickname' => $nickname])
+ || DBA::exists('userd', ['username' => $nickname])
) {
throw new Exception(L10n::t('Nickname is already registered. Please choose another.'));
}
$sprvkey = $sres['prvkey'];
$spubkey = $sres['pubkey'];
- $insert_result = dba::insert('user', [
+ $insert_result = DBA::insert('user', [
'guid' => generate_user_guid(),
'username' => $username,
'password' => $new_password_encoded,
]);
if ($insert_result) {
- $uid = dba::lastInsertId();
- $user = dba::selectFirst('user', [], ['uid' => $uid]);
+ $uid = DBA::lastInsertId();
+ $user = DBA::selectFirst('user', [], ['uid' => $uid]);
} else {
throw new Exception(L10n::t('An error occurred during registration. Please try again.'));
}
// if somebody clicked submit twice very quickly, they could end up with two accounts
// due to race condition. Remove this one.
- $user_count = dba::count('user', ['nickname' => $nickname]);
+ $user_count = DBA::count('user', ['nickname' => $nickname]);
if ($user_count > 1) {
- dba::delete('user', ['uid' => $uid]);
+ DBA::delete('user', ['uid' => $uid]);
throw new Exception(L10n::t('Nickname is already registered. Please choose another.'));
}
- $insert_result = dba::insert('profile', [
+ $insert_result = DBA::insert('profile', [
'uid' => $uid,
'name' => $username,
'photo' => System::baseUrl() . "/photo/profile/{$uid}.jpg",
'profile-name' => L10n::t('default')
]);
if (!$insert_result) {
- dba::delete('user', ['uid' => $uid]);
+ DBA::delete('user', ['uid' => $uid]);
throw new Exception(L10n::t('An error occurred creating your default profile. Please try again.'));
}
// Create the self contact
if (!Contact::createSelfFromUserId($uid)) {
- dba::delete('user', ['uid' => $uid]);
+ DBA::delete('user', ['uid' => $uid]);
throw new Exception(L10n::t('An error occurred creating your self contact. Please try again.'));
}
// right away as a default group for new contacts.
$def_gid = Group::create($uid, L10n::t('Friends'));
if (!$def_gid) {
- dba::delete('user', ['uid' => $uid]);
+ DBA::delete('user', ['uid' => $uid]);
throw new Exception(L10n::t('An error occurred creating your default contact group. Please try again.'));
}
$fields['allow_gid'] = '<' . $def_gid . '>';
}
- dba::update('user', $fields, ['uid' => $uid]);
+ DBA::update('user', $fields, ['uid' => $uid]);
// if we have no OpenID photo try to look up an avatar
if (!strlen($photo)) {
}
if (!$photo_failure) {
- dba::update('photo', ['profile' => 1], ['resource-id' => $hash]);
+ DBA::update('photo', ['profile' => 1], ['resource-id' => $hash]);
}
}
}
logger('Removing user: ' . $uid);
- $user = dba::selectFirst('user', [], ['uid' => $uid]);
+ $user = DBA::selectFirst('user', [], ['uid' => $uid]);
Addon::callHooks('remove_user', $user);
// save username (actually the nickname as it is guaranteed
// unique), so it cannot be re-registered in the future.
- dba::insert('userd', ['username' => $user['nickname']]);
+ DBA::insert('userd', ['username' => $user['nickname']]);
// The user and related data will be deleted in "cron_expire_and_remove_users" (cronjobs.php)
- dba::update('user', ['account_removed' => true, 'account_expires_on' => DateTimeFormat::utcNow()], ['uid' => $uid]);
+ DBA::update('user', ['account_removed' => true, 'account_expires_on' => DateTimeFormat::utcNow()], ['uid' => $uid]);
Worker::add(PRIORITY_HIGH, "Notifier", "removeme", $uid);
// Send an update to the directory
use Friendica\BaseModule;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
require_once 'include/dba.php';
require_once 'include/text.php';
System::jsonExit($result);
}
- $taglist = dba::p("SELECT DISTINCT(`term`) FROM `term` WHERE `term` LIKE ? AND `type` = ? ORDER BY `term`",
+ $taglist = DBA::p("SELECT DISTINCT(`term`) FROM `term` WHERE `term` LIKE ? AND `type` = ? ORDER BY `term`",
$t . '%',
intval(TERM_HASHTAG)
);
- while ($tag = dba::fetch($taglist)) {
+ while ($tag = DBA::fetch($taglist)) {
$result[] = ['text' => $tag['term']];
}
- dba::close($taglist);
+ DBA::close($taglist);
System::jsonExit($result);
}
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\User;
use Friendica\Util\DateTimeFormat;
throw new Exception(L10n::t('Login failed.'));
}
} else {
- $record = dba::selectFirst('user', [],
+ $record = DBA::selectFirst('user', [],
['uid' => User::getIdFromPasswordAuthentication($username, $password)]
);
}
$data = json_decode($_COOKIE["Friendica"]);
if (isset($data->uid)) {
- $user = dba::selectFirst('user', [],
+ $user = DBA::selectFirst('user', [],
[
'uid' => $data->uid,
'blocked' => false,
goaway(self::getApp()->get_baseurl());
}
- $user = dba::selectFirst('user', [],
+ $user = DBA::selectFirst('user', [],
[
'uid' => $_SESSION['uid'],
'blocked' => false,
namespace Friendica\Module;
use Friendica\BaseModule;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Util\HTTPSignature;
use Friendica\Util\Network;
goaway($dest);
}
- $contact = dba::selectFirst('contact', ['id', 'nurl', 'url'], ['id' => $cid]);
+ $contact = DBA::selectFirst('contact', ['id', 'nurl', 'url'], ['id' => $cid]);
// Redirect if the contact is already authenticated on this site.
if (!empty($a->contact) && array_key_exists('id', $a->contact) && strpos($contact['nurl'], normalise_link(self::getApp()->get_baseurl())) !== false) {
use Friendica\BaseModule;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\OpenWebAuthToken;
$fields = ['id', 'url', 'addr', 'pubkey'];
$condition = ['id' => $cid];
- $contact = dba::selectFirst('contact', $fields, $condition);
+ $contact = DBA::selectFirst('contact', $fields, $condition);
if (DBM::is_result($contact)) {
// Try to verify the signed header with the public key of the contact record
use Friendica\Core\Addon;
use Friendica\Core\PConfig;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Util\DateTimeFormat;
use OAuthServer;
{
logger("FKOAuth1::loginUser $uid");
$a = get_app();
- $record = dba::selectFirst('user', [], ['uid' => $uid, 'blocked' => 0, 'account_expired' => 0, 'account_removed' => 0, 'verified' => 1]);
+ $record = DBA::selectFirst('user', [], ['uid' => $uid, 'blocked' => 0, 'account_expired' => 0, 'account_removed' => 0, 'verified' => 1]);
if (!DBM::is_result($record)) {
logger('FKOAuth1::loginUser failure: ' . print_r($_SERVER, true), LOGGER_DEBUG);
$a->timezone = $a->user['timezone'];
}
- $contact = dba::selectFirst('contact', [], ['uid' => $_SESSION['uid'], 'self' => 1]);
+ $contact = DBA::selectFirst('contact', [], ['uid' => $_SESSION['uid'], 'self' => 1]);
if (DBM::is_result($contact)) {
$a->contact = $contact;
$a->cid = $contact['id'];
$_SESSION['cid'] = $a->cid;
}
- dba::update('user', ['login_date' => DateTimeFormat::utcNow()], ['uid' => $_SESSION['uid']]);
+ DBA::update('user', ['login_date' => DateTimeFormat::utcNow()], ['uid' => $_SESSION['uid']]);
Addon::callHooks('logged_in', $a->user);
}
namespace Friendica\Network;
use Friendica\Core\Config;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use OAuthConsumer;
use OAuthDataStore;
{
logger(__function__ . ":" . $consumer_key);
- $s = dba::select('clients', ['client_id', 'pw', 'redirect_uri'], ['client_id' => $consumer_key]);
- $r = dba::inArray($s);
+ $s = DBA::select('clients', ['client_id', 'pw', 'redirect_uri'], ['client_id' => $consumer_key]);
+ $r = DBA::inArray($s);
if (DBM::is_result($r)) {
return new OAuthConsumer($r[0]['client_id'], $r[0]['pw'], $r[0]['redirect_uri']);
{
logger(__function__ . ":" . $consumer . ", " . $token_type . ", " . $token);
- $s = dba::select('tokens', ['id', 'secret', 'scope', 'expires', 'uid'], ['client_id' => $consumer->key, 'scope' => $token_type, 'id' => $token]);
- $r = dba::inArray($s);
+ $s = DBA::select('tokens', ['id', 'secret', 'scope', 'expires', 'uid'], ['client_id' => $consumer->key, 'scope' => $token_type, 'id' => $token]);
+ $r = DBA::inArray($s);
if (DBM::is_result($r)) {
$ot = new OAuthToken($r[0]['id'], $r[0]['secret']);
*/
public function lookup_nonce($consumer, $token, $nonce, $timestamp)
{
- $token = dba::selectFirst('tokens', ['id', 'secret'], ['client_id' => $consumer->key, 'id' => $nonce, 'expires' => $timestamp]);
+ $token = DBA::selectFirst('tokens', ['id', 'secret'], ['client_id' => $consumer->key, 'id' => $nonce, 'expires' => $timestamp]);
if (DBM::is_result($token)) {
return new OAuthToken($token['id'], $token['secret']);
}
$k = $consumer;
}
- $r = dba::insert(
+ $r = DBA::insert(
'tokens',
[
'id' => $key,
if (is_null($verifier) || ($uverifier !== false)) {
$key = self::genToken();
$sec = self::genToken();
- $r = dba::insert(
+ $r = DBA::insert(
'tokens',
[
'id' => $key,
}
}
- dba::delete('tokens', ['id' => $token->key]);
+ DBA::delete('tokens', ['id' => $token->key]);
if (!is_null($ret) && !is_null($uverifier)) {
Config::delete("oauth", $verifier);
use Friendica\Core\Cache;
use Friendica\Core\Config;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Profile;
use Friendica\Protocol\Email;
$condition = ['nurl' => normalise_link($data["url"])];
- $old_fields = dba::selectFirst('gcontact', $fieldnames, $condition);
+ $old_fields = DBA::selectFirst('gcontact', $fieldnames, $condition);
// When the gcontact doesn't exist, the value "true" will trigger an insert.
// In difference to the public contacts we want to have every contact
$fields['created'] = DateTimeFormat::utcNow();
}
- dba::update('gcontact', $fields, $condition, $old_fields);
+ DBA::update('gcontact', $fields, $condition, $old_fields);
$fields = ['name' => $data['name'],
'nick' => $data['nick'],
// This won't trigger an insert. This is intended, since we only need
// public contacts for everyone we store items from.
// We don't need to store every contact on the planet.
- $old_fields = dba::selectFirst('contact', $fieldnames, $condition);
+ $old_fields = DBA::selectFirst('contact', $fieldnames, $condition);
$fields['name-date'] = DateTimeFormat::utcNow();
$fields['uri-date'] = DateTimeFormat::utcNow();
$fields['success_update'] = DateTimeFormat::utcNow();
- dba::update('contact', $fields, $condition, $old_fields);
+ DBA::update('contact', $fields, $condition, $old_fields);
}
}
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Item;
'starred' => L10n::t('starred'),
];
- $thread = dba::selectFirst('thread', ['ignored'], ['uid' => $item['uid'], 'iid' => $item['id']]);
+ $thread = DBA::selectFirst('thread', ['ignored'], ['uid' => $item['uid'], 'iid' => $item['id']]);
if (DBM::is_result($thread)) {
$ignore = [
'do' => L10n::t("ignore thread"),
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Event;
$conversation_uri = $conversation_href;
if (isset($parent_item)) {
- $conversation = dba::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $item['parent-uri']]);
+ $conversation = DBA::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $item['parent-uri']]);
if (DBM::is_result($conversation)) {
if ($conversation['conversation-uri'] != '') {
$conversation_uri = $conversation['conversation-uri'];
if (empty($contact['addr'])) {
logger('Empty contact handle for ' . $contact['id'] . ' - ' . $contact['url'] . ' - trying to update it.');
if (Contact::updateFromProbe($contact['id'])) {
- $new_contact = dba::selectFirst('contact', ['addr'], ['id' => $contact['id']]);
+ $new_contact = DBA::selectFirst('contact', ['addr'], ['id' => $contact['id']]);
$contact['addr'] = $new_contact['addr'];
}
'name', 'nick', 'about', 'location', 'keywords', 'xmpp', 'bdyear', 'bd', 'hidden', 'contact-type'];
$condition = ["`uid` = ? AND `nurl` = ? AND `network` != ?",
$importer["importer_uid"], normalise_link($author["link"]), NETWORK_STATUSNET];
- $contact_old = dba::selectFirst('contact', $fields, $condition);
+ $contact_old = DBA::selectFirst('contact', $fields, $condition);
if (DBM::is_result($contact_old)) {
$author["contact-id"] = $contact_old["id"];
$msg["seen"] = 0;
$msg["replied"] = 0;
- dba::insert('mail', $msg);
+ DBA::insert('mail', $msg);
// send notifications.
/// @TODO Arange this mess
'url' => $relocate["url"], 'nurl' => normalise_link($relocate["url"]),
'addr' => $relocate["addr"], 'connect' => $relocate["addr"],
'notify' => $relocate["notify"], 'server_url' => $relocate["server_url"]];
- dba::update('gcontact', $fields, ['nurl' => normalise_link($old["url"])]);
+ DBA::update('gcontact', $fields, ['nurl' => normalise_link($old["url"])]);
// Update the contact table. We try to find every entry.
$fields = ['name' => $relocate["name"], 'avatar' => $relocate["avatar"],
'poll' => $relocate["poll"], 'site-pubkey' => $relocate["sitepubkey"]];
$condition = ["(`id` = ?) OR (`nurl` = ?)", $importer["id"], normalise_link($old["url"])];
- dba::update('contact', $fields, $condition);
+ DBA::update('contact', $fields, $condition);
Contact::updateAvatar($relocate["avatar"], $importer["importer_uid"], $importer["id"], true);
}
if ($Blink && link_compare($Blink, System::baseUrl() . "/profile/" . $importer["nickname"])) {
- $author = dba::selectFirst('contact', ['name', 'thumb', 'url'], ['id' => $item['author-id']]);
+ $author = DBA::selectFirst('contact', ['name', 'thumb', 'url'], ['id' => $item['author-id']]);
// send a notification
notification(
$accounttype = intval(XML::getFirstNodeValue($xpath, "/atom:feed/dfrn:account_type/text()"));
if ($accounttype != $importer["contact-type"]) {
- dba::update('contact', ['contact-type' => $accounttype], ['id' => $importer["id"]]);
+ DBA::update('contact', ['contact-type' => $accounttype], ['id' => $importer["id"]]);
}
// A forum contact can either have set "forum" or "prv" - but not both
if (($accounttype == ACCOUNT_TYPE_COMMUNITY) && (($forum != $importer["forum"]) || ($forum == $importer["prv"]))) {
$condition = ['(`forum` != ? OR `prv` != ?) AND `id` = ?', $forum, !$forum, $importer["id"]];
- dba::update('contact', ['forum' => $forum, 'prv' => !$forum], $condition);
+ DBA::update('contact', ['forum' => $forum, 'prv' => !$forum], $condition);
}
} elseif ($forum != $importer["forum"]) { // Deprecated since 3.5.1
$condition = ['`forum` != ? AND `id` = ?', $forum, $importer["id"]];
- dba::update('contact', ['forum' => $forum], $condition);
+ DBA::update('contact', ['forum' => $forum], $condition);
}
$sec = random_string();
- dba::insert('profile_check', ['uid' => local_user(), 'cid' => $cid, 'dfrn_id' => $dfrn_id, 'sec' => $sec, 'expire' => time() + 45]);
+ DBA::insert('profile_check', ['uid' => local_user(), 'cid' => $cid, 'dfrn_id' => $dfrn_id, 'sec' => $sec, 'expire' => time() + 45]);
$url = curPageURL();
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Core\Worker;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
}
// Servers that want to get all content
- $servers = dba::select('gserver', ['url'], ['relay-subscribe' => true, 'relay-scope' => 'all']);
- while ($server = dba::fetch($servers)) {
+ $servers = DBA::select('gserver', ['url'], ['relay-subscribe' => true, 'relay-scope' => 'all']);
+ while ($server = DBA::fetch($servers)) {
$serverlist[$server['url']] = $server['url'];
}
// All tags of the current post
$condition = ['otype' => TERM_OBJ_POST, 'type' => TERM_HASHTAG, 'oid' => $parent['parent']];
- $tags = dba::select('term', ['term'], $condition);
+ $tags = DBA::select('term', ['term'], $condition);
$taglist = [];
- while ($tag = dba::fetch($tags)) {
+ while ($tag = DBA::fetch($tags)) {
$taglist[] = $tag['term'];
}
// All servers who wants content with this tag
$tagserverlist = [];
if (!empty($taglist)) {
- $tagserver = dba::select('gserver-tag', ['gserver-id'], ['tag' => $taglist]);
- while ($server = dba::fetch($tagserver)) {
+ $tagserver = DBA::select('gserver-tag', ['gserver-id'], ['tag' => $taglist]);
+ while ($server = DBA::fetch($tagserver)) {
$tagserverlist[] = $server['gserver-id'];
}
}
// All adresses with the given id
if (!empty($tagserverlist)) {
- $servers = dba::select('gserver', ['url'], ['relay-subscribe' => true, 'relay-scope' => 'tags', 'id' => $tagserverlist]);
- while ($server = dba::fetch($servers)) {
+ $servers = DBA::select('gserver', ['url'], ['relay-subscribe' => true, 'relay-scope' => 'tags', 'id' => $tagserverlist]);
+ while ($server = DBA::fetch($servers)) {
$serverlist[$server['url']] = $server['url'];
}
}
// Fetch the relay contact
$condition = ['uid' => 0, 'nurl' => normalise_link($server_url),
'contact-type' => ACCOUNT_TYPE_RELAY];
- $contact = dba::selectFirst('contact', $fields, $condition);
+ $contact = DBA::selectFirst('contact', $fields, $condition);
if (DBM::is_result($contact)) {
if ($contact['archive'] || $contact['blocked']) {
} else {
self::setRelayContact($server_url);
- $contact = dba::selectFirst('contact', $fields, $condition);
+ $contact = DBA::selectFirst('contact', $fields, $condition);
if (DBM::is_result($contact)) {
return $contact;
}
$condition = ['uid' => 0, 'nurl' => normalise_link($server_url),
'contact-type' => ACCOUNT_TYPE_RELAY];
- if (dba::exists('contact', $condition)) {
+ if (DBA::exists('contact', $condition)) {
unset($fields['created']);
}
- dba::update('contact', $fields, $condition, true);
+ DBA::update('contact', $fields, $condition, true);
}
/**
*/
public static function participantsForThread($thread, array $contacts)
{
- $r = dba::p("SELECT `contact`.`batch`, `contact`.`id`, `contact`.`name`, `contact`.`network`,
+ $r = DBA::p("SELECT `contact`.`batch`, `contact`.`id`, `contact`.`name`, `contact`.`network`,
`fcontact`.`batch` AS `fbatch`, `fcontact`.`network` AS `fnetwork` FROM `participation`
INNER JOIN `contact` ON `contact`.`id` = `participation`.`cid`
INNER JOIN `fcontact` ON `fcontact`.`id` = `participation`.`fid`
WHERE `participation`.`iid` = ?", $thread);
- while ($contact = dba::fetch($r)) {
+ while ($contact = DBA::fetch($r)) {
if (!empty($contact['fnetwork'])) {
$contact['network'] = $contact['fnetwork'];
}
$contacts[] = $contact;
}
}
- dba::close($r);
+ DBA::close($r);
return $contacts;
}
{
$update = false;
- $person = dba::selectFirst('fcontact', [], ['network' => NETWORK_DIASPORA, 'addr' => $handle]);
+ $person = DBA::selectFirst('fcontact', [], ['network' => NETWORK_DIASPORA, 'addr' => $handle]);
if (DBM::is_result($person)) {
logger("In cache " . print_r($person, true), LOGGER_DEBUG);
self::updateFContact($r);
// Fetch the updated or added contact
- $person = dba::selectFirst('fcontact', [], ['network' => NETWORK_DIASPORA, 'addr' => $handle]);
+ $person = DBA::selectFirst('fcontact', [], ['network' => NETWORK_DIASPORA, 'addr' => $handle]);
if (!DBM::is_result($person)) {
$person = $r;
}
$condition = ['url' => $arr["url"], 'network' => $arr["network"]];
- dba::update('fcontact', $fields, $condition, true);
+ DBA::update('fcontact', $fields, $condition, true);
}
/**
private static function authorContactByUrl($def_contact, $person, $uid)
{
$condition = ['nurl' => normalise_link($person["url"]), 'uid' => $uid];
- $contact = dba::selectFirst('contact', ['id', 'network'], $condition);
+ $contact = DBA::selectFirst('contact', ['id', 'network'], $condition);
if (DBM::is_result($contact)) {
$cid = $contact["id"];
$network = $contact["network"];
'notify' => $data['notify'], 'poll' => $data['poll'],
'network' => $data['network']];
- dba::update('contact', $fields, ['addr' => $old_handle]);
+ DBA::update('contact', $fields, ['addr' => $old_handle]);
$fields = ['url' => $data['url'], 'nurl' => normalise_link($data['url']),
'name' => $data['name'], 'nick' => $data['nick'],
'notify' => $data['notify'], 'photo' => $data['photo'],
'server_url' => $data['baseurl'], 'network' => $data['network']];
- dba::update('gcontact', $fields, ['addr' => $old_handle]);
+ DBA::update('gcontact', $fields, ['addr' => $old_handle]);
logger('Contacts are updated.');
{
$author = notags(unxmlify($data->author));
- $contacts = dba::select('contact', ['id'], ['addr' => $author]);
- while ($contact = dba::fetch($contacts)) {
+ $contacts = DBA::select('contact', ['id'], ['addr' => $author]);
+ while ($contact = DBA::fetch($contacts)) {
Contact::remove($contact["id"]);
}
- dba::delete('gcontact', ['addr' => $author]);
+ DBA::delete('gcontact', ['addr' => $author]);
logger('Removed contacts for ' . $author);
$item = Item::selectFirst(['uid'], ['origin' => true, 'guid' => $guid]);
if (DBM::is_result($item)) {
logger("Found user ".$item['uid']." as owner of item ".$guid, LOGGER_DEBUG);
- $contact = dba::selectFirst('contact', [], ['self' => true, 'uid' => $item['uid']]);
+ $contact = DBA::selectFirst('contact', [], ['self' => true, 'uid' => $item['uid']]);
if (DBM::is_result($contact)) {
return $contact;
}
$person = self::personByHandle($msg_author);
- dba::lock('mail');
+ DBA::lock('mail');
$r = q(
"SELECT `id` FROM `mail` WHERE `guid` = '%s' AND `uid` = %d LIMIT 1",
dbesc($msg_created_at)
);
- dba::unlock();
+ DBA::unlock();
- dba::update('conv', ['updated' => DateTimeFormat::utcNow()], ['id' => $conversation["id"]]);
+ DBA::update('conv', ['updated' => DateTimeFormat::utcNow()], ['id' => $conversation["id"]]);
notification(
[
$body = self::replacePeopleGuid($body, $person["url"]);
- dba::lock('mail');
+ DBA::lock('mail');
$r = q(
"SELECT `id` FROM `mail` WHERE `guid` = '%s' AND `uid` = %d LIMIT 1",
dbesc($created_at)
);
- dba::unlock();
+ DBA::unlock();
- dba::update('conv', ['updated' => DateTimeFormat::utcNow()], ['id' => $conversation["id"]]);
+ DBA::update('conv', ['updated' => DateTimeFormat::utcNow()], ['id' => $conversation["id"]]);
return true;
}
logger('Received participation for ID: '.$item['id'].' - Contact: '.$contact_id.' - Server: '.$server, LOGGER_DEBUG);
- if (!dba::exists('participation', ['iid' => $item['id'], 'server' => $server])) {
- dba::insert('participation', ['iid' => $item['id'], 'cid' => $contact_id, 'fid' => $person['id'], 'server' => $server]);
+ if (!DBA::exists('participation', ['iid' => $item['id'], 'server' => $server])) {
+ DBA::insert('participation', ['iid' => $item['id'], 'cid' => $contact_id, 'fid' => $person['id'], 'server' => $server]);
}
// Send all existing comments and likes to the requesting server
logger("Send ".$cmd." for item ".$comment['id']." to contact ".$contact_id, LOGGER_DEBUG);
Worker::add(PRIORITY_HIGH, 'Delivery', $cmd, $comment['id'], $contact_id);
}
- dba::close($comments);
+ DBA::close($comments);
return true;
}
$fields['bd'] = $birthday;
}
- dba::update('contact', $fields, ['id' => $contact['id']]);
+ DBA::update('contact', $fields, ['id' => $contact['id']]);
$gcontact = ["url" => $contact["url"], "network" => NETWORK_DIASPORA, "generation" => 2,
"photo" => $image_url, "name" => $name, "location" => $location,
$a = get_app();
if ($contact["rel"] == CONTACT_IS_SHARING) {
- dba::update(
+ DBA::update(
'contact',
['rel' => CONTACT_IS_FRIEND, 'writable' => true],
['id' => $contact["id"], 'uid' => $importer["uid"]]
// If the item belongs to a user, we take this user id.
if ($item['uid'] == 0) {
$condition = ['verified' => true, 'blocked' => false, 'account_removed' => false, 'account_expired' => false];
- $first_user = dba::selectFirst('user', ['uid'], $condition);
+ $first_user = DBA::selectFirst('user', ['uid'], $condition);
$owner = User::getOwnerDataById($first_user['uid']);
} else {
$owner = User::getOwnerDataById($item['uid']);
* Now store the signature more flexible to dynamically support new fields.
* This will break Diaspora compatibility with Friendica versions prior to 3.5.
*/
- dba::insert('sign', ['iid' => $post_id, 'signed_text' => json_encode($message)]);
+ DBA::insert('sign', ['iid' => $post_id, 'signed_text' => json_encode($message)]);
logger('Stored diaspora like signature');
return true;
* Now store the signature more flexible to dynamically support new fields.
* This will break Diaspora compatibility with Friendica versions prior to 3.5.
*/
- dba::insert('sign', ['iid' => $message_id, 'signed_text' => json_encode($message)]);
+ DBA::insert('sign', ['iid' => $message_id, 'signed_text' => json_encode($message)]);
logger('Stored diaspora comment signature');
return true;
use Friendica\Core\L10n;
use Friendica\Core\Lock;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Conversation;
$condition = ["`uid` = ? AND `alias` = ? AND `network` != ? AND `rel` IN (?, ?)",
$importer["uid"], $aliaslink, NETWORK_STATUSNET,
CONTACT_IS_SHARING, CONTACT_IS_FRIEND];
- $contact = dba::selectFirst('contact', [], $condition);
+ $contact = DBA::selectFirst('contact', [], $condition);
}
if (!DBM::is_result($contact) && $author["author-link"] != '') {
$condition = ["`uid` = ? AND `nurl` IN (?, ?) AND `network` != ? AND `rel` IN (?, ?)",
$importer["uid"], normalise_link($author["author-link"]), normalise_link($aliaslink),
NETWORK_STATUSNET, CONTACT_IS_SHARING, CONTACT_IS_FRIEND];
- $contact = dba::selectFirst('contact', [], $condition);
+ $contact = DBA::selectFirst('contact', [], $condition);
}
if (!DBM::is_result($contact) && ($addr != '')) {
$condition = ["`uid` = ? AND `addr` = ? AND `network` != ? AND `rel` IN (?, ?)",
$importer["uid"], $addr, NETWORK_STATUSNET,
CONTACT_IS_SHARING, CONTACT_IS_FRIEND];
- $contact = dba::selectFirst('contact', [], $condition);
+ $contact = DBA::selectFirst('contact', [], $condition);
}
if (DBM::is_result($contact)) {
$contact['name-date'] = DateTimeFormat::utcNow();
- dba::update('contact', $contact, ['id' => $contact["id"]], $current);
+ DBA::update('contact', $contact, ['id' => $contact["id"]], $current);
if (!empty($author["author-avatar"]) && ($author["author-avatar"] != $current['avatar'])) {
logger("Update profile picture for contact ".$contact["id"], LOGGER_DEBUG);
if ($cid) {
$fields = ['url', 'nurl', 'name', 'nick', 'alias', 'about', 'location'];
- $old_contact = dba::selectFirst('contact', $fields, ['id' => $cid]);
+ $old_contact = DBA::selectFirst('contact', $fields, ['id' => $cid]);
// Update it with the current values
$fields = ['url' => $author["author-link"], 'name' => $contact["name"],
'about' => $contact["about"], 'location' => $contact["location"],
'success_update' => DateTimeFormat::utcNow(), 'last-update' => DateTimeFormat::utcNow()];
- dba::update('contact', $fields, ['id' => $cid], $old_contact);
+ DBA::update('contact', $fields, ['id' => $cid], $old_contact);
// Update the avatar
if (!empty($author["author-avatar"])) {
$conv_data['source'] = $doc2->saveXML();
$condition = ['item-uri' => $conv_data['uri'],'protocol' => PROTOCOL_OSTATUS_FEED];
- if (dba::exists('conversation', $condition)) {
+ if (DBA::exists('conversation', $condition)) {
logger('Delete deprecated entry for URI '.$conv_data['uri'], LOGGER_DEBUG);
- dba::delete('conversation', ['item-uri' => $conv_data['uri']]);
+ DBA::delete('conversation', ['item-uri' => $conv_data['uri']]);
}
logger('Store conversation data for uri '.$conv_data['uri'], LOGGER_DEBUG);
private static function fetchSelf($self, &$item)
{
$condition = ['`item-uri` = ? AND `protocol` IN (?, ?)', $self, PROTOCOL_DFRN, PROTOCOL_OSTATUS_SALMON];
- if (dba::exists('conversation', $condition)) {
+ if (DBA::exists('conversation', $condition)) {
logger('Conversation '.$item['uri'].' is already stored.', LOGGER_DEBUG);
return;
}
private static function fetchRelated($related, $related_uri, $importer)
{
$condition = ['`item-uri` = ? AND `protocol` IN (?, ?)', $related_uri, PROTOCOL_DFRN, PROTOCOL_OSTATUS_SALMON];
- $conversation = dba::selectFirst('conversation', ['source', 'protocol'], $condition);
+ $conversation = DBA::selectFirst('conversation', ['source', 'protocol'], $condition);
if (DBM::is_result($conversation)) {
$stored = true;
$xml = $conversation['source'];
}
if ($conversation['protocol'] == PROTOCOL_OSTATUS_SALMON) {
logger('Delete invalid cached XML for URI '.$related_uri, LOGGER_DEBUG);
- dba::delete('conversation', ['item-uri' => $related_uri]);
+ DBA::delete('conversation', ['item-uri' => $related_uri]);
}
}
// Finally we take the data that we fetched from "ostatus:conversation"
if ($xml == '') {
$condition = ['item-uri' => $related_uri, 'protocol' => PROTOCOL_SPLITTED_CONV];
- $conversation = dba::selectFirst('conversation', ['source'], $condition);
+ $conversation = DBA::selectFirst('conversation', ['source'], $condition);
if (DBM::is_result($conversation)) {
$stored = true;
logger('Got cached XML from conversation for URI '.$related_uri, LOGGER_DEBUG);
if ($owner['account-type'] == ACCOUNT_TYPE_COMMUNITY) {
$condition = ['uid' => $owner['uid'], 'self' => false, 'pending' => false,
'archive' => false, 'hidden' => false, 'blocked' => false];
- $members = dba::count('contact', $condition);
+ $members = DBA::count('contact', $condition);
XML::addElement($doc, $root, "statusnet:group_info", "", ["member_count" => $members]);
}
*/
private static function addAuthor($doc, $owner, $show_profile = true)
{
- $profile = dba::selectFirst('profile', ['homepage', 'publish'], ['uid' => $owner['uid'], 'is-default' => true]);
+ $profile = DBA::selectFirst('profile', ['homepage', 'publish'], ['uid' => $owner['uid'], 'is-default' => true]);
$author = $doc->createElement("author");
XML::addElement($doc, $author, "id", $owner["url"]);
if ($owner['account-type'] == ACCOUNT_TYPE_COMMUNITY) {
$conversation_uri = $conversation_href;
if (isset($parent_item)) {
- $conversation = dba::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $parent_item]);
+ $conversation = DBA::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $parent_item]);
if (DBM::is_result($conversation)) {
if ($conversation['conversation-uri'] != '') {
$conversation_uri = $conversation['conversation-uri'];
foreach ($mentioned as $mention) {
$condition = ['uid' => $owner['uid'], 'nurl' => normalise_link($mention)];
- $contact = dba::selectFirst('contact', ['forum', 'prv', 'self', 'contact-type'], $condition);
+ $contact = DBA::selectFirst('contact', ['forum', 'prv', 'self', 'contact-type'], $condition);
if ($contact["forum"] || $contact["prv"] || ($owner['contact-type'] == ACCOUNT_TYPE_COMMUNITY) ||
($contact['self'] && ($owner['account-type'] == ACCOUNT_TYPE_COMMUNITY))) {
XML::addElement($doc, $entry, "link", "",
use Friendica\Content\Text\HTML;
use Friendica\Core\Config;
use Friendica\Core\Worker;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\GContact;
use Friendica\Model\Profile;
if ($cid) {
if (!$url || !$uid) {
- $contact = dba::selectFirst('contact', ['poco', 'uid'], ['id' => $cid]);
+ $contact = DBA::selectFirst('contact', ['poco', 'uid'], ['id' => $cid]);
if (DBM::is_result($contact)) {
$url = $contact['poco'];
$uid = $contact['uid'];
logger("load: loaded $total entries", LOGGER_DEBUG);
$condition = ["`cid` = ? AND `uid` = ? AND `zcid` = ? AND `updated` < UTC_TIMESTAMP - INTERVAL 2 DAY", $cid, $uid, $zcid];
- dba::delete('glink', $condition);
+ DBA::delete('glink', $condition);
}
public static function reachable($profile, $server = "", $network = "", $force = false)
if (!self::checkServer($server_url, $gcontacts[0]["network"], $force)) {
if ($force) {
$fields = ['last_failure' => DateTimeFormat::utcNow()];
- dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
+ DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
}
logger("Profile ".$profile.": Server ".$server_url." wasn't reachable.", LOGGER_DEBUG);
if (!empty($noscrape["updated"])) {
$fields = ['last_contact' => DateTimeFormat::utcNow()];
- dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
+ DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
logger("Profile ".$profile." was last updated at ".$noscrape["updated"]." (noscrape)", LOGGER_DEBUG);
&& (normalise_link($profile) != normalise_link($data["url"]))
) {
// Delete the old entry
- dba::delete('gcontact', ['nurl' => normalise_link($profile)]);
+ DBA::delete('gcontact', ['nurl' => normalise_link($profile)]);
$gcontact = array_merge($gcontacts[0], $data);
if (($data["poll"] == "") || (in_array($data["network"], [NETWORK_FEED, NETWORK_PHANTOM]))) {
$fields = ['last_failure' => DateTimeFormat::utcNow()];
- dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
+ DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
logger("Profile ".$profile." wasn't reachable (profile)", LOGGER_DEBUG);
return false;
if (!$feedret["success"]) {
$fields = ['last_failure' => DateTimeFormat::utcNow()];
- dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
+ DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
logger("Profile ".$profile." wasn't reachable (no feed)", LOGGER_DEBUG);
return false;
$fields['updated'] = $last_updated;
}
- dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
+ DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
if (($gcontacts[0]["generation"] == 0)) {
$fields = ['generation' => 9];
- dba::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
+ DBA::update('gcontact', $fields, ['nurl' => normalise_link($profile)]);
}
logger("Profile ".$profile." was last updated at ".$last_updated, LOGGER_DEBUG);
return false;
}
- $gserver = dba::selectFirst('gserver', [], ['nurl' => normalise_link($server_url)]);
+ $gserver = DBA::selectFirst('gserver', [], ['nurl' => normalise_link($server_url)]);
if (DBM::is_result($gserver)) {
if ($gserver["created"] <= NULL_DATE) {
$fields = ['created' => DateTimeFormat::utcNow()];
$condition = ['nurl' => normalise_link($server_url)];
- dba::update('gserver', $fields, $condition);
+ DBA::update('gserver', $fields, $condition);
}
$poco = $gserver["poco"];
$noscrape = $gserver["noscrape"];
// Mastodon uses the "@" for user profiles.
// But this can be misunderstood.
if (parse_url($server_url, PHP_URL_USER) != '') {
- dba::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => normalise_link($server_url)]);
+ DBA::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => normalise_link($server_url)]);
return false;
}
if (DBM::is_result($gserver) && ($orig_server_url == $server_url) &&
(!$serverret["success"] && ($serverret['errno'] == CURLE_OPERATION_TIMEDOUT))) {
logger("Connection to server ".$server_url." timed out.", LOGGER_DEBUG);
- dba::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => normalise_link($server_url)]);
+ DBA::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => normalise_link($server_url)]);
return false;
}
// Quit if there is a timeout
if (!$serverret["success"] && ($serverret['errno'] == CURLE_OPERATION_TIMEDOUT)) {
logger("Connection to server ".$server_url." timed out.", LOGGER_DEBUG);
- dba::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => normalise_link($server_url)]);
+ DBA::update('gserver', ['last_failure' => DateTimeFormat::utcNow()], ['nurl' => normalise_link($server_url)]);
return false;
}
if (!$failure) {
// This will be too low, but better than no value at all.
- $registered_users = dba::count('gcontact', ['server_url' => normalise_link($server_url)]);
+ $registered_users = DBA::count('gcontact', ['server_url' => normalise_link($server_url)]);
}
// Look for poco
}
// Check again if the server exists
- $found = dba::exists('gserver', ['nurl' => normalise_link($server_url)]);
+ $found = DBA::exists('gserver', ['nurl' => normalise_link($server_url)]);
$version = strip_tags($version);
$site_name = strip_tags($site_name);
'last_contact' => $last_contact, 'last_failure' => $last_failure];
if ($found) {
- dba::update('gserver', $fields, ['nurl' => normalise_link($server_url)]);
+ DBA::update('gserver', $fields, ['nurl' => normalise_link($server_url)]);
} elseif (!$failure) {
$fields['nurl'] = normalise_link($server_url);
$fields['created'] = DateTimeFormat::utcNow();
- dba::insert('gserver', $fields);
+ DBA::insert('gserver', $fields);
}
if (!$failure && in_array($fields['network'], [NETWORK_DFRN, NETWORK_DIASPORA])) {
return;
}
- $gserver = dba::selectFirst('gserver', ['id', 'relay-subscribe', 'relay-scope'], ['nurl' => normalise_link($server_url)]);
+ $gserver = DBA::selectFirst('gserver', ['id', 'relay-subscribe', 'relay-scope'], ['nurl' => normalise_link($server_url)]);
if (!DBM::is_result($gserver)) {
return;
}
if (($gserver['relay-subscribe'] != $data->subscribe) || ($gserver['relay-scope'] != $data->scope)) {
$fields = ['relay-subscribe' => $data->subscribe, 'relay-scope' => $data->scope];
- dba::update('gserver', $fields, ['id' => $gserver['id']]);
+ DBA::update('gserver', $fields, ['id' => $gserver['id']]);
}
- dba::delete('gserver-tag', ['gserver-id' => $gserver['id']]);
+ DBA::delete('gserver-tag', ['gserver-id' => $gserver['id']]);
if ($data->scope == 'tags') {
// Avoid duplicates
$tags = [];
}
foreach ($tags as $tag) {
- dba::insert('gserver-tag', ['gserver-id' => $gserver['id'], 'tag' => $tag], true);
+ DBA::insert('gserver-tag', ['gserver-id' => $gserver['id'], 'tag' => $tag], true);
}
}
}
$fields = ['last_poco_query' => DateTimeFormat::utcNow()];
- dba::update('gserver', $fields, ['nurl' => $server["nurl"]]);
+ DBA::update('gserver', $fields, ['nurl' => $server["nurl"]]);
return true;
} else {
// If we couldn't reach the server, we will try it some time later
$fields = ['last_poco_query' => DateTimeFormat::utcNow()];
- dba::update('gserver', $fields, ['nurl' => $server["nurl"]]);
+ DBA::update('gserver', $fields, ['nurl' => $server["nurl"]]);
return false;
}
if (!self::checkServer($server["url"], $server["network"])) {
// The server is not reachable? Okay, then we will try it later
$fields = ['last_poco_query' => DateTimeFormat::utcNow()];
- dba::update('gserver', $fields, ['nurl' => $server["nurl"]]);
+ DBA::update('gserver', $fields, ['nurl' => $server["nurl"]]);
continue;
}
use Friendica\Core\Config;
use Friendica\Core\PConfig;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\User;
{
while (!feof(STDIN)) {
// Quit if the database connection went down
- if (!dba::connected()) {
+ if (!DBA::connected()) {
$this->writeLog(LOG_ERR, 'the database connection went down');
return;
}
// Does the hostname match? So we try directly
if ($a->get_hostname() == $aCommand[2]) {
$this->writeLog(LOG_INFO, 'internal user check for ' . $sUser . '@' . $aCommand[2]);
- $found = dba::exists('user', ['nickname' => $sUser]);
+ $found = DBA::exists('user', ['nickname' => $sUser]);
} else {
$found = false;
}
if ($a->get_hostname() == $aCommand[2]) {
$this->writeLog(LOG_INFO, 'internal auth for ' . $sUser . '@' . $aCommand[2]);
- $aUser = dba::selectFirst('user', ['uid', 'password', 'legacy_password'], ['nickname' => $sUser]);
+ $aUser = DBA::selectFirst('user', ['uid', 'password', 'legacy_password'], ['nickname' => $sUser]);
if (DBM::is_result($aUser)) {
$uid = $aUser['uid'];
$success = User::authenticate($aUser, $aCommand[3]);
namespace Friendica\Util;
use Friendica\Core\Config;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
/**
private static function getActivitypubKey($id)
{
if (strpos($id, 'acct:') === 0) {
- $contact = dba::selectFirst('contact', ['pubkey'], ['uid' => 0, 'addr' => str_replace('acct:', '', $id)]);
+ $contact = DBA::selectFirst('contact', ['pubkey'], ['uid' => 0, 'addr' => str_replace('acct:', '', $id)]);
} else {
- $contact = dba::selectFirst('contact', ['pubkey'], ['id' => $id, 'network' => 'activitypub']);
+ $contact = DBA::selectFirst('contact', ['pubkey'], ['id' => $id, 'network' => 'activitypub']);
}
if (DBM::is_result($contact)) {
use DOMXPath;
use Friendica\Content\OEmbed;
use Friendica\Core\Addon;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Object\Image;
require_once 'include/dba.php';
return false;
}
- $parsed_url = dba::selectFirst('parsed_url', ['content'],
+ $parsed_url = DBA::selectFirst('parsed_url', ['content'],
['url' => normalise_link($url), 'guessing' => !$no_guessing, 'oembed' => $do_oembed]
);
if (!empty($parsed_url['content'])) {
$data = self::getSiteinfo($url, $no_guessing, $do_oembed);
- dba::insert(
+ DBA::insert(
'parsed_url',
[
'url' => normalise_link($url), 'guessing' => !$no_guessing,
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\Worker;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Util\DateTimeFormat;
if (Config::get('system', 'last_cron_hourly', 0) + 3600 < time()) {
// Delete all done workerqueue entries
- dba::delete('workerqueue', ['`done` AND `executed` < UTC_TIMESTAMP() - INTERVAL 1 HOUR']);
+ DBA::delete('workerqueue', ['`done` AND `executed` < UTC_TIMESTAMP() - INTERVAL 1 HOUR']);
// Optimizing this table only last seconds
if (Config::get('system', 'optimize_workerqueue', false)) {
- dba::e("OPTIMIZE TABLE `workerqueue`");
+ DBA::e("OPTIMIZE TABLE `workerqueue`");
}
Config::set('system', 'last_cron_hourly', time());
use Friendica\BaseObject;
use Friendica\Core\Cache;
use Friendica\Core\Config;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Database\PostUpdate;
use Friendica\Model\Contact;
{
// expire any expired regular accounts. Don't expire forums.
$condition = ["NOT `account_expired` AND `account_expires_on` > ? AND `account_expires_on` < UTC_TIMESTAMP() AND `page-flags` = 0", NULL_DATE];
- dba::update('user', ['account_expired' => true], $condition);
+ DBA::update('user', ['account_expired' => true], $condition);
// Remove any freshly expired account
- $users = dba::select('user', ['uid'], ['account_expired' => true, 'account_removed' => false]);
- while ($user = dba::fetch($users)) {
+ $users = DBA::select('user', ['uid'], ['account_expired' => true, 'account_removed' => false]);
+ while ($user = DBA::fetch($users)) {
User::remove($user['uid']);
}
// delete user records for recently removed accounts
- $users = dba::select('user', ['uid'], ["`account_removed` AND `account_expires_on` < UTC_TIMESTAMP() - INTERVAL 3 DAY"]);
- while ($user = dba::fetch($users)) {
- dba::delete('user', ['uid' => $user['uid']]);
+ $users = DBA::select('user', ['uid'], ["`account_removed` AND `account_expires_on` < UTC_TIMESTAMP() - INTERVAL 3 DAY"]);
+ while ($user = DBA::fetch($users)) {
+ DBA::delete('user', ['uid' => $user['uid']]);
}
}
$cachetime = PROXY_DEFAULT_TIME;
}
$condition = ['`uid` = 0 AND `resource-id` LIKE "pic:%" AND `created` < NOW() - INTERVAL ? SECOND', $cachetime];
- dba::delete('photo', $condition);
+ DBA::delete('photo', $condition);
}
// Delete the cached OEmbed entries that are older than three month
- dba::delete('oembed', ["`created` < NOW() - INTERVAL 3 MONTH"]);
+ DBA::delete('oembed', ["`created` < NOW() - INTERVAL 3 MONTH"]);
// Delete the cached "parse_url" entries that are older than three month
- dba::delete('parsed_url', ["`created` < NOW() - INTERVAL 3 MONTH"]);
+ DBA::delete('parsed_url', ["`created` < NOW() - INTERVAL 3 MONTH"]);
// Maximum table size in megabyte
$max_tablesize = intval(Config::get('system', 'optimize_max_tablesize')) * 1000000;
use Friendica\Core\Config;
use Friendica\Core\Worker;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
require_once 'include/dba.php';
$last_id = Config::get('system', 'dbclean-last-id-1', 0);
logger("Deleting old global item entries from item table without user copy. Last ID: ".$last_id);
- $r = dba::p("SELECT `id` FROM `item` WHERE `uid` = 0 AND
+ $r = DBA::p("SELECT `id` FROM `item` WHERE `uid` = 0 AND
NOT EXISTS (SELECT `guid` FROM `item` AS `i` WHERE `item`.`guid` = `i`.`guid` AND `i`.`uid` != 0) AND
`received` < UTC_TIMESTAMP() - INTERVAL ? DAY AND `id` >= ?
ORDER BY `id` LIMIT ".intval($limit), $days_unclaimed, $last_id);
- $count = dba::num_rows($r);
+ $count = DBA::num_rows($r);
if ($count > 0) {
logger("found global item orphans: ".$count);
- while ($orphan = dba::fetch($r)) {
+ while ($orphan = DBA::fetch($r)) {
$last_id = $orphan["id"];
- dba::delete('item', ['id' => $orphan["id"]]);
+ DBA::delete('item', ['id' => $orphan["id"]]);
}
Worker::add(PRIORITY_MEDIUM, 'DBClean', 1, $last_id);
} else {
logger("No global item orphans found");
}
- dba::close($r);
+ DBA::close($r);
logger("Done deleting ".$count." old global item entries from item table without user copy. Last ID: ".$last_id);
Config::set('system', 'dbclean-last-id-1', $last_id);
$last_id = Config::get('system', 'dbclean-last-id-2', 0);
logger("Deleting items without parents. Last ID: ".$last_id);
- $r = dba::p("SELECT `id` FROM `item`
+ $r = DBA::p("SELECT `id` FROM `item`
WHERE NOT EXISTS (SELECT `id` FROM `item` AS `i` WHERE `item`.`parent` = `i`.`id`)
AND `id` >= ? ORDER BY `id` LIMIT ".intval($limit), $last_id);
- $count = dba::num_rows($r);
+ $count = DBA::num_rows($r);
if ($count > 0) {
logger("found item orphans without parents: ".$count);
- while ($orphan = dba::fetch($r)) {
+ while ($orphan = DBA::fetch($r)) {
$last_id = $orphan["id"];
- dba::delete('item', ['id' => $orphan["id"]]);
+ DBA::delete('item', ['id' => $orphan["id"]]);
}
Worker::add(PRIORITY_MEDIUM, 'DBClean', 2, $last_id);
} else {
logger("No item orphans without parents found");
}
- dba::close($r);
+ DBA::close($r);
logger("Done deleting ".$count." items without parents. Last ID: ".$last_id);
Config::set('system', 'dbclean-last-id-2', $last_id);
$last_id = Config::get('system', 'dbclean-last-id-3', 0);
logger("Deleting orphaned data from thread table. Last ID: ".$last_id);
- $r = dba::p("SELECT `iid` FROM `thread`
+ $r = DBA::p("SELECT `iid` FROM `thread`
WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`parent` = `thread`.`iid`) AND `iid` >= ?
ORDER BY `iid` LIMIT ".intval($limit), $last_id);
- $count = dba::num_rows($r);
+ $count = DBA::num_rows($r);
if ($count > 0) {
logger("found thread orphans: ".$count);
- while ($orphan = dba::fetch($r)) {
+ while ($orphan = DBA::fetch($r)) {
$last_id = $orphan["iid"];
- dba::delete('thread', ['iid' => $orphan["iid"]]);
+ DBA::delete('thread', ['iid' => $orphan["iid"]]);
}
Worker::add(PRIORITY_MEDIUM, 'DBClean', 3, $last_id);
} else {
logger("No thread orphans found");
}
- dba::close($r);
+ DBA::close($r);
logger("Done deleting ".$count." orphaned data from thread table. Last ID: ".$last_id);
Config::set('system', 'dbclean-last-id-3', $last_id);
$last_id = Config::get('system', 'dbclean-last-id-4', 0);
logger("Deleting orphaned data from notify table. Last ID: ".$last_id);
- $r = dba::p("SELECT `iid`, `id` FROM `notify`
+ $r = DBA::p("SELECT `iid`, `id` FROM `notify`
WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`id` = `notify`.`iid`) AND `id` >= ?
ORDER BY `id` LIMIT ".intval($limit), $last_id);
- $count = dba::num_rows($r);
+ $count = DBA::num_rows($r);
if ($count > 0) {
logger("found notify orphans: ".$count);
- while ($orphan = dba::fetch($r)) {
+ while ($orphan = DBA::fetch($r)) {
$last_id = $orphan["id"];
- dba::delete('notify', ['iid' => $orphan["iid"]]);
+ DBA::delete('notify', ['iid' => $orphan["iid"]]);
}
Worker::add(PRIORITY_MEDIUM, 'DBClean', 4, $last_id);
} else {
logger("No notify orphans found");
}
- dba::close($r);
+ DBA::close($r);
logger("Done deleting ".$count." orphaned data from notify table. Last ID: ".$last_id);
Config::set('system', 'dbclean-last-id-4', $last_id);
$last_id = Config::get('system', 'dbclean-last-id-5', 0);
logger("Deleting orphaned data from notify-threads table. Last ID: ".$last_id);
- $r = dba::p("SELECT `id` FROM `notify-threads`
+ $r = DBA::p("SELECT `id` FROM `notify-threads`
WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`parent` = `notify-threads`.`master-parent-item`) AND `id` >= ?
ORDER BY `id` LIMIT ".intval($limit), $last_id);
- $count = dba::num_rows($r);
+ $count = DBA::num_rows($r);
if ($count > 0) {
logger("found notify-threads orphans: ".$count);
- while ($orphan = dba::fetch($r)) {
+ while ($orphan = DBA::fetch($r)) {
$last_id = $orphan["id"];
- dba::delete('notify-threads', ['id' => $orphan["id"]]);
+ DBA::delete('notify-threads', ['id' => $orphan["id"]]);
}
Worker::add(PRIORITY_MEDIUM, 'DBClean', 5, $last_id);
} else {
logger("No notify-threads orphans found");
}
- dba::close($r);
+ DBA::close($r);
logger("Done deleting ".$count." orphaned data from notify-threads table. Last ID: ".$last_id);
Config::set('system', 'dbclean-last-id-5', $last_id);
$last_id = Config::get('system', 'dbclean-last-id-6', 0);
logger("Deleting orphaned data from sign table. Last ID: ".$last_id);
- $r = dba::p("SELECT `iid`, `id` FROM `sign`
+ $r = DBA::p("SELECT `iid`, `id` FROM `sign`
WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`id` = `sign`.`iid`) AND `id` >= ?
ORDER BY `id` LIMIT ".intval($limit), $last_id);
- $count = dba::num_rows($r);
+ $count = DBA::num_rows($r);
if ($count > 0) {
logger("found sign orphans: ".$count);
- while ($orphan = dba::fetch($r)) {
+ while ($orphan = DBA::fetch($r)) {
$last_id = $orphan["id"];
- dba::delete('sign', ['iid' => $orphan["iid"]]);
+ DBA::delete('sign', ['iid' => $orphan["iid"]]);
}
Worker::add(PRIORITY_MEDIUM, 'DBClean', 6, $last_id);
} else {
logger("No sign orphans found");
}
- dba::close($r);
+ DBA::close($r);
logger("Done deleting ".$count." orphaned data from sign table. Last ID: ".$last_id);
Config::set('system', 'dbclean-last-id-6', $last_id);
$last_id = Config::get('system', 'dbclean-last-id-7', 0);
logger("Deleting orphaned data from term table. Last ID: ".$last_id);
- $r = dba::p("SELECT `oid`, `tid` FROM `term`
+ $r = DBA::p("SELECT `oid`, `tid` FROM `term`
WHERE NOT EXISTS (SELECT `id` FROM `item` WHERE `item`.`id` = `term`.`oid`) AND `tid` >= ?
ORDER BY `tid` LIMIT ".intval($limit), $last_id);
- $count = dba::num_rows($r);
+ $count = DBA::num_rows($r);
if ($count > 0) {
logger("found term orphans: ".$count);
- while ($orphan = dba::fetch($r)) {
+ while ($orphan = DBA::fetch($r)) {
$last_id = $orphan["tid"];
- dba::delete('term', ['oid' => $orphan["oid"]]);
+ DBA::delete('term', ['oid' => $orphan["oid"]]);
}
Worker::add(PRIORITY_MEDIUM, 'DBClean', 7, $last_id);
} else {
logger("No term orphans found");
}
- dba::close($r);
+ DBA::close($r);
logger("Done deleting ".$count." orphaned data from term table. Last ID: ".$last_id);
Config::set('system', 'dbclean-last-id-7', $last_id);
$last_id = Config::get('system', 'dbclean-last-id-8', 0);
logger("Deleting expired threads. Last ID: ".$last_id);
- $r = dba::p("SELECT `thread`.`iid` FROM `thread`
+ $r = DBA::p("SELECT `thread`.`iid` FROM `thread`
INNER JOIN `contact` ON `thread`.`contact-id` = `contact`.`id` AND NOT `notify_new_posts`
WHERE `thread`.`received` < UTC_TIMESTAMP() - INTERVAL ? DAY
AND NOT `thread`.`mention` AND NOT `thread`.`starred`
OR (`item`.`attach` != '') OR `item`.`wall` OR `item`.`origin`)
AND `item`.`parent` = `thread`.`iid`)
ORDER BY `thread`.`iid` LIMIT 1000", $days, $last_id);
- $count = dba::num_rows($r);
+ $count = DBA::num_rows($r);
if ($count > 0) {
logger("found expired threads: ".$count);
- while ($thread = dba::fetch($r)) {
+ while ($thread = DBA::fetch($r)) {
$last_id = $thread["iid"];
- dba::delete('thread', ['iid' => $thread["iid"]]);
+ DBA::delete('thread', ['iid' => $thread["iid"]]);
}
Worker::add(PRIORITY_MEDIUM, 'DBClean', 8, $last_id);
} else {
logger("No expired threads found");
}
- dba::close($r);
+ DBA::close($r);
logger("Done deleting ".$count." expired threads. Last ID: ".$last_id);
Config::set('system', 'dbclean-last-id-8', $last_id);
$till_id = Config::get('system', 'dbclean-last-id-8', 0);
logger("Deleting old global item entries from expired threads from ID ".$last_id." to ID ".$till_id);
- $r = dba::p("SELECT `id` FROM `item` WHERE `uid` = 0 AND
+ $r = DBA::p("SELECT `id` FROM `item` WHERE `uid` = 0 AND
NOT EXISTS (SELECT `guid` FROM `item` AS `i` WHERE `item`.`guid` = `i`.`guid` AND `i`.`uid` != 0) AND
`received` < UTC_TIMESTAMP() - INTERVAL 90 DAY AND `id` >= ? AND `id` <= ?
ORDER BY `id` LIMIT ".intval($limit), $last_id, $till_id);
- $count = dba::num_rows($r);
+ $count = DBA::num_rows($r);
if ($count > 0) {
logger("found global item entries from expired threads: ".$count);
- while ($orphan = dba::fetch($r)) {
+ while ($orphan = DBA::fetch($r)) {
$last_id = $orphan["id"];
- dba::delete('item', ['id' => $orphan["id"]]);
+ DBA::delete('item', ['id' => $orphan["id"]]);
}
Worker::add(PRIORITY_MEDIUM, 'DBClean', 9, $last_id);
} else {
logger("No global item entries from expired threads");
}
- dba::close($r);
+ DBA::close($r);
logger("Done deleting ".$count." old global item entries from expired threads. Last ID: ".$last_id);
Config::set('system', 'dbclean-last-id-9', $last_id);
$days = intval(Config::get('system', 'dbclean_expire_conversation', 90));
logger("Deleting old conversations. Last created: ".$last_id);
- $r = dba::p("SELECT `received`, `item-uri` FROM `conversation`
+ $r = DBA::p("SELECT `received`, `item-uri` FROM `conversation`
WHERE `received` < UTC_TIMESTAMP() - INTERVAL ? DAY
ORDER BY `received` LIMIT ".intval($limit), $days);
- $count = dba::num_rows($r);
+ $count = DBA::num_rows($r);
if ($count > 0) {
logger("found old conversations: ".$count);
- while ($orphan = dba::fetch($r)) {
+ while ($orphan = DBA::fetch($r)) {
$last_id = $orphan["received"];
- dba::delete('conversation', ['item-uri' => $orphan["item-uri"]]);
+ DBA::delete('conversation', ['item-uri' => $orphan["item-uri"]]);
}
Worker::add(PRIORITY_MEDIUM, 'DBClean', 10, $last_id);
} else {
logger("No old conversations found");
}
- dba::close($r);
+ DBA::close($r);
logger("Done deleting ".$count." conversations. Last created: ".$last_id);
Config::set('system', 'dbclean-last-id-10', $last_id);
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Item;
$public_message = false;
if ($cmd == self::MAIL) {
- $target_item = dba::selectFirst('mail', [], ['id' => $item_id]);
+ $target_item = DBA::selectFirst('mail', [], ['id' => $item_id]);
if (!DBM::is_result($target_item)) {
return;
}
$uid = $target_item['uid'];
$items = [];
} elseif ($cmd == self::SUGGESTION) {
- $target_item = dba::selectFirst('fsuggest', [], ['id' => $item_id]);
+ $target_item = DBA::selectFirst('fsuggest', [], ['id' => $item_id]);
if (!DBM::is_result($target_item)) {
return;
}
}
$items[] = $item;
}
- dba::close($itemdata);
+ DBA::close($itemdata);
$uid = $target_item['contact-uid'];
}
// We don't deliver our items to blocked or pending contacts, and not to ourselves either
- $contact = dba::selectFirst('contact', [],
+ $contact = DBA::selectFirst('contact', [],
['id' => $contact_id, 'blocked' => false, 'pending' => false, 'self' => false]
);
if (!DBM::is_result($contact)) {
} elseif ($cmd == self::SUGGESTION) {
$item = $target_item;
$atom = DFRN::fsuggest($item, $owner);
- dba::delete('fsuggest', ['id' => $item['id']]);
+ DBA::delete('fsuggest', ['id' => $item['id']]);
} elseif ($cmd == self::RELOCATION) {
$atom = DFRN::relocate($owner, $owner['uid']);
} elseif ($followup) {
if (link_compare($basepath, System::baseUrl())) {
$condition = ['nurl' => normalise_link($contact['url']), 'self' => true];
- $target_self = dba::selectFirst('contact', ['uid'], $condition);
+ $target_self = DBA::selectFirst('contact', ['uid'], $condition);
if (!DBM::is_result($target_self)) {
return;
}
}
// We now have some contact, so we fetch it
- $target_importer = dba::fetch_first("SELECT *, `name` as `senderName`
+ $target_importer = DBA::fetch_first("SELECT *, `name` as `senderName`
FROM `contact`
WHERE NOT `blocked` AND `id` = ? LIMIT 1",
$cid);
return;
}
- $user = dba::selectFirst('user', [], ['uid' => $target_uid]);
+ $user = DBA::selectFirst('user', [], ['uid' => $target_uid]);
$target_importer = array_merge($target_importer, $user);
return;
}
- $local_user = dba::selectFirst('user', [], ['uid' => $owner['uid']]);
+ $local_user = DBA::selectFirst('user', [], ['uid' => $owner['uid']]);
if (!DBM::is_result($local_user)) {
return;
}
logger('Deliver ' . $target_item["guid"] . ' via mail to ' . $contact['addr']);
$reply_to = '';
- $mailacct = dba::selectFirst('mailacct', ['reply_to'], ['uid' => $owner['uid']]);
+ $mailacct = DBA::selectFirst('mailacct', ['reply_to'], ['uid' => $owner['uid']]);
if (DBM::is_result($mailacct) && !empty($mailacct['reply_to'])) {
$reply_to = $mailacct['reply_to'];
}
use Friendica\Core\Cache;
use Friendica\Core\Config;
use Friendica\Core\Worker;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\GContact;
use Friendica\Network\Probe;
$urlparts = parse_url($user["url"]);
if (!isset($urlparts["scheme"])) {
- dba::update('gcontact', ['network' => NETWORK_PHANTOM],
+ DBA::update('gcontact', ['network' => NETWORK_PHANTOM],
['nurl' => normalise_link($user["url"])]);
continue;
}
"identi.ca" => NETWORK_PUMPIO,
"alpha.app.net" => NETWORK_APPNET];
- dba::update('gcontact', ['network' => $networks[$urlparts["host"]]],
+ DBA::update('gcontact', ['network' => $networks[$urlparts["host"]]],
['nurl' => normalise_link($user["url"])]);
continue;
}
return;
}
} else {
- dba::update('gcontact', ['last_failure' => DateTimeFormat::utcNow()],
+ DBA::update('gcontact', ['last_failure' => DateTimeFormat::utcNow()],
['nurl' => normalise_link($user["url"])]);
}
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\Worker;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Item;
logger('Delete expired items', LOGGER_DEBUG);
// physically remove anything that has been deleted for more than two months
$condition = ["`deleted` AND `changed` < UTC_TIMESTAMP() - INTERVAL 60 DAY"];
- $rows = dba::select('item', ['id', 'iaid', 'icid', 'psid'], $condition);
- while ($row = dba::fetch($rows)) {
- dba::delete('item', ['id' => $row['id']]);
- if (!empty($row['iaid']) && !dba::exists('item', ['iaid' => $row['iaid']])) {
- dba::delete('item-activity', ['id' => $row['iaid']]);
+ $rows = DBA::select('item', ['id', 'iaid', 'icid', 'psid'], $condition);
+ while ($row = DBA::fetch($rows)) {
+ DBA::delete('item', ['id' => $row['id']]);
+ if (!empty($row['iaid']) && !DBA::exists('item', ['iaid' => $row['iaid']])) {
+ DBA::delete('item-activity', ['id' => $row['iaid']]);
}
- if (!empty($row['icid']) && !dba::exists('item', ['icid' => $row['icid']])) {
- dba::delete('item-content', ['id' => $row['icid']]);
+ if (!empty($row['icid']) && !DBA::exists('item', ['icid' => $row['icid']])) {
+ DBA::delete('item-content', ['id' => $row['icid']]);
}
// When the permission set will be used in photo and events as well.
// this query here needs to be extended.
- if (!empty($row['psid']) && !dba::exists('item', ['psid' => $row['psid']])) {
- dba::delete('permissionset', ['id' => $row['psid']]);
+ if (!empty($row['psid']) && !DBA::exists('item', ['psid' => $row['psid']])) {
+ DBA::delete('permissionset', ['id' => $row['psid']]);
}
}
- dba::close($rows);
+ DBA::close($rows);
// Normally we shouldn't have orphaned data at all.
// If we do have some, then we have to check why.
logger('Deleting orphaned item activities - start', LOGGER_DEBUG);
$condition = ["NOT EXISTS (SELECT `iaid` FROM `item` WHERE `item`.`iaid` = `item-activity`.`id`)"];
- dba::delete('item-activity', $condition);
- logger('Orphaned item activities deleted: ' . dba::affected_rows(), LOGGER_DEBUG);
+ DBA::delete('item-activity', $condition);
+ logger('Orphaned item activities deleted: ' . DBA::affected_rows(), LOGGER_DEBUG);
logger('Deleting orphaned item content - start', LOGGER_DEBUG);
$condition = ["NOT EXISTS (SELECT `icid` FROM `item` WHERE `item`.`icid` = `item-content`.`id`)"];
- dba::delete('item-content', $condition);
- logger('Orphaned item content deleted: ' . dba::affected_rows(), LOGGER_DEBUG);
+ DBA::delete('item-content', $condition);
+ logger('Orphaned item content deleted: ' . DBA::affected_rows(), LOGGER_DEBUG);
// make this optional as it could have a performance impact on large sites
if (intval(Config::get('system', 'optimize_items'))) {
- dba::e("OPTIMIZE TABLE `item`");
+ DBA::e("OPTIMIZE TABLE `item`");
}
logger('Delete expired items - done', LOGGER_DEBUG);
return;
} elseif (intval($param) > 0) {
- $user = dba::selectFirst('user', ['uid', 'username', 'expire'], ['uid' => $param]);
+ $user = DBA::selectFirst('user', ['uid', 'username', 'expire'], ['uid' => $param]);
if (DBM::is_result($user)) {
logger('Expire items for user '.$user['uid'].' ('.$user['username'].') - interval: '.$user['expire'], LOGGER_DEBUG);
Item::expire($user['uid'], $user['expire']);
Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true],
'Expire', 'delete');
- $r = dba::p("SELECT `uid`, `username` FROM `user` WHERE `expire` != 0");
- while ($row = dba::fetch($r)) {
+ $r = DBA::p("SELECT `uid`, `username` FROM `user` WHERE `expire` != 0");
+ while ($row = DBA::fetch($r)) {
logger('Calling expiry for user '.$row['uid'].' ('.$row['username'].')', LOGGER_DEBUG);
Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true],
'Expire', (int)$row['uid']);
}
- dba::close($r);
+ DBA::close($r);
logger('expire: calling hooks');
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\Worker;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Group;
if ($cmd == Delivery::MAIL) {
$normal_mode = false;
- $message = dba::selectFirst('mail', ['uid', 'contact-id'], ['id' => $item_id]);
+ $message = DBA::selectFirst('mail', ['uid', 'contact-id'], ['id' => $item_id]);
if (!DBM::is_result($message)) {
return;
}
$recipients[] = $message['contact-id'];
} elseif ($cmd == Delivery::SUGGESTION) {
$normal_mode = false;
- $suggest = dba::selectFirst('fsuggest', ['uid', 'cid'], ['id' => $item_id]);
+ $suggest = DBA::selectFirst('fsuggest', ['uid', 'cid'], ['id' => $item_id]);
if (!DBM::is_result($suggest)) {
return;
}
$fields = ['forum', 'prv'];
$condition = ['id' => $target_item['contact-id']];
- $contact = dba::selectFirst('contact', $fields, $condition);
+ $contact = DBA::selectFirst('contact', $fields, $condition);
if (!DBM::is_result($contact)) {
// Should never happen
return false;
logger('Some parent is OStatus for '.$target_item["guid"]." - Author: ".$thr_parent['author-id']." - Owner: ".$thr_parent['owner-id'], LOGGER_DEBUG);
// Send a salmon to the parent author
- $probed_contact = dba::selectFirst('contact', ['url', 'notify'], ['id' => $thr_parent['author-id']]);
+ $probed_contact = DBA::selectFirst('contact', ['url', 'notify'], ['id' => $thr_parent['author-id']]);
if (DBM::is_result($probed_contact) && !empty($probed_contact["notify"])) {
logger('Notify parent author '.$probed_contact["url"].': '.$probed_contact["notify"]);
$url_recipients[$probed_contact["notify"]] = $probed_contact["notify"];
}
// Send a salmon to the parent owner
- $probed_contact = dba::selectFirst('contact', ['url', 'notify'], ['id' => $thr_parent['owner-id']]);
+ $probed_contact = DBA::selectFirst('contact', ['url', 'notify'], ['id' => $thr_parent['owner-id']]);
if (DBM::is_result($probed_contact) && !empty($probed_contact["notify"])) {
logger('Notify parent owner '.$probed_contact["url"].': '.$probed_contact["notify"]);
$url_recipients[$probed_contact["notify"]] = $probed_contact["notify"];
if (!empty($networks)) {
$condition['network'] = $networks;
}
- $contacts = dba::select('contact', ['id', 'url', 'network'], $condition);
- $r = dba::inArray($contacts);
+ $contacts = DBA::select('contact', ['id', 'url', 'network'], $condition);
+ $r = DBA::inArray($contacts);
}
// delivery loop
$condition = ['network' => NETWORK_DFRN, 'uid' => $owner['uid'], 'blocked' => false,
'pending' => false, 'archive' => false, 'rel' => [CONTACT_IS_FOLLOWER, CONTACT_IS_FRIEND]];
- $r2 = dba::inArray(dba::select('contact', ['id', 'name', 'network'], $condition));
+ $r2 = DBA::inArray(DBA::select('contact', ['id', 'name', 'network'], $condition));
$r = array_merge($r2, $r1);
use Friendica\Content\Text\BBCode;
use Friendica\Core\Config;
use Friendica\Core\PConfig;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Item;
$d = DateTimeFormat::utcNow();
- $contact = dba::selectFirst('contact', [], ['id' => $contact_id]);
+ $contact = DBA::selectFirst('contact', [], ['id' => $contact_id]);
if (!DBM::is_result($contact)) {
logger('Contact not found or cannot be used.');
return;
logger("Skipping probably dead contact ".$contact['url']);
// set the last-update so we don't keep polling
- dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
+ DBA::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
return;
}
logger('Contact is marked dead');
// set the last-update so we don't keep polling
- dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
+ DBA::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
return;
} else {
Contact::unmarkForArchival($contact);
logger('Ignore public contacts');
// set the last-update so we don't keep polling
- dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
+ DBA::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
return;
}
logger('No self contact for user '.$importer_uid);
// set the last-update so we don't keep polling
- dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
+ DBA::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
return;
}
if (!intval($contact['writable'])) {
$fields = ['writable' => true];
- dba::update('contact', $fields, ['id' => $contact['id']]);
+ DBA::update('contact', $fields, ['id' => $contact['id']]);
}
$url = $contact['poll'] . '?dfrn_id=' . $idtosend
if (!$ret["success"] && ($ret['errno'] == CURLE_OPERATION_TIMEDOUT)) {
// set the last-update so we don't keep polling
- dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
+ DBA::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
Contact::markForArchival($contact);
return;
}
if ((intval($res->status) != 0) || !strlen($res->challenge) || !strlen($res->dfrn_id)) {
// set the last-update so we don't keep polling
- dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
+ DBA::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
return;
}
if (((float)$res->dfrn_version > 2.21) && ($contact['poco'] == '')) {
$fields = ['poco' => str_replace('/profile/', '/poco/', $contact['url'])];
- dba::update('contact', $fields, ['id' => $contact['id']]);
+ DBA::update('contact', $fields, ['id' => $contact['id']]);
}
$postvars = [];
logger('ID did not decode: ' . $contact['id'] . ' orig: ' . $orig_id . ' final: ' . $final_dfrn_id);
// set the last-update so we don't keep polling
- dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
+ DBA::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
Contact::markForArchival($contact);
return;
}
if ($stat_writeable != $contact['writable']) {
$fields = ['writable' => $stat_writeable];
- dba::update('contact', $fields, ['id' => $contact['id']]);
+ DBA::update('contact', $fields, ['id' => $contact['id']]);
}
// Are we allowed to import from this person?
if ($contact['rel'] == CONTACT_IS_FOLLOWER || $contact['blocked']) {
// set the last-update so we don't keep polling
- dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
+ DBA::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
return;
}
if (!$ret["success"] && ($ret['errno'] == CURLE_OPERATION_TIMEDOUT)) {
// set the last-update so we don't keep polling
- dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
+ DBA::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
Contact::markForArchival($contact);
return;
}
$mail_disabled = ((function_exists('imap_open') && (! Config::get('system', 'imap_disabled'))) ? 0 : 1);
if ($mail_disabled) {
// set the last-update so we don't keep polling
- dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
+ DBA::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]);
Contact::markForArchival($contact);
return;
}
logger("Mail: Enabled", LOGGER_DEBUG);
$mbox = null;
- $user = dba::selectFirst('user', ['prvkey'], ['uid' => $importer_uid]);
+ $user = DBA::selectFirst('user', ['prvkey'], ['uid' => $importer_uid]);
$condition = ["`server` != '' AND `uid` = ?", $importer_uid];
- $mailconf = dba::selectFirst('mailacct', [], $condition);
+ $mailconf = DBA::selectFirst('mailacct', [], $condition);
if (DBM::is_result($user) && DBM::is_result($mailconf)) {
$mailbox = Email::constructMailboxName($mailconf);
$password = '';
logger("Mail: Connect to " . $mailconf['user']);
if ($mbox) {
$fields = ['last_check' => DateTimeFormat::utcNow()];
- dba::update('mailacct', $fields, ['id' => $mailconf['id']]);
+ DBA::update('mailacct', $fields, ['id' => $mailconf['id']]);
logger("Mail: Connected to " . $mailconf['user']);
} else {
logger("Mail: Connection error ".$mailconf['user']." ".print_r(imap_errors(), true));
$updated = DateTimeFormat::utcNow();
self::updateContact($contact, ['last-update' => $updated, 'success_update' => $updated]);
- dba::update('gcontact', ['last_contact' => $updated], ['nurl' => $contact['nurl']]);
+ DBA::update('gcontact', ['last_contact' => $updated], ['nurl' => $contact['nurl']]);
Contact::unmarkForArchival($contact);
} elseif (in_array($contact["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, NETWORK_FEED])) {
$updated = DateTimeFormat::utcNow();
self::updateContact($contact, ['last-update' => $updated, 'failure_update' => $updated]);
- dba::update('gcontact', ['last_failure' => $updated], ['nurl' => $contact['nurl']]);
+ DBA::update('gcontact', ['last_failure' => $updated], ['nurl' => $contact['nurl']]);
Contact::markForArchival($contact);
} else {
$updated = DateTimeFormat::utcNow();
- dba::update('contact', ['last-update' => $updated], ['id' => $contact['id']]);
+ DBA::update('contact', ['last-update' => $updated], ['id' => $contact['id']]);
}
return;
*/
private static function updateContact($contact, $fields)
{
- dba::update('contact', $fields, ['id' => $contact['id']]);
- dba::update('contact', $fields, ['uid' => 0, 'nurl' => $contact['nurl']]);
+ DBA::update('contact', $fields, ['id' => $contact['id']]);
+ DBA::update('contact', $fields, ['uid' => 0, 'nurl' => $contact['nurl']]);
}
}
use Friendica\BaseObject;
use Friendica\Core\System;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\PushSubscriber;
use Friendica\Protocol\OStatus;
{
$a = BaseObject::getApp();
- $subscriber = dba::selectFirst('push_subscriber', [], ['id' => $id]);
+ $subscriber = DBA::selectFirst('push_subscriber', [], ['id' => $id]);
if (!DBM::is_result($subscriber)) {
return;
}
use Friendica\Core\Cache;
use Friendica\Core\Config;
use Friendica\Core\Worker;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\PushSubscriber;
use Friendica\Model\Queue as QueueModel;
// Handling the pubsubhubbub requests
PushSubscriber::requeue();
- $r = dba::inArray(dba::p("SELECT `id` FROM `queue` WHERE `next` < UTC_TIMESTAMP() ORDER BY `batch`, `cid`"));
+ $r = DBA::inArray(DBA::p("SELECT `id` FROM `queue` WHERE `next` < UTC_TIMESTAMP() ORDER BY `batch`, `cid`"));
Addon::callHooks('queue_predeliver', $r);
// delivering
- $q_item = dba::selectFirst('queue', [], ['id' => $queue_id]);
+ $q_item = DBA::selectFirst('queue', [], ['id' => $queue_id]);
if (!DBM::is_result($q_item)) {
return;
}
- $contact = dba::selectFirst('contact', [], ['id' => $q_item['cid']]);
+ $contact = DBA::selectFirst('contact', [], ['id' => $q_item['cid']]);
if (!DBM::is_result($contact)) {
QueueModel::removeItem($q_item['id']);
return;
}
}
- $user = dba::selectFirst('user', [], ['uid' => $contact['uid']]);
+ $user = DBA::selectFirst('user', [], ['uid' => $contact['uid']]);
if (!DBM::is_result($user)) {
QueueModel::removeItem($q_item['id']);
return;
*/
namespace Friendica\Worker;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
require_once 'include/dba.php';
public static function execute($id) {
// Only delete if the contact doesn't exist (anymore)
- $r = dba::exists('contact', ['id' => $id]);
+ $r = DBA::exists('contact', ['id' => $id]);
if ($r) {
return;
}
// Now we delete all the depending table entries
- dba::delete('contact', ['id' => $id]);
+ DBA::delete('contact', ['id' => $id]);
}
}
namespace Friendica\Worker;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
class TagUpdate
{
public static function execute()
{
- $messages = dba::p("SELECT `oid`,`item`.`guid`, `item`.`created`, `item`.`received` FROM `term` INNER JOIN `item` ON `item`.`id`=`term`.`oid` WHERE `term`.`otype` = 1 AND `term`.`guid` = ''");
+ $messages = DBA::p("SELECT `oid`,`item`.`guid`, `item`.`created`, `item`.`received` FROM `term` INNER JOIN `item` ON `item`.`id`=`term`.`oid` WHERE `term`.`otype` = 1 AND `term`.`guid` = ''");
- logger('fetched messages: ' . dba::num_rows($messages));
- while ($message = dba::fetch($messages)) {
+ logger('fetched messages: ' . DBA::num_rows($messages));
+ while ($message = DBA::fetch($messages)) {
if ($message['uid'] == 0) {
$global = true;
- dba::update('term', ['global' => true], ['otype' => TERM_OBJ_POST, 'guid' => $message['guid']]);
+ DBA::update('term', ['global' => true], ['otype' => TERM_OBJ_POST, 'guid' => $message['guid']]);
} else {
- $global = (dba::count('term', ['uid' => 0, 'otype' => TERM_OBJ_POST, 'guid' => $message['guid']]) > 0);
+ $global = (DBA::count('term', ['uid' => 0, 'otype' => TERM_OBJ_POST, 'guid' => $message['guid']]) > 0);
}
$fields = ['guid' => $message['guid'], 'created' => $message['created'],
'received' => $message['received'], 'global' => $global];
- dba::update('term', $fields, ['otype' => TERM_OBJ_POST, 'oid' => $message['oid']]);
+ DBA::update('term', $fields, ['otype' => TERM_OBJ_POST, 'oid' => $message['oid']]);
}
- dba::close($messages);
+ DBA::close($messages);
- $messages = dba::select('item', ['guid'], ['uid' => 0]);
+ $messages = DBA::select('item', ['guid'], ['uid' => 0]);
- logger('fetched messages: ' . dba::num_rows($messages));
- while ($message = dba::fetch(messages)) {
- dba::update('item', ['global' => true], ['guid' => $message['guid']]);
+ logger('fetched messages: ' . DBA::num_rows($messages));
+ while ($message = DBA::fetch(messages)) {
+ DBA::update('item', ['global' => true], ['guid' => $message['guid']]);
}
- dba::close($messages);
+ DBA::close($messages);
}
}
namespace Friendica\Test;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use PHPUnit\DbUnit\DataSet\YamlDataSet;
use PHPUnit\DbUnit\TestCaseTrait;
use PHPUnit\Framework\TestCase;
*/
protected function getConnection()
{
- if (!dba::connected()) {
+ if (!DBA::connected()) {
$this->markTestSkipped('Could not connect to the database.');
}
- return $this->createDefaultDBConnection(dba::get_db(), getenv('MYSQL_DATABASE'));
+ return $this->createDefaultDBConnection(DBA::get_db(), getenv('MYSQL_DATABASE'));
}
/**
namespace Friendica\Test\src\Core\Lock;
use Friendica\Core\Lock\DatabaseLockDriver;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
class DatabaseLockDriverTest extends LockTest
{
public function tearDown()
{
- dba::delete('locks', [ 'id > 0']);
+ DBA::delete('locks', [ 'id > 0']);
parent::tearDown();
}
}
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\Worker;
-use Friendica\Database\dba;
+use Friendica\Database\DBA;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Item;
function update_1244() {
// Sets legacy_password for all legacy hashes
- dba::update('user', ['legacy_password' => true], ['SUBSTR(password, 1, 4) != "$2y$"']);
+ DBA::update('user', ['legacy_password' => true], ['SUBSTR(password, 1, 4) != "$2y$"']);
// All legacy hashes are re-hashed using the new secure hashing function
- $stmt = dba::select('user', ['uid', 'password'], ['legacy_password' => true]);
- while($user = dba::fetch($stmt)) {
- dba::update('user', ['password' => User::hashPassword($user['password'])], ['uid' => $user['uid']]);
+ $stmt = DBA::select('user', ['uid', 'password'], ['legacy_password' => true]);
+ while($user = DBA::fetch($stmt)) {
+ DBA::update('user', ['password' => User::hashPassword($user['password'])], ['uid' => $user['uid']]);
}
// Logged in users are forcibly logged out
- dba::delete('session', ['1 = 1']);
+ DBA::delete('session', ['1 = 1']);
return UPDATE_SUCCESS;
}
function update_1247() {
// Removing hooks with the old name
- dba::e("DELETE FROM `hook`
+ DBA::e("DELETE FROM `hook`
WHERE `hook` LIKE 'plugin_%'");
// Make sure we install the new renamed ones
Config::set('system', 'maintenance', 1);
Config::set('system', 'maintenance_reason', L10n::t('%s: Updating author-id and owner-id in item and thread table. ', DBM::date().' '.date('e')));
- $items = dba::p("SELECT `id`, `owner-link`, `owner-name`, `owner-avatar`, `network` FROM `item`
+ $items = DBA::p("SELECT `id`, `owner-link`, `owner-name`, `owner-avatar`, `network` FROM `item`
WHERE `owner-id` = 0 AND `owner-link` != ''");
- while ($item = dba::fetch($items)) {
+ while ($item = DBA::fetch($items)) {
$contact = ['url' => $item['owner-link'], 'name' => $item['owner-name'],
'photo' => $item['owner-avatar'], 'network' => $item['network']];
$cid = Contact::getIdForURL($item['owner-link'], 0, false, $contact);
}
Item::update(['owner-id' => $cid], ['id' => $item['id']]);
}
- dba::close($items);
+ DBA::close($items);
- dba::e("UPDATE `thread` INNER JOIN `item` ON `thread`.`iid` = `item`.`id`
+ DBA::e("UPDATE `thread` INNER JOIN `item` ON `thread`.`iid` = `item`.`id`
SET `thread`.`owner-id` = `item`.`owner-id` WHERE `thread`.`owner-id` = 0");
- $items = dba::p("SELECT `id`, `author-link`, `author-name`, `author-avatar`, `network` FROM `item`
+ $items = DBA::p("SELECT `id`, `author-link`, `author-name`, `author-avatar`, `network` FROM `item`
WHERE `author-id` = 0 AND `author-link` != ''");
- while ($item = dba::fetch($items)) {
+ while ($item = DBA::fetch($items)) {
$contact = ['url' => $item['author-link'], 'name' => $item['author-name'],
'photo' => $item['author-avatar'], 'network' => $item['network']];
$cid = Contact::getIdForURL($item['author-link'], 0, false, $contact);
}
Item::update(['author-id' => $cid], ['id' => $item['id']]);
}
- dba::close($items);
+ DBA::close($items);
- dba::e("UPDATE `thread` INNER JOIN `item` ON `thread`.`iid` = `item`.`id`
+ DBA::e("UPDATE `thread` INNER JOIN `item` ON `thread`.`iid` = `item`.`id`
SET `thread`.`author-id` = `item`.`author-id` WHERE `thread`.`author-id` = 0");
Config::set('system', 'maintenance', 0);
function update_1261() {
// This fixes the results of an issue in the develop branch of 2018-05.
- dba::update('contact', ['blocked' => false, 'pending' => false], ['uid' => 0, 'blocked' => true, 'pending' => true]);
+ DBA::update('contact', ['blocked' => false, 'pending' => false], ['uid' => 0, 'blocked' => true, 'pending' => true]);
return UPDATE_SUCCESS;
}