VOIP PHP Webserver

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
isgur513
Forum Newbie
Posts: 3
Joined: Fri Mar 14, 2008 12:28 pm

VOIP PHP Webserver

Post by isgur513 »

Hi all,

I am a network engineer and at the moment I am implementing a large amount of Polycom VOIP phones using Asterisk PBX. Polycom's use HTTP to connect to a webserver and download the necessary config files needed to boot up and work. Each phone needs to have two files on the server, a <MACADDRESS>.cfg file and a <MACADDRESS>-registration.cfg file. I have developed an HTML form with the exact parameters I need; however, I cannot get a PHP script to do what I need it to do.

Upon clicking submit on my HTML form, I need the script to create these two separate files based on the MAC address entered in the form.

Here is my HTML form:
----------------------------
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Polycom Auto-Provisioning</title>
<meta name="Microsoft Theme" content="none, default">
<meta name="Microsoft Border" content="none, default">
<style type="text/css">
.style1 {
font-family: "Goudy Old Style";
}
.style2 {
font-family: "Goudy Old Style";
font-size: medium;
}
</style>
</head>

<body>

<H1 class="style1"><img alt="" src="polycom-logo.jpg" width="347" height="71"></H1>
<H1 class="style1">Polycom Auto-Provisioning&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </H1>
<HR>
<form name="PolycomRegistration" action="register.php" method="post">
<p class="style2">P<font size="4">lease fill out the following form as
accurately as possible to register your new Polycom VOIP phone.</font></p>
<p>&nbsp;</p>
<p><font face="Goudy Old Style"><br>
</font></p>
<dl>

<dd>
<table id="table1">
<tr>
<td>MAC Address</td>
<td><font face="Goudy Old Style">
<input type="text" size="35" maxlength="256" name="MAC" value="0004f2"></font></td>
</tr>
<tr>
<td class="style1">Acount</td>

<td><font face="Goudy Old Style">
<input type="text" size="35" maxlength="256" name="Account"></font></td>
</tr>
<tr>
<td class="style1">Password</td>
<td><font face="Goudy Old Style">
<input type="password" name="Password" size="35"></font></td>
</tr>
<tr>
<td class="style1">Caller ID</td>

<td><font face="Goudy Old Style">
<input type="text" name="CallID" size="35"></font></td>
</tr>
<tr>
<td class="style1">Idle Phone Display</td>
<td>
<font face="Goudy Old Style">
<input type="text" size="35" maxlength="256" name="Display"></font></td>
</tr>

<tr>
<td class="style1">Number of Lines</td>
<td><font face="Goudy Old Style">
<input type="text" size="35" maxlength="256" name="Lines"></font></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>

</table>
</dd>
<dd>
<table id="table2" style="width: 446px">
<tr>
<td class="style1" style="width: 132px">Phone Type</td>
<td width="255"><select size="1" name="item">
<option selected="">SoundPoint IP330</option>
<option>SoundPoint IP430</option>
<option>SoundPoint IP450</option>
<option>SoundPoint IP501</option>
<option>SoundPoint IP550</option>
<option>SoundPoint IP601</option>
<option>SoundPoint IP650</option>
<option>SoundPoint IP670</option>
<option>SoundStation IP4000</option>
<option>SoundStation IP6000</option>
<option>SoundStation IP7000</option>

</select></td>
</tr>
</table>
</dd>
</dl>
<p>&nbsp;</p>

<p><font face="Goudy Old Style"><input type="submit" value="Register Phone"></font><font color="#000000" face="Goudy Old Style">
</font><font face="Goudy Old Style"><input type="reset" value="Reset Form"></font></p>
<p>&nbsp;</p>
</form>
</body>

</html>

-------------------------------------------------------------------------------

Here is my PHP:

--------------------------------------------
<html><body>
<?php
$MAC = $_POST['MAC'];
$Account = $_POST['Account'];
$CallID = $_POST['CallID'];
$Display = $_POST['Display'];
$Lines = $_POST['Lines'];
$item = $_POST['item'];
$Password = $_Password['Password'];

//$ourFileName = $_POST['MAC'].+".cfg";
$ourFileName = "$MAC.cfg";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
fclose($ourFileHandle);

$fh = fopen($file, 'r+');
fwrite($fh, $new_contents);
fclose($fh);
?>

echo "You have successfully registered your Polycom phone under the MAC address: ". $MAC . ".<br />";
echo "Your account is: ". $Account . ".<br />";
echo "Your Caller ID will be displayed as: ". $CallID .".<br />";
echo "The Display on your phone will show up as: ". $Display . ".<br />";
echo "Number of lines: ". $Lines . ".<br />";
echo "Phone Model: ". $item . ".<br />";
echo "Password: ". $Password . ".<br />";
echo "<br />";
echo "Thank you for registering your phone with Us.";

?>
</body></html>

----------------------------------------------------------------------

Any help is greatly appreciated!
-Matt
Post Reply