diff --git a/src/php/add_device.php b/src/php/add_device.php index 6c118c1b..15f49d51 100644 --- a/src/php/add_device.php +++ b/src/php/add_device.php @@ -1,5 +1,107 @@ + + + + + + + + -

I guess I should add a device

- + 0){ + $result = exec($cmd); + echo '
'; + echo 'Ran command:
'.$cmd.'
'; + echo '
'; + } + // Check to see if the command succeeded + if(strlen($result) > 0){ + html_generate_warning($result); + } + else { + html_generate_success_message(); + } + echo '
'; + html_generate_ok_to_go_home(); + } + else { + html_generate_add_new_device(trim($id)); + } + + +function html_generate_add_new_device($id){ + echo '

Add New Device

'; + echo '
'; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo '
SCSI ID:'; + echo ' '; + echo $id; + echo ' Device:'; + html_generate_scsi_type_select_list(); + echo ' File:'; + echo ' '; + echo ' '; + echo ' '; + echo '
'; +} +?> + + diff --git a/src/php/disconnect.php b/src/php/disconnect.php new file mode 100644 index 00000000..e096c6ac --- /dev/null +++ b/src/php/disconnect.php @@ -0,0 +1,39 @@ + + + + + + + + + + +'; + echo 'Ran command:
'.$cmd.'
'; + echo '
'; + + // Check to see if the command succeeded + if(strlen($result) > 0){ + html_generate_warning($result); + } + else { + html_generate_success_message(); + } + } + else { + html_generate_warning('Page opened without arguments'); + } + echo '
'; + html_generate_ok_to_go_home(); +?> + + diff --git a/src/php/eject.php b/src/php/eject.php index 7d1c5d2a..1afd6ebf 100644 --- a/src/php/eject.php +++ b/src/php/eject.php @@ -1,5 +1,39 @@ + + + + + + + + -

I guess I should eject something

+'; + echo 'Ran command:
'.$cmd.'
'; + echo '
'; + + // Check to see if the command succeeded + if(strlen($result) > 0){ + html_generate_warning($result); + } + else { + html_generate_success_message(); + } + } + else { + html_generate_warning('Page opened without arguments'); + } + echo '
'; + html_generate_ok_to_go_home(); +?> diff --git a/src/php/lib_rascsi.php b/src/php/lib_rascsi.php index c7c27822..52cecf2c 100644 --- a/src/php/lib_rascsi.php +++ b/src/php/lib_rascsi.php @@ -7,6 +7,7 @@ '; @@ -15,14 +16,12 @@ function html_generate_header(){ echo ' '; echo ' '; echo ' '; + echo '

'.time().'

'; echo '
'; echo ' '; echo ' '; echo ' '; - echo 'Debug timestamp: '; - $t=time(); - echo($t . "
"); - echo(exec('whoami')); + //echo(exec('whoami')); } function html_generate_scsi_id_select_list(){ @@ -34,13 +33,41 @@ function html_generate_scsi_id_select_list(){ } function html_generate_scsi_type_select_list(){ - echo ''; $options = array("Hard Disk", "CD-ROM", "Zip Drive", "Ethernet Tap", "Filesystem Bridge"); foreach($options as $type){ echo ''; } echo ''; } + +function html_generate_warning($message){ + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo '
'; + echo ' '.$message.''; + echo '
'; +} + +function html_generate_success_message(){ + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo '
'; + echo ' Success!'; + echo '
'; +} + +function html_generate_ok_to_go_home(){ + echo '
'; + echo ' '; + echo '
'; +} + + function current_rascsi_config() { $raw_output = shell_exec("/usr/local/bin/rasctl -l"); $rasctl_lines = explode(PHP_EOL, $raw_output); @@ -98,7 +125,7 @@ function current_rascsi_config() { echo ' -'; echo ' -'; echo ' '; - echo ' '; + echo ' '; echo ' '; } @@ -109,7 +136,7 @@ function current_rascsi_config() { } function get_all_files() { - $raw_ls_output = shell_exec('ls --time-style="+\"%Y-%m-%d %H:%M:%S\"" -alh --quoting-style=c /home/pi/images/'); + $raw_ls_output = shell_exec('ls --time-style="+\"%Y-%m-%d %H:%M:%S\"" -alh --quoting-style=c '.$GLOBALS['FILE_PATH']); return $raw_ls_output; } @@ -141,4 +168,25 @@ function file_category_from_file_name($value){ } return "Unknown type: " . $value; } + + + +function type_string_to_rasctl_type($typestr){ + if(strcasecmp($typestr,"Hard Disk") == 0){ + return "hd"; + } + if(strcasecmp($typestr,"CD-ROM") == 0){ + return "cd"; + } + if(strcasecmp($typestr,"Zip Drive") == 0){ + } + if(strcasecmp($typestr,"Filesystem bridge") == 0){ + return "bridge"; + } + return ""; +} + + + + ?> diff --git a/src/php/rascsi.php b/src/php/rascsi.php index 452d1b87..5090682b 100644 --- a/src/php/rascsi.php +++ b/src/php/rascsi.php @@ -18,20 +18,23 @@ function compute(f) { } function eject_image(id,file){ - if(confirm("Not implemented yet.... would eject " + file + " from " + id)) - window.location = 'eject.php'; + var url = "eject.php?id=" + encodeURIComponent(id) + "&file=" + encodeURIComponent(file); + window.location.href = url; } function insert_image(id,file){ if(confirm("Not implemented yet.... would insert " + file + " into " + id)) alert("OK"); } function add_device(id){ - if(confirm("Not implemented yet.... would add device id: " + id)) - alert("OK"); + var url = "add_device.php?id=" + encodeURIComponent(id); + window.location.href = url; } function remove_device(id){ - if(confirm("Not implemented yet.... would remove device id: " + id)) - alert("OK"); + confirm_message = "Are you sure you want to disconnect ID " + id + "? This may cause unexpected behavior on the host computer if it is still running"; + if(confirm(confirm_message)){ + var url = "disconnect.php?id=" + encodeURIComponent(id); + window.location.href=url; + } } function delete_file(f){ @@ -69,61 +72,6 @@ function delete_file(f){ ?>
-

Add New Device

-
- - - - - - - - - - -
SCSI ID: - - Device: - - File: - - - -
- - - - - -
- - -
-
-

Image File Management