/** @test */ public function adminTest() { //[1,2] $res = handle_admin(); $this->assertEquals("post error", $res); //[1,3,4] //sqlite database file was not existed. $_POST['admin_account'] = "text-account"; $_POST['admin_password'] = "******"; copy("../sqlite/books_web.s3db", "./books_web.s3db"); @unlink("../sqlite/books_web.s3db"); $res = handle_admin(); $this->assertEquals("cannot link database.", $res); //[1,3,5,7] $_POST['admin_account'] = "text-account"; $_POST['admin_password'] = "******"; copy("./books_web.s3db", "../sqlite/books_web.s3db"); //sqlite database file already has existed. $res = handle_admin(); $this->assertEquals("admin login failed.", $res); //[1,3,5,6] copy("./books_web.s3db", "../sqlite/books_web.s3db"); $_POST['admin_account'] = "text-account"; $_POST['admin_password'] = "******"; $res = handle_admin(); $this->assertEquals("admin login success.", $res); }
$es = array($admin) + $sockets; #errorlog("Doing select with read sockets ".count($rs)." '".var_export($rs,TRUE)."'"); $n = socket_select($rs, $ws, $es, 0, 1000000); check_sock_error("BACKEND select"); if (count($es) > 0) { handle_exceptions($es); } if ($n === false) { errorlog("BACKEND: socket_select: " . socket_strerror(socket_last_error())); } else { if ($n > 0) { #errorlog("BACKEND: select returned n=".$n); foreach ($rs as $readsocket) { #errorlog("BACKEND: Read for socket ".$readsocket); if ($readsocket === $admin) { $done = handle_admin($admin, $sockets, $sockets_seq_data, $sockets_next_seq, $clientdata); } else { errorlog("BACKEND: *** Data for created socket " . $readsocket); $sockkey = get_socket_key($sockets, $readsocket); if ($sockkey) { errorlog("BACKEND: *** Socket key is " . $sockkey); $data = ''; $ret = socket_recv($readsocket, $data, 2 * 1024 * 1024, 0); check_sock_error("BACKEND recv from readsocket"); #errorlog("BACKEND: *** recv returned data '".$data."' with ret=".$ret." on socket ".$readsocket); if ($data == NULL) { errorlog("BACKEND: *** Socket " . $readsocket . " has been closed"); array_push($clientdata, "[data]" . $sockkey . ":*"); socket_close($readsocket); unset($sockets[$sockkey]); } else {
} } $user = get_logged_in_user(); $action = get_str('action', true); switch ($action) { case '': handle_main($user); break; case 'abort_batch': handle_abort_batch($user); break; case 'abort_batch_confirm': handle_abort_batch_confirm(); break; case 'admin': handle_admin($user); break; case 'query_batch': handle_query_batch($user); break; case 'query_job': handle_query_job($user); break; case 'retire_batch': handle_retire_batch($user); break; case 'retire_batch_confirm': handle_retire_batch_confirm(); break; case 'show_all': handle_show_all($user);