Pessoal achei esse script que pega os arquivos do diretório INBOX e sobe automático no banco, funfou belezinha segue o mesmo pra alguém que tiver interesse:<br><br><ol><li>!/usr/bin/php -q
</li></ol>&lt;?
<br>$my_user = &quot;convert&quot;;           <br>$my_passwd = &quot;convert&quot;;         <br>$my_host = &quot;localhost&quot;;         <br>$my_database = &quot;asterisk&quot;;      <br>$my_table = &quot;voicemessages&quot;;    <br>
$msg_format = &quot;WAV&quot;;            <br>$dir_prefix = &quot;/var/spool/asterisk/voicemail/&quot;; <br>$ignore_default = TRUE;         # TRUE ignorar contexto &#39;default&#39; , 
FALSE nao ignora contexto default
<br>
<br>echo &quot;Starting....\n&quot;;
<br>$DB = mysql_connect($my_host, $my_user, $my_passwd) or die(&quot;Could 
not connect: &quot; . mysql_error());
<br>mysql_select_db($my_database) or die(&quot;Could not select database: &quot; .
 mysql_error());
<br>
<br>if(!is_dir($dir_prefix)) die(&quot;$dir_prefix is not a directory.\n&quot;);
<br>$DirH = opendir($dir_prefix) or die (&quot;opendir failed on 
$dir_prefix.\n&quot;);
<br>while(FALSE !== ($DirEnt = readdir($DirH)) ) {  # each of these 
directories is a voicemailbox context
<br><span style="font-family: monospace;">       if($DirEnt == &quot;.&quot; || $DirEnt == &quot;..&quot;) continue;
</span><br><span style="font-family: monospace;">       if($DirEnt == &quot;default&quot; &amp;&amp; $ignore_default) continue;
</span><br><span style="font-family: monospace;">       echo &quot;Processing context directory $dir_prefix$DirEnt\n&quot;;
</span><br><span style="font-family: monospace;">       $mailboxcontext=$DirEnt;
</span><br><span style="font-family: monospace;">       $CtxH = opendir($dir_prefix.$DirEnt) or die (&quot;opendir failed on $dir_prefix$DirEnt\n&quot;);
</span><br><span style="font-family: monospace;">       while(FALSE !== ($CtxEnt = readdir($CtxH)) ) {  # each of these directories is a voicemailbox 
</span><br><span style="font-family: monospace;">               if($CtxEnt == &quot;.&quot; || $CtxEnt == &quot;..&quot;) continue;
</span><br><span style="font-family: monospace;">               $mailbox=$CtxEnt;
</span><br><span style="font-family: monospace;">               echo &quot;\tVoicemailbox $mailbox\n&quot;;
</span><br><span style="font-family: monospace;">               $MbxH = opendir($dir_prefix.$DirEnt.&quot;/&quot;.$mailbox) or die (&quot;opendir failed on $dir_prefix$DirEnt/$mailbox\n&quot;);
</span><br><span style="font-family: monospace;">               while(FALSE !== ($MbxEnt = readdir($MbxH)) ) {  # each of these directories is a folder or announcemen/greeting
</span><br><span style="font-family: monospace;">                       if($MbxEnt == &quot;.&quot; || $MbxEnt == &quot;..&quot;) continue;
</span><br><span style="font-family: monospace;">                       $path = $dir_prefix.$DirEnt.&quot;/&quot;.$mailbox.&quot;/&quot;.$MbxEnt;
</span><br><span style="font-family: monospace;">                       if(is_dir($path)) {
</span><br><span style="font-family: monospace;">                               echo &quot;\t\tVmailbox folder $MbxEnt: &quot;;
</span><br><span style="font-family: monospace;">                               $FldH = opendir($path) or die (&quot;opendir failed on $path\n&quot;);
</span><br><span style="font-family: monospace;">                               while(FALSE !== ($FldEnt = readdir($FldH))) {   # entries in mailbox folders: the messages
</span><br><span style="font-family: monospace;">                                       if($FldEnt == &quot;.&quot; || $FldEnt == &quot;..&quot;)   continue;
</span><br><span style="font-family: monospace;">                                       if(strpos($FldEnt,&quot;txt&quot;) !== FALSE) {
</span><br><span style="font-family: monospace;">                                               doMsgInsert($mailboxcontext,$mailbox,$FldEnt,$path);
</span><br><span style="font-family: monospace;">                                               echo &quot;.&quot;;
</span><br><span style="font-family: monospace;">                                        }
</span><br><span style="font-family: monospace;">                                } # end mailbox-folder directory loop
</span><br><span style="font-family: monospace;">                               closedir($FldH);
</span><br><span style="font-family: monospace;">                               echo &quot;\n&quot;;
</span><br><span style="font-family: monospace;">                        } else {
</span><br><span style="font-family: monospace;">                               switch($MbxEnt) {
</span><br><span style="font-family: monospace;">                                       case &quot;busy.&quot;.$msg_format:
</span><br><span style="font-family: monospace;">                                       case &quot;temp.&quot;.$msg_format:
</span><br><span style="font-family: monospace;">                                       case &quot;greet.&quot;.$msg_format:
</span><br><span style="font-family: monospace;">                                       case &quot;unavail.&quot;.$msg_format:
</span><br><span style="font-family: monospace;">                                               $announce = substr($MbxEnt,0,-4);
</span><br><span style="font-family: monospace;">                                               break;
</span><br><span style="font-family: monospace;">                                       default:
</span><br><span style="font-family: monospace;">                                               $announce = &quot;WRONG_FORMAT&quot;;
</span><br><span style="font-family: monospace;">                                               break;
</span><br><span style="font-family: monospace;">                                }
</span><br><span style="font-family: monospace;">                               if($announce == &quot;WRONG_FORMAT&quot;) continue;
</span><br><span style="font-family: monospace;">                               doGreetInsert($mailboxcontext,$mailbox,$path);
</span><br><span style="font-family: monospace;">                               echo &quot;\t  — Mailbox recording $announce done.\t \n&quot;;
</span><br><span style="font-family: monospace;">                        }
</span><br><span style="font-family: monospace;">                } # end voicemailbox directory loop
</span><br><span style="font-family: monospace;">               closedir($MbxH);
</span><br><span style="font-family: monospace;">        } # end voicemailbox directory loop
</span><br><span style="font-family: monospace;">       closedir($CtxH);
</span><br>} # end voicemailbox context directory loop
<br>closedir($DirH);
<br>
<br>echo &quot;\n&quot;;
<br>echo &quot;All done.\n&quot;;
<br>exit(0);
<br>
<br>function doMsgInsert($mailboxcontext,$mailbox,$msgFile,$path) {
<br><span style="font-family: monospace;">       global $msg_format;
</span><br><span style="font-family: monospace;">       $Ipref = &quot;INSERT INTO voicemessages (msgnum,context,callerid,duration,origtime,dir,mailboxuser,mailboxcontext,recording) VALUES (&quot;;
</span><br><span style="font-family: monospace;">       $msgnum = 0+substr($msgFile,3,4);
</span><br><span style="font-family: monospace;">       $DETAILS = parse_ini_file($path.&quot;/&quot;.$msgFile,FALSE);
</span><br><span style="font-family: monospace;">       $DFile = fopen($path.&quot;/&quot;.$msgFile,&quot;r&quot;) or die (&quot;Could not open $dir_prefix $MSG_FILE \n&quot;);
</span><br><span style="font-family: monospace;">       while(!feof($DFile)) {          # need to get callerid seperately
</span><br><span style="font-family: monospace;">               $LINE = rtrim(fgets($DFile,4096));
</span><br><span style="font-family: monospace;">               if(strpos($LINE,&quot;callerid&quot;) !== FALSE)  list($y,$callerid) = explode(&quot;=&quot;,$LINE);
</span><br><span style="font-family: monospace;">        }
</span><br><span style="font-family: monospace;">       fclose($DFile);
</span><br><span style="font-family: monospace;">       $recording = mysql_real_escape_string(file_get_contents($path.&quot;/&quot;.substr($msgFile,0,-3).$msg_format));
</span><br><span style="font-family: monospace;">       if($recording) $BLOB = &quot;read ok&quot;; else $BLOB = &quot;false&quot;;
</span><br><span style="font-family: monospace;">       $INSERT = $Ipref . &quot;&#39;&quot;.$msgnum.&quot;&#39;,&#39;&quot;.$DETAILS<em>context</em>&gt;&#39;context&#39;.&quot;&#39;,&#39;&quot; . mysql_real_escape_string($callerid).&quot;&#39;,&#39;&quot;;
</span><br><span style="font-family: monospace;">       if (!isset($DETAILS<em>duration</em>&gt;&#39;duration&#39;))       $DETAILS<em>duration</em>&gt;&#39;duration&#39; = 0;
</span><br><span style="font-family: monospace;">       $INSERT .= $DETAILS<em>duration</em>&gt;&#39;duration&#39;.&quot;&#39;,&#39;&quot;;
</span><br><span style="font-family: monospace;">       if (!isset($DETAILS<em>origtime</em>&gt;&#39;origtime&#39;))       $DETAILS<em>origtime</em>&gt;&#39;origtime&#39; = 0;
</span><br><span style="font-family: monospace;">       $INSERT .= $DETAILS<em>origtime</em>&gt;&#39;origtime&#39;.&quot;&#39;,&#39;&quot; . $path . &quot;&#39;,&#39;$mailbox&#39;,&#39;$mailboxcontext&#39;,&#39;&quot;;
</span><br><span style="font-family: monospace;">       $INSERT_REAL = $INSERT . $recording .&quot;&#39;)&quot;;
</span><br><span style="font-family: monospace;">       $INSERT .= $BLOB. &quot;&#39;)&quot;;
</span><br><span style="font-family: monospace;">       $R = mysql_query($INSERT_REAL) or die(&quot;Problem with INSERT: \n$INSERT\n\n&quot;. mysql_error().&quot;\n&quot;);
</span><br>} # end function doMsgInsert()
<br>
<br>function doGreetInsert($mailboxcontext,$mailbox,$path) {
<br><span style="font-family: monospace;">       $Gpref = &quot;INSERT INTO voicemessages (msgnum,dir,mailboxuser,mailboxcontext,recording) VALUES (-1,&#39;&quot;;
</span><br><span style="font-family: monospace;">       $dir = substr($path,0,-4);
</span><br><span style="font-family: monospace;">       $recording = mysql_real_escape_string(file_get_contents($path));
</span><br><span style="font-family: monospace;">       if($recording) $BLOB = &quot;ok&quot;; else $BLOB = &quot;failed&quot;;
</span><br><span style="font-family: monospace;">       $INSERT = $Gpref . $dir . &quot;&#39;,&#39;$mailbox&#39;,&#39;$mailboxcontext&#39;,&#39;&quot;;
</span><br><span style="font-family: monospace;">       $INSERT_REAL = $INSERT . $recording . &quot;&#39;)&quot;;
</span><br><span style="font-family: monospace;">       $INSERT .= $BLOB.&quot;&#39;)&quot;;
</span><br><span style="font-family: monospace;">       $R = mysql_query($INSERT_REAL) or die(&quot;Problem with INSERT: \n$INSERT\n\n&quot;. mysql_error().&quot;\n&quot;);
</span><br>} # end function doGreetInsert()
<br>
<br>?&gt;
<br clear="all"><br>-- <br>Wendell Silva Bandeira<br>Analista de TI <br><br>