Hi Guys, Sorry if this has already been discussed in details but i cant seem to search the forum topics.
I did some previous google searches and find a few topics that help describe what i want to do, but i cant seem to get the solution working so im hoping someone here can highlight what i am doing wrong.
i'm simply trying to get the phone directory button on Cisco 7941 Phones working,
I have been looking at these two sets of instructions to help me complete;
CANT POST LINKS [LINK REMOVED]
CANT POST LINKS [LINK REMOVED]
My environment is two freepbx servers;
Server 1;
PBX Firmware: 1.810.210.57-1
PBX Service Pack: 1.0.0.0
Server 2
PBX Firmware: 1.813.210.58-1
PBX Service Pack: 1.0.0.0
So i require the directory button to probe both servers extension list, according to the first resource i need to do this via php script, now i have literally 0 skills with scripting or coding at any level so i already feel out of my comfort zone. but through a process of copy and paste and replacing the blanks i think i managed to get the script working
now on each server when i visit /localhost/search.php i see an output of all the users and extension numbers like;
Joe Bloggs- 4119
4119
Joey Bloggs- 4118
4118
Jospeh Bloggs- 5031
5031
Jerry Bloggs- 4103
4103
so im assuming the script is doing as it should,
now i have to add that configuration to my phones; according too CANT POST LINKS [LINK REMOVED] i do this in SIPDefault.cnf
looking at my SIPDefault.cnf the only line i see that relates to directory is;
directory_url: "CANT POST LINKS [LINK REMOVED]/menu2.xml"
this xml file looks like the following;
Phone Directory
Enter The Search Criteria
CANT POST LINKS [LINK REMOVED]/ciscodir/search.php
Enter Name
sn
U
so this includes the search.php originally created which looks like the following;
<?php
header ("content-type: text/xml");
// Created by Intuit
// with credit to JOYCE CR, s.r.o.CANT POST LINKS [LINK REMOVED]
// Make sure you configure the allowable settings only
// This script directly integrates with FreePBX and picksup the asterisk.users table
// Should work for both device-user mode or extensions mode
// Works by searching from anywhere of the person's name
// feedback to CANT POST LINKS [LINK REMOVED]
// Change here to match the webaddress absolute path
$URL = 'server1ip/ciscodir/';
// Choose how many results to return if search term produces a lot of output
$per_page = '100';
// Change here to match your own passwords
$mysql_conn = mysql_connect('server2ip','freepbxuser','password');
$mysql_conn2 = mysql_connect('server1ip','freepbxuser','password', true);
// Dont change anything from here unless you know what you are doing
mysql_select_db('asterisk', $mysql_conn );
mysql_select_db('asterisk', $mysql_conn2 );
$NAME=$_GET["sn"];
$FROM=$_GET["FROM"];
$TO=$_GET["TO"];
if ( ($FROM=='') and ($TO=='') )
{
//check to see how many
$result= mysql_query("SELECT count(phones.Remark) as total
FROM phones
WHERE phones.Remark LIKE '%$NAME%' ", $mysql_conn);
$howmany = mysql_fetch_row($result);
$result2= mysql_query("SELECT count(users.name) as total
FROM users
WHERE users.name LIKE '%$NAME%' ", $mysql_conn2);
$howmany2 = mysql_fetch_row($result2);
if (($howmany[0] > $per_page) || ($howmany2[0] > $per_page))
{
print("\n");
print("\n");
$start = 0;
$index = 0;
$total = $howmany[0];
$remain = $per_page;
while ($start < ($total + 1))
{
$limitstart = 'LIMIT '.$start.','.$per_page;
$result = mysql_query("SELECT Remark,username
FROM phones
WHERE Remark LIKE '%$NAME%' ORDER BY Remark $limitstart", $mysql_conn);
$row = mysql_fetch_row($result);
$from = $row[0];
if (($total - $start) < $per_page) { $remain = $total - $start; }
for ($i = 1; $i < $remain; ++$i) { $row = mysql_fetch_row($result); }
$to = $row[0];
print("<SoftKeyItem>\n");
print("\t<Name>");
print($index);
print("</Name>\n");
print("\t<URL>");
print($URL."search.php?FROM=".$from."&TO=".$to);
print("</URL>\n");
print("</SoftKeyItem>\n");
$start = $start + $per_page;
$index = $index+1;
}
$start2 = 0;
$index2 = 0;
$total2 = $howmany2[0];
$remain2 = $per_page;
while ($start2 < ($total2 + 1))
{
$limitstart2 = 'LIMIT '.$start2.','.$per_page2;
$result2 = mysql_query("SELECT name,extension
FROM users
WHERE name LIKE '%$NAME%' ORDER BY name $limitstart2", $mysql_conn2);
$row2 = mysql_fetch_row($result2);
$from2 = $row2[0];
if (($total2 - $start2) < $per_page) { $remain2 = $total2 - $start2; }
for ($i2 = 1; $i2 < $remain2; ++$i2) { $row2 = mysql_fetch_row($result2); }
$to2 = $row2[0];
print("<SoftKeyItem>\n");
print("\t<Name>");
print($index2);
print("</Name>\n");
print("\t<URL>");
print($URL."search.php?FROM=".$from2."&TO=".$to2);
print("</URL>\n");
print("</SoftKeyItem>\n");
$start2 = $start2 + $per_page2;
$index2 = $index2+1;
}
print("</CiscoIPPhoneDirectory>\n");
} else {
print("\n");
print("\n");
$result = mysql_query("SELECT Remark,username,username
FROM phones
WHERE phones.Remark LIKE '%$NAME%'
ORDER BY Remark ", $mysql_conn);
while($row = mysql_fetch_row($result))
{
print("<DirectoryEntry>\n");
print("\t<Name>");
print($row[0]."- ".$row[1] );
print("</Name>\n");
print("\t<Telephone>");
print($row[2]);
print("</Telephone>\n");
print("</DirectoryEntry>\n");
}
$result2 = mysql_query("SELECT name,extension,extension
FROM users
WHERE users.name LIKE '%$NAME%'
ORDER BY name ", $mysql_conn2);
while($row2 = mysql_fetch_row($result2))
{
print("<DirectoryEntry>\n");
print("\t<Name>");
print($row2[0]."- ".$row2[1] );
print("</Name>\n");
print("\t<Telephone>");
print($row2[2]);
print("</Telephone>\n");
print("</DirectoryEntry>\n");
}
print("</CiscoIPPhoneDirectory>\n");
}
} else {
print("\n");
print("\n");
print("Intuittech Directory\n");
print("Intuittech Directory\n");
$result = mysql_query("SELECT Remark,username,username
FROM phones
WHERE Remark>='$FROM' AND Remark<='$TO'
ORDER BY Remark", $mysql_conn);
while($row = mysql_fetch_row($result))
{
print("\n");
print("\t");
print($row[0]."- ".$row[1] );
print("\n");
print("\t");
print($row[2]);
print("\n");
print("\n");
}
$result2 = mysql_query("SELECT name,extension,extension
FROM users
WHERE name>='$FROM' AND name<='$TO'
ORDER BY name", $mysql_conn2);
while($row2 = mysql_fetch_row($result2))
{
print("\n");
print("\t");
print($row2[0]."- ".$row2[1] );
print("\n");
print("\t");
print($row2[2]);
print("\n");
print("\n");
}
print("\n");
}
?>
I then do a factory reset of a cisco 7941, hoping when it comes back up, pulls its config from the tftp server the directory button works, but i don't get anything the directory buttons takes you to the directory menu but i only have options for missed/received and placed.
im obviously doing something wrong but with all the documentation im reading i cant figure out for the life of me what.
hopefully some braniac here will be able to help.
Sorry for the long post i just wanted to make it as detailed as possible.
Regards
Cap