diff --git a/src/php/LICENSE b/src/php/LICENSE index 6681ff16..ffef9a2f 100644 --- a/src/php/LICENSE +++ b/src/php/LICENSE @@ -1,22 +1,31 @@ -MIT License +BSD 3-Clause License -Copyright (c) 2019 ztto -Copyright (c) 2020 akuker +Copyright (C) 2001-2006 PI.(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. diff --git a/src/php/concept_wireframe.png b/src/php/concept_wireframe.png new file mode 100644 index 00000000..1aea0024 Binary files /dev/null and b/src/php/concept_wireframe.png differ diff --git a/src/php/index.php b/src/php/index.php deleted file mode 100644 index f5617496..00000000 --- a/src/php/index.php +++ /dev/null @@ -1,512 +0,0 @@ -/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 ''; - echo ''; - // Information Display - infoOut(); - - // SCSI Operation - echo '

Scsi Remove/Eject
'; - scsiOut($path); - - // Data display - echo '

Image Operations
'; - dataOut($path, $hdType, $moType, $cdType); - - // Start / Stop -// echo '

RASCSI Start/Stop
'; -// rascsiStartStop(); - - // Reboot / Power down - echo '

Raspberry Pi Reboot / Power down
'; - raspiRebootShut(); - -} - -// Information Display -function infoOut() { - echo '
'; - // Process confirmation - echo '

Process status:'; - $result = exec("ps -aef | grep ".PROCESS_NAME2." | grep -v grep", $output); - if(empty($output)) { - echo 'Stopping
'; - } else { - echo 'Starting
'; - $command = PROCESS_PATH.PROCESS_NAME1.' -l'; - $output = array(); - $ret = null; - exec($command, $output, $ret); - foreach ($output as $line){ - echo '
'.$line.'
'; - } - } - echo ''; -} - -// SCSI Operation -function scsiOut() { - echo 'Connect/Disconnect'; - echo 'Insert/Eject'; - - echo ''; - echo ''; - // SCSI Eject / Disconnect - echo ''; - - // SCSI Disconnect - echo ''; - - // SCSI Eject - echo ''; - - echo ''; - echo '
'; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo '
'; -} - -// 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 ''; - foreach ($array_dir as $file) { - //Show directory - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - } - $cnt = 0; - foreach ($array_file1 as $file) { - $cnt++; - echo ''; - echo ''; - - echo ''; - - echo ''; - echo ''; - } - - foreach ($array_file2 as $file) { - $cnt++; - echo ''; - echo ''; - - echo ''; - - echo ''; - - echo ''; - echo ''; - } - - foreach ($array_file3 as $file) { - $cnt++; - echo ''; - echo ''; - - echo ''; - - echo ''; - - echo ''; - echo ''; - } - echo '
'; - echo ''; - echo ''; - echo ''; - echo '
'.$file.'
'; - echo '
'; - echo ''; - echo ''; - echo ''; - echo ''; - echo '
'.$file.'
'; - echo '
'; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo '
'.$file.'
'; - echo '
'; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo '
'.$file.'
'; - echo '
'; - } -} - -// Start / Stop -function rascsiStartStop() { - // Startup - echo ''; - // Stop - echo ''; -} - -// Reboot / Power down -function raspiRebootShut() { - // Reboot - echo ''; - // Power Down - echo ''; - - echo ''; -} -?> diff --git a/src/php/rascsi.php b/src/php/rascsi.php new file mode 100644 index 00000000..2c3915d5 --- /dev/null +++ b/src/php/rascsi.php @@ -0,0 +1,289 @@ + + + + + + + + + + + + + + + + + + + + + + + + +

RaSCSI - 68kmla Edition

+
+ +
+
+ + "); + // 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 '
'; + echo '

Current RaSCSI Configuration

'; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + + 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 ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + + } + echo '
SCSI IDTypeImage FileActions
'.$segments[1].''.$segments[3].''.$segments[4].''; + echo ' '; + echo ' '; + echo '
'; +} +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; +} + +?> + +
+

Add New Device

+
+ + + + + + + + + + +
SCSI ID: + + Device: + + File: + + + +
+ + + + + +
+

Image File Management

+ + + + + + + + + + +'; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ''; + } +?> +
LocationFilenameSizeTypeDate ModifiedActions
SD Card'.$file_name.''.file_size_from_ls($this_file).''.file_category_from_file_name($file_name).''.mod_date_from_ls($this_file).''; + echo ' '; + echo ' '; + echo '
+ + +
+
+

Upload New Image File

+
+ + + + + +
+

+
+ +
+
+ +
+

RaSCSI Service Status

+
+ + +
+ +
+

Raspberry Pi Operations

+
+ + +
+ + +