From 5e26a395330e4eaa050da4c7fa0ac4f7f5d72a72 Mon Sep 17 00:00:00 2001 From: Gabriel Dunne Date: Sun, 17 Apr 2011 22:30:26 -0700 Subject: [PATCH] Deleting, and rss --- data.php | 1 - delete.php | 30 ++++++++++++++++++++++++++++++ get.php | 11 ++++++----- index.php | 42 +++++++++++++++++++++++++----------------- put.php | 2 -- rss.php | 26 ++++++++++++++++++++++++++ signin.php | 37 +++++++++++++++---------------------- style.css | 20 +++++++++++++++++++- 8 files changed, 121 insertions(+), 48 deletions(-) create mode 100644 delete.php create mode 100644 rss.php diff --git a/data.php b/data.php index c445a27..ee63c0d 100644 --- a/data.php +++ b/data.php @@ -31,7 +31,6 @@ return $q->fetch(); } } - throw( new PDOException(sprintf("user %s doesn't exist", $args['user']))); } catch (PDOException $e) { echo $e->getMessage(); diff --git a/delete.php b/delete.php new file mode 100644 index 0000000..f5324f2 --- /dev/null +++ b/delete.php @@ -0,0 +1,30 @@ +beginTransaction(); + + if ($user = get_user()) { + $sql = "DELETE FROM clmpr.clumps WHERE id = ? AND user_id = ?"; + $q = $dbh->prepare($sql); + $count = $q->execute( array( $params['clump_id'], $user['id'] )); + $dbh = null; + echo json_encode(array('deleted' => true)); + exit; + } else { + echo json_encode(array('mssg' => 'must be logged in')); + } + exit; + } + catch(PDOException $e) + { + echo $e->getMessage(); + } + + exit; \ No newline at end of file diff --git a/get.php b/get.php index 75de523..17a740a 100644 --- a/get.php +++ b/get.php @@ -5,7 +5,6 @@ $params = array(); $params['user'] = isset($_GET['user']) ? $_GET['user'] : null; - $dbh = get_db_connection(); $dbh->beginTransaction(); @@ -16,9 +15,6 @@ $q = $dbh->prepare(" SELECT *, clumps.id as clump_id FROM clumps JOIN users ON users.id = clumps.user_id WHERE user_id = ? ORDER BY date DESC "); $q->execute( array( $user['id'] )); } - else { - throw( new PDOException(sprintf("user %s doesn't exist", $params['user']))); - } } else { @@ -32,7 +28,12 @@ exit; } - include 'head.html'; + + switch ($format) { + case 'rss' : + include 'rss.php'; + exit; + } ?> diff --git a/index.php b/index.php index 5e8c2d3..cf293fb 100644 --- a/index.php +++ b/index.php @@ -6,35 +6,38 @@ list($endpoint) = explode('/', $url); + $pathinfo = pathinfo($_SERVER['SCRIPT_URL']); + $format = isset($pathinfo['extension']) ? $pathinfo['extension'] : null; + + $endpoint = str_replace('.'.$format, '', $endpoint); - $dbh = get_db_connection(); - $dbh->beginTransaction(); switch($endpoint) { - case 'get' : - include 'get.php'; - exit; - case 'put' : - exit; + case 'about' : + break; + default : + if ($endpoint != '') { + + $dbh = get_db_connection(); + $dbh->beginTransaction(); $user = get_users($dbh, array( 'user' => $endpoint )); + $dbh = null; 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; + + switch ($format) { + case 'rss' : + include 'get.php'; + exit; + } ?> @@ -47,7 +50,7 @@ -Citation, Logging and Multi-Purpose aRchive +
Citation, Logging and Multi-Purpose aRchive
@@ -60,4 +63,9 @@ $js = file_get_contents('bookmarklet.js');
- \ No newline at end of file + + +
+ \ No newline at end of file diff --git a/put.php b/put.php index 3db4372..d77836a 100644 --- a/put.php +++ b/put.php @@ -24,10 +24,8 @@ echo 'ok'; } else { - include 'head.html'; include 'signin.php'; - } exit; } diff --git a/rss.php b/rss.php new file mode 100644 index 0000000..1fd79fa --- /dev/null +++ b/rss.php @@ -0,0 +1,26 @@ +'; ?> + + + + +clmpr.com <?php echo $endpoint ?> +http://www.clmpr.com/ + +Citation, Logging and Multi-Purpose aRchive + + +fetch(); $i++ ): ?> + + + <?php echo $row['title'] ?> + + + + + posted by + + + + + + \ No newline at end of file diff --git a/signin.php b/signin.php index 80927f6..1e634d0 100644 --- a/signin.php +++ b/signin.php @@ -82,39 +82,32 @@ -

-

- +
- hi, -
- logout + - + + logout - sign in -
-    - - -
- - -
+ - +
+    + + +
- or signup + or sign up - + - + -

+
diff --git a/style.css b/style.css index 18bff4e..85408ec 100644 --- a/style.css +++ b/style.css @@ -22,8 +22,26 @@ li { list-style-type: none; } +.header { + color: #888888; + font-size: 18px; +} + +.header b { + color: #000000; +} +#signin { + position:absolute; + top:0; + right:0; + padding:5px; +} +#register { + display: inline-block; +} + .uname { - color: #DDDDDD; + color: #888888; text-decoration: none; } -- 2.34.1