{"id":214235,"date":"2014-02-28T16:42:02","date_gmt":"2014-02-28T12:42:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=214235"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=214235","title":{"rendered":"<span class=\"post_title\">\u0410\u0432\u0442\u043e\u043f\u0440\u043e\u0432\u0438\u0436\u0438\u043d\u0438\u043d\u0433 Cisco SPA504g \u0438 Asterisk. \u0427\u0430\u0441\u0442\u044c 2. \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 DHCP-\u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438 Apache<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u0412 <a href=\"http:\/\/habrahabr.ru\/post\/214181\/\">\u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/a> \u043c\u044b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438 MySQL \u0438 \u0441\u043e\u0431\u0440\u0430\u043b\u0438 \u0410\u0441\u0442\u0435\u0440\u0438\u0441\u043a \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432 \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 res_config_mysql (Asterisk Realtime Architecture)<\/p>\n<h4>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 DHCP-\u0441\u0435\u0440\u0432\u0435\u0440\u0430<\/h4>\n<p>  \u0423 \u043c\u0435\u043d\u044f \u0432 \u0434\u0432\u0443\u0445 \u0440\u0430\u0431\u043e\u0447\u0438\u0445 \u0441\u0440\u0435\u0434\u0430\u0445 \u0440\u0430\u0437\u0432\u0451\u0440\u043d\u0443\u0442\u044b \u0440\u0430\u0437\u043d\u044b\u0435 DHCP-\u0441\u0435\u0440\u0432\u0435\u0440\u044b, \u043f\u043e\u043a\u0430\u0436\u0443 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0434\u043b\u044f \u0442\u0440\u0451\u0445 \u0441\u0430\u043c\u044b\u0445 (\u0438\u043c\u0445\u043e) \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445: Windows Server DHCP, Mikrotik, DNSMasq<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h5>Windows Server 2012R2 DHCP Server<\/h5>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/4ca\/e62\/f75\/4cae62f75502d6cae1f82e83bd8904e2.png\" alt=\"image\"\/><\/p>\n<p>  \u0412 DHCP-\u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u043e\u0432\u0443\u044e \u043e\u043f\u0446\u0438\u044e \u043a \u043d\u0430\u0448\u0435\u043c\u0443 DHCP-\u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0443, \u0441 \u043d\u043e\u043c\u0435\u0440\u043e\u043c 66 (Boot Server Host Name) \u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c<br \/>  <code>http:\/\/&lt;server ip&gt;\/cisco.php?mac=$MA&sn=$SN<\/code><\/p>\n<h5>Mikrotik RouterOS v6.x<\/h5>\n<p>  <code>\/ip dhcp-server option add code=66 name=tftp value=&quot;'http:\/\/&lt;server ip&gt;\/cisco.php\\?mac=\\$MA&sn=\\$SN'&quot; \/ip dhcp-server network set dhcp-option=tftp 0 <\/code><\/p>\n<h5>DNSMasq<\/h5>\n<p>  \u0432 dnsmasq.conf<br \/>  <code>dhcp-option=66,&quot;http:\/\/&lt;server ip&gt;\/cisco.php\\?mac=$MA&sn=$SN&quot;<\/code><\/p>\n<h4>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 Apache + PHP<\/h4>\n<p>  \u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0438 thttpd, \u0438 lighttpd, \u0438 \u0434\u0430\u0436\u0435 nginx&#8217;\u043e\u043c, \u043d\u043e \u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u043b\u044e\u0431\u043b\u044e \u0441\u0442\u0430\u0440\u043e\u0433\u043e \u0434\u043e\u0431\u0440\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u0439\u0446\u0430.<\/p>\n<pre><code class=\"bash\">[root@asterisk ~]# yum install httpd php php-mysql -y [root@asterisk ~]# chkconfig httpd on [root@asterisk ~]# vi \/etc\/php.ini <\/code><\/pre>\n<p>  \u0438 \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 <code>Date<\/code> \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c <code>date.timezone = Europe\/Moscow<\/code> (\u0438\u043b\u0438 \u0441\u0432\u043e\u044e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0437\u043e\u043d\u0443, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0432 \u041c\u043e\u0441\u043a\u043e\u0432\u0441\u043a\u043e\u043c \u0447\u0430\u0441\u043e\u0432\u043e\u043c \u043f\u043e\u044f\u0441\u0435), \u0438\u043d\u0430\u0447\u0435 \u0431\u0443\u0434\u0435\u0442 \u043a\u0443\u0447\u0430 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0439.  <\/p>\n<pre><code class=\"bash\">Esc -&gt; :wq -&gt; Enter [root@asterisk ~]# echo &quot;&lt;?php phpinfo(); ?&gt;&quot;&gt;\/var\/www\/html\/index.php <\/code><\/pre>\n<p>  \u0418 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u043e\u043c \u0430\u0434\u0440\u0435\u0441 <code>http:\/\/&lt;ip \u0441\u0435\u0440\u0432\u0435\u0440\u0430&gt;\/<\/code> \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0410\u043f\u0430\u0447\u0430 \u0438 PHP.<\/p>\n<h4>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0441\u043a\u0440\u0438\u043f\u0442 \u0430\u0432\u0442\u043e\u0432\u044b\u0434\u0430\u0447\u0438 XML \u0434\u043b\u044f SPA504G<\/h4>\n<p>  \u0421\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u0432 \/var\/www\/html \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0438 7.5.2b \u0438 7.5.5 \u0434\u043b\u044f SPA504G, \u0430 \u0442\u0430\u043a\u0436\u0435 \u044f\u0437\u044b\u043a\u043e\u0432\u044b\u0435 XML&#8217;\u043a\u0438 \u0434\u043b\u044f \u0440\u0443\u0441\u0441\u043a\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430:   <\/p>\n<pre><code class=\"bash\">[root@asterisk ~]# cd \/var\/www\/html\/ [root@asterisk html]# wget http:\/\/zztopper.ru\/cisco.tar.gz [root@asterisk html]# tar fzx cisco.tar.gz [root@asterisk html]# rm cisco.tar.gz <\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0451\u043c cisco.php  <\/p>\n<pre><code class=\"bash\">[root@asterisk html]#  nano cisco.php <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"php\">&lt;?php  \/\/---------------------------------\u0422\u0443\u0442 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435  \/\/-------\u0414\u0430\u043d\u043d\u044b\u0435 MySQL $mysrv = 'localhost'; $mydb = 'asterisk'; $myuser = 'asterisk'; $mypass = 'mypass'; $table = 'tbl_sip_conf';  $server = 'SERVERIP'; \/\/IP \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0441 \u0430\u043f\u0430\u0447\u0435\u043c \u0438 \u0430\u0441\u0442\u0435\u0440\u0438\u0441\u043a\u043e\u043c $dns = 'DNSIP';  \/\/ IP DNS-\u0441\u0435\u0440\u0432\u0435\u0440\u0430 $enable_vlan = 'No'; \/\/ \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c VLAN'\u044b $voice_vlan = 1; \/\/ VLAN \u0434\u043b\u044f \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0438\u0438  $pc_vlan = 1; \/\/ Access VLAN \u0434\u043b\u044f \u0441\u043a\u0432\u043e\u0437\u043d\u043e\u0433\u043e PC-\u043f\u043e\u0440\u0442\u0430 $adminpass = '7654321'; \/\/\u041f\u0430\u0440\u043e\u043b\u044c \u0434\u043b\u044f Web-\u043c\u043e\u0440\u0434\u044b \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430 $textlogo = 'LOGO'; \/\/\u0422\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0435 \u043b\u043e\u0433\u043e  $tz = 'GMT+04:00'; \/\/\u0427\u0430\u0441\u043e\u0432\u043e\u0439 \u043f\u043e\u044f\u0441 $dialplan = '(1xxS0|911S0|1xxxS0|2xxxxxxS0|8xxxxxxxxxx|7xxxxxxxxxx)'; \/\/\u0421\u0442\u0440\u043e\u043a\u0430 \u0434\u0438\u0430\u043b\u043f\u043b\u0430\u043d\u0430 $label = 'Yellow Pages'; \/\/\u041f\u043e\u0434\u043f\u0438\u0441\u044c \u0434\u043b\u044f \u043a\u043d\u043e\u043f\u043a\u0438 Line 4 \u0434\u043b\u044f \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u0439 \u043a\u043d\u0438\u0433\u0438 $use4line = 1; \/\/ \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u0438 \u043a\u043d\u043e\u043f\u043a\u0443 Line 4 \u0434\u043b\u044f \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u0439 \u043a\u043d\u0438\u0433\u0438 \/\/---------------------------------\u0414\u0430\u043b\u044c\u0448\u0435 \u0441\u0430\u043c \u0441\u043a\u0440\u0438\u043f\u0442, \u043d\u0435 \u0442\u0440\u043e\u0433\u0430\u0435\u043c \u0431\u0435\u0437 \u043d\u0443\u0436\u0434\u044b  function randomPassword() {     $alphabet = &quot;abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789&quot;;     $pass = array(); \/\/remember to declare $pass as an array     $alphaLength = strlen($alphabet) - 1; \/\/put the length -1 in cache     for ($i = 0; $i &lt; 10; $i++) {         $n = rand(0, $alphaLength);         $pass[] = $alphabet[$n];     }     return implode($pass); \/\/turn the array into a string }   $mac = isset($_GET['mac'])?$_GET['mac']:&quot;000000000000&quot;;  $sn = isset($_GET['sn'])?$_GET['sn']:&quot;0000000&quot;;  $link = new mysqli($mysrv,$myuser,$mypass,$mydb); if ($link-&gt;connect_error) {     die('Connect Error (' . $link-&gt;connect_errno . ') '             . $link-&gt;connect_error); }  $query = 'set names utf8;';  $link-&gt;query($query);  $query = 'SELECT * FROM `'.$table.'` WHERE `macaddress`=&quot;'.$mac.'&quot;';  $result = $link-&gt;query($query);  if (!$result).     die(&quot;\u041e\u0448\u0438\u0431\u043a\u0430: &quot;.$link-&gt;error);  if ($result-&gt;num_rows == 1).  {     while ($myrow = $result-&gt;fetch_array(MYSQLI_ASSOC))     {       $phone=$myrow[&quot;name&quot;];       $pass=$myrow[&quot;secret&quot;];       $name=$myrow[&quot;defaultuser&quot;];     }.     $result-&gt;close();.  }else  {  $query=&quot;SELECT MAX(name) FROM `&quot;.$table.&quot;`&quot;;  $result = $link-&gt;query($query);  while ($myrow = $result-&gt;fetch_array(MYSQLI_NUM))  {     $phone=$myrow[0];  }     $phone++;  $result-&gt;close();                                                                                                $pass=randomPassword();     $name=&quot;Unidentified Phone #&quot;.$phone;  $query=&quot;INSERT INTO `&quot;.$table.&quot;` (`defaultuser`,`macaddress`,`secret`,`name`, `serial`) VALUES ('&quot;.$name.&quot;', '&quot;.$mac.&quot;', '&quot;.$pass.&quot;', '&quot;.$phone.&quot;', '&quot;.$sn.&quot;');&quot;;  $result=$link-&gt;query($query);  }  $host=&quot;SPA&quot;.strtoupper($mac); ?&gt; &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&gt; &lt;flat-profile xmlns=&quot;http:\/\/www.sipura.net\/xsd\/SPA50x-30x-SIP&quot; xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http:\/\/www.sipura.net\/xsd\/SPA5 &lt;Enable_VLAN ua=&quot;rw&quot;&gt;&lt;?php echo $use_vlan ?&gt;&lt;\/Enable_VLAN&gt; &lt;VLAN_ID ua=&quot;rw&quot;&gt;&lt;?php echo $voice_vlan?&gt;&lt;\/VLAN_ID&gt; &lt;Enable_PC_Port_VLAN_Tagging ua=&quot;na&quot;&gt;No&lt;\/Enable_PC_Port_VLAN_Tagging&gt; &lt;Enable_CDP ua=&quot;na&quot;&gt;Yes&lt;\/Enable_CDP&gt; &lt;Enable_LLDP-MED ua=&quot;na&quot;&gt;Yes&lt;\/Enable_LLDP-MED&gt; &lt;PC_Port_VLAN_ID ua=&quot;na&quot;&gt;&lt;?php echo $pc_vlan ?&gt;&lt;\/PC_Port_VLAN_ID&gt; &lt;Resync_On_Reset&gt;Yes&lt;\/Resync_On_Reset&gt; &lt;Resync_Periodic&gt;60&lt;\/Resync_Periodic&gt; &lt;Admin_Passwd ua=&quot;na&quot;&gt;&lt;?php echo $adminpass ?&gt;&lt;\/Admin_Passwd&gt; &lt;SPCP_Auto-detect ua=&quot;na&quot;&gt;No&lt;\/SPCP_Auto-detect&gt; &lt;Domain ua=&quot;rw&quot;&gt;aton.local&lt;\/Domain&gt; &lt;Primary_DNS ua=&quot;rw&quot;&gt;$dns&lt;\/Primary_DNS&gt; &lt;Debug_Level ua=&quot;na&quot;&gt;0&lt;\/Debug_Level&gt; &lt;Primary_NTP_Server ua=&quot;na&quot;&gt;ru.pool.ntp.org&lt;\/Primary_NTP_Server&gt; &lt;Profile_Rule ua=&quot;na&quot;&gt;http:\/\/&lt;?php echo $server?&gt;\/cisco.php?mac=$MA&sn=$SN&lt;\/Profile_Rule&gt; &lt;Key_System_Auto_Discovery ua=&quot;na&quot;&gt;No&lt;\/Key_System_Auto_Discovery&gt; &lt;G722_Enable_1_ ua=&quot;na&quot;&gt;Yes&lt;\/G722_Enable_1_&gt; &lt;L16_Enable_1_ ua=&quot;na&quot;&gt;No&lt;\/L16_Enable_1_&gt; &lt;G726-16_Enable_1_ ua=&quot;na&quot;&gt;No&lt;\/G726-16_Enable_1_&gt; &lt;G726-24_Enable_1_ ua=&quot;na&quot;&gt;No&lt;\/G726-24_Enable_1_&gt; &lt;G726-32_Enable_1_ ua=&quot;na&quot;&gt;No&lt;\/G726-32_Enable_1_&gt; &lt;G726-40_Enable_1_ ua=&quot;na&quot;&gt;No&lt;\/G726-40_Enable_1_&gt; &lt;Enable_IP_Dialing_1_ ua=&quot;na&quot;&gt;No&lt;\/Enable_IP_Dialing_1_&gt; &lt;Use_Remote_Pref_Codec_1_ ua=&quot;na&quot;&gt;Yes&lt;\/Use_Remote_Pref_Codec_1_&gt; &lt;Text_Logo ua=&quot;na&quot;&gt;&lt;?php echo $textlogo ?&gt;&lt;\/Text_Logo&gt; &lt;Time_Zone ua=&quot;na&quot;&gt;&lt;?php echo $tz ?&gt;&lt;\/Time_Zone&gt; &lt;Upgrade_Rule ua=&quot;na&quot;&gt;( $SWVER lt 7.5.2b )? http:\/\/&lt;?php echo $server ?&gt;\/spa50x-30x-7-5-2b.bin | http:\/\/&lt;?php echo $server ?&gt;\/spa50x-30x-7-5-5.bin &lt;\/Upgrade_Rule&gt; &lt;HostName ua=&quot;rw&quot;&gt;&lt;?php echo $host ?&gt;&lt;\/HostName&gt; &lt;Phone-UI-readonly ua=&quot;na&quot;&gt;Yes&lt;\/Phone-UI-readonly&gt; &lt;Phone-UI-user-mode ua=&quot;na&quot;&gt;Yes&lt;\/Phone-UI-user-mode&gt; &lt;Proxy_1_ ua=&quot;na&quot;&gt;&lt;?php echo $server ?&gt;&lt;\/Proxy_1_&gt; &lt;Display_Name_1_ ua=&quot;na&quot;&gt;&lt;?php echo $name ?&gt;&lt;\/Display_Name_1_&gt; &lt;User_ID_1_ ua=&quot;na&quot;&gt;&lt;?php echo $phone ?&gt;&lt;\/User_ID_1_&gt; &lt;Password_1_ ua=&quot;na&quot;&gt;&lt;?php echo $pass ?&gt;&lt;\/Password_1_&gt; &lt;Dial_Plan_1_ ua=&quot;na&quot;&gt;&lt;?php echo $dialplan ?&gt;&lt;\/Dial_Plan_1_&gt; &lt;Station_Name ua=&quot;na&quot;&gt;&lt;?php echo $phone ?&gt;&lt;\/Station_Name&gt; &lt;Date_Format&gt;day\/month&lt;\/Date_Format&gt;                                                                              &lt;Time_Format ua=&quot;rw&quot;&gt;24hr&lt;\/Time_Format&gt;          &lt;Station_Display_Name ua=&quot;na&quot;&gt;&lt;?php echo $name ?&gt;&lt;\/Station_Display_Name&gt; &lt;Server_Type ua=&quot;na&quot;&gt;Asterisk&lt;\/Server_Type&gt; &lt;Language_Selection ua=&quot;na&quot;&gt;Russian&lt;\/Language_Selection&gt; &lt;Dictionary_Server_Script ua=&quot;na&quot;&gt;serv=http:\/\/&lt;?php echo $server?&gt;\/;d0=English;x0=spa50x_30x_en_v755.xml;d1=Russian;x1=spa50x_30x_ru_v755.xml&lt;\/Dictionary_Server_Script&gt; &lt;Default_Character_Encoding ua=&quot;na&quot;&gt;UTF-8&lt;\/Default_Character_Encoding&gt; &lt;Locale ua=&quot;na&quot;&gt;ru-RU&lt;\/Locale&gt; &lt;!-- Vertical Service Activation Codes --&gt; &lt;Call_Return_Code ua=&quot;na&quot;&gt;&lt;\/Call_Return_Code&gt; &lt;Blind_Transfer_Code ua=&quot;na&quot;&gt;&lt;\/Blind_Transfer_Code&gt; &lt;Call_Back_Act_Code ua=&quot;na&quot;&gt;&lt;\/Call_Back_Act_Code&gt; &lt;Call_Back_Deact_Code ua=&quot;na&quot;&gt;&lt;\/Call_Back_Deact_Code&gt; &lt;Cfwd_All_Act_Code ua=&quot;na&quot;&gt;&lt;\/Cfwd_All_Act_Code&gt; &lt;Cfwd_All_Deact_Code ua=&quot;na&quot;&gt;&lt;\/Cfwd_All_Deact_Code&gt; &lt;Cfwd_Busy_Act_Code ua=&quot;na&quot;&gt;&lt;\/Cfwd_Busy_Act_Code&gt; &lt;Cfwd_Busy_Deact_Code ua=&quot;na&quot;&gt;&lt;\/Cfwd_Busy_Deact_Code&gt; &lt;Cfwd_No_Ans_Act_Code ua=&quot;na&quot;&gt;&lt;\/Cfwd_No_Ans_Act_Code&gt; &lt;Cfwd_No_Ans_Deact_Code ua=&quot;na&quot;&gt;&lt;\/Cfwd_No_Ans_Deact_Code&gt; &lt;CW_Act_Code ua=&quot;na&quot;&gt;&lt;\/CW_Act_Code&gt; &lt;CW_Deact_Code ua=&quot;na&quot;&gt;&lt;\/CW_Deact_Code&gt; &lt;CW_Per_Call_Act_Code ua=&quot;na&quot;&gt;&lt;\/CW_Per_Call_Act_Code&gt; &lt;CW_Per_Call_Deact_Code ua=&quot;na&quot;&gt;&lt;\/CW_Per_Call_Deact_Code&gt; &lt;Block_CID_Act_Code ua=&quot;na&quot;&gt;&lt;\/Block_CID_Act_Code&gt; &lt;Block_CID_Deact_Code ua=&quot;na&quot;&gt;&lt;\/Block_CID_Deact_Code&gt; &lt;Block_CID_Per_Call_Act_Code ua=&quot;na&quot;&gt;&lt;\/Block_CID_Per_Call_Act_Code&gt; &lt;Block_CID_Per_Call_Deact_Code ua=&quot;na&quot;&gt;&lt;\/Block_CID_Per_Call_Deact_Code&gt; &lt;Block_ANC_Act_Code ua=&quot;na&quot;&gt;&lt;\/Block_ANC_Act_Code&gt; &lt;Block_ANC_Deact_Code ua=&quot;na&quot;&gt;&lt;\/Block_ANC_Deact_Code&gt; &lt;DND_Act_Code ua=&quot;na&quot;&gt;&lt;\/DND_Act_Code&gt; &lt;DND_Deact_Code ua=&quot;na&quot;&gt;&lt;\/DND_Deact_Code&gt; &lt;Secure_All_Call_Act_Code ua=&quot;na&quot;&gt;&lt;\/Secure_All_Call_Act_Code&gt; &lt;Secure_No_Call_Act_Code ua=&quot;na&quot;&gt;&lt;\/Secure_No_Call_Act_Code&gt; &lt;Secure_One_Call_Act_Code ua=&quot;na&quot;&gt;&lt;\/Secure_One_Call_Act_Code&gt; &lt;Secure_One_Call_Deact_Code ua=&quot;na&quot;&gt;&lt;\/Secure_One_Call_Deact_Code&gt; &lt;Paging_Code ua=&quot;na&quot;&gt;&lt;\/Paging_Code&gt; &lt;Call_Park_Code ua=&quot;na&quot;&gt;&lt;\/Call_Park_Code&gt; &lt;Call_Pickup_Code ua=&quot;na&quot;&gt;&lt;\/Call_Pickup_Code&gt; &lt;Call_UnPark_Code ua=&quot;na&quot;&gt;&lt;\/Call_UnPark_Code&gt; &lt;Group_Call_Pickup_Code ua=&quot;na&quot;&gt;&lt;\/Group_Call_Pickup_Code&gt; &lt;Media_Loopback_Code ua=&quot;na&quot;&gt;&lt;\/Media_Loopback_Code&gt; &lt;Referral_Services_Codes ua=&quot;na&quot;&gt;&lt;\/Referral_Services_Codes&gt; &lt;Feature_Dial_Services_Codes ua=&quot;na&quot;&gt;&lt;\/Feature_Dial_Services_Codes&gt; &lt;XML_Directory_Service_Name ua=&quot;na&quot;&gt;Address Book&lt;\/XML_Directory_Service_Name&gt; &lt;XML_Directory_Service_URL ua=&quot;na&quot;&gt;http:\/\/&lt;?php echo $server ?&gt;\/directory.php&lt;\/XML_Directory_Service_URL&gt; &lt;?php if ($use4line==1){ ?&gt; &lt;Extension_4_ group=&quot;Phone\/Line_Key_4&quot;&gt;Disabled&lt;\/Extension_4_&gt; &lt;Short_Name_4_ group=&quot;Phone\/Line_Key_4&quot;&gt;&lt;?php echo $label ?&gt;&lt;\/Short_Name_4_&gt; &lt;Share_Call_Appearance_4_ group=&quot;Phone\/Line_Key_4&quot;&gt;private&lt;\/Share_Call_Appearance_4_&gt;    &lt;Extended_Function_4_ group=&quot;Phone\/Line_Key_4&quot;&gt;fnc=xml;url=http:\/\/&lt;?php echo $server ?&gt;\/directory.php&lt;\/Extended_Function_4_&gt; &lt;?php } ?&gt; &lt;\/flat-profile&gt; <\/code><\/pre>\n<p>  \u0422\u0443\u0442 \u0436\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c PHP-\u0444\u0430\u0439\u043b \u0434\u043b\u044f \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u0439 \u043a\u043d\u0438\u0433\u0438:  <\/p>\n<pre><code class=\"bash\">nano directory.php <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"php\">&lt;?php  \/\/-------\u0414\u0430\u043d\u043d\u044b\u0435 MySQL $mysrv = 'localhost'; $mydb = 'asterisk'; $myuser = 'asterisk'; $mypass = 'mypass'; $table = 'tbl_sip_conf';  $mysqli = new mysqli($mysrv,$myuser,$mypass,$mydb); if ($mysqli-&gt;connect_error) {     die('Connect Error (' . $mysqli-&gt;connect_errno . ') ' . $mysqli-&gt;connect_error); } $mysqli-&gt;query(&quot;set names utf8&quot;); $query = 'SELECT * from `'.$table.'` ORDER BY `defaultuser` ASC'; $result=$mysqli-&gt;query($query); while ($row = $result-&gt;fetch_assoc()){ $phones[] = $row['name']; $names[] = $row['defaultuser']; } $mysqli-&gt;close();  ?&gt; &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt; &lt;CiscoIPPhoneDirectory&gt;    &lt;Title&gt;\u041a\u0430\u0442\u0430\u043b\u043e\u0433&lt;\/Title&gt;    &lt;Prompt&gt;\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u043d\u043e\u043c\u0435\u0440&lt;\/Prompt&gt; &lt;?php foreach($phones as $k=&gt;$v){?&gt;    &lt;DirectoryEntry&gt;      &lt;Name&gt;&lt;?php echo $names[$k].&quot; - &quot;.$v;?&gt;&lt;\/Name&gt;      &lt;Telephone&gt;&lt;?php echo $v;?&gt;&lt;\/Telephone&gt;    &lt;\/DirectoryEntry&gt; &lt;?php } ?&gt; &lt;\/CiscoIPPhoneDirectory&gt;  <\/code><\/pre>\n<h4>\u041a\u0440\u0430\u0442\u043a\u043e \u043f\u043e\u0434\u044b\u0442\u043e\u0436\u0438\u043c<\/h4>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0443 \u043d\u0430\u0441 \u0441\u0435\u0439\u0447\u0430\u0441 \u0442\u0435\u043b\u0435\u0444\u043e\u043d \u043f\u0440\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043a \u0441\u0435\u0442\u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 IP-\u0430\u0434\u0440\u0435\u0441 \u0438 DHCP-\u043e\u043f\u0446\u0438\u044e 66 \u043e\u0442 DHCP-\u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0438\u0434\u0451\u0442 \u043d\u0430 \u0430\u0434\u0440\u0435\u0441, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0432 \u043e\u043f\u0446\u0438\u0438 66, \u0437\u0430 \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u043e\u043c. \u0415\u0441\u043b\u0438 \u0432\u0435\u0440\u0441\u0438\u044f \u0435\u0433\u043e \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0438 \u043c\u0435\u043d\u044c\u0448\u0435, \u0447\u0435\u043c 7.5.2b, \u0442\u043e \u043e\u043d \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u043d\u0435\u0451, \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u2014 \u0442\u043e \u043d\u0430 7.5.5 (\u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043f\u043e\u0441\u0442\u0430).<br \/>  \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0410\u0441\u0442\u0435\u0440\u0438\u0441\u043a\u0430 \u0441 \u043b\u043e\u0433\u0438\u043d\u043e\u043c-\u043f\u0430\u0440\u043e\u043b\u0435\u043c \u0438\u0437 \u0411\u0414.<br \/>  \u0415\u0441\u043b\u0438 \u0432 \u0411\u0414 \u0440\u0430\u043d\u0435\u0435 \u0442\u0435\u043b\u0435\u0444\u043e\u043d \u0441 \u044d\u0442\u0438\u043c MAC-\u0430\u0434\u0440\u0435\u0441\u043e\u043c \u043d\u0435 \u043f\u043e\u044f\u0432\u043b\u044f\u043b\u0441\u044f \u2014 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u00abUnidentified phone #xxxx&#8217;, \u0438 \u0442\u0435\u043b\u0435\u0444\u043e\u043d \u0442\u0430\u043a \u0436\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0430 \u0410\u0441\u0442\u0435\u0440\u0438\u0441\u043a\u0435 \u0441 \u044d\u0442\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u044c\u044e.<\/p>\n<p>  \u0415\u0449\u0435 \u043d\u0430 \u0447\u0435\u0442\u0432\u0451\u0440\u0442\u0443\u044e \u043a\u043d\u043e\u043f\u043a\u0443 \u0432\u044b\u0431\u043e\u0440\u0430 \u043b\u0438\u043d\u0438\u0438 \u044f \u043f\u043e\u0432\u0435\u0441\u0438\u043b \u0432\u044b\u0437\u043e\u0432 XML-\u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 \u0441 \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u0439 \u043a\u043d\u0438\u0433\u043e\u0439, \u043a\u0430\u043a\u043e\u0432\u0443\u044e \u0441\u043a\u0440\u0438\u043f\u0442 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0442 \u043d\u0430 \u043b\u0435\u0442\u0443 \u043f\u0440\u044f\u043c\u043e \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043f\u0438\u0440\u043e\u0432 \u0432 \u0411\u0414.<\/p>\n<p>  \u0412 \u0442\u0440\u0435\u0442\u044c\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u043d\u0430\u043a\u0438\u0434\u0430\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u0438\u0439 \u0432\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f\/\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f\/\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u043c\u0435\u0440\u043e\u0432 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b.<\/p>\n<p>  \u041a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u0438 \u043f\u043e\u0436\u0435\u043b\u0430\u043d\u0438\u044f \u2014 \u0432\u0435\u043b\u043a\u043e\u043c, \u043e\u0447\u0435\u043d\u044c \u0436\u0434\u0443!    \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/214235\/\"> http:\/\/habrahabr.ru\/post\/214235\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u0412 <a href=\"http:\/\/habrahabr.ru\/post\/214181\/\">\u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/a> \u043c\u044b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438 MySQL \u0438 \u0441\u043e\u0431\u0440\u0430\u043b\u0438 \u0410\u0441\u0442\u0435\u0440\u0438\u0441\u043a \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432 \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 res_config_mysql (Asterisk Realtime Architecture)<\/p>\n<h4>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 DHCP-\u0441\u0435\u0440\u0432\u0435\u0440\u0430<\/h4>\n<p>  \u0423 \u043c\u0435\u043d\u044f \u0432 \u0434\u0432\u0443\u0445 \u0440\u0430\u0431\u043e\u0447\u0438\u0445 \u0441\u0440\u0435\u0434\u0430\u0445 \u0440\u0430\u0437\u0432\u0451\u0440\u043d\u0443\u0442\u044b \u0440\u0430\u0437\u043d\u044b\u0435 DHCP-\u0441\u0435\u0440\u0432\u0435\u0440\u044b, \u043f\u043e\u043a\u0430\u0436\u0443 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0434\u043b\u044f \u0442\u0440\u0451\u0445 \u0441\u0430\u043c\u044b\u0445 (\u0438\u043c\u0445\u043e) \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445: Windows Server DHCP, Mikrotik, DNSMasq  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-214235","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/214235","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=214235"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/214235\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=214235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=214235"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=214235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}