diff --git a/include/auth.php b/include/auth.php index e3c8d92eeb..57e9d9bf61 100644 --- a/include/auth.php +++ b/include/auth.php @@ -125,6 +125,7 @@ if (isset($_SESSION) && x($_SESSION,'authenticated') && (!x($_POST,'auth-params' $openid = new LightOpenID; $openid->identity = $openid_url; $_SESSION['openid'] = $openid_url; + $_SESSION['remember'] = $_POST['remember']; $openid->returnUrl = App::get_baseurl(true).'/openid'; goaway($openid->authUrl()); } catch (Exception $e) { @@ -178,17 +179,12 @@ if (isset($_SESSION) && x($_SESSION,'authenticated') && (!x($_POST,'auth-params' goaway(z_root()); } - // If the user specified to remember the authentication, then set a cookie - // that expires after one week (the default is when the browser is closed). - // The cookie will be renewed automatically. - // The week ensures that sessions will expire after some inactivity. - if ($_POST['remember']) - new_cookie(604800, $r[0]); - else + if (! $_POST['remember']) { new_cookie(0); // 0 means delete on browser exit + } // if we haven't failed up this point, log them in. - + $_SESSION['remember'] = $_POST['remember']; $_SESSION['last_login_date'] = datetime_convert('UTC','UTC'); authenticate_success($record, true, true); } @@ -203,39 +199,3 @@ function nuke_session() { session_unset(); session_destroy(); } - -/** - * @brief Calculate the hash that is needed for the "Friendica" cookie - * - * @param array $user Record from "user" table - * - * @return string Hashed data - */ -function cookie_hash($user) { - return(hash("sha256", get_config("system", "site_prvkey"). - $user["uprvkey"]. - $user["password"])); -} - -/** - * @brief Set the "Friendica" cookie - * - * @param int $time - * @param array $user Record from "user" table - */ -function new_cookie($time, $user = array()) { - - if ($time != 0) - $time = $time + time(); - - if ($user) - $value = json_encode(array("uid" => $user["uid"], - "hash" => cookie_hash($user), - "ip" => $_SERVER['REMOTE_ADDR'])); - else - $value = ""; - - setcookie("Friendica", $value, $time, "/", "", - (get_config('system', 'ssl_policy') == SSL_POLICY_FULL), true); - -} diff --git a/include/security.php b/include/security.php index c379518562..afb37a72d8 100644 --- a/include/security.php +++ b/include/security.php @@ -1,5 +1,44 @@ $user["uid"], + "hash" => cookie_hash($user), + "ip" => $_SERVER['REMOTE_ADDR'])); + } + else { + $value = ""; + } + + setcookie("Friendica", $value, $time, "/", "", + (get_config('system', 'ssl_policy') == SSL_POLICY_FULL), true); + +} + function authenticate_success($user_record, $login_initial = false, $interactive = false, $login_refresh = false) { $a = get_app(); @@ -94,6 +133,21 @@ function authenticate_success($user_record, $login_initial = false, $interactive } + + if ($login_initial) { + // If the user specified to remember the authentication, then set a cookie + // that expires after one week (the default is when the browser is closed). + // The cookie will be renewed automatically. + // The week ensures that sessions will expire after some inactivity. + if ($_SESSION['remember']) { + logger('Injecting cookie for remembered user '. $_SESSION['remember_user']['nickname']); + new_cookie(604800, $user_record); + unset($_SESSION['remember']); + } + } + + + if ($login_initial) { call_hooks('logged_in', $a->user); diff --git a/include/text.php b/include/text.php index 580bd95fc7..6619dec93a 100644 --- a/include/text.php +++ b/include/text.php @@ -291,8 +291,8 @@ function paginate_data(App $a, $count = null) { } $url = $stripped; - $data = array(); + function _l(&$d, $name, $url, $text, $class = '') { if (strpos($url, '?') === false && ($pos = strpos($url, '&')) !== false) { $url = substr($url, 0, $pos) . '?' . substr($url, $pos + 1); @@ -318,9 +318,10 @@ function paginate_data(App $a, $count = null) { $numstart = 1; $numstop = $numpages; - if ($numpages > 14) { - $numstart = (($pagenum > 7) ? ($pagenum - 7) : 1); - $numstop = (($pagenum > ($numpages - 7)) ? $numpages : ($numstart + 14)); + // Limit the number of displayed page number buttons. + if ($numpages > 8) { + $numstart = (($pagenum > 4) ? ($pagenum - 4) : 1); + $numstop = (($pagenum > ($numpages - 7)) ? $numpages : ($numstart + 8)); } $pages = array(); diff --git a/mod/openid.php b/mod/openid.php index 59a7530140..b45cd97975 100644 --- a/mod/openid.php +++ b/mod/openid.php @@ -30,7 +30,7 @@ function openid_content(App $a) { // mod/settings.php in 8367cad so it might have left mixed // records in the user table // - $r = q("SELECT * FROM `user` + $r = q("SELECT *, `user`.`pubkey` as `upubkey`, `user`.`prvkey` as `uprvkey` FROM `user` WHERE ( `openid` = '%s' OR `openid` = '%s' ) AND `blocked` = 0 AND `account_expired` = 0 AND `account_removed` = 0 AND `verified` = 1 diff --git a/view/theme/frio/css/style.css b/view/theme/frio/css/style.css index 4e3dc9749c..ec3bc69aff 100644 --- a/view/theme/frio/css/style.css +++ b/view/theme/frio/css/style.css @@ -2515,21 +2515,53 @@ body .tread-wrapper .hovercard:hover .hover-card-content a { } /* Pagination improvements */ +.pagination { + text-align: center; + display: block; +} .pagination > li > a, .pagination > li > span { - color: $link_color; + color: $link_color; + float: none; } -.pagination>.active>a, -.pagination>.active>a:focus, -.pagination>.active>a:hover, -.pagination>.active>span, -.pagination>.active>span:focus, -.pagination>.active>span:hover { - background-color: $link_color; +.pagination>li>a:hover, +.pagination>li>span:hover { + color: $link_hover_color; +} +.pagination > .active > a, +.pagination > .active > a:focus, +.pagination > .active > a:hover, +.pagination > .active > span, +.pagination > .active > span:focus, +.pagination > .active > span:hover { + background-color: $link_color; border-color: $link_color; + border-radius: 3px; } -.disabled > a { - pointer-events: none; +.pagination li.pager_n a { + margin-left: 3px; + border-radius: 3px; +} +.pagination .pager_prev a { + margin-left: -5px; + margin-right: 4px; + border-top-right-radius: 3px; + border-bottom-right-radius: 3px; +} +.pagination .pager_next a { + margin-left: 4px; + margin-right: -5px; + border-top-left-radius: 3px; + border-bottom-left-radius: 3px; +} +.pager .next > a, +.pager .previous > a { + float: none; + border-radius: 3px; +} +.pagination .disabled > a, +.pager .disabled > a { + display: none; } /* diff --git a/view/theme/frio/templates/paginate.tpl b/view/theme/frio/templates/paginate.tpl index ab65cdd406..252dd7e5b0 100644 --- a/view/theme/frio/templates/paginate.tpl +++ b/view/theme/frio/templates/paginate.tpl @@ -1,14 +1,16 @@ + {{* Pager template, uses output of paginate_data() in include/text.php *}} + {{if $pager}} -
- {{if $pager.first}}
  • {{$pager.first.text}}
  • {{/if}} +
    + {{if $pager.last}}
  • >∣
  • {{/if}} + {{/if}}