function Login($username, $password) { global $session; $user = new User("username = '******'"); if ($user->IsEmpty()) { $user = null; return LOGIN_USER_NOT_FOUND; } if ($user->Password() == $password) { if ($user->Enabled()) { if ($user->PlayTimesLocation() == "") { $user->PlayTimesLocation($session->PlayTimesLocation()); } if (UpdateObject($user)) { $session->UserID($user->ID()); $session->LoggedIn(true); UpdateObject($session); $session->Authenticated("User", $user->ID()); UpdateObject($session, false); return LOGIN_AUTH; } } else { $session->AuthenticatedButAccountDisabled("Session", $session->ID()); return LOGIN_ACCOUNT_DISABLED; } } else { $session->FailedAuthentication("Session", $session->ID()); return LOGIN_FAILED_AUTH; } }
function main() { try { global $pageTitle; global $editable; global $session; global $user; $post = $_POST['blnPost']; $username = $_GET['username']; $selUser = new User("username = '******'"); $logout = $_GET['logout']; if ($selUser->IsEmpty()) { print GetCap('capUserNotFound'); $session->ViewedNotFound("Movie", $username); UpdateObject($session, false); Dump(); } if ($logout) { $selUser->Logout(); $session->ForcedLogout($selUser->ID()); } if (isset($user)) { if ($user->ID() == $selUser->ID()) { $sameUser = true; } } if (!$editable && !$selUser->Enabled()) { echo GetCap('capThisAccountHasBeenDisabled'); Dump(); } if ($post) { if (!$editable && !$sameUser) { BlockIfViolation('update'); } ThrowExceptionOnMaliciousInput($_POST['txtInfo'], 'USER_INFO'); if ($editable) { $selUser->Enabled($_POST['chkEnabled'] == '1' ? 1 : 0); } $selUser->PlayTimesLocation($_POST['txtPlayTimesLocation']); $selUser->Email($_POST['txtEmail']); $selUser->Info(strip_tags($_POST['txtInfo'])); UpdateObject($selUser); } else { $session->Viewed("User", $selUser->ID()); } $username = $selUser->UserName(); $pageTitle = $username; $email = $selUser->Email(); $playTimesLocation = $selUser->PlayTimesLocation(); $enabled = $selUser->Enabled(); $info = $selUser->Info(); ?> <br /> <form name="frm" method="post" action="<?php echo $PHP_SELF . "?username="******"> <table> <tr> <td> <font size=6><b><?php echo $username; ?> </b></font> <?php if (!$sameUser) { echo PublicizedInfo($info); } ?> </td> </tr> <?php if ($editable || $sameUser) { ?> <tr> <td> <b><?php echo GetCap('capEmailAddress'); ?> : </b> </td> <td> <input type="text" size=50 name="txtEmail" value="<?php echo $email; ?> "/> <?php echo "<i>(" . GetCap('capPrivate') . ")</i>"; ?> </td> </tr> <?php } if ($editable || $sameUser) { ?> <tr> <td> <b><?php echo GetCap('capPlayTimesLocation'); ?> : </b> </td> <td> <input type="text" size=50 name="txtPlayTimesLocation" value="<?php echo $playTimesLocation; ?> "/> <?php echo "<i>(" . GetCap('capPrivate') . ")</i>"; ?> </td> </tr> <?php } if ($editable || $sameUser) { ?> <tr> <td valign=top> <b><?php echo GetCap('capTellUsAboutYourself'); ?> : </b> <br/> <i>(<?php echo GetCap('capEditAnywayYouWish'); ?> )</i> </td> <td valign=top> <textarea rows="10" cols="57" name="txtInfo"><?php echo $info; ?> </textarea> <?php echo "<i>(" . GetCap('capPublic') . ")</i>"; ?> </td> </tr> <tr valign=top> <td> <b><?php echo GetCap('capPublicView'); ?> : </b> </td> <td> <?php echo PublicizedInfo($info); ?> </td> </tr> <?php } if ($editable) { ?> <tr> <td> <b><?php echo GetCap('capLoggedIn'); ?> : </b> <?php if ($selUser->LoggedIn()) { print GetCap("capYes"); if ($admin) { print "<a href=\"user.php?username={$username}&logout=1\">[" . GetCap('capLogout') . "]</a>"; } } else { print GetCap("capNo"); } ?> </tr> <tr> <td> <b><?php echo GetCap('capEnabled'); ?> : </b> <?php print "<input type=\"checkbox\" name=\"chkEnabled\" value=\"1\" " . ($enabled ? 'checked="checked"' : '') . "/>"; ?> </tr> <?php } if ($editable || $sameUser) { ?> <tr> <td> <input type="submit" name="btnLogin" value="<?php echo GetCap('capSave'); ?> "/> </td> <td> <input type="hidden" name="blnPost" value="1"/> </td> </tr> <?php } ?> </table> </form> <?php } catch (Exception $ex) { ProcessException($ex); } }