diff --git a/cis/private/bildupload.php b/cis/private/bildupload.php index 968f67ab0..b8ce66422 100644 --- a/cis/private/bildupload.php +++ b/cis/private/bildupload.php @@ -23,8 +23,6 @@ */ // Oberflaeche zum Upload von Bildern - -//session_cache_limiter('none'); //muss gesetzt werden damit der upload in chrome und das automatische updaten des profilbildes funktioniert require_once('../../config/cis.config.inc.php'); require_once('../../include/functions.inc.php'); require_once('../../include/person.class.php'); @@ -32,67 +30,52 @@ require_once('../../include/benutzer.class.php'); require_once('../../include/akte.class.php'); require_once('../../include/phrasen.class.php'); require_once('../../include/fotostatus.class.php'); - $user = get_uid(); $sprache = getSprache(); $p = new phrasen($sprache); - echo ' + - - '. - cropCss().' - - - - - - - - - + + '.$p->t('profil/Bildupload').' +

'.$p->t('profil/Bildupload').'

'; - function resize($filename, $width, $height) { - $ext = explode('.',$_FILES['bild']['name']); - $ext = strtolower($ext[count($ext)-1]); + $ext = explode('.',$_FILES['bild']['name']); + $ext = strtolower($ext[count($ext)-1]); + // Hoehe und Breite neu berechnen + list($width_orig, $height_orig) = getimagesize($filename); + if ($width && ($width_orig < $height_orig)) + { + $width = ($height / $height_orig) * $width_orig; + } + else + { + $height = ($width / $width_orig) * $height_orig; + } - // Hoehe und Breite neu berechnen - list($width_orig, $height_orig) = getimagesize($filename); + $image_p = imagecreatetruecolor($width, $height); - if ($width && ($width_orig < $height_orig)) - { - $width = ($height / $height_orig) * $width_orig; - } - else - { - $height = ($width / $width_orig) * $height_orig; - } + $image = imagecreatefromjpeg($filename); - $image_p = imagecreatetruecolor($width, $height); + //Bild nur verkleinern aber nicht vergroessern + if($width_orig>$width || $height_orig>$height) + imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); + else + $image_p = $image; - $image = imagecreatefromjpeg($filename); + imagejpeg($image_p, $filename, 80); - //Bild nur verkleinern aber nicht vergroessern - if($width_orig>$width || $height_orig>$height) - imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); - else - $image_p = $image; - - imagejpeg($image_p, $filename, 80); - - @imagedestroy($image_p); - @imagedestroy($image); + @imagedestroy($image_p); + @imagedestroy($image); } - - if(isset($_GET['person_id'])) { $benutzer = new benutzer(); @@ -107,269 +90,132 @@ if(isset($_GET['person_id'])) } else die($p->t('global/fehlerBeiDerParameteruebergabe')); +//Bei Upload des Bildes +if(isset($_POST['submitbild'])) +{ + if(isset($_FILES['bild']['tmp_name'])) + { + //Extension herausfiltern + $ext = explode('.',$_FILES['bild']['name']); + $ext = mb_strtolower($ext[count($ext)-1]); + $width=101; + $height=130; -echo '
'; -echo $p->t('profil/BilduploadInfotext',array($p->t('dms_link/bildRichtlinien'))).'

'; -echo '
- '.$p->t('profil/fotoAuswählen').' -
- -
- - '; + //--check that it's a jpeg + if ($ext=='jpg' || $ext=='jpeg') + { + $filename = $_FILES['bild']['tmp_name']; -if (isset($_POST['src'])) { - $src = $_POST['src']; - echo $src; + //groesse auf maximal 827x1063 begrenzen + resize($filename, 827, 1063); + + $fp = fopen($filename,'r'); + //auslesen + $content = fread($fp, filesize($filename)); + fclose($fp); + + $akte = new akte(); + + if($akte->getAkten($_GET['person_id'], 'Lichtbil')) + { + if(count($akte->result)>0) + { + $akte = $akte->result[0]; + $akte->new = false; + } + else + $akte->new = true; + } + else + { + $akte->new = true; + } + + $akte->dokument_kurzbz = 'Lichtbil'; + $akte->person_id = $_GET['person_id']; + $akte->inhalt = base64_encode($content); + $akte->mimetype = "image/jpg"; + $akte->erstelltam = date('Y-m-d H:i:s'); + $akte->gedruckt = false; + $akte->titel = "Lichtbild_".$_GET['person_id'].".jpg"; + $akte->bezeichnung = "Lichtbild gross"; + $akte->updateamum = date('Y-m-d H:i:s'); + $akte->updatevon = $user; + $akte->insertamum = date('Y-m-d H:i:s'); + $akte->insertvon = $user; + $akte->uid = ''; + + if(!$akte->save()) + { + echo '
Fehler: '.$akte->errormsg.'
'; + } + + //groesse auf maximal 101x130 begrenzen + resize($filename, 101, 130); + + //in DB speichern + //File oeffnen + $fp = fopen($filename,'r'); + //auslesen + $content = fread($fp, filesize($filename)); + fclose($fp); + //in base64-Werte umrechnen + $content = base64_encode($content); + $person = new person(); + if($person->load($_GET['person_id'])) + { + //base64 Wert in die Datenbank speichern + $person->foto = $content; + $person->new = false; + if($person->save()) + { + $fs = new fotostatus(); + $fs->person_id=$person->person_id; + $fs->fotostatus_kurzbz='hochgeladen'; + $fs->datum = date('Y-m-d'); + $fs->insertamum = date('Y-m-d H:i:s'); + $fs->insertvon = $user; + $fs->updateamum = date('Y-m-d H:i:s'); + $fs->updatevon = $user; + if(!$fs->save(true)) + echo '
Fehler beim Setzen des Bildstatus
'; + else + { + + echo "
Bild wurde erfolgreich gespeichert
+ "; + } + } + else + echo '
'.$person->errormsg.'
'; + } + else + echo '
'.$person->errormsg.'
'; + } + else + echo '
'.$p->t('profil/nurJPGBilder').'
'; + } } -function cropCss() { - return ' - '; -} +//echo '
'; +echo $p->t('profil/BilduploadInfotext',array($p->t('dms_link/bildRichtlinien'))).'

+
+ '.$p->t('profil/Bild').':
+ +
+ '; ?> +