jhylands

LIRA PHP page

Jan 13th, 2012
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.77 KB | None | 0 0
  1. <?php
  2. //if user wants to add a word
  3. if ($_POST["AddWord"]=="true"){
  4.         echo "Whichword";
  5.     if ($_POST["TYPE"]=="property"){
  6.         $file = fopen("pw.txt","r+") or exit("Unable to open file!");
  7.         $test = fread($file,filesize("pw.txt")) or exit("!!!");
  8.         $text = $text . $_POST["word"] . ",";
  9.         echo fwrite($file,"$text") or exit("Unable to edit file!");
  10.         fclose($file);
  11.         echo "Property word added";
  12.         echo $text;
  13.     }
  14.     elseif ($_POST["TYPE"]=="otherword"){
  15.         $file = fopen("ow.txt","r+") or exit("Unable to open file!");
  16.         $test = fread($file,filesize("pw.txt")) or exit("!!!");
  17.         $text = $text . $_POST["word"] . ",";
  18.         echo fwrite($file,"$text") or exit("Unable to edit file!");
  19.         fclose($file);
  20.         echo "Property word added";
  21.         echo $text;
  22. }
  23. else{
  24.     echo "object database not yet supported";
  25. }//end type
  26. }//end if addword
  27. elseif ($_POST["AddWord"] == "pw"){
  28.     $file = fopen("pw.txt","r") or exit("Unable to open file!");
  29.     $text = fread($file,filesize("pw.txt")) or exit("!!!");
  30.     fclose($file);
  31.     echo $text;
  32. }
  33. elseif ($_POST["AddWord"] == "ow"){
  34.     $file = fopen("ow.txt","r") or exit("Unable to open file!");
  35.     $text = fread($file,filesize("pw.txt")) or exit("!!!");
  36.     fclose($file);
  37.     echo $text;
  38. }
  39. elseif ($_POST["AddWord"] == "check"){//check if it's a property word
  40.     //create varibale with commas ither side to make checking correct
  41.     $word = "," . $_POST["word"] . ",";
  42.     //open property words text file
  43.     $file = fopen("pw.txt","r") or exit("Unable to open file!");
  44.     //save its contence to $text
  45.     $text = fread($file,filesize("pw.txt")) or exit("pw!!!");
  46.     //if the word that is being checked is in the file
  47.     if (strrpos($text,$word) != false){
  48.         echo "property";
  49.     }
  50.     //close the filestream
  51.     fclose($file);
  52.     //open other words text document
  53.     $file = fopen("ow.txt","r") or exit("Unable to open file!");
  54.     //save its contence to $text
  55.     $text = fread($file,filesize("ow.txt")) or exit("ow!!!");
  56.     //if the words that is being checked is in this string
  57.     if (strrpos($text,$word) != false){
  58.         echo "other";
  59.     }
  60.     //close filestream
  61.     fclose($file);
  62.     }//end check
  63. elseif ($_POST["AddWord"] == "AddObjects"){//add noun and properties
  64.     $file = fopen("/objects.xml","r+");
  65.     $text = fread($file,filesize("pw.txt")) or exit("!!!");
  66.     $text = $Text . "\n" . $_POST["object"];
  67.     echo fwrite($file,$Text);
  68.     fclose($file);
  69.     echo $text;
  70. }
  71. elseif ($_POST["AddWord"] == "GetObjects"){/get object list.
  72.     $file = fopen("/objects.xml","r");
  73.     $text = fread($file,filesize("pw.txt")) or exit("!!!");
  74.     fclose($file);
  75.     echo $text;
  76. }
  77. else{
  78. mysql_connect("cloud.wfv.me", "lira", "fast10sp33d") or die(mysql_error());
  79. echo "Connected to MySQL<br />";
  80. mysql_select_db("lira") or die(mysql_error());
  81. $result = mysql_query("SELECT * FROM objects");
  82. echo "Connected to Database";
  83. echo $result;
  84. }
  85. php?>
Advertisement
Add Comment
Please, Sign In to add comment