Avaya Support Forums

Avaya Support Forums (http://support.avaya.com/forums/index.php)
-   Telephones, Adjuncts, and Adapters (http://support.avaya.com/forums/forumdisplay.php?f=27)
-   -   subscribe.php issues (http://support.avaya.com/forums/showthread.php?t=1502)

rfisher1008 03-01-2012 11:33 AM

subscribe.php issues
 
I am having an issue when phones are rebooted the subscribe.php runs and over writes the existing line on the phone_db.txt file. The subscribe file is as follows.

<?php
/* This file captures the extension, IP, MAC and SetID during the Boot-up process.
These values are obtained as part of the Subscription feature of the Avaya IP Phones*/
$EXT = $_GET["Extn"]; //capture the extension
$IP = $_GET["ip"]; //capture the ip-address
$MAC = $_GET["MAC"]; //capture the MAC Address
$SET_ID = $_GET["SetID"]; //capture the Set ID
$CWD = getcwd(); // returns the current working directory
/* For simplicity the database is a simple text file (Phone_db.txt), in a real world application
any database such as MySQL, SQL Server, Oracle, etc. would be used */
// Phone_db.txt is a file of CSV lines: ext,ip
$handle = fopen("$CWD\\Phone_db.txt", "r");
// read the contents of file
if ($handle) {
while (!feof($handle)) {
// $line is an array of where each element is one of the CSV fields of the file
// Note that the newline chars have been stripped
$line = explode("\n", rtrim(fgets($handle)));
// $lines[] is an array of arrays, i.e., each element is one of the line arrays
$lines[] = $line;
}
}
fclose($handle);
// create the new file with old references to EXT or IP removed and the new one added
$handle = fopen("$CWD\\Phone_db.txt", "w");
foreach($lines as $line) {
// note: $line[0] = ext, $line[1] = ip etc.
// skip any line that has either the same IP or the same EXT
// as these are being replaced with the new values
if($EXT == $line[0] || $IP == $line[1] || $MAC == $line[2] || $SET_ID == $line[3])
continue;
fwrite($handle, $line[0] . "," . $line[1] . "," . $line[2] . "," . $line[3] . "\r\n");
}
// now write the new record
fwrite($handle, $EXT . "," . $IP . "," . $MAC . "," . $SET_ID);
fclose($handle); //close the file
?>

Thank you in advance for your help.

aviswanathan 04-03-2012 03:46 AM

Which phones are you using and where is this file located ?

rfisher1008 04-09-2012 05:54 AM

We have 9611's and the file is located on the web server itself.
Thank you.

aviswanathan 04-09-2012 07:17 AM

Seems this would need modification of existing script. Recommend opening a Service Request with Avaya Support. Please go to support.avaya.com and open a new Service Request.

rfisher1008 04-09-2012 07:26 AM

Thank you for your help. I will try that.


All times are GMT -7. The time now is 07:57 PM.