login  Naam:   Wachtwoord: 
Registreer je!
 Scripts:

Scripts > PHP > Foto gallerijen > MyUploader v.1.0 by Host4clan

MyUploader v.1.0 by Host4clan

Auteur: Serial - 12 juni 2005 - 09:50 - Gekeurd door: Joel - Hits: 16684 - 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:
  1. <html>
  2. <head>
  3. <title>Login Page</title>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
  5. <body bgcolor="C6E2F3">
  6. <p><strong>MyUploader - By Host4clan.nl: Michiel</strong></p>
  7. <table width="400" align="center">
  8. <tr>
  9. <th valign=top> User en pass benodigd voor upload.</th>
  10. </tr>
  11. <tr>
  12. <td>
  13. <p>&nbsp;</p>
  14. <?
  15. //if no cookie is set then display the form
  16. if(!isset($_COOKIE["this_cookie"])){
  17. echo '<div align="center"><form action="validate.php" method="post">';
  18. echo 'username : <input type="text" name="username"><br><br>';
  19. echo 'password : <input type="password" name="password"><br><br>';
  20. echo '<input type="submit" value="login"></form></div>';
  21. }else{
  22. echo "Je bent al ingelogd op MyUploader. <a href=\"upload.php\">Klik hier om verder te gaan</a>";
  23. }
  24. ?>
  25. </td>
  26. </tr>
  27. </table>
  28. </body>
  29. </html>


logout.php in myuploader directory:
  1. <?
  2. //verwijdert de cookie uit je systeem om uit te loggen
  3. $login_page = "index.php";
  4. setcookie ("this_cookie", "", 0, "", "", 0);
  5. setcookie ("name", "", 0, "", "", 0);
  6. header("Location: $login_page");
  7. exit();
  8. ?>


upload.php in myuploader directory:
  1. <?
  2. include("validate.php");
  3. ?>
  4. <html>
  5. <title>Host4clan.nl - MyUploader</title>
  6. <head>
  7. <link href="style.css" rel="stylesheet" type="text/css">
  8. </head></html>
  9. <?php
  10. if(!empty($_POST)){
  11. $locatie="images/"; //of een andere map, vergeet niet de w-rechten
  12. if(is_uploaded_file($_FILES['afbeelding']['tmp_name']))
  13. {
  14. //controleer grootte
  15. if($_FILES['afbeelding']['size']>1500000)
  16. { //bepaal zelf de max. grootte in bytes
  17. echo "Het bestand is te groot";
  18. }
  19.  
  20. //controleer extensie, voeg maar andere toe
  21. if(!eregi("((.gif|.jpg)$)", $_FILES['afbeelding']['name']))
  22. {
  23. echo "Dit type wordt niet ondersteund, enkel .gif of .jpg. Klik op vorige om terug te gaan. " ;
  24. }
  25.  
  26.  
  27. if(!move_uploaded_file($_FILES['afbeelding']['tmp_name'],
  28. $locatie.$_FILES['afbeelding']['name']))
  29.  
  30. {
  31. echo" het bestand kon niet worden verplaatst";
  32. }
  33.  
  34. 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> ";
  35. }
  36.  
  37. else
  38. {
  39. echo "Het uploaden is mislukt";
  40. }
  41.  
  42.  
  43. }
  44. else{
  45. ?>
  46. <body bgcolor="#00CCFF">
  47. <div align="center">
  48. <table width="75%" border="0" bordercolor="#FF0000">
  49. <tr>
  50. <td bgcolor="#00CCFF">
  51. <div align="center"><strong>MyUploader<br>
  52. By Host4clan.nl: Michiel</strong></div></td>
  53. </tr>
  54. </table><a href="logout.php">Uitloggen</a>
  55. <hr>
  56. <font size="3" face="Verdana, Arial, Helvetica, sans-serif"><strong></strong></font></div>
  57. <div align="center"><strong><font size="3" face="Verdana, Arial, Helvetica, sans-serif">MyUploader
  58. v.1.0.</font></strong> </div>
  59. <p align="center"><font size="3" face="Verdana, Arial, Helvetica, sans-serif"><strong>Blader
  60. naar uw bestand, klik op Upload! en uw favoriete foto staat online</strong>.</font></p>
  61. <p align="center"> <br>
  62. <font size="2" face="serif"><strong><font color="#FF0000">.gif and .jpg extension
  63. <em>only</em> </font></strong></font></p>
  64. <p align="center"><font color="#FF0000"><strong><font size="2" face="serif">Maximum
  65. size: 1500000 bytes</font></strong></font></p>
  66. <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data">
  67. <!--Bepaal zelf de maximale grootte in bytes -->
  68. <div align="center">
  69. <input type="file" name="afbeelding">
  70. <br>
  71. <input type="submit" name="submit" value="Upload!">
  72. </div>
  73. </form>
  74. <div align="center">
  75. <?php
  76. }
  77. ?>
  78. <p>&nbsp;</p>
  79. <p align="right">CopyRight 2005 - <a href="http://www.host4clan.nl">Host4clan.nl
  80. </a>- All Rights Reserved<br>
  81. Host4clan.nl: Michiel</p>
  82. </div>


validate.php in myuploader directory:
  1. <?
  2. header("Pragma: ");
  3. header("Cache-Control: ");
  4. header("Expires: Mon, 26 Jul 1980 05:00:00 GMT");
  5. header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
  6. header("Cache-Control: no-store, no-cache, must-revalidate, proxy-revalidate");
  7. header("Cache-Control: post-check=0, pre-check=0", false);
  8. //set global variables
  9. global $username,$password;
  10.  
  11. //header("Pragma: no-cache");
  12. // BEWERK ONDERSTAANDE GEGEVENS
  13. //Stel je gebruikersnaam en pass in.
  14. //Enkel letters en cijfers zijn toegestaan.
  15. $uname[1] = "admin";
  16. $upass[1] = "mijnpass";
  17. $known_as[1] = "admin";
  18. //gebruikers kun je hier toevoegen.
  19. //$uname[2] = "demo";
  20. //$upass[2] = "demo";
  21. //$known_as[2] = "demo";
  22.  
  23.  
  24. //Adres naar login-pagina
  25. $login_page = "index.php";
  26. //Pagina bij een geaccepteerde inlog.
  27. $success_page = "upload.php";
  28. //the path to validate.php .. NIET veranderen!
  29. $validate_path = "full path to validate.php";
  30. //meldingen bij een foutieve inlog!
  31. $login_err = '<div align="center">Uw gebruikersnaam en/of wachtwoord was onjuist!</b></div>';
  32. //no fields filled in
  33. $empty_err = '<div align="center"><b>Het bekijken van deze pagina vereist inloggen op het systeem!</b></div>';
  34. //something entered that wasn't a letter or number error message
  35. $chr_err = '<div align="center"><b>A.u.b. opnieuw proberen</b></div>';
  36. // DO NOT EDIT BELOW HERE
  37.  
  38. //if the form is empty and the cookie isn't set
  39. //then display error message the return to login
  40. if($username == "" && $password == "" && !isset($_COOKIE["this_cookie"])){
  41. print($empty_err);
  42. include($login_page);
  43. exit();
  44. }
  45.  
  46. //if the form is not empty and the cookie isn't set
  47. //then make sure that only letters and numbers are entered
  48. //if there are then display error message the return to login
  49. if($username != "" || $password != "" && !isset($_COOKIE["this_cookie"])){
  50. if (preg_match ("/[^a-zA-Z0-9]/", $username.$password)){
  51. print($chr_err);
  52. include($login_page);
  53. exit();
  54. }
  55. }
  56.  
  57. //if the cookie isn't set
  58. if (!isset($_COOKIE["this_cookie"]) ){
  59. $user_count = count($uname);
  60. $user_exists = false;
  61.  
  62. // check through all the users to see if they exist
  63. for ($i = 1; $i <= $user_count; $i++) {
  64. if ($uname[$i] == $username && $upass[$i] == $password){
  65. $user_id=$i;
  66. //$welcome_name = $known_as[$i];
  67. $user_exists = true;
  68. }
  69. }
  70.  
  71. if(!$user_exists){
  72. print ($login_err);
  73. include($login_page);
  74. exit();
  75. }
  76.  
  77. //if the login is correct then set the cookie
  78. $cookie_val=crypt($uname[$user_id]);
  79. //set the cookie so it dies when the browser is closed
  80. setcookie ("name", $known_as[$user_id], 0);
  81. setcookie ("this_cookie", $cookie_val, 0);
  82. header("Location: $success_page");
  83. exit();
  84. }
  85.  
  86. //if a user tries to access validate.php directly and they are logged in
  87. if($REQUEST_URI == $validate_path){
  88. echo "<html>\n<head>\n";
  89. echo "<title>U bent reeds ingelogd</title>\n";
  90. echo "</head>\n";
  91. echo "<body bgcolor=\"white\">\n";
  92. echo "You are logged in. <a href=\"".$success_page."\">Continue</a>\n";
  93. echo "</body>\n";
  94. echo "</html>\n";
  95.  
  96. }
  97.  
  98. ?>


index.php in myuploader/images directory:
  1. <?php
  2. //Door Host4clan.nl: Michiel
  3. $Gal = "MyUploader Image Index "; // Titel
  4. $thumb = "thumbs"; // Thumbs directory naam
  5. $thumbwidth = "100"; // Width van een thumbnail
  6. $imagequality = "100"; // Foto kwaliteit, in procenten
  7. $cols = "4"; // Aantal kolommen
  8. $vi = "Bekijk Foto"; // Text voor link van foto bekijken
  9. $sname = "index.php"; // Naam van deze file
  10. $isz = "Grote"; // Text voor grote
  11. $msgnav = "Bekijk FotoGallery"; // Text voor het bekijken van de gallery
  12. $msgcp = "Foto"; // Text voor een foto
  13. $msgof = "van"; // Text voor foto 1 VAN 24
  14. $msgback = "Terug naar het album"; // Text voor link naar de gallery
  15.  
  16. if (isset($_GET['iid'])) {
  17. $_GET['iid'];
  18. } elseif (isset($_POST['iid'])) {
  19. $_POST['iid'];
  20. }
  21.  
  22.  
  23. $files = array();
  24. if ($handle = opendir('.')) {
  25. while (false !== ($file = readdir($handle))) {
  26. if ($file != "." && $file != "..") {
  27. if (eregi("\.jpe?g$", $file) ||
  28. eregi("\.gif$", $file) ||
  29. eregi("\.png$", $file)) {
  30. $files[] = $file;
  31. }
  32. }
  33. }
  34. closedir($handle);
  35. }
  36.  
  37.  
  38. sort($files);
  39.  
  40. if (!is_dir($thumb)) {
  41. mkdir($thumb, 0755);
  42. }
  43.  
  44. $i = 0;
  45. $th = array();
  46. $iw = array();
  47. $ih = array();
  48. $ifs = array();
  49. foreach ($files as $image) {
  50. $thumbimage = $thumb."/".$image;
  51. $thumb_exists = file_exists($thumbimage);
  52. $size = GetImageSize($image);
  53. $width = $size[0];
  54. $height = $size[1];
  55. $type = $size[2];
  56. if (!$thumb_exists) {
  57. switch ($type) {
  58. case 1 :
  59. $im = ImageCreateFromGIF($image);
  60. break;
  61. case 2 :
  62. $im = ImageCreateFromJPEG($image);
  63. break;
  64. case 3 :
  65. $im = ImageCreateFromPNG($image);
  66. break;
  67. }
  68. $newwidth = $thumbwidth;
  69. $newheight = ($newwidth / $width) * $height;
  70. $im2 = ImageCreateTrueColor($newwidth,$newheight);
  71. ImageCopyResampled($im2,$im,0,0,0,0,$newwidth,$newheight,$width,$height);
  72. switch ($type) {
  73. case 1:
  74. ImageGIF($im2, $thumbimage);
  75. break;
  76. case 2:
  77. ImageJpeg($im2, $thumbimage, $imagequality);
  78. break;
  79. case 3:
  80. ImagePNG($im2, $thumbimage);
  81. break;
  82. imagedestroy($im);
  83. imagedestroy($im2);
  84. }
  85.  
  86. }
  87. $th[$i] = $thumbimage;
  88. $iw[$i] = $width;
  89. $ih[$i] = $height;
  90. $ifs[$i] = round((@filesize($image)/1024), 1);
  91. $i++;
  92. }
  93.  
  94. echo "<br>";
  95. echo "<p align=\"center\"><font size=\"4\" color=\"#000000\">" . $Gal . "</font></p>";
  96. echo "<br>";
  97. echo "<table border=\"1\" align=\"center\" bordercolor=\"#000000\" cellspacing=\"3\" cellpadding=\"3\">"; // Dit kan je natuurlijk naar je eigen style aanpassen
  98. if (!isset($iid)) {
  99. $rows = round(count($th)/$cols);
  100. if (($rows * $cols) < (count($th))) {
  101. $rows++;
  102. }
  103. for ($i = 1; $i <= $rows; $i++) {
  104. echo "<tr>";
  105. for ($j = 1; $j <= $cols; $j++) {
  106. $td = (($i - 1) * $cols) + $j;
  107. $iu = ($td - 1);
  108. if (isset($th[$iu])) {
  109. $op = "";
  110. $op .= "<td>\n<div align=\"center\">\n<br>\n";
  111. $op .= "<a title=\"" . $vi . "\" href=\"" . $sname . "?iid=" .$iu . "\">\n";
  112. $op .= "<img src=\"" . $th[$iu] . "\" border=\"0\">\n";
  113. $op .= "<br>" . $isz . ": " . $hw[$iu] . " x" . $ih[$iu] . "\n";
  114. $op .= "<br>" . $ifs[$iu] . " Kb.</a>\n";
  115. $op .= "<br>\n</div>\n</td>\n";
  116. echo $op;
  117. } else {
  118. echo "<td>\n<br></td>\n";
  119. }
  120. }
  121. echo "</tr>\n";
  122. }
  123.  
  124. } else {
  125. $iid2 = $iid+1;
  126. $tot = count($th);
  127. $op = "";
  128. $op .= "<tr>\n<td>\n<div align=\"center\"> " . $msgnav . " " . $Gal . " :: " . $msgcp . " " . $iid2 . " " . $msgof . " " . $tot . " </td>\n</tr>\n<tr>\n";
  129. $op .= "<td>\n<div align=\"center\">\n<br>\n";
  130. $op .= "<img src=\"" . $files[$iid] . "\" border=\"0\">\n";
  131. $op .= "<br>" . $isz . " " . $iw[$iid] . " x " . $ih[$iid] . "\n";
  132. $op .= "<br>" . $ifs[$iid] . " Kb.</a>\n";
  133. $op .= "<br>\n</div>\n</td>\n</tr>\n";
  134. $op .= "<tr>\n<td>\n<div align=\"center\"><a href=\"" . $sname . "\"> " . $msgback . " </a></div></td></tr>";
  135. echo $op;
  136. }
  137. echo "</table>";
  138. ?>
  139. <html>
  140. <center><b>.gif extensies worden niet weergegeven in deze foto-index.</b><br>
  141. <a href="logout.php">Uitloggen</a><br>
  142. <a href="../upload.php">Terug naar uploader</a></center>
  143. </html>


Zorg dus dat je de submap images CHMOD naar 777!
.gif extensies zijn nog niet ondersteund in het fotoalbum!Download code! Download code (.txt)

Download dit script! Bekijk een voorbeeld van dit script!
 Stemmen
Niet ingelogd.

 Reacties
Post een reactie
Lees de reacties (4)
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.105s