Portions created by the Initial Developer are Copyright (C) 2008-2012 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane James Rose */ include "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; 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(*) as num_rows from v_settings "; $prep_statement = $db->prepare(check_sql($sql)); $num_rows = 0; if ($prep_statement) { $prep_statement->execute(); $row = $prep_statement->fetch(PDO::FETCH_ASSOC); if ($row['num_rows'] > 0) { $num_rows = $row['num_rows']; } else { $num_rows = 0; } } unset($prep_statement, $result); //set the action if ($num_rows == 0) { $action = "add"; } else { $action = "update"; } //get the http values and set them as php variables if (count($_POST)>0) { //$numbering_plan = check_str($_POST["numbering_plan"]); //$default_gateway = check_str($_POST["default_gateway"]); $event_socket_ip_address = check_str($_POST["event_socket_ip_address"]); if (strlen($event_socket_ip_address) == 0) { $event_socket_ip_address = '127.0.0.1'; } $event_socket_port = check_str($_POST["event_socket_port"]); $event_socket_password = check_str($_POST["event_socket_password"]); $xml_rpc_http_port = check_str($_POST["xml_rpc_http_port"]); $xml_rpc_auth_realm = check_str($_POST["xml_rpc_auth_realm"]); $xml_rpc_auth_user = check_str($_POST["xml_rpc_auth_user"]); $xml_rpc_auth_pass = check_str($_POST["xml_rpc_auth_pass"]); //$admin_pin = check_str($_POST["admin_pin"]); $mod_shout_decoder = check_str($_POST["mod_shout_decoder"]); $mod_shout_volume = check_str($_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($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 ($action == "add" && permission_exists('setting_edit')) { $sql = "insert into v_settings "; $sql .= "("; $sql .= "event_socket_ip_address, "; $sql .= "event_socket_port, "; $sql .= "event_socket_password, "; $sql .= "xml_rpc_http_port, "; $sql .= "xml_rpc_auth_realm, "; $sql .= "xml_rpc_auth_user, "; $sql .= "xml_rpc_auth_pass, "; $sql .= "mod_shout_decoder, "; $sql .= "mod_shout_volume "; $sql .= ")"; $sql .= "values "; $sql .= "("; $sql .= "'$event_socket_ip_address', "; $sql .= "'$event_socket_port', "; $sql .= "'$event_socket_password', "; $sql .= "'$xml_rpc_http_port', "; $sql .= "'$xml_rpc_auth_realm', "; $sql .= "'$xml_rpc_auth_user', "; $sql .= "'$xml_rpc_auth_pass', "; $sql .= "'$mod_shout_decoder', "; $sql .= "'$mod_shout_volume' "; $sql .= ")"; $db->exec(check_sql($sql)); unset($sql); //synchronize settings save_setting_xml(); messages::add($text['message-add']); header("Location: setting_edit.php"); return; } //if ($action == "add") if ($action == "update" && permission_exists('setting_edit')) { $sql = "update v_settings set "; $sql .= "event_socket_ip_address = '$event_socket_ip_address', "; $sql .= "event_socket_port = '$event_socket_port', "; $sql .= "event_socket_password = '$event_socket_password', "; $sql .= "xml_rpc_http_port = '$xml_rpc_http_port', "; $sql .= "xml_rpc_auth_realm = '$xml_rpc_auth_realm', "; $sql .= "xml_rpc_auth_user = '$xml_rpc_auth_user', "; $sql .= "xml_rpc_auth_pass = '$xml_rpc_auth_pass', "; $sql .= "mod_shout_decoder = '$mod_shout_decoder', "; $sql .= "mod_shout_volume = '$mod_shout_volume' "; $db->exec(check_sql($sql)); unset($sql); //synchronize settings save_setting_xml(); messages::add($text['message-update']); header("Location: setting_edit.php"); return; } //if ($action == "update") } //if ($_POST["persistformvar"] != "true") } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) //pre-populate the form if ($_POST["persistformvar"] != "true") { $sql = ""; $sql .= "select * from v_settings "; $prep_statement = $db->prepare($sql); if ($prep_statement) { $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); foreach ($result as &$row) { $event_socket_ip_address = $row["event_socket_ip_address"]; $event_socket_port = $row["event_socket_port"]; $event_socket_password = $row["event_socket_password"]; $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"]; break; //limit to 1 row } unset ($prep_statement); } } //show the header require_once "resources/header.php"; //show the content echo "
\n"; echo "\n"; echo "\n"; if ($action == "add") { echo "\n"; } if ($action == "update") { 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"; if (permission_exists('setting_edit')) { echo " \n"; echo " \n"; echo " "; } echo "
".$text['title-settings-add']."

".$text['title-settings-update']."

"; if (permission_exists('setting_edit')) { 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"; echo $text['description-event-socket-port']."\n"; echo "
\n"; echo " ".$text['label-event-socket-pw']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-event-socket-pw']."\n"; echo "
\n"; echo " ".$text['label-xml-rpc-port']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-xml-rpc-port']."\n"; echo "
\n"; echo " ".$text['label-xml-rpc-realm']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-xml-rpc-realm']."\n"; echo "
\n"; echo " ".$text['label-xml-rpc-user']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-xml-rpc-user']."\n"; echo "
\n"; echo " ".$text['label-xml-rpc-pw']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-xml-rpc-pw']."\n"; echo "
\n"; echo " ".$text['label-shout-decoder']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-shout-decoder']."\n"; echo "
\n"; echo " ".$text['label-shout-volume']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-shout-volume']."\n"; echo "
\n"; echo "
"; echo " \n"; echo "
"; echo "

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