[Updated php scripts to work with latest mediaproxy statistics ag@ag-projects.com**20081205145702] { move ./web/config/phone_images.php ./web/phone_images.php hunk ./web/config/media_sessions.conf.sample 4 + +# Optional access list of domains for which sessions are displayed +# $allowedDomains = array('example.com','customer.com'); + hunk ./web/library/media_sessions.php 3 + hunk ./web/library/media_sessions.php 10 - var $dispatcher_port = 25061; + var $dispatcher_port = 25061; hunk ./web/library/media_sessions.php 15 - function MediaSessions ($dispatcher='',$filters=array(),$allowedDomains=array()) { + function MediaSessions ($dispatcher='',$allowedDomains=array(),$filters=array()) { + + if (!strlen($dispatcher)) return false; hunk ./web/library/media_sessions.php 19 - global $userAgentImages; - require("config/phone_images.php"); + global $userAgentImages; + require_once("phone_images.php"); + $this->userAgentImages = $userAgentImages; hunk ./web/library/media_sessions.php 26 - $this->userAgentImages = $userAgentImages; - - if (!strlen($dispatcher)) return false; - hunk ./web/library/media_sessions.php 32 - return $this->getSessions($this->dispatcher_ip,$this->dispatcher_port); + return $this->getSessions(); hunk ./web/library/media_sessions.php 42 + printf ("

Connected to MediaProxy2 dispatcher %s:%s",$this->dispatcher_ip, $this->dispatcher_port); hunk ./web/library/media_sessions.php 46 - - while (!feof($fp)) { - $line = fgets($fp); - - if (preg_match("/^\r\n/",$line)) { - break; - } - - $this->relays[] = json_decode($line); - } - } + $line = fgets($fp); + $this->relays = json_decode($line); + } hunk ./web/library/media_sessions.php 51 + $line = fgets($fp); hunk ./web/library/media_sessions.php 53 - while (!feof($fp)) { - $line = fgets($fp); - - $this->sessions_json[] = $line; - - if (preg_match("/^\r\n/",$line)) { - break; - } + $_sessions=json_decode($line); hunk ./web/library/media_sessions.php 55 - $line=json_decode($line); - - if (count($this->allowedDomains)) { - list($user1,$domain1)=explode("@",$line->from_uri); - list($user2,$domain2)=explode("@",$line->to_uri); + if (count($this->allowedDomains)) { + foreach ($_sessions as $_session) { + list($user1,$domain1)=explode("@",$_session->from_uri); + list($user2,$domain2)=explode("@",$_session->to_uri); hunk ./web/library/media_sessions.php 62 - } hunk ./web/library/media_sessions.php 63 - if (strlen($this->filters['user'])) { - $user=$this->filters['user']; - if (preg_match("/$user/",$line->from_uri) || - preg_match("/$user/",$line->to_uri) - ) { - $this->sessions[] = $line; + if (strlen($this->filters['user'])) { + $user=$this->filters['user']; + if (preg_match("/$user/",$_session->from_uri) || + preg_match("/$user/",$_session->to_uri) + ) { + $this->sessions[] = $_session; + } hunk ./web/library/media_sessions.php 71 - - } else { - $this->sessions[] = $line; hunk ./web/library/media_sessions.php 72 - + } else { + $this->sessions = $_sessions; hunk ./web/library/media_sessions.php 76 - fclose($fp); + + fclose($fp); hunk ./web/library/media_sessions.php 87 + if (!count($this->sessions)) return; hunk ./web/library/media_sessions.php 158 - print ""; - print " - - - "; hunk ./web/library/media_sessions.php 162 - $this->showHeader(); + $this->showHeader(); hunk ./web/library/media_sessions.php 164 - print "

Media sessions

"; + print "

Media sessions

"; hunk ./web/library/media_sessions.php 166 - $this->showSearch(); + $this->showSearch(); hunk ./web/library/media_sessions.php 169 - $this->showRelays(); + $this->showRelays(); hunk ./web/library/media_sessions.php 174 - $this->showFooter(); + $this->showFooter(); hunk ./web/library/media_sessions.php 178 + if (!count($this->sessions)) return; hunk ./web/library/media_sessions.php 204 - unset($media_types); + unset($media_types); hunk ./web/library/media_sessions.php 210 - if ($media_types > 1) { + if ($media_types > 1) { hunk ./web/library/media_sessions.php 220 - $streams=sprintf("%s %s",$key,$value); + $streams=sprintf("%s %s",$key,$value); hunk ./web/library/media_sessions.php 224 - printf (" - + printf (" + hunk ./web/library/media_sessions.php 262 + if (!count($this->sessions)) return; hunk ./web/library/media_sessions.php 426 - hunk ./web/media_sessions.phtml 32 -$MediaSessions = new MediaSessions($dispatcher,$filters); +$MediaSessions = new MediaSessions($dispatcher,$allowedDomains,$filters); }