From f9d8c349e1aea76afad3749d8f453dd6a466df8e Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 18 Jan 2018 12:39:08 -0800 Subject: [PATCH] Move unparse_url from add_monitors to functions to make it generally available --- web/ajax/add_monitors.php | 19 ------------------- web/includes/functions.php | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/web/ajax/add_monitors.php b/web/ajax/add_monitors.php index b95f0e8f4..65c25d85d 100644 --- a/web/ajax/add_monitors.php +++ b/web/ajax/add_monitors.php @@ -1,23 +1,4 @@ set(array( diff --git a/web/includes/functions.php b/web/includes/functions.php index a05bfe6b2..a5df103da 100644 --- a/web/includes/functions.php +++ b/web/includes/functions.php @@ -841,6 +841,7 @@ function daemonControl( $command, $daemon=false, $args=false ) { } $string = escapeshellcmd( $string ); #$string .= ' 2>/dev/null >&- <&- >/dev/null'; +Logger::Debug("daemonControl $string"); exec( $string ); } @@ -2314,4 +2315,23 @@ function csrf_startup() { csrf_conf('rewrite-js', 'includes/csrf/csrf-magic.js'); } +function unparse_url($parsed_url, $substitutions = array() ) { + $fields = array('scheme','host','port','user','pass','path','query','fragment'); + + foreach ( $fields as $field ) { + if ( isset( $substitutions[$field] ) ) { + $parsed_url[$field] = $substitutions[$field]; + } + } + $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; + $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; + $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; + $user = isset($parsed_url['user']) ? $parsed_url['user'] : ''; + $pass = isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : ''; + $pass = ($user || $pass) ? "$pass@" : ''; + $path = isset($parsed_url['path']) ? $parsed_url['path'] : ''; + $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; + $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; + return "$scheme$user$pass$host$port$path$query$fragment"; +} ?>