return $q->fetch();
}
}
- throw( new PDOException(sprintf("user %s doesn't exist", $args['user'])));
}
catch (PDOException $e) {
echo $e->getMessage();
--- /dev/null
+<?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
$params = array();
$params['user'] = isset($_GET['user']) ? $_GET['user'] : null;
-
$dbh = get_db_connection();
$dbh->beginTransaction();
$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;
+ }
?>
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>
<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'; ?>
<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
echo '<a href="javascript:window.close();">ok</a>';
} else {
-
include 'head.html';
include 'signin.php';
-
}
exit;
}
--- /dev/null
+<?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
</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">
- <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">
+ <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>
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;
}