IMGLoad 2.1

Zukünftige Releases

  • Version: 2.2
  • Veröffentlichung: unklar
  • Features: CSS, saubere Verlinkung
  • Status: 0% completed

Autor

written by PsyCore 2007/2008

Verzeichnisstruktur

  • config.php
  • footer.php
  • header.php
  • show.php
    • /admin/form.php
    • /admin/functions.php
    • /admin/list.php
    • /admin/upload.php
      • /admin/img/delete.png

config.php

config.php
<?php
	$max_byte_size = 5242880; //maximale Dateigröße in Byte
	$allowed_types = "(jpg|jpeg|gif|png)"; //Erlaubte Dateiendungen
	$host = "http://www.electrohead.de/bilder/"; //Host zu den Bildern (z.B. http://www.meineseite.de/bilder/)
	$uldir = "../bilder/"; //Upload Verzeichnis z.B. bilder/ (Muss mit / enden!!!)
	DEFINE("SQLDB", "dbname");
	DEFINE("SQLUSER", "dbuser");
	DEFINE("SQLPASS", "dbpass");
	DEFINE("ADMIN", ""); //Login Name (Funktion noch nicht aktiv)
	DEFINE("PASS", ""); //Login Passwort (Funktion noch nicht aktiv)
	DEFINE("VERSION", "2.1"); //Bitte nicht ändern
?>

footer.php

footer.php
<?PHP
/**
* IMGLoad by PsyCore
* small Image Uploader with link output
* edit config.php to change options
*/
 
echo '<hr>';
echo '<p align="center"><a href="http://validator.w3.org/check?uri=referer">'.
     '<img src="http://www.w3.org/Icons/valid-html401-blue"'.
     'alt="Valid HTML 4.01 Transitional" height="31" width="88"></a></p>';
echo '<p align="center"><font size="2" face="Trebuchet MS">&nbsp;&copy; 2008 by ';
echo '<a href="http://www.hellhost.de">hellhost.de</a> /';
echo '<a href="http://defcon.hellhost.de">DefCon-1</a><br>';
echo 'Codename: Gammatron</font></p>';
echo '</body>';
echo '</html>';
?>

form.php

form.php
<?PHP
	include('../config.php');
	include('../header.php');
?>
<a href="list.php">List Gallery</a><br><br>
<form action="upload.php" method="post" enctype="multipart/form-data" name="upload">
<font face="Trebuchet MS">
<input type="file" name="file"><input type="submit" name="submit" value="Upload">
</font>
</form>
<p><font face="Trebuchet MS">Datei wählen und dann hochladen...</font></p>
<?PHP
	include('../footer.php');
?>

header.php

header.php
<?PHP
/**
* IMGLoad by PsyCore
* small Image Uploader with link output
* edit config.php to change options
*/
 
include('config.php');
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">';
echo '<html><head><title>IMGLoad '.VERSION.' by PsyCore</title></head>';
echo '<body>';
echo '<p align="left"><font face="Trebuchet MS"><font color="#99CCFF"><b><font size="7">IMGLoad&nbsp;</font><font size="7">'.VERSION.'&nbsp;</font></b></font><br>';
echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;by PsyCore<br></font></p>';
echo '<hr>';
?>

upload.php

upload.php
<?php
 
/**
* IMGLoad by PsyCore
* small Image Uploader with link output
* edit config.php to change options
*/
 
include('../config.php');
include('../header.php');
echo '<br><a href="list.php">List all Pictures</a><br>';
if($_POST["submit"] == "Upload") {
  if(is_uploaded_file($_FILES["file"]["tmp_name"])) { 
    if(preg_match("/\." . $allowed_types . "$/i", $_FILES["file"]["name"])) { 
      if($_FILES["file"]["size"] <= $max_byte_size) { 
        if(copy($_FILES["file"]["tmp_name"], '../'.$uldir.$_FILES["file"]["name"])) {
          $ufile = $host.$_FILES["file"]["name"];
          chmod('../'.$uldir.$_FILES["file"]["name"],0744);
          $picture = $_FILES["file"]["name"];
          $src = imagecreatefromjpeg('../'.$uldir. $_FILES["file"]["name"]);
          $width = ImageSX($src);
          $height = ImageSY($src);
          $image_p = imagecreatetruecolor(150, 150);
          imagecopyresized($image_p, $src, 0,0,0,0, 150, 150, $width, $height);
          imagejpeg($image_p, '../'.$uldir.'thumbs/th_'.$picture);
          chmod('../'.$uldir.'thumbs/th_'.$picture,0744);
          $fname = $_FILES["file"]["name"];
          $fsize = $_FILES["file"]["size"];
          $ftype = $_FILES["file"]["type"];
          $flink = '<a href="../show.php?id=' . $_FILES["file"]["name"] . '">'. $_FILES["file"]["name"].'</a>';
          $furl = $ufile;
          $fforum = '[IMG]'.$ufile.'[/IMG]';
          $fthumb = '<a href="../show.php?id='.$_FILES["file"]["name"].'"><img src="../'.$uldir.'thumbs/th_'.$picture.'" alt="Thumbnail"></a>';
          mysql_connect(localhost,SQLUSER,SQLPASS);
          @mysql_select_db(SQLDB) or die("unable to select database");
          mysql_query("INSERT INTO imgload 
          VALUES (
            '',
            '$fname',
            '$fsize',
            '$ftype',
            '$flink',
            '$furl',
            '$fforum',
            '$fthumb')") or die(mysql_error());
          mysql_close();
          echo '<b>Datei erfolgreich hochgeladen!</b><br>';
          echo '<table border="1" style="border-collapse: collapse">'; 
          echo '<tr><th>Name:</th><th bgcolor="#D9FFD9"> &nbsp;' . $fname . '&nbsp;</th></tr>'; 
          echo '<tr><th>Größe:</th><th bgcolor="#D9FFD9"> &nbsp;' . $fsize . ' Bytes&nbsp;</th></tr>'; 
          echo '<tr><th>MIME-Type:</th><th bgcolor="#D9FFD9"> &nbsp;' . $ftype . '&nbsp;</th></tr>'; 
          echo '<tr><th>Link:</th><th bgcolor="#D9FFD9"> &nbsp;'.$flink.'&nbsp';
          echo '<tr><th>URL:</th><th bgcolor="#D9FFD9"> '.$furl.'</th></tr>';
          echo '<tr><th>Forum:</th><th bgcolor="#D9FFD9"> &nbsp;'.$fforum.'&nbsp;</th></tr>';
          echo '<tr><th>Thumb:</th><th bgcolor="#D9FFD9">&nbsp;'.$fthumb.'&nbsp;</th></tr>';
          echo '</table>'; 
        } 
      else { 
          echo 'Datei konnte nicht hochgeladen werden.'; 
          } 
        } 
      else { 
          echo 'Die Datei darf nur eine Größe von ' . $max_byte_size . ' Bytes besitzen.'; 
          } 
        } 
    else { 
          echo 'Die Datei besitzt keine gültige Endung.'; 
          } 
        } 
    else { 
        echo 'Keine Datei zum Hochladen angegeben.'; 
         } 
     } 
  else { 
     echo 'Bitte benutzen Sie das Upload Formular.'; 
}
include('../footer.php'); 
?>

show.php

show.php
<?php
 
/**
* IMGLoad by PsyCore
* small Image Uploader with link output
* edit config.php to change options
*/
 
include('header.php');
if (isset($_GET[id])) {
 $ID = $_GET[id];
	mysql_connect(localhost,SQLUSER,SQLPASS);
	@mysql_select_db(SQLDB) or die("unable to select database");
	$query = "	SELECT *
				FROM imgload
				WHERE NAME='".mysql_real_escape_string($ID)."'
				LIMIT 0 , 30";
	$result = mysql_query($query);
	$fname = mysql_result($result,0,NAME);
	$fsize = mysql_result($result,0,SIZE);
	$ftype = mysql_result($result,0,MIME);
	$flink = mysql_result($result,0,LINK);
	$furl = mysql_result($result,0,URL);
	$fforum = mysql_result($result,0,FORUM);
	mysql_close(); 
echo '<center><table border="1" style="border-collapse: collapse">';
echo '<tr><th>&nbsp;Dateiname&nbsp;</th><th>&nbsp;Größe&nbsp;</th><th>&nbsp;Typ&nbsp;</th>
	<th>&nbsp;URL&nbsp;</th><th>&nbsp;BBCode&nbsp;</th></tr>';
echo '<tr><th>&nbsp;'.$fname.'&nbsp;</th><th>&nbsp;'.$fsize.' bytes&nbsp;</th><th>&nbsp;'.$ftype.'
	&nbsp;</th><th>&nbsp;'.$flink.'&nbsp;</th><th>&nbsp;'.$fforum.'&nbsp;</th></tr>';
echo '</table><br><br>';
echo '<img src="'.$furl.'" alt="IMGLoad: '.$fname.'"></center><br>';
include('footer.php');
 }
 else { echo 'Kein Parameter übergeben'; }
 ?>

list.php

list.php
<?php
 
/**
* IMGLoad by PsyCore
* small Image Uploader with link output
* edit config.php to change options
*/
 
include('../config.php');
include('../header.php');
 
echo '<br><a href="form.php">Image Upload<br></a>';
mysql_connect(localhost,SQLUSER,SQLPASS);
@mysql_select_db(SQLDB) or die("unable to select database");
 
$select=mysql_query("select MAX(ID) from imgload");
$zeile=mysql_result($select,0);
//echo $zeile;
echo '<table border="0" bgcolor="#FFFFFF">';
echo '  <tr>';
 
$counter = 1;
$tablebreak = 1;
 
while ($counter <= $zeile) {
$query = "	SELECT THUMB, URL
				FROM imgload
				WHERE ID='".mysql_real_escape_string($counter)."'
				LIMIT 0 , 30";
 
$result = mysql_query($query);
if (mysql_num_rows($result)==1) {
	$fthumb = mysql_result($result,0,THUMB);
	$furl = mysql_result($result,0,URL);
	echo '    <td>&nbsp;'.$fthumb.'<br>&nbsp;<a href="functions.php?delete='.$counter.'"><img src="img/delete.png" ALT="delete this"></a>&nbsp;<a href="'.$furl.'">Full Size</a></td>';
	$tablebreak++;
	}
if ($tablebreak == 5) {
	echo '</tr><tr>';
	$tablebreak = 1;
	}
$counter++;
//echo '  </tr>';
}
if ($tablebreak != 5) echo '</tr>';
echo '</table>';
mysql_close();
include('../footer.php');
?>

functions.php

functions.php
<?PHP
/**
* IMGLoad by PsyCore
* small Image Uploader with link output
* edit config.php to change options
*/
include('../config.php');
include('../header.php');
if (isset($_GET[delete])) {
$DelID = $_GET[delete];
echo 'Picture ID to delete: '.$DelID.'<br>';
mysql_connect(localhost,SQLUSER,SQLPASS);
@mysql_select_db(SQLDB) or die("unable to select database");
$query1 = 'SELECT NAME FROM imgload WHERE ID = '.mysql_real_escape_string($DelID).' LIMIT 1';
$query2 = 'DELETE FROM imgload WHERE ID = '.mysql_real_escape_string($DelID).' LIMIT 1';
$result = mysql_query($query1);
$datei1 = '../'.$uldir.mysql_result($result,0);
$datei2 = '../'.$uldir.'thumbs/th_'.mysql_result($result,0);
echo 'Picture Name to delete: '.$datei1.'<br>';
echo 'Thumb Name to delete: '.$datei2.'<br>';
unlink($datei1);
unlink($datei2);
$result = mysql_query($query2);
mysql_close();
 
echo 'Entries deleted<br>';
echo '<br><a href="list.php">Go back</a><br>';
}
include('../footer.php');
?>

mySQL Datenbank

imgload.sql
-- phpMyAdmin SQL Dump
-- version 2.9.0.3-Debian-1
-- http://www.phpmyadmin.net
-- 
-- Host: localhost
-- Erstellungszeit: 12. Februar 2008 um 15:57
-- 
-- IMGLoad Database
-- 
-- --------------------------------------------------------
 
-- 
-- Tabellenstruktur für Tabelle `imgload`
-- 
 
CREATE TABLE `imgload` (
  `ID` INT(10) NOT NULL AUTO_INCREMENT,
  `NAME` VARCHAR(255) NOT NULL,
  `SIZE` VARCHAR(25) NOT NULL,
  `MIME` VARCHAR(255) NOT NULL,
  `LINK` VARCHAR(255) NOT NULL,
  `URL` VARCHAR(255) NOT NULL,
  `FORUM` VARCHAR(255) NOT NULL,
  `THUMB` VARCHAR(255) NOT NULL,
  PRIMARY KEY  (`ID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COMMENT='IMGLoad Table' AUTO_INCREMENT=5 ;
 
-- 
-- Daten für Tabelle `imgload`
-- 
 
INSERT INTO `imgload` (`ID`, `NAME`, `SIZE`, `MIME`, `LINK`, `URL`, `FORUM`, `THUMB`) VALUES 
(1, 'brand_neg.jpg', '11429', 'image/jpeg', '<a href="../show.php?id=brand_neg.jpg">brand_neg.jpg</a>', 'http://www.electrohead.de/bilder/brand_neg.jpg', '[IMG]http://www.electrohead.de/bilder/brand_neg.jpg[/IMG]', '<a href="../show.php?id=brand_neg.jpg"><img src="../../bilder/thumbs/th_brand_neg.jpg" alt="Thumbnail"></a>'),
(3, 'combichrist1_ml.jpg', '147661', 'image/jpeg', '<a href="../show.php?id=combichrist1_ml.jpg">combichrist1_ml.jpg</a>', 'http://www.electrohead.de/bilder/combichrist1_ml.jpg', '[IMG]http://www.electrohead.de/bilder/combichrist1_ml.jpg[/IMG]', '<a href="../show.php?id=combichrist1_ml.jpg"><img src="../../bilder/thumbs/th_combichrist1_ml.jpg" alt="Thumbnail"></a>'),
(4, 'schaeuble.jpg', '136376', 'image/jpeg', '<a href="../show.php?id=schaeuble.jpg">schaeuble.jpg</a>', 'http://www.electrohead.de/bilder/schaeuble.jpg', '[IMG]http://www.electrohead.de/bilder/schaeuble.jpg[/IMG]', '<a href="../show.php?id=schaeuble.jpg"><img src="../../bilder/thumbs/th_schaeuble.jpg" alt="Thumbnail"></a>');
Drucken/exportieren
QR-Code
QR-Code IMGLoad 2.1 (erstellt für aktuelle Seite)