]> git.quilime.com - clmpr.git/commitdiff
Deleting, and rss
authorGabriel Dunne <gdunne@quilime.com>
Mon, 18 Apr 2011 05:30:26 +0000 (22:30 -0700)
committerGabriel Dunne <gdunne@quilime.com>
Mon, 18 Apr 2011 05:30:26 +0000 (22:30 -0700)
data.php
delete.php [new file with mode: 0644]
get.php
index.php
put.php
rss.php [new file with mode: 0644]
signin.php
style.css

index c445a27a427acf9361adcf5171c92e760f2600c7..ee63c0d76b54b28e3cd105e71a4d78c608521be1 100644 (file)
--- 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 (file)
index 0000000..f5324f2
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+
+    include 'init.php';
+
+    $params = array();
+    $params['clump_id'] = isset($_POST['clump_id']) ? $_POST['clump_id'] : null;
+
+    try {
+
+        $dbh = get_db_connection();
+        $dbh->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 75de523ddad0f47323415fd8fff2ee496dd99d51..17a740a83ce09e68caa915557ab5d9b30afcb4c8 100644 (file)
--- 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
         {
         exit;
     }
 
-    include 'head.html';
+
+    switch ($format) {
+        case 'rss' :
+            include 'rss.php';
+            exit;
+    }
 
 ?>
 
index 5e8c2d3ba144a8dd15c45e4ca27ecaaf1889f72f..cf293fb89d197f686e0d8842f255e0d291d40c41 100644 (file)
--- 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;
+    }
 
 ?><!DOCTYPE html>
 
@@ -47,7 +50,7 @@
 
 <body>
 
-<b>C</b>itation, <b>L</b>ogging and <b>M</b>ulti-<b>P</b>urpose a<b>R</b>chive
+<div class="header"><b>C</b>itation, <b>L</b>ogging and <b>M</b>ulti-<b>P</b>urpose a<b>R</b>chive</div>
 
 <?php include 'signin.php'; ?>
 
@@ -60,4 +63,9 @@ $js = file_get_contents('bookmarklet.js');
 
 <hr />
 
-<?php include 'get.php'; ?>
\ No newline at end of file
+<?php include 'get.php'; ?>
+
+<hr />
+<div id="footer">
+    <a class="about" href="/about">about</a>
+</div>
\ No newline at end of file
diff --git a/put.php b/put.php
index 3db4372d3f434257333adac6598af91a28443098..d77836a09bacd3d79741ed75c33d40e880b2ee61 100644 (file)
--- a/put.php
+++ b/put.php
             echo '<a href="javascript:window.close();">ok</a>';
 
         } else {
-
             include 'head.html';
             include 'signin.php';
-
         }
         exit;
     }
diff --git a/rss.php b/rss.php
new file mode 100644 (file)
index 0000000..1fd79fa
--- /dev/null
+++ b/rss.php
@@ -0,0 +1,26 @@
+<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
+<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://search.yahoo.com/mrss/">
+
+<channel>
+
+<title>clmpr.com <?php echo $endpoint ?></title>
+<link>http://www.clmpr.com/</link>
+<description></description>
+<title>Citation, Logging and Multi-Purpose aRchive</title>
+
+
+<?php for($i = 0; $row = $q->fetch(); $i++ ): ?>
+
+<item>
+    <title><?php echo $row['title'] ?></title>
+    <link><?php echo $row['location'] ?></link>
+    <pubDate><?php echo date('r', strtotime($row['date'])); ?></pubDate>
+    <tags><?php echo $row['tags'] ?></tags>
+    <postedby><?php echo $row['user'] ?></postedby>
+    <description>posted by <?php echo $row['user'] ?></description>
+</item>
+
+<?php endfor; ?>
+
+</channel>
+</rss>
\ No newline at end of file
index 80927f634ec6a10dbca3e0d7afe80532ce54d11d..1e634d0dd711affcf52c52e66b1fcb95c53d38fa 100644 (file)
 
 </script>
 
-<p>
 
-    <div id="signin">
-    <?php if ($user = get_user()) { ?>
+<div id="signin">
 
-        hi, <a href="/<?php echo $user['user']; ?>"><?php echo $user['user']; ?></a>
-        <br/>
-        <a href="#" onClick="return onLogout();">logout</a>
+<?php if ($user = get_user()) : ?>
 
-    <? } else { ?>
+    <a href="/<?php echo $user['user']; ?>"><?php echo $user['user']; ?></a>
+    <a href="#" onClick="return onLogout();">logout</a>
 
-        sign in
-        <form id="signin_form" action="javascript:onSignIn();" style="display:inline-block;">
-            <input type="text" id="user" name="u">&nbsp;&nbsp;
-            <input type="password" id="pass" name="p">
-            <input type="submit" value="sign in" />
-        </form>
-
-    <? } ?>
-    </div>
+<? else:  ?>
 
-    <?php if (!$user = get_user()) { ?>
+    <form id="signin_form" action="javascript:onSignIn();" style="display:inline-block;">
+        <input type="text" id="user" name="u">&nbsp;&nbsp;
+        <input type="password" id="pass" name="p">
+        <input type="submit" value="sign in" />
+    </form>
 
-    or <a id="register_link" href="#" onClick="$('#register').toggle(); return false;">signup</a>
+    or <a id="register_link" href="#" onClick="$('#register').toggle();">sign up</a>
 
-    <div id="register" style="display:none;">
+    <span id="register" style="display:none;">
         <form>
             <input id="nuser" type="text" value="user" onFocus="this.select();">
             <input id="npass" type="password" value="pass" onFocus="this.select();">
             <input type="submit" value="register" onClick="return register();">
         </form>
-    </div>
+    </span>
 
-    <?php } ?>
+<? endif; ?>
 
-</p>
+</div>
index 18bff4efd473fee0d24e3c4871e7ae2cb3c752c1..85408ec53798f131ca05c40e5b79a97904d36962 100644 (file)
--- 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;
 }