(04-18-2017 03:41 AM)Kevin_Yealink Wrote: I know totally what you need. I have 1 question, would you mind kindly guiding me who to create cfg/config file on the server side.
....So I don't think it is convenience.
Hi Kevin,
You're still thinking static config files my friend... Oliv and I are talking about dynamically generated ones. So in our case, the server will generate the configs on demand, based on the request.
For example:
1) Configure webserver so that all requests to a given path are forwarded to a dynamic generator (in this case PHP script). In Apache you can do something like this in an htaccess file:
Code:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ master.php?file=$1 [L,QSA]
This takes all incoming requests and says if the requested file doesn't exist, make the request to master.php, and pass the filename as the "file=" argument.
2) Now write master.php to generate the appropriate configuration based on the requested file. Usually this involves pulling information from a database, or some pre-set cache. Once the data is loaded, appropriate config information is written out. A simple example:
Code:
<?php
//Get the name of the requested file
$targetFN = $_REQUEST["file"];
if ($targetFN == "y000000000046.cfg") {
//Generate or import generic config for T29G
} else if (preg_match("/^([0-9A-Fa-f]{2}){6}\.cfg$/", $targetFN)) {
//Regular expressoin matches any MAC.cfg file requests.
//connect to database and load information for this device...
//Fake this in our example
if ($targetFN == "001565297016.cfg") {
$myExt = "420";
} else {
//..other definitions based on other MACs
}
//Now generate config as it will be seen by phone
echo '#!version:1.0.0.1
##File header "#!version:1.0.0.1" can not be edited or deleted, and must be placed in the first line.##
';
//Output basic config for first 3 line keys
echo "linekey.1.line = 1
linekey.1.type = 15
linekey.1.label = $myExt
linekey.2.line = 1
linekey.2.type = 15
linekey.2.label = $myExt
linekey.3.line = 1
linekey.3.type = 15
linekey.3.label = $myExt
";
//Now, let's output BLF depending on what is in user agent.
$ua = $_SERVER['HTTP_USER_AGENT'];
//If the user agent contained expander information, we could search for that and adjust our BLF output based on it.
if (strpos($ua, "Exp") !== false) {
//Expander is included in UA, so must be present. Put exp button config out
echo "expansion_module.1.key.1.type = 16
expansion_module.1.key.1.line = 1
expansion_module.1.key.1.value = 254
expansion_module.1.key.1.label = Jim Bob
";
} else {
//No Expander present, so put this as a BLF on normal phone key instead
echo "linekey.8.line = 1
linekey.8.type = 16
linekey.8.value = 254
linekey.8.label = Jim Bob
";
}
}
?>
3) Setup phones to request provisioning from the above server.
If Yealink updated firmware to add expander information to user agent in some way (i.e. add "Exp1:EXP20" if a EXP20 was connected), then the script from would adjust it's output. Phone without EXP would get:
Code:
#!version:1.0.0.1
##File header "#!version:1.0.0.1" can not be edited or deleted, and must be placed in the first line.##
linekey.1.line = 1
linekey.1.type = 15
linekey.1.label = 420
linekey.2.line = 1
linekey.2.type = 15
linekey.2.label = 420
linekey.3.line = 1
linekey.3.type = 15
linekey.3.label = 420
linekey.8.line = 1
linekey.8.type = 16
linekey.8.value = 254
linekey.8.label = Jim Bob
While alternatively, phone with EXP would automatically get:
Code:
#!version:1.0.0.1
##File header "#!version:1.0.0.1" can not be edited or deleted, and must be placed in the first line.##
linekey.1.line = 1
linekey.1.type = 15
linekey.1.label = 420
linekey.2.line = 1
linekey.2.type = 15
linekey.2.label = 420
linekey.3.line = 1
linekey.3.type = 15
linekey.3.label = 420
expansion_module.1.key.1.type = 16
expansion_module.1.key.1.line = 1
expansion_module.1.key.1.value = 254
expansion_module.1.key.1.label = Jim Bob
That of course is an overly simplified piece of coding but it works for demonstration.
These type of cfg generators are usually included as part of PBX software, implemented through "Auto Provisioning" or "Provision generator templates". Other times people like me write our own to fit custom needs or requirements for our customers and different types of installations.