forked from root/threadr.lostcave.ddnss.de
				
			rewrote a significant portion of the code to make it more modular, added git commands
							parent
							
								
									91bc640df1
								
							
						
					
					
						commit
						9589a16566
					
				|  | @ -1,18 +1,18 @@ | ||||||
| <!DOCTYPE html> | <!DOCTYPE html> | ||||||
| <!-- | <!-- | ||||||
| <?php | <?php | ||||||
| echo "Getting status commands..."; | function get_command_list($command_file_name){ | ||||||
| $status_file_name = "commands_status.conf"; |   echo "Getting commands from file $command_file_name..."; | ||||||
| $status_file = fopen($status_file_name, "r") or die("Could not read file $status_file_name. Aborting."); |   $command_file = fopen($command_file_name, "r") or die("Could not read file $command_file_name. Aborting."); | ||||||
| $status_commands = explode(PHP_EOL, fread($status_file, filesize($status_file_name))); |   $commands = explode(PHP_EOL, fread($command_file, filesize($command_file_name))); | ||||||
| fclose($status_file); |   fclose($command_file); | ||||||
| echo "Done."; |   echo "Done."; | ||||||
| echo "Getting ondemand commands..."; |   return $commands; | ||||||
| $ondemand_file_name = "commands_ondemand.conf"; | } | ||||||
| $ondemand_file = fopen($ondemand_file_name, "r") or die("Could not read file $ondemand_file_name. Aborting."); | 
 | ||||||
| $ondemand_commands = explode(PHP_EOL, fread($ondemand_file, filesize($ondemand_file_name))); | $status_commands = get_command_list("commands_status.conf"); | ||||||
| fclose($ondemand_file); | $ondemand_commands = get_command_list("commands_ondemand.conf"); | ||||||
| echo "Done."; | $git_commands = get_command_list("commands_git.conf"); | ||||||
| ?>
 | ?>
 | ||||||
| --> | --> | ||||||
| <html> | <html> | ||||||
|  | @ -29,11 +29,19 @@ echo "Done."; | ||||||
|     <h1> Strassenkind Server Status </h1> |     <h1> Strassenkind Server Status </h1> | ||||||
|     <hr /> |     <hr /> | ||||||
|     <?php |     <?php | ||||||
|     if (!isset($_POST['ondemand'])) { |     function add_button($button_text, $button_action){ | ||||||
|       echo "<form action=\"\" method=\"post\"><input type=\"submit\" value=\"Run ondemand commands\" name=\"ondemand\" /></form><hr />"; |       if (!isset($_POST[$button_action])) { | ||||||
|  |         echo "<form action=\"\" method=\"post\"><input type=\"submit\" value=\"$button_text\" name=\"$button_action\" /></form>";
 | ||||||
|       } else { |       } else { | ||||||
|       echo "<a href=\"\"><button> Return to regular status commands </button></a><hr />"; |         echo "<a href=\"\"><button> Return to regular status commands </button></a>"; | ||||||
|       } |       } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     add_button("Run ondemand commands", "ondemand"); | ||||||
|  |     add_button("Force ThreadR update", "git"); | ||||||
|  |     ?>
 | ||||||
|  |     <hr /> | ||||||
|  |     <?php | ||||||
|     function execute_command_list($commands){ |     function execute_command_list($commands){ | ||||||
|       foreach ($commands as $command) { |       foreach ($commands as $command) { | ||||||
|         if ($command != ""){ |         if ($command != ""){ | ||||||
|  | @ -51,6 +59,8 @@ echo "Done."; | ||||||
|     // run ondemand command list if demanded
 |     // run ondemand command list if demanded
 | ||||||
|     if (isset($_POST['ondemand'])) { |     if (isset($_POST['ondemand'])) { | ||||||
|       execute_command_list($ondemand_commands); |       execute_command_list($ondemand_commands); | ||||||
|  |     } elseif (isset($_POST['git'])) { | ||||||
|  |       execute_command_list($git_commands); | ||||||
|     } else { |     } else { | ||||||
|       //run status command list otherwise
 |       //run status command list otherwise
 | ||||||
|       execute_command_list($status_commands); |       execute_command_list($status_commands); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 BodgeMaster
						BodgeMaster