#!/usr/bin/php -q
<?php
//Gigaset Reset-Script by Dakapo
//Stationen die neu gestartet werden sollen
$gigasets = array ( '192.168.0.30', '192.168.0.31', '192.168.0.32' );
//Admin-Passwort der Konfigurationsoberflaeche
$password = '0000';
foreach ( $gigasets AS $gigaset ) {
reset_gigaset ( $gigaset, $password );
}
function reset_gigaset ( $ip, $password = '0000' ) {
// INIT CURL
$ch = curl_init();
// SET URL FOR THE POST FORM LOGIN
curl_setopt($ch, CURLOPT_URL, 'http://' . $ip . '/login.html');
// ENABLE HTTP POST
curl_setopt ($ch, CURLOPT_POST, 1);
// SET POST PARAMETERS : FORM VALUES FOR EACH FIELD
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'password=' . $password . '&language=2');
// IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIES
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
# Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL
# not to print out the results of its query.
# Instead, it will return the results as a string return value
# from curl_exec() instead of the usual true/false.
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
// EXECUTE 1st REQUEST (FORM LOGIN)
$store = curl_exec ($ch);
// SET FILE TO DOWNLOAD
curl_setopt($ch, CURLOPT_URL, 'http://' . $ip . '/settings_messaging_messenger.html');
// EXECUTE 2nd REQUEST (FILE DOWNLOAD)
$content = curl_exec ($ch);
// POST reset-command to Gigaset
curl_setopt($ch, CURLOPT_URL, 'http://' . $ip . '/settings_messaging_messenger.html');
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'password=' . $password . '&language=2&do_reset=1');
curl_exec ($ch);
//LOGOUT FROM GIGASET
curl_setopt($ch, CURLOPT_URL, 'http://' . $ip . '/logout.html');
curl_exec ($ch);
// CLOSE CURL
curl_close ($ch);
}
?>