aboutsummaryrefslogtreecommitdiff
path: root/xp/navigator/shit.php
diff options
context:
space:
mode:
Diffstat (limited to 'xp/navigator/shit.php')
-rw-r--r--xp/navigator/shit.php38
1 files changed, 38 insertions, 0 deletions
diff --git a/xp/navigator/shit.php b/xp/navigator/shit.php
new file mode 100644
index 0000000..8602a94
--- /dev/null
+++ b/xp/navigator/shit.php
@@ -0,0 +1,38 @@
+<?php
+ function do_login($pdo,$o)
+ {
+ $usrname=$o['username'];
+ $passwd=$o['passwd'];
+ $sessname=$o['sessionname'];
+ $qr=$pdo->query(sprintf('select passwd from navigator_user where username=\'%s\'',$usrname));
+ if($qr->rowCount()!=1){return array('result'=>1);}
+ if($passwd!=$qr->fetchColumn(0)){return array('result'=>1);}
+ $token=uniqid();
+ $pdo->query(sprintf('insert into navigator_session values(\'%s\',\'%s\',\'%s\',%d)',
+ $usrname,$passwd,$sessname,time()));
+ $pdo->commit();
+ {return array('result'=>0,'token'=>$token);}
+ }
+ $pdo=new PDO('mysql:host=localhost;dbname=chrisoft','chrisoft',null);
+ $o=json_decode(file_get_contents('php://stdin'));
+ $r=null;
+ switch($o['op'])
+ {
+ case 0:
+ $r=do_login($pdo,$o);
+ break;
+ case 1:
+ //get bookmarks
+ break;
+ case 2:
+ //set bookmarks
+ break;
+ case 3:
+ //list sessions
+ break;
+ case 4:
+ //remove session
+ break;
+ }
+ echo json_encode($r);
+?>