Skip to content
Snippets Groups Projects
Commit 27ae1d3d authored by Johannes Feldmann's avatar Johannes Feldmann
Browse files

Website added

parent c958f2fa
No related branches found
No related tags found
No related merge requests found
upload_max_filesize = "20M"
post_max_size = "25M"
\ No newline at end of file
<?php
if(isset($_POST["start_bitstream"])) {
start_bitstream($_POST["start_bitstream"]);
// header("Location: " . $_SERVER['REQUEST_URI']);
}
if(isset($_POST["delete_bitstream"])) {
delete_bitstream($_POST["delete_bitstream"]);
// header("Location: " . $_SERVER['REQUEST_URI']);
}
function get_bitstream() {
$bit = array();
// Files in /lib/firmware
if ($handle = opendir('/lib/firmware')) {
// Eintrge erstellen
while (false !== ($entry = readdir($handle))) {
if ($entry != '.' && $entry != '..') {
$bit[] = $entry;
}
}
closedir($handle);
}
return $bit;
}
function build_table($array){
// data rows
foreach( $array as $key => $value){
echo '<tr>';
echo '<td>' . $value . '</td>';
echo '<td>
<form action="?start_bitstream" method="post">
<input type="hidden" name="start_bitstream" value="'.$value.'">
<input type="submit" value="Load to FPGA">
</form>
</td>';
echo '<td>
<form action="?delete_bitstream" method="post">
<input type="hidden" name="delete_bitstream" id ="delete_bitstream" value="'.$value.'">';
if(check_link($value)){
echo '<input type="submit" value="Delete" disabled>';
}
else {
echo '<input type="submit" value="Delete" >';
}
echo '</form>
</td>
</tr>';
}
}
function start_bitstream($name) {
// echo '/var/www/scripts/load_bitstream.sh ' . $name;
$ret = exec('/var/www/scripts/load_bitstream.sh ' . $name);
// echo $ret;
if ($ret != 'operating') {
echo '<script language="javascript">alert("Error loading bitstream '.$name.' - '.$ret.'")</script>';
}
}
function delete_bitstream($name) {
// echo $name.'<br>';
// echo 'rm /lib/firmware/' . $name;
$ret = exec('rm /lib/firmware/' . $name);
// echo $ret;
if ($ret != '') {
echo '<script language="javascript">alert("Error deleting bitstream '.$name.' - '.$ret.'")</script>';
}
}
function check_link($name) {
$ret = exec('ls -l /lib/firmware/' . $name);
if($ret[0] == 'l') {
# Link
return true;
}
return false;
}
?>
\ No newline at end of file
<?php
//error handler function
function customError($errno, $errstr) {
echo "<b>Error:</b> [$errno] $errstr";
}
//set error handler
set_error_handler("customError");
?>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Welcome page</title>
<style type="text/css" media="screen">
body { background: #e7e7e7; font-family: Verdana, sans-serif; font-size: 11pt; }
#page { background: #ffffff; margin: 50px; border: 2px solid #c0c0c0; padding: 10px; }
#header { background: #4b6983; border: 2px solid #7590ae; text-align: center; padding: 10px; color: #ffffff; }
#header h1 { color: #ffffff; }
#body { padding: 10px; }
span.tt { font-family: monospace; }
span.bold { font-weight: bold; }
a:link { text-decoration: none; font-weight: bold; color: #C00; background: #ffc; }
a:visited { text-decoration: none; font-weight: bold; color: #999; background: #ffc; }
a:active { text-decoration: none; font-weight: bold; color: #F00; background: #FC0; }
a:hover { text-decoration: none; color: #C00; background: #FC0; }
</style>
</head>
<body>
<div id="page">
<div id="header">
<h1> Placeholder page </h1>
The owner of this web site has not put up any web pages yet. Please come back later.
</div>
<div id="body">
<h2>You should replace this page with your own web pages as soon as possible.</h2>
Unless you changed its configuration, your new server is configured as follows:
<ul>
<li>Configuration files can be found in <span class="tt">/etc/lighttpd</span>. Please read <span class="tt">/etc/lighttpd/conf-available/README</span> file.</li>
<li>The DocumentRoot, which is the directory under which all your HTML files should exist, is set to <span class="tt">/var/www/html</span>.</li>
<li>CGI scripts are looked for in <span class="tt">/usr/www/cgi-bin</span>, which is where Debian packages will place their scripts. You can enable cgi module by using command <span class="bold tt">&quot;lighty-enable-mod cgi&quot;</span>.</li>
<li>Log files are placed in <span class="tt">/var/log/lighttpd</span>, and will be rotated weekly. The frequency of rotation can be easily changed by editing <span class="tt">/etc/logrotate.d/lighttpd</span>.</li>
<li>The default directory index is <span class="tt">index.html</span>, meaning that requests for a directory <span class="tt">/foo/bar/</span> will give the contents of the file /var/www/foo/bar/index.html if it exists (assuming that <span class="tt">/var/www</span> is your DocumentRoot).</li>
<li>You can enable user directories by using command <span class="bold tt">&quot;lighty-enable-mod userdir&quot;</span></li>
</ul>
<h2>About this page</h2>
<p>
This is a placeholder page installed by the Debian release of the <a href="http://packages.debian.org/lighttpd">Lighttpd server package.</a>
</p>
<p>
This computer has installed the Debian GNU/Linux operating system, but it has nothing to do with the Debian Project. Please do not contact the Debian Project about it.
</p>
<p>
If you find a bug in this Lighttpd package, or in Lighttpd itself, please file a bug report on it. Instructions on doing this, and the list of known bugs of this package, can be found in the
<a href="http://bugs.debian.org/cgi-bin/pkgreport.cgi?pkg=lighttpd">Debian Bug Tracking System.</a>
</p>
</div>
</div>
<!-- s:853e9a42efca88ae0dd1a83aeb215047 -->
<a href="env.cgi">Test</a>
<!-- #exec cgi="/cgi-bin/env.cgi" -->
</body>
</html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body>
<?php
include 'error.php';
include 'bitstream.php';
include 'upload.php';
?>
<br>
<h2>Available Bitstreams:</h2>
<table>
<thead>
<tr><th>Name</th><th class="fixed"></th><th class="fixed"></th></tr>
</thead>
<tbody>
<?php build_table(get_bitstream()); ?>
</tbody>
</table>
<h2>Upload Bitstream:</h2>
<p><?php print_upload(); ?></p>
</body>
</html>
table {
border-collapse: collapse;
width: 80%;
margin-left:auto;
margin-right:auto;
}
th, td {
text-align: left;
padding: 8px;
}
tr:nth-child(even){background-color: #f2f2f2}
th {
background-color: #4CAF50;
color: white;
}
th.fixed {
width: 50px
}
h2 {
margin-left: 25px
}
p {
margin-left: 50px
}
\ No newline at end of file
<?php
function upload()
{
$target_dir = "/var/www/uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
// Check if file already exists
//if (file_exists($target_file)) {
// echo "Sorry, file already exists.";
// $uploadOk = 0;
//}
// Check file size
if ($_FILES["fileToUpload"]["size"] > 500000) {
echo "Sorry, your file is too large.";
$uploadOk = 0;
}
// Allow certain file formats
if($imageFileType != "bit.bin") {
echo "Only file type *.bit.bin allowed.<br>";
$uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";
}
}
}
echo '<p>This is a PHP script</p>';
$uploaddir = '/var/www/uploads/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
// Files in /lib/firmware
if ($handle = opendir('/lib/firmware')) {
echo 'Verzeichnis-Handle: '. $handle .'<br>';
echo "Eintrge:\n";
// Tabelle erstellen
echo '<table><thead><tr><th>File</th><th></th></tr></thead><tbody><tr>';
// Eintrge erstellen
while (false !== ($entry = readdir($handle))) {
if ($entry != '.' && $entry != '..') {
echo "<td>$entry</td><td></td>";
}
}
echo '</tr></tbody></table>';
closedir($handle);
}
if (isset($_POST['userfile'])) {
upload();
echo '<script language="javascript">alert("message successfully sent")</script>';
}
else
{
print_upload();
}
function print_upload() {
echo '
<!-- Die Encoding-Art enctype MUSS wie dargestellt angegeben werden -->
<form enctype="multipart/form-data" action="" method="POST">
<!-- MAX_FILE_SIZE muss vor dem Dateiupload Input Feld stehen -->
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
<!-- Der Name des Input Felds bestimmt den Namen im $_FILES Array -->
Diese Datei hochladen: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>
';
}
?>
\ No newline at end of file
<?php
if(isset($_POST["upload"])) {
//upload();
if($_FILES["fileToUpload"] == "") {
echo "empty";
} else {
$target_file = basename($_FILES["fileToUpload"]["name"]);
echo $target_file . "</br>";
check_upload();
}
// header("Location: " . $_SERVER['REQUEST_URI']);
}
function check_upload() {
$target_dir = "/lib/firmware/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$BinFileType = pathinfo($target_file,PATHINFO_EXTENSION);
$BitFileType = pathinfo(pathinfo($target_file, PATHINFO_FILENAME), PATHINFO_EXTENSION);
// Check if file already exists
//if (file_exists($target_file)) {
// echo "Sorry, file already exists.";
// $uploadOk = 0;
//}
// Check file size
if ($_FILES["fileToUpload"]["size"] > 10000000) {
echo "Sorry, your file is too large.";
$uploadOk = 0;
}
// Allow certain file formats
if($BinFileType != "bin" && $BitFileType != "bit") {
echo "Only file type *.bit.bin allowed.<br>";
$uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";
}
}
}
function print_upload() {
echo '
<!-- Die Encoding-Art enctype MUSS wie dargestellt angegeben werden -->
<form enctype="multipart/form-data" action="?upload" method="POST">
<!-- MAX_FILE_SIZE muss vor dem Dateiupload Input Feld stehen -->
<input type="hidden" name="MAX_FILE_SIZE" value="100000000" />
<!-- Der Name des Input Felds bestimmt den Namen im $_FILES Array -->
<p>Diese Datei hochladen: <input name="fileToUpload" type="file" id="fileToUpload" /></p>
<p><input type="submit" name="upload" value="Upload File" /></p>
</form>
';
}
?>
#/bin/bash
# sh scriptname 1
if [ $# -ne 1 ]
then
echo "ERROR: # Arguments not equal to 1 ($#)."
else
echo "$1" > /sys/class/fpga_manager/fpga0/firmware
cat /sys/class/fpga_manager/fpga0/state
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment