Created conceptual wireframe and generated new php file that sort-of matches the wireframe. Still a work in progress and doesn't do anything useful (yet)

This commit is contained in:
akuker 2020-07-26 19:54:40 -05:00
parent 5794e56477
commit a482c465ad
4 changed files with 316 additions and 530 deletions

View File

@ -1,22 +1,31 @@
MIT License
BSD 3-Clause License
Copyright (c) 2019 ztto
Copyright (c) 2020 akuker
Copyright (C) 2001-2006 (ytanaka@ipc-tokai.or.jp)
Copyright (C) 2014-2020 GIMONS
Copyright (c) 2020, akuker
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 KiB

View File

@ -1,512 +0,0 @@
<?php
header( 'Expires: Thu, 01 Jan 1970 00:00:00 GMT' );
header( 'Last-Modified: '.gmdate( 'D, d M Y H:i:s' ).' GMT' );
// HTTP/1.1
header( 'Cache-Control: no-store, no-cache, must-revalidate' );
header( 'Cache-Control: post-check=0, pre-check=0', FALSE );
// HTTP/1.0
header( 'Pragma: no-cache' );
define("IMAGE_PATH", "/home/pi/");
define("PROCESS_PATH", "/usr/local/bin/");
define("PROCESS_NAME1", "rasctl");
define("PROCESS_NAME2", "rascsi");
// Initial Settings
$hdType = array("HDS", "HDN", "HDI", "NHD", "HDA");
$moType = array("MOS");
$cdType = array("ISO");
$path = IMAGE_PATH;
// parameter check
if(isset($_GET['shutdown'])){
// Power Down
exec("sudo shutdown now");
} else if(isset($_GET['reboot'])){
// Reboot
exec("sudo shutdown -r now");
} else if(isset($_GET['start'])){
// Startup
$command = "sudo ".PROCESS_PATH.PROCESS_NAME2." 2>/dev/null";
exec($command . " > /dev/null &");
// 1.0s
sleep(1);
// Information Display
infoOut();
} else if(isset($_GET['stop'])){
// End
$command = "sudo pkill ".PROCESS_NAME2;
$output = array();
$ret = null;
exec($command, $output, $ret);
// 0.5s
usleep(500000);
// Information Display
infoOut();
} else if(isset($_GET['param'])){
$param = $_GET['param'];
if($param[0] === 'mounth') {
// ファイルマウント
$path = $param[2];
$command = PROCESS_PATH.PROCESS_NAME1.' -i '.$param[1].' -c attach -t hd -f '.$param[2].$param[3];
$output = array();
$ret = null;
exec($command, $output, $ret);
// File mount
infoOut();
} else if($param[0] === 'mountm') {
// File Connection
$path = $param[2];
$command = PROCESS_PATH.PROCESS_NAME1.' -i '.$param[1].' -c attach -t mo -f '.$param[2].$param[3];
$output = array();
$ret = null;
exec($command, $output, $ret);
// Information Display
infoOut();
} else if($param[0] === 'mountc') {
// File connection
$path = $param[2];
$command = PROCESS_PATH.PROCESS_NAME1.' -i '.$param[1].' -c attach -t cd -f '.$param[2].$param[3];
$output = array();
$ret = null;
exec($command, $output, $ret);
// Information Display
infoOut();
} else if($param[0] === 'umount') {
// File disconnect
$command = PROCESS_PATH.PROCESS_NAME1.' -i '.$param[1].' -c detatch -t hd';
$output = array();
$ret = null;
exec($command, $output, $ret);
// Information Display
infoOut();
} else if($param[0] === 'insertm') {
// Insert file
$command = PROCESS_PATH.PROCESS_NAME1.' -i '.$param[1].' -c insert -t mo -f '.$param[2].$param[3];
$output = array();
$ret = null;
exec($command, $output, $ret);
// Information Display
infoOut();
} else if($param[0] === 'insertc') {
// Insert file
$command = PROCESS_PATH.PROCESS_NAME1.' -i '.$param[1].' -c insert -t cd -f '.$param[2].$param[3];
$output = array();
$ret = null;
exec($command, $output, $ret);
// Information Display
infoOut();
} else if($param[0] === 'eject') {
// Eject file
$command = PROCESS_PATH.PROCESS_NAME1.' -i '.$param[1].' -c eject';
$output = array();
$ret = null;
exec($command, $output, $ret);
// Information Display
infoOut();
} else if($param[0] === 'dir') {
// Directory display
$pos = strrpos($param[1], "..");
if($pos !== false) {
$pos1 = strrpos($param[1], "/", -5);
$path = substr($param[1], 0, $pos1)."/";
} else {
$path = $param[1];
}
// Data display
dataOut($path, $hdType, $moType, $cdType);
}
} else {
echo '<!DOCTYPE html><html><head><meta charset="utf-8">';
echo '<script type="text/javascript">';
echo 'window.onload = function(){';
echo ' chMode();';
echo '};';
echo 'chMode();';
echo 'function chMode() {';
echo ' var elements = document.getElementsByName(\'mode\');';
echo ' for(var a=\'\',i = elements.length; i--;) {';
echo ' if(elements[i].checked) {';
echo ' a = elements[i].value;';
echo ' break;';
echo ' }';
echo ' }';
echo ' if(a === "mu") {';
echo ' var toenable = document.getElementsByClassName(\'mu\');';
echo ' for (var k in toenable) {';
echo ' toenable[k].disabled = \'\';';
echo ' }';
echo ' var todisable = document.getElementsByClassName(\'ie\');';
echo ' for (var k in todisable) {';
echo ' todisable[k].disabled = \'disabled\';';
echo ' }';
echo ' } else {';
echo ' var todisable = document.getElementsByClassName(\'mu\');';
echo ' for (var k in todisable) {';
echo ' todisable[k].disabled = \'disabled\';';
echo ' }';
echo ' var toenable = document.getElementsByClassName(\'ie\');';
echo ' for (var k in toenable) {';
echo ' toenable[k].disabled = \'\';';
echo ' }';
echo ' }';
echo '};';
echo '</script></head><body>';
// Information Display
infoOut();
// SCSI Operation
echo '<p><div>Scsi Remove/Eject</div>';
scsiOut($path);
// Data display
echo '<p><div>Image Operations</div>';
dataOut($path, $hdType, $moType, $cdType);
// Start / Stop
// echo '<p><div>RASCSI Start/Stop</div>';
// rascsiStartStop();
// Reboot / Power down
echo '<p><div>Raspberry Pi Reboot / Power down</div>';
raspiRebootShut();
}
// Information Display
function infoOut() {
echo '<div id="info">';
// Process confirmation
echo '<p><div>Process status:';
$result = exec("ps -aef | grep ".PROCESS_NAME2." | grep -v grep", $output);
if(empty($output)) {
echo 'Stopping</div>';
} else {
echo 'Starting</div>';
$command = PROCESS_PATH.PROCESS_NAME1.' -l';
$output = array();
$ret = null;
exec($command, $output, $ret);
foreach ($output as $line){
echo '<div>'.$line.'</div>';
}
}
echo '</div>';
}
// SCSI Operation
function scsiOut() {
echo '<input type="radio" name="mode" onclick="chMode()" value="mu" checked>Connect/Disconnect';
echo '<input type="radio" name="mode" onclick="chMode()" value="ie">Insert/Eject';
echo '<table border="0">';
echo '<tr>';
// SCSI Eject / Disconnect
echo '<td>';
echo '<select id="ejectSelect">';
echo '<option value="0">SCSI0</option>';
echo '<option value="1">SCSI1</option>';
echo '<option value="2">SCSI2</option>';
echo '<option value="3">SCSI3</option>';
echo '<option value="4">SCSI4</option>';
echo '<option value="5">SCSI5</option>';
echo '</select>';
echo '</td>';
// SCSI Disconnect
echo '<td>';
echo '<input type="button" class="mu" value="Disconnect" onclick="';
echo 'var req = new XMLHttpRequest();';
echo 'req.onreadystatechange = function(){';
echo ' if(req.readyState == 4){';
echo ' if(req.status == 200){';
echo ' document.getElementById(\'info\').innerHTML = req.responseText;';
echo ' }';
echo ' }';
echo '};';
echo 'req.open(\'GET\',\'index.php?param[]=umount&param[]=\'+document.getElementById(\'ejectSelect\').value,true);';
echo 'req.send(null);"/>';
echo '</td>';
// SCSI Eject
echo '<td>';
echo '<input type="button" class="ie" value="Eject" onclick="';
echo 'var req = new XMLHttpRequest();';
echo 'req.onreadystatechange = function(){';
echo ' if(req.readyState == 4){';
echo ' if(req.status == 200){';
echo ' document.getElementById(\'info\').innerHTML = req.responseText;';
echo ' }';
echo ' }';
echo '};';
echo 'req.open(\'GET\',\'index.php?param[]=eject&param[]=\'+document.getElementById(\'ejectSelect\').value,true);';
echo 'req.send(null);"/>';
echo '</td>';
echo '</tr>';
echo '</table>';
}
// Data display
function dataOut($path, $hdType, $moType, $cdType) {
$array_dir = array();
$array_file1 = array();
$array_file2 = array();
$array_file3 = array();
// Folder Check
if($dir = opendir($path)) {
while(($file = readdir($dir)) !== FALSE) {
$file_path = $path.$file;
if(!is_file($file_path)) {
if(($path === IMAGE_PATH) &&
($file === '..')) {
continue;
}
//Show directory
if($file !== '.') {
$array_dir[] = $file;
}
} else {
//Show files
$path_data = pathinfo($file);
if(array_key_exists('extension',$path_data))
{
$ext = strtoupper($path_data['extension']);
if(in_array($ext, $hdType)) {
$array_file1[] = $file;
}
if(in_array($ext, $moType)) {
$array_file2[] = $file;
}
if(in_array($ext, $cdType)) {
$array_file3[] = $file;
}
}
}
}
closedir($dir);
sort($array_dir);
sort($array_file1);
sort($array_file2);
sort($array_file3);
echo '<table id="table" border="0">';
foreach ($array_dir as $file) {
//Show directory
echo '<tr>';
echo '<td>';
echo '<input type="button" value="Change" onclick="';
echo 'var req = new XMLHttpRequest();';
echo 'req.onreadystatechange = function(){';
echo ' if(req.readyState == 4){';
echo ' if(req.status == 200){';
echo ' document.getElementById(\'table\').innerHTML = req.responseText;';
echo ' chMode();';
echo ' }';
echo ' }';
echo '};';
echo 'req.open(\'GET\',\'index.php?param[]=dir&param[]='.$path.$file.'/'.'\',true);';
echo 'req.send(null);"/>';
echo '</td>';
echo '<td>';
echo '</td>';
echo '<td>';
echo '<div>'.$file.'</div>';
echo '</td>';
echo '</tr>';
}
$cnt = 0;
foreach ($array_file1 as $file) {
$cnt++;
echo '<tr>';
echo '<td>';
echo '<select id="insertSelect'.$cnt.'">';
echo '<option value="0">SCSI0</option>';
echo '<option value="1">SCSI1</option>';
echo '<option value="2">SCSI2</option>';
echo '<option value="3">SCSI3</option>';
echo '<option value="4">SCSI4</option>';
echo '<option value="5">SCSI5</option>';
echo '</select>';
echo '</td>';
echo '<td>';
echo '<input type="button" class="mu" value="Connect" onclick="';
echo 'var req = new XMLHttpRequest();';
echo 'req.onreadystatechange = function(){';
echo ' if(req.readyState == 4){';
echo ' if(req.status == 200){';
echo ' document.getElementById(\'info\').innerHTML = req.responseText;';
echo ' }';
echo ' }';
echo '};';
echo 'req.open(\'GET\',\'index.php?param[]=mounth&param[]=\'+document.getElementById(\'insertSelect'.$cnt.'\').value+\'&param[]='.$path.'&param[]='.$file.'\',true);';
echo 'req.send(null);"/>';
echo '</td>';
echo '<td>';
echo '<div>'.$file.'</div>';
echo '</td>';
echo '</tr>';
}
foreach ($array_file2 as $file) {
$cnt++;
echo '<tr>';
echo '<td>';
echo '<select id="insertSelect'.$cnt.'">';
echo '<option value="0">SCSI0</option>';
echo '<option value="1">SCSI1</option>';
echo '<option value="2">SCSI2</option>';
echo '<option value="3">SCSI3</option>';
echo '<option value="4">SCSI4</option>';
echo '<option value="5">SCSI5</option>';
echo '</select>';
echo '</td>';
echo '<td>';
echo '<input type="button" class="mu" value="Connect" onclick="';
echo 'var req = new XMLHttpRequest();';
echo 'req.onreadystatechange = function(){';
echo ' if(req.readyState == 4){';
echo ' if(req.status == 200){';
echo ' document.getElementById(\'info\').innerHTML = req.responseText;';
echo ' }';
echo ' }';
echo '};';
echo 'req.open(\'GET\',\'index.php?param[]=mountm&param[]=\'+document.getElementById(\'insertSelect'.$cnt.'\').value+\'&param[]='.$path.'&param[]='.$file.'\',true);';
echo 'req.send(null);"/>';
echo '</td>';
echo '<td>';
echo '<input type="button" class="ie" value="Insert" onclick="';
echo 'var req = new XMLHttpRequest();';
echo 'req.onreadystatechange = function(){';
echo ' if(req.readyState == 4){';
echo ' if(req.status == 200){';
echo ' document.getElementById(\'info\').innerHTML = req.responseText;';
echo ' }';
echo ' }';
echo '};';
echo 'req.open(\'GET\',\'index.php?param[]=insertm&param[]=\'+document.getElementById(\'insertSelect'.$cnt.'\').value+\'&param[]='.$path.'&param[]='.$file.'\',true);';
echo 'req.send(null);"/>';
echo '</td>';
echo '<td>';
echo '<div>'.$file.'</div>';
echo '</td>';
echo '</tr>';
}
foreach ($array_file3 as $file) {
$cnt++;
echo '<tr>';
echo '<td>';
echo '<select id="insertSelect'.$cnt.'">';
echo '<option value="0">SCSI0</option>';
echo '<option value="1">SCSI1</option>';
echo '<option value="2">SCSI2</option>';
echo '<option value="3">SCSI3</option>';
echo '<option value="4">SCSI4</option>';
echo '<option value="5">SCSI5</option>';
echo '</select>';
echo '</td>';
echo '<td>';
echo '<input type="button" class="mu" value="Connect" onclick="';
echo 'var req = new XMLHttpRequest();';
echo 'req.onreadystatechange = function(){';
echo ' if(req.readyState == 4){';
echo ' if(req.status == 200){';
echo ' document.getElementById(\'info\').innerHTML = req.responseText;';
echo ' }';
echo ' }';
echo '};';
echo 'req.open(\'GET\',\'index.php?param[]=mountc&param[]=\'+document.getElementById(\'insertSelect'.$cnt.'\').value+\'&param[]='.$path.'&param[]='.$file.'\',true);';
echo 'req.send(null);"/>';
echo '</td>';
echo '<td>';
echo '<input type="button" class="ie" value="Insert" onclick="';
echo 'var req = new XMLHttpRequest();';
echo 'req.onreadystatechange = function(){';
echo ' if(req.readyState == 4){';
echo ' if(req.status == 200){';
echo ' document.getElementById(\'info\').innerHTML = req.responseText;';
echo ' }';
echo ' }';
echo '};';
echo 'req.open(\'GET\',\'index.php?param[]=insertc&param[]=\'+document.getElementById(\'insertSelect'.$cnt.'\').value+\'&param[]='.$path.'&param[]='.$file.'\',true);';
echo 'req.send(null);"/>';
echo '</td>';
echo '<td>';
echo '<div>'.$file.'</div>';
echo '</td>';
echo '</tr>';
}
echo '</table>';
}
}
// Start / Stop
function rascsiStartStop() {
// Startup
echo '<input type="button" value="起動" onclick="';
echo 'var req = new XMLHttpRequest();';
echo 'req.onreadystatechange = function(){';
echo ' if(req.readyState == 4){';
echo ' if(req.status == 200){';
echo ' document.getElementById(\'info\').innerHTML = req.responseText;';
echo ' }';
echo ' }';
echo '};';
echo 'req.open(\'GET\',\'index.php?start=0\',true);';
echo 'req.send(null);"/>';
// Stop
echo '<input type="button" value="停止" onclick="';
echo 'var req = new XMLHttpRequest();';
echo 'req.onreadystatechange = function(){';
echo ' if(req.readyState == 4){';
echo ' if(req.status == 200){';
echo ' document.getElementById(\'info\').innerHTML = req.responseText;';
echo ' }';
echo ' }';
echo '};';
echo 'req.open(\'GET\',\'index.php?stop=0\',true);';
echo 'req.send(null);"/>';
}
// Reboot / Power down
function raspiRebootShut() {
// Reboot
echo '<input type="button" value="Reboot" onclick="';
echo 'var req = new XMLHttpRequest();';
echo 'req.onreadystatechange = function(){';
echo ' if(req.readyState == 4){';
echo ' if(req.status == 200){';
echo ' location.reload();';
echo ' }';
echo ' }';
echo '};';
echo 'req.open(\'GET\',\'index.php?reboot=0\',true);';
echo 'req.send(null);"/>';
// Power Down
echo '<input type="button" value="Power off" onclick="';
echo 'var req = new XMLHttpRequest();';
echo 'req.onreadystatechange = function(){';
echo ' if(req.readyState == 4){';
echo ' if(req.status == 200){';
echo ' location.reload();';
echo ' }';
echo ' }';
echo '};';
echo 'req.open(\'GET\',\'index.php?shutdown=0\',true);';
echo 'req.send(null);"/>';
echo '</body></html>';
}
?>

289
src/php/rascsi.php Normal file
View File

@ -0,0 +1,289 @@
<!-- PHP source code for controlling the RaSCSI - 68kmla edition with a web interface. -->
<!-- Copyright (c) 2020 akuker -->
<!-- Distributed under the BSD-3 Clause License -->
<!-- Note: the origina rascsi-php project was under MIT license.-->
<!DOCTYPE html>
<html>
<head>
<style>h1{
color:white;
font-size:20px;
font-family: Arial, Helvetica, sans-serif;
background-color: black;
}</style>
<style>h2{
color:black;
font-size:16px;
font-family: Arial, Helvetica, sans-serif;
background-color: white;
margin: 0px;
}</style>
</style>
<style>body{
color:black;
font-family:Arial, Helvetica, sans-serif;
background-color: white;
}</style>
<STYLE>A {text-decoration: none;} </STYLE>
<style>table,tr,td {
border: 1px solid black;
border-collapse:collapse;
margin: none;
font-family:Arial, Helvetica, sans-serif;
}
</style>
</head>
<body>
<table width="100%" >
<tr style="background-color: black;">
<td style="background-color: black;"><a href=http://github.com/akuker/RASCSI><h1>RaSCSI - 68kmla Edition</h1></a></td>
<td style="background-color: black;">
<form action="/rascsi.php">
<input type="submit" value="Refresh"/>
</form>
</td>
</tr>
</table>
<?php
echo "Debug timestamp:";
$t=time();
echo($t . "<br>");
// parameter check
if(isset($_GET['restart_rascsi_service'])){
// Restart the RaSCSI service
echo 'exec("sudo systemctl restart rascsi.service");';
} else if(isset($_GET['stop_rascsi_service'])){
// Stop the RaSCSI Service
echo 'exec("sudo systemctl stop rascsi.service");';
} else if(isset($_GET['reboot_rasbperry_pi'])){
// Reboot the Raspberry Pi
echo 'exec("sudo shutdown -r -t 0");';
} else if(isset($_GET['shutdown_raspberry_pi'])){
// Shut down the Raspberry Pi
echo 'exec("sudo shutdown -s -t 0");';
}
current_rascsi_config();
function current_rascsi_config() {
$raw_output = shell_exec("/usr/local/bin/rasctl -l");
$rasctl_lines = explode(PHP_EOL, $raw_output);
echo ' <br>';
echo ' <h2>Current RaSCSI Configuration</h2>';
echo ' <table border="black">';
echo ' <tr>';
echo ' <td><b>SCSI ID</b></td>';
echo ' <td><b>Type</b></td>';
echo ' <td><b>Image File</b></td>';
echo ' <td><b>Actions</b></td>';
echo ' </tr>';
foreach ($rasctl_lines as $current_line)
{
if(strlen($current_line) === 0){
continue;
}
if(strpos($current_line, '+----') === 0){
continue;
}
if(strpos($current_line, '| ID | UN') === 0){
continue;
echo 'Dont stop til you get enough';
}
$segments = explode("|", $current_line);
echo ' <tr>';
echo ' <form>';
echo ' <td>'.$segments[1].'</td>';
echo ' <td>'.$segments[3].'</td>';
echo ' <td>'.$segments[4].'</td>';
echo ' <td>';
echo ' <input type="button" value="Eject"/>';
echo ' <input type="button" value="Disconnect">';
echo ' </td>';
echo ' </form>';
echo ' </tr>';
}
echo '</table>';
}
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/');
return $raw_ls_output;
}
?>
<br>
<h2>Add New Device</h2>
<form action=rascsi.php>
<table style="border: none">
<tr style="border: none">
<td style="border: none">SCSI ID:</td>
<td style="border: none">
<select>
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
</select>
</td>
<td style="border: none">Device:</td>
<td style="border: none">
<select>
<option value="hard_disk">Hard Disk</option>
<option value="cd_rom">CD-ROM</option>
<option value="zip_drive" disabled>Zip Drive</option>
<option value="ethernet_tap" disabled>Ethernet Tap</option>
<option value="filesystem_bridge" disabled>Filesystem Bridge</option>
</select>
</td>
<td style="border: none">File:</td>
<td style="border: none">
<select>
<?php
$all_files = get_all_files();
foreach(explode(PHP_EOL, $all_files) as $this_file){
if(strpos($current_line, 'total') === 0){
continue;
}
$file_name = file_name_from_ls($this_file);
if(strlen($file_name) === 0){
continue;
}
// Ignore files that start with a .
if(strpos($file_name, '.') === 0){
continue;
}
echo '<option value="'.$file_name.'">'.$file_name.'</option>';
}
function mod_date_from_ls($value){
$ls_pieces = explode("\"", $value);
return $ls_pieces[1];
}
function file_name_from_ls($value){
$ls_pieces = explode("\"", $value);
return $ls_pieces[3];
}
function file_size_from_ls($value){
$ls_pieces = explode("\"", $value);
$file_props = preg_split("/\s+/", $ls_pieces[0]);
return $file_props[4];
}
function file_category_from_file_name($value){
if(strpos($value,".iso") > 0){
return "CD-ROM Image";
}
if(strpos($value,".hda") > 0){
return "Hard Disk Image";
}
return "Unknown type: " . $value;
}
?>
</select>
</td>
<td style="border: none">
<INPUT type="submit" value="Add">
</td>
</tr>
</table>
<br>
<h2>Image File Management</h2>
<table border="black">
<tr>
<td><b>Location</b></td>
<td><b>Filename</b></td>
<td><b>Size</b></td>
<td><b>Type</b></td>
<td><b>Date Modified</b></td>
<td><b>Actions</b></td>
</tr>
<tr>
<?php
// Generate the table with all of the file names in it.....
$all_files = get_all_files();
foreach(explode(PHP_EOL, $all_files) as $this_file){
if(strpos($this_file, 'total') === 0){
continue;
}
$file_name = file_name_from_ls($this_file);
if(strlen($file_name) === 0){
continue;
}
// Ignore file names that start with .
if(strpos($file_name,".") === 0){
continue;
}
echo '<tr>';
echo ' <form>';
echo ' <td>SD Card</td>';
echo ' <td>'.$file_name.'</td>';
echo ' <td>'.file_size_from_ls($this_file).'</td>';
echo ' <td>'.file_category_from_file_name($file_name).'</td>';
echo ' <td>'.mod_date_from_ls($this_file).'</td>';
echo ' <td>';
echo ' <input type="button" value="Delete"/>';
echo ' <input type="button" value="Copy to RAM Disk" disabled/>';
echo ' </td>';
echo ' </form>';
echo '</tr>';
}
?>
</table>
<br>
<br>
<h2>Upload New Image File</h2>
<form>
<table style="border: none">
<tr style="border: none">
<td style="border: none; vertical-align:top;">
<input type="file" id="filename" name="fname"><br><br>
</td>
<td style="border: none; vertical-align:top;">
<input type="submit" value="Upload">
</td>
</tr>
</table>
</form>
<br>
<h2>RaSCSI Service Status</h2>
<form method="get" action="rascsi.php" id="service">
<input type="submit" name="restart_rascsi_service" value="Restart RaSCSI service"/>
<input type="submit" name="stop_rascsi_service" value="Stop RaSCSI service"/>
</form>
<br>
<h2>Raspberry Pi Operations</h2>
<form id="pi stuff">
<input type="submit" name="reboot_rasbperry_pi" value="Reboot Raspberry Pi"/>
<input type="submit" name="shutdown_raspberry_pi" value="Shut Down Raspberry Pi"/>
</form>
</body>
</html>