serverFFS Forum

Last visit was: It is currently Thu Sep 09, 2010 8:22 am


All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: API Simple Webpanel Interface
PostPosted: Fri Jul 23, 2010 1:56 pm 

Joined: Thu Jan 28, 2010 3:02 pm
Posts: 17
Location: UK
ServerFFS API Panel - Version 1.0

Okay, so this is something me and a friend have been working on, it supports all the current API commands.

As more commands and stuff are added to the API, this will (hopefully) support them :)

This uses HTML5, CSS3 (for the nice, round borders), and of course PHP / JSON.

Configuration:
This is pretty easy to configure, first (if you don't already have one) create an API code at https://www.serverffs.com/control/other/api/

Next, allow you're webserver to access the API, this can be done by finding your sites IP address, or if you have a dedicated IP, that can be used! (I use http://whois.domaintools.com/ to find my sites IP).

Now, once the files are downloaded, go into the "inc" folder and edit settings.php - in here, this is what you'll see:
Code:
<?php
$apikey = "Your-API-Key"; //Your API Key
$comname = "ServerFFS API WebPanel"; //Your Community Name - This will also show as the "title", and header on main page.
$servid = "Your-Server-ID"; //Your Server ID
?>


It includes the settings.php file on all pages, I am using this method for it:
Code:
<?php include_once($_SERVER['DOCUMENT_ROOT']."/inc/settings.php"); ?>

This means, if you have it on your webserver at site.tld/folder/api - it will try to include from site.tld/inc/

Credits:
First I'd like to thank "D0erf|er", for giving me the idea with his thread called "Using the API with PHP".
And WanderG - For helping out when I needed it.

Things still to do:
Create a secure login system (don't know when this will be done), right now I use htaccess to password protect mine.
Clean up some code, and maybe make a new interface for it.

Issues:
On the list firewall bans page, if you have a lot of bans it will go down over the footer.

Demo and Download:

Here is a demo of it: (currently uses my server, as an example) http://demo.serverffs-api.dcsrvdls.com/ (The add/remove ban options are disabled on the demo, for security reasons etc, and because its just a demo ;))

Download is available at: http://files.dcsrvdls.com/downloads/apiwebpanel.zip

If you find any bugs or have any suggestions, then please reply! :)

Also, sorry for lack of info on it, as I havent made a thread like this before :oops:

~Adj011


Top
Offline Profile  
 
 Post subject: Re: API Simple Webpanel Interface
PostPosted: Mon Aug 16, 2010 6:02 am 

Joined: Mon Aug 16, 2010 5:10 am
Posts: 8
Hi, i tried, bu i get error code :s


Top
Offline Profile  
 
 Post subject: Re: API Simple Webpanel Interface
PostPosted: Mon Aug 16, 2010 3:22 pm 

Joined: Thu Jan 28, 2010 3:02 pm
Posts: 17
Location: UK
maxence4845 wrote:
Hi, i tried, bu i get error code :s

Could you say what the error is?

If it's something like:
Code:
Warning: include_once(path/to/required/file/) [function.include-once]: failed to open stream: No such file or directory in path/to/file.php on line 1

Then make sure the "inc" folder is in the same directory as where the main index file is, like: http://site.tld/inc/ - because I made it to include the settings file like that.

If it's something like:
Code:
Warning: Invalid argument supplied for foreach() in path/to/file/file.php on line 30

Then make sure you websites IP address has access to the API, (or if it isn't on a webserver, make sure your IP has access to it).


Top
Offline Profile  
 
 Post subject: Re: API Simple Webpanel Interface
PostPosted: Tue Aug 17, 2010 5:34 am 

Joined: Mon Aug 16, 2010 5:10 am
Posts: 8
Thank you, i did what you said, but i have still

Warning: Invalid argument supplied for foreach() in path/to/file/file.php on line 30

and i have allowed the website ip and my ip.

And now i haven't any template, look


Image


Top
Offline Profile  
 
 Post subject: Re: API Simple Webpanel Interface
PostPosted: Tue Aug 17, 2010 1:42 pm 

Joined: Thu Jan 28, 2010 3:02 pm
Posts: 17
Location: UK
maxence4845 wrote:
Thank you, i did what you said, but i have still

Warning: Invalid argument supplied for foreach() in path/to/file/file.php on line 30

and i have allowed the website ip and my ip.

And now i haven't any template, look


Image


The foreach() error only occurs when the IP address trying to access it isn't on the "Allowed IP addresses" list, try find your sites IP this way: create a php file on your site, and have this inside it:
Code:
<?php $ip = $_SERVER['SERVER_ADDR']; echo $ip; ?>
That will show what the sites IP address is.

The template doesn't seem to be loading because it can't find the stylesheet - make sure the 'main.css' file is within the "inc" folder, if the 'main.css' file is inside of it, make sure the folder with all php scripts is in the same directory as the inc folder (like site.tld/apipanel).

Anyway, I'm working on a new template for it, with a login/log-out system - here's what I've got done already (just started work on it, should be done soon - it'll also be a lot more user friendly):
Image (Click it for full-size!).


Top
Offline Profile  
 
 Post subject: Re: API Simple Webpanel Interface
PostPosted: Tue Aug 17, 2010 5:55 pm 
serverFFS Staff

Joined: Mon Dec 14, 2009 8:29 am
Posts: 49
Maybe you should output the actual error from our API to users so they know the exact issue.


Top
Offline Profile  
 
 Post subject: Re: API Simple Webpanel Interface
PostPosted: Tue Aug 17, 2010 9:26 pm 

Joined: Mon Aug 16, 2010 5:10 am
Posts: 8
I did one more step by step, bu always same result, and the ip is allowed


Top
Offline Profile  
 
 Post subject: Re: API Simple Webpanel Interface
PostPosted: Wed Aug 18, 2010 11:26 am 

Joined: Thu Jan 28, 2010 3:02 pm
Posts: 17
Location: UK
maxence4845 wrote:
I did one more step by step, bu always same result, and the ip is allowed

There's only 2 pages which use the foreach function (list firewall bans and list services) try this, and it'll help debug the foreach error(it'll out put the actual error from the API)

listbans:
Code:

<?php
$key 
= ""  //api key
$lfb = file_get_contents ("https://api.serverffs.com/?key=".$key."&command=firewall_list");
echo $lfb;
?>


listservices:
Code:

<?php
$key 
= ""; //api key
$ls = file_get_contents ("https://api.serverffs.com/?key=".$key."&command=server_list");
echo $ls;
?>


If the above code does work (and it probably will, as it's not using the foreach function), then I'm not sure what's causing the foreach error, it might be a outdated version of PHP (my webserver has version 5.2.42), find your version by doing this:
Code:
<?php phpinfo(); ?>

Then look around for the "core" section, and it'll say what version it is.

Also, does the other pages work? such as 'View Resources', 'Add ban to Firewall' etc..? - because they don't use the foreach function.


Top
Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC + 1 hour [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Proudly powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net & kodeki