aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin J. Novack <jnovack@gmail.com>2012-09-16 11:58:51 -0400
committerJustin J. Novack <jnovack@gmail.com>2012-09-16 11:58:51 -0400
commit57ec8736424dfa1637ea01228b87fbbf458b213f (patch)
treeb038b8b7ae29e6e01ce1c90cf303f43eddf9ecb6
parentfbaebb7485cfab4948b8fe000ef2a5279b376f04 (diff)
downloadphorkie-57ec8736424dfa1637ea01228b87fbbf458b213f.tar.gz
phorkie-57ec8736424dfa1637ea01228b87fbbf458b213f.zip
ADD: Allow editing of user session data
-rw-r--r--data/templates/base.htm4
-rw-r--r--data/templates/user.htm15
-rw-r--r--www/.htaccess1
-rw-r--r--www/user.php27
4 files changed, 45 insertions, 2 deletions
diff --git a/data/templates/base.htm b/data/templates/base.htm
index 8192b6b..ec2b746 100644
--- a/data/templates/base.htm
+++ b/data/templates/base.htm
@@ -27,7 +27,7 @@
</li>
{% if identity %}
<li>
- <a href="#">{{name}} ({{email}})</a>
+ <a href="/user">{{name}} ({{email}})</a>
</li>
<li>
<a href="/auth?logout">Logout</a>
@@ -65,4 +65,4 @@
</div>
</body>
-</html> \ No newline at end of file
+</html>
diff --git a/data/templates/user.htm b/data/templates/user.htm
new file mode 100644
index 0000000..c8ef387
--- /dev/null
+++ b/data/templates/user.htm
@@ -0,0 +1,15 @@
+{% extends "base.htm" %}
+{% block title %}User Preferences{% endblock %}
+
+{% block content %}
+
+<form method="post" action="/user" id="user_form">
+<fieldset>
+ <legend>User Profile</legend>
+ <p>Please update your git preferences for <code>{{ identity }}</code></p>
+ <label for='name'>Name:</label><input class="" id="name" type="text" name="name" width="35" value="{{ name }}"><br/>
+ <label for='email'>Email:</label><input class="" id="email" type="text" name="email" width="35" value="{{ email }}"><br/>
+ <input class="btn" id="submit" type="submit" value="Update">
+</fieldset>
+</form>
+{% endblock %}
diff --git a/www/.htaccess b/www/.htaccess
index fd2963b..c1d339d 100644
--- a/www/.htaccess
+++ b/www/.htaccess
@@ -23,3 +23,4 @@ RewriteRule ^search/([0-9]+)$ /search.php?page=$1
RewriteRule ^auth$ /auth.php
RewriteRule ^login$ /login.php
RewriteRule ^forbidden$ /forbidden.php
+RewriteRule ^user$ /user.php
diff --git a/www/user.php b/www/user.php
new file mode 100644
index 0000000..1cc8aeb
--- /dev/null
+++ b/www/user.php
@@ -0,0 +1,27 @@
+<?php
+/**
+ * Edit user information
+ */
+namespace phorkie;
+require_once 'www-header.php';
+if (!isset($_SESSION['identity'])) {
+ require_once 'secure.php';
+}
+
+if (isset($_POST['name'])) {
+ $_SESSION['name'] = substr(filter_var($_POST['name'], FILTER_SANITIZE_STRING), 0, 35);
+}
+
+if (isset($_POST['email'])) {
+ $_SESSION['email'] = substr(filter_var($_POST['email'], FILTER_SANITIZE_EMAIL), 0, 35);
+}
+
+render(
+ 'user',
+ array(
+ 'identity' => $_SESSION['identity'],
+ 'name' => $_SESSION['name'],
+ 'email' => $_SESSION['email']
+ )
+);
+?>