Mariomarco

Wireless Redstone Mariomarco Edition

Aug 6th, 2013
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.70 KB | None | 0 0
  1. <?php
  2. /*//////////////////////////////////////////////////////////////////////////
  3. |   Script fully wrote by Marco Dittrich aka. "Mariomarco"
  4. |   published on the 06-08-2013 at 15:45 pm UTC +1 in Germany
  5. |   Created to assist Wireless redstone without Redpower od Codechicken
  6. |   THIS SCRIPT IS MADE FOR FREE USE !
  7.  
  8. |--|
  9. |
  10. |   Links to my webspace are not allowed because of some safety issues with this script (inicated with the !!)
  11. |   WARNING: Do not give anybody the link to this script on your webspace who wants to cause Damage.
  12. |   All the "!!" in the comments inicate where somebody could write anything -> that means he could possibly fullfill your webspace.
  13. |  
  14. |   There are no other Bugs or Issues known Today - please feel free to contact me on Youtube: Youtube.com/eWobbit
  15. |
  16. |--|
  17. |
  18. |   I hope you like it, Marco.
  19. |
  20. //////////////////////////////////////////////////////////////////////////*/
  21.  
  22.  
  23. $Domain = "";                                                               //< File name to seperate multiple users !!
  24. $Domain = $_GET["domain"];
  25. $Action = "get";                                                            //< Action can be either "get" or "set"
  26. $Action = $_GET["act"];
  27. $Frequenz = -1;                                                             //< Wireless Frequenz from 0 to 1023
  28. $Frequenz = $_GET["freq"];
  29. $State = "0";                                                               //< State of the Frequenz could be anything !!
  30. $State = $_GET["state"];
  31. if( $Domain != "" && $Frequenz <= 1023 && $Frequenz >=0){                   //< checking for valid Domain and Frequenz
  32.     if(!file_exists ("WRMME." . strtolower($Domain) . ".db")){
  33.         $filename = "WRMME." . strtolower($Domain) . ".db";                 //< Open File
  34.         $handle = fopen($filename, "a+");
  35.         $contents = "by Mariomarco|";
  36.         fwrite($handle, $contents);
  37.         fclose($handle);
  38.     }
  39.     if(strtolower($Action) == "set" ) {                                     //< Check if Action is "set" or "get"
  40.             $filename = "WRMME." . strtolower($Domain) . ".db";             //< Open File
  41.             $handle = fopen($filename, "a+");
  42.             $contents = fread($handle, filesize($filename));
  43.             $contents = explode("|",$contents);                             //< Write File as Array
  44.             if(array_search($Frequenz . "F-",$contents) != False){                  //< Searching if the Frequenz already exists
  45.                 $arraySpot = array_search($Frequenz . "F-", $contents);
  46.                 unset($contents[array_search($Frequenz . "F-", $contents)]);        //< Overwriting it
  47.                 $contents[$arraySpot] = $Frequenz ."F-". $State;   
  48.                 echo'overwrote state';
  49.             }else{
  50.                 $contents[count($contents)] = $Frequenz ."F-". $State;      //< If it didn't exist add it
  51.                 echo'added state ';
  52.             }
  53.             $contents = array_values($contents);                            //< Save them again with the old Format
  54.             $i = 0;
  55.             file_put_contents($KeysFile1, "");
  56.             while(count($contents) > $i){
  57.                 if($i == 0 ){
  58.                     fwrite($handle, $contents[0]);
  59.                 }else{
  60.                     fwrite($handle, "|".$contents[$i]);
  61.                 }
  62.             }
  63.         }else{
  64.             $filename = "WRMME." . strtolower($Domain) . ".db";             //< If the Action is "get"
  65.             $handle = fopen($filename, "a+");                               //< Opens File
  66.             $contents = fread($handle, filesize($filename));
  67.             $contents = explode("|",$contents);
  68.            
  69.             if (array_search($Frequenz . "F-", $contents) != False){                //< Searches if the Frequenz exists
  70.                 echo''. str_replace($Frequenz . "F-","",$contents[array_search($Frequenz . "F-", $contents)]);
  71.             }else{
  72.                 echo'freqnotfound';
  73.             }
  74.                 $contents = array_values($contents);                        //< Write them back in the special Save form
  75.                 $i = 0;
  76.                 file_put_contents($KeysFile1, "");
  77.                 while(count($contents) > $i){
  78.                     if($i == 0 ){
  79.                         fwrite($handle, $contents[0]);
  80.                     }else{
  81.                         fwrite($handle, "|".$contents[$i]);
  82.                     }
  83.                 }
  84.     }
  85. }else{                                                                          //<  If the Start Variables were incorrect -> output reason
  86.     if($Domain==""){
  87.      echo'nodomain';
  88.     }
  89.     if($Frequenz >= 1023 || $Frequenz <=0){
  90.         echo'invalidfreq';
  91.     }
  92. }
  93. fclose($handle);
  94. ?>
Advertisement
Add Comment
Please, Sign In to add comment