The following points may come in handy for study.
1) Connect to SQL server to execute queries:
mysql -u freepbxuser -p Enter . Enter, MySQL: mysql>_
2) Basic sql commands
: SHOW DATABASES; : USE dbtest; : SHOW tables; : SELECT * FROM page; : DESCRIBE testtable;
3) Connection to sql from an external network:
CREATE USER '--'@'localhost' IDENTIFIED BY '!!!!!!'; GRANT ALL PRIVILEGES ON * . * TO '--'@'localhost'; GRANT SELECT ON * . * TO '--'@'localhost'; use mysql SELECT Host,User,Password FROM user; UPDATE user SET Host='%' WHERE User='--' AND Host='localhost'; FLUSH PRIVILEGES;
4) XML file format:
<?xml version="1.0" encoding="UTF-8"?> <AddressBook> <pbgroup> <id>70</id> <name>User Manager Group</name> </pbgroup> <Contact> <id>760</id> <FirstName></FirstName> <LastName></LastName> <Frequent>0</Frequent> <Phone type="Work"> <phonenumber>101</phonenumber> <accountindex>1</accountindex> </Phone> <Group>70</Group> <Primary>0</Primary> </Contact> </AddressBook>
Step 1. Creating a php script to read the Asterisk sql table and generate an xml fileWe create two files config.php and phonebook.php, specifying the necessary parameters.
Config.php file
<?php return array( "db" => "mysql:host=localhost;dbname=asterisk", "pb_file_gs" => "/var/www/html/phonebook/phonebook.xml", "username" => "freepbxuser",
Phonebook.php file
<?php $config = include("db/config.php"); $db = new PDO($config["db"], $config["username"], $config["password"], $config["options"]);
Step 2. Set up your Grandstream phone to read the phone book from an xml fileAttention, it is important when setting up "Phonebook Management" on the Grandstream GXP16xx phone, in the "Phonebook XML Server Path" field, specify only the path without the file name.
- In the field "Enable Phonebook XML Download" select "Enabled, use HTTP"
- In the "Phonebook XML Server Path" field, specify the path to the xml file, for example: "192.168.0.220/phonebook"
The remaining parameters are indicated on demand.
Step 3. Create a web directory of the phone book
Create the pb.php file.
Highlights.
- First load from the xml file and form contact groups
- Process the selection of the group and display the contacts of the selected group.
Config.php file <html> <style> <!-- table.sort{ border-spacing:0em; margin-bottom:1em; margin-top:1em } table.sort td{ border:1px solid