Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*//////////////////////////////////////////////////////////////////////////
- | Script fully wrote by Marco Dittrich aka. "Mariomarco"
- | published on the 06-08-2013 at 15:45 pm UTC +1 in Germany
- | Created to assist Wireless redstone without Redpower od Codechicken
- | THIS SCRIPT IS MADE FOR FREE USE !
- |--|
- |
- | Links to my webspace are not allowed because of some safety issues with this script (inicated with the !!)
- | WARNING: Do not give anybody the link to this script on your webspace who wants to cause Damage.
- | All the "!!" in the comments inicate where somebody could write anything -> that means he could possibly fullfill your webspace.
- |
- | There are no other Bugs or Issues known Today - please feel free to contact me on Youtube: Youtube.com/eWobbit
- |
- |--|
- |
- | I hope you like it, Marco.
- |
- //////////////////////////////////////////////////////////////////////////*/
- $Domain = ""; //< File name to seperate multiple users !!
- $Domain = $_GET["domain"];
- $Action = "get"; //< Action can be either "get" or "set"
- $Action = $_GET["act"];
- $Frequenz = -1; //< Wireless Frequenz from 0 to 1023
- $Frequenz = $_GET["freq"];
- $State = "0"; //< State of the Frequenz could be anything !!
- $State = $_GET["state"];
- if( $Domain != "" && $Frequenz <= 1023 && $Frequenz >=0){ //< checking for valid Domain and Frequenz
- if(!file_exists ("WRMME." . strtolower($Domain) . ".db")){
- $filename = "WRMME." . strtolower($Domain) . ".db"; //< Open File
- $handle = fopen($filename, "a+");
- $contents = "by Mariomarco|";
- fwrite($handle, $contents);
- fclose($handle);
- }
- if(strtolower($Action) == "set" ) { //< Check if Action is "set" or "get"
- $filename = "WRMME." . strtolower($Domain) . ".db"; //< Open File
- $handle = fopen($filename, "a+");
- $contents = fread($handle, filesize($filename));
- $contents = explode("|",$contents); //< Write File as Array
- if(array_search($Frequenz . "F-",$contents) != False){ //< Searching if the Frequenz already exists
- $arraySpot = array_search($Frequenz . "F-", $contents);
- unset($contents[array_search($Frequenz . "F-", $contents)]); //< Overwriting it
- $contents[$arraySpot] = $Frequenz ."F-". $State;
- echo'overwrote state';
- }else{
- $contents[count($contents)] = $Frequenz ."F-". $State; //< If it didn't exist add it
- echo'added state ';
- }
- $contents = array_values($contents); //< Save them again with the old Format
- $i = 0;
- file_put_contents($KeysFile1, "");
- while(count($contents) > $i){
- if($i == 0 ){
- fwrite($handle, $contents[0]);
- }else{
- fwrite($handle, "|".$contents[$i]);
- }
- }
- }else{
- $filename = "WRMME." . strtolower($Domain) . ".db"; //< If the Action is "get"
- $handle = fopen($filename, "a+"); //< Opens File
- $contents = fread($handle, filesize($filename));
- $contents = explode("|",$contents);
- if (array_search($Frequenz . "F-", $contents) != False){ //< Searches if the Frequenz exists
- echo''. str_replace($Frequenz . "F-","",$contents[array_search($Frequenz . "F-", $contents)]);
- }else{
- echo'freqnotfound';
- }
- $contents = array_values($contents); //< Write them back in the special Save form
- $i = 0;
- file_put_contents($KeysFile1, "");
- while(count($contents) > $i){
- if($i == 0 ){
- fwrite($handle, $contents[0]);
- }else{
- fwrite($handle, "|".$contents[$i]);
- }
- }
- }
- }else{ //< If the Start Variables were incorrect -> output reason
- if($Domain==""){
- echo'nodomain';
- }
- if($Frequenz >= 1023 || $Frequenz <=0){
- echo'invalidfreq';
- }
- }
- fclose($handle);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment