Initial commit: Backup der Webseiten
- zoesch.de - blitzkiste.net - gruene-hassberge (norbert.zoesch.de) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
17
zoesch.de/ImageUpload/classes/Page_Data.class.php
Normal file
17
zoesch.de/ImageUpload/classes/Page_Data.class.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
class Page_Data
|
||||
{
|
||||
public $title = "";
|
||||
public $content = "";
|
||||
public $css = "";
|
||||
public $embeddedStyle = "";
|
||||
public $scriptElements = "";
|
||||
|
||||
//declare methods
|
||||
public function addScript( $src ){
|
||||
$this->scriptElements .= "<script src='$src'></script>";
|
||||
}
|
||||
public function addCSS( $href ){
|
||||
$this->css .= "<link href='$href' rel='stylesheet' />";
|
||||
}
|
||||
}
|
||||
33
zoesch.de/ImageUpload/classes/Uploader.class.php
Normal file
33
zoesch.de/ImageUpload/classes/Uploader.class.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
class Uploader
|
||||
{
|
||||
private $filename;
|
||||
private $fileData;
|
||||
private $destination;
|
||||
|
||||
//declare a constructor method
|
||||
public function __construct($key)
|
||||
{
|
||||
$this->filename = $_FILES[$key]['name'];
|
||||
$this->fileData = $_FILES[$key]['tmp_name'];
|
||||
}
|
||||
|
||||
public function saveIn($folder)
|
||||
{
|
||||
$this->destination = $folder;
|
||||
}
|
||||
public function save()
|
||||
{
|
||||
$folderIsWriteAble = is_writable($this->destination);
|
||||
if ($folderIsWriteAble) {
|
||||
$name = "$this->destination/$this->filename";
|
||||
$succes = move_uploaded_file($this->fileData, $name);
|
||||
} else {
|
||||
trigger_error("cannot write to $this->destination");
|
||||
$succes = false;
|
||||
}
|
||||
|
||||
return $succes;
|
||||
}
|
||||
}
|
||||
1
zoesch.de/ImageUpload/css/layout.css
Normal file
1
zoesch.de/ImageUpload/css/layout.css
Normal file
@@ -0,0 +1 @@
|
||||
h1 {color:red;}
|
||||
5
zoesch.de/ImageUpload/css/navigation.css
Normal file
5
zoesch.de/ImageUpload/css/navigation.css
Normal file
@@ -0,0 +1,5 @@
|
||||
nav a {
|
||||
text-decoration: none;
|
||||
color: black;
|
||||
}
|
||||
nav a:hover {text-decoration: underline;}
|
||||
BIN
zoesch.de/ImageUpload/img/56.jpg
Normal file
BIN
zoesch.de/ImageUpload/img/56.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 82 KiB |
BIN
zoesch.de/ImageUpload/img/80.jpg
Normal file
BIN
zoesch.de/ImageUpload/img/80.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
BIN
zoesch.de/ImageUpload/img/Ashlecker.jpg
Normal file
BIN
zoesch.de/ImageUpload/img/Ashlecker.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 137 KiB |
BIN
zoesch.de/ImageUpload/img/header_3.jpg
Normal file
BIN
zoesch.de/ImageUpload/img/header_3.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 352 KiB |
20
zoesch.de/ImageUpload/index.php
Normal file
20
zoesch.de/ImageUpload/index.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
//complete code for index.php
|
||||
error_reporting(E_ALL);
|
||||
ini_set("display_errors", 1);
|
||||
include_once "classes/Page_Data.class.php";
|
||||
$pageData = new Page_Data();
|
||||
$pageData->addScript("js/lightbox.js");
|
||||
$pageData->title = "Dynamic image gallery";
|
||||
$pageData->addCSS("css/layout.css");
|
||||
$pageData->addCSS("css/navigation.css");
|
||||
$pageData->content = include_once "views/navigation.php";
|
||||
$userClicked = isset($_GET["page"]);
|
||||
if ($userClicked) {
|
||||
$fileToLoad = $_GET["page"];
|
||||
} else {
|
||||
$fileToLoad = "gallery";
|
||||
}
|
||||
$pageData->content .= include_once "views/$fileToLoad.php";
|
||||
$page = include_once "templates/page.php";
|
||||
echo $page;
|
||||
0
zoesch.de/ImageUpload/js/lightbox.js
Normal file
0
zoesch.de/ImageUpload/js/lightbox.js
Normal file
15
zoesch.de/ImageUpload/templates/page.php
Normal file
15
zoesch.de/ImageUpload/templates/page.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
return "<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>$pageData->title</title>
|
||||
<meta http-equiv='Content-Type' content='text/html;charset=utf-8' />
|
||||
$pageData->css
|
||||
$pageData->embeddedStyle
|
||||
</head>
|
||||
<body>
|
||||
$pageData->content
|
||||
$pageData->scriptElements
|
||||
</body>
|
||||
</html>";
|
||||
25
zoesch.de/ImageUpload/views/gallery.php
Normal file
25
zoesch.de/ImageUpload/views/gallery.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
//function call
|
||||
return showImages();
|
||||
//function defintion
|
||||
function showImages()
|
||||
{
|
||||
$out = '<h1>Image Gallery</h1>';
|
||||
$out .= "<ul id='images'>";
|
||||
$folder = 'img';
|
||||
$filesInFolder = new DirectoryIterator($folder);
|
||||
while ($filesInFolder->valid()) {
|
||||
$file = $filesInFolder->current();
|
||||
$filename = $file->getFilename();
|
||||
$src = "$folder/$filename";
|
||||
$fileInfo = new Finfo(FILEINFO_MIME_TYPE);
|
||||
$mimeType = $fileInfo->file($src);
|
||||
if ($mimeType === 'image/jpeg') {
|
||||
$out .= "<li><img src='$src' /></li>";
|
||||
}
|
||||
$filesInFolder->next();
|
||||
}
|
||||
$out .= '</ul>';
|
||||
|
||||
return $out;
|
||||
}
|
||||
7
zoesch.de/ImageUpload/views/navigation.php
Normal file
7
zoesch.de/ImageUpload/views/navigation.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
return "
|
||||
<nav>
|
||||
<a href='index.php?page=gallery'>Gallery</a>
|
||||
<a href='index.php?page=upload'>Upload new image</a>
|
||||
</nav>
|
||||
";
|
||||
8
zoesch.de/ImageUpload/views/upload-form.php
Normal file
8
zoesch.de/ImageUpload/views/upload-form.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
return "
|
||||
Upload new jpg images</h1>
|
||||
<form method='post' action='index.php?page=upload' enctype='multipart/form-data' >
|
||||
<label>Find a jpg image to upload</label>
|
||||
<input type='file' name='image-data' accept='image/jpeg'/>
|
||||
<input type='submit' value='upload' name='new-image' />
|
||||
</form>";
|
||||
29
zoesch.de/ImageUpload/views/upload.php
Normal file
29
zoesch.de/ImageUpload/views/upload.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
//complete source code for views/upload.php
|
||||
//$newImageSubmitted is TRUE if form was submitted, otherwise FALSE
|
||||
$newImageSubmitted = isset($_POST['new-image']);
|
||||
if ($newImageSubmitted) {
|
||||
//this code runs if form was submitted
|
||||
$output = upload();
|
||||
} else {
|
||||
//this runs if form was NOT submitted
|
||||
$output = include_once 'views/upload-form.php';
|
||||
}
|
||||
|
||||
return $output;
|
||||
//declare new function
|
||||
function upload()
|
||||
{
|
||||
include_once 'classes/Uploader.class.php';
|
||||
//image-data is the name attribute used in <input type='file' />
|
||||
$uploader = new Uploader('image-data');
|
||||
$uploader->saveIn('img');
|
||||
$fileUploaded = $uploader->save();
|
||||
if ($fileUploaded) {
|
||||
$out = 'new file uploaded';
|
||||
} else {
|
||||
$out = 'something went wrong';
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
Reference in New Issue
Block a user