From 5794e56477e01628ac0cf713406a8fdb4bb62120 Mon Sep 17 00:00:00 2001 From: Tony Kuker Date: Sat, 25 Jul 2020 21:40:03 -0500 Subject: [PATCH] Translated to Englished and fixed handling of files without an extension --- src/php/LICENSE | 1 + src/php/index.php | 151 +++++++++++++++++++++++----------------------- 2 files changed, 78 insertions(+), 74 deletions(-) diff --git a/src/php/LICENSE b/src/php/LICENSE index e7c31cdf..6681ff16 100644 --- a/src/php/LICENSE +++ b/src/php/LICENSE @@ -1,6 +1,7 @@ MIT License Copyright (c) 2019 ztto +Copyright (c) 2020 akuker Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/php/index.php b/src/php/index.php index d478e0cf..f5617496 100644 --- a/src/php/index.php +++ b/src/php/index.php @@ -9,41 +9,41 @@ header( 'Cache-Control: post-check=0, pre-check=0', FALSE ); // HTTP/1.0 header( 'Pragma: no-cache' ); -define("IMAGE_PATH", "/home/pi/rasimg/"); +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']; @@ -54,60 +54,60 @@ if(isset($_GET['shutdown'])){ $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); @@ -115,7 +115,7 @@ if(isset($_GET['shutdown'])){ } else { $path = $param[1]; } - // データ表示 + // Data display dataOut($path, $hdType, $moType, $cdType); } } else { @@ -154,37 +154,37 @@ if(isset($_GET['shutdown'])){ echo ' }'; echo '};'; echo ''; - // 情報表示 + // Information Display infoOut(); - // SCSI操作 - echo '

Scsi取り外し/排出
'; + // SCSI Operation + echo '

Scsi Remove/Eject
'; scsiOut($path); - // データ表示 - echo '

Image操作
'; + // Data display + echo '

Image Operations
'; dataOut($path, $hdType, $moType, $cdType); - // 起動/停止 -// echo '

RASCSI 起動/停止
'; + // Start / Stop +// echo '

RASCSI Start/Stop
'; // rascsiStartStop(); - // 再起動/電源断 - echo '

Raspberry Pi 再起動/電源断
'; + // Reboot / Power down + echo '

Raspberry Pi Reboot / Power down
'; raspiRebootShut(); } -// 情報表示 +// Information Display function infoOut() { echo '
'; - // プロセス確認 - echo '

プロセス状況:'; + // Process confirmation + echo '

Process status:'; $result = exec("ps -aef | grep ".PROCESS_NAME2." | grep -v grep", $output); if(empty($output)) { - echo '停止中
'; + echo 'Stopping
'; } else { - echo '起動中
'; + echo 'Starting'; $command = PROCESS_PATH.PROCESS_NAME1.' -l'; $output = array(); $ret = null; @@ -196,14 +196,14 @@ function infoOut() { echo ''; } -// SCSI操作 +// SCSI Operation function scsiOut() { - echo '接続/切断'; - echo '挿入/排出'; + echo 'Connect/Disconnect'; + echo 'Insert/Eject'; echo ''; echo ''; - // SCSI?排出/切断 + // SCSI Eject / Disconnect echo ''; - // SCSI?切断 + // SCSI Disconnect echo ''; - // SCSI?排出 + // SCSI Eject echo ''; echo '
'; echo ''; echo ''; - echo ''; echo ''; - echo ''; foreach ($array_dir as $file) { - //ディレクトリを表示 + //Show directory echo '
'; - echo ''; - // 停止 + // Stop echo ''; } -// 再起動/電源断 +// Reboot / Power down function raspiRebootShut() { - // 再起動 - echo ''; - // 電源断 - echo '