aboutsummaryrefslogblamecommitdiff
path: root/xp/navigator/shit.php
blob: 8602a9460f081176a8123fbea549cc12deeef95e (plain) (tree)





































                                                                                                             
<?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);
?>