]> git.mxchange.org Git - friendica.git/commitdiff
The first queries are replaced with the new functions. More to come ...
authorMichael <heluecht@pirati.ca>
Sun, 7 May 2017 20:52:00 +0000 (20:52 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 7 May 2017 20:52:00 +0000 (20:52 +0000)
include/nav.php
include/network.php
include/remove_contact.php
index.php
mod/hovercard.php
mod/receive.php
mod/xrd.php
object/Item.php

index e2633be0af5eb3dc2ea18d3fa5b2dbc1f0b3a521..602bcd83ba9ffb38069f3fe758d05f4cc84fbdb1 100644 (file)
@@ -88,9 +88,9 @@ function nav_info(App $a)
                $nav['usermenu'][] = array('notes/', t('Personal notes'), '', t('Your personal notes'));
 
                // user info
-               $r = q("SELECT `micro` FROM `contact` WHERE `uid` = %d AND `self` = 1", intval($a->user['uid']));
+               $r = dba::select('contact', array('micro'), array('uid' => $a->user['uid'], 'self' => true), array('limit' => 1));
                $userinfo = array(
-                       'icon' => (dbm::is_result($r) ? $a->remove_baseurl($r[0]['micro']) : 'images/person-48.jpg'),
+                       'icon' => (dbm::is_result($r) ? $a->remove_baseurl($r['micro']) : 'images/person-48.jpg'),
                        'name' => $a->user['username'],
                );
        } else {
index 72d3ce626c14c473913785e963cc033e40d89f49..8019322d8b6eb44277df9c6cad3ddd03df7a3d7a 100644 (file)
@@ -724,22 +724,7 @@ function fix_contact_ssl_policy(&$contact,$new_policy) {
        }
 
        if ($ssl_changed) {
-               q("UPDATE `contact` SET
-                       `url` = '%s',
-                       `request` = '%s',
-                       `notify` = '%s',
-                       `poll` = '%s',
-                       `confirm` = '%s',
-                       `poco` = '%s'
-                       WHERE `id` = %d LIMIT 1",
-                       dbesc($contact['url']),
-                       dbesc($contact['request']),
-                       dbesc($contact['notify']),
-                       dbesc($contact['poll']),
-                       dbesc($contact['confirm']),
-                       dbesc($contact['poco']),
-                       intval($contact['id'])
-               );
+               dba::update('contact', $contact, array('id' => $contact['id']));
        }
 }
 
index a3938ad8ecbe390a7d52b612efea226963607d0a..92f712255771bb05537801b2451b3533448ca89b 100644 (file)
@@ -14,7 +14,7 @@ function remove_contact_run($argv, $argc) {
        $id = intval($argv[1]);
 
        // Only delete if the contact doesn't exist (anymore)
-       $r = q("SELECT `id` FROM `contact` WHERE `id` = %d", intval($id));
+       $r = dba::select('contact', array('id'), array('id' => $id), array('limit' => 1));
        if (dbm::is_result($r)) {
                return;
        }
index 639437017a09696a445045fbf2e511e8887fc7dc..2b26eb90f0caad691e99605471e24863cc640e9a 100644 (file)
--- a/index.php
+++ b/index.php
@@ -113,9 +113,11 @@ if (!$a->is_backend()) {
  */
 if (x($_SESSION,'authenticated') && !x($_SESSION,'language')) {
        // we didn't loaded user data yet, but we need user language
-       $r = q("SELECT language FROM user WHERE uid=%d", intval($_SESSION['uid']));
+       $r = dba::select('user', array('language'), array('uid' => $_SESSION['uid']), array('limit' => 1));
        $_SESSION['language'] = $lang;
-       if (dbm::is_result($r)) $_SESSION['language'] = $r[0]['language'];
+       if (dbm::is_result($r)) {
+               $_SESSION['language'] = $r['language'];
+       }
 }
 
 if ((x($_SESSION,'language')) && ($_SESSION['language'] !== $lang)) {
index 1420aae4ef0e118772fa367c2c278036eeb1a5f9..5c9ef61fc9ec409b0ceeb46394798d494244f47f 100644 (file)
@@ -41,9 +41,9 @@ function hovercard_content() {
        // the real url (nurl)
        if(local_user() && strpos($profileurl, "redir/") === 0) {
                $cid = intval(substr($profileurl, 6));
-               $r = q("SELECT `nurl`, `self`  FROM `contact` WHERE `id` = '%d' LIMIT 1", intval($cid));
-               $profileurl = ($r[0]["nurl"] ? $r[0]["nurl"] : "");
-               $self = ($r[0]["self"] ? $r[0]["self"] : "");
+               $r = dba::select('contact', array('nurl', 'self'), array('id' => $cid), array('limit' => 1));
+               $profileurl = ($r["nurl"] ? $r["nurl"] : "");
+               $self = ($r["self"] ? $r["self"] : "");
        }
 
        // if it's the url containing https it should be converted to http
index 9048642174706bd486689bc9fdbca5907c425902..2873cb971af703286836e10049a2548c9bf039fc 100644 (file)
@@ -28,14 +28,10 @@ function receive_post(App $a) {
                }
                $guid = $a->argv[2];
 
-               $r = q("SELECT * FROM `user` WHERE `guid` = '%s' AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1",
-                       dbesc($guid)
-               );
-               if (!dbm::is_result($r)) {
+               $importer = dba::select('user', array(), array('guid' => $guid, 'account_expired' => false, 'account_removed' => false), array('limit' => 1));
+               if (!dbm::is_result($importer)) {
                        http_status_exit(500);
                }
-
-               $importer = $r[0];
        }
 
        // It is an application/x-www-form-urlencoded
index c51f41946c59237a493fc60682c0e717e5bf60e3..bfb889258cf5193ae21e4e4d8eb67df14a374871 100644 (file)
@@ -20,14 +20,12 @@ function xrd_init(App $a) {
                $name = substr($local,0,strpos($local,'@'));
        }
 
-       $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' LIMIT 1",
-               dbesc($name)
-       );
+       $r = dba::select('user', array(), array('nickname' => $name), array('limit' => 1));
        if (! dbm::is_result($r)) {
                killme();
        }
 
-       $salmon_key = salmon_key($r[0]['spubkey']);
+       $salmon_key = salmon_key($r['spubkey']);
 
        header('Access-Control-Allow-Origin: *');
        header("Content-type: text/xml");
@@ -35,19 +33,19 @@ function xrd_init(App $a) {
        $tpl = get_markup_template('xrd_diaspora.tpl');
        $dspr = replace_macros($tpl,array(
                '$baseurl' => App::get_baseurl(),
-               '$dspr_guid' => $r[0]['guid'],
-               '$dspr_key' => base64_encode(pemtorsa($r[0]['pubkey']))
+               '$dspr_guid' => $r['guid'],
+               '$dspr_key' => base64_encode(pemtorsa($r['pubkey']))
        ));
 
        $tpl = get_markup_template('xrd_person.tpl');
 
-       $profile_url = App::get_baseurl().'/profile/'.$r[0]['nickname'];
+       $profile_url = App::get_baseurl().'/profile/'.$r['nickname'];
 
        if ($acct) {
                $alias = $profile_url;
        }
        else {
-               $alias = 'acct:'.$r[0]['nickname'].'@'.$a->get_hostname();
+               $alias = 'acct:'.$r['nickname'].'@'.$a->get_hostname();
 
                if ($a->get_path()) {
                        $alias .= '/'.$a->get_path();
@@ -55,25 +53,25 @@ function xrd_init(App $a) {
        }
 
        $o = replace_macros($tpl, array(
-               '$nick'        => $r[0]['nickname'],
+               '$nick'        => $r['nickname'],
                '$accturi'     => $uri,
                '$alias'       => $alias,
                '$profile_url' => $profile_url,
-               '$hcard_url'   => App::get_baseurl() . '/hcard/'         . $r[0]['nickname'],
-               '$atom'        => App::get_baseurl() . '/dfrn_poll/'     . $r[0]['nickname'],
-               '$zot_post'    => App::get_baseurl() . '/post/'          . $r[0]['nickname'],
-               '$poco_url'    => App::get_baseurl() . '/poco/'          . $r[0]['nickname'],
-               '$photo'       => App::get_baseurl() . '/photo/profile/' . $r[0]['uid']      . '.jpg',
+               '$hcard_url'   => App::get_baseurl() . '/hcard/'         . $r['nickname'],
+               '$atom'        => App::get_baseurl() . '/dfrn_poll/'     . $r['nickname'],
+               '$zot_post'    => App::get_baseurl() . '/post/'          . $r['nickname'],
+               '$poco_url'    => App::get_baseurl() . '/poco/'          . $r['nickname'],
+               '$photo'       => App::get_baseurl() . '/photo/profile/' . $r['uid']      . '.jpg',
                '$dspr'        => $dspr,
-               '$salmon'      => App::get_baseurl() . '/salmon/'        . $r[0]['nickname'],
-               '$salmen'      => App::get_baseurl() . '/salmon/'        . $r[0]['nickname'] . '/mention',
+               '$salmon'      => App::get_baseurl() . '/salmon/'        . $r['nickname'],
+               '$salmen'      => App::get_baseurl() . '/salmon/'        . $r['nickname'] . '/mention',
                '$subscribe'   => App::get_baseurl() . '/follow?url={uri}',
                '$modexp'      => 'data:application/magic-public-key,'  . $salmon_key,
-               '$bigkey'      => salmon_key($r[0]['pubkey']),
+               '$bigkey'      => salmon_key($r['pubkey']),
        ));
 
 
-       $arr = array('user' => $r[0], 'xml' => $o);
+       $arr = array('user' => $r, 'xml' => $o);
        call_hooks('personal_xrd', $arr);
 
        echo $arr['xml'];
index 0042e070a9da9b3bc73b02606f68328e880c44a2..9e8b4738e209ed2fa451526c2226bcbf8c428ec0 100644 (file)
@@ -242,17 +242,14 @@ class Item extends BaseObject {
                                        'classundo' => (($item['starred']) ? "" : "hidden"),
                                        'starred'   =>  t('starred'),
                                );
-                               $r = q("SELECT `ignored` FROM `thread` WHERE `uid` = %d AND `iid` = %d LIMIT 1",
-                                       intval($item['uid']),
-                                       intval($item['id'])
-                               );
+                               $r = dba::select('thread', array('ignored'), array('uid' => $item['uid'], 'iid' => $item['id']), array('limit' => 1));
                                if (dbm::is_result($r)) {
                                        $ignore = array(
                                                'do'        => t("ignore thread"),
                                                'undo'      => t("unignore thread"),
                                                'toggle'    => t("toggle ignore status"),
-                                               'classdo'   => (($r[0]['ignored']) ? "hidden" : ""),
-                                               'classundo' => (($r[0]['ignored']) ? "" : "hidden"),
+                                               'classdo'   => (($r['ignored']) ? "hidden" : ""),
+                                               'classundo' => (($r['ignored']) ? "" : "hidden"),
                                                'ignored'   =>  t('ignored'),
                                        );
                                }