Added unstaged
This commit is contained in:
parent
2db45400bd
commit
5abe6defa5
11
lib/Util.php
Normal file
11
lib/Util.php
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
class Util
|
||||||
|
{
|
||||||
|
public static function diff($a, $b)
|
||||||
|
{
|
||||||
|
$a = intval(preg_replace("/[^0-9]/", "", $a));
|
||||||
|
$b = intval(preg_replace("/[^0-9]/", "", $b));
|
||||||
|
return abs($a - $b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
66
pages/user/info.php
Normal file
66
pages/user/info.php
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<?php
|
||||||
|
global $c;
|
||||||
|
$varUser = UserAuth::getUser();
|
||||||
|
|
||||||
|
if ($varUser == null)
|
||||||
|
Respond::redirect("/user/signin");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (Request::posts("user_name", "display_name"))
|
||||||
|
{
|
||||||
|
$strUsername = Request::getPosted("user_name");
|
||||||
|
$strDisplayName = Request::getPosted("display_name");
|
||||||
|
|
||||||
|
if (!preg_match("/^[A-Za-z0-9]{1,}$/", $strUsername))
|
||||||
|
throw new Exception("Username must be alphanumeric characters only");
|
||||||
|
|
||||||
|
$c->query(
|
||||||
|
"INSERT or replace into users (email, user_name, display_name)
|
||||||
|
select
|
||||||
|
?,
|
||||||
|
?,
|
||||||
|
?",
|
||||||
|
$varUser["email"],
|
||||||
|
$strUsername,
|
||||||
|
$strDisplayName);
|
||||||
|
|
||||||
|
PageRender::message("Profile updated", "success");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception $x)
|
||||||
|
{
|
||||||
|
PageRender::message($x->getMessage(), "danger");
|
||||||
|
}
|
||||||
|
|
||||||
|
$strUsername = $varUser["username"];
|
||||||
|
PageRender::message("You are signed in as {$strUsername}.");
|
||||||
|
?>
|
||||||
|
|
||||||
|
<?php PageRender::message(); ?>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td><label>Username</label></td>
|
||||||
|
<td><?= $varUser["username"]; ?></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td><label>Created</label></td>
|
||||||
|
<td><?= $varUser["created"]; ?></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<?php if (Request::getParam("more")): ?>
|
||||||
|
<tr>
|
||||||
|
<td><label>Token</label></td>
|
||||||
|
<td><?= $varUser["token"]; ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php endif; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li><a href="?more=1">More</a></li>
|
||||||
|
<li><a href="/user/signout">Sign out</a></li>
|
||||||
|
</ul>
|
Loading…
Reference in New Issue
Block a user