Portions created by the Initial Developer are Copyright (C) 2008-2020 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane James Rose */ //includes require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; //check permissions if (permission_exists('setting_view') || if_group("superadmin")) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //get the number of rows in v_extensions $sql = " select count(*) from v_settings "; $database = new database; $num_rows = $database->select($sql, $parameters, 'column'); //set the action $action = $num_rows == 0 ? "add" : "update"; //get the http values and set them as php variables if (count($_POST)>0) { //$numbering_plan = $_POST["numbering_plan"]; //$default_gateway = $_POST["default_gateway"]; $setting_uuid = $_POST["setting_uuid"]; $event_socket_ip_address = $_POST["event_socket_ip_address"]; if (strlen($event_socket_ip_address) == 0) { $event_socket_ip_address = '127.0.0.1'; } $event_socket_port = $_POST["event_socket_port"]; $event_socket_password = $_POST["event_socket_password"]; $event_socket_acl = $_POST["event_socket_acl"]; $xml_rpc_http_port = $_POST["xml_rpc_http_port"]; $xml_rpc_auth_realm = $_POST["xml_rpc_auth_realm"]; $xml_rpc_auth_user = $_POST["xml_rpc_auth_user"]; $xml_rpc_auth_pass = $_POST["xml_rpc_auth_pass"]; //$admin_pin = $_POST["admin_pin"]; $mod_shout_decoder = $_POST["mod_shout_decoder"]; $mod_shout_volume = $_POST["mod_shout_volume"]; } if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { //check for all required data $msg = ''; //if (strlen($numbering_plan) == 0) { $msg .= "Please provide: Numbering Plan
\n"; } //if (strlen($default_gateway) == 0) { $msg .= "Please provide: Default Gateway
\n"; } if (strlen($event_socket_port) == 0) { $msg .= "Please provide: Event Socket Port
\n"; } if (strlen($event_socket_password) == 0) { $msg .= "Please provide: Event Socket Password
\n"; } //if (strlen($event_socket_acl) == 0) { $msg .= "Please provide: Event Socket ACL
\n"; } //if (strlen($xml_rpc_http_port) == 0) { $msg .= "Please provide: XML RPC HTTP Port
\n"; } //if (strlen($xml_rpc_auth_realm) == 0) { $msg .= "Please provide: XML RPC Auth Realm
\n"; } //if (strlen($xml_rpc_auth_user) == 0) { $msg .= "Please provide: XML RPC Auth User
\n"; } //if (strlen($xml_rpc_auth_pass) == 0) { $msg .= "Please provide: XML RPC Auth Password
\n"; } //if (strlen($admin_pin) == 0) { $msg .= "Please provide: Admin PIN Number
\n"; } //if (strlen($mod_shout_decoder) == 0) { $msg .= "Please provide: Mod Shout Decoder
\n"; } //if (strlen($mod_shout_volume) == 0) { $msg .= "Please provide: Mod Shout Volume
\n"; } if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; echo "
\n"; echo $msg."
"; echo "
\n"; persistformvar($_POST); echo "
\n"; require_once "resources/footer.php"; return; } //add or update the database if ($_POST["persistformvar"] != "true") { if (permission_exists('setting_edit')) { //build array $array['settings'][0]['setting_uuid'] = $action == "add" ? uuid() : $setting_uuid; $array['settings'][0]['event_socket_ip_address'] = $event_socket_ip_address; $array['settings'][0]['event_socket_port'] = $event_socket_port; $array['settings'][0]['event_socket_password'] = $event_socket_password; $array['settings'][0]['event_socket_acl'] = $event_socket_acl; $array['settings'][0]['xml_rpc_http_port'] = $xml_rpc_http_port; $array['settings'][0]['xml_rpc_auth_realm'] = $xml_rpc_auth_realm; $array['settings'][0]['xml_rpc_auth_user'] = $xml_rpc_auth_user; $array['settings'][0]['xml_rpc_auth_pass'] = $xml_rpc_auth_pass; $array['settings'][0]['mod_shout_decoder'] = $mod_shout_decoder; $array['settings'][0]['mod_shout_volume'] = $mod_shout_volume; //grant temporary permissions $p = new permissions; if ($action == 'add') { $p->add('setting_add', 'temp'); } else if ($action == 'update') { $p->add('setting_edit', 'temp'); } //execute insert $database = new database; $database->app_name = 'settings'; $database->app_uuid = 'b6b1b2e5-4ba5-044c-8a5c-18709a15eb60'; $database->save($array); unset($array); //revoke temporary permissions $p->delete('setting_add', 'temp'); $p->delete('setting_edit', 'temp'); //synchronize settings save_setting_xml(); //set message if ($action == 'add') { message::add($text['message-add']); } else if ($action == 'update') { message::add($text['message-update']); } //redirect header("Location: setting_edit.php"); exit; } } } //pre-populate the form if ($_POST["persistformvar"] != "true") { $sql = "select * from v_settings "; $database = new database; $row = $database->select($sql, null, 'row'); if (is_array($row) && @sizeof($row) != 0) { $setting_uuid = $row['setting_uuid']; $event_socket_ip_address = $row["event_socket_ip_address"]; $event_socket_port = $row["event_socket_port"]; $event_socket_password = $row["event_socket_password"]; $event_socket_acl = $row["event_socket_acl"]; $xml_rpc_http_port = $row["xml_rpc_http_port"]; $xml_rpc_auth_realm = $row["xml_rpc_auth_realm"]; $xml_rpc_auth_user = $row["xml_rpc_auth_user"]; $xml_rpc_auth_pass = $row["xml_rpc_auth_pass"]; $mod_shout_decoder = $row["mod_shout_decoder"]; $mod_shout_volume = $row["mod_shout_volume"]; } unset($sql, $row); } //show the header if ($action == "add") { $document['title'] = $text['title-settings_add']; } else if ($action == "update") { $document['title'] = $text['title-settings_update']; } require_once "resources/header.php"; //show the content echo "
\n"; echo "
\n"; echo "
"; if ($action == "add") { echo "".$text['title-settings_add'].""; } else if ($action == "update") { echo "".$text['title-settings_update'].""; } echo "
\n"; echo "
\n"; echo button::create(['type'=>'button','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save','collapse'=>'never','onclick'=>'submit_form();']); 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"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; echo " ".$text['label-event_socket_ip']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-event_socket_ip']."\n"; echo "
\n"; echo " ".$text['label-event_socket_port']."\n"; echo "\n"; echo " \n"; echo " \n"; //help defeat browser auto-fill echo "
\n"; echo $text['description-event_socket_port']."\n"; echo "
\n"; echo " ".$text['label-event_socket_password']."\n"; echo "\n"; echo " \n"; //help defeat browser auto-fill echo " \n"; echo "
\n"; echo $text['description-event_socket_password']."\n"; echo "
\n"; echo " ".$text['label-event_socket_acl']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-event_socket_acl']."\n"; echo "
\n"; echo " ".$text['label-xml_rpc_http_port']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-xml_rpc_http_port']."\n"; echo "
\n"; echo " ".$text['label-xml_rpc_auth_realm']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-xml_rpc_auth_realm']."\n"; echo "
\n"; echo " ".$text['label-xml_rpc_auth_user']."\n"; echo "\n"; echo " \n"; echo " \n"; //help defeat browser auto-fill echo "
\n"; echo $text['description-xml_rpc_auth_user']."\n"; echo "
\n"; echo " ".$text['label-xml_rpc_auth_pass']."\n"; echo "\n"; echo " \n"; //help defeat browser auto-fill echo " \n"; echo "
\n"; echo $text['description-xml_rpc_auth_pass']."\n"; echo "
\n"; echo " ".$text['label-mod_shout_decoder']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-mod_shout_decoder']."\n"; echo "
\n"; echo " ".$text['label-mod_shout_volume']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-mod_shout_volume']."\n"; echo "
"; echo "

"; echo "\n"; echo "
"; echo "\n"; //show the footer require_once "resources/footer.php"; ?>