Passed
Push — master ( 1df823...87c846 )
by Tony
01:27
created
src/php/rascsi.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@  discard block
 block discarded – undo
16 16
 
17 17
     <?php
18 18
 
19
-	include 'lib_rascsi.php';
20
-	html_generate_header();
21
-	current_rascsi_config();
19
+    include 'lib_rascsi.php';
20
+    html_generate_header();
21
+    current_rascsi_config();
22 22
 ?>
23 23
 
24 24
     <br>
@@ -34,23 +34,23 @@  discard block
 block discarded – undo
34 34
         </tr>
35 35
         <tr>
36 36
             <?php
37
-	// Generate the table with all of the file names in it.....
38
-	$all_files = get_all_files();
39
-	foreach(explode(PHP_EOL, $all_files) as $this_file){
40
-		if(strpos($this_file, 'total') === 0){
41
-			continue;
42
-		}
43
-		$file_name = file_name_from_ls($this_file);
44
-		if(strlen($file_name) === 0){
45
-			continue;
46
-		}
47
-		// Ignore file names that start with .
48
-		if(strpos($file_name,".") === 0){
49
-			continue;
50
-		}
51
-
52
-
53
-		echo '<tr>'.PHP_EOL;
37
+    // Generate the table with all of the file names in it.....
38
+    $all_files = get_all_files();
39
+    foreach(explode(PHP_EOL, $all_files) as $this_file){
40
+        if(strpos($this_file, 'total') === 0){
41
+            continue;
42
+        }
43
+        $file_name = file_name_from_ls($this_file);
44
+        if(strlen($file_name) === 0){
45
+            continue;
46
+        }
47
+        // Ignore file names that start with .
48
+        if(strpos($file_name,".") === 0){
49
+            continue;
50
+        }
51
+
52
+
53
+        echo '<tr>'.PHP_EOL;
54 54
         echo '    <td>SD Card</td>'.PHP_EOL;
55 55
         echo '    <td>'.$file_name.'</td>'.PHP_EOL;
56 56
         echo '    <td>'.file_size_from_ls($this_file).'</td>'.PHP_EOL;
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
         echo '       </form>'.PHP_EOL;
65 65
         echo '    </td>'.PHP_EOL;
66 66
         echo '</tr>'.PHP_EOL;
67
-	}
67
+    }
68 68
 ?>
69 69
     </table>
70 70
 
Please login to merge, or discard this patch.
src/php/rascsi_upload.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -11,74 +11,74 @@
 block discarded – undo
11 11
 
12 12
 <body>
13 13
     <?php
14
-	include 'lib_rascsi.php';
15
-	html_generate_header();
14
+    include 'lib_rascsi.php';
15
+    html_generate_header();
16 16
 
17
-   echo '<br>';
17
+    echo '<br>';
18 18
 
19
-   if($GLOBALS['DEBUG_ENABLE']){
20
-      echo '<table>'.PHP_EOL;
21
-      echo '  <tr><td><p style="color:gray">Debug stuff</p></td></tr>'.PHP_EOL;
22
-      echo '  <tr><td>';
19
+    if($GLOBALS['DEBUG_ENABLE']){
20
+        echo '<table>'.PHP_EOL;
21
+        echo '  <tr><td><p style="color:gray">Debug stuff</p></td></tr>'.PHP_EOL;
22
+        echo '  <tr><td>';
23 23
 
24
-      echo '<p style="color:gray">Post values......................'.PHP_EOL;
25
-      echo '<br> '.PHP_EOL;
26
-      var_dump($_POST);
27
-      echo '<br><br>'.PHP_EOL;
28
-      var_dump($_FILES);
29
-      echo '<br></p>'.PHP_EOL;
30
-      echo '</td></tr></table>';
31
-   }
24
+        echo '<p style="color:gray">Post values......................'.PHP_EOL;
25
+        echo '<br> '.PHP_EOL;
26
+        var_dump($_POST);
27
+        echo '<br><br>'.PHP_EOL;
28
+        var_dump($_FILES);
29
+        echo '<br></p>'.PHP_EOL;
30
+        echo '</td></tr></table>';
31
+    }
32 32
 
33
-   $target_dir = $GLOBALS['FILE_PATH'].'/';
34
-   $target_file = $target_dir.basename($_FILES['file_name']['name']);
35
-   $upload_ok=1;
36
-   $file_type = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
33
+    $target_dir = $GLOBALS['FILE_PATH'].'/';
34
+    $target_file = $target_dir.basename($_FILES['file_name']['name']);
35
+    $upload_ok=1;
36
+    $file_type = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
37 37
 
38
-	if(isset($_POST['submit']))
39
-	{
40
-      // Check if file already exists
41
-      if ($upload_ok && (file_exists($target_file))) {
42
-         html_generate_warning('Error: File '.$target_file.' already exists.');
43
-         $upload_ok = 0;
44
-      }
38
+    if(isset($_POST['submit']))
39
+    {
40
+        // Check if file already exists
41
+        if ($upload_ok && (file_exists($target_file))) {
42
+            html_generate_warning('Error: File '.$target_file.' already exists.');
43
+            $upload_ok = 0;
44
+        }
45 45
 
46
-      // Check file size. Limit is specified in lib_rascsi.php
47
-      if ($upload_ok && ($_FILES["file_name"]["size"] > $GLOBALS['MAX_UPLOAD_FILE_SIZE'])) {
48
-         html_generate_warning("Error: your file is larger than the maximum size of " . $GLOBALS['MAX_UPLOAD_FILE_SIZE'] . "bytes");
49
-         $upload_ok = 0;
50
-      }
46
+        // Check file size. Limit is specified in lib_rascsi.php
47
+        if ($upload_ok && ($_FILES["file_name"]["size"] > $GLOBALS['MAX_UPLOAD_FILE_SIZE'])) {
48
+            html_generate_warning("Error: your file is larger than the maximum size of " . $GLOBALS['MAX_UPLOAD_FILE_SIZE'] . "bytes");
49
+            $upload_ok = 0;
50
+        }
51 51
 
52
-      // Allow certain file formats, also specified in lib_rascsi.php
53
-      if($upload_ok && (!in_array(strtolower($file_type),$GLOBALS['ALLOWED_FILE_TYPES']))){
54
-         $error_string = 'File type "'. $file_type. '" is not currently allowed.'.
55
-         'Only the following file types are allowed: <br>'.
56
-         '<ul>'.PHP_EOL;
57
-         foreach($GLOBALS['ALLOWED_FILE_TYPES'] as $ft){
52
+        // Allow certain file formats, also specified in lib_rascsi.php
53
+        if($upload_ok && (!in_array(strtolower($file_type),$GLOBALS['ALLOWED_FILE_TYPES']))){
54
+            $error_string = 'File type "'. $file_type. '" is not currently allowed.'.
55
+            'Only the following file types are allowed: <br>'.
56
+            '<ul>'.PHP_EOL;
57
+            foreach($GLOBALS['ALLOWED_FILE_TYPES'] as $ft){
58 58
             $error_string = $error_string. '<li>'.$ft.'</li>'.PHP_EOL;
59
-         }
60
-         $error_string = $error_string.'</ul>';
61
-         $error_string = $error_string.'<br>';
62
-         html_generate_warning($error_string);
63
-         $upload_ok = 0;
64
-      }
59
+            }
60
+            $error_string = $error_string.'</ul>';
61
+            $error_string = $error_string.'<br>';
62
+            html_generate_warning($error_string);
63
+            $upload_ok = 0;
64
+        }
65 65
 
66
-   //Check if $upload_ok is set to 0 by an error
67
-   if ($upload_ok != 0) {
68
-      if (move_uploaded_file($_FILES["file_name"]["tmp_name"], $target_file)) {
69
-         html_generate_success_message(basename( $_FILES["file_name"]["name"]). " has been uploaded.");
70
-      } else {
71
-         html_generate_warning("There was an unknown error uploading your file.");
72
-      }
66
+    //Check if $upload_ok is set to 0 by an error
67
+    if ($upload_ok != 0) {
68
+        if (move_uploaded_file($_FILES["file_name"]["tmp_name"], $target_file)) {
69
+            html_generate_success_message(basename( $_FILES["file_name"]["name"]). " has been uploaded.");
70
+        } else {
71
+            html_generate_warning("There was an unknown error uploading your file.");
72
+        }
73
+    }
74
+    }
75
+    else
76
+    {
77
+        html_generate_warning('The Submit POST information was not populated. Something went wrong');
73 78
     }
74
-   }
75
-   else
76
-   {
77
-      html_generate_warning('The Submit POST information was not populated. Something went wrong');
78
-   }
79
-   echo '<br>';
79
+    echo '<br>';
80 80
 
81
-   html_generate_ok_to_go_home();
81
+    html_generate_ok_to_go_home();
82 82
 ?>
83 83
 
84 84
 </body>
Please login to merge, or discard this patch.
src/php/status.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -25,12 +25,12 @@
 block discarded – undo
25 25
 //     https://stackoverflow.com/questions/53695187/php-function-that-shows-status-of-systemctl-service
26 26
     $output = shell_exec("systemctl is-active rascsi");
27 27
     if (trim($output) == "active") {
28
-	    $color='green';
29
-	    $text='Running';
28
+        $color='green';
29
+        $text='Running';
30 30
     }
31 31
     else{
32
-	    $color='red';
33
-	    $text='Stopped';
32
+        $color='red';
33
+        $text='Stopped';
34 34
     }
35 35
 
36 36
     echo '<body style="background-color: '.$color.';">';
Please login to merge, or discard this patch.
src/php/rascsi_action.php 1 patch
Indentation   +232 added lines, -232 removed lines patch added patch discarded remove patch
@@ -11,283 +11,283 @@
 block discarded – undo
11 11
 
12 12
 <body>
13 13
     <?php
14
-	include 'lib_rascsi.php';
15
-	html_generate_header();
14
+    include 'lib_rascsi.php';
15
+    html_generate_header();
16 16
 
17
-   echo '<br>';
18
-   if($GLOBALS['DEBUG_ENABLE']){
19
-      echo '<table>'.PHP_EOL;
20
-      echo '  <tr><td><p style="color:gray">Debug stuff</p></td></tr>'.PHP_EOL;
21
-      echo '  <tr><td>';
17
+    echo '<br>';
18
+    if($GLOBALS['DEBUG_ENABLE']){
19
+        echo '<table>'.PHP_EOL;
20
+        echo '  <tr><td><p style="color:gray">Debug stuff</p></td></tr>'.PHP_EOL;
21
+        echo '  <tr><td>';
22 22
 
23
-      echo '<p style="color:gray">Post values......................'.PHP_EOL;
24
-      echo '<br> '.PHP_EOL;
25
-      var_dump($_POST);
26
-      echo '<br><br>Running command.... '.$_POST['command'].PHP_EOL;
27
-      echo '<br></p>'.PHP_EOL;
28
-      echo '</td></tr></table>';
29
-   }
23
+        echo '<p style="color:gray">Post values......................'.PHP_EOL;
24
+        echo '<br> '.PHP_EOL;
25
+        var_dump($_POST);
26
+        echo '<br><br>Running command.... '.$_POST['command'].PHP_EOL;
27
+        echo '<br></p>'.PHP_EOL;
28
+        echo '</td></tr></table>';
29
+    }
30 30
 
31
-	if(isset($_POST['command']))
32
-	{
33
-		switch(strtolower($_POST['command'])){
34
-			case "eject_disk":
35
-				action_eject_disk();
36
-				break;
37
-			case "remove_device":
38
-				action_remove_device();
39
-				break;
40
-			case "connect_new_device":
41
-				action_connect_new_device();
42
-				break;
43
-			case "insert_disk":
44
-				action_insert_disk();
45
-				break;
46
-			case "delete_file":
47
-				action_delete_file();
48
-				break;
49
-			case "create_new_image":
50
-				action_create_new_image();
51
-				break;
52
-			case "restart_rascsi_service":
53
-				action_restart_rascsi_service();
54
-				break;
55
-			case "stop_rascsi_service":
56
-				action_stop_rascsi_service();
57
-				break;
58
-			case "reboot_raspberry_pi":
59
-				action_reboot_raspberry_pi();
60
-				break;
61
-			case "shutdown_raspberry_pi":
62
-				action_shutdown_raspberry_pi();
63
-				break;
64
-			default:
65
-				action_unknown_command();
66
-				break;
67
-      }
68
-	}
69
-   else{
70
-      html_generate_warning("HTTP command was missing POST information. Are you trying to access this page directly? That won't work");
71
-      echo "<br>".PHP_EOL;
72
-      html_generate_ok_to_go_home();
73
-   }
31
+    if(isset($_POST['command']))
32
+    {
33
+        switch(strtolower($_POST['command'])){
34
+            case "eject_disk":
35
+                action_eject_disk();
36
+                break;
37
+            case "remove_device":
38
+                action_remove_device();
39
+                break;
40
+            case "connect_new_device":
41
+                action_connect_new_device();
42
+                break;
43
+            case "insert_disk":
44
+                action_insert_disk();
45
+                break;
46
+            case "delete_file":
47
+                action_delete_file();
48
+                break;
49
+            case "create_new_image":
50
+                action_create_new_image();
51
+                break;
52
+            case "restart_rascsi_service":
53
+                action_restart_rascsi_service();
54
+                break;
55
+            case "stop_rascsi_service":
56
+                action_stop_rascsi_service();
57
+                break;
58
+            case "reboot_raspberry_pi":
59
+                action_reboot_raspberry_pi();
60
+                break;
61
+            case "shutdown_raspberry_pi":
62
+                action_shutdown_raspberry_pi();
63
+                break;
64
+            default:
65
+                action_unknown_command();
66
+                break;
67
+        }
68
+    }
69
+    else{
70
+        html_generate_warning("HTTP command was missing POST information. Are you trying to access this page directly? That won't work");
71
+        echo "<br>".PHP_EOL;
72
+        html_generate_ok_to_go_home();
73
+    }
74 74
 
75 75
 function action_eject_disk(){
76
-   $command = 'rasctl -i '.$_POST['id'].' -c eject 2>&1'.PHP_EOL;
77
-   exec($command, $retArray, $result);
78
-   check_result($result, $command,$retArray);
79
-   html_generate_ok_to_go_home();
76
+    $command = 'rasctl -i '.$_POST['id'].' -c eject 2>&1'.PHP_EOL;
77
+    exec($command, $retArray, $result);
78
+    check_result($result, $command,$retArray);
79
+    html_generate_ok_to_go_home();
80 80
 }
81 81
 
82 82
 function action_remove_device(){
83
-	// Check to see if the user has confirmed
84
-	if(isset($_POST['confirmed'])){
85
-		$command = 'rasctl -i '.$_POST['id'].' -c disconnect 2>&1'.PHP_EOL;
86
-		exec($command, $retArray, $result);
87
-		check_result($result, $command,$retArray);
88
-		html_generate_ok_to_go_home();
89
-	}
90
-	else{
91
-		check_are_you_sure('Are you sure you want to disconnect SCSI ID ' . $_POST['id'].'? If the host is running, this could cause undesirable behavior.');
92
-	}
83
+    // Check to see if the user has confirmed
84
+    if(isset($_POST['confirmed'])){
85
+        $command = 'rasctl -i '.$_POST['id'].' -c disconnect 2>&1'.PHP_EOL;
86
+        exec($command, $retArray, $result);
87
+        check_result($result, $command,$retArray);
88
+        html_generate_ok_to_go_home();
89
+    }
90
+    else{
91
+        check_are_you_sure('Are you sure you want to disconnect SCSI ID ' . $_POST['id'].'? If the host is running, this could cause undesirable behavior.');
92
+    }
93 93
 }
94 94
 // function action_connect_new_device(){}
95 95
 function action_insert_disk(){
96
-   $command = 'rasctl -i '.$_POST['id'].' -c insert -f '.$GLOBALS['FILE_PATH'].'/'.$_POST['file_name'].' 2>&1'.PHP_EOL;
97
-   exec($command, $retArray, $result);
98
-   check_result($result, $command,$retArray);
99
-   html_generate_ok_to_go_home();
96
+    $command = 'rasctl -i '.$_POST['id'].' -c insert -f '.$GLOBALS['FILE_PATH'].'/'.$_POST['file_name'].' 2>&1'.PHP_EOL;
97
+    exec($command, $retArray, $result);
98
+    check_result($result, $command,$retArray);
99
+    html_generate_ok_to_go_home();
100 100
 }
101 101
 function action_create_new_image(){
102
-	// If we already know the size & filename, we can go create the image...
103
-	if(isset($_POST['size']) && isset($_POST['file_name'])){
104
-		$command = 'dd if=/dev/zero of='.$GLOBALS['FILE_PATH'].'/'.$_POST['file_name'].' bs=1M count='.$_POST['size'];
105
-		exec($command, $retArray, $result);
106
-		check_result($result, $command, $retArray);
107
-		html_generate_ok_to_go_home();
108
-	}
109
-	else{
110
-		echo '<h2>Create a new empty file</h2>'.PHP_EOL;
111
-		echo '<form action=rascsi_action.php method="post">'.PHP_EOL;
112
-		echo '   <input type="hidden" name="command" value="'.$_POST['command'].'"/>'.PHP_EOL;
113
-		echo '   <table style="border: none">'.PHP_EOL;
114
-		echo '       <tr style="border: none">'.PHP_EOL;
115
-		echo '           <td style="border: none">File Name:</td>'.PHP_EOL;
116
-		echo '           <td style="border: none">'.PHP_EOL;
117
-		echo '              <input type="text" name=file_name value="'.get_new_filename().'"/>'.PHP_EOL;
118
-		echo '           </td>'.PHP_EOL;
119
-		echo '           <td style="border: none">  Size:</td>'.PHP_EOL;
120
-		echo '           <td style="border: none">'.PHP_EOL;
121
-		echo '              <input type="number" name=size value="10""/>'.PHP_EOL;
122
-		echo '           </td>'.PHP_EOL;
123
-		echo '           <td style="border: none">MB</td>'.PHP_EOL;
124
-		echo '           <td style="border: none">'.PHP_EOL;
125
-		echo '              <input type="submit" name="create" value="Create New" />'.PHP_EOL;
126
-		echo '           </td>'.PHP_EOL;
127
-		echo '      </tr>'.PHP_EOL;
128
-		echo '   </table>'.PHP_EOL;
129
-		echo '</form>'.PHP_EOL;
130
-		echo '<br><i>Note: Creating a large file may take a long time!</i>'.PHP_EOL;
131
-		echo '<br><br>'.PHP_EOL;
132
-		echo '<form action="rascsi.php" method="post">'.PHP_EOL;
133
-		echo '   <input type="submit" name="cancel" value="Cancel" />'.PHP_EOL;
134
-		echo '</form>'.PHP_EOL;
135
-	}
102
+    // If we already know the size & filename, we can go create the image...
103
+    if(isset($_POST['size']) && isset($_POST['file_name'])){
104
+        $command = 'dd if=/dev/zero of='.$GLOBALS['FILE_PATH'].'/'.$_POST['file_name'].' bs=1M count='.$_POST['size'];
105
+        exec($command, $retArray, $result);
106
+        check_result($result, $command, $retArray);
107
+        html_generate_ok_to_go_home();
108
+    }
109
+    else{
110
+        echo '<h2>Create a new empty file</h2>'.PHP_EOL;
111
+        echo '<form action=rascsi_action.php method="post">'.PHP_EOL;
112
+        echo '   <input type="hidden" name="command" value="'.$_POST['command'].'"/>'.PHP_EOL;
113
+        echo '   <table style="border: none">'.PHP_EOL;
114
+        echo '       <tr style="border: none">'.PHP_EOL;
115
+        echo '           <td style="border: none">File Name:</td>'.PHP_EOL;
116
+        echo '           <td style="border: none">'.PHP_EOL;
117
+        echo '              <input type="text" name=file_name value="'.get_new_filename().'"/>'.PHP_EOL;
118
+        echo '           </td>'.PHP_EOL;
119
+        echo '           <td style="border: none">  Size:</td>'.PHP_EOL;
120
+        echo '           <td style="border: none">'.PHP_EOL;
121
+        echo '              <input type="number" name=size value="10""/>'.PHP_EOL;
122
+        echo '           </td>'.PHP_EOL;
123
+        echo '           <td style="border: none">MB</td>'.PHP_EOL;
124
+        echo '           <td style="border: none">'.PHP_EOL;
125
+        echo '              <input type="submit" name="create" value="Create New" />'.PHP_EOL;
126
+        echo '           </td>'.PHP_EOL;
127
+        echo '      </tr>'.PHP_EOL;
128
+        echo '   </table>'.PHP_EOL;
129
+        echo '</form>'.PHP_EOL;
130
+        echo '<br><i>Note: Creating a large file may take a long time!</i>'.PHP_EOL;
131
+        echo '<br><br>'.PHP_EOL;
132
+        echo '<form action="rascsi.php" method="post">'.PHP_EOL;
133
+        echo '   <input type="submit" name="cancel" value="Cancel" />'.PHP_EOL;
134
+        echo '</form>'.PHP_EOL;
135
+    }
136 136
 }
137 137
 
138 138
 function action_delete_file(){
139
-	// Check to see if the user has confirmed
140
-	if(isset($_POST['confirmed'])){
141
-		$command = 'rm '.$GLOBALS['FILE_PATH'].'/'.$_POST['file_name'];
142
-		exec($command, $retArray, $result);
143
-		check_result($result, $command, $retArray);
144
-		html_generate_ok_to_go_home();
145
-	}
146
-	else{
147
-		check_are_you_sure('Are you sure you want to PERMANENTLY delete '.$_POST['file_name'].'?');
148
-	}
139
+    // Check to see if the user has confirmed
140
+    if(isset($_POST['confirmed'])){
141
+        $command = 'rm '.$GLOBALS['FILE_PATH'].'/'.$_POST['file_name'];
142
+        exec($command, $retArray, $result);
143
+        check_result($result, $command, $retArray);
144
+        html_generate_ok_to_go_home();
145
+    }
146
+    else{
147
+        check_are_you_sure('Are you sure you want to PERMANENTLY delete '.$_POST['file_name'].'?');
148
+    }
149 149
 }
150 150
 
151 151
 function action_restart_rascsi_service(){
152
-	// Restart the RaSCSI service
153
-	$command = "sudo /bin/systemctl restart rascsi.service 2>&1";
154
-	exec($command, $retArray, $result);
155
-	check_result($result, $command,$retArray);
156
-	html_generate_ok_to_go_home();
152
+    // Restart the RaSCSI service
153
+    $command = "sudo /bin/systemctl restart rascsi.service 2>&1";
154
+    exec($command, $retArray, $result);
155
+    check_result($result, $command,$retArray);
156
+    html_generate_ok_to_go_home();
157 157
 }
158 158
 
159 159
 function action_stop_rascsi_service(){
160
-	// Stop the RaSCSI service
161
-	$command = "sudo /bin/systemctl stop rascsi.service 2>&1";
162
-	exec($command, $retArray, $result);
163
-	check_result($result, $command,$retArray);
164
-	html_generate_ok_to_go_home();
160
+    // Stop the RaSCSI service
161
+    $command = "sudo /bin/systemctl stop rascsi.service 2>&1";
162
+    exec($command, $retArray, $result);
163
+    check_result($result, $command,$retArray);
164
+    html_generate_ok_to_go_home();
165 165
 }
166 166
 
167 167
 function action_reboot_raspberry_pi(){
168
-	// Check to see if the user has confirmed
169
-	if(isset($_POST['confirmed'])){
170
-      $command = "sleep 2 && sudo reboot 2>&1";
171
-      exec($command, $retArray, $result);
172
-      // The unit should reboot at this point. Doesn't matter what we do now...
173
-      check_result($result, $command,$retArray);
174
-		html_generate_ok_to_go_home();
175
-	}
176
-	else{
177
-		check_are_you_sure("Are you sure you want to reboot the Raspberry Pi?");
178
-	}
168
+    // Check to see if the user has confirmed
169
+    if(isset($_POST['confirmed'])){
170
+        $command = "sleep 2 && sudo reboot 2>&1";
171
+        exec($command, $retArray, $result);
172
+        // The unit should reboot at this point. Doesn't matter what we do now...
173
+        check_result($result, $command,$retArray);
174
+        html_generate_ok_to_go_home();
175
+    }
176
+    else{
177
+        check_are_you_sure("Are you sure you want to reboot the Raspberry Pi?");
178
+    }
179 179
 }
180 180
 
181 181
 function action_shutdown_raspberry_pi(){
182
-	// Check to see if the user has confirmed
183
-	if(isset($_POST['confirmed'])){
184
-      $command = "sleep 2 && sudo shutdown -h now 2>&1";
185
-      exec($command, $retArray, $result);
186
-      // The unit should shutdown at this point. Doesn't matter what we do now...
187
-      check_result($result, $command,$retArray);
188
-		html_generate_ok_to_go_home();
189
-	}
190
-	else{
191
-		check_are_you_sure("Are you sure you want to shut down the Raspberry Pi?");
192
-	}
182
+    // Check to see if the user has confirmed
183
+    if(isset($_POST['confirmed'])){
184
+        $command = "sleep 2 && sudo shutdown -h now 2>&1";
185
+        exec($command, $retArray, $result);
186
+        // The unit should shutdown at this point. Doesn't matter what we do now...
187
+        check_result($result, $command,$retArray);
188
+        html_generate_ok_to_go_home();
189
+    }
190
+    else{
191
+        check_are_you_sure("Are you sure you want to shut down the Raspberry Pi?");
192
+    }
193 193
 }
194 194
 
195 195
 function action_unknown_command(){
196
-	html_generate_warning('<br><h2>Unknown command: '.$_POST['command'].'</h2>');
197
-	html_generate_ok_to_go_home();
196
+    html_generate_warning('<br><h2>Unknown command: '.$_POST['command'].'</h2>');
197
+    html_generate_ok_to_go_home();
198 198
 }
199 199
 
200 200
 function check_result($result,$command,$output){
201
-	if(!$result){
202
-		html_generate_success_message('Command succeeded!');
203
-	}
204
-	else{
205
-      html_generate_warning('Command failed!');
206
-	}
207
-	echo '<br><code>'.$command.'</code><br>'.PHP_EOL;
208
-	if(count($output) > 0){
209
-		echo '<br>Output:<code>'.PHP_EOL;
210
-		foreach($output as $line){
211
-			echo '<br> Error message: '.$line.PHP_EOL;
212
-		}
213
-		echo '</code>'.PHP_EOL;
214
-	}
201
+    if(!$result){
202
+        html_generate_success_message('Command succeeded!');
203
+    }
204
+    else{
205
+        html_generate_warning('Command failed!');
206
+    }
207
+    echo '<br><code>'.$command.'</code><br>'.PHP_EOL;
208
+    if(count($output) > 0){
209
+        echo '<br>Output:<code>'.PHP_EOL;
210
+        foreach($output as $line){
211
+            echo '<br> Error message: '.$line.PHP_EOL;
212
+        }
213
+        echo '</code>'.PHP_EOL;
214
+    }
215 215
 }
216 216
 
217 217
 function check_are_you_sure($prompt){
218
-	echo '<br><h2>'.$prompt.'</h2>'.PHP_EOL;
219
-	echo '      <table style="border: none">'.PHP_EOL;
220
-	echo '      <tr style="border: none">'.PHP_EOL;
221
-	echo '      <td style="border: none; vertical-align:top;">'.PHP_EOL;
222
-	echo '      	<form action="rascsi_action.php" method="post">'.PHP_EOL;
223
-	foreach($_POST as $key => $value){
224
-		echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>'.PHP_EOL;
225
-	}
226
-	echo '      		<input type="hidden" name="confirmed" value="yes" />'.PHP_EOL;
227
-	echo '      		<input type="submit" name="do_it" value="Yes" />'.PHP_EOL;
228
-	echo '      	</form>'.PHP_EOL;
229
-	echo '      </td>'.PHP_EOL;
230
-	echo '    	<td style="border: none; vertical-align:top;">'.PHP_EOL;
231
-	echo '      	<form action="rascsi.php" method="post">'.PHP_EOL;
232
-	echo '      		<input type="submit" name="cancel" value="Cancel" />'.PHP_EOL;
233
-	echo '      	</form>'.PHP_EOL;
234
-	echo '      </td>'.PHP_EOL;
235
-	echo '   </tr>'.PHP_EOL;
236
-	echo '</table>'.PHP_EOL;
218
+    echo '<br><h2>'.$prompt.'</h2>'.PHP_EOL;
219
+    echo '      <table style="border: none">'.PHP_EOL;
220
+    echo '      <tr style="border: none">'.PHP_EOL;
221
+    echo '      <td style="border: none; vertical-align:top;">'.PHP_EOL;
222
+    echo '      	<form action="rascsi_action.php" method="post">'.PHP_EOL;
223
+    foreach($_POST as $key => $value){
224
+        echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>'.PHP_EOL;
225
+    }
226
+    echo '      		<input type="hidden" name="confirmed" value="yes" />'.PHP_EOL;
227
+    echo '      		<input type="submit" name="do_it" value="Yes" />'.PHP_EOL;
228
+    echo '      	</form>'.PHP_EOL;
229
+    echo '      </td>'.PHP_EOL;
230
+    echo '    	<td style="border: none; vertical-align:top;">'.PHP_EOL;
231
+    echo '      	<form action="rascsi.php" method="post">'.PHP_EOL;
232
+    echo '      		<input type="submit" name="cancel" value="Cancel" />'.PHP_EOL;
233
+    echo '      	</form>'.PHP_EOL;
234
+    echo '      </td>'.PHP_EOL;
235
+    echo '   </tr>'.PHP_EOL;
236
+    echo '</table>'.PHP_EOL;
237 237
 }
238 238
 
239 239
 function action_connect_new_device(){
240
-	// If we already know the type & filename, we can go connect the device...
241
-	if(isset($_POST['type']) && isset($_POST['file_name'])){
242
-		$command = 'rasctl -i '.$_POST['id'].' -c attach -t '.type_string_to_rasctl_type($_POST['type']);
243
-		if($_POST['file_name'] != "None"){
244
-			$command = $command.' -f '.$GLOBALS['FILE_PATH'].'/'.$_POST['file_name'];
245
-		}
246
-		exec($command, $retArray, $result);
247
-		check_result($result, $command, $retArray);
248
-		html_generate_ok_to_go_home();
249
-	}
250
-	else{
240
+    // If we already know the type & filename, we can go connect the device...
241
+    if(isset($_POST['type']) && isset($_POST['file_name'])){
242
+        $command = 'rasctl -i '.$_POST['id'].' -c attach -t '.type_string_to_rasctl_type($_POST['type']);
243
+        if($_POST['file_name'] != "None"){
244
+            $command = $command.' -f '.$GLOBALS['FILE_PATH'].'/'.$_POST['file_name'];
245
+        }
246
+        exec($command, $retArray, $result);
247
+        check_result($result, $command, $retArray);
248
+        html_generate_ok_to_go_home();
249
+    }
250
+    else{
251 251
 
252 252
 
253
-	$id = $_POST['id'];
254
-		echo '<h2>Add New Device</h2>'.PHP_EOL;
255
-		echo '<form action=rascsi_action.php method="post">'.PHP_EOL;
256
-		echo '   <input type="hidden" name="command" value="'.$_POST['command'].'"/>'.PHP_EOL;
257
-		echo '   <table style="border: none">'.PHP_EOL;
258
-		echo '       <tr style="border: none">'.PHP_EOL;
259
-		echo '           <td style="border: none">SCSI ID:</td>'.PHP_EOL;
260
-		echo '           <td style="border: none">'.PHP_EOL;
261
-		echo '           <input type="hidden" name=id value="'.$id.'"/>'.PHP_EOL;
262
-		echo $id;
263
-		echo '           </td>'.PHP_EOL;
264
-		echo '           <td style="border: none">Device:</td>'.PHP_EOL;
265
-		echo '           <td style="border: none">'.PHP_EOL;
266
-		html_generate_scsi_type_select_list();
267
-		echo '           </td>'.PHP_EOL;
268
-		echo '           <td style="border: none">File:</td>'.PHP_EOL;
269
-		echo '           <td style="border: none">'.PHP_EOL;
270
-		echo '               <select name="file_name">'.PHP_EOL;
271
-		echo '                  <option value="None">None</option>'.PHP_EOL;
272
-      html_generate_image_file_select_list();
273
-		echo '             </select>'.PHP_EOL;
274
-		echo '          </td>'.PHP_EOL;
275
-		echo '          <td style="border: none">'.PHP_EOL;
276
-		echo '               <INPUT type="submit" value="Add"/>'.PHP_EOL;
277
-		echo '          </td>'.PHP_EOL;
278
-		echo '       </tr>'.PHP_EOL;
279
-		echo '   </table>'.PHP_EOL;
280
-	}
253
+    $id = $_POST['id'];
254
+        echo '<h2>Add New Device</h2>'.PHP_EOL;
255
+        echo '<form action=rascsi_action.php method="post">'.PHP_EOL;
256
+        echo '   <input type="hidden" name="command" value="'.$_POST['command'].'"/>'.PHP_EOL;
257
+        echo '   <table style="border: none">'.PHP_EOL;
258
+        echo '       <tr style="border: none">'.PHP_EOL;
259
+        echo '           <td style="border: none">SCSI ID:</td>'.PHP_EOL;
260
+        echo '           <td style="border: none">'.PHP_EOL;
261
+        echo '           <input type="hidden" name=id value="'.$id.'"/>'.PHP_EOL;
262
+        echo $id;
263
+        echo '           </td>'.PHP_EOL;
264
+        echo '           <td style="border: none">Device:</td>'.PHP_EOL;
265
+        echo '           <td style="border: none">'.PHP_EOL;
266
+        html_generate_scsi_type_select_list();
267
+        echo '           </td>'.PHP_EOL;
268
+        echo '           <td style="border: none">File:</td>'.PHP_EOL;
269
+        echo '           <td style="border: none">'.PHP_EOL;
270
+        echo '               <select name="file_name">'.PHP_EOL;
271
+        echo '                  <option value="None">None</option>'.PHP_EOL;
272
+        html_generate_image_file_select_list();
273
+        echo '             </select>'.PHP_EOL;
274
+        echo '          </td>'.PHP_EOL;
275
+        echo '          <td style="border: none">'.PHP_EOL;
276
+        echo '               <INPUT type="submit" value="Add"/>'.PHP_EOL;
277
+        echo '          </td>'.PHP_EOL;
278
+        echo '       </tr>'.PHP_EOL;
279
+        echo '   </table>'.PHP_EOL;
280
+    }
281 281
 }
282 282
 
283 283
 function get_new_filename(){
284
-	// Try to find a new file name that doesn't exist.
285
-	$i=1;
286
-	while(file_exists($GLOBALS['FILE_PATH'].'/'.'new_file'.$i.'.hda'))
287
-	{
288
-		$i = $i+1;
289
-	}
290
-	return 'new_file'.$i.'.hda';
284
+    // Try to find a new file name that doesn't exist.
285
+    $i=1;
286
+    while(file_exists($GLOBALS['FILE_PATH'].'/'.'new_file'.$i.'.hda'))
287
+    {
288
+        $i = $i+1;
289
+    }
290
+    return 'new_file'.$i.'.hda';
291 291
 }
292 292
 
293 293
 ?>
Please login to merge, or discard this patch.
src/php/lib_rascsi.php 1 patch
Indentation   +158 added lines, -158 removed lines patch added patch discarded remove patch
@@ -13,107 +13,107 @@  discard block
 block discarded – undo
13 13
 $ALLOWED_FILE_TYPES=array('iso','hda');
14 14
 
15 15
 function html_generate_header(){
16
-	echo '    <table width="100%" >'. PHP_EOL;
17
-	echo '        <tr style="background-color: black;">'. PHP_EOL;
18
-	echo '          <td style="background-color: black;"><a href=http://github.com/akuker/RASCSI><h1>RaSCSI - 68kmla Edition</h1></a></td>'. PHP_EOL;
19
-	echo '          <td style="background-color: black;">'. PHP_EOL;
20
-	echo '                <form action="rascsi.php">'. PHP_EOL;
21
-   echo '                    <input type="submit" value="Go Home"/>'. PHP_EOL;
22
-   if($GLOBALS['DEBUG_ENABLE']){
23
-      echo '                    <p style="color:#595959">Debug Timestamp: '.time().'</p>'. PHP_EOL;
24
-   }
25
-	echo '                </form>'. PHP_EOL;
26
-	echo '          </td>'. PHP_EOL;
27
-	echo '        </tr>'. PHP_EOL;
28
-	echo '    </table>'. PHP_EOL;
29
-	//echo(exec('whoami'));
16
+    echo '    <table width="100%" >'. PHP_EOL;
17
+    echo '        <tr style="background-color: black;">'. PHP_EOL;
18
+    echo '          <td style="background-color: black;"><a href=http://github.com/akuker/RASCSI><h1>RaSCSI - 68kmla Edition</h1></a></td>'. PHP_EOL;
19
+    echo '          <td style="background-color: black;">'. PHP_EOL;
20
+    echo '                <form action="rascsi.php">'. PHP_EOL;
21
+    echo '                    <input type="submit" value="Go Home"/>'. PHP_EOL;
22
+    if($GLOBALS['DEBUG_ENABLE']){
23
+        echo '                    <p style="color:#595959">Debug Timestamp: '.time().'</p>'. PHP_EOL;
24
+    }
25
+    echo '                </form>'. PHP_EOL;
26
+    echo '          </td>'. PHP_EOL;
27
+    echo '        </tr>'. PHP_EOL;
28
+    echo '    </table>'. PHP_EOL;
29
+    //echo(exec('whoami'));
30 30
 }
31 31
 
32 32
 function html_generate_image_file_select_list(){
33
-   $all_files = get_all_files();
34
-   foreach(explode(PHP_EOL, $all_files) as $this_file){
35
-         if(strpos($this_file, 'total') === 0){
36
-               continue;
37
-         }
38
-         $file_name = file_name_from_ls($this_file);
39
-         if(strlen($file_name) === 0){
40
-               continue;
41
-         }
42
-         // Ignore files that start with a .
43
-         if(strpos($file_name, '.') === 0){
44
-               continue;
45
-         }
33
+    $all_files = get_all_files();
34
+    foreach(explode(PHP_EOL, $all_files) as $this_file){
35
+            if(strpos($this_file, 'total') === 0){
36
+                continue;
37
+            }
38
+            $file_name = file_name_from_ls($this_file);
39
+            if(strlen($file_name) === 0){
40
+                continue;
41
+            }
42
+            // Ignore files that start with a .
43
+            if(strpos($file_name, '.') === 0){
44
+                continue;
45
+            }
46 46
 
47
-         echo '<option value="'.$file_name.'">'.$file_name.'</option>'.PHP_EOL;
48
-   }
47
+            echo '<option value="'.$file_name.'">'.$file_name.'</option>'.PHP_EOL;
48
+    }
49 49
 }
50 50
 
51 51
 
52 52
 function html_generate_scsi_id_select_list(){
53
-	echo '<select>'. PHP_EOL;
54
-	foreach(range(0,7) as $id){
55
-		echo '<option value="'.$id.'">'.$id.'</option>'. PHP_EOL;
56
-	}
57
-	echo '</select>'. PHP_EOL;
53
+    echo '<select>'. PHP_EOL;
54
+    foreach(range(0,7) as $id){
55
+        echo '<option value="'.$id.'">'.$id.'</option>'. PHP_EOL;
56
+    }
57
+    echo '</select>'. PHP_EOL;
58 58
 }
59 59
 
60 60
 function html_generate_scsi_type_select_list(){
61
-	echo '<select name=type>'. PHP_EOL;
62
-	$options = array("Hard Disk", "CD-ROM", "Zip Drive", "Ethernet Tap", "Filesystem Bridge");
63
-	foreach($options as $type){
64
-		echo '<option value="'.$type.'">'.$type.'</option>'. PHP_EOL;
65
-	}
66
-	echo '</select>'. PHP_EOL;
61
+    echo '<select name=type>'. PHP_EOL;
62
+    $options = array("Hard Disk", "CD-ROM", "Zip Drive", "Ethernet Tap", "Filesystem Bridge");
63
+    foreach($options as $type){
64
+        echo '<option value="'.$type.'">'.$type.'</option>'. PHP_EOL;
65
+    }
66
+    echo '</select>'. PHP_EOL;
67 67
 }
68 68
 
69 69
 function html_generate_warning($message){
70
-	echo '    <table width="100%" >'. PHP_EOL;
71
-	echo '        <tr style="background-color: red;">'. PHP_EOL;
72
-	echo '          <td style="background-color: red;">'. PHP_EOL;
73
-	echo '              <font size=+2>'.$message.'</font>'. PHP_EOL;
74
-	echo '         </td>'. PHP_EOL;
75
-	echo '        </tr>'. PHP_EOL;
76
-	echo '    </table>'. PHP_EOL;
70
+    echo '    <table width="100%" >'. PHP_EOL;
71
+    echo '        <tr style="background-color: red;">'. PHP_EOL;
72
+    echo '          <td style="background-color: red;">'. PHP_EOL;
73
+    echo '              <font size=+2>'.$message.'</font>'. PHP_EOL;
74
+    echo '         </td>'. PHP_EOL;
75
+    echo '        </tr>'. PHP_EOL;
76
+    echo '    </table>'. PHP_EOL;
77 77
 }
78 78
 
79 79
 function html_generate_success_message($message){
80
-	echo '    <table width="100%" >'. PHP_EOL;
81
-	echo '        <tr style="background-color: green;">'. PHP_EOL;
82
-	echo '          <td style="background-color: green;">'. PHP_EOL;
83
-   echo '              <font size=+2>Success</font>'. PHP_EOL;
84
-	echo '         </td>'. PHP_EOL;
85
-   echo '        </tr>'. PHP_EOL;
86
-   if(strlen($message) > 0){
87
-      echo '        <tr style="background-color: green;">'. PHP_EOL;
88
-      echo '          <td style="background-color: green;">'. PHP_EOL;
89
-      echo '              '.$message.PHP_EOL;
90
-      echo '         </td>'. PHP_EOL;
91
-      echo '        </tr>'. PHP_EOL;
92
-   }
93
-	echo '    </table>'. PHP_EOL;
80
+    echo '    <table width="100%" >'. PHP_EOL;
81
+    echo '        <tr style="background-color: green;">'. PHP_EOL;
82
+    echo '          <td style="background-color: green;">'. PHP_EOL;
83
+    echo '              <font size=+2>Success</font>'. PHP_EOL;
84
+    echo '         </td>'. PHP_EOL;
85
+    echo '        </tr>'. PHP_EOL;
86
+    if(strlen($message) > 0){
87
+        echo '        <tr style="background-color: green;">'. PHP_EOL;
88
+        echo '          <td style="background-color: green;">'. PHP_EOL;
89
+        echo '              '.$message.PHP_EOL;
90
+        echo '         </td>'. PHP_EOL;
91
+        echo '        </tr>'. PHP_EOL;
92
+    }
93
+    echo '    </table>'. PHP_EOL;
94 94
 }
95 95
 
96 96
 function html_generate_ok_to_go_home(){
97
-	echo '   <form action="rascsi.php">'. PHP_EOL;
98
-	echo '       <input type="submit" value="OK"/>'. PHP_EOL;
99
-	echo '   </form>'. PHP_EOL;
97
+    echo '   <form action="rascsi.php">'. PHP_EOL;
98
+    echo '       <input type="submit" value="OK"/>'. PHP_EOL;
99
+    echo '   </form>'. PHP_EOL;
100 100
 }
101 101
 
102 102
 
103 103
 function current_rascsi_config() {
104
-	$raw_output = shell_exec("/usr/local/bin/rasctl -l");
105
-	$rasctl_lines = explode(PHP_EOL, $raw_output);
104
+    $raw_output = shell_exec("/usr/local/bin/rasctl -l");
105
+    $rasctl_lines = explode(PHP_EOL, $raw_output);
106 106
 
107
-	echo '      <br>'. PHP_EOL;
108
-	echo '      <h2>Current RaSCSI Configuration</h2>'. PHP_EOL;
109
-	echo '      <table border="black" cellpadding="3">'. PHP_EOL;
110
-	echo '          <tr>'. PHP_EOL;
111
-	echo '              <td><b>SCSI ID</b></td>'. PHP_EOL;
112
-	echo ' 	             <td><b>Type</b></td>'. PHP_EOL;
113
-	echo '             <td><b>File</b></td>'. PHP_EOL;
114
-	echo '              <td><b>File Ops</b></td>'. PHP_EOL;
115
-	echo '              <td><b>Device Ops</b></td>'. PHP_EOL;
116
-	echo '          </tr>'. PHP_EOL;
107
+    echo '      <br>'. PHP_EOL;
108
+    echo '      <h2>Current RaSCSI Configuration</h2>'. PHP_EOL;
109
+    echo '      <table border="black" cellpadding="3">'. PHP_EOL;
110
+    echo '          <tr>'. PHP_EOL;
111
+    echo '              <td><b>SCSI ID</b></td>'. PHP_EOL;
112
+    echo ' 	             <td><b>Type</b></td>'. PHP_EOL;
113
+    echo '             <td><b>File</b></td>'. PHP_EOL;
114
+    echo '              <td><b>File Ops</b></td>'. PHP_EOL;
115
+    echo '              <td><b>Device Ops</b></td>'. PHP_EOL;
116
+    echo '          </tr>'. PHP_EOL;
117 117
 
118 118
         $scsi_ids = array();
119 119
 
@@ -141,117 +141,117 @@  discard block
 block discarded – undo
141 141
 
142 142
 
143 143
         foreach (range(0,7) as $id){
144
-               echo '         <tr>'. PHP_EOL;
145
-               echo '                 <td style="text-align:center">'.$id.'</td>'. PHP_EOL;
146
-               if(isset($scsi_ids[$id]))
147
-               {
148
-                  echo '    <td style="text-align:center">'.$scsi_ids[$id]['type'].'</td>'. PHP_EOL;
149
-                  if(strtolower($scsi_ids[$id]['file']) == "no media"){
150
-                     echo '   <td>'.PHP_EOL;
151
-                     echo '      <form action="rascsi_action.php" method="post">'. PHP_EOL;
152
-                     echo '         <select name="file_name">'.PHP_EOL;
153
-                     echo '            <option value="None">None</option>'.PHP_EOL;
154
-                     html_generate_image_file_select_list();
155
-                     echo '         </select>'.PHP_EOL;
156
-                     echo '         <input type="hidden" name="command" value="insert_disk" />'. PHP_EOL;
157
-                     echo '         <input type="hidden" name="id" value="'.$id.'" />'. PHP_EOL;
158
-                     echo '         <input type="hidden" name="file" value="'.$scsi_ids[$id]['file'].'" />'. PHP_EOL;
159
-                     echo '   </td><td>'.PHP_EOL;
160
-                     echo '         <input type="submit" name="insert_disk" value="Insert" />'. PHP_EOL;
161
-                     echo '      </form>'. PHP_EOL;
162
-                     echo '   </td>'.PHP_EOL;
163
-                  }
164
-                  else{
165
-                     // rascsi inserts "WRITEPROTECT" for the read-only drives. We want to display that differently.
166
-                     echo '   <form action="rascsi_action.php" method="post">'. PHP_EOL;
167
-                     echo '      <td>'.str_replace('(WRITEPROTECT)', '', $scsi_ids[$id]['file']). PHP_EOL;
168
-                     echo '   </td><td>'.PHP_EOL;
169
-                     if(strtolower($scsi_ids[$id]['type']) == 'sccd'){
144
+                echo '         <tr>'. PHP_EOL;
145
+                echo '                 <td style="text-align:center">'.$id.'</td>'. PHP_EOL;
146
+                if(isset($scsi_ids[$id]))
147
+                {
148
+                    echo '    <td style="text-align:center">'.$scsi_ids[$id]['type'].'</td>'. PHP_EOL;
149
+                    if(strtolower($scsi_ids[$id]['file']) == "no media"){
150
+                        echo '   <td>'.PHP_EOL;
151
+                        echo '      <form action="rascsi_action.php" method="post">'. PHP_EOL;
152
+                        echo '         <select name="file_name">'.PHP_EOL;
153
+                        echo '            <option value="None">None</option>'.PHP_EOL;
154
+                        html_generate_image_file_select_list();
155
+                        echo '         </select>'.PHP_EOL;
156
+                        echo '         <input type="hidden" name="command" value="insert_disk" />'. PHP_EOL;
157
+                        echo '         <input type="hidden" name="id" value="'.$id.'" />'. PHP_EOL;
158
+                        echo '         <input type="hidden" name="file" value="'.$scsi_ids[$id]['file'].'" />'. PHP_EOL;
159
+                        echo '   </td><td>'.PHP_EOL;
160
+                        echo '         <input type="submit" name="insert_disk" value="Insert" />'. PHP_EOL;
161
+                        echo '      </form>'. PHP_EOL;
162
+                        echo '   </td>'.PHP_EOL;
163
+                    }
164
+                    else{
165
+                        // rascsi inserts "WRITEPROTECT" for the read-only drives. We want to display that differently.
166
+                        echo '   <form action="rascsi_action.php" method="post">'. PHP_EOL;
167
+                        echo '      <td>'.str_replace('(WRITEPROTECT)', '', $scsi_ids[$id]['file']). PHP_EOL;
168
+                        echo '   </td><td>'.PHP_EOL;
169
+                        if(strtolower($scsi_ids[$id]['type']) == 'sccd'){
170 170
                         echo '          <input type="hidden" name="command" value="eject_disk" />'. PHP_EOL;
171 171
                         echo '          <input type="hidden" name="id" value="'.$id.'" />'. PHP_EOL;
172 172
                         echo '          <input type="hidden" name="file" value="'.$scsi_ids[$id]['file'].'" />'. PHP_EOL;
173 173
                         echo '          <input type="submit" name="eject_disk" value="Eject" />'. PHP_EOL;
174
-                     }
175
-                     echo '   </td>'.PHP_EOL;
176
-                     echo '      </form>'. PHP_EOL;
177
-                  }
178
-                  echo '    <td>'. PHP_EOL;
179
-                  echo '       <form action="rascsi_action.php" method="post">'. PHP_EOL;
180
-                  echo '          <input type="hidden" name="command" value="remove_device" />'. PHP_EOL;
181
-                  echo '          <input type="hidden" name="id" value="'.$id.'" />'. PHP_EOL;
182
-                  echo '          <input type="submit" name="remove_device" value="Disconnect" />'. PHP_EOL;
183
-						echo '      </form>'. PHP_EOL;
184
-                  echo '   </td>'. PHP_EOL;
174
+                        }
175
+                        echo '   </td>'.PHP_EOL;
176
+                        echo '      </form>'. PHP_EOL;
177
+                    }
178
+                    echo '    <td>'. PHP_EOL;
179
+                    echo '       <form action="rascsi_action.php" method="post">'. PHP_EOL;
180
+                    echo '          <input type="hidden" name="command" value="remove_device" />'. PHP_EOL;
181
+                    echo '          <input type="hidden" name="id" value="'.$id.'" />'. PHP_EOL;
182
+                    echo '          <input type="submit" name="remove_device" value="Disconnect" />'. PHP_EOL;
183
+                        echo '      </form>'. PHP_EOL;
184
+                    echo '   </td>'. PHP_EOL;
185 185
                 }
186 186
                 else
187 187
                 {
188
-                  echo '                 <td style="text-align:center">-</td>'. PHP_EOL;
189
-                  echo '                 <td>-</td>'. PHP_EOL;
190
-                  echo '                 <td></td>'. PHP_EOL;
191
-                  echo '                 <td>'. PHP_EOL;
192
-						echo '                 <form action="rascsi_action.php" method="post">'. PHP_EOL;
193
-						echo '                 <input type="hidden" name="command" value="connect_new_device" />'. PHP_EOL;
194
-						echo '                 <input type="hidden" name="id" value="'.$id.'" />'. PHP_EOL;
195
-						echo '                 <input type="submit" name="connect_new_device" value="Connect New" />'. PHP_EOL;
196
-						echo '                 </form>'. PHP_EOL;
188
+                    echo '                 <td style="text-align:center">-</td>'. PHP_EOL;
189
+                    echo '                 <td>-</td>'. PHP_EOL;
190
+                    echo '                 <td></td>'. PHP_EOL;
191
+                    echo '                 <td>'. PHP_EOL;
192
+                        echo '                 <form action="rascsi_action.php" method="post">'. PHP_EOL;
193
+                        echo '                 <input type="hidden" name="command" value="connect_new_device" />'. PHP_EOL;
194
+                        echo '                 <input type="hidden" name="id" value="'.$id.'" />'. PHP_EOL;
195
+                        echo '                 <input type="submit" name="connect_new_device" value="Connect New" />'. PHP_EOL;
196
+                        echo '                 </form>'. PHP_EOL;
197 197
                         echo '                 </td>'. PHP_EOL;
198 198
 
199 199
                 }
200 200
                 echo '             </form>'. PHP_EOL;
201 201
                 echo '         </tr>'. PHP_EOL;
202
-	}
203
-	echo '</table>'. PHP_EOL;
202
+    }
203
+    echo '</table>'. PHP_EOL;
204 204
 }
205 205
 function get_all_files()
206 206
 {
207
-	$raw_ls_output = shell_exec('ls --time-style="+\"%Y-%m-%d %H:%M:%S\"" -alh --quoting-style=c '.$GLOBALS['FILE_PATH']);
208
-	return $raw_ls_output;
207
+    $raw_ls_output = shell_exec('ls --time-style="+\"%Y-%m-%d %H:%M:%S\"" -alh --quoting-style=c '.$GLOBALS['FILE_PATH']);
208
+    return $raw_ls_output;
209 209
 }
210 210
 
211 211
 function mod_date_from_ls($value){
212
-	$ls_pieces = explode("\"", $value);
213
-	if(count($ls_pieces)<1){
214
-		return "";
215
-	}
216
-	return $ls_pieces[1];
212
+    $ls_pieces = explode("\"", $value);
213
+    if(count($ls_pieces)<1){
214
+        return "";
215
+    }
216
+    return $ls_pieces[1];
217 217
 }
218 218
 function file_name_from_ls($value){
219
-	$ls_pieces = explode("\"", $value);
220
-	if(count($ls_pieces) < 4){
221
-		return "";
222
-	}
223
-	return $ls_pieces[3];
219
+    $ls_pieces = explode("\"", $value);
220
+    if(count($ls_pieces) < 4){
221
+        return "";
222
+    }
223
+    return $ls_pieces[3];
224 224
 }
225 225
 function file_size_from_ls($value){
226
-	$ls_pieces = explode("\"", $value);
227
-	$file_props = preg_split("/\s+/", $ls_pieces[0]);
228
-	return $file_props[4];
226
+    $ls_pieces = explode("\"", $value);
227
+    $file_props = preg_split("/\s+/", $ls_pieces[0]);
228
+    return $file_props[4];
229 229
 }
230 230
 function file_category_from_file_name($value){
231
-	if(strpos($value,".iso") || strpos($value,".cdr") > 0){
232
-		return "CD-ROM Image";
233
-	}
234
-	if(strpos($value,".hda") > 0){
235
-		return "Hard Disk Image";
236
-	}
237
-	return "Unknown type: " . $value;
231
+    if(strpos($value,".iso") || strpos($value,".cdr") > 0){
232
+        return "CD-ROM Image";
233
+    }
234
+    if(strpos($value,".hda") > 0){
235
+        return "Hard Disk Image";
236
+    }
237
+    return "Unknown type: " . $value;
238 238
 }
239 239
 
240 240
 
241 241
 
242 242
 function type_string_to_rasctl_type($typestr){
243
-	if(strcasecmp($typestr,"Hard Disk") == 0){
244
-		return "hd";
245
-	}
246
-	if(strcasecmp($typestr,"CD-ROM") == 0){
247
-		return "cd";
248
-	}
249
-	if(strcasecmp($typestr,"Zip Drive") == 0){
250
-	}
251
-	if(strcasecmp($typestr,"Filesystem bridge") == 0){
252
-		return "bridge";
253
-	}
254
-	return "";
243
+    if(strcasecmp($typestr,"Hard Disk") == 0){
244
+        return "hd";
245
+    }
246
+    if(strcasecmp($typestr,"CD-ROM") == 0){
247
+        return "cd";
248
+    }
249
+    if(strcasecmp($typestr,"Zip Drive") == 0){
250
+    }
251
+    if(strcasecmp($typestr,"Filesystem bridge") == 0){
252
+        return "bridge";
253
+    }
254
+    return "";
255 255
 }
256 256
 
257 257
 
Please login to merge, or discard this patch.