Skip to content
Narrow screen resolution Wide screen resolution Auto adjust screen size Increase font size Decrease font size Default font size default color grey color red color blue color

Totek - Asterisk VoIP (SIP) News & Technology Source


 
Home
Use PHP and Curl to extract phone settings from the Linksys SPA941 PDF Print E-mail
User Rating: / 1
PoorBest 
Written by Web Master   
Sunday, 19 August 2007
Here is some PHP and Curl code on how to extract phone settings from the Linksys SPA941 phone. This code should also work with the Linksys SPA942 or SPA962 phones. Since the Linksys phones are basically mini web servers we can use PHP and Curl to extract whatever information we need.

This is just a small example but it could be used as a starting point for more advance software to scan and provision the Linksys phones as well. This code was created and tested on Ubuntu 7.04 with PHP 5.2.1 and Curl 7.15


<?php

 

// Using PHP and Curl to extract information

// from a Linksys SPA941 phone

// By Nick Onoufriou http://www.totek.ca

// Donated to Public Domain August 19, 2007

 

function gethtmlnamevalue($name,$data)

{

$pat='name="'.$name.'" value="(.{0,20})"';

ereg($pat,$data,$match); //look for name field

$data=$match[0];

ereg('value="(.{0,20})"',$data,$match);

$data=substr($match[0],7,-1); //strip value and quotes

return $data;

}

 

function getstationname($data)

{

return gethtmlnamevalue('53039',$data);

}

 

function getproductname($data)

{

$pat='SPA-([0-9]{0,10})';

ereg($pat,$data,$match);

$data=$match[0];

return $data;

}

 

function getmac($data)

{

$pat='MAC Address:(.{1,30})[0-9,A-F]{12,12}';

ereg($pat,$data,$match);

$data=$match[0];

$pat='[0-9,A-F]{12,12}';

ereg($pat,$data,$match);

$data=$match[0];

return $data;

}



 

Login Form






Lost Password?


Syndicate