X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fsecurity.php;h=6f6ef94b6937cba12c154fa37dfc1e0dce6427c3;hb=de56a3a824ec9aa0e54dd0903c995076fdb9ae43;hp=51fb6f7259a1aaaacfdfd2f4bb1dcc81b84514a6;hpb=13c8750c2704106281fad37988cd20be4c400904;p=friendica.git diff --git a/include/security.php b/include/security.php index 51fb6f7259..6f6ef94b69 100644 --- a/include/security.php +++ b/include/security.php @@ -1,6 +1,10 @@ user = $user_record; @@ -81,32 +85,30 @@ function authenticate_success($user_record, $login_initial = false, $interactive $master_record = $a->user; if ((x($_SESSION,'submanage')) && intval($_SESSION['submanage'])) { - $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", + $r = dba::fetch_first("SELECT * FROM `user` WHERE `uid` = ? LIMIT 1", intval($_SESSION['submanage']) ); - if (dbm::is_result($r)) { - $master_record = $r[0]; + if (DBM::is_result($r)) { + $master_record = $r; } } - $r = q("SELECT `uid`,`username`,`nickname` FROM `user` WHERE `password` = '%s' AND `email` = '%s' AND `account_removed` = 0 ", - dbesc($master_record['password']), - dbesc($master_record['email']) - ); - if (dbm::is_result($r)) { - $a->identities = $r; + $r = dba::select('user', array('uid', 'username', 'nickname'), + array('password' => $master_record['password'], 'email' => $master_record['email'], 'account_removed' => false)); + if (DBM::is_result($r)) { + $a->identities = dba::inArray($r); } else { $a->identities = array(); } - $r = q("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` = %d", - intval($master_record['uid']) + WHERE `user`.`account_removed` = 0 AND `manage`.`uid` = ?", + $master_record['uid'] ); - if (dbm::is_result($r)) { - $a->identities = array_merge($a->identities,$r); + if (DBM::is_result($r)) { + $a->identities = array_merge($a->identities, dba::inArray($r)); } if ($login_initial) { @@ -116,31 +118,21 @@ function authenticate_success($user_record, $login_initial = false, $interactive logger('auth_identities refresh: ' . print_r($a->identities,true), LOGGER_DEBUG); } - $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1", - intval($_SESSION['uid'])); - if (dbm::is_result($r)) { - $a->contact = $r[0]; - $a->cid = $r[0]['id']; + $r = dba::fetch_first("SELECT * FROM `contact` WHERE `uid` = ? AND `self` LIMIT 1", $_SESSION['uid']); + if (DBM::is_result($r)) { + $a->contact = $r; + $a->cid = $r['id']; $_SESSION['cid'] = $a->cid; } header('X-Account-Management-Status: active; name="' . $a->user['username'] . '"; id="' . $a->user['nickname'] .'"'); if ($login_initial || $login_refresh) { - - q("UPDATE `user` SET `login_date` = '%s' WHERE `uid` = %d", - dbesc(datetime_convert()), - intval($_SESSION['uid']) - ); + dba::update('user', array('login_date' => datetime_convert()), array('uid' => $_SESSION['uid'])); // Set the login date for all identities of the user - q("UPDATE `user` SET `login_date` = '%s' WHERE `password` = '%s' AND `email` = '%s' AND `account_removed` = 0", - dbesc(datetime_convert()), - dbesc($master_record['password']), - dbesc($master_record['email']) - ); - - + dba::update('user', array('login_date' => datetime_convert()), + array('password' => $master_record['password'], 'email' => $master_record['email'], 'account_removed' => false)); } if ($login_initial) { @@ -155,16 +147,13 @@ function authenticate_success($user_record, $login_initial = false, $interactive } } - - if ($login_initial) { call_hooks('logged_in', $a->user); if (($a->module !== 'home') && isset($_SESSION['return_url'])) { - goaway(App::get_baseurl() . '/' . $_SESSION['return_url']); + goaway(System::baseUrl() . '/' . $_SESSION['return_url']); } } - } @@ -221,7 +210,7 @@ function can_write_wall(App $a, $owner) { intval(PAGE_COMMUNITY) ); - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { $verified = 2; return true; } @@ -271,7 +260,7 @@ function permissions_sql($owner_id, $remote_verified = false, $groups = null) { intval($remote_user), intval($owner_id) ); - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { $remote_verified = true; $groups = init_groups_visitor($remote_user); } @@ -350,7 +339,7 @@ function item_permissions_sql($owner_id, $remote_verified = false, $groups = nul intval($remote_user), intval($owner_id) ); - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { $remote_verified = true; $groups = init_groups_visitor($remote_user); } @@ -443,7 +432,7 @@ function check_form_security_token_redirectOnErr($err_redirect, $typename = '', logger('check_form_security_token failed: user ' . $a->user['guid'] . ' - form element ' . $typename); logger('check_form_security_token failed: _REQUEST data: ' . print_r($_REQUEST, true), LOGGER_DATA); notice( check_form_security_std_err_msg() ); - goaway(App::get_baseurl() . $err_redirect ); + goaway(System::baseUrl() . $err_redirect ); } } function check_form_security_token_ForbiddenOnErr($typename = '', $formname = 'form_security_token') { @@ -468,7 +457,7 @@ function init_groups_visitor($contact_id) { WHERE `contact-id` = %d ", intval($contact_id) ); - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { foreach ($r as $rr) $groups[] = $rr['gid']; }