gpuser
Member
- Joined
- Aug 19, 2013
- Messages
- 37
- Reaction score
- 12
If you are interested to get fop2 phonebook on your IP phone please read on.......
I have this working on Cisco and Yealink phones, other phones might need a little bit tweaking.
First thing is to have a working fop2 installation and entries in fop2 phonebook.
Use filezilla to access your PIAF machine using SFTP protocol and browse to /var/www/html/fop2
Download vphonebook.php to your local system.
Rename localcopy to vphonebook-mod.php and open in text editor - gedit/notepad++ etc.
Modify this line:
To:
Just below after:
Add:
And modify the function query_phonebook to:
Please note that SQL query is modified by adding "ORDER BY firstname" to list entries in alphabetical order.
Now using Filezilla copy vphonebook-mod.php to /var/www/html/fop2
Open a browser and go to http://your_piaf_ip/fop2/vphonebook-mod.php and you should see all your phone entries listed in order.
Final step is to modify your phone provisioning file to point remote phonebook url to
http://your_piaf_ip/fop2/vphonebook-mod.php
This is by no means a great work, just a hack of existing code to suit. All credits go to original fop2 programmers.
Cheers!
I have this working on Cisco and Yealink phones, other phones might need a little bit tweaking.
First thing is to have a working fop2 installation and entries in fop2 phonebook.
Use filezilla to access your PIAF machine using SFTP protocol and browse to /var/www/html/fop2
Download vphonebook.php to your local system.
Rename localcopy to vphonebook-mod.php and open in text editor - gedit/notepad++ etc.
Modify this line:
PHP:
echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?><Suggestions>";
To:
PHP:
echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?><CiscoIPPhoneDirectory>";
echo "<Title>Phone Directory</Title>";
echo "<Prompt>Please Select</Prompt>";
Just below after:
PHP:
if(preg_match("/\.tel$/",$texto)) {
// query_tel($texto);
} else {
query_phonebook($texto);
}
Add:
PHP:
echo "</CiscoIPPhoneDirectory>";
And modify the function query_phonebook to:
PHP:
function query_phonebook($texto) {
global $db;
global $context;
global $extension;
$db->consulta("SET NAMES 'UTF8'");
$res=$db->consulta("SELECT phone1,phone2,CONCAT(firstname,' ',lastname,' (',company,')') AS name FROM visual_phonebook WHERE CONCAT(firstname,' ',lastname,' ',company) LIKE '%%%s%%' AND context='%s' AND (owner='%s' OR (owner<>'%s' AND private='no')) ORDER BY firstname",$texto,$context,$extension,$extension);
$contador=0;
if($db->num_rows()>0) {
while($row=$db->fetch_assoc()) {
$htmlname = htmlspecialchars($row['name']);
$htmlname = preg_replace("/\(\)/","",$htmlname);
$phone1 = preg_replace("/[^0-9]/","", $row['phone1']);
//$phone2 = preg_replace("/[^0-9]/","", $row['phone2']);
//$htmlphone2 = htmlentities($phone2);
if($row['phone1']<>"") {
echo "<DirectoryEntry>";
echo "<Name>".$htmlname."</Name>";
echo "<Telephone>".$phone1."</Telephone>";
echo "</DirectoryEntry>";
$contador++;
}
//if($row['phone2']<>"") {
// echo "<suggestion id='".$phone2."' info='".$phone2."'>".$htmlname.": $phone2</suggestion>";
// $contador++;
//}
}
}
}
Please note that SQL query is modified by adding "ORDER BY firstname" to list entries in alphabetical order.
Now using Filezilla copy vphonebook-mod.php to /var/www/html/fop2
Open a browser and go to http://your_piaf_ip/fop2/vphonebook-mod.php and you should see all your phone entries listed in order.
Final step is to modify your phone provisioning file to point remote phonebook url to
http://your_piaf_ip/fop2/vphonebook-mod.php
This is by no means a great work, just a hack of existing code to suit. All credits go to original fop2 programmers.
Cheers!