diff --git a/src/php/lib_rascsi.php b/src/php/lib_rascsi.php index 467dbab7..dd4158f6 100644 --- a/src/php/lib_rascsi.php +++ b/src/php/lib_rascsi.php @@ -6,7 +6,7 @@ '. PHP_EOL; @@ -14,7 +14,7 @@ function html_generate_header(){ echo '

RaSCSI - 68kmla Edition

'. PHP_EOL; echo ' '. PHP_EOL; echo '
'. PHP_EOL; - echo ' '. PHP_EOL; + echo ' '. PHP_EOL; echo '

'.time().'

'. PHP_EOL; echo '
'. PHP_EOL; echo ' '. PHP_EOL; diff --git a/src/php/rascsi.php b/src/php/rascsi.php index f412e977..b2ec3471 100644 --- a/src/php/rascsi.php +++ b/src/php/rascsi.php @@ -9,44 +9,7 @@ - - + @@ -86,19 +49,20 @@ } - echo ''; - echo '
'; - echo ' SD Card'; - echo ' '.$file_name.''; - echo ' '.file_size_from_ls($this_file).''; - echo ' '.file_category_from_file_name($file_name).''; - echo ' '.mod_date_from_ls($this_file).''; - echo ' '; - echo ' '; - echo ' '; - echo ' '; - echo '
'; - echo ''; + echo ''.PHP_EOL; + echo ' SD Card'.PHP_EOL; + echo ' '.$file_name.''.PHP_EOL; + echo ' '.file_size_from_ls($this_file).''.PHP_EOL; + echo ' '.file_category_from_file_name($file_name).''.PHP_EOL; + echo ' '.mod_date_from_ls($this_file).''.PHP_EOL; + echo ' '.PHP_EOL; + echo '
'.PHP_EOL; + echo ' '.PHP_EOL; + echo ' '.PHP_EOL; + echo ' '.PHP_EOL; + echo '
'.PHP_EOL; + echo ' '.PHP_EOL; + echo ''.PHP_EOL; } ?> diff --git a/src/php/rascsi_action.php b/src/php/rascsi_action.php index 7e746991..97c6df38 100644 --- a/src/php/rascsi_action.php +++ b/src/php/rascsi_action.php @@ -13,15 +13,20 @@ include 'lib_rascsi.php'; html_generate_header(); - echo "Post values......................".PHP_EOL; - echo '
'.PHP_EOL; + echo '
'; + echo ''.PHP_EOL; + echo ' '.PHP_EOL; + echo '

Debug stuff

'; + + echo '

Post values......................'.PHP_EOL; + echo '
'.PHP_EOL; var_dump($_POST); - echo '
'.PHP_EOL; - + echo '

Running command.... '.$_POST['command'].PHP_EOL; + echo '

'.PHP_EOL; + echo '
'; if(isset($_POST['command'])) { - echo 'Running command.... '.$_POST['command'].'

'.PHP_EOL; switch(strtolower($_POST['command'])){ case "eject_disk": action_eject_disk(); @@ -139,15 +144,54 @@ function action_remove_device(){ } // function action_connect_new_device(){} function action_insert_disk(){} -function action_create_new_image(){} +function action_create_new_image(){ + // If we already know the size & filename, we can go create the image... + if(isset($_POST['size']) && isset($_POST['file_name'])){ + $command = 'dd if=/dev/zero of='.$GLOBALS['FILE_PATH'].'/'.$_POST['file_name'].' bs=1M count='.$_POST['size']; + exec($command, $retArray, $result); + echo '

'.$command.'

'; + check_result($result, $command, $retArray); + html_generate_ok_to_go_home(); + } + else{ + echo '

Create a new empty file

'.PHP_EOL; + echo '
'.PHP_EOL; + echo ' '.PHP_EOL; + echo ' '.PHP_EOL; + echo ' '.PHP_EOL; + echo ' '.PHP_EOL; + echo ' '.PHP_EOL; + echo ' '.PHP_EOL; + echo ' '.PHP_EOL; + echo ' '.PHP_EOL; + echo ' '.PHP_EOL; + echo ' '.PHP_EOL; + echo '
File Name:'.PHP_EOL; + echo ' '.PHP_EOL; + echo ' Size:'.PHP_EOL; + echo ' '.PHP_EOL; + echo ' MB'.PHP_EOL; + echo ' '.PHP_EOL; + echo '
'.PHP_EOL; + echo '
'.PHP_EOL; + echo '
Note: Creating a large file may take a long time!'.PHP_EOL; + echo '

'.PHP_EOL; + echo '
'.PHP_EOL; + echo ' '.PHP_EOL; + echo '
'.PHP_EOL; + } +} + function action_delete_file(){ // Check to see if the user has confirmed if(isset($_POST['confirmed'])){ - echo '
exec(rm '.$_POST['file'].')'.PHP_EOL; + $command = 'rm '.$GLOBALS['FILE_PATH'].'/'.$_POST['file_name']; + exec($command, $retArray, $result); + check_result($result, $command, $retArray); html_generate_ok_to_go_home(); } else{ - check_are_you_sure('Are you sure you want to PERMANENTLY delete '.$_POST['file'].'?'); + check_are_you_sure('Are you sure you want to PERMANENTLY delete '.$_POST['file_name'].'?'); } } @@ -197,17 +241,19 @@ function action_unknown_command(){ function check_result($result,$command,$output){ if(!$result){ - echo '

Command succeeded!

'.PHP_EOL; + echo '

Command succeeded!

'.PHP_EOL; } else{ echo '

Command failed!

'.PHP_EOL; } - echo '
'.$command.''.PHP_EOL; - echo '
Output:'.PHP_EOL; - foreach($output as $line){ - echo '
Error message: '.$line.PHP_EOL; + echo '
'.$command.'
'.PHP_EOL; + if(count($output) > 0){ + echo '
Output:'.PHP_EOL; + foreach($output as $line){ + echo '
Error message: '.$line.PHP_EOL; + } + echo '
'.PHP_EOL; } - echo '
'.PHP_EOL; } function check_are_you_sure($prompt){ @@ -225,7 +271,7 @@ function check_are_you_sure($prompt){ echo ''.PHP_EOL; } echo ' '.PHP_EOL; - echo ' '.PHP_EOL; + echo ' '.PHP_EOL; echo ' '.PHP_EOL; echo ' '.PHP_EOL; echo ' '.PHP_EOL; @@ -276,6 +322,17 @@ function action_connect_new_device(){ echo ' '.PHP_EOL; echo ' '.PHP_EOL; } + +function get_new_filename(){ + // Try to find a new file name that doesn't exist. + $i=1; + while(file_exists($GLOBALS['FILE_PATH'].'/'.'new_file'.$i.'.hda')) + { + $i = $i+1; + } + return 'new_file'.$i.'.hda'; +} + ?>