Jump to content

absorr

Members
  • Posts

    53
  • Joined

  • Last visited

Everything posted by absorr

  1. absorr

    Filter

    Basically I pasted it right in <?phprequire('JSONAPI.php'); // get this file at: https://github.com/alecgorge/jsonapi/raw/master/sdk/php/JSONAPI.php$api = new JSONAPI(CENSORED, CENSORED, CENSORED, CENSORED, CENSORED);var_dump($api->call("getPlayer", array($_POST["name"]))); echo '<table>';echo '<tbody>';foreach($array as $property=>$value) { echo '<tr>'; echo "<td>$property</td><td>$value</td>"; echo '</tr>';}echo '</tbody>';echo '<thead><tr><th>Property</th><th>Value</th></tr></thead>';echo '</table>';?>
  2. absorr

    Filter

    Didn't work either
  3. absorr

    Filter

    I put that in and it only gave me the headers
  4. absorr

    Filter

    ummmm when I do it with getPlayer I just get the word Array. When i do non-filtering, I get this: array(3) { ["result"]=> string(7) "success" ["source"]=> string(9) "getPlayer" ["success"]=> array(18) { ["worldInfo"]=> array(7) { ["remainingWeatherTicks"]=> int(131354) ["hasStorm"]=> bool(false) ["time"]=> int(13278) ["environment"]=> string(6) "normal" ["isThundering"]=> bool(false) ["name"]=> string(9) "adventure" ["fullTime"]=> int(4957278) } ["op"]=> bool(true) ["location"]=> array(5) { ["yaw"]=> float(91.047104) ["pitch"]=> float(22.049994) ["z"]=> float(1152.71875) ["y"]=> float(64) ["x"]=> float(862.90625) } ["exhaustion"]=> float(3.6588554) ["sleeping"]=> bool(false) ["health"]=> int(16) ["ip"]=> string(18) "/192.168.1.1:52644" ["gameMode"]=> int(0) ["inVehicle"]=> bool(false) ["level"]=> int(2) ["inventory"]=> array(3) { ["hand"]=> array(4) { ["enchantments"]=> array(0) { } ["amount"]=> int(1) ["durability"]=> int(1) ["type"]=> int(267) } ["inventory"]=> array(36) { [0]=> array(4) { ["enchantments"]=> array(0) { } ["amount"]=> int(1) ["durability"]=> int(1) ["type"]=> int(267) } [1]=> array(4) { ["enchantments"]=> array(0) { } ["amount"]=> int(1) ["durability"]=> int(0) ["type"]=> int(344) } [2]=> array(4) { ["enchantments"]=> array(0) { } ["amount"]=> int(1) ["durability"]=> int(31) ["type"]=> int(346) } [3]=> array(4) { ["enchantments"]=> array(0) { } ["amount"]=> int(19) ["durability"]=> int(0) ["type"]=> int(297) } [4]=> array(4) { ["enchantments"]=> array(0) { } ["amount"]=> int(64) ["durability"]=> int(0) ["type"]=> int(295) } [5]=> array(4) { ["enchantments"]=> array(0) { } ["amount"]=> int(21) ["durability"]=> int(0) ["type"]=> int(295) } [6]=> NULL [7]=> NULL [8]=> NULL [9]=> NULL [10]=> NULL [11]=> NULL [12]=> NULL [13]=> NULL [14]=> NULL [15]=> NULL [16]=> NULL [17]=> NULL [18]=> NULL [19]=> NULL [20]=> NULL [21]=> NULL [22]=> NULL [23]=> NULL [24]=> NULL [25]=> NULL [26]=> NULL [27]=> NULL [28]=> NULL [29]=> NULL [30]=> NULL [31]=> NULL [32]=> NULL [33]=> NULL [34]=> NULL [35]=> NULL } ["armor"]=> array(4) { ["helmet"]=> array(4) { ["enchantments"]=> array(0) { } ["amount"]=> int(0) ["durability"]=> int(-1) ["type"]=> int(0) } ["boots"]=> array(4) { ["enchantments"]=> array(0) { } ["amount"]=> int(0) ["durability"]=> int(-1) ["type"]=> int(0) } ["leggings"]=> array(4) { ["enchantments"]=> array(0) { } ["amount"]=> int(0) ["durability"]=> int(-1) ["type"]=> int(0) } ["chestplate"]=> array(4) { ["enchantments"]=> array(0) { } ["amount"]=> int(0) ["durability"]=> int(-1) ["type"]=> int(0) } } } ["name"]=> string(6) "absorr" ["foodLevel"]=> int(8) ["experience"]=> int(25) ["itemInHand"]=> array(4) { ["enchantments"]=> array(0) { } ["amount"]=> int(1) ["durability"]=> int(1) ["type"]=> int(267) } ["sneaking"]=> bool(false) ["world"]=> int(3) ["sprinting"]=> bool(false) } } What I want is to have each bit of information organized. If you look through there are things like the world the player is in, the things in their inventory, all sorts of stuff, but how do I make each individual part show? I plan to make it so that like the health will be represented by a different picture for each amount using if and ifelse, show a picture of the players inventory based on the item ids, etc. All I need is the individual parts that I actually want
  5. absorr

    Filter

    THANK YOU! That worked perfectly! You 2 are awesome! This has unlocked a lot for me in the web application I am making with this.
  6. absorr

    Filter

    How would I do that and how would that help?
  7. absorr

    Filter

    Yeah that did not work. I'm sorry if my error confused you but I didn't mean that I got it through function. Here is JSONAPI.php which is used by it <?php/*** A PHP class for access Minecraft servers that have Bukkit with the {@link http://github.com/alecgorge/JSONAPI JSONAPI} plugin installed.** This class handles everything from key creation to URL creation to actually returning the decoded JSON as an associative array.** @author Alec Gorge <alecgorge@gmail.com>* @version Alpha 5* @link http://github.com/alecgorge/JSONAPI* @package JSONAPI* @since Alpha 5*/class JSONAPI {public $host;public $port;public $salt;public $username;public $password;private $urlFormats = array( "call" => "http://%s:%s/api/call?method=%s&args=%s&key=%s", "callMultiple" => "http://%s:%s/api/call-multiple?method=%s&args=%s&key=%s");/** * Creates a new JSONAPI instance. */public function __construct ($host, $port, $uname, $pword, $salt) { $this->host = $host; $this->port = $port; $this->username = $uname; $this->password = $pword; $this->salt = $salt; if(!extension_loaded("cURL")) { throw new Exception("JSONAPI requires cURL extension in order to work."); }}/** * Generates the proper SHA256 based key from the given method suitable for use as the key GET parameter in a JSONAPI API call. * * @param string $method The name of the JSONAPI API method to generate the key for. * @return string The SHA256 key suitable for use as the key GET parameter in a JSONAPI API call. */public function createKey($method) { if(is_array($method)) { $method = json_encode($method); } return hash('sha256', $this->username . $method . $this->password . $this->salt);}/** * Generates the proper URL for a standard API call the given method and arguments. * * @param string $method The name of the JSONAPI API method to generate the URL for. * @param array $args An array of arguments that are to be passed in the URL. * @return string A proper standard JSONAPI API call URL. Example: "http://localhost:20059/api/call?method=methodName&args=jsonEncodedArgsArray&key=validKey". */public function makeURL($method, array $args) { return sprintf($this->urlFormats["call"], $this->host, $this->port, rawurlencode($method), rawurlencode(json_encode($args)), $this->createKey($method));}/** * Generates the proper URL for a multiple API call the given method and arguments. * * @param array $methods An array of strings, where each string is the name of the JSONAPI API method to generate the URL for. * @param array $args An array of arrays, where each array contains the arguments that are to be passed in the URL. * @return string A proper multiple JSONAPI API call URL. Example: "http://localhost:20059/api/call-multiple?method=[methodName,methodName2]&args=jsonEncodedArrayOfArgsArrays&key=validKey". */public function makeURLMultiple(array $methods, array $args) { return sprintf($this->urlFormats["callMultiple"], $this->host, $this->port, rawurlencode(json_encode($methods)), rawurlencode(json_encode($args)), $this->createKey($methods));}/** * Calls the single given JSONAPI API method with the given args. * * @param string $method The name of the JSONAPI API method to call. * @param array $args An array of arguments that are to be passed. * @return array An associative array representing the JSON that was returned. */public function call($method, array $args = array()) { if(is_array($method)) { return $this->callMultiple($method, $args); } $url = $this->makeURL($method, $args); return json_decode($this->curl($url), true);}private function curl($url) { $c = curl_init($url); curl_setopt($c, CURLOPT_PORT, $this->port); curl_setopt($c, CURLOPT_HEADER, false); curl_setopt($c, CURLOPT_RETURNTRANSFER, true); curl_setopt($c, CURLOPT_TIMEOUT, 10); $result = curl_exec($c); curl_close($c); return $result;}/** * Calls the given JSONAPI API methods with the given args. * * @param array $methods An array strings, where each string is the name of a JSONAPI API method to call. * @param array $args An array of arrays of arguments that are to be passed. * @throws Exception When the length of the $methods array and the $args array are different, an exception is thrown. * @return array An array of associative arrays representing the JSON that was returned. */public function callMultiple(array $methods, array $args = array()) { if(count($methods) !== count($args)) { throw new Exception("The length of the arrays \$methods and \$args are different! You need an array of arguments for each method!"); } $url = $this->makeURLMultiple($methods, $args); return json_decode($this->curl($url), true);}} and here is broadcastWithName.php with the login information censored with ***. This is what takes the input from an HTML text field and sends it to JSONAPI.php (the one above). This does work but again the reason I'm posting is to try to filter out the results it gives me to just one part. <?php require('JSONAPI.php'); // get this file at: [url="https://github.com/alecgorge/jsonapi/raw/master/sdk/php/JSONAPI.php"]https://github.com/a...php/JSONAPI.php[/url] $api = new JSONAPI("***", ***, "***", "***", "***"); var_dump($api->call("broadcastWithName", array($_POST["msg"], $_POST["name"])));?>
  8. absorr

    Upload To Api Help

    Please help, it is not working. I'm trying to upload a .jar onto it. The console says it received the error page where the contents of the jar should be. it is uploading, I know that because it went into my directory upload.php <?php if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; move_uploaded_file($_FILES["file"]["tmp_name"], "plugins/" . $_FILES["file"]["name"]); echo "Stored in: " . "plugins/" . $_FILES["file"]["name"]; $a_str = array($_FILES["file"]["name"]); $contents = implode(PHP_EOL, $a_str); $contents .= PHP_EOL . PHP_EOL; print("|$contents|"); $lines = file("http://games.absorr.pcriot.com/JSONAPI/plugins/{$_FILES['file']['name']}"); foreach($lines as $line); echo $lines; echo "debug 2"; require('JSONAPI.php'); // get this file at: https://github.com/alecgorge/jsonapi/raw/master/sdk/php/JSONAPI.php $api = new JSONAPI("174.101.159.155", 20059, "absorr", "PASSWORD CENSORED FOR FORUM", " SALT CENSORED FOR FORUM"); var_dump($api->call("setFileContents", array("{$_FILES['file']['name']}", $lines))); echo "Debug 3"; }?>
  9. absorr

    Filter

    I realize i may have made an aerror than. i did not mean a PHP function. I meant a method for the API, which in the above example is getPlayerLimit
  10. absorr

    Filter

    So i would just doecho $array[success'] ?
  11. absorr

    Filter

    Ok so I'm using this API and whenever I use a method, it gives me more than I want. For example, one function gives me: array(3) { ["result"]=> string(7) "success" ["source"]=> string(14) "getPlayerLimit" ["success"]=> int(20)} when all i want is the number at the bottom by intHow do I make it so that it will only show that number?
  12. How do I get php to put the contents, and only the contents, of a file being uploaded into an array?
  13. absorr

    Month What?

    Using HTML and PHP, it is supposed to post to the month.html but it doesn't. When I press submit it doesn't even show that it received the month. HTML <form action="events/submit.php" method="post"enctype="multipart/form-data">Month: <select name="month"> <option value="January">January</option> <option value="Febuary">Febuary</option> <option value="March">March</option> <option value="April">April</option> <option value="May">May</option> <option value="June">June</option> <option value="July">July</option> <option value="August">August</option> <option value="Septemper">September</option> <option value="October">October</option> <option value="November">November</option> <option value="December">December</option></select><br>Date:<INPUT TYPE="text" NAME="date" value="12"><br>Time:<INPUT TYPE="text" NAME="time" value="1:00-3:00pm"><br>Title:<INPUT TYPE="text" NAME="title"><br>Description:<br><TEXTAREA NAME="detail" ROWS="10" WRAP="hard"></TEXTAREA><br><input type="submit" name="submit" value="Submit" /></form> PHP <?php$a_str = array($_POST["month"],$_POST["date"],$_POST["time"],$_POST["title"],$_POST["detail"]);$contents = implode(PHP_EOL, $a_str);$contents .= PHP_EOL . PHP_EOL;file_put_contents("{$_POST['month']}.html", "<br><h2>{$_POST['month']} {$_POST['date']}, {$_POST['time']}</h2><b>{$_POST['title']}</b><br><p>{$_POST['detail']}</p><br>", FILE_APPEND);print("|$contents|");?> and no matter what month I selected, there is no html posted. What is wrong? It is most likely the HTML. Is it the select stuff?
  14. absorr

    Upload Video Problem

    turns out i forgot to add </forum>
  15. I created something to upload videos but it won't work. <?php if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "/" . $_FILES["file"]["name"]); echo "Stored in: " . "/" . $_FILES["file"]["name"]; $a_str = array($_POST["fname"],$_POST["age"],$_POST["alb"],$_FILES["file"]["name"]); $contents = implode(PHP_EOL, $a_str); $contents .= PHP_EOL . PHP_EOL; file_put_contents("videos.html", "<br><b>{$_POST['fname']}</b><video height=\"400\" controls=\"controls\"><source src=\"{$_FILES['file']['name']}\" type=\"video/{$_FILES['file']['type']}\" /><object data=\"{$_FILES['file']['name']}\" width=\"320\" height=\"240\"><embed src=\"movie.swf\" width=\"320\" height=\"240\">FAIL! Your browser can not handle this video</object></video><br><u>Description</u> <p>{$_POST['age']}</p><br>", FILE_APPEND); print("|$contents|"); } }?> and here is what it said when i tried uploading an mp4 file: Upload: Type: Size: 0 KbTemp file: already exists. I looked in my folder and there was no video there. What is wrong? How can I fix it?
  16. I want to replicate this game I made in Scratch onto my site. http://scratch.mit.edu/projects/absorr/1489987Would javascript work? Is there a better option that won't cost me money? If javascript would work, how do i make it so that the object can move and bounce off walls?
  17. Ok, now I tried doing that with the image and it won't let it. Reading the error report, I discovered it is because when it sees the quotation marks in <img src="example"> it thinks that the text part of the string ended and gets confused with the {} you have to put the uploaded file in. How do I make it so that it will see " as text to add in instead of part of the code?
  18. THANK YOU! That worked perfectly!
  19. You still gave not told me the actual reason I posted: CREATING CODE WITH WHAT WAS SUBMITTED
  20. Oh you were refering to the iframe part. Thanks for that but i wanted s better solution for iframe for some thing else, not this issue, but thats one less post to this forum I have to make. Can you help with the main issue now?
  21. This confuses me. How does this help me create an HTML element with this? I don't think you understand what I'm asking for. I want it so that when you press submit on photos_main.html the php file puts <img src="(photo)"><br><b>(title here)</b><br><p>(description)</p> in an html file
  22. I barely know anything about directories, want to go on on how this would work?
  23. i want to make it so that what you put in an HTML forum when sent will add to a separate HTML page with the input from the forum inserted into code. For example, on a forum in typeit.html you type "My Name" into the name text box and "This Is My Message" into the message box. You clock submit and it sends it to the PHP page which sends <b>My Name</b><br><p>This Is My message</p><br> to a separate HTML page called mytxt.htmlNote that was an example and what the names of pages and forums are above are different in reality.I already have a code to simple print the text as it is but i don't know how to make code with PHP.Here is the code that I have so far: in photo_main.html <form action="upload_file.php" method="post"enctype="multipart/form-data"><input type="file" name="file" id="file" /> <br />Title:<INPUT TYPE="text" NAME="fname"><br>Description:<INPUT TYPE="text" NAME="age"><br>Photo Album:<INPUT TYPE="text" NAME="alb"><br><input type="submit" name="submit" value="Submit" /></form> in upload_file.php <?php if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("images/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "images/" . $_FILES["file"]["name"]); echo "Stored in: " . "images/" . $_FILES["file"]["name"]; $a_str = array($_POST["fname"],$_POST["age"],$_POST["alb"],$_FILES["file"]["name"]); $contents = implode(PHP_EOL, $a_str); $contents .= PHP_EOL . PHP_EOL; file_put_contents("photos.txt", $contents, FILE_APPEND); print("|$contents|"); } }?> I want to make it so that instead of text going to a txt file I want code going to an HTML file so that i don't have to keep manually putting in uploaded photos. I am going to use an iframe to put in the HTML to a page. If there is a better way than an iframe that would be great too. I hope I was not confusing.
  24. THANK YOU THANK YOU THANK YOU! That worked perfectly! Funny story, I asked my Web Design teacher about this and he said he barely knew anything about PHP so he gave me 2 huge books to look through.
×
×
  • Create New...