MineLink v. 0.1 ~ Download Compatible with BukkitTcpServer v1.0. Hey everyone, a while back I made a PHP Class that connects to the plugin BukkitTcpServer by DerpinLlama and have just now decided to release it. Right now it supports the following commands: getplayers maxplayers pid playercount But I'm planning on adding more in the future. In the ZIP there is the Class file, a Config file, and a Usage file. Hopefully this will get everyone started right. This program is released under the terms of the GNU GPL v3. You will find the license in the ZIP file.
Hi, really nice, thank you for your job. Do you envisage to made a PHP Bukkit admin ? If not i'm working on it. Best regards. Cyb
It's GPL so you can post them. If I see then Fitting I'll add them. Also after releasing it I noticed there were a ton of bugs. I'll release 0.2 tonight.
perhaps it is postet already... in the usage.php are some syntax errors and in the minelink.php the funtion players returns $data['message'] instead of the right $data['players']. greetings abadon edit: instead of the echo for players in the usage php you should use <?php $players = $link->players(); foreach($players as $player){echo $player.' ';} ?>
Mhhh, i have still a problem with the server usage... we are running a debian server and the the minelink class doesn´t show me me the usage of the cpu and memory... does anyone knows this problem and perhaps how to fix it? greetings abadon
if i type the comand directly in the server console it works but called by the exec of the class it doesn´t work...
safe mode is off, here the server mesage wenn i type manually... i check the php.ini again noki@91-143-80-71:~$ ps -p 32502 -o %cpu %CPU 82.0 EDIT: safemode is off disable_functions is empty --- merged: Feb 27, 2011 10:25 PM --- OMG epic fail.... it must running on this server^^ i modify it so that it works from remote... --- merged: Feb 27, 2011 10:56 PM --- i have solved it with ssh2_lib... btw in the minelink.php $minecraft['memorylimit'] is not declared as class variable... because of that it can't use it in memoryusage here the example code for cpu usage with ssh2 lib mem usage is nearly the same: PHP: // log in at server1.example.com on port 22if(!($con = ssh2_connect('server-ip', 22))){ echo "fail: unable to establish connection\n";} else { // try to authenticate with username root, password secretpassword if(!ssh2_auth_password($con, 'username', 'password')) { echo "fail: unable to authenticate\n"; } else { if (!($stream = ssh2_exec($con, 'ps -p '. $this->pid .' -o %cpu' ))) { echo "fail: unable to execute command\n"; } else { // collect returning data from command stream_set_blocking($stream, true); $data = ""; while ($buf = fread($stream,4096)) { $data .= $buf; } fclose($stream); } }} $return = explode("\n", $data); if(!$return[1]) $return[1] = '0'; return $return[1];
Nice, glad you got it working! About the memorylimit, it's just however much memory you gave your server at startup with XmX
so it is in the function mem_usage: return ($return[1] / 1024) / $minecraft['memorylimit'] * 100; but it can't reach the variable so it works if it is set as class variable: return ($return[1] / 1024) / $this->minecraft['memorylimit'] * 100;
i have added a new function to show the server uptime, if you like it put it in the new release PHP: public function uptime(){ $return = explode("\n", shell_exec( 'ps -p '. $this->pid .' -o %t' )); if(!$return[1]) { $return = '0'; } else { $return = explode(":", $return[1]); if (count($return) == 3) {$return = $return[0].'h '.$return[1].'m '.$return[2].'s';} elseif(count($return) == 2){$return = $return[0].'m '.$return[1].'s';} elseif(count($return) == 1){$return = $return.'s';} } return $return;}
UPDATE UPTIME: this will only work if the server is running less than an hour^^ here the correct code: PHP: public function uptime(){ $return = explode("\n", shell_exec( 'ps -p '. $this->pid .' -o %t' )); if(!$return[1]) { $return = '0'; } else { $return = explode(":", $return[1]); if (count($return) == 3) {$return = $return[0].'h '.$return[1].'m '.$return[2].'s';} elseif(count($return) == 2){$return[0].'m '.$return[2].'s';} elseif(count($return) == 1){$return.'s';} } return $return;} perhaps it adds days to the reply if the server runs so long, in case of that another if must be added... i will watch it. without formatting the otput will be hh:mm:ss but if the server is running lesser than an hour or a minute the reply didn`t show the zeros...