diff options
author | Chris Xiong <chirs241097@gmail.com> | 2019-02-09 00:04:45 +0800 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2019-02-09 00:04:45 +0800 |
commit | 9d0b51a2abdacb5fc4eed95cb3249934b607fdc7 (patch) | |
tree | 298358cf2685f8ef87feaa3b4e46348d69929377 /xp/navigator/shit.php | |
parent | e1af5e214c389aea2b55daf82bdec92472db3f19 (diff) | |
download | oddities-9d0b51a2abdacb5fc4eed95cb3249934b607fdc7.tar.xz |
Navigator.
Diffstat (limited to 'xp/navigator/shit.php')
-rw-r--r-- | xp/navigator/shit.php | 38 |
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); +?> |