had issues with caller id name and number not working.
also patched issue with AGI gateway parsing that
didn't capture everything.
-bill
wlloyd@slap.net
*** phpagi.php   Wed Jun  1 14:07:00 2005
--- phpagi.php.orig    Tue May 31 13:15:16 2005
***************
*** 179,199 ****
// make sure temp folder exists
$this->make_folder($this->config['phpagi']['tempdir']);
!       while ( !feof($this->in) ) 
!  {
!    $str = fgets($this->in );
!     
!    // Strip off any new-line characters
!    $str = str_replace( "\n", "", $str );
!     
!    $s = explode( ":", $str );
! 
!    if ( ( $str == "") || ($str == "\n") )
!      {
!        break;
!      }
!    $this->request[$s[0]] = trim( $s[1] );
!  } 
// open audio if eagi detected
if($this->request['agi_enhanced'] == '1.0')
--- 179,191 ----
// make sure temp folder exists
$this->make_folder($this->config['phpagi']['tempdir']);
!       // read the request
!       $str = fgets($this->in);
!       while($str != "\n")
!       {
!         $this->request[substr($str, 0, strpos($str,
':'))] = trim(substr($str, strpos($str, ':') + 1));
!         $str = fgets($this->in);
!       }
// open audio if eagi detected
if($this->request['agi_enhanced'] == '1.0')
***************
*** 1201,1207 ****
*
* @example examples/dtmf.php Get DTMF tones from
the user and say the digits
* @example examples/input.php Get text input from
the user and say it back
!     *.
* "name" <proto:user@server:port>
*
* @param string $callerid
--- 1193,1199 ----
*
* @example examples/dtmf.php Get DTMF tones from
the user and say the digits
* @example examples/input.php Get text input from
the user and say it back
!     *
* "name" <proto:user@server:port>
*
* @param string $callerid
***************
*** 1212,1252 ****
if(is_null($callerid))
$callerid = $this->request['agi_callerid'];
!       $ret = array('name'=>'', 'number'=>'');
! 
$callerid = trim($callerid);
-     
-       // Callerid info comes in many many different
formats.  
-       // extract the name or text info first
-       // Do we have a name enclosed in ' or " ?
-       $start = 0;
if($callerid{0} == '"' || $callerid{0} == "'")
{
!  $start = 1;
}
-       // if we match here we only have caller number
no name info
-       if (!(preg_match('/[ 0123456789\-]+/',
$callerid, $match))) 
-  {
-    $ret['name'] = substr($callerid, $start,
(strrpos($callerid,'<')-$start));
-  }
- 
-       // ok let's try to get somethign number like
-       // Often enclosed like <xxxxxxxxxx>
-       // phone numbers may have spaces or - or nothing
-       if (preg_match('/<([ 0123456789\-]+)>/',
$callerid, $match) )
-  {
-    $ret['number'] = trim($match[1]);
-  }
-       else // Did not find the <##...> look for the
first number in the string to use as CID
-  {
-    if (preg_match('/([0-9]+)/', $callerid, $match) )
-      {
-        $ret['number'] = trim($match[1]);
-      }
-  }
-     
return $ret;
}
--- 1204,1240 ----
if(is_null($callerid))
$callerid = $this->request['agi_callerid'];
!       $ret = array('name'=>'', 'protocol'=>'',
'username'=>'', 'host'=>'', 'port'=>'');
$callerid = trim($callerid);
if($callerid{0} == '"' || $callerid{0} == "'")
{
!         $d = $callerid{0};
!         $callerid = explode($d, substr($callerid, 1));
!         $ret['name'] = array_shift($callerid);
!         $callerid = join($d, $callerid);
!       }
! 
!       $callerid = explode('@', trim($callerid, '<> '));
!       $username  = explode(':', array_shift($callerid));
!       if(count($username) == 1)
!         $ret['username'] = $username[0];
!       else
!       {
!         $ret['protocol'] = array_shift($username);
!         $ret['username'] = join(':', $username);
!       }
! 
!       $callerid = join('@', $callerid);
!       $host = explode(':', $callerid);
!       if(count($host) == 1)
!         $ret['host'] =  $host[0];
!       else
!       {
!         $ret['host'] = array_shift($host);
!         $ret['port'] = join(':', $host);
}
return $ret;
}
patch