⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 callmonitor.module

📁 最近在做软交换时研究的一个软交换的东东
💻 MODULE
📖 第 1 页 / 共 2 页
字号:
    // end form    if ($CALLMONITOR_ALLOW_DELETE) {      $ret .= "</form>";    }    $ret .= $display->displaySearchBlock('center',$m,$q,$url_opts,false);    $ret .= $display->displayNavigationBlock($m,$q,$url_opts,$start,$span,$record_count);    return $ret;  }  /*   * Checks for a recording file   *   * @param $asterisk_callmonitor_path   *   path call monitor recording directory on the asterisk server   * @param $data   *   current call monitor recordings on the asterisk server   * @return $recording   *   returns an array of $recording file names if found   */  function getRecordings($asterisk_callmonitor_path,$data) {    global $CALLMONITOR_ONLY_EXACT_MATCHING;    global $CALLMONITOR_AGGRESSIVE_MATCHING;    $recordings = array();    $extension = $_SESSION['ari_user']['extension'];    $paths = split(';',$asterisk_callmonitor_path);    foreach($paths as $key => $path) {      $paths[$key] = fixPathSlash($paths[$key]);    }    $files = array();    if (!$CALLMONITOR_ONLY_EXACT_MATCHING) {      $filter = '';      $recursiveMax = 6;      $recursiveCount = 0;      foreach($paths as $key => $path) {        $path_files = getFiles($path,$filter,$recursiveMax,$recursiveCount);        if ($path_files) {          $files = array_merge($files,$path_files);        }      }      rsort($files);    }    foreach($data as $data_key => $data_value) {      $recording='';      $calldate = $data_value['calldate'];      $duration = $data_value['duration'];      $lastdata = $data_value['lastdata'];      $uniqueid = $data_value['uniqueid'];      $userfield = $data_value['userfield'];      // timestamps      $st = trim(strtotime($calldate));      $et = trim(strtotime($calldate) + $duration);   // for on-demand call recordings      // unique file key      if ($uniqueid) {        $buf = preg_replace('/\-|\:/', '', $calldate);        $calldate_key = preg_replace('/\s+/', '-', $buf);        $unique_file_key = $calldate_key . "-" . $uniqueid;      }      if ($unique_file_key=='') {        $buf = preg_split("/\|/", $lastdata);        $unique_file_key = $buf[1];      }      $recordingLink = '';      foreach($paths as $callmonitor_key => $path) {        // try to find an exact match using the uniqueid        if (isset($uniqueid)) {          $check_files = array();          array_push($check_files,$path . $uniqueid . ".WAV");          array_push($check_files,$path . $uniqueid . ".wav");          array_push($check_files,$path . $uniqueid . ".gsm");          array_push($check_files,$path . $unique_file_key . ".WAV");          array_push($check_files,$path . $unique_file_key . ".wav");          array_push($check_files,$path . $unique_file_key . ".gsm");          array_push($check_files,$path . "g" . $extension . "-" . $unique_file_key . ".WAV");          array_push($check_files,$path . "g" . $extension . "-" . $unique_file_key . ".wav");          array_push($check_files,$path . "g" . $extension . "-" . $unique_file_key . ".gsm");          array_push($check_files,$path . "q" . $extension . "-" . $unique_file_key . ".WAV");          array_push($check_files,$path . "q" . $extension . "-" . $unique_file_key . ".wav");          array_push($check_files,$path . "q" . $extension . "-" . $unique_file_key . ".gsm");          array_push($check_files,$path . "OUT" . $extension . "-" . $unique_file_key . ".WAV");          array_push($check_files,$path . "OUT" . $extension . "-" . $unique_file_key . ".wav");          array_push($check_files,$path . "OUT" . $extension . "-" . $unique_file_key . ".gsm");          array_push($check_files,$path . $userfield);          // try to match           foreach($check_files as $check_file) {            if (is_file($check_file)) {              $recording = $check_file;              break;            }          }        }         // if found do not need to check the rest of the paths        if ($recording!='') {          break;        }      }      // get all the callmonitor recordings on server and try to find a non-exact match for this log entry      if (!$CALLMONITOR_ONLY_EXACT_MATCHING) {        // try to find a file using the uniqueid        if (!$recording) {          // try and match the unique id          if (!$recording) {             foreach($files as $key => $path) {              if (strlen($uniqueid)>1 && strpos($path,$uniqueid)!==FALSE) {                $recording = $path;                $files[$key] = '';  // remove it from the recording files so it will not be matched twice                break;              }            }           }        }         // try and match a file using the calldate (if no unique number from database)         if (!$recording) {           foreach($files as $key => $path) {            $parts = split("-", $path);            if (strlen($st)>1 &&                    (strpos($path,$st)!==FALSE) ||                    (strpos($path,"auto")!==FALSE && $parts[1] >= $st && $parts[1] <= $et)) {              $recording = $path;              $files[$key] = '';  // remove it from the recording files so it will not be matched twice              break;            }          }         }        if ($CALLMONITOR_AGGRESSIVE_MATCHING) {          // one last stab at finding a recording by adding one or two seconds to the call time           if (!$recording) {             $st_1 = trim($st+1);            $st_2 = trim($st+2);            $et_1 = trim($et+1);            $et_2 = trim($et+2);            foreach($files as $key => $path) {              $split = explode("-", $path);              if (strlen($st)>1                     && ((strpos($path,$st_1)!==FALSE) ||                         (strpos($path,$st_2)!==FALSE) ||                        (strpos($path,"auto")!==FALSE && $parts[1] >= $st_1 && $parts[1] <= $et_1) ||                        (strpos($path,"auto")!==FALSE && $parts[1] >= $st_2 && $parts[1] <= $et_2))) {                $recording = $path;                $files[$key] = '';  // remove it from the recording files so it will not be matched twice                break;              }            }           }        }      }      // add to array to be returned      if ($recording) {        $recordings[$uniqueid . $calldate] = $recording;      }    }    return $recordings;  }  /*   * Deletes selected call monitor recordings   *   * @param $files   *   Array of files to delete   */  function deleteRecData($files) {    foreach($files as $key => $file) {      if (is_writable($file)) {        unlink($file);      } else {        $_SESSION['ari_error'] = _("Only deletes recording files, not cdr log");      }    }  }  /*   * Gets cdr record count   *   * @param $q   *   query text   */  function getSearchText($q,$duration_filter) {    // search text    if ($q!='*' && $q!=NULL) {      $searchText .= "WHERE ";      $tok = strtok($q," \n\t");      while ($tok) {        $searchText .= " (calldate regexp '" . $tok . "'                         OR clid regexp '" . $tok . "'                         OR src regexp '" . $tok . "'                         OR dst regexp '" . $tok . "'                         OR dstchannel regexp '" . $tok . "'                         OR dcontext regexp '" . $tok . "'                         OR duration regexp '" . $tok . "'                         OR disposition regexp '" . $tok . "'                         OR uniqueid regexp '" . $tok . "'                         OR userfield regexp '" . $tok . "'                       )";        $tok = strtok(" \n\t");        if ($tok) {          $searchText .= " AND";        }      }    }    // duration_filter    if ($duration_filter) {      if (!$searchText) {        $searchText .= "WHERE ";      } else {        $searchText .= "AND ";      }      $searchText .= "duration>" . $duration_filter . " ";     }    // admin    if (!$_SESSION['ari_user']['admin_callmonitor']) {      if (!$searchText) {        $searchText .= "WHERE ";      } else {        $searchText .= "AND ";      }      // allow entries to be viewed with users extension      $searchText .= "(src = '" . $_SESSION['ari_user']['extension'] . "'                      OR dst = '" . $_SESSION['ari_user']['extension'] . "')";      // allow entries to be viewed with users outbound CID      if (isset($_SESSION['ari_user']['outboundCID'])) {        $searchText .= "OR (src = '" . $_SESSION['ari_user']['outboundCID'] . "'                        OR dst = '" . $_SESSION['ari_user']['outboundCID'] . "')";      }    }    return $searchText;  }  /*   * Gets cdr record count   *   * @param $q   *   query text   * @return $count   *   Number of cdr records counted   */  function getCdrCount($q,$duration_filter) {    global $ASTERISKCDR_DBTABLE;    $searchText = $this->getSearchText($q,$duration_filter);    $dbh = $_SESSION['dbh_cdr'];    $sql = "SELECT count(*)             FROM " . $ASTERISKCDR_DBTABLE . "            " . $searchText;    $result = $dbh->getAll($sql);    if (DB::isError($result)) {      $_SESSION['ari_error'] = $result->getMessage();      return;    }    $count = $result[0][0];    return $count;  }  /*   * Gets cdr data   *   * @param $q   *   query text   * @param $start   *   start record   * @param $span   *   number of records to return   * @return $data   *   cdr data to be returned   */  function getCdrData($q,$duration_filter,$start,$span,$order,$sort) {    global $ASTERISKCDR_DBTABLE;    $data = array();    $searchText = $this->getSearchText($q,$duration_filter);    $dbh = $_SESSION['dbh_cdr'];    $sql = "SELECT *            FROM " . $ASTERISKCDR_DBTABLE . "             " . $searchText . "            ORDER BY " . $order . " " . $sort . "            LIMIT " . $start . "," . $span;    $result = $dbh->getAll($sql,DB_FETCHMODE_ASSOC);    if (DB::isError($result)) {      $_SESSION['ari_error'] = $result->getMessage();      return;    }    $data = $result;    return $data;  }}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -