Created
August 20, 2020 22:38
-
-
Save ravnx/fa8ac4e629612391cc1c5f4a1209a595 to your computer and use it in GitHub Desktop.
Yealink Phonebook XML, quick and dirty.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| print("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); | |
| print("<MyIPPhoneDirectory clearlight=\"true\">\n"); | |
| print("<Prompt>Prompt</Prompt>\n"); | |
| set_time_limit(5); # Set max execution time | |
| $output = shell_exec("/usr/sbin/asterisk -rx \"database show AMPUSER\" | grep cidname"); # grab cidname and number cleanly | |
| $outAry = explode("\n",$output); # explode to array | |
| foreach ($outAry as $line) { # loop array | |
| # /AMPUSER/1000/cidname : TX03 Receptionist | |
| preg_match('/USER\/(\d+)\/cidname\s+:\s([\w\s-]+)/',$line,$matches); # match on extension and name | |
| if (!$matches[1]) { continue; } # if we have a blank match, skip it. | |
| if (strlen($matches[1]) < 4 ) { continue; } # if we have a 3 digit extension, skip it, its an analog line | |
| #echo 'Ext: '.$matches[1].' : '.$matches[2]."\n"; | |
| echo "<DirectoryEntry>\n". # Print out the xml. | |
| " <Name>".trim($matches[2])."</Name>\n". | |
| " <Telephone>".$matches[1]."</Telephone>\n". | |
| "</DirectoryEntry>\n"; | |
| } | |
| print("</MyIPPhoneDirectory>"); | |
| /* in y0000000000 file add: | |
| remote_phonebook.data.1.url = http://10.10.100.10/yealink-phonebook.php | |
| remote_phonebook.data.1.name = Default Directory | |
| # ** The above may change depending on your firmware version of yealink. | |
| # Put this file in your /var/www/html/ directory | |
| */ | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment