Avaya Support Forums  

Go Back   Avaya Support Forums > Telephones, Adjuncts, and Adapters

Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 03-01-2012, 11:33 AM
rfisher1008 rfisher1008 is offline
Join Date: Feb 2012
Posts: 3
rfisher1008 has 10 reputation points
Default 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.

/* 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;
// 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])
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.
Reply With Quote

96xx, php, subscribe, subscription

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -7. The time now is 09:32 AM.

This Forum is provided solely for the use and convenience of Avaya customers and partners. Use of the Forum is subject to the Terms and Use and Privacy Statement found at www.avaya.com. No other use is permitted. The Forum including all content posted is “AS IS” and Avaya expressly disclaims all warranties and/or guarantees as to its accuracy, reliability, usefulness, quality or non-infringement of intellectual property. Avaya reserves the right to remove any content posted on the Forum at any time and for whatever reason.

Avaya will not be liable for any content posted on this Forum, including, without limitation, any errors or omissions or for any losses or damages of any kind incurred as a result of use or reliance on any content, regardless of its origin.

You expressly understand and agree that you assume all risks associated with use or reliance on this content.