From: Gabriel Dunne Date: Wed, 16 Mar 2011 08:44:08 +0000 (-0700) Subject: clmpr is operational X-Git-Tag: v0.1~82 X-Git-Url: https://git.quilime.com/?a=commitdiff_plain;h=f55bad509b801215c5239dc737b1e64c7e9cace6;p=clmpr.git clmpr is operational --- f55bad509b801215c5239dc737b1e64c7e9cace6 diff --git a/README b/README new file mode 100644 index 0000000..e69de29 diff --git a/clmp.js b/clmp.js new file mode 100644 index 0000000..7841eb6 --- /dev/null +++ b/clmp.js @@ -0,0 +1,52 @@ +// clmp.js +(function() +{ + var l = 0; $(window).width() / 2; + var t = 0; $(window).height() / 2; + + var c = $([ + '
' + , '
' + , 'title:
' + , 'desc:  
' + , 'tags:  

' + , '' + , '
' + , '
' + ].join('')); + + $('body').append(c); + + // the following is on click + var params = { + 'title': "test", + 'referer': location.href, + 'tags': "tags", + 'desc': "desc" + }; + var urlb = []; + urlb.push('http://clmpr.com/save.php'); + urlb.push('?'); + for (var n in params) { + urlb.push(encodeURIComponent(n)); + urlb.push('='); + urlb.push(encodeURIComponent(params[n])); + urlb.push('&'); + } + // this method does a popup blocker + if (true) { + window.open(urlb.join(''), + 'saved ' + new Date().getTime(), + 'status=no,resizable=no,scrollbars=no,personalbar=no,directories=no,location=no,toolbar=no,menubar=no,' + + 'width=300,height=50,left=0,top=0'); + } + +} +)(); + +/* + +javascript:var i,s,ss=['http://kathack.com/js/kh.js','http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js'];for(i=0;i!=ss.length;i++){s=document.createElement('script');s.src=ss[i];document.body.appendChild(s);}void(0); +javascript:void((function(){var%20e=document.createElement('script');e.setAttribute('type','text/javascript');e.setAttribute('charset','UTF-8');e.setAttribute('src','http://ffffound.com/bookmarklet.js');document.body.appendChild(e)})()); + +*/ \ No newline at end of file diff --git a/data.php b/data.php new file mode 100644 index 0000000..f95c57c --- /dev/null +++ b/data.php @@ -0,0 +1,31 @@ +getMessage(); + } + } + + function get_user() + { + return isset($_SESSION['user']) ? $_SESSION['user'] : false; + } + + function get_users(&$dbh, $args) + { + $user = isset($args['user']) ? $args['user'] : false; + + if ($user) { + $sql = "SELECT * FROM `clmpr`.`users` WHERE `user` = ?"; + $q = $dbh->prepare($sql); + $q->execute( array( $user )); + if ($q->rowCount() == 1) { + return $q->fetch(); + } + } + return false; + } \ No newline at end of file diff --git a/get.php b/get.php new file mode 100644 index 0000000..d132e30 --- /dev/null +++ b/get.php @@ -0,0 +1,36 @@ +beginTransaction(); + + try { + + 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->execute( array( $user['id'] )); + } + + } else + { + $q = $dbh->prepare("SELECT * FROM `clumps` JOIN users ON users.id = clumps.user_id ORDER BY date DESC"); + $q->execute(); + } + } + catch(PDOException $e) + { + echo $e->getMessage(); + } + + + for($i = 0; $row = $q->fetch(); $i++ ) { + echo $row['date'] . ' - ' . $row['user'] . ': ' . $row['title'] . '
'; + } diff --git a/index.php b/index.php new file mode 100644 index 0000000..fbc682d --- /dev/null +++ b/index.php @@ -0,0 +1,38 @@ + + + + +clmpr + + + + + + + +Citation, Logging and Multi-Purpose aRchive + + + +

+bookmarklet: +clmpr \ No newline at end of file diff --git a/init.php b/init.php new file mode 100644 index 0000000..a257800 --- /dev/null +++ b/init.php @@ -0,0 +1,22 @@ +;dbname="); + define('DB_UNAME', ""); + define('DB_PW', ""); + + + ini_set('display_errors', 1); + error_reporting( E_ALL ); + + + include 'data.php'; diff --git a/put.php b/put.php new file mode 100644 index 0000000..b39ddc1 --- /dev/null +++ b/put.php @@ -0,0 +1,35 @@ +beginTransaction(); + + if ($user = get_user()) { + + $user['user']; + + $sql = "INSERT INTO `clmpr`.`clumps` ( `user_id`, `title` , `location` , `date` ) + VALUES ( ?, ?, ?, NOW() ) "; + $q = $dbh->prepare($sql); + $count = $q->execute( array( $user['id'], $params['title'],$params['location'] )); + + $dbh = null; + + echo "clumped.

"; + echo 'ok'; + } + exit; + } + catch(PDOException $e) + { + echo $e->getMessage(); + } + + exit; \ No newline at end of file diff --git a/signin.php b/signin.php new file mode 100644 index 0000000..c2bd50a --- /dev/null +++ b/signin.php @@ -0,0 +1,123 @@ + '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'])); + } else { + $_SESSION['user'] = null; + echo json_encode(array('error'=>true, 'mssg' => 'invalid login')); + } + + $dbh = null; + exit; + } + + } + catch(PDOException $e) + { + echo json_encode(array('success' => true, 'mssg' => $e->getMessage() )); + } + +?> + + +

+ + + +

+ + + hi,
+ logout + + + + sign in +
+    + + +
+ + +
+ +
+
+ + register + + + +

diff --git a/signup.php b/signup.php new file mode 100644 index 0000000..3beb5ea --- /dev/null +++ b/signup.php @@ -0,0 +1,38 @@ +beginTransaction(); + + $sql = "INSERT INTO `clmpr`.`users` ( `user` , `pass` , `created` ) + VALUES ( :user, PASSWORD(:pass), NOW() ) "; + $q = $dbh->prepare($sql); + $count = $q->execute( array( ':user' => $params['user'], ':pass' => $params['pass'] )); + + if ($count == 1) { + echo json_encode(array('success' => true, 'mssg' => 'welcome, ' . $params['user'] . '. your password is ' . $params['pass'] . '' )); + } else { + echo json_encode(array('exists' => true, 'mssg' => 'user already exists' )); + } + + $dbh = null; + + + } + + } + catch(PDOException $e) + { + echo json_encode(array('success' => true, 'mssg' => $e->getMessage() )); + } + + exit; \ No newline at end of file