Portal Home > Knowledgebase > cPanel > Call notify script


Call notify script




Installed in /var/lib/astersisk/bin
Runs every 10 minutes due to cron setup


#!/usr/bin/php -q

$callNotify = array( 
      'ext'  => 'comma delimited list of SMS number',
      '302'  => '6138188391,6138801797',  // robin, amanda
      '5212' => '6138801797', // mark
      '5213' => '6138801797'  // steph
   );

# Directory housing the voicemail spool for asterisk  
$dir = "/var/spool/asterisk/voicemail/default/";  

foreach ($callNotify as $ext => $sms) 
{
   if( dir_has_files($dir . $ext . '/INBOX') ) 
   {
      $phones = preg_split("/[\s]*[,][\s]*/", $sms);
      foreach( $phones as $phone )
      {
         // http://192.168.10.23:9090/sendsms?phone=6138188391&text=text+message
         file_get_contents('http://192.168.10.23:9090/sendsms?phone='.$phone.'&text=MMAH+voicemail+on+extension+'.$ext);
      }
   }
}

function dir_has_files($dir) {
  if (is_dir($dir))
     return (count(scandir($dir)) > 2);
  return 0;
}
?>



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article