0) { // figure out which form was entered if ($_POST['comment_ax0']) { $_SESSION['comment_ax0'] = $_POST['comment_ax0']; $_SESSION['period_ax0'] = $_POST['period_ax0']; $_SESSION['path_ax0'] = $_POST['path_ax0']; } if ($_POST['comment_ax1']) { $_SESSION['comment_ax1'] = $_POST['comment_ax1']; $_SESSION['period_ax1'] = $_POST['period_ax1']; $_SESSION['path_ax1'] = $_POST['path_ax1']; } if ($_POST['comment_ax2']) { $_SESSION['comment_ax2'] = $_POST['comment_ax2']; $_SESSION['period_ax2'] = $_POST['period_ax2']; $_SESSION['path_ax2'] = $_POST['path_ax2']; } header("HTTP/1.1 303 See Other"); header("Location: http://$_SERVER[HTTP_HOST]/index.php"); die(); } else { if (isset($_SESSION['comment_ax0'])){ $comment_ax0 = $_SESSION['comment_ax0']; $period_ax0 = $_SESSION['period_ax0']; $path_ax0 = $_SESSION['path_ax0']; //echo "Set ax0: $comment_ax0, $period_ax0, $path_ax0"; save_settings("ax0", $period_ax0, 0, $path_ax0, 0, $comment_ax0); # Wait for the changes to take effect sleep(1); } else if (isset($_SESSION['comment_ax1'])){ $comment_ax1 = $_SESSION['comment_ax1']; $period_ax1 = $_SESSION['period_ax1']; $path_ax1 = $_SESSION['path_ax1']; //echo "Set ax1: $comment_ax1, $period_ax1, $path_ax1"; save_settings("ax1", $period_ax1, 0, $path_ax1, 0, $comment_ax1); # Wait for the changes to take effect sleep(1); } else if (isset($_SESSION['comment_ax2'])){ $comment_ax2 = $_SESSION['comment_ax2']; $period_ax2 = $_SESSION['period_ax2']; $path_ax2 = $_SESSION['path_ax2']; //echo "Set ax2: $comment_ax2, $period_ax2, $path_ax2"; save_settings("ax2", $period_ax2, 0, $path_ax2, 0, $comment_ax2); # Wait for the changes to take effect sleep(1); } session_unset(); session_destroy(); } // END: Prevents a repost when the user refreshes the page. # Reads configuration file from pe1rxf-aprs-server directory, makes changes if necesary # and writes the newly constructed file to a temporary config-file. It does not overwrite # the original file, because user www-data can only read the program directory, not write to it. # It's a safety thing... # The main loop of pe1rxf-aprs-server than copies it to the program directory and removes the temporary file. function change_parameter_value($parameter, $value) { $config_file = '/var/www/html/config/test.cfg'; $tmp_config_file = '/var/www/html/config/test.cfg.tmp'; $reading = fopen($config_file, 'r'); $writing = fopen($tmp_config_file, 'w'); $replaced = false; while (!feof($reading)) { $line = fgets($reading); if (stristr($line,$parameter)) { $line = "$parameter=$value\n"; //echo "New value: ", "$line"; $replaced = true; } fputs($writing, $line); } fclose($reading); fclose($writing); // might as well not overwrite the file if we didn't replace anything if ($replaced) { shell_exec("mv $tmp_config_file $config_file"); } else { shell_exec("rm $tmp_config_file"); } } # Saves setting for given form: ax0 or ax1 # $a = beacon_time # $b = beacon_destination # $c = beacon_path # $d = beacon_position # $e = beacon_comment # $f = beacon_file # $g = transmit_directory function save_settings($form, $a, $b=0, $c=0, $d=0, $e=0, $f=0, $g=0) { # Copy original config file to temporary place on web server. # From here we can change the values $original_config_file = '/home/marcel/ham/aprs_utils/pe1rxf-aprs-server.cfg'; $destination_config_file = '/var/www/html/config/test.cfg'; $newly_made_config_file = '/var/www/html/config/pe1rxf-aprs-server.cfg'; $fileCopied = copy("$original_config_file", "$destination_config_file"); if($fileCopied) { //echo "# $a, $b, $c, $d, $e, $f, $g"; if ($form == "ax0" ) { change_parameter_value("ax0_beacon_time", $a); if ($c) change_parameter_value("ax0_beacon_path", $c); if ($e) change_parameter_value("ax0_beacon_comment", $e); } else if ($form == "ax1" ) { change_parameter_value("ax1_beacon_time", $a); if ($c) change_parameter_value("ax1_beacon_path", $c); if ($e) change_parameter_value("ax1_beacon_comment", $e); } else if ($form == "ax2" ) { change_parameter_value("ax2_beacon_time", $a); if ($c) change_parameter_value("ax2_beacon_path", $c); if ($e) change_parameter_value("ax2_beacon_comment", $e); } # now make new file with new configuration for the main loop to find. shell_exec("cp $destination_config_file $newly_made_config_file"); # and remove working file: shell_exec("rm $destination_config_file"); } else{ #echo "Error"; } } # Reads configuration file from pe1rxf-aprs-server directory. # Search this file for given paramter and returns its value. function search_parameter_in_config_file($parameter) { $config_file = '/home/marcel/ham/aprs_utils/pe1rxf-aprs-server.cfg'; $reading = fopen($config_file, 'r'); while (!feof($reading)) { $line = fgets($reading); if ( strstr($line,$parameter) ) { $line = substr( $line, strlen($parameter)+1 ); # Found match. Stop further search. fclose($reading); return rtrim($line); } } } $ax0_name = search_parameter_in_config_file("ax0_name"); $ax0_frequency = search_parameter_in_config_file("ax0_frequency"); $ax0_beacon_comment = search_parameter_in_config_file("ax0_beacon_comment"); $ax0_beacon_time = search_parameter_in_config_file("ax0_beacon_time"); $ax0_beacon_path = search_parameter_in_config_file("ax0_beacon_path"); $ax1_name = search_parameter_in_config_file("ax1_name"); $ax1_frequency = search_parameter_in_config_file("ax1_frequency"); $ax1_beacon_comment = search_parameter_in_config_file("ax1_beacon_comment"); $ax1_beacon_time = search_parameter_in_config_file("ax1_beacon_time"); $ax1_beacon_path = search_parameter_in_config_file("ax1_beacon_path"); $ax2_name = search_parameter_in_config_file("ax2_name"); $ax2_frequency = search_parameter_in_config_file("ax2_frequency"); $ax2_beacon_comment = search_parameter_in_config_file("ax2_beacon_comment"); $ax2_beacon_time = search_parameter_in_config_file("ax2_beacon_time"); $ax2_beacon_path = search_parameter_in_config_file("ax2_beacon_path"); ?>

  PE1RXF APRS server

Send a message

Received messages

Telemetry

Heard stations

Beacon

>
>
>
>