diff --git a/app/notifications/app_config.php b/app/notifications/app_config.php new file mode 100644 index 0000000000..4dd3b98b34 --- /dev/null +++ b/app/notifications/app_config.php @@ -0,0 +1,58 @@ + diff --git a/app/notifications/app_defaults.php b/app/notifications/app_defaults.php new file mode 100644 index 0000000000..f2b41f198c --- /dev/null +++ b/app/notifications/app_defaults.php @@ -0,0 +1,54 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +if (strlen($_SESSION['switch']['scripts']['dir']) > 0) { + if ($domains_processed == 1) { + + //update the notifications table + $sql = "select count(*) as num_rows from v_notifications "; + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] == 0) { + $sql = "insert into v_notifications "; + $sql .= "("; + $sql .= "notification_uuid, "; + $sql .= "project_notifications "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".uuid()."', "; + $sql .= "'false' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } + } + } +} + +?> \ No newline at end of file diff --git a/app/notifications/app_languages.php b/app/notifications/app_languages.php new file mode 100644 index 0000000000..77c78b4d51 --- /dev/null +++ b/app/notifications/app_languages.php @@ -0,0 +1,137 @@ +Disclosure: Enabling FusionPBX Project Notifications implies consent to the collection of anonymous and general demographic information about your installation environment. Information requested consists of the following: 1) FusionPBX version, 2) PHP version, 3) web server and version, 4) voice switch version, 5) database type and version, 6) operating system platform and version, and 7) public IP address (only for approximating your geographical location). Any information collected will not be used to contact you individually, and will not be selectively shared with any 3rd party. If you do not wish for this information to be submitted, simply leave Project Notifications disabled, and no information will be submitted about your system to the developers of FusionPBX."; + $text['message-disclaimer']['es-cl'] = ""; + $text['message-disclaimer']['pt-pt'] = ""; + $text['message-disclaimer']['fr-fr'] = ""; +?> diff --git a/app/notifications/notifications_edit.php b/app/notifications/notifications_edit.php new file mode 100644 index 0000000000..43c83b6e67 --- /dev/null +++ b/app/notifications/notifications_edit.php @@ -0,0 +1,404 @@ + +Portions created by the Initial Developer are Copyright (C) 2008-2012 +the Initial Developer. All Rights Reserved. + +Contributor(s): +Mark J Crane +*/ + +require_once "root.php"; +require_once "resources/require.php"; +require_once "resources/check_auth.php"; +if (permission_exists("notifications_edit")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +// add multi-lingual support + require_once "app_languages.php"; + foreach($text as $key => $value) { + $text[$key] = $value[$_SESSION['domain']['language']['code']]; + } + +// retrieve software uuid + $sql = "select software_uuid, software_url, software_version from v_software"; + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $software_uuid = $row["software_uuid"]; + $software_url = $row["software_url"]; + $software_version = $row["software_version"]; + break; // limit to 1 row + } + } + unset($sql, $prep_statement); + +// process submitted values + if (count($_POST) > 0) { + + // retrieve submitted values + $project_notifications = check_str($_POST["project_notifications"]); + $project_security = check_str($_POST["project_security"]); + $project_releases = check_str($_POST["project_releases"]); + $project_events = check_str($_POST["project_events"]); + $project_news = check_str($_POST["project_news"]); + $project_notification_method = check_str($_POST["project_notification_method"]); + $project_notification_recipient = check_str($_POST["project_notification_recipient"]); + + // check if remote record should be removed + if ( $project_notifications == 'false' || ( + $project_security == 'false' && + $project_releases == 'false' && + $project_events == 'false' && + $project_news == 'false' + ) + ) { + + // remove remote server record + $url = "https://".$software_url."/app/notifications/notifications_manage.php?id=".$software_uuid."&action=delete"; + if (function_exists('curl_version')) { + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); + $response = curl_exec($curl); + curl_close($curl); + } + else if (file_get_contents(__FILE__) && ini_get('allow_url_fopen')) { + $response = file_get_contents($url); + } + + // parse response + $response = json_decode($response, true); + + if ($response['result'] == 'deleted') { + // set local project notification participation flag to false + $sql = "update v_notifications set project_notifications = 'false'"; + $db->exec(check_sql($sql)); + unset($sql); + + // redirect + $_SESSION["message"] = $text['message-update']; + } + + header("Location: notifications_edit.php"); + return; + } + + // check for invalid recipient + if ( + $project_notifications == 'true' && + (($project_notification_method == 'email' && !valid_email($project_notification_recipient)) || + ($project_notification_method == 'email' && $project_notification_recipient == '') || + ($project_notification_method == 'text' && $project_notification_recipient == '') + )) { + $_SESSION["message"] = $text['message-invalid_recipient']; + header("Location: notifications_edit.php"); + return; + } + + // collect demographic information ********************************************** + + // fusionpbx version + $software_ver = $software_version; + + // php version + $php_ver = phpversion(); + + // webserver name & version + $web_server = $_SERVER['SERVER_SOFTWARE']; + + // switch version + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + if ($fp) { + $switch_result = event_socket_request($fp, 'api version'); + } + $switch_ver = trim($switch_result); + + // database name & version + switch ($db_type) { + case "pgsql" : $db_ver_query = "select version() as db_ver;"; break; + case "mysql" : $db_ver_query = "select version() as db_ver;"; break; + case "sqlite" : $db_ver_query = "select sqlite_version() as db_ver;"; break; + } + $prep_statement = $db->prepare($db_ver_query); + if ($prep_statement) { + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $database_version = $row["db_ver"]; + break; // limit to 1 row + } + } + unset($db_ver_query, $prep_statement); + $db_ver = $database_version; + + // operating system name & version + $os_platform = PHP_OS; + $os_info_1 = php_uname("a"); + if ($os_platform == "Linux") { + $os_info_2 = shell_exec("cat /etc/*{release,version}"); + $os_info_2 .= shell_exec("lsb_release -d -s"); + } + else if (substr(strtoupper($os_platform), 0, 3) == "WIN") { + $os_info_2 = trim(shell_exec("ver")); + } + + // ************************************************************************** + + // update remote server record with new values + $url = "https://".$software_url."/app/notifications/notifications_manage.php"; + $url .= "?id=".$software_uuid; + $url .= "&security=".$project_security; + $url .= "&releases=".$project_releases; + $url .= "&events=".$project_events; + $url .= "&news=".$project_news; + $url .= "&method=".$project_notification_method; + $url .= "&recipient=".urlencode($project_notification_recipient); + $url .= "&software_ver=".urlencode($software_ver); + $url .= "&php_ver=".urlencode($php_ver); + $url .= "&web_server=".urlencode($web_server); + $url .= "&switch_ver=".urlencode($switch_ver); + $url .= "&db_type=".urlencode($db_type); + $url .= "&db_ver=".urlencode($db_ver); + $url .= "&os_platform=".urlencode($os_platform); + $url .= "&os_info_1=".urlencode($os_info_1); + $url .= "&os_info_2=".urlencode($os_info_2); +// echo $url."

"; +// exit; + if (function_exists('curl_version')) { + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); + $response = curl_exec($curl); + curl_close($curl); + } + else if (file_get_contents(__FILE__) && ini_get('allow_url_fopen')) { + $response = file_get_contents($url); + } + + // parse response + $response = json_decode($response, true); + + if ($response['result'] == 'updated' || $response['result'] == 'inserted') { + // set local project notification participation flag to true + $sql = "update v_notifications set project_notifications = 'true'"; + $db->exec(check_sql($sql)); + unset($sql); + + // redirect + $_SESSION["message"] = $text['message-update']; + header("Location: notifications_edit.php"); + return; + } + + + } + +// check local project notification participation flag + $sql = "select project_notifications from v_notifications"; + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $project_notifications = $row["project_notifications"]; + break; // limit to 1 row + } + } + unset($sql, $prep_statement); + + // if participation enabled + if ($project_notifications == 'true') { + + // get current project notification preferences + $url = "https://".$software_url."/app/notifications/notifications_manage.php?id=".$software_uuid; + if (function_exists('curl_version')) { + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); + $response = curl_exec($curl); + curl_close($curl); + } + else if (file_get_contents(__FILE__) && ini_get('allow_url_fopen')) { + $response = file_get_contents($url); + } + + // parse response + $setting = json_decode($response, true); + + } + + +require_once "resources/header.php"; +$page["title"] = $text['title-notifications']; + +// show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + echo "
\n"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + + //echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + + if (permission_exists('notifications_edit')) { + echo " \n"; + echo " \n"; + echo " "; + } + + echo "
".$text['header-notifications']."

"; + if (permission_exists('notifications_edit')) { + echo " \n"; + } + echo "

"; + echo "
\n"; + echo " ".$text['description-notifications']."

\n"; + echo "
\n"; + echo $text['label-project_notifications']."\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo $text['description-project_notifications']."\n"; + echo "
\n"; + echo $text['label-project_security']."\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo $text['description-project_security']."\n"; + echo "
\n"; + echo $text['label-project_releases']."\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo $text['description-project_releases']."\n"; + echo "
\n"; + echo $text['label-project_events']."\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo $text['description-project_events']."\n"; + echo "
\n"; + echo $text['label-project_news']."\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo $text['description-project_news']."\n"; + echo "
\n"; + echo $text['label-project_notification_method']."\n"; + echo " \n"; + //echo " \n"; + //echo " \n"; + echo " \n"; + //echo " \n"; + echo " \n"; + echo "
\n"; + echo $text['description-project_notification_method']."\n"; + echo "
\n"; + echo $text['label-project_notification_recipient']."\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo $text['description-project_notification_recipient']."\n"; + echo "
\n"; + echo " \n"; + echo "
\n"; + + echo "
\n"; + + echo "

"; + echo "
".$text['message-disclaimer']."
"; + + echo "
"; + echo "
"; + echo "

"; + +// include the footer + require_once "resources/footer.php"; +?> \ No newline at end of file diff --git a/app/notifications/root.php b/app/notifications/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/notifications/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file