RewriteEngine On
# redirect every other request to the index
-RewriteCond %{REQUEST_FILENAME} !-f
-RewriteCond %{REQUEST_FILENAME} !-d
-RewriteRule . index.php [L]
\ No newline at end of file
+RewriteRule /*\.(css|php|js|gif|png|jpe?g)$ - [NC,L]
+RewriteRule ^(.*)$ index.php?_url=$1 [QSA,L]
if ($params['user']) {
$user = get_users($dbh, array('user' => $params['user'] ));
if ($user) {
- $q = $dbh->prepare(" SELECT * FROM clumps JOIN users ON users.id = clumps.user_id WHERE user_id = ? ORDER BY date DESC ");
+ $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 {
}
else
{
- $q = $dbh->prepare("SELECT * FROM clumps JOIN users ON users.id = clumps.user_id ORDER BY date DESC");
+ $q = $dbh->prepare("SELECT *, clumps.id as clump_id FROM clumps JOIN users ON users.id = clumps.user_id ORDER BY date DESC");
$q->execute();
}
}
include 'head.html';
- echo '<ul>';
- for($i = 0; $row = $q->fetch(); $i++ ) {
- echo '<li>';
- echo sprintf(
- '%s - <a href="/get.php?user=%s">%s</a> : <a href="%s">%s</a>'
- , $row['date']
- , $row['user']
- , $row['user']
- , $row['location']
- , $row['title']);
- echo $row['tags'] ? '<span class="">' . $row['tags'] . '</span>' : '';
- echo '</li>';
+?>
+
+<script>
+
+ function deleteClump( id, elem ) {
+ if (confirm("delete clump?")) {
+ $.post('delete.php', { clump_id : id }, function(result) {
+ $(elem).hide(150);
+ }, 'json');
+ return false;
+ }
}
- echo '</ul>';
\ No newline at end of file
+
+</script>
+
+<ul>
+<?php for($i = 0; $row = $q->fetch(); $i++ ): ?>
+ <li>
+ <?php echo date("Y-m-d", strtotime($row['date'])) ?>
+ <a class="uname" href="/get.php?user=<?php echo $row['user'] ?>"><?php echo $row['user'] ?></a>
+ <a href="<?php echo $row['location'] ?>"><?php echo $row['title'] ?></a>
+ <span class="tags"><?php echo $row['tags'] ?></span>
+ <?php if ($user = get_user()): ?>
+ <?php if ($user['user'] == $row['user']): ?>
+ <a href="#" onClick="return deleteClump(<?php echo $row['clump_id']; ?>, this.parentNode);" class="delete">x</a>
+ <?php endif; ?>
+ <?php endif; ?>
+ </li>
+<?php endfor; ?>
+</ul>
-<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
-<LINK REL=StyleSheet HREF="/style.css" TYPE="text/css" MEDIA=screen>
\ No newline at end of file
+<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
+<link href='http://fonts.googleapis.com/css?family=Cousine:regular,italic,bold,bolditalic' rel='stylesheet' type='text/css' />
+<link href="/style.css" rel="styleSheet" type="text/css" media="screen" />
require_once 'init.php';
- $dbh = get_db_connection();
- $dbh->beginTransaction();
+ $url = trim($_GET['_url'], '/');
+
+ list($endpoint) = explode('/', $url);
- $switch = explode("/", $_SERVER['SCRIPT_URL']);
- switch($section = $switch[1])
+ $dbh = get_db_connection();
+ $dbh->beginTransaction();
+ switch($endpoint)
{
case 'get' :
include 'get.php';
exit;
-
case 'put' :
exit;
-
default :
- if ($section != '') {
- $user = get_users($dbh, array( 'user' => $section ));
+ if ($endpoint != '') {
+ $user = get_users($dbh, array( 'user' => $endpoint ));
if ( isset($user['user']) ) {
$get = function( $user ) {
$_GET['user'] = $user;
}
}
}
-
$dbh = null;
-
?><!DOCTYPE html>
<head>
<p>
bookmarklet:
-<?php
+<?php
$js = file_get_contents('bookmarklet.js');
?>
<br />
if ($user = get_user()) {
- $user['user'];
-
$sql = "INSERT INTO `clmpr`.`clumps` ( `user_id`, `title` , `location` , `date` )
VALUES ( ?, ?, ?, NOW() ) ";
$q = $dbh->prepare($sql);
body {
- font-family: times;
- font-size:14px;
- line-height:1.3em;
-}
\ No newline at end of file
+ color: #444444;
+ font-family: Cousine,monospace;
+ font-size: 12px;
+ line-height: 1.3em;
+}
+
+a {
+ text-decoration: none;
+}
+
+a:hover {
+ color: #000099;
+ text-decoration: underline;
+}
+
+ul {
+ padding: 0pt;
+}
+
+li {
+ list-style-type: none;
+}
+
+.uname {
+ color: #DDDDDD;
+ text-decoration: none;
+}
+.delete {
+ color:#d00;
+}
+.delete:hover {
+ text-decoration:none;
+}