cvs: docweb /include lib_auth.inc.php /include/rfc rfc.php /www/rfc rfc-comments-show.php rfc-overview.php rfc-proposal-show.php

From: Date: Fri, 29 Jul 2005 19:31:13 +0000
Subject: cvs: docweb /include lib_auth.inc.php /include/rfc rfc.php /www/rfc rfc-comments-show.php rfc-overview.php rfc-proposal-show.php
Groups: php.doc.web 
Request: Send a blank email to doc-web+get-706@lists.php.net to get a copy of this message
nlopess Fri Jul 29 15:31:13 2005 EDT Modified files: /docweb/include lib_auth.inc.php /docweb/include/rfc rfc.php /docweb/www/rfc rfc-comments-show.php rfc-overview.php rfc-proposal-show.php Log: make RFC work with the users DB http://cvs.php.net/diff.php/docweb/include/lib_auth.inc.php?r1=1.6&r2=1.7&ty=u Index: docweb/include/lib_auth.inc.php diff -u docweb/include/lib_auth.inc.php:1.6 docweb/include/lib_auth.inc.php:1.7 --- docweb/include/lib_auth.inc.php:1.6 Fri Jul 29 14:43:47 2005 +++ docweb/include/lib_auth.inc.php Fri Jul 29 15:31:12 2005 @@ -17,7 +17,7 @@ * | Nuno Lopes <nlopess@php.net> | * +----------------------------------------------------------------------+ * - * $Id: lib_auth.inc.php,v 1.6 2005/07/29 18:43:47 nlopess Exp $ + * $Id: lib_auth.inc.php,v 1.7 2005/07/29 19:31:12 nlopess Exp $ */ require_once 'cvs-auth.inc'; @@ -37,14 +37,10 @@ 'vincent', ); +$user = $password = false; -/** - * read the magic cookie and return array(user, pass) - */ -function read_magic_cookie() -{ - return explode(':', base64_decode(@$_COOKIE['MAGIC_COOKIE'])); -} +// make the username & password global +list($user, $password) = explode(':', base64_decode(@$_COOKIE['MAGIC_COOKIE'])); /** @@ -52,10 +48,11 @@ */ function auth() { + global $user, $password; + if (isset($_COOKIE['MAGIC_COOKIE'])) { - list($user, $pw) = read_magic_cookie(); - if (!verify_password($user, $pw)) { + if (!verify_password($user, $password)) { header ('Location: http://doc.php.net/login.php'); exit; } @@ -84,28 +81,34 @@ */ function is_admin() { - if (!isset($_COOKIE['MAGIC_COOKIE'])) - return false; - - list($user) = read_magic_cookie(); - - return in_array($user, $GLOBALS['admins']); + return in_array($GLOBALS['user'], $GLOBALS['admins']); } /** * read user info from the DB */ -function user_info() +function user_info($u = false) { - global $idx; + global $idx, $user; - list($user) = read_magic_cookie(); - - $result = @sqlite_unbuffered_query($idx, "SELECT * FROM users WHERE username='" . sqlite_escape_string($user) . "'"); + $u = $u ? $u : $user; + $result = @sqlite_unbuffered_query($idx, "SELECT * FROM users WHERE username='" . sqlite_escape_string($u) . "'"); if (!$result) { return false; } return sqlite_fetch_array($result, SQLITE_ASSOC); } + + +/** + * returns the user's real name + */ +function user_name($user = false) +{ + if ($info = user_info($user)) + return $info['name']; + + return $GLOBALS['user'];; +} http://cvs.php.net/diff.php/docweb/include/rfc/rfc.php?r1=1.14&r2=1.15&ty=u Index: docweb/include/rfc/rfc.php diff -u docweb/include/rfc/rfc.php:1.14 docweb/include/rfc/rfc.php:1.15 --- docweb/include/rfc/rfc.php:1.14 Fri Jul 29 08:47:13 2005 +++ docweb/include/rfc/rfc.php Fri Jul 29 15:31:13 2005 @@ -24,7 +24,7 @@ * @author Daniel Convissor <danielc@php.net> * @copyright Copyright (c) 1997-2004 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License - * @version $Id: rfc.php,v 1.14 2005/07/29 12:47:13 vincent Exp $ + * @version $Id: rfc.php,v 1.15 2005/07/29 19:31:13 nlopess Exp $ */ $path = realpath(dirname(__FILE__)); @@ -36,8 +36,8 @@ require_once $path . '/../lib_auth.inc.php'; -list($docwebUser) = read_magic_cookie(); -if ($docwebUser === '') { +$docwebUser = $user; +if (!$docwebUser) { unset($docwebUser); } http://cvs.php.net/diff.php/docweb/www/rfc/rfc-comments-show.php?r1=1.5&r2=1.6&ty=u Index: docweb/www/rfc/rfc-comments-show.php diff -u docweb/www/rfc/rfc-comments-show.php:1.5 docweb/www/rfc/rfc-comments-show.php:1.6 --- docweb/www/rfc/rfc-comments-show.php:1.5 Fri Jul 29 07:24:49 2005 +++ docweb/www/rfc/rfc-comments-show.php Fri Jul 29 15:31:13 2005 @@ -19,7 +19,7 @@ * @author Daniel Convissor <danielc@php.net> * @copyright Copyright (c) 1997-2004 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License - * @version $Id: rfc-comments-show.php,v 1.5 2005/07/29 11:24:49 vincent Exp $ + * @version $Id: rfc-comments-show.php,v 1.6 2005/07/29 19:31:13 nlopess Exp $ */ /** @@ -158,8 +158,7 @@ echo ' <ul class="spaced">' . "\n"; foreach ($comments as $comment) { if (empty($userInfos[$comment->user_handle])) { // not used? - // $userInfos[$comment->user_handle] = user::info($comment->user_handle); // !!! - // $userinfos[$comment->user_handle] = 'TestUser'; + //$userInfos[$comment->user_handle] = user_name(); } echo '<li><p style="margin: 0em 0em 0.3em 0em;">'; echo make_link('/user/'.$comment->user_handle, $comment->user_handle); http://cvs.php.net/diff.php/docweb/www/rfc/rfc-overview.php?r1=1.11&r2=1.12&ty=u Index: docweb/www/rfc/rfc-overview.php diff -u docweb/www/rfc/rfc-overview.php:1.11 docweb/www/rfc/rfc-overview.php:1.12 --- docweb/www/rfc/rfc-overview.php:1.11 Fri Jul 29 14:51:48 2005 +++ docweb/www/rfc/rfc-overview.php Fri Jul 29 15:31:13 2005 @@ -22,7 +22,7 @@ * @author Daniel Convissor <danielc@php.net> * @copyright Copyright (c) 1997-2004 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License - * @version $Id: rfc-overview.php,v 1.11 2005/07/29 18:51:48 vincent Exp $ + * @version $Id: rfc-overview.php,v 1.12 2005/07/29 19:31:13 nlopess Exp $ */ /** @@ -83,7 +83,7 @@ } } if (!isset($users[$proposal->user_handle])) { - $users[$proposal->user_handle] = array($proposal->user_handle,'name'=>$proposal->user_handle);// user::info($proposal->user_handle); // !!! + $users[$proposal->user_handle] = array($proposal->user_handle,'name'=>user_name($proposal->user_handle)); } $already_voted = false; http://cvs.php.net/diff.php/docweb/www/rfc/rfc-proposal-show.php?r1=1.12&r2=1.13&ty=u Index: docweb/www/rfc/rfc-proposal-show.php diff -u docweb/www/rfc/rfc-proposal-show.php:1.12 docweb/www/rfc/rfc-proposal-show.php:1.13 --- docweb/www/rfc/rfc-proposal-show.php:1.12 Fri Jul 29 07:24:49 2005 +++ docweb/www/rfc/rfc-proposal-show.php Fri Jul 29 15:31:13 2005 @@ -19,7 +19,7 @@ * @author Daniel Convissor <danielc@php.net> * @copyright Copyright (c) 1997-2004 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License - * @version $Id: rfc-proposal-show.php,v 1.12 2005/07/29 11:24:49 vincent Exp $ + * @version $Id: rfc-proposal-show.php,v 1.13 2005/07/29 19:31:13 nlopess Exp $ */ /** @@ -265,8 +265,7 @@ echo "<ul>\n"; foreach ($changelog as $comment) { if (!isset($userinfos[$comment->user_handle])) { - //$userinfo[$comment->user_handle] = user::info($comment->user_handle); // !!! - $userinfo[$comment->user_handle] = array('name'=> $comment->user_handle); + $userinfo[$comment->user_handle] = array('name'=> user_name($comment->user_handle)); } echo '<li><p style="margin: 0em 0em 0.3em 0em; font-size: 90%;">'; echo htmlspecialchars($userinfo[$comment->user_handle]['name']);

« previous php.doc.web (#706) next »