Hi Forum,
I'm trying to create a php page to reboot-phones remotely using a multiselect java dropdown...
Here is my index.php:
---
<html>
<body>
<script type="text/javascript">
function setOptions(chosen){
var selbox = document.formName.ip;
selbox.options.length = 0;
if (chosen == " ") {
selbox.options[selbox.options.length] = new Option('No site selected',' ');
}
if (chosen == "1") {
selbox.options[selbox.options.length] = new Option('second choice - option one','twoone');
selbox.options[selbox.options.length] = new Option('second choice - option two','twotwo');
selbox.options[selbox.options.length] = new Option('second choice - option three','twothree');
selbox.options[selbox.options.length] = new Option('second choice - option four','twofour');
}
if (chosen == "2") {
selbox.options[selbox.options.length] = new Option('second choice - option one','twoone');
selbox.options[selbox.options.length] = new Option('second choice - option two','twotwo');
selbox.options[selbox.options.length] = new Option('second choice - option three','twothree');
selbox.options[selbox.options.length] = new Option('second choice - option four','twofour');
}
}
</script>
<form name="formName" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<select name="site" size="1" onchange="setOptions(document.formName.site.option s[document.formName.site.selectedIndex].value);">
<option value=" " selected="selected"></option>
<option value="1">Site1</option>
<option value="2">Site2</option>
</select>
<select name="ip" size="1" method="post" action="polycom-reboot.php">
<option value=" " selected="selected">No phone selected</option>
</select>
<input type="submit" value="Reboot..."/>
</form>
</body>
</html>
---
Here is my polycom-reboot.php:
---
<html>
<body>
<form method="POST" action="index.php">
<input type="submit" value="Return" />
</form>
<?php
$postip = $_POST["ip"];
echo "$postip: ";
require_once('php-sip/PhpSIP.class.php');
/* Sends NOTIFY to reset Polycom phone */
try
{
$api = new PhpSIP();
$api->setUsername('USR'); // authentication username
$api->setPassword('PWD'); // authentication password
// $api->setProxy('GW');
$api->addHeader('Event: check-sync');
$api->setMethod('NOTIFY');
$api->setFrom('sip:6000@DEST');
$api->setUri("sip:4000@$postip");
$res = $api->send();
echo "response: $res\n";
} catch (Exception $e) {
echo $e;
}
?>
---
1. Do any of you know what to do to get it working... or just how to get some errormessages to point me in the right direction...
If you have another example howto this it is highly appreciated.
2. Futhermore I would like the ability to also reboot phones from cron/linux shell using reboot-polycom.php with argument "ip". Or even better: site="site1"+ip="all" or site="site1"+ip="multiselected" wich will then reboot the "ip"s for this specific site... this functionality would be great also on webpage... :-)
Thanks in advance :-) !
Br
~Maymann