MyUploader v.1.0 by Host4clan
Auteur: Serial - 12 juni 2005 - 09:50 - Gekeurd door: Joel - Hits: 16834 - Aantal punten: 4.00 (5 stemmen)
MyUploader - V.1.0
By Host4clan.nl: Michiel - michiel@host4clan.nl (Serial)
Gamehosting - Teamspeakhosting - Webhosting - Domainregistration
-== XXXXXXXXXXXX ==-
-=Beschrijving=-
- Simpele, maar werkende (zonder MySQL) met wachtwoord beveiligde, image-uploader inclusief album!
-=Benodigdheden=-
- Host voorzien van PHP ondersteuning
- FTP toegang, CHMOD functie is nodig!
- Je eigen verstand ;)
-=Installatie=-
- Upload de bestanden index.php ; logout.php ; upload.php ; validate.php naar een directory.
- In die map upload je de map images, en CHMOD deze naar 777.
- Open validate.php , ga naar regel 15 en 16 en bewerk je inloggegevens.
- Open upload.php , daar kun je eventuele foutmeldingen en berichten wijzigen.
-=====-
Fouten a.u.b. melden aan michiel@host4clan.nl.
Thnx
[u]Downloadlink is gebroken, host is permanent down.. binnenkort nieuwe versie en downloadlink[/u]
|
Code: |
Simpele, maar werkende (zonder MySQL) met wachtwoord beveiligde, image-uploader.
Standaard user: admin
Standaaard pass: mijnpass
Link naar voorbeeld: http://serial.host4clan.nl/testupload
Codes:
index.php in myuploader directory:
<html>
<head>
<title>Login Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body bgcolor="C6E2F3">
<p><strong>MyUploader - By Host4clan.nl: Michiel</strong></p>
<table width="400" align="center">
<tr>
<th valign=top> User en pass benodigd voor upload.</th>
</tr>
<tr>
<td>
<p> </p>
<?
//if no cookie is set then display the form
if(!isset($_COOKIE["this_cookie"])){
echo '<div align="center"><form action="validate.php" method="post">';
echo 'username : <input type="text" name="username"><br><br>';
echo 'password : <input type="password" name="password"><br><br>';
echo '<input type="submit" value="login"></form></div>';
}else{
echo "Je bent al ingelogd op MyUploader. <a href=\"upload.php\">Klik hier om verder te gaan</a>";
}
?>
</td>
</tr>
</table>
</body>
</html>
<html> <head> <title>Login Page</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head> <body bgcolor="C6E2F3"> <p><strong>MyUploader - By Host4clan.nl: Michiel</strong></p> <table width="400" align="center"> <tr> <th valign=top> User en pass benodigd voor upload.</th> </tr> <tr> <td> <p> </p> <? //if no cookie is set then display the form if(!isset($_COOKIE["this_cookie"])){ echo '<div align="center"><form action="validate.php" method="post">'; echo 'username : <input type="text" name="username"><br><br>'; echo 'password : <input type="password" name="password"><br><br>'; echo '<input type="submit" value="login"></form></div>'; }else{ echo "Je bent al ingelogd op MyUploader. <a href=\"upload.php\">Klik hier om verder te gaan</a>"; } ?> </td> </tr> </table> </body> </html>
logout.php in myuploader directory:
<?
//verwijdert de cookie uit je systeem om uit te loggen
$login_page = "index.php";
setcookie ("this_cookie", "", 0, "", "", 0);
setcookie ("name", "", 0, "", "", 0);
header("Location: $login_page");
exit();
?>
<? //verwijdert de cookie uit je systeem om uit te loggen $login_page = "index.php"; header("Location: $login_page"); ?>
upload.php in myuploader directory:
<?
include("validate.php");
?>
<html>
<title>Host4clan.nl - MyUploader</title>
<head>
<link href="style.css" rel="stylesheet" type="text/css">
</head></html>
<?php
if(!empty($_POST)){
$locatie="images/"; //of een andere map, vergeet niet de w-rechten
if(is_uploaded_file($_FILES['afbeelding']['tmp_name']))
{
//controleer grootte
if($_FILES['afbeelding']['size']>1500000)
{ //bepaal zelf de max. grootte in bytes
echo "Het bestand is te groot";
exit;
}
//controleer extensie, voeg maar andere toe
if(!eregi("((.gif|.jpg)$)", $_FILES['afbeelding']['name']))
{
echo "Dit type wordt niet ondersteund, enkel .gif of .jpg. Klik op vorige om terug te gaan. " ;
exit;
}
if(!move_uploaded_file($_FILES['afbeelding']['tmp_name'],
$locatie.$_FILES['afbeelding']['name']))
{
echo" het bestand kon niet worden verplaatst";
exit;
}
echo "Uw bestand ".$_FILES['afbeelding']['name']." is geupload. Link: http://mijnhost/myuploader/images/".$_FILES['afbeelding']['name']." Album: <a href=\"images/index.php\">Album bekijken</a> ";
}
else
{
echo "Het uploaden is mislukt";
}
}
else{
?>
<body bgcolor="#00CCFF">
<div align="center">
<table width="75%" border="0" bordercolor="#FF0000">
<tr>
<td bgcolor="#00CCFF">
<div align="center"><strong>MyUploader<br>
By Host4clan.nl: Michiel</strong></div></td>
</tr>
</table><a href="logout.php">Uitloggen</a>
<hr>
<font size="3" face="Verdana, Arial, Helvetica, sans-serif"><strong></strong></font></div>
<div align="center"><strong><font size="3" face="Verdana, Arial, Helvetica, sans-serif">MyUploader
v.1.0.</font></strong> </div>
<p align="center"><font size="3" face="Verdana, Arial, Helvetica, sans-serif"><strong>Blader
naar uw bestand, klik op Upload! en uw favoriete foto staat online</strong>.</font></p>
<p align="center"> <br>
<font size="2" face="serif"><strong><font color="#FF0000">.gif and .jpg extension
<em>only</em> </font></strong></font></p>
<p align="center"><font color="#FF0000"><strong><font size="2" face="serif">Maximum
size: 1500000 bytes</font></strong></font></p>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data">
<!--Bepaal zelf de maximale grootte in bytes -->
<div align="center">
<input type="file" name="afbeelding">
<br>
<input type="submit" name="submit" value="Upload!">
</div>
</form>
<div align="center">
<?php
}
?>
<p> </p>
<p align="right">CopyRight 2005 - <a href="http://www.host4clan.nl">Host4clan.nl
</a>- All Rights Reserved<br>
Host4clan.nl: Michiel</p>
</div>
<? include("validate.php"); ?> <html> <title>Host4clan.nl - MyUploader</title> <head> <link href="style.css" rel="stylesheet" type="text/css"> </head></html> <?php $locatie="images/"; //of een andere map, vergeet niet de w-rechten { //controleer grootte if($_FILES['afbeelding']['size']>1500000) { //bepaal zelf de max. grootte in bytes echo "Het bestand is te groot"; } //controleer extensie, voeg maar andere toe if(!eregi("((.gif|.jpg)$)", $_FILES['afbeelding']['name'])) { echo "Dit type wordt niet ondersteund, enkel .gif of .jpg. Klik op vorige om terug te gaan. " ; } $locatie.$_FILES['afbeelding']['name'])) { echo" het bestand kon niet worden verplaatst"; } echo "Uw bestand ".$_FILES['afbeelding']['name']." is geupload. Link: http://mijnhost/myuploader/images/".$_FILES['afbeelding']['name']." Album: <a href=\"images/index.php\">Album bekijken</a> "; } else { echo "Het uploaden is mislukt"; } } else{ ?> <body bgcolor="#00CCFF"> <div align="center"> <table width="75%" border="0" bordercolor="#FF0000"> <tr> <td bgcolor="#00CCFF"> <div align="center"><strong>MyUploader<br> By Host4clan.nl: Michiel</strong></div></td> </tr> </table><a href="logout.php">Uitloggen</a> <hr> <font size="3" face="Verdana, Arial, Helvetica, sans-serif"><strong></strong></font></div> <div align="center"><strong><font size="3" face="Verdana, Arial, Helvetica, sans-serif">MyUploader v.1.0.</font></strong> </div> <p align="center"><font size="3" face="Verdana, Arial, Helvetica, sans-serif"><strong>Blader naar uw bestand, klik op Upload! en uw favoriete foto staat online</strong>.</font></p> <p align="center"> <br> <font size="2" face="serif"><strong><font color="#FF0000">.gif and .jpg extension <em>only</em> </font></strong></font></p> <p align="center"><font color="#FF0000"><strong><font size="2" face="serif">Maximum size: 1500000 bytes</font></strong></font></p> <form method="post" action=" <?php echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data"> <!--Bepaal zelf de maximale grootte in bytes --> <div align="center"> <input type="file" name="afbeelding"> <br> <input type="submit" name="submit" value="Upload!"> </div> </form> <div align="center"> <?php } ?> <p> </p> <p align="right">CopyRight 2005 - <a href="http://www.host4clan.nl">Host4clan.nl </a>- All Rights Reserved<br> Host4clan.nl: Michiel</p> </div>
validate.php in myuploader directory:
<?
header("Pragma: ");
header("Cache-Control: ");
header("Expires: Mon, 26 Jul 1980 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate, proxy-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
//set global variables
global $username,$password;
//header("Pragma: no-cache");
// BEWERK ONDERSTAANDE GEGEVENS
//Stel je gebruikersnaam en pass in.
//Enkel letters en cijfers zijn toegestaan.
$uname[1] = "admin";
$upass[1] = "mijnpass";
$known_as[1] = "admin";
//gebruikers kun je hier toevoegen.
//$uname[2] = "demo";
//$upass[2] = "demo";
//$known_as[2] = "demo";
//Adres naar login-pagina
$login_page = "index.php";
//Pagina bij een geaccepteerde inlog.
$success_page = "upload.php";
//the path to validate.php .. NIET veranderen!
$validate_path = "full path to validate.php";
//meldingen bij een foutieve inlog!
$login_err = '<div align="center">Uw gebruikersnaam en/of wachtwoord was onjuist!</b></div>';
//no fields filled in
$empty_err = '<div align="center"><b>Het bekijken van deze pagina vereist inloggen op het systeem!</b></div>';
//something entered that wasn't a letter or number error message
$chr_err = '<div align="center"><b>A.u.b. opnieuw proberen</b></div>';
// DO NOT EDIT BELOW HERE
//if the form is empty and the cookie isn't set
//then display error message the return to login
if($username == "" && $password == "" && !isset($_COOKIE["this_cookie"])){
print($empty_err);
include($login_page);
exit();
}
//if the form is not empty and the cookie isn't set
//then make sure that only letters and numbers are entered
//if there are then display error message the return to login
if($username != "" || $password != "" && !isset($_COOKIE["this_cookie"])){
if (preg_match ("/[^a-zA-Z0-9]/", $username.$password)){
print($chr_err);
include($login_page);
exit();
}
}
//if the cookie isn't set
if (!isset($_COOKIE["this_cookie"]) ){
$user_count = count($uname);
$user_exists = false;
// check through all the users to see if they exist
for ($i = 1; $i <= $user_count; $i++) {
if ($uname[$i] == $username && $upass[$i] == $password){
$user_id=$i;
//$welcome_name = $known_as[$i];
$user_exists = true;
}
}
if(!$user_exists){
print ($login_err);
include($login_page);
exit();
}
//if the login is correct then set the cookie
$cookie_val=crypt($uname[$user_id]);
//set the cookie so it dies when the browser is closed
setcookie ("name", $known_as[$user_id], 0);
setcookie ("this_cookie", $cookie_val, 0);
header("Location: $success_page");
exit();
}
//if a user tries to access validate.php directly and they are logged in
if($REQUEST_URI == $validate_path){
echo "<html>\n<head>\n";
echo "<title>U bent reeds ingelogd</title>\n";
echo "</head>\n";
echo "<body bgcolor=\"white\">\n";
echo "You are logged in. <a href=\"".$success_page."\">Continue</a>\n";
echo "</body>\n";
echo "</html>\n";
}
?>
<? header("Expires: Mon, 26 Jul 1980 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate, proxy-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); //set global variables //header("Pragma: no-cache"); // BEWERK ONDERSTAANDE GEGEVENS //Stel je gebruikersnaam en pass in. //Enkel letters en cijfers zijn toegestaan. $uname[1] = "admin"; $upass[1] = "mijnpass"; $known_as[1] = "admin"; //gebruikers kun je hier toevoegen. //$uname[2] = "demo"; //$upass[2] = "demo"; //$known_as[2] = "demo"; //Adres naar login-pagina $login_page = "index.php"; //Pagina bij een geaccepteerde inlog. $success_page = "upload.php"; //the path to validate.php .. NIET veranderen! $validate_path = "full path to validate.php"; //meldingen bij een foutieve inlog! $login_err = '<div align="center">Uw gebruikersnaam en/of wachtwoord was onjuist!</b></div>'; //no fields filled in $empty_err = '<div align="center"><b>Het bekijken van deze pagina vereist inloggen op het systeem!</b></div>'; //something entered that wasn't a letter or number error message $chr_err = '<div align="center"><b>A.u.b. opnieuw proberen</b></div>'; // DO NOT EDIT BELOW HERE //if the form is empty and the cookie isn't set //then display error message the return to login if($username == "" && $password == "" && !isset($_COOKIE["this_cookie"])){ include($login_page); } //if the form is not empty and the cookie isn't set //then make sure that only letters and numbers are entered //if there are then display error message the return to login if($username != "" || $password != "" && !isset($_COOKIE["this_cookie"])){ if (preg_match ("/[^a-zA-Z0-9]/", $username.$password)){ include($login_page); } } //if the cookie isn't set if (!isset($_COOKIE["this_cookie"]) ){ $user_count = count($uname); $user_exists = false; // check through all the users to see if they exist for ($i = 1; $i <= $user_count; $i++) { if ($uname[$i] == $username && $upass[$i] == $password){ $user_id=$i; //$welcome_name = $known_as[$i]; $user_exists = true; } } if(!$user_exists){ include($login_page); } //if the login is correct then set the cookie $cookie_val=crypt($uname[$user_id]); //set the cookie so it dies when the browser is closed header("Location: $success_page"); } //if a user tries to access validate.php directly and they are logged in if($REQUEST_URI == $validate_path){ echo "<title>U bent reeds ingelogd</title>\n"; echo "<body bgcolor=\"white\">\n"; echo "You are logged in. <a href=\"".$success_page."\">Continue</a>\n"; } ?>
index.php in myuploader/images directory:
<?php
//Door Host4clan.nl: Michiel
$Gal = "MyUploader Image Index "; // Titel
$thumb = "thumbs"; // Thumbs directory naam
$thumbwidth = "100"; // Width van een thumbnail
$imagequality = "100"; // Foto kwaliteit, in procenten
$cols = "4"; // Aantal kolommen
$vi = "Bekijk Foto"; // Text voor link van foto bekijken
$sname = "index.php"; // Naam van deze file
$isz = "Grote"; // Text voor grote
$msgnav = "Bekijk FotoGallery"; // Text voor het bekijken van de gallery
$msgcp = "Foto"; // Text voor een foto
$msgof = "van"; // Text voor foto 1 VAN 24
$msgback = "Terug naar het album"; // Text voor link naar de gallery
if (isset($_GET['iid'])) {
$_GET['iid'];
} elseif (isset($_POST['iid'])) {
$_POST['iid'];
}
$files = array();
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if (eregi("\.jpe?g$", $file) ||
eregi("\.gif$", $file) ||
eregi("\.png$", $file)) {
$files[] = $file;
}
}
}
closedir($handle);
}
sort($files);
if (!is_dir($thumb)) {
mkdir($thumb, 0755);
}
$i = 0;
$th = array();
$iw = array();
$ih = array();
$ifs = array();
foreach ($files as $image) {
$thumbimage = $thumb."/".$image;
$thumb_exists = file_exists($thumbimage);
$size = GetImageSize($image);
$width = $size[0];
$height = $size[1];
$type = $size[2];
if (!$thumb_exists) {
set_time_limit(30);
switch ($type) {
case 1 :
$im = ImageCreateFromGIF($image);
break;
case 2 :
$im = ImageCreateFromJPEG($image);
break;
case 3 :
$im = ImageCreateFromPNG($image);
break;
}
$newwidth = $thumbwidth;
$newheight = ($newwidth / $width) * $height;
$im2 = ImageCreateTrueColor($newwidth,$newheight);
ImageCopyResampled($im2,$im,0,0,0,0,$newwidth,$newheight,$width,$height);
switch ($type) {
case 1:
ImageGIF($im2, $thumbimage);
break;
case 2:
ImageJpeg($im2, $thumbimage, $imagequality);
break;
case 3:
ImagePNG($im2, $thumbimage);
break;
imagedestroy($im);
imagedestroy($im2);
}
}
$th[$i] = $thumbimage;
$iw[$i] = $width;
$ih[$i] = $height;
$ifs[$i] = round((@filesize($image)/1024), 1);
$i++;
}
echo "<br>";
echo "<p align=\"center\"><font size=\"4\" color=\"#000000\">" . $Gal . "</font></p>";
echo "<br>";
echo "<table border=\"1\" align=\"center\" bordercolor=\"#000000\" cellspacing=\"3\" cellpadding=\"3\">"; // Dit kan je natuurlijk naar je eigen style aanpassen
if (!isset($iid)) {
$rows = round(count($th)/$cols);
if (($rows * $cols) < (count($th))) {
$rows++;
}
for ($i = 1; $i <= $rows; $i++) {
echo "<tr>";
for ($j = 1; $j <= $cols; $j++) {
$td = (($i - 1) * $cols) + $j;
$iu = ($td - 1);
if (isset($th[$iu])) {
$op = "";
$op .= "<td>\n<div align=\"center\">\n<br>\n";
$op .= "<a title=\"" . $vi . "\" href=\"" . $sname . "?iid=" .$iu . "\">\n";
$op .= "<img src=\"" . $th[$iu] . "\" border=\"0\">\n";
$op .= "<br>" . $isz . ": " . $hw[$iu] . " x" . $ih[$iu] . "\n";
$op .= "<br>" . $ifs[$iu] . " Kb.</a>\n";
$op .= "<br>\n</div>\n</td>\n";
echo $op;
} else {
echo "<td>\n<br></td>\n";
}
}
echo "</tr>\n";
}
} else {
$iid2 = $iid+1;
$tot = count($th);
$op = "";
$op .= "<tr>\n<td>\n<div align=\"center\"> " . $msgnav . " " . $Gal . " :: " . $msgcp . " " . $iid2 . " " . $msgof . " " . $tot . " </td>\n</tr>\n<tr>\n";
$op .= "<td>\n<div align=\"center\">\n<br>\n";
$op .= "<img src=\"" . $files[$iid] . "\" border=\"0\">\n";
$op .= "<br>" . $isz . " " . $iw[$iid] . " x " . $ih[$iid] . "\n";
$op .= "<br>" . $ifs[$iid] . " Kb.</a>\n";
$op .= "<br>\n</div>\n</td>\n</tr>\n";
$op .= "<tr>\n<td>\n<div align=\"center\"><a href=\"" . $sname . "\"> " . $msgback . " </a></div></td></tr>";
echo $op;
}
echo "</table>";
?>
<html>
<center><b>.gif extensies worden niet weergegeven in deze foto-index.</b><br>
<a href="logout.php">Uitloggen</a><br>
<a href="../upload.php">Terug naar uploader</a></center>
</html>
<?php //Door Host4clan.nl: Michiel $Gal = "MyUploader Image Index "; // Titel $thumb = "thumbs"; // Thumbs directory naam $thumbwidth = "100"; // Width van een thumbnail $imagequality = "100"; // Foto kwaliteit, in procenten $cols = "4"; // Aantal kolommen $vi = "Bekijk Foto"; // Text voor link van foto bekijken $sname = "index.php"; // Naam van deze file $isz = "Grote"; // Text voor grote $msgnav = "Bekijk FotoGallery"; // Text voor het bekijken van de gallery $msgcp = "Foto"; // Text voor een foto $msgof = "van"; // Text voor foto 1 VAN 24 $msgback = "Terug naar het album"; // Text voor link naar de gallery if (isset($_GET['iid'])) { $_GET['iid']; } elseif (isset($_POST['iid'])) { $_POST['iid']; } while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { if (eregi("\.jpe?g$", $file) || eregi("\.gif$", $file) || eregi("\.png$", $file)) { $files[] = $file; } } } } } $i = 0; foreach ($files as $image) { $thumbimage = $thumb."/".$image; $width = $size[0]; $height = $size[1]; $type = $size[2]; if (!$thumb_exists) { switch ($type) { case 1 : $im = ImageCreateFromGIF($image); break; case 2 : $im = ImageCreateFromJPEG($image); break; case 3 : $im = ImageCreateFromPNG($image); break; } $newwidth = $thumbwidth; $newheight = ($newwidth / $width) * $height; $im2 = ImageCreateTrueColor($newwidth,$newheight); ImageCopyResampled($im2,$im,0,0,0,0,$newwidth,$newheight,$width,$height); switch ($type) { case 1: ImageGIF($im2, $thumbimage); break; case 2: ImageJpeg($im2, $thumbimage, $imagequality); break; case 3: ImagePNG($im2, $thumbimage); break; imagedestroy($im); imagedestroy($im2); } } $th[$i] = $thumbimage; $iw[$i] = $width; $ih[$i] = $height; $i++; } echo "<p align=\"center\"><font size=\"4\" color=\"#000000\">" . $Gal . "</font></p>"; echo "<table border=\"1\" align=\"center\" bordercolor=\"#000000\" cellspacing=\"3\" cellpadding=\"3\">"; // Dit kan je natuurlijk naar je eigen style aanpassen if (($rows * $cols) < (count($th))) { $rows++; } for ($i = 1; $i <= $rows; $i++) { for ($j = 1; $j <= $cols; $j++) { $td = (($i - 1) * $cols) + $j; $iu = ($td - 1); $op = ""; $op .= "<td>\n<div align=\"center\">\n<br>\n"; $op .= "<a title=\"" . $vi . "\" href=\"" . $sname . "?iid=" .$iu . "\">\n"; $op .= "<img src=\"" . $th[$iu] . "\" border=\"0\">\n"; $op .= "<br>" . $isz . ": " . $hw[$iu] . " x" . $ih[$iu] . "\n"; $op .= "<br>" . $ifs[$iu] . " Kb.</a>\n"; $op .= "<br>\n</div>\n</td>\n"; } else { echo "<td>\n<br></td>\n"; } } } } else { $iid2 = $iid+1; $op = ""; $op .= "<tr>\n<td>\n<div align=\"center\"> " . $msgnav . " " . $Gal . " :: " . $msgcp . " " . $iid2 . " " . $msgof . " " . $tot . " </td>\n</tr>\n<tr>\n"; $op .= "<td>\n<div align=\"center\">\n<br>\n"; $op .= "<img src=\"" . $files[$iid] . "\" border=\"0\">\n"; $op .= "<br>" . $isz . " " . $iw[$iid] . " x " . $ih[$iid] . "\n"; $op .= "<br>" . $ifs[$iid] . " Kb.</a>\n"; $op .= "<br>\n</div>\n</td>\n</tr>\n"; $op .= "<tr>\n<td>\n<div align=\"center\"><a href=\"" . $sname . "\"> " . $msgback . " </a></div></td></tr>"; } ?> <html> <center><b>.gif extensies worden niet weergegeven in deze foto-index.</b><br> <a href="logout.php">Uitloggen</a><br> <a href="../upload.php">Terug naar uploader</a></center> </html>
Zorg dus dat je de submap images CHMOD naar 777!
.gif extensies zijn nog niet ondersteund in het fotoalbum! Download code (.txt)
|
|
|
Stemmen |
Niet ingelogd. |
|