Permalink
Browse files

adding more files

  • Loading branch information...
1 parent d5eeb4a commit ebb87206dec86a57d258083a48cbd8210ced23f4 @qzio qzio committed Apr 5, 2011
Showing with 152 additions and 0 deletions.
  1. +20 −0 public/session.php
  2. +31 −0 public/style.css
  3. +8 −0 public/success.php
  4. +37 −0 public/user.php
  5. +5 −0 templates/error.php
  6. +36 −0 templates/layout.php
  7. +7 −0 templates/session.php
  8. +2 −0 templates/success.php
  9. +6 −0 templates/user.php
View
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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>
@@ -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>
@@ -0,0 +1,2 @@
+<h1>IAM SUCCESS</h1>
+<a href="#">DOWNLOAD THE CLIENT!</a>
View
@@ -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>

0 comments on commit ebb8720

Please sign in to comment.