4 function readline($prompt="") {
8 $ifp = fopen("php://stdin", "r"); //PHP <= 4
9 $line = fgets($ifp, 999); //PHP <= 4
10 fclose($ifp); //PHP <= 4
13 $line = fgets(STDIN
, 999); //PHP >= 5
22 $random_out = "Random judged: ";
23 $nextf_out = "\nNext file: ";
24 exec("chcp 1250"); //Only Windows - set CP1250 - national alphabets - needed for Cestina ;)
28 $game = ""; //Hra natazena v pameti
29 $file = ""; //Posledni otevreny soubor
30 $nextf = ""; //Soubor nacteny z odkazu
31 $pos = 2; //Pozice ve hre
33 $hist[$histpos] = "START";
39 "http://gbook.wz.cz/\n".
40 "-----------------------\n".
41 "Type h[ENTER] for help.\n"
46 $in_line = readline($prompt);
47 $in_cmds = explode(" ", $in_line);
48 $in_cmds[0] = strtolower($in_cmds[0]);
51 if ($in_cmds[0] == "h") {
56 "l file - Load file\n".
57 "l URL - Load file from HTTP or FTP\n".
58 "y - set CP 1250 ONLY WINDOWS!!! (for some national characters)\n".
61 "p - Print history\n".
62 "n - Load next file from link\n".
70 if ($in_cmds[0] == "l") {
71 if ( file_exists( trim($in_cmds[1]) ) ||
strpos(" ".$in_cmds[1], ":") )
73 if ( strpos(" ".$in_cmds[1], ":") ) {
74 echo("DOWNLOADING...\n");
76 $game = file( trim($in_cmds[1]) );
77 $file = trim($in_cmds[1]);
79 $hist[$histpos] = "\nLOAD: ".trim($in_cmds[1])."\n";
80 echo("LOADED: $in_cmds[1]\n");
81 print_r(explode("|", $game[0]));
86 echo("CAN'T LOAD: $in_cmds[1]\n");
91 if ($in_cmds[0] == "r") {
93 $hist[$histpos] = "RELOAD";
98 if ($in_cmds[0] == "p") {
99 echo( implode(";", $hist) );
103 if ($in_cmds[0] == "c") {
105 $hist[$histpos] = "CLOSE\n";
110 if ( is_numeric( trim($in_cmds[0]) ) ) {
111 $pos = round(trim($in_cmds[0]));
113 if(isset($game[$posi])) {
117 $hist[$histpos] = $pos;
120 if ( strpos( (" ".$game[$posi]), "%%" ) ) {
121 $nextf = explode("%%", $game[$posi]);
122 $nextf = explode("|", $nextf[1]);
128 if ( strpos( (" ".$game[$posi]), "{" ) ) {
129 $rnd = explode("{", $game[$posi]);
130 $rnd = explode("}", $rnd[1]);
131 $rnd = explode("\\\\", $rnd[0]);
132 $rnd = $rnd[rand( 0, (sizeof($rnd) - 1) )];
133 $rnd = ($random_out.$rnd);
137 echo("$pos: ". $game[$posi]);
143 if( is_file($nextf) ) {
144 echo($nextf_out.$nextf."\nType n[ENTER]2[ENTER] to go on.");
150 if ( $in_cmds[0] == "f" ) {
153 while (false!==($file = readdir($dfp))) {
154 if ($file != "." && $file != "..") {
161 //y - CP 1250 (needed for Czech language)
162 if ( $in_cmds[0] == "y" ) {
163 system("chcp 1250"); //Only Windows
167 if ($in_cmds[0] == "i") {
168 print_r(explode("|", $game[0]));
173 if ($in_cmds[0] == "n" && is_file($nextf) ) {
174 $game = file($nextf);
177 $hist[$histpos] = "\n
183 if ($in_cmds[0] == "q") {
184 die("Exited by user at $file - $pos.\n");
This page took 2.081313 seconds and 4 git commands to generate.