mirror of
https://github.com/akuker/RASCSI.git
synced 2024-08-22 11:29:04 +00:00
Added file upload functionality. Disabled some debug messages.
This commit is contained in:
parent
e962706d4e
commit
dfa28091e4
8
src/php/.editorconfig
Normal file
8
src/php/.editorconfig
Normal file
@ -0,0 +1,8 @@
|
||||
root = true
|
||||
|
||||
[*.{html,php,htm}]
|
||||
indent_style = space
|
||||
indent_size = 3
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
@ -6,7 +6,11 @@
|
||||
|
||||
<?php
|
||||
|
||||
$DEBUG_ENABLE=0;
|
||||
$FILE_PATH='/home/pi/images';
|
||||
// Limit the maximum upload file size to 1GB
|
||||
$MAX_UPLOAD_FILE_SIZE=1000000000;
|
||||
$ALLOWED_FILE_TYPES=array('iso','hda');
|
||||
|
||||
function html_generate_header(){
|
||||
echo ' <table width="100%" >'. PHP_EOL;
|
||||
@ -15,7 +19,9 @@ function html_generate_header(){
|
||||
echo ' <td style="background-color: black;">'. PHP_EOL;
|
||||
echo ' <form action="rascsi.php">'. PHP_EOL;
|
||||
echo ' <input type="submit" value="Go Home"/>'. PHP_EOL;
|
||||
echo ' <p style="color:white">'.time().'</p>'. PHP_EOL;
|
||||
if($GLOBALS['DEBUG_ENABLE']){
|
||||
echo ' <p style="color:#595959">Debug Timestamp: '.time().'</p>'. PHP_EOL;
|
||||
}
|
||||
echo ' </form>'. PHP_EOL;
|
||||
echo ' </td>'. PHP_EOL;
|
||||
echo ' </tr>'. PHP_EOL;
|
||||
@ -23,6 +29,26 @@ function html_generate_header(){
|
||||
//echo(exec('whoami'));
|
||||
}
|
||||
|
||||
function html_generate_image_file_select_list(){
|
||||
$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 files that start with a .
|
||||
if(strpos($file_name, '.') === 0){
|
||||
continue;
|
||||
}
|
||||
|
||||
echo '<option value="'.$file_name.'">'.$file_name.'</option>'.PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function html_generate_scsi_id_select_list(){
|
||||
echo '<select>'. PHP_EOL;
|
||||
foreach(range(0,7) as $id){
|
||||
@ -44,19 +70,26 @@ function html_generate_warning($message){
|
||||
echo ' <table width="100%" >'. PHP_EOL;
|
||||
echo ' <tr style="background-color: red;">'. PHP_EOL;
|
||||
echo ' <td style="background-color: red;">'. PHP_EOL;
|
||||
echo ' <font size=+4>'.$message.'</font>'. PHP_EOL;
|
||||
echo ' <font size=+2>'.$message.'</font>'. PHP_EOL;
|
||||
echo ' </td>'. PHP_EOL;
|
||||
echo ' </tr>'. PHP_EOL;
|
||||
echo ' </table>'. PHP_EOL;
|
||||
}
|
||||
|
||||
function html_generate_success_message(){
|
||||
function html_generate_success_message($message){
|
||||
echo ' <table width="100%" >'. PHP_EOL;
|
||||
echo ' <tr style="background-color: green;">'. PHP_EOL;
|
||||
echo ' <td style="background-color: green;">'. PHP_EOL;
|
||||
echo ' <font size=+2>Success!</font>'. PHP_EOL;
|
||||
echo ' <font size=+2>Success</font>'. PHP_EOL;
|
||||
echo ' </td>'. PHP_EOL;
|
||||
echo ' </tr>'. PHP_EOL;
|
||||
if(strlen($message) > 0){
|
||||
echo ' <tr style="background-color: green;">'. PHP_EOL;
|
||||
echo ' <td style="background-color: green;">'. PHP_EOL;
|
||||
echo ' '.$message.PHP_EOL;
|
||||
echo ' </td>'. PHP_EOL;
|
||||
echo ' </tr>'. PHP_EOL;
|
||||
}
|
||||
echo ' </table>'. PHP_EOL;
|
||||
}
|
||||
|
||||
@ -77,8 +110,9 @@ function current_rascsi_config() {
|
||||
echo ' <tr>'. PHP_EOL;
|
||||
echo ' <td><b>SCSI ID</b></td>'. PHP_EOL;
|
||||
echo ' <td><b>Type</b></td>'. PHP_EOL;
|
||||
echo ' <td><b>Image File</b></td>'. PHP_EOL;
|
||||
echo ' <td><b>Actions</b></td>'. PHP_EOL;
|
||||
echo ' <td><b>File</b></td>'. PHP_EOL;
|
||||
echo ' <td><b>File Ops</b></td>'. PHP_EOL;
|
||||
echo ' <td><b>Device Ops</b></td>'. PHP_EOL;
|
||||
echo ' </tr>'. PHP_EOL;
|
||||
|
||||
$scsi_ids = array();
|
||||
@ -112,14 +146,36 @@ function current_rascsi_config() {
|
||||
if(isset($scsi_ids[$id]))
|
||||
{
|
||||
echo ' <td style="text-align:center">'.$scsi_ids[$id]['type'].'</td>'. PHP_EOL;
|
||||
echo ' <td>'.$scsi_ids[$id]['file'].'</td>'. PHP_EOL;
|
||||
echo ' <td>'. PHP_EOL;
|
||||
if(strtolower($scsi_ids[$id]['file']) == "no media"){
|
||||
echo ' <td>'.PHP_EOL;
|
||||
echo ' <form action="rascsi_action.php" method="post">'. PHP_EOL;
|
||||
echo ' <select name="file_name">'.PHP_EOL;
|
||||
echo ' <option value="None">None</option>'.PHP_EOL;
|
||||
html_generate_image_file_select_list();
|
||||
echo ' </select>'.PHP_EOL;
|
||||
echo ' <input type="hidden" name="command" value="insert_disk" />'. PHP_EOL;
|
||||
echo ' <input type="hidden" name="id" value="'.$id.'" />'. PHP_EOL;
|
||||
echo ' <input type="hidden" name="file" value="'.$scsi_ids[$id]['file'].'" />'. PHP_EOL;
|
||||
echo ' </td><td>'.PHP_EOL;
|
||||
echo ' <input type="submit" name="insert_disk" value="Insert" />'. PHP_EOL;
|
||||
echo ' </form>'. PHP_EOL;
|
||||
echo ' </td>'.PHP_EOL;
|
||||
}
|
||||
else{
|
||||
// rascsi inserts "WRITEPROTECT" for the read-only drives. We want to display that differently.
|
||||
echo ' <form action="rascsi_action.php" method="post">'. PHP_EOL;
|
||||
echo ' <td>'.str_replace('(WRITEPROTECT)', '', $scsi_ids[$id]['file']). PHP_EOL;
|
||||
echo ' </td><td>'.PHP_EOL;
|
||||
if(strtolower($scsi_ids[$id]['type']) == 'sccd'){
|
||||
echo ' <input type="hidden" name="command" value="eject_disk" />'. PHP_EOL;
|
||||
echo ' <input type="hidden" name="id" value="'.$id.'" />'. PHP_EOL;
|
||||
echo ' <input type="hidden" name="file" value="'.$scsi_ids[$id]['file'].'" />'. PHP_EOL;
|
||||
echo ' <input type="submit" name="eject_disk" value="Eject" />'. PHP_EOL;
|
||||
}
|
||||
echo ' </td>'.PHP_EOL;
|
||||
echo ' </form>'. PHP_EOL;
|
||||
}
|
||||
echo ' <td>'. PHP_EOL;
|
||||
echo ' <form action="rascsi_action.php" method="post">'. PHP_EOL;
|
||||
echo ' <input type="hidden" name="command" value="remove_device" />'. PHP_EOL;
|
||||
echo ' <input type="hidden" name="id" value="'.$id.'" />'. PHP_EOL;
|
||||
@ -131,11 +187,12 @@ function current_rascsi_config() {
|
||||
{
|
||||
echo ' <td style="text-align:center">-</td>'. PHP_EOL;
|
||||
echo ' <td>-</td>'. PHP_EOL;
|
||||
echo ' <td></td>'. PHP_EOL;
|
||||
echo ' <td>'. PHP_EOL;
|
||||
echo ' <form action="rascsi_action.php" method="post">'. PHP_EOL;
|
||||
echo ' <input type="hidden" name="command" value="connect_new_device" />'. PHP_EOL;
|
||||
echo ' <input type="hidden" name="id" value="'.$id.'" />'. PHP_EOL;
|
||||
echo ' <input type="submit" name="connect_new_device" value="Connect New Device" />'. PHP_EOL;
|
||||
echo ' <input type="submit" name="connect_new_device" value="Connect New" />'. PHP_EOL;
|
||||
echo ' </form>'. PHP_EOL;
|
||||
echo ' </td>'. PHP_EOL;
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>RaSCSI Main Control Page</title>
|
||||
<link rel="stylesheet" href="rascsi_styles.css">
|
||||
</head>
|
||||
|
||||
@ -71,14 +72,14 @@
|
||||
<br>
|
||||
<br>
|
||||
<h2>Upload New Image File</h2>
|
||||
<form>
|
||||
<form action="rascsi_upload.php" method="post" enctype="multipart/form-data">
|
||||
<table style="border: none">
|
||||
<tr style="border: none">
|
||||
<td style="border: none; vertical-align:top;">
|
||||
<input type="file" id="filename" name="fname"><br><br>
|
||||
<input type="file" id="filename" name="file_name"><br><br>
|
||||
</td>
|
||||
<td style="border: none; vertical-align:top;">
|
||||
<input type="submit" value="Upload">
|
||||
<input type="submit" value="Upload" name="submit">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -5,6 +5,7 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>RaSCSI Action Page</title>
|
||||
<link rel="stylesheet" href="rascsi_styles.css">
|
||||
</head>
|
||||
|
||||
@ -14,6 +15,7 @@
|
||||
html_generate_header();
|
||||
|
||||
echo '<br>';
|
||||
if($GLOBALS['DEBUG_ENABLE']){
|
||||
echo '<table>'.PHP_EOL;
|
||||
echo ' <tr><td><p style="color:gray">Debug stuff</p></td></tr>'.PHP_EOL;
|
||||
echo ' <tr><td>';
|
||||
@ -24,6 +26,7 @@
|
||||
echo '<br><br>Running command.... '.$_POST['command'].PHP_EOL;
|
||||
echo '<br></p>'.PHP_EOL;
|
||||
echo '</td></tr></table>';
|
||||
}
|
||||
|
||||
if(isset($_POST['command']))
|
||||
{
|
||||
@ -63,79 +66,25 @@
|
||||
break;
|
||||
}
|
||||
}
|
||||
else{
|
||||
html_generate_warning("HTTP command was missing POST information. Are you trying to access this page directly? That won't work");
|
||||
echo "<br>".PHP_EOL;
|
||||
html_generate_ok_to_go_home();
|
||||
}
|
||||
|
||||
// // parameter check
|
||||
// if(isset($_GET['restart_rascsi_service'])){
|
||||
// // Restart the RaSCSI service
|
||||
// exec("sudo /bin/systemctl restart rascsi.service");
|
||||
// } else if(isset($_GET['stop_rascsi_service'])){
|
||||
// // Stop the RaSCSI Service
|
||||
// exec("sudo /bin/systemctl stop rascsi.service");
|
||||
// } else if(isset($_GET['reboot_rasbperry_pi'])){
|
||||
// // Reboot the Raspberry Pi
|
||||
// exec("sudo /sbin/reboot");
|
||||
// } else if(isset($_GET['shutdown_raspberry_pi'])){
|
||||
// // Shut down the Raspberry Pi
|
||||
// echo "<h1>For now, shutdown is disabled....</h1>";
|
||||
// echo 'exec("sudo /sbin/shutdown -s -t 0");'.PHP_EOL;
|
||||
// }
|
||||
function action_eject_disk(){
|
||||
$command = 'rasctl -i '.$_POST['id'].' -c eject 2>&1'.PHP_EOL;
|
||||
exec($command, $retArray, $result);
|
||||
check_result($result, $command,$retArray);
|
||||
html_generate_ok_to_go_home();
|
||||
}
|
||||
|
||||
|
||||
// // Check if we're passed an ID
|
||||
// if(isset($_GET['id'])){
|
||||
// $id = $_GET['id'];
|
||||
// }
|
||||
// else {
|
||||
// html_generate_warning('Page opened without arguments');
|
||||
// }
|
||||
|
||||
// if(isset($_GET['type'])){
|
||||
// $type = type_string_to_rasctl_type($_GET['type']);
|
||||
// if(strlen($type) < 1){
|
||||
// html_generate_warning('Unknown drive type: '.$_GET['type']);
|
||||
// }
|
||||
|
||||
// $cmd = 'rasctl -i '.$id.' -c attach -t '.$type;
|
||||
|
||||
// // Check to see if the file name is specified
|
||||
// if(isset($_GET['file'])){
|
||||
// if(strcasecmp($_GET['file'],"None") != 0)
|
||||
// {
|
||||
// $cmd = $cmd.' -f '.$FILE_PATH.'/'.$_GET['file'];
|
||||
// }
|
||||
// }
|
||||
|
||||
// $result = "Command not ran.....";
|
||||
// // Go do the actual action
|
||||
// if(strlen($type) > 0){
|
||||
// $result = exec($cmd);
|
||||
// echo '<br>'.PHP_EOL;
|
||||
// echo 'Ran command: <pre>'.$cmd.'</pre>'.PHP_EOL;
|
||||
// echo '<br>'.PHP_EOL;
|
||||
// }
|
||||
// // Check to see if the command succeeded
|
||||
// if(strlen($result) > 0){
|
||||
// html_generate_warning($result);
|
||||
// }
|
||||
// else {
|
||||
// html_generate_success_message();
|
||||
// }
|
||||
// echo '<br>'.PHP_EOL;
|
||||
// html_generate_ok_to_go_home();
|
||||
// }
|
||||
// else {
|
||||
// html_generate_add_new_device(trim($id));
|
||||
|
||||
|
||||
|
||||
function action_eject_disk(){}
|
||||
function action_remove_device(){
|
||||
// Check to see if the user has confirmed
|
||||
if(isset($_POST['confirmed'])){
|
||||
$command = 'rasctl -i '.$_POST['id'].' -c disconnect 2>&1'.PHP_EOL;
|
||||
echo '<br><br> Go execute...... '.$command.PHP_EOL;
|
||||
// exec($command, $retArray, $result);
|
||||
// check_result($result, $command,$retArray);
|
||||
exec($command, $retArray, $result);
|
||||
check_result($result, $command,$retArray);
|
||||
html_generate_ok_to_go_home();
|
||||
}
|
||||
else{
|
||||
@ -143,13 +92,17 @@ function action_remove_device(){
|
||||
}
|
||||
}
|
||||
// function action_connect_new_device(){}
|
||||
function action_insert_disk(){}
|
||||
function action_insert_disk(){
|
||||
$command = 'rasctl -i '.$_POST['id'].' -c insert -f '.$GLOBALS['FILE_PATH'].'/'.$_POST['file_name'].' 2>&1'.PHP_EOL;
|
||||
exec($command, $retArray, $result);
|
||||
check_result($result, $command,$retArray);
|
||||
html_generate_ok_to_go_home();
|
||||
}
|
||||
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 '<br><br>'.$command.'<br><br>';
|
||||
check_result($result, $command, $retArray);
|
||||
html_generate_ok_to_go_home();
|
||||
}
|
||||
@ -216,6 +169,7 @@ function action_reboot_raspberry_pi(){
|
||||
if(isset($_POST['confirmed'])){
|
||||
echo('<br>exec(sleep 2 && sudo reboot)');
|
||||
// The unit should reboot at this point. Doesn't matter what we do now...
|
||||
html_generate_ok_to_go_home();
|
||||
}
|
||||
else{
|
||||
check_are_you_sure("Are you sure you want to reboot the Raspberry Pi?");
|
||||
@ -235,16 +189,16 @@ function action_shutdown_raspberry_pi(){
|
||||
}
|
||||
|
||||
function action_unknown_command(){
|
||||
echo '<br><h2>Unknown command: '.$_POST['command'].'</h2>'.PHP_EOL;
|
||||
html_generate_warning('<br><h2>Unknown command: '.$_POST['command'].'</h2>');
|
||||
html_generate_ok_to_go_home();
|
||||
}
|
||||
|
||||
function check_result($result,$command,$output){
|
||||
if(!$result){
|
||||
echo '<br><h2>Command succeeded!</h2>'.PHP_EOL;
|
||||
html_generate_success_message('Command succeeded!');
|
||||
}
|
||||
else{
|
||||
echo '<br><h2>Command failed!</h2>'.PHP_EOL;
|
||||
html_generate_warning('Command failed!');
|
||||
}
|
||||
echo '<br><code>'.$command.'</code><br>'.PHP_EOL;
|
||||
if(count($output) > 0){
|
||||
@ -261,11 +215,6 @@ function check_are_you_sure($prompt){
|
||||
echo ' <table style="border: none">'.PHP_EOL;
|
||||
echo ' <tr style="border: none">'.PHP_EOL;
|
||||
echo ' <td style="border: none; vertical-align:top;">'.PHP_EOL;
|
||||
echo ' <form action="rascsi.php" method="post">'.PHP_EOL;
|
||||
echo ' <input type="submit" name="cancel" value="Cancel" />'.PHP_EOL;
|
||||
echo ' </form>'.PHP_EOL;
|
||||
echo ' </td>'.PHP_EOL;
|
||||
echo ' <td style="border: none; vertical-align:top;">'.PHP_EOL;
|
||||
echo ' <form action="rascsi_action.php" method="post">'.PHP_EOL;
|
||||
foreach($_POST as $key => $value){
|
||||
echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>'.PHP_EOL;
|
||||
@ -274,11 +223,29 @@ function check_are_you_sure($prompt){
|
||||
echo ' <input type="submit" name="do_it" value="Yes" />'.PHP_EOL;
|
||||
echo ' </form>'.PHP_EOL;
|
||||
echo ' </td>'.PHP_EOL;
|
||||
echo ' <td style="border: none; vertical-align:top;">'.PHP_EOL;
|
||||
echo ' <form action="rascsi.php" method="post">'.PHP_EOL;
|
||||
echo ' <input type="submit" name="cancel" value="Cancel" />'.PHP_EOL;
|
||||
echo ' </form>'.PHP_EOL;
|
||||
echo ' </td>'.PHP_EOL;
|
||||
echo ' </tr>'.PHP_EOL;
|
||||
echo '</table>'.PHP_EOL;
|
||||
}
|
||||
|
||||
function action_connect_new_device(){
|
||||
// If we already know the type & filename, we can go connect the device...
|
||||
if(isset($_POST['type']) && isset($_POST['file_name'])){
|
||||
$command = 'rasctl -i '.$_POST['id'].' -c attach -t '.type_string_to_rasctl_type($_POST['type']);
|
||||
if($_POST['file_name'] != "None"){
|
||||
$command = $command.' -f '.$GLOBALS['FILE_PATH'].'/'.$_POST['file_name'];
|
||||
}
|
||||
exec($command, $retArray, $result);
|
||||
check_result($result, $command, $retArray);
|
||||
html_generate_ok_to_go_home();
|
||||
}
|
||||
else{
|
||||
|
||||
|
||||
$id = $_POST['id'];
|
||||
echo '<h2>Add New Device</h2>'.PHP_EOL;
|
||||
echo '<form action=rascsi_action.php method="post">'.PHP_EOL;
|
||||
@ -296,24 +263,9 @@ function action_connect_new_device(){
|
||||
echo ' </td>'.PHP_EOL;
|
||||
echo ' <td style="border: none">File:</td>'.PHP_EOL;
|
||||
echo ' <td style="border: none">'.PHP_EOL;
|
||||
echo ' <select name="file">'.PHP_EOL;
|
||||
echo ' <select name="file_name">'.PHP_EOL;
|
||||
echo ' <option value="None">None</option>'.PHP_EOL;
|
||||
$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 files that start with a .
|
||||
if(strpos($file_name, '.') === 0){
|
||||
continue;
|
||||
}
|
||||
|
||||
echo '<option value="'.$file_name.'">'.$file_name.'</option>'.PHP_EOL;
|
||||
}
|
||||
html_generate_image_file_select_list();
|
||||
echo ' </select>'.PHP_EOL;
|
||||
echo ' </td>'.PHP_EOL;
|
||||
echo ' <td style="border: none">'.PHP_EOL;
|
||||
@ -321,6 +273,7 @@ function action_connect_new_device(){
|
||||
echo ' </td>'.PHP_EOL;
|
||||
echo ' </tr>'.PHP_EOL;
|
||||
echo ' </table>'.PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
function get_new_filename(){
|
||||
|
86
src/php/rascsi_upload.php
Normal file
86
src/php/rascsi_upload.php
Normal file
@ -0,0 +1,86 @@
|
||||
<!-- PHP source code for controlling the RaSCSI - 68kmla edition with a web interface. -->
|
||||
<!-- Copyright (c) 2020 akuker -->
|
||||
<!-- Distributed under the BSD-3 Clause License -->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>RaSCSI Upload Page</title>
|
||||
<link rel="stylesheet" href="rascsi_styles.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
include 'lib_rascsi.php';
|
||||
html_generate_header();
|
||||
|
||||
echo '<br>';
|
||||
|
||||
if($GLOBALS['DEBUG_ENABLE']){
|
||||
echo '<table>'.PHP_EOL;
|
||||
echo ' <tr><td><p style="color:gray">Debug stuff</p></td></tr>'.PHP_EOL;
|
||||
echo ' <tr><td>';
|
||||
|
||||
echo '<p style="color:gray">Post values......................'.PHP_EOL;
|
||||
echo '<br> '.PHP_EOL;
|
||||
var_dump($_POST);
|
||||
echo '<br><br>'.PHP_EOL;
|
||||
var_dump($_FILES);
|
||||
echo '<br></p>'.PHP_EOL;
|
||||
echo '</td></tr></table>';
|
||||
}
|
||||
|
||||
$target_dir = $GLOBALS['FILE_PATH'].'/';
|
||||
$target_file = $target_dir.basename($_FILES['file_name']['name']);
|
||||
$upload_ok=1;
|
||||
$file_type = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
|
||||
|
||||
if(isset($_POST['submit']))
|
||||
{
|
||||
// Check if file already exists
|
||||
if ($upload_ok && (file_exists($target_file))) {
|
||||
html_generate_warning('Error: File '.$target_file.' already exists.');
|
||||
$upload_ok = 0;
|
||||
}
|
||||
|
||||
// Check file size. Limit is specified in lib_rascsi.php
|
||||
if ($upload_ok && ($_FILES["file_name"]["size"] > $GLOBALS['MAX_UPLOAD_FILE_SIZE'])) {
|
||||
html_generate_warning("Error: your file is larger than the maximum size of " . $GLOBALS['MAX_UPLOAD_FILE_SIZE'] . "bytes");
|
||||
$upload_ok = 0;
|
||||
}
|
||||
|
||||
// Allow certain file formats, also specified in lib_rascsi.php
|
||||
if($upload_ok && (!in_array(strtolower($file_type),$GLOBALS['ALLOWED_FILE_TYPES']))){
|
||||
$error_string = 'File type "'. $file_type. '" is not currently allowed.'.
|
||||
'Only the following file types are allowed: <br>'.
|
||||
'<ul>'.PHP_EOL;
|
||||
foreach($GLOBALS['ALLOWED_FILE_TYPES'] as $ft){
|
||||
$error_string = $error_string. '<li>'.$ft.'</li>'.PHP_EOL;
|
||||
}
|
||||
$error_string = $error_string.'</ul>';
|
||||
$error_string = $error_string.'<br>';
|
||||
html_generate_warning($error_string);
|
||||
$upload_ok = 0;
|
||||
}
|
||||
|
||||
//Check if $upload_ok is set to 0 by an error
|
||||
if ($upload_ok != 0) {
|
||||
if (move_uploaded_file($_FILES["file_name"]["tmp_name"], $target_file)) {
|
||||
html_generate_success_message(basename( $_FILES["file_name"]["name"]). " has been uploaded.");
|
||||
} else {
|
||||
html_generate_warning("There was an unknown error uploading your file.");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
html_generate_warning('The Submit POST information was not populated. Something went wrong');
|
||||
}
|
||||
echo '<br>';
|
||||
|
||||
html_generate_ok_to_go_home();
|
||||
?>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user