Thursday, July 29th 2010, 1:39pm UTC+2

You are not logged in.

  • Login
  • Register

undefined

Super Moderator

Posts: 4,248

Location: Germany

1

Tuesday, June 17th 2003, 9:23am

Image Download Klasse

Eine Klasse für das Uploaden von Image Dateien auf deinem Server!
Die Image Dateien werden Automatisch Numeriert (z.B. 00011.jpg).

PHP Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<?php
/**********************************************************************/
/* letzte Update am : Sonntag, 6. April 2003                          */
/**********************************************************************/
/* Script:     Webmaster Flash-PHP-MAIL  (APACHE 2 - PHP5.0 Flash MX) */
/* Version:    1.1-dev                                                */
/* Datum:      2003                                                   */
/* Autor:      Juergen Heinemann                                      */
/* E-Mail:     [EMAIL]mingmaster@gmx.de[/EMAIL]                                      */
/* URL:        [URL]http://www.flash-php-mail.de[/URL]                           */
/**********************************************************************/

 Class jheiuploads
{
// Einnstellbare Variablen
 var $DATUMSCON "d m Y, H:i"// Datumsconvertierung

/**********************************************************************/
//    Bitte ab hier nichts mehr Editieren !!!                         //
/**********************************************************************/
 var $JHUPLOADDIR "";

 var $zeigebild;
 var $dateiupload;
 var $error "";

   function jheiuploads($JHUPLOADDIR$MAXBREIT$MAXHOCH$MAXUPSIZE$SPELL) {
     if(is_string($JHUPLOADDIR)) {
      $this->JHUPLOADDIR $JHUPLOADDIR;
     }
      $this->JHMAXBREIT  intval($JHMAXBREIT  = (isset($MAXBREIT) ? $MAXBREIT "450"));
      $this->JHMAXHOCH   intval($JHMAXHOCH  = (isset($MAXHOCH) ? $MAXHOCH "450"));
      $this->JHMAXUPSIZE intval($JHMAXUPSIZE  = (isset($MAXUPSIZE) ? $MAXUPSIZE "125"));
      $this->JHSPELL     intval($JHSPELL = (isset($SPELL) ? $SPELL "0"));
   } 

function fehler($error,$zeile) {
    $spr $this->JHSPELL;
     $errors = array("1" => array("Kann Konfigurationsdatei nicht lesen!","no configuration file found"),
                     "2" => array("Kann Verzeichnis nicht öffnen!","cant open file"),
                     "3" => array("Falsche Eingabe - Album ausgewählt?","not legal input or no category selected"),
                     "4" => array("Verzeichnis Existiert nicht!","file does not exists"),
                     "5" => array("Datei Existiert nicht","file does not exists"),
                     "6" => array("Die Dateigröße ist höher als die zulässigen Kilo Bytes!","not legal filesize"),
                     "7" => array("Die Bilddatei ist zu Breit!","image file to width"),
                     "8" => array("Die Bilddatei ist zu Hoch!","image file to height"),
                     "9" => array("Der Server unterstützt nur JPG und PNG Bildformate!","only image jpg and png files supportet"));
   echo $errors[$error][$spr]." Error Nr. ".$zeile;
   exit;
}

   function filerechte($file) {
     $perms  = ($file 00400) ? "r" "-";
     $perms .= ($file 00200) ? "w" "-";
     $perms .= ($file 00100) ? "x" "-";
     $perms .= ($file 00040) ? "r" "-";
     $perms .= ($file 00020) ? "w" "-";
     $perms .= ($file 00010) ? "x" "-";
     $perms .= ($file 00004) ? "r" "-";
     $perms .= ($file 00002) ? "w" "-";
     $perms .= ($file 00001) ? "x" "-";
    return $perms;
   }

function fileinfo($album,$file) {
  $directory $this->JHUPLOADDIR."/".$album."/".$file;
 if(!file_exists($directory)) {  
    $this->fehler(4__LINE__);
    return false;
 }

  $dateiInfos = array("1" => (basename($directory)),
                      "2" => (dirname($directory)),
                      "3" => (date($this->DATUMSCON)),
                      "4" => (filemtime($directory)),
                      "5" => ($this->filerechte(fileperms($directory))),
                      "6" => (filesize($directory)),
                      "7" => ($this->speicherplatz($directory)));
  return $dateiInfos;
}

function speicherplatz($directory) {

  $freeSpace diskfreespace($directory);
  if ($freeSpace/(1024*1024) > 1024) {
      $space printf("%.2f ".$txt[8], $freeSpace/(1024*1024*1024));
   } else {
      $space = (int)($freeSpace/(1024*1024)).$txt[7];
  }
  return $space;
}

function leseverzeich($file) {
 if(!file_exists($file)) {  
    $this->fehler(4__LINE__);
    return false;
 }
  $alben = array();
  $files opendir($file);
 while($ordner readdir($files)) {
    if(($ordner != ".") && ($ordner != "..") && (!is_file($file."/".$ordner)) && (is_writeable($file."/".$ordner))) {
       clearstatcache();
      array_push($alben$ordner);
    }
   }
   closedir($files);
  sort($albenSORT_STRING);
 return $alben;
}

function leseinhalte($file) {
 if(!file_exists($file)) {  
    $this->fehler(4,__LINE__);
    return false;
 }
  $bilder = array();
  $files opendir($file);
 while($datei readdir($files)) {
    if(($datei != ".") && ($datei != "..") && (is_file($datei)) || (eregi(".jpg"$datei)) || (eregi(".png"$datei))) {
       clearstatcache();
      array_push($bilder,$datei);
    }
   }
   closedir($files);
  sort($bilderSORT_NUMERIC);
 return $bilder;
}

function lesealben($read) {
  if (is_integer($read)) {
    $alben $this->leseverzeich($this->JHUPLOADDIR);
   return $alben;
  } else {
    $this->fehler(3__LINE__);
   return false;
  }
}

function lesebilder($read) {
  if(empty($read)) {  
    $this->fehler(3__LINE__);
    return false;
 }
   $rootpfad $this->JHUPLOADDIR."/".$read;
 if(!file_exists($rootpfad)) {  
    $this->fehler(5__LINE__);
    return false;
 }
   $alben $this->leseinhalte($rootpfad);
 return $alben;
}

function suchebisluecke($alben) {
   if(!is_array($alben)) {  
    $this->fehler(3__LINE__);
    return false;
   }
   $result = array();
   $int 1;
   foreach ($alben AS $value) {
     if(substr($value05) == sprintf("%05d"$int++)) {
      array_push($result$value);
     } else {
      continue;
     }
   }
   $neuBild sprintf("%05d"substr(end($result), 05) +);
   $ausgabe = array(end($result), count($result), count($alben), $neuBild);
  return $ausgabe;
}

function dateiupload($album,$_FILES) {
  $bildtyp = array("1" => ".gif""2" => ".jpg""3" => ".png""4" => ".swf");
  $directory $this->JHUPLOADDIR."/".$album;
 if(!file_exists($directory)) {
     echo $directory;
    $this->fehler(4__LINE__);
    return false;
 }
  $maxuploadsize $this->JHMAXUPSIZE."000";
  $neuBILD $this->suchebisluecke($this->lesebilder($album));

 if ($_FILES['imageupload']['size'] > $maxuploadsize) {  
    $this->fehler(6__LINE__);
    return false;
 }
  $typ getimagesize($_FILES['imageupload']['tmp_name']);
  $Image_Neu $directory."/".$neuBILD[3].$bildtyp[$typ[2]];

 if($typ[0] > $this->JHMAXBREIT) {
       $this->fehler(7__LINE__);
    } else if($typ[1] > $this->JHMAXHOCH) {
       $this->fehler(8__LINE__);
    }
 
 if(($typ[2] < 2) || ($typ[2] > 3)) {
       $this->fehler(9__LINE__);
       unlink ($_FILES['imageupload']['name']);
    return false;
  }

 if (isset($_FILES['imageupload']) && ! $_FILES['imageupload']['error']) {
    move_uploaded_file($_FILES['imageupload']['tmp_name'], $Image_Neu);
     @chmod($Image_Neu0644);
   $ausgabe = array($_FILES['imageupload']['name'], $typ$this->fileinfo($album$neuBILD[3].$bildtyp[$typ[2]]));
  return $ausgabe;
 } else {
    $this->fehler(7__LINE__);
  return false;
 }
}

}
?>

Klassen aufruf und Verarbeitung

PHP Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/*********************************************************************/
/* letzte Update am : Samstag, 5. April 2003                         */
/*********************************************************************/
/* Script:     Webmaster Flash-PHP-MAIL  (APACHE 2 - PHP5.0 Flash MX)*/
/* Version:    1.1-dev                                               */
/* Datum:      2003                                                  */
/* Autor:      Juergen Heinemann                                     */
/* E-Mail:     [EMAIL]mingmaster@gmx.de[/EMAIL]                                     */
/* URL:        [URL]http://www.flash-php-mail.de[/URL]                          */
/*********************************************************************/
include ($_SERVER['DOCUMENT_ROOT']."/Homepfad/zum/Script/uploadcl.php");

$fotouploads = NEW uploadjh;
if(!$fotouploads -> init()) {
    echo ".:ERROR:.";
   return exit;
  }

if($HTTP_POST_FILES['imageupload']) {
$upload $fotouploads->dateiupload($_POST[album],$_FILES);
// Zeige Upload Informationen an!
echo "<br>";
echo $upload[0]."<br>";
foreach ($upload[1] AS $value) {
    echo $value."<br>";
}
// Gibt Bilddaten zurück von egtimagesize!
foreach ($upload[2] AS $value) {
    echo $value."<br>";
}

} else {

$alben $fotouploads -> lesealben(1);
echo "Es sind ".count($alben)." Alben vorhanden!<br>
<form action="".$_SERVER['PHP_SELF']."" method="post" enctype="multipart/form-data">
<select name="album">";
  foreach ($alben AS $value) {
     echo "<option value="". $value ."">" $value "</option>\n";
  }
echo "</select>
<input type="file" name="imageupload" />
<input type="submit" value="Los!" />
</form>
<br>";

}

?>

Source code

1
$fotouploads = NEW jheiuploads(JHEI_ROOTDIR.JHHEI_PICDIR, JHHEI_JHMAXBREIT, JHHEI_JHMAXHOCH, JHEI_JHMAXUPSIZE, JHEI_JHSPELL, JHEI_ABSOLUT);

Viel Spaß damit! :)
Undefined Behavior (undefiniertes Verhalten) bedeutet meistens etwas ungültiges.
PHP Katepart - Speichenrechner - .htpasswd - RPM XDG Tool - Kcmnvview - QTidy
  • Go to the top of the page

syro

Beginner

2

Thursday, March 2nd 2006, 7:56pm

das $txt in Zeile 89 wird nirgends wo definiert. Was hat es dort zu suchen?

seeya Dennis
  • Go to the top of the page

3

Friday, March 3rd 2006, 9:49am

Hi,

gefällt mir muss ich gleich mal testen. :)
Greetz Andi

Mod Dewey

CREAKTIF - Comes soon

Google ist dein Freund :D
  • Go to the top of the page

undefined

Super Moderator

Posts: 4,248

Location: Germany

4

Friday, March 3rd 2006, 5:34pm

Quoted

Original von syro
das $txt in Zeile 89 wird nirgends wo definiert. Was hat es dort zu suchen?

seeya Dennis

Ist mir anscheinend beim Entfernen der Array Meldungen Untergegangen.
Kannst du einfach entfernen.

PHP Source code

1
2
3
4
5
6
7
8
9
10
function speicherplatz($directory)
{
  $freeSpace diskfreespace($directory);
  if ($freeSpace/(1024*1024) > 1024) {
      $space sprintf("%.2f "$freeSpace/(1024*1024*1024));
   } else {
      $space = (int)($freeSpace/(1024*1024));
  }
  return $space;
}
Undefined Behavior (undefiniertes Verhalten) bedeutet meistens etwas ungültiges.
PHP Katepart - Speichenrechner - .htpasswd - RPM XDG Tool - Kcmnvview - QTidy
  • Go to the top of the page

[neo_ryke]

Professional

Posts: 906

Location: Hohenmölsen

5

Friday, March 3rd 2006, 7:17pm

jup sher geil

werde es auch mal testen
  • Go to the top of the page