cvs: pearweb /include pear-auth.php /public_html login.php

From: Date: Wed, 16 Jun 2004 23:07:09 +0000
Subject: cvs: pearweb /include pear-auth.php /public_html login.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-20774@lists.php.net to get a copy of this message
danielc Wed Jun 16 19:07:09 2004 EDT Modified files: /pearweb/include pear-auth.php /pearweb/public_html login.php Log: * When going to the login page, if user is already logged in, say so rather than present login form. * If user comes to login page directly and then logs in sucessfully, print a welcome message. http://cvs.php.net/diff.php/pearweb/include/pear-auth.php?r1=1.48&r2=1.49&ty=u Index: pearweb/include/pear-auth.php diff -u pearweb/include/pear-auth.php:1.48 pearweb/include/pear-auth.php:1.49 --- pearweb/include/pear-auth.php:1.48 Wed Jun 16 18:26:19 2004 +++ pearweb/include/pear-auth.php Wed Jun 16 19:07:09 2004 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ | Authors: | +----------------------------------------------------------------------+ - $Id: pear-auth.php,v 1.48 2004/06/16 22:26:19 danielc Exp $ + $Id: pear-auth.php,v 1.49 2004/06/16 23:07:09 danielc Exp $ */ function auth_reject($realm = null, $message = null) @@ -28,7 +28,7 @@ $message = "Please enter your username and password:"; } - response_header($message); + response_header('Login'); if ($format == 'xmlrpc') { Header("HTTP/1.0 401 Unauthorized"); Header("WWW-authenticate: basic realm=\"$realm\""); @@ -70,7 +70,7 @@ } elseif (isset($_SERVER['REQUEST_URI'])) { print htmlspecialchars($_SERVER['REQUEST_URI']); } else { - print '/'; + print 'login.php'; } print "\" />\n"; print "</form>\n"; http://cvs.php.net/diff.php/pearweb/public_html/login.php?r1=1.18&r2=1.19&ty=u Index: pearweb/public_html/login.php diff -u pearweb/public_html/login.php:1.18 pearweb/public_html/login.php:1.19 --- pearweb/public_html/login.php:1.18 Mon Jun 14 00:23:04 2004 +++ pearweb/public_html/login.php Wed Jun 16 19:07:09 2004 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ | Authors: | +----------------------------------------------------------------------+ - $Id: login.php,v 1.18 2004/06/14 04:23:04 danielc Exp $ + $Id: login.php,v 1.19 2004/06/16 23:07:09 danielc Exp $ */ /* @@ -30,6 +30,18 @@ auth_reject(PEAR_AUTH_REALM, 'Cookies must be enabled to log in.'); } +/* + * If they're already logged in, say so. + */ +if (isset($_COOKIE['PEAR_USER']) && isset($_COOKIE['PEAR_PW'])) { + if (auth_verify($_COOKIE['PEAR_USER'], $_COOKIE['PEAR_PW'])) { + response_header('Login'); + echo '<div class="warnings">You are already logged in.</div>'; + response_footer(); + exit; + } +} + if (auth_verify(@$_POST['PEAR_USER'], @$_POST['PEAR_PW'])) { if (!empty($_POST['PEAR_PERSIST'])) { $expire = 2147483647; @@ -39,7 +51,7 @@ setcookie('PEAR_USER', $_POST['PEAR_USER'], $expire, '/'); setcookie('PEAR_PW', md5($_POST['PEAR_PW']), $expire, '/'); - /** + /* * Update users password if it is held in the db * crypt()ed. */ @@ -48,17 +60,21 @@ $dbh->query($query, array(md5($_POST['PEAR_PW']), $_POST['PEAR_USER'])); } - /** + /* * Determine URL */ - if (isset($_POST['PEAR_OLDURL'])) { - $gotourl = $_POST['PEAR_OLDURL']; + if (isset($_POST['PEAR_OLDURL']) && + basename($_POST['PEAR_OLDURL']) != 'login.php') + { + localRedirect($_POST['PEAR_OLDURL']); } else { - $gotourl = '/'; + response_header('Login'); + echo '<div class="thanks">Welcome.</div>'; + response_footer(); + exit; } - localRedirect($gotourl); - exit(); + exit; } $msg = "";

« previous php.pear.cvs (#20774) next »