body {font-family: monospace} a {color: white; text-decoration: none} img {border-style: none}"; print "
"; if( !$empty ) { print "Welcome to the listy thingy. Your list is empty. Here's how to get your list on:\n\n\n"; } print "All commands are appended to the url: (For example '".$_SERVER['SCRIPT_URI']."?hello world')\n\n"; print "?<text> // add line to list\n"; print "?-<line number> // delete line\n"; print "?-h // show this page\n"; print "?logout // logout"; print ""; print "If you use Firefox, drag the robot"; print "**"; print "to the bookmarks toolbar.
"; print "<keyword> // view all entries\n"; print "<keyword> <text> // add line to list\n"; print "<keyword> -<line number> // delete line\n"; print "<keyword> -h // show this page\n"; print "<keyword> logout // logout\n"; print ""; } function login() { print ""; print "
"; print "This is an online list keeper.\n"; print "You can add and remove items from a numbered list by appending to the url. Simple.\n\n\n"; print "To login, append ?<username>:<password> to the url.\n"; print "If no such username exists, it will be registered.\n"; print ""; } session_start(); if( $_SERVER['QUERY_STRING'] == 'logout' ) { session_destroy(); header("Location: ."); die; } if( urldecode($_SERVER['QUERY_STRING']) == '%s' ) { header("Location: ."); die; } if( !isset($_SESSION['u']) ) { $acct = explode(":",$_SERVER['QUERY_STRING']); $user = preg_replace("/[^A-Za-z0-9]/","",$acct[0]); if( $user && !file_exists("$dir/$user") ) { if( !$acct[1] ) { print ""; print "
"; print "no user $user, you can register this user.\n"; print ""; die; } else { $fp = fopen("$dir/$user","w"); fwrite($fp,md5($acct[1])."\n"); fclose($fp); $_SESSION['u'] = $user; $_SESSION['w'] = md5($acct[1]); header("Location: ."); die; } } else { $fp = fopen("$dir/$user","r"); $data=fgets($fp); fclose($fp); if( !$acct[1] ) { login(); die; } if( md5($acct[1]) != chop($data) ) { print ""; print "Incorrect password"; die; } else { $_SESSION['u'] = $user; $_SESSION['w'] = md5($acct[1]); header("Location: ."); die; } } } $data=file("$dir/".preg_replace("/[^A-Za-z0-9]/","",$_SESSION['u'])); if( $_SESSION['w'] != chop($data[0]) ) { session_destroy(); die; } if( ereg("^-([0-9]+)$",$_SERVER['QUERY_STRING'],$regs) ) { array_splice($data,$regs[1],1); $fp = fopen("$dir/".preg_replace("/[^A-Za-z0-9]/","",$_SESSION['u']),"w"); fwrite($fp,join("",$data)); fclose($fp); header("Location: ."); die; } $pass = array_shift($data); if( (!$data[0] && !$_SERVER['QUERY_STRING']) || $_SERVER['QUERY_STRING'] == "-h" ) { help($data[0]); die; } if( $_SERVER['QUERY_STRING'] ) { $fp = fopen("$dir/".preg_replace("/[^A-Za-z0-9]/","",$_SESSION['u']),"w"); fwrite($fp,$pass); fwrite($fp,urldecode(stripslashes($_SERVER['QUERY_STRING']))."\n"); fwrite($fp,join("",$data)); fclose($fp); header("Location: ."); } header("Content-type: text/plain"); foreach( $data as $line ) { print "[".++$i."] $line"; } ?>