Search the Community
Showing results for tags 'minecraft'.
-
Hi! I need some help because I'am new in php language. So, my problem is that when I load my page I got this: But I don't need all this staff, i only need the number from the int(). Please help me Thank you! index.php <html> <head> <title>PHP Test</title> </head> <?php require('JSONAPI.php'); $api = new JSONAPI("localhost", 20059, "szabi****", "jate****", ""); var_dump($api->call("getPlayerLimit")); var_dump($api->call("getPlayerCount")); ?> <html> JSONAPI.php <?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 $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) { $this->host = $host; $this->port = $port; $this->username = $uname; $this->password = $pword; 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); } /** * 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); } /** * The default function called if no one matched for JSONAPI. * * @param string $method The name of the JSONAPI API method to call. * @param array $params An array of arguments that are to be passed. * @return array An associative array representing the JSON that was returned. */ function __call($method, $params) { if(is_array($params)) { return $this->call($method, $params); } else { return $this->call($method, array($params)); } } } Configuration file on my server: ~~~~Link~~~~ If you need any other info, just say it
-
I have this php : <?php $email = 'yourpaypalemail'; $url = 'locationofdatabase'; $user = 'username'; $password = 'password'; $database = 'DatabaseName'; $sandbox = 'false'; $packages = array( "package1" => "ExamplePackage", "package2" => "Yourpackagetwo", "package3" => "Yourpackagethree" ); function anti_injection($sql) { foreach ($sql as &$value) { if (!is_array($value)) { $value = mysql_real_escape_string(stripslashes(trim($value))); } } unset($value); return $sql; } $link = mysql_connect($url, $user, $password); if (!$link) { die('Not connected : ' . mysql_error()); } $db_selected = mysql_select_db($database, $link); if (!$db_selected) { die ('Can\'t use database : ' . mysql_error()); } $req = 'cmd=' . urlencode('_notify-validate'); foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; } if($sandbox == 'true'){ $url = '[url="https://www.sandbox.paypal.com/cgi-bin/webscr%27;"]https://www.sandbox....in/webscr';[/url] } else { $url = '[url="https://www.paypal.com/cgi-bin/webscr%27;"]https://www.paypal.c...in/webscr';[/url] } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $req); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/x-www-form-urlencoded", "Content-Length: " . strlen($req))); curl_setopt($ch, CURLOPT_HEADER , 0); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_TIMEOUT, 30); $curl_result = @curl_exec($ch); $curl_err = curl_error($ch); curl_close($ch); $_POST = anti_injection($_POST); $item_name = $_POST['item_name']; $item_number = $_POST['item_number']; $payment_status = $_POST['payment_status']; $amount = $_POST['mc_gross']; $payment_currency = $_POST['mc_currency']; $txn_id = $_POST['txn_id']; $receiver_email = $_POST['receiver_email']; $payer_email = $_POST['payer_email']; $player = mysql_real_escape_string(stripslashes(trim($_POST['custom']))); $settle = $_POST['settle_amount']; $package=false; foreach($packages as $pack){ if($pack == $item_name){ $package=true; } } //if($settle!=''){ //$amount = $settle; //} if (strpos($curl_result, "VERIFIED")==0) { if ($payment_status == 'Completed' && $receiver_email == $email){ $query = "INSERT INTO toothtransaction (player, amount, used, ipn) VALUES ('{$player}', {$amount}, 0, '{$txn_id}')"; mysql_query($query); if($package==true){ $query = "INSERT INTO toothpackages (player, cost, status, package) VALUES ('{$player}', {$amount}, 0, '{$item_name}')"; mysql_query($query); } mysql_close(); } } ?> And I need help cutting it down becasue evertime someone connect to the remote database on my minecraft server it lags alot. Im stuck and need help. I need to find out what part is causing the lag and I am debating between a remote database vs a local database.