Based on the current examples with Bash scripts, Perl and LUA code on the site, I decided to contribute some PHP snippets which provide various functions:
Update: According to my research, the reboot and provisioning methods used for the GXP2120 and GXP2140 should also apply to the GXP2100 and GXP1200 phones.
Reboot for GXP2120 and GXP2140:
$pass = "admin";
// generate URLs
$login_url = "http://" . $ip . "/cgi-bin/dologin";
$reboot_url = "http://" . $ip . "/cgi-bin/api-sys_operation";
// curl object
$ch = curl_init();
// set curl to use cookie file
$ckfile = tempnam("/tmp", "CURLCOOKIE");
curl_setopt($ch, CURLOPT_COOKIEJAR, $ckfile);
//set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $login_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "&password=" . $pass);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
// get 'sid' as a string
$response = curl_exec($ch);
preg_match('/sid" : "([A-z0-9]*)/', $response, $sid);
$sid = $sid[1];
// now that we have the sid, send the reboot command
curl_setopt($ch, CURLOPT_URL, $reboot_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "&request=REBOOT&sid=" . $sid);
$response = curl_exec($ch);
curl_close($ch);
UPDATE 2017/03: as of recent firmware builds, the following GET request appears to be enough
$pass = "admin";
// generate URLs
$login_url = "http://" . $ip . "/cgi-bin/dologin";
$reboot_url = "http://" . $ip . "/cgi-bin/api-sys_operation";
// http://xx.xx.xx.xx/cgi-bin/api-sys_operation?password=XXXXX&request=REBOOT
$reboot_url = "http://" . $ip . "/cgi-bin/api-sys_operation?password=$pass&request=REBOOT";
// curl object
$ch = curl_init();
// Set some options - we are passing in a useragent too here
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $reboot_url);
curl_setopt($ch, CURLOPT_USERAGENT, 'GSProv cURL');
// send GET request
$response = curl_exec($ch);
curl_close($ch);
Reboot for the GXP2000:
$pass = "admin";
// generate URLs
$login_url = "http://" . $ip . "/dologin.htm";
$reboot_url = "http://" . $ip . "/rs.htm";
// curl object
$ch = curl_init();
// set curl to use cookie file
$ckfile = tempnam("/tmp", "CURLCOOKIE");
curl_setopt($ch, CURLOPT_COOKIEJAR, $ckfile);
//set the URL, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $login_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "P2=" . $pass . "&Login=Login&gnkey=0b82");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_MAXREDIRS, 3);
curl_setopt($ch, CURLOPT_REFERER, str_replace('dologin', 'login', $login_url));
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 ( .NET CLR 3.5.30729)");
// get 'sid' cookie by logging in
$response = curl_exec($ch);
// now that we have the sid cookie, send the reboot command
curl_setopt($ch, CURLOPT_URL, $reboot_url);
curl_setopt($ch, CURLOPT_POST, false);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, $ckfile);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_MAXREDIRS, 3);
$response = curl_exec($ch);
curl_close($ch);
Provisioning (plain XML) for GXP2120 and GXP2140:
-- This example assumes you have a database with tables named after the configuration parameters. If not, substitute the database part with reading a textfile of params instead or get creative...
// clear any previous output
ob_end_clean();
// set headers for filetype
header("Content-type: text/xml");
header("Content-Disposition: \"inline; filename=cfg" . $mac . ". ...