file = $file; $this->callTypes = $callTypes; $this->msns = (array)$msns; $this->fileHdl = fopen($this->file, 'a'); if (!$this->fileHdl) { throw new \Exception( 'Cannot open call log file for writing: ' . $this->file ); } } public function log($type, $arData) { if ($type != 'finishedCall') { return; } $call = $arData['call']; //check if call type matches if ($call->type == CallMonitor_Call::INCOMING && $this->callTypes == 'o') { return; } if ($call->type == CallMonitor_Call::OUTGOING && $this->callTypes == 'i') { return; } if ($call->type == CallMonitor_Call::INCOMING) { $msn = $call->to; } else { $msn = $call->from; } if (count($this->msns) > 0 && !in_array($msn, $this->msns)) { //msn shall not be logged return; } fwrite($this->fileHdl, $this->createLogEntry($call)); } protected function createLogEntry(CallMonitor_Call $call) { $this->addUnsetVars($call); $str = date('Y-m-d H:i:s', $call->start); if ($call->type == CallMonitor_Call::INCOMING) { $str .= ' ' . $call->to . ' von ' . $this->getNumberString($call, 'from'); } else { $str .= ' ' . $call->from . ' nach ' . $this->getNumberString($call, 'to'); } $str .= ', Dauer ' . date('H:i:s', $call->end - $call->start - 3600); return $str . "\n"; } } ?>