datum = date("d.m.Y"); $this->ext_array = array (0=>"pdf",1=>"doc",2=>"xls",3=>"ppt",4=>"txt",5=>"rtf",6=>"xml",7=>"html",8=>"htm"); } function speichern($file,$meta){ global $file_path, $VERSION, $DIRECT_STORE; $this->name = $file[name]; if ( $this->pruefe_ext() ){ $size = $file[size]; $mime = $file[type]; $zufall = rand(5,99999); $this->uniq_name = date('U') . "_" . $zufall . "." . substr(strrchr($this->name,'.'), 1); $data = fread(fopen($file[tmp_name], "r"), $file[size]); $this->full_path = $file_path . $this->uniq_name; $pic=fopen($this->full_path,"w+"); fputs($pic, $data); fclose($pic); $eintragen = new db(); if ( $VERSION == "10" && $DIRECT_STORE == "N"){ $stmt = "INSERT INTO mein_doc (id, file_name, user_file_name, upload_datum,titel, autor, beschreibung,groesse, mime,inhalt) values (mein_doc_seq.NEXTVAL,'$this->uniq_name','$this->name', '$this->datum', '$meta[titel]', '$meta[autor]', '$meta[beschreibung]', '$size', '$mime','$this->full_path')";} elseif ( $VERSION == "9" && $DIRECT_STORE == "N"){ $stmt = "call put_file('$this->uniq_name','$this->name', '$this->datum', '$meta[titel]', '$meta[autor]', '$meta[beschreibung]', '$size', '$mime','$this->full_path')";} else{ $stmt = "call put_file('$this->uniq_name','$this->name', '$this->datum', '$meta[titel]', '$meta[autor]', '$meta[beschreibung]', '$size', '$mime')";} if($eintragen->insert($stmt) ){ echo 'Datei: ' . $this->name . ' ist upgeloadet'.'
'; echo 'Datei Groesse: '.$size.' Byte'.'
'; $this->file1 = ""; $this->titel = ""; $this->autor = ""; $this->beschreibung = ""; }else {echo "Datei konnte nicht eingetragen werden"; $this->file1 = $this->name; $this->titel = $meta[titel]; $this->autor = $meta[autor]; $this->beschreibung = $meta[beschreibung]; $this->loesche_file(); } } else { echo $this->fehler_meldung; $this->file1 = $this->name; $this->titel = $meta[titel]; $this->autor = $meta[autor]; $this->beschreibung = $meta[beschreibung]; } } function pruefe_ext(){ $pos = strrpos($this->name,"."); if( !$pos) $this->fehler_meldung = "Datei ohne Erweiterung kann nicht archiviert werden."; else{ $ext = strtolower(substr($this->name, $pos +1)); $i = 0; while ( $i < count($this->ext_array) && $ext != $this->ext_array[$i]) $i++; if ( $i >= count($this->ext_array)){ $this->fehler_meldung = "Datei mit dieser Erweiterung kann nicht indiziert werde."; return false; }else return true; } } function loesche_file(){ $cmd = "rm " . $this->full_path; $ver_file = popen($cmd,"w"); pclose($ver_file); } } ?>