Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
152 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
require_once dirname(__FILE__).'/../bootstrap.php'; | ||
|
||
function on_get($params) { | ||
return template(basename(__FILE__), $params); | ||
} | ||
|
||
run(basename(__FILE__,'.php')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<h1>IAM SUCCESS</h1> | ||
<a href="#">DOWNLOAD THE CLIENT!</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |