Jump to content

HeyAwesomePeople

Members
  • Posts

    15
  • Joined

  • Last visited

HeyAwesomePeople's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Oh yeah... Okay so escaping just the "" doesn't result in an error, I just get the null message again. And the API is pretty simple. https://github.com/alecgorge/jsonapi http://hastebin.com/jozigaruru.php The API provides a way to communicate between a Minecraft server, Java, and the user. This can be through web app or iphone/android app or whatever. I don't think it's the API's fault, as Adminium(IOS app) also has a file manager system using the JSONAPI, and their files work just fine(including the types of one I am messing with). I looked through the Java anyways and found the method I am calling through the website: http://hastebin.com/avodositud.coffee Now this method only returns a success message or an error message, not nothing. It also state here that it should only return true or an error message... I'm also not the best at PHP(still fairly new to it) so the JSONAPI php file is hard to read for me, but I don't see anywhere I could get an error.. I cannot figure this out still. Thanks for helping me so far. What else should I be trying/looking at?
  2. If I don't escape the "" and '' I get php errors.
  3. The script fails because of the "" and '' in the yaml file... see here At least this is what I am assuming, because I can paste any part of the file but I have to escape the quotations. This works but then I have backslashes in my yaml file... Okay scratch what I just said here ^ If I use a literal string, like so, var_dump($api->call("files.write", array("plugins/GroupManager/worlds/world/groups.yml", " groups: Owner: default: false permissions: \"\" - \'*\' inheritance: \"\" - Coowner info: prefix: \'&4[Owner]\' build: true suffix: \"\" HeadAdmin: default: false permissions: [ ] inheritance: \"\" - g:server_head_admin - admin info: prefix: \'&c[Head Admin]\' build: true suffix: \"\" Admin: default: false permissions: [ ] inheritance: \"\" - g:bukkit_admin - g:towny_admin - g:groupmanager_admin - g:server_admin - Architect info: prefix: \'&c[Head Admin]\' build: true suffix: \"\" Architect: default: false permissions: [ ] inheritance: \"\" - g:server_architect - HeadModerator info: prefix: \'&a[Architect]\' build: true suffix: \"\" HeadModerator: default: false permissions: [ ] inheritance: \"\" - g:server_head_moderator - Moderator info: prefix: \'&5[Head Moderator]\' build: true suffix: \"\" Moderator: default: false permissions: [ ] inheritance: \"\" - g:bukkit_moderator - g:towny_moderator - g:server_moderator - Helper info: prefix: \'&d[Moderator]\' build: true suffix: \"\" Helper: default: false permissions: [ ] "))); This works fine(Other than the fact it adds backslashes to the yaml). The character count of the string is 1622 characters(this includes spaces). But if I add ANY character, just one more space or letter or number, the code fails and outputs this in its var_dump: null At 1622 characters I get a success message. array (size=1) 0 => array (size=4) 'result' => string 'success' (length=7) 'success' => boolean true 'source' => string 'files.write' (length=11) 'is_success' => boolean true So at first I think there's a limit of 1622 characters, but that's a very specific number. So I put into the literal string 3000 random characters and it worked.... I'm lost here. The difference between working and not working is 1 character...? I did another test too. I cut the yaml file I am editing to around 1550 characters and my script works perfectly fine all the way through. I figured this would be the case, but this means the quotes don't have anything to do with it. So I'm realllllyyyy confused. In the YAML format, I can only hit 1622 characters. Is there a php limit somewhere I don't know about?
  4. THERE'S PARENTHESIS. Ooohhh..... Okay so I need those parenthesis in the YAML to make it work right, so how would I avoid creating an issue with those?
  5. Maybe, but what do I do then? Printing $yaml into a text file results in what I want. $myfile = fopen("newfile.txt", "w") or die("Unable to open file!"); fwrite($myfile, $yaml); fclose($myfile); Result: http://hastebin.com/ucurevadup.sm
  6. Hello! I know this seems like an easy task, using strval or casting to string, but the API I am using WON'T accept anything but a hard coded string "". I figure there has to be a way to get around this... What I have here is a method used to convert an array in to a YAML/String format for me to upload onto a server using JSONAPI, found here. I am using Spyc, as that is the only thing I have found that works for this, and it does pretty well. function pushArrayToServer($array, $api) { $yaml = Spyc::YAMLDump($array,4,60); $value = 0; while (strpos($yaml, "$value:") !== false) { $yaml = str_replace("$value:", "-", $yaml); $value = $value + 1; } $yaml = str_replace("---", "", $yaml); // Final YAML from Array var_dump($api->call("files.write", array("plugins/GroupManager/worlds/world/groups.yml", $yaml))); } Now the problem is that last $api->call I do. This call accepts the method type as a string(argument 1), and an array for argument two. For the method "files.write", the api requires an array being (file location, string). The string is what will be replacing the content of the file. But the only way I can get that line to work is if I do this: var_dump($api->call("files.write", array("plugins/GroupManager/worlds/world/groups.yml", "a string here"))); That works 100% fine, no errors. This is the dump I get when I run that. But as soon as I do one of these: var_dump($api->call("files.write", array("plugins/GroupManager/worlds/world/groups.yml", $yaml))); $yaml2 = $yaml . ""; var_dump($api->call("files.write", array("plugins/GroupManager/worlds/world/groups.yml", $yaml2))); var_dump($api->call("files.write", array("plugins/GroupManager/worlds/world/groups.yml", strval($yaml)))); var_dump($api->call("files.write", array("plugins/GroupManager/worlds/world/groups.yml", "$yaml2"))); var_dump($api->call("files.write", array("plugins/GroupManager/worlds/world/groups.yml", (string)$yaml))); These do not work. The dumps all return null. I haven't found a way yet to not do "". It almost worked once when I attempted some things, but I found out I was just converting a boolean into a string which caused an error. The server I am working with is a minecraft server with JSONAPi installed. It works great, except for this error. So I am assuming the string type has to be just like Java's, or pretty plain? I have no clue this is the first real issue I've had with this plugin. Thanks in advance, HeyAwesomePeople
  7. Works, thanks! I tried that, but it didn't work. I think it's because I am trying to put values from a MySQL server in it as well. But the above one showed works fine and is a little less confusing. Thanks.
  8. Hello. I'm new to PHP and have kinda just been playing around. But I ran into a problem. I want to echo this: echo '<div class=""list"" onclick=""location.href="#"""> <div class=""serverListHover"" style=""width: 90%; float: right""> <div class=""serverListHover"" style=""width: 25%; float: right""> <span style=""font-size: 12px;"">Ip Address Here</span> <div style=""background:blue; height:4px""></div> </div> <div class=""serverListHover"" style=""width: 75%; float: left""> <img class=""listImage"" src=""http://www.news.balkanenergy.com/wp-content/uploads/2014/02/InEnerg14-460x90-EN.jpg"" alt=""Pulpit rock"" width=""460"" height=""60""> </div> </div> <div class=""serverListHoverLeft""> <span class=""rank"" style=""display:inline-block; vertical-align:middle"">123</span> </div> </div>'; But it won't turn out right. First off, the styles/classes don't seem to be working. All it shows with this code is "IP Address Here" and "123". No styles at all. And secondly, is this a good way to do this? I plan on using a MySQL database to pull data from and insert into parts of this code, but I want to know it this will be efficient enough(or if there's a easier/better way). Thanks, HeyAwesomePeople
  9. Basically I want it to create a new page USING the template, and that new page has this in a specific location: <span style="float: left; font-size: 34px;">Showing Server: '.$name.'</span><br /><br /> <table class="serverList"> <tbody><tr> <th class="tname">Name</th> <th class="tdesc">Desc</th> <th class="ttype">Type</th> <th class="tplayers">Players</th> <th class="tstatus">Status</th> </tr> <tr> <td class="tname"><p class="wrap-tname"><a href="server/'.$ip.'.php">'.$name.'</a></p></td> <td class="tserver"> '.$desc.' </td> <td class="ttype"><p class="wrap-ttype">'.$type.'</p></td> <td class="tplayers">UNKNOWN</td> <td class="tstatus Online">UNKNOWN</td> </tr> </tbody></table>
  10. Hello. I am trying to make it so that when a person enters there server info(For minecraft(game)) then it will take a template file, add in an edited peace of code, then save it called something else, somewhere else. Here is my PHP. <?php if($_POST['submit']) { $name = htmlspecialchars($_POST['sName']); $ip = htmlspecialchars($_POST['sIp']); $port = htmlspecialchars($_POST['sPort']); $desc = htmlspecialchars($_POST['sDesc']); $descName = "/home/content/85/9477285/html/uniqueminecraftservers/server/{$ip}.php"; $finalName = "/home/content/85/9477285/html/uniqueminecraftservers/slist/{$ip}({$port}).php"; if (file_exists($finalName)) { echo 'File already exists'; } else { $writestring = ' <tr> <td class="trank">*</td> <td class="tname"><p class="wrap-tname"><a href="server/'.$ip.'.php">'.$name.'</a></p></td> <td class="tserver"> <a href="server/'.$ip.'.php"><img style="border:none;width:468px;height:60px;" src="/uniqueminecraftservers/slist/banners/1.jpg"></a> <br>IP: '.$ip.'</td> <td class="tport"><p class="wrap-ttype">'.$port.'</p></td> <td class="tplayers">2078/3000</td> <td class="tstatus Online">Online</td> </tr>'; $file = fopen($finalName, "w"); $size = filesize($finalName); fwrite($file, $writestring); fclose($file); } //Now start saving of description if (file_exists($descName)) { echo 'File already exists'; } else { $writestring = ' <span style="float: left; font-size: 34px;">Showing Server: '.$name.'</span><br /><br /> <table class="serverList"> <tbody><tr> <th class="tname">Name</th> <th class="tdesc">Desc</th> <th class="ttype">Type</th> <th class="tplayers">Players</th> <th class="tstatus">Status</th> </tr> <tr> <td class="tname"><p class="wrap-tname"><a href="server/'.$ip.'.php">'.$name.'</a></p></td> <td class="tserver"> '.$desc.' </td> <td class="ttype"><p class="wrap-ttype">'.$type.'</p></td> <td class="tplayers">UNKNOWN</td> <td class="tstatus Online">UNKNOWN</td> </tr> </tbody></table> '; $file = fopen($descName, "w"); $size = filesize($descName); fwrite($file, $writestring); fclose($file); echo 'File Saved. Your server is now listed!'; } } ?> Right now, this PHP code, when ran, first creates a server listing on the home page, then continues to $writestring to make another file. What I want to do is be able to take what is in that $writestring and replace $serverInfo with the $writestring in the template, then save the edited template somewhere else and keep the origanal template in its original form. Hopefully you understood what I said. Here is the template I want to use, and the keyword '.$serverInfo.' is where I want the contents of $writestring. <!doctype html> <title>Unique Minecraft Servers || Home</title> <?php $path = $_SERVER['DOCUMENT_ROOT']; $path .= "/uniqueminecraftservers/head/head.php"; include_once($path); ?> <link rel="stylesheet" href="style.css"> </head> <body id="body"> <div class="centered"> <div class="table1"> <img src="/uniqueminecraftservers/UMS.png" alt="UMS Banner" height="70" width="900"> <?php $path = $_SERVER['DOCUMENT_ROOT']; $path .= "/uniqueminecraftservers/navmenu/navimenu.php"; include_once($path); ?></p> </div> </div> '.$serverInfo.' <div class="centered"> <div class="ad"> <p>Advertisment</p> </div> </div> <div class="centered"> <div class="table1"> <p> '.$server.' </div> <div class="centered"> <div class="ad"> <p> <script type="text/javascript"><!-- google_ad_client = "ca-pub-1405430741302930"; /* Bottom Ad 1 */ google_ad_slot = "2957143917"; google_ad_width = 728; google_ad_height = 90; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> </p> </div> </div> </div> </div> </div> </body> </html> I hope this all made sense. If not tell me and I will try to explain more. Thanks!
  11. FIXED I used /home/content/85/9477285/html/uniqueminecraftservers/slist/{$ip}({$port}).php INSTEAD OF JUST /uniqueminecraftservers/slist/{$ip}({$port}).php Thanks for your help guys!
  12. I already tried doing that, then I tried your code above. Both came out with many errors. Warning: fopen(/uniqueminecraftservers/slist/70.170.21.9(25565).php) [function.fopen]: failed to open stream: No such file or directory in /home/content/85/9477285/html/uniqueminecraftservers/upload/upload.php on line 24 Warning: filesize() [function.filesize]: stat failed for /uniqueminecraftservers/slist/70.170.21.9(25565).php in /home/content/85/9477285/html/uniqueminecraftservers/upload/upload.php on line 25 Warning: fwrite() expects parameter 1 to be resource, boolean given in /home/content/85/9477285/html/uniqueminecraftservers/upload/upload.php on line 26 Warning: fclose() expects parameter 1 to be resource, boolean given in /home/content/85/9477285/html/uniqueminecraftservers/upload/upload.php on line 27 If I kept it how it was, no errors would show and it would work fine, but the file would not go to the specified location.
  13. I changed $finalName = "$ip.(".$port.").html"; To $finalName = "/uniqueminecraftservers/slist/$ip.(".$port.").html"; Still uploads the file to the same folder AND now the check for if the file already exists is broken, it just rewrites it.
  14. Right now I have a PHP code which takes a template, changes some things on it, and saves it to the same folder the .php file is in. How do I make it so that I can change where that file is saved? <?php if($_POST['submit']) { $name = htmlspecialchars($_POST['sName']); $ip = htmlspecialchars($_POST['sIp']); $port = htmlspecialchars($_POST['sPort']); $desc = htmlspecialchars($_POST['sDesc']); $finalName = $ip."(".$port.").html"; $writestring = ' <tr> <td class="trank">*</td> <td class="tname"><p class="wrap-tname"><a href="/server/5510">'.$name.'</a></p></td> <td class="tserver"><a href="/server/5510"><img style="border:none;width:468px;height:60px;" src="/uniqueminecraftservers/slist/banners/1.jpg"></a><br>IP: '.$ip.'</td> <td class="ttype"><p class="wrap-ttype">'.$port.'</p></td> <td class="tplayers">2078/3000 </td> <td class="tstatus Online">Online </td> </tr>'; if (file_exists($ip."(".$port.").html")) { echo 'File already exists'; } else { $finalName = $ip."(".$port.").html"; $file = fopen($finalName, "w"); $size = filesize($finalName); fwrite($file, $writestring); fclose($file); echo 'File Saved. Your server is now listed!'; } } $url = "http://www.maytagaclasvegas.com/uniqueminecraftservers/"; function redirect($url){ if (headers_sent()){ die('<script type="text/javascript">window.location.href="' . $url . '";</script>'); }else{ header('Location: ' . $url); die(); } } ?> Thanks! -HeyAwesomePeople
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.