From 8d8d8deceb4f64286136970234738de709786f09 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Thu, 24 Dec 2015 12:48:25 +0300 Subject: [PATCH 1/5] Change. Reduce too long app data in active calls app. Problem that when you have large app data (>7k in my case) it takes over 2 pages to display only single channel. --- app/calls_active/calls_active_inc.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/calls_active/calls_active_inc.php b/app/calls_active/calls_active_inc.php index 0418c94a1f..4891ec0dc6 100644 --- a/app/calls_active/calls_active_inc.php +++ b/app/calls_active/calls_active_inc.php @@ -183,6 +183,11 @@ else { } } + // reduce too long app data + if(strlen($application_data) > 512) { + $application_data = substr($application_data, 0, 512) . ' ...'; + } + echo "\n"; echo "".$sip_profile." \n"; echo "".$created." \n"; From 8ac7d708d32b9911de421cbc202f4dd7eaf3627d Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Thu, 24 Dec 2015 13:19:53 +0300 Subject: [PATCH 2/5] Change. Reuse same esl connection to send cache event and command. Fix. Implicitly close esl connection after do cache command. --- resources/classes/cache.php | 118 +++++++++++++++++++++--------------- 1 file changed, 68 insertions(+), 50 deletions(-) diff --git a/resources/classes/cache.php b/resources/classes/cache.php index 689fe7199a..077cfd9599 100644 --- a/resources/classes/cache.php +++ b/resources/classes/cache.php @@ -33,17 +33,23 @@ class cache { * @var string $value string to be cached */ public function set($key, $value) { - //send a custom event - - //run the memcache + // connect to event socket $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); - if ($fp) { - $command = "memcache set ".$key." ".$value; - return event_socket_request($fp, 'api '.$command); - } - else { + if ($fp === false) { return false; } + + //send a custom event + + //run the memcache + $command = "memcache set ".$key." ".$value; + $result = event_socket_request($fp, 'api '.$command); + + //close event socket + fclose($fp); + + // return result + return $result; } /** @@ -51,17 +57,23 @@ class cache { * @var string $key cache id */ public function get($key) { - //send a custom event - - //run the memcache + // connect to event socket $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); - if ($fp) { - $command = "memcache get ".$key; - return event_socket_request($fp, 'api '.$command); - } - else { + if ($fp === false) { return false; } + + //send a custom event + + //run the memcache + $command = "memcache get ".$key; + $result = event_socket_request($fp, 'api '.$command); + + //close event socket + fclose($fp); + + // return result + return $result; } /** @@ -69,52 +81,58 @@ class cache { * @var string $key cache id */ public function delete($key) { - //send a custom event + // connect to event socket $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); - if ($fp) { - $event = "sendevent CUSTOM\n"; - $event .= "Event-Name: MEMCACHE\n"; - $event .= "Event-Subclass: delete\n"; - $event .= "API-Command: memcache\n"; - $event .= "API-Command-Argument: delete ".$key."\n"; - echo event_socket_request($fp, $event); - } - - //run the memcache - $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); - if ($fp) { - $command = "memcache delete ".$key; - return event_socket_request($fp, 'api '.$command); - } - else { + if ($fp === false) { return false; } + + //send a custom event + $event = "sendevent CUSTOM\n"; + $event .= "Event-Name: MEMCACHE\n"; + $event .= "Event-Subclass: delete\n"; + $event .= "API-Command: memcache\n"; + $event .= "API-Command-Argument: delete ".$key."\n"; + event_socket_request($fp, $event); + + //run the memcache + $command = "memcache delete ".$key; + $result = event_socket_request($fp, 'api '.$command); + + //close event socket + fclose($fp); + + // return result + return $result; } /** * Delete the entire cache */ public function flush() { - //send a custom event + // connect to event socket $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); - if ($fp) { - $event = "sendevent CUSTOM\n"; - $event .= "Event-Name: MEMCACHE\n"; - $event .= "Event-Subclass: flush\n"; - $event .= "API-Command: memcache\n"; - $event .= "API-Command-Argument: flush\n"; - echo event_socket_request($fp, $event); - } - - //run the memcache - $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); - if ($fp) { - $command = "memcache flush"; - return event_socket_request($fp, 'api '.$command); - } - else { + if ($fp === false) { return false; } + + //send a custom event + $event = "sendevent CUSTOM\n"; + $event .= "Event-Name: MEMCACHE\n"; + $event .= "Event-Subclass: flush\n"; + $event .= "API-Command: memcache\n"; + $event .= "API-Command-Argument: flush\n"; + event_socket_request($fp, $event); + + //run the memcache + $command = "memcache flush"; + $result = event_socket_request($fp, 'api '.$command); + + //close event socket + fclose($fp); + + // return result + return $result; } } From ad5002c57a748c4b3ff7263b564b65c684383042 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Fri, 25 Dec 2015 10:33:41 +0300 Subject: [PATCH 3/5] Add. `.gitignore` file. --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..d19e84a3fe --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +resources/config.php +secure/mailto.bat +secure/*.db +secure/*.sqlite From 47871b1aa67e112fdc9e7272fbc3d2189a8912aa Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Fri, 25 Dec 2015 11:48:17 +0300 Subject: [PATCH 4/5] Fix. Use `text` class in fax_files.php --- app/fax/fax_files.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/fax/fax_files.php b/app/fax/fax_files.php index bb08fa837d..cd9a80b589 100644 --- a/app/fax/fax_files.php +++ b/app/fax/fax_files.php @@ -35,10 +35,8 @@ else { } //add multi-lingual support - require_once "app_languages.php"; - foreach($text as $key => $value) { - $text[$key] = $value[$_SESSION['domain']['language']['code']]; - } + $language = new text; + $text = $language->get(); //get variables used to control the order $order_by = check_str($_GET["order_by"]); From e51b97fdf2b6fc7ec1ce834728cb009959e18f65 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Mon, 28 Dec 2015 15:48:18 +0300 Subject: [PATCH 5/5] Fix. Do not cast dialed number to int in `Operator Panel` app. This make problems with numbers starting with `0` e.g. (001) Also this makes problem with too long numbers which does not fit to int type. --- app/operator_panel/index_inc.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/operator_panel/index_inc.php b/app/operator_panel/index_inc.php index e28c3f4425..2c58342155 100644 --- a/app/operator_panel/index_inc.php +++ b/app/operator_panel/index_inc.php @@ -173,8 +173,8 @@ foreach ($activity as $extension => $ext) { $call_number = $ext['dest']; } else { - $call_name = $activity[(int) $ext['dest']]['effective_caller_id_name']; - $call_number = format_phone((int) $ext['dest']); + $call_name = $activity[$ext['dest']]['effective_caller_id_name']; + $call_number = format_phone($ext['dest']); } $dir_icon = 'outbound'; } @@ -182,13 +182,13 @@ foreach ($activity as $extension => $ext) { if ($ext['callstate'] == 'ACTIVE') { $ext_state = 'active'; if ($ext['direction'] == 'inbound') { - $call_name = $activity[(int) $ext['dest']]['effective_caller_id_name']; - $call_number = format_phone((int) $ext['dest']); + $call_name = $activity[$ext['dest']]['effective_caller_id_name']; + $call_number = format_phone($ext['dest']); $dir_icon = 'outbound'; } else if ($ext['direction'] == 'outbound') { - $call_name = $activity[(int) $ext['cid_num']]['effective_caller_id_name']; - $call_number = format_phone((int) $ext['cid_num']); + $call_name = $activity[$ext['cid_num']]['effective_caller_id_name']; + $call_number = format_phone($ext['cid_num']); $dir_icon = 'inbound'; } } @@ -201,8 +201,8 @@ foreach ($activity as $extension => $ext) { $ext_state = 'active'; } $dir_icon = 'inbound'; - $call_name = $activity[(int) $ext['cid_num']]['effective_caller_id_name']; - $call_number = format_phone((int) $ext['cid_num']); + $call_name = $activity[$ext['cid_num']]['effective_caller_id_name']; + $call_number = format_phone($ext['cid_num']); } else { unset($ext_state, $dir_icon, $call_name, $call_number);