Replace old database queries with the new ones

This commit is contained in:
Michael 2018-05-02 19:26:15 +00:00
commit 4ad655ab80
12 changed files with 42 additions and 181 deletions

View file

@ -140,7 +140,7 @@ function dfrn_poll_init(App $a)
if ($type === 'profile-check' && $dfrn_version < 2.2) {
if ((strlen($challenge)) && (strlen($sec))) {
q("DELETE FROM `profile_check` WHERE `expire` < " . intval(time()));
dba::delete('profile_check', ["`expire` < ?", time()]);
$r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1",
dbesc($sec)
);
@ -205,7 +205,7 @@ function dfrn_poll_init(App $a)
break;
}
q("DELETE FROM `profile_check` WHERE `expire` < " . intval(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)) {
@ -232,7 +232,7 @@ function dfrn_poll_post(App $a)
if (strlen($challenge) && strlen($sec)) {
logger('dfrn_poll: POST: profile-check');
q("DELETE FROM `profile_check` WHERE `expire` < " . intval(time()));
dba::delete('profile_check', ["`expire` < ?", time()]);
$r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1",
dbesc($sec)
);
@ -305,11 +305,7 @@ function dfrn_poll_post(App $a)
$type = $r[0]['type'];
$last_update = $r[0]['last_update'];
$r = q("DELETE FROM `challenge` WHERE `dfrn-id` = '%s' AND `challenge` = '%s'",
dbesc($dfrn_id),
dbesc($challenge)
);
dba::delete('challenge', ['dfrn-id' => $dfrn_id, 'challenge' => $challenge]);
$sql_extra = '';
switch ($direction) {
@ -414,7 +410,7 @@ function dfrn_poll_content(App $a)
$status = 0;
$r = q("DELETE FROM `challenge` WHERE `expire` < " . intval(time()));
dba::delete('challenge', ["`expire` < ?", time()]);
if ($type !== 'profile') {
$r = q("INSERT INTO `challenge` ( `challenge`, `dfrn-id`, `expire` , `type`, `last_update` )