diff options
author | redmatrix <git@macgirvin.com> | 2016-03-31 20:15:47 -0700 |
---|---|---|
committer | redmatrix <git@macgirvin.com> | 2016-03-31 20:15:47 -0700 |
commit | 0cda43145629586e6110e83fa2356e1c4ee4811a (patch) | |
tree | cd971890c1731062fe2168959b29f85e9e070346 /include/security.php | |
parent | bbfe4de3107a1eb8293f4ee6b620f7e27bf26dbf (diff) | |
download | volse-hubzilla-0cda43145629586e6110e83fa2356e1c4ee4811a.tar.gz volse-hubzilla-0cda43145629586e6110e83fa2356e1c4ee4811a.tar.bz2 volse-hubzilla-0cda43145629586e6110e83fa2356e1c4ee4811a.zip |
create miniApp to convert existing settings files to the static App class
Diffstat (limited to 'include/security.php')
-rw-r--r-- | include/security.php | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/include/security.php b/include/security.php index 479013460..38045c8a9 100644 --- a/include/security.php +++ b/include/security.php @@ -14,8 +14,6 @@ */ function authenticate_success($user_record, $login_initial = false, $interactive = false, $return = false, $update_lastlog = false) { - $a = get_app(); - $_SESSION['addr'] = $_SERVER['REMOTE_ADDR']; $lastlog_updated = false; @@ -360,10 +358,9 @@ function public_permissions_sql($observer_hash) { * so this mechanism brings in some damage control (the attacker would be able to forge a request to a form of this type, but not to forms of other types). */ function get_form_security_token($typename = '') { - $a = get_app(); $timestamp = time(); - $sec_hash = hash('whirlpool', App::$user['guid'] . App::$user['prvkey'] . session_id() . $timestamp . $typename); + $sec_hash = hash('whirlpool', App::$observer['xchan_guid'] . ((local_channel()) ? App::$channel['channel_prvkey'] : '') . session_id() . $timestamp . $typename); return $timestamp . '.' . $sec_hash; } @@ -374,12 +371,10 @@ function check_form_security_token($typename = '', $formname = 'form_security_to $max_livetime = 10800; // 3 hours - $a = get_app(); - $x = explode('.', $hash); if (time() > (IntVal($x[0]) + $max_livetime)) return false; - $sec_hash = hash('whirlpool', App::$user['guid'] . App::$user['prvkey'] . session_id() . $x[0] . $typename); + $sec_hash = hash('whirlpool', App::$observer['xchan_guid'] . ((local_channel()) ? App::$channel['channel_prvkey'] : '') . session_id() . $x[0] . $typename); return ($sec_hash == $x[1]); } @@ -389,8 +384,7 @@ function check_form_security_std_err_msg() { } function check_form_security_token_redirectOnErr($err_redirect, $typename = '', $formname = 'form_security_token') { if (!check_form_security_token($typename, $formname)) { - $a = get_app(); - logger('check_form_security_token failed: user ' . App::$user['guid'] . ' - form element ' . $typename); + logger('check_form_security_token failed: user ' . App::$observer['xchan_name'] . ' - 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(z_root() . $err_redirect ); @@ -398,8 +392,7 @@ function check_form_security_token_redirectOnErr($err_redirect, $typename = '', } function check_form_security_token_ForbiddenOnErr($typename = '', $formname = 'form_security_token') { if (!check_form_security_token($typename, $formname)) { - $a = get_app(); - logger('check_form_security_token failed: user ' . App::$user['guid'] . ' - form element ' . $typename); + logger('check_form_security_token failed: user ' . App::$observer['xchan_name'] . ' - form element ' . $typename); logger('check_form_security_token failed: _REQUEST data: ' . print_r($_REQUEST, true), LOGGER_DATA); header('HTTP/1.1 403 Forbidden'); killme(); |