X-Git-Url: http://git.pjr.cc/?a=blobdiff_plain;f=gwvpmini%2Fgwvpmini_user.php;h=799ef3718dd151d12574f26408a26d0e75278c5c;hb=7c855df8f42cc8508f556068a707c9258cd40e43;hp=5def0abac521b3b3d145df9b234000571009b638;hpb=aaf0ad00ae0539a90f96458f18e01fb294add456;p=gwvp-mini.git diff --git a/gwvpmini/gwvpmini_user.php b/gwvpmini/gwvpmini_user.php index 5def0ab..799ef37 100644 --- a/gwvpmini/gwvpmini_user.php +++ b/gwvpmini/gwvpmini_user.php @@ -5,8 +5,9 @@ if($IS_WEB_REQUEST) { $reg = gwvpmini_getConfigVal("gravatarenabled"); $use_gravatar = false; - if($reg == null) { - gwvpmini_setConfigVal("gravatarenabled", "1"); + if($reg == null) { + // disable grav's by default + gwvpmini_setConfigVal("gravatarenabled", "0"); } else if($reg == 1) { $use_gravatar = true; } else { @@ -14,6 +15,21 @@ if($IS_WEB_REQUEST) { } global $use_gravatar; + + $reg = gwvpmini_getConfigVal("forcessl"); + + $force_ssl = false; + if($reg == null) { + // dont force ssl by default + gwvpmini_setConfigVal("forcessl", "0"); + } else if($reg == 1) { + $force_ssl = true; + } else { + $force_ssl = false; + } + + global $force_ssl; + } @@ -21,7 +37,7 @@ function gwvpmini_UserViewCallMe() { global $user_view_call; - error_log("in admin callme"); + // error_log("in admin callme"); if(isset($_REQUEST["q"])) { $query = $_REQUEST["q"]; $qspl = explode("/", $query); @@ -32,8 +48,20 @@ function gwvpmini_UserViewCallMe() if(!gwvpmini_GetUserId($user_view_call)) { gwvpmini_SendMessage("error", "No such user, $user_view_call"); return false; + } else { + if(isset($qspl[2])) { + if($qspl[2] == "updateuserdesc") { + return "gwvpmini_ViewUpdateUserDesc"; + } + if($qspl[2] == "updateuserpassword") { + return "gwvpmini_ViewUpdateUserPassword"; + } + if($qspl[2] == "updateuseremail") { + return "gwvpmini_ViewUpdateUserEmail"; + } + } + return "gwvpmini_UserViewPage"; } - return "gwvpmini_UserViewPage"; } else return false; } else return false; } @@ -57,21 +85,138 @@ function gwvpmini_UserViewPage() function gwvpmini_UserViewPageBody() { - global $user_view_call; + global $user_view_call, $BASE_URL; $dets = gwvpmini_getUser($user_view_call); - //error_log("show view of user with $user_view_call: ". print_r($dets, true)); + //// error_log("show view of user with $user_view_call: ". print_r($dets, true)); echo "

".$dets["fullname"]."


"; echo gwvpmini_HtmlGravatar($dets["email"],80); + echo "
"; $isme = false; if(isset($_SESSION["id"])) { if($_SESSION["id"] == $dets["id"]) { - echo "This is your page"; + $isme = true; } } + + if($isme || gwvpmini_isUserAdmin()) { + echo "
"; + echo "Your Description

"; + echo ""; + echo "
"; + + echo "

New Password

"; + echo "
"; + echo ""; + if($isme) echo ""; + echo ""; + echo "
Old Password
New Password
Confirm New Password
"; + echo ""; + echo "
"; + + echo "

New Email Address

"; + echo "
"; + echo ""; + echo "
New Email Address
Confirm New Email Address
"; + echo ""; + echo "
"; + } else { + echo $dets["desc"]."
"; + } +} + +function gwvpmini_ViewUpdateUserPassword() +{ + global $user_view_call, $BASE_URL; + + $newpass1 = $_REQUEST["newpassword1"]; + $newpass2 = $_REQUEST["newpassword2"]; + $oldpass = $_REQUEST["oldpassword"]; + + $authd = gwvpmini_authUserPass($user_view_call, $oldpass); + + $doupdate = false; + + if(isset($_SESSION["username"])) if($_SESSION["username"] == $user_view_call && $authd !== false) { + $doupdate = true; + } + + if(gwvpmini_isUserAdmin()) { + $doupdate = true; + } + + + if($newpass1 != $newpass2) { + gwvpmini_SendMessage("error", "Password and confirmation dont match"); + } else if(!$doupdate) { + gwvpmini_SendMessage("error", "Could not update user desc, are you logged in?"); + } else { + // do update + $uid = gwvpmini_GetUserId($user_view_call); + gwvpmini_UpdateUserPassword($uid, $newpass1); + gwvpmini_SendMessage("info", "Password Updated"); + } + + header("Location: $BASE_URL/user/$user_view_call"); +} + +function gwvpmini_ViewUpdateUserDesc() +{ + global $user_view_call, $BASE_URL; + + $newdesc = $_REQUEST["desc"]; + $doupdate = false; + + if(isset($_SESSION["username"])) if($_SESSION["username"] == $user_view_call) { + $doupdate = true; + } + + if(gwvpmini_isUserAdmin()) { + $doupdate = true; + } + + if(!$doupdate) { + gwvpmini_SendMessage("error", "Could not update user desc, are you logged in?"); + } else { + $uid = gwvpmini_GetUserId($user_view_call); + gwvpmini_UpdateUserDesc($uid, $newdesc); + gwvpmini_SendMessage("info", "Description Updated"); + } + + header("Location: $BASE_URL/user/$user_view_call"); + } + +function gwvpmini_ViewUpdateUserEmail() +{ + global $user_view_call, $BASE_URL; + + $newem1 = $_REQUEST["newemail1"]; + $newem2 = $_REQUEST["newemail2"]; + $doupdate = false; + + if(isset($_SESSION["username"])) if($_SESSION["username"] == $user_view_call) { + $doupdate = true; + } + + if(gwvpmini_isUserAdmin()) { + $doupdate = true; + } + + if($newem1 != $newem2) { + gwvpmini_SendMessage("error", "Email and confirmation did not match"); + } else if(!$doupdate) { + gwvpmini_SendMessage("error", "Could not update user desc, are you logged in?"); + } else { + $uid = gwvpmini_GetUserId($user_view_call); + gwvpmini_UpdateUserEmail($uid, $newem1); + gwvpmini_SendMessage("info", "Email Address Updated"); + } + + header("Location: $BASE_URL/user/$user_view_call"); + } ?> \ No newline at end of file