アステリックCDRレポート。 アクセス制限のあるFreePBXで通話を聞く

ソフトウェアバージョン



FreePBX 2.11.0.41

Asternic CDRレポート1.5.1



はじめに



タスク:会話の録音を聴く機会を人に与える必要がありますが、厳密には特定の範囲の内部拡張についてです。 私たちは新しい管理者を作成し、拡張範囲を彼に処方することも試みています。







しかし、それから、作成されたアカウントの下に行き、コールレポートに行くと、それらが失敗したことを認識します-CDRレポートは指定された拡張範囲を無視し、すべての番号の情報を表示します。



頭の後ろをひっかいた後、別のレポートモジュールを探しています-そして、見よ、私たちはそれを見つけます:Asternic CDR Reports。 これは素晴らしいことであり、許可された管理者に範囲が制限されている番号でのみ機能します。







しかし、それは何ですか? 通話を聞いていませんか? [リスン]列にはボイスメールが表示されますか? いいえ、それは動作しません...



修正します



アスタリスクでの呼び出しに関する情報は、テーブルcdrのasteriskcdrdbデータベースのMysqlに保存されます。 これは、通常のCDRレポートのpage.cdr.phpファイルから取得した次のコードから確認できます。



$resultscdr = $dbcdr->getAll($query, DB_FETCHMODE_ASSOC); ... foreach($resultscdr as $row) ...       if ($row['recordingfile']) {          $rec_parts = explode('-',$row['recordingfile']);          $fyear = substr($rec_parts[3],0,4);          $fmonth = substr($rec_parts[3],4,2);          $fday = substr($rec_parts[3],6,2);          $monitor_base = $amp_conf['MIXMON_DIR'] ? $amp_conf['MIXMON_DIR'] : $amp_conf['ASTSPOOLDIR'] . '/monitor';          $recordingfile = "$monitor_base/$fyear/$fmonth/$fday/" . $row['recordingfile'];          if (!file_exists($recordingfile)) {             $recordingfile = '';          }       } else {          $recordingfile = '';       }
      
      





したがって、必要なのは、「filename.wav」という文字列が保存されているrecordingfileセルの値を読み取り、同じファイル名(年、月、日)から取得されたこのファイルへのフルパスを追加することです。



Asternicモジュールの/var/www/html/admin/modules/asternic_cdr/functions.inc.phpファイルを開きます。



154行目を探しています



 $query.= "billsec,duration,duration-billsec as ringtime,src,";
      
      





で置き換える



 $query.= "billsec,duration,duration-billsec as ringtime,src,recordingfile,";
      
      





そのため、データベースへのクエリでrecordingfileフィールドを追加しました。それに応じて値が結果の配列になり、そこからファイルへのリンクを作成します。



208行目を探しています



 $detail[$row['chan1']].= "\n<td>"; $uni = $row['uniqueid']; $uni = str_replace(".","",$uni); if($row['userfield']<>"") { $detail[$row['chan1']].="<a href=\"javascript:void(0);\" onclick='javascript:playVmail(\"".$row['userfield']."\",\"play".$uni."\");'>"; $detail[$row['chan1']].="<div class='playicon' title='Play' id='play".$uni."' style='float:left;'>"; $detail[$row['chan1']].="<img src='images/blank.gif' alt='pixel' height='16' width='16' border='0'>"; $detail[$row['chan1']].="</div></a>"; $detail[$row['chan1']].="<a href=\"javascript:void(0); return false;\" onclick='javascript:downloadVmail(\"".$row['userfield']."\",\"play".$uni."\",\"$ftype\",\"$fdisplay\",\"$ftab\"); return false;'>"; $detail[$row['chan1']].="<div class='downicon' title='Download' id='dload".$uni."' style='float:left;'>"; $detail[$row['chan1']].="<img src='images/blank.gif' alt='pixel' height='16' width='16' border='0'>"; $detail[$row['chan1']].="</div></a>"; } else { $detail[$row['chan1']].= " "; } $detail[$row['chan1']].= "</td>\n";
      
      







に置き換える



 if ($row['recordingfile']) {         $rec_parts = explode('-',$row['recordingfile']);         $fyear = substr($rec_parts[3],0,4);         $fmonth = substr($rec_parts[3],4,2);         $fday = substr($rec_parts[3],6,2);         $monitor_base = $amp_conf['MIXMON_DIR'] ? $amp_conf['MIXMON_DIR'] : $amp_conf['ASTSPOOLDIR'] . '/monitor';         $recordingfile = "$monitor_base/$fyear/$fmonth/$fday/" . $row['recordingfile'];         if (!file_exists($recordingfile)) {            $recordingfile = '';            $detail[$row['chan1']].= "\n<td>";         }         else {         $detail[$row['chan1']].= "\n<td style='text-align: center;' title=\"$row[recordingfile]\"><a href=\"".$PHP_SELF."?getRec=".base64_encode($recordingfile)."\" target=\"_blank\"><img src=\"images/asternic_playicon.png\" alt=\"Call recording\" /></a>";         }      } else {         $recordingfile = '';         $detail[$row['chan1']].= "\n<td>";      }         $detail[$row['chan1']].= "</td>\n";
      
      





したがって、テーブルセルでボイスメールを出力する代わりに、このコールレコードの存在を確認し、見つかった場合は、base64でエンコードされたリンクを含む小さな「Play」アイコンをオーディオ録音ファイル自体に出力します。







気配りのある読者は、生成されたリンクにgetRecというGET要求変数があることに気付きました。 Webサーバーはオーディオ録音を含むディレクトリにアクセスできないため、phpを介してファイルを提供します。このため、functions.inc.phpファイルの最後に、getRec変数が存在するかどうかを確認します。



もちろん、phpタグ「?>」を閉じる前に、ファイルの最後にコードを追加します



 function recordfile_uri($path) {   $size = filesize($path);   $name = basename($path);   $extension = strtolower(substr(strrchr($name,"."),1));   // This will set the Content-Type to the appropriate setting for the file   $ctype ='';   switch( $extension ) {      case "WAV":         $ctype="audio/x-wav";         break;      case "wav":         $ctype="audio/x-wav";         break;      case "ulaw":         $ctype="audio/basic";         break;      case "alaw":         $ctype="audio/x-alaw-basic";         break;      case "sln":         $ctype="audio/x-wav";         break;      case "gsm":         $ctype="audio/x-gsm";         break;      case "g729":         $ctype="audio/x-g729";         break;      default: //not downloadable         // echo ("<b>404 File not found! foo</b>");         // TODO: what to do if none of the above work?      break ;   } $fp=fopen($path, "rb"); if ($size && $ctype && $fp) {   header("Pragma: public");   header("Expires: 0");   header("Cache-Control: must-revalidate, post-check=0, pre-check=0");   header("Cache-Control: public");   header("Content-Description: audio file");   header("Content-Type: " . $ctype);   header("Content-Disposition: attachment; filename=" . $name);   header("Content-Transfer-Encoding: binary");   header("Content-length: " . $size);   $chunksize = 1*(1024*1024);   while (!feof($fp)) {       $buffer = fread($fp, $chunksize);       echo $buffer;       ob_flush();       flush();   }   fclose($fp); } } if(isset($_GET['getRec'])){   recordfile_uri(base64_decode($_GET['getRec']));   die(); }
      
      







できた!



誰もが幸せです-会話の録音を簡単にダウンロードして、オーディオプレーヤーでローカルに聞くことができるようになったからです。



All Articles