cvs: docweb /templates/all/www users.tpl.php /www users.php

From: Date: Mon, 01 Aug 2005 14:34:35 +0000
Subject: cvs: docweb /templates/all/www users.tpl.php /www users.php
Groups: php.doc.web 
Request: Send a blank email to doc-web+get-769@lists.php.net to get a copy of this message
vincent Mon Aug 1 10:34:35 2005 EDT Modified files: /docweb/templates/all/www users.tpl.php /docweb/www users.php Log: Allow users to delete there current photo http://cvs.php.net/diff.php/docweb/templates/all/www/users.tpl.php?r1=1.6&r2=1.7&ty=u Index: docweb/templates/all/www/users.tpl.php diff -u docweb/templates/all/www/users.tpl.php:1.6 docweb/templates/all/www/users.tpl.php:1.7 --- docweb/templates/all/www/users.tpl.php:1.6 Sun Jul 31 17:34:45 2005 +++ docweb/templates/all/www/users.tpl.php Mon Aug 1 10:34:35 2005 @@ -28,6 +28,12 @@ } $countries .= "<option value=\"".$code."\"$selected>".$cntry."</option>\n"; } + +if (is_file($_SERVER['DOCUMENT_ROOT'] . '/images/users/' . $info['username'] . '.jpg')) { + $currentphoto = '<tr><td>&nbsp;</td><td><input type="checkbox" name="deletephoto" />&docweb.users.delete-photo;</td></tr>'; +} else { + $currentphoto = ''; +} echo <<< HTML <h3>$info[name], you can edit your info here</h3> $errors @@ -45,6 +51,7 @@ <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> +$currentphoto <tr><td>&nbsp;</td><td><input type="submit" name="editSubmit" value="&docweb.common.submit;"></td></tr> </table> </form> http://cvs.php.net/diff.php/docweb/www/users.php?r1=1.4&r2=1.5&ty=u Index: docweb/www/users.php diff -u docweb/www/users.php:1.4 docweb/www/users.php:1.5 --- docweb/www/users.php:1.4 Sun Jul 31 12:28:26 2005 +++ docweb/www/users.php Mon Aug 1 10:34:35 2005 @@ -1,5 +1,5 @@ <?php -/* $Id: users.php,v 1.4 2005/07/31 16:28:26 nlopess Exp $ */ +/* $Id: users.php,v 1.5 2005/08/01 14:34:35 vincent Exp $ */ include '../include/init.inc.php'; require_once '../include/lib_auth.inc.php'; @@ -30,21 +30,27 @@ 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']); + if (isset($_POST['deletephoto']) && $_POST['deletephoto'] == 'on') { + if (is_file($_SERVER['DOCUMENT_ROOT'] . '/images/users/' . $info['username'] . '.jpg')) { + unlink($_SERVER['DOCUMENT_ROOT'] . '/images/users/' . $info['username'] . '.jpg'); + } + } + + 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 { - $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'); - } + move_uploaded_file($_FILES['photo']['tmp_name'], + $_SERVER['DOCUMENT_ROOT'].'/images/users/' . $info['username'] . '.jpg'); } } + } $pictureError = 'succes'; unset($info); $info = user_info($userid);

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