cvs: docweb /include/rfc rfc.php /templates/all/www users.tpl.php /www redirect.php users.php
[email protected] ("Vincent Gevers")
| Newsgroups | php.doc.web |
|---|---|
| Message-ID | <cvsvincent1122818223@cvsserver> |
vincent Sun Jul 31 09:57:03 2005 EDT
Modified files:
/docweb/include/rfc rfc.php
/docweb/templates/all/www users.tpl.php
/docweb/www redirect.php users.php
Log:
Adding an update interface for user information
http://cvs.php.net/diff.php/docweb/include/rfc/rfc.php?r1=1.19&r2=1.20&ty=u
Index: docweb/include/rfc/rfc.php
diff -u docweb/include/rfc/rfc.php:1.19 docweb/include/rfc/rfc.php:1.20
--- docweb/include/rfc/rfc.php:1.19 Sat Jul 30 12:17:19 2005
+++ docweb/include/rfc/rfc.php Sun Jul 31 09:57:02 2005
@@ -24,7 +24,7 @@
* @author Daniel Convissor <[email protected]>
* @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.19 2005/07/30 16:17:19 vincent Exp $
+ * @version $Id: rfc.php,v 1.20 2005/07/31 13:57:02 vincent Exp $
*/
$path = realpath(dirname(__FILE__));
@@ -607,7 +607,7 @@
* + User must be logged in.
* + User must be a full-featured PEAR developer.
* + Only one vote can be cast.
- * + Proposers can't vote on their own package, though can for RFC's.
+ * + Proposers can't vote on their own package.
*
* @param object $dbh the current DB object
* @param string $userHandle the user's handle
http://cvs.php.net/diff.php/docweb/templates/all/www/users.tpl.php?r1=1.1&r2=1.2&ty=u
Index: docweb/templates/all/www/users.tpl.php
diff -u docweb/templates/all/www/users.tpl.php:1.1 docweb/templates/all/www/users.tpl.php:1.2
--- docweb/templates/all/www/users.tpl.php:1.1 Sat Jul 30 08:36:08 2005
+++ docweb/templates/all/www/users.tpl.php Sun Jul 31 09:57:02 2005
@@ -1,17 +1,55 @@
<?php
-global $info;
+global $info, $doEdit, $pictureError;
+if (isset($doEdit)) {
+auth();
+switch ($pictureError) {
+ case 'succes':
+ $errors = "&docweb.users.succes;";
+ break;
+ case 'size':
+ $errors = "&docweb.users.error.size;";
+ break;
+ case 'format':
+ $errors = "&docweb.users.error.format;";
+ break;
+ default:
+ $errors = '';
+}
echo <<< HTML
-<p>&docweb.users.username;: $info[username]<br />
-&docweb.users.name;: $info[name]<br />
-&docweb.users.country;: $info[country]<br />
+<h3>$info[username], you can edit your info here</h3>
+$errors
+<form enctype="multipart/form-data" action="$_SERVER[REQUEST_URI]" method="post">
+<table>
+<tr><td>&docweb.users.name;</td><td>
+ <input type="text" name="name" value="$info[name]" /></td></tr>
+<tr><td>&docweb.users.country;</td><td>
+ <input type="text" name="country" value="$info[country]" /></td></tr>
+<tr><td>&docweb.users.website;</td><td>
+ <input type="text" name="site" value="$info[site]" /></td></tr>
+<tr><td>&docweb.users.wishlist;</td><td>
+ <input type="text" name="wishlist" value="$info[wishlist]" /></td></tr>
+<tr><td>&docweb.users.photo;</td><td><input type="file" name="photo"/></td></tr>
+<tr><td> </td><td><input type="submit" name="editSubmit" value="&docweb.common.submit;"></td></tr>
+</table>
+</form>
HTML;
-if ($info['whishlist'])
- echo "<a href='$info[whishlist]'>&docweb.users.whishlist;</a><br />";
+} else {
+echo <<< HTML
+<p><strong>&docweb.users.username;</strong>: $info[username]<br />
+<strong>&docweb.users.name;</strong>: $info[name]<br />
+<strong>&docweb.users.country;</strong>: $info[country]<br />
+<strong>&docweb.users.website;</strong>: <a href="$info[site]">$info[site]</a><br />
+HTML;
-if (is_file(dirname(__FILE__) . '/images/users/' . $info['username'] . '.jpg'))
+if ($info['wishlist'])
+ echo "<a href='$info[wishlist]'>&docweb.users.wishlist;</a><br />";
+
+if (is_file($_SERVER['DOCUMENT_ROOT'] . '/images/users/' . $info['username'] . '.jpg'))
echo "<img src='/images/users/$info[username].jpg' alt='&docweb.users.photo;'/>";
echo '</p>';
+
+}
?>
http://cvs.php.net/diff.php/docweb/www/redirect.php?r1=1.8&r2=1.9&ty=u
Index: docweb/www/redirect.php
diff -u docweb/www/redirect.php:1.8 docweb/www/redirect.php:1.9
--- docweb/www/redirect.php:1.8 Sat Jul 30 08:36:09 2005
+++ docweb/www/redirect.php Sun Jul 31 09:57:02 2005
@@ -15,7 +15,7 @@
+----------------------------------------------------------------------+
| Authors: Sean Coates <[email protected]> |
+----------------------------------------------------------------------+
-$Id: redirect.php,v 1.8 2005/07/30 12:36:09 nlopess Exp $
+$Id: redirect.php,v 1.9 2005/07/31 13:57:02 vincent Exp $
*/
require_once('../include/lib_proj_lang.inc.php');
@@ -85,6 +85,9 @@
$parts[1] == 'user')
{
$userid = $parts[2];
+ if (isset($parts[3]) && $parts[3] == 'edit') {
+ $doEdit = true;
+ }
$uri = './users.php';
// generic uri validator
http://cvs.php.net/diff.php/docweb/www/users.php?r1=1.1&r2=1.2&ty=u
Index: docweb/www/users.php
diff -u docweb/www/users.php:1.1 docweb/www/users.php:1.2
--- docweb/www/users.php:1.1 Sat Jul 30 08:36:09 2005
+++ docweb/www/users.php Sun Jul 31 09:57:03 2005
@@ -1,16 +1,57 @@
<?php
-/* $Id: users.php,v 1.1 2005/07/30 12:36:09 nlopess Exp $ */
+/* $Id: users.php,v 1.2 2005/07/31 13:57:03 vincent Exp $ */
include '../include/init.inc.php';
require_once '../include/lib_auth.inc.php';
-if(empty($userid) || !is_string($userid) || !ctype_alpha($userid))
- die('no hacking allowed :)');
+if(empty($userid) || !is_string($userid) || !ctype_alpha($userid)) {
+ echo site_header('docweb.common.header.users');
+ echo '<h3>No such user found</h3>';
+ echo site_footer();
+ exit;
+}
$info = user_info($userid);
-echo site_header('docweb.common.header.users');
-echo DocWeb_Template::get('users.tpl.php');
-echo site_footer();
+if (isset($_POST['editSubmit'])) {
+
+$sql = 'UPDATE users SET
+ name = "'.sqlite_escape_string(htmlspecialchars($_POST['name'])).'",
+ country = "'.sqlite_escape_string(htmlspecialchars($_POST['country'])).'",
+ site = "'.sqlite_escape_string(htmlspecialchars($_POST['site'])).'",
+ wishlist = "'.sqlite_escape_string(htmlspecialchars($_POST['wishlist'])).'"
+ WHERE username = "'.sqlite_escape_string($info['username']).'"';
+$result = sqlite_query($sql, $idx);
+if (!$result) {
+ sqlite_error_string(sqlite_last_error($idx));
+}
+
+ if (!empty($_FILES['photo']['name'])) {
+ // this will need some more security checks
+ if ($_FILES['photo']['size'] >= round((1024 * 1024)/10)) {
+ $pictureError = 'size';
+ unlink($_FILES['photo']['tmp_name']);
+ } else {
+ $img = getimagesize($_FILES['photo']['tmp_name']);
+ if (!$img or $img[0] >= 500 or $img[1] >= 500 or $img['mime'] != 'image/jpeg') {
+ $pictureError = 'format';
+ } else {
+ move_uploaded_file($_FILES['photo']['tmp_name'],
+ $_SERVER['DOCUMENT_ROOT'].'/images/users/' . $info['username'] . '.jpg');
+ }
+ }
+ }
+$pictureError = 'succes';
+unset($info);
+$info = user_info($userid);
+}
+
+if (isset($doEdit)) {
+ echo site_header('docweb.common.header.users.edit');
+} else {
+ echo site_header('docweb.common.header.users');
+}
+ echo DocWeb_Template::get('users.tpl.php');
+ echo site_footer();
?>