XML Phone Directory Setup

In order for a IP phone to connect to the freePBX XML Phone Directory.

You will have to do a few things.


Create new User in FreePBX:

Click Setup. Under Basic Heading.  Click Administrators

You will need to create a new user called xmldirectory .
You can set any password.

Allow only modules XML Directory


Edit header_auth.php:

Change you header_auth.php file.
You will need to edit the file: /admin/header_auth.php 
After the block Logout.( logout block ends with the 2 lines below. )

exit;
}


Add:

//XML Phone Login added by xmlphonedirectory
if( !isset( $_SESSION['AMP_user']  ) )
{
    if( isset($_GET['display'])  )
    {
	if( $_GET['display'] == "xmlphonedirectory" )
	{
		if( IsIpARegedSIP( $_SERVER['REMOTE_ADDR'] ) == true )
		{
			$_SESSION['AMP_user'] = new ampuser("xmldirectory");
		}
	}
    }
}
 



Now we need to add the sip security function:

Go to the very bottom of /admin/header_auth.php

Above the last line. the last line is.

?>


Add:

//function added by xmlphonedirectory
function IsIpARegedSIP($CheckIP)
{
	global $astman;
	$response = $astman->send_request('Command',array('Command'=>'sip show peers'));
	$new_value = $response['data'];

	$MyList = split("\n",$new_value) ;
	if( count( $MyList) > 4 )
	{
		for($ix=2;$ix< (count($MyList)-2);$ix++ )
		{
			$matches = preg_split("/[\s,]+/", $MyList[$ix]);
			if( $CheckIP == $matches[1] ) { return true; }
		}
	}
	return false;
}
 



Now save your file!

This will make it so only ip address in the "sip users" can access the file.

They will be logged in as xmldirectory