Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding more files

  • Loading branch information...
commit ebb87206dec86a57d258083a48cbd8210ced23f4 1 parent d5eeb4a
@qzio qzio authored
View
20 public/session.php
@@ -0,0 +1,20 @@
+<?php
+require dirname(__FILE__) . '/../bootstrap.php';
+
+function on_get( $params = array() ) {
+ return template(basename(__FILE__));
+}
+
+function on_post( $params = array() ) {
+ if ($_SESSION['username'] = user_authenticate($params)) {
+ redirect('/success.php?flash_notice='.urlencode('successfull login'));
+ }
+ return template(basename(__FILE__), array('flash_error' => 'failed login'));
+}
+
+function on_delete() {
+ unset($_SESSION['username']);
+ redirect('/');
+}
+
+run(basename(__FILE__,'.php') );
View
31 public/style.css
@@ -0,0 +1,31 @@
+body {
+ background: black; color: white;
+}
+
+/** grid **/
+#wrapper {
+ text-align: left;
+ width: 600px;
+ margin: 0 auto;
+}
+#stream-wrapper {
+ height: 320px;
+ border: 1px solid red;
+}
+
+.flash {
+ padding: 1em;
+}
+.notice {
+ border: 1px solid yellow;
+}
+.error {
+ border: 1px solid red;
+}
+
+form {
+ display: inline;
+}
+fieldset {
+ display: inline;
+}
View
8 public/success.php
@@ -0,0 +1,8 @@
+<?php
+require_once dirname(__FILE__).'/../bootstrap.php';
+
+function on_get($params) {
+ return template(basename(__FILE__), $params);
+}
+
+run(basename(__FILE__,'.php'));
View
37 public/user.php
@@ -0,0 +1,37 @@
+<?php
+require dirname(__FILE__).'/../bootstrap.php';
+
+function validate($params) {
+ $errors = array();
+ if (empty($params['username'])) {
+ $errors['username'] = 'need to specify a username';
+ }
+ if (empty($params['email'])) {
+ $errors['email'] = 'need to specify a email';
+ }
+ if (strlen($params['password']) < 2) {
+ $errors['password'] = 'need to have a password';
+ }
+ return (empty($errors)) ? false : $errors;
+}
+
+function on_get($params = array()) {
+ if (isset($params['new'])) {
+ $params['title'] = 'create a new user!';
+ }
+
+ return template(basename(__FILE__), $params);
+}
+
+function on_post($params) {
+ $user_create = user_save($params);
+
+ $ok = array_shift($user_create);
+ if (!$ok) {
+ $params['user_errors'] = array_shift($user_create);
+ return template(basename(__FILE__), $params);
+ }
+ redirect('/success.php?flash_notice='.urlencode('a new user was registered'));
+}
+
+echo run(basename(__FILE__, '.php'));
View
5 templates/error.php
@@ -0,0 +1,5 @@
+<div class="error">
+ error!
+ <?php if (isset($render_me)) echo "tried to render ".h($render_me); ?>
+ <?php var_dump($p); ?>
+</div>
View
36 templates/layout.php
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf8"/>
+ <link rel="stylesheet" type="text/css" href="/style.css"/>
+ <title></title>
+ </head>
+ <body>
+ <div id="wrapper">
+ <?php if (is_authenticated()) { ?>
+ <div>
+ Du är inloggad som <?=user_current()?>
+ |
+ <?= form_start(array('action' => '/session.php', 'method' => 'delete'))?>
+ <input type="submit" value="logout" />
+ </form>
+
+ <?php } else { ?>
+ <div>
+ <a href="/session.php">Logga in</a>
+ |
+ <a href="/user.php">registrera</a>
+ </div>
+ <?php } ?>
+ <?php if (isset($p['flash_notice'])) { ?>
+ <div class="msg notice"><?=h($p['flash_notice'])?></div>
+ <?php } else if (isset($p['flash_error'])) { ?>
+ <div class="msg error"><?=h($p['flash_error'])?></div>
+ <?php } ?>
+ <?= $p['_content']?>
+ <?= template('_webcam.php')?>
+ <address>copyleft! <?php unset($p['_content']); //var_dump($p)?></address>
+ </div>
+
+ </body>
+</html>
View
7 templates/session.php
@@ -0,0 +1,7 @@
+<?=form_start(array('action' => '/session.php', 'method' => 'post'))?>
+<fieldset>
+ <input type="text" name="username" />
+ <input type="password" name="password" />
+ <input type="submit" value="submit"/>
+</fieldset>
+</form>
View
2  templates/success.php
@@ -0,0 +1,2 @@
+<h1>IAM SUCCESS</h1>
+<a href="#">DOWNLOAD THE CLIENT!</a>
View
6 templates/user.php
@@ -0,0 +1,6 @@
+<?= form_start(array('action'=>'/user.php','method' => 'post'))?>
+ <?php if (isset($p['user_errors'])) var_dump($p['user_errors']); ?>
+ <input type="text" name="username" placeholder="username" value=""/>
+ <input type="password" name="password" placeholder="password" value=""/>
+ <input type="submit" value="register!"/>
+</form>
Please sign in to comment.
Something went wrong with that request. Please try again.