From: Gabriel Dunne
bookmarklet:
-clmpr
\ No newline at end of file
+
+
-
-
';
for($i = 0; $row = $q->fetch(); $i++ ) {
- echo $row['date'] . ' - ' . $row['user'] . ': ' . $row['title'] . '
';
\ No newline at end of file
diff --git a/head.html b/head.html
new file mode 100644
index 0000000..174073a
--- /dev/null
+++ b/head.html
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/index.php b/index.php
index fbc682d..e4c0d05 100644
--- a/index.php
+++ b/index.php
@@ -1,12 +1,49 @@
-
-
+ $dbh = get_db_connection();
+ $dbh->beginTransaction();
+
+ $switch = explode("/", $_SERVER['SCRIPT_URL']);
+
+ switch($section = $switch[1])
+ {
+ case 'get' :
+ include 'get.php';
+ exit;
+
+ case 'put' :
+ exit;
+
+ default :
+ if ($section != '') {
+ $user = get_users($dbh, array( 'user' => $section ));
+ if ( isset($user['user']) ) {
+ $get = function( $user ) {
+ $_GET['user'] = $user;
+ include 'get.php';
+ exit;
+ };
+ $get( $user['user'] );
+ } else {
+ // else 404
+ $_GET['error'] = '404';
+ include 'error.php';
+ exit;
+ }
+ }
+ }
+
+ $dbh = null;
+
+
+?>
+
+
';
+ echo '
++
diff --git a/put.php b/put.php
index b39ddc1..cb7753d 100644
--- a/put.php
+++ b/put.php
@@ -24,6 +24,12 @@
echo "clumped.
";
echo 'ok';
+
+ } else {
+
+ include 'head.html';
+ include 'signin.php';
+
}
exit;
}
diff --git a/signin.php b/signin.php
index c2bd50a..4243dbb 100644
--- a/signin.php
+++ b/signin.php
@@ -16,23 +16,20 @@
echo json_encode(array('mssg' => 'logged out'));
exit;
}
-
$dbh = get_db_connection();
$dbh->beginTransaction();
$sql = "SELECT * FROM `clmpr`.`users` WHERE `user` = ? AND `pass` = PASSWORD(?)";
$q = $dbh->prepare($sql);
$q->execute( array( $params['user'], $params['pass'] ));
-
if ($q->rowCount() == 1) {
$res = $q->fetch();
$_SESSION['user'] = array( 'user' => $res['user'], 'id' => $res['id'] );
- echo json_encode(array('success'=>true, 'mssg' => 'welcome, ' . $params['user']));
+ echo json_encode(array('success'=>true, 'res' => $res));
} else {
$_SESSION['user'] = null;
echo json_encode(array('error'=>true, 'mssg' => 'invalid login'));
}
-
$dbh = null;
exit;
}
@@ -40,7 +37,7 @@
}
catch(PDOException $e)
{
- echo json_encode(array('success' => true, 'mssg' => $e->getMessage() ));
+ echo json_encode(array('error' => true, 'mssg' => $e->getMessage() ));
}
?>
@@ -52,14 +49,15 @@
var pass = $('#npass').val();
$('#register').text("creating user...");
$.post('signup.php', { user : user, pass : pass }, function(result) {
- $('#register').html(result.mssg);
+ if (result.success = 'true') {
+ window.location.reload();
+ }
}, 'json');
return false;
}
$('#signin_form').submit(function() {
- alert('Handler for .submit() called.');
return false;
});
function onSignIn()
@@ -68,7 +66,7 @@
var pass = $('#pass').val();
$('#signin').text("signing in...");
$.post('signin.php', { user : user, pass : pass }, function(result) {
- $('#signin').html(result.mssg);
+ window.location.reload();
}, 'json');
}
@@ -82,17 +80,15 @@
return false;
}
-
@@ -120,4 +118,6 @@
+
+