11 function picture($ERPhost,$ERPuser,$ERPpass,$ERPimgdir,$SHOPhost,$SHOPuser,$SHOPpass,$SHOPimgdir,$err) {
12 $this->ERPftphost = $ERPhost;
13 $this->ERPftpuser = $ERPuser;
14 $this->ERPftppwd = $ERPpass;
15 $this->ERPimgdir = $ERPimgdir;
16 $this->SHOPftphost = $SHOPhost;
17 $this->SHOPftpuser = $SHOPuser;
18 $this->SHOPftppwd = $SHOPpass;
19 $this->SHOPimgdir = $SHOPimgdir;
23 function copyImage($id,$image,$typ) {
24 if ( !$this->fromERP($image) ) return false;
25 if ( !$this->mkbilder() ) return false;
26 return $this->toShop($id,$typ);
30 if ( !class_exists("Imagick") ) { $this->err->out("Imagick-Extention nicht installiert",true); return false; };
31 $handle = new Imagick();
32 if ( !$handle->readImage("./tmp/tmp.file_org") ) return false;
33 $d = $handle->getImageGeometry();
34 if ( $d["width"]<$d["height"] ) {
35 $faktor = $d["height"]/$d["width"];
37 $faktor = $d["width"]/$d["height"];
40 $thumbheight = floor($this->thumbwidth*$faktor);
41 $handle->thumbnailImage($this->thumbwidth, $thumbheight);
42 $rc = $handle->writeImage( "./tmp/tmp.file_thumb");
44 $handle->readImage("./tmp/tmp.file_org");
45 $popupheight = floor($this->popupwidth * $faktor);
46 $handle->thumbnailImage( $this->popupwidth, $popupheight);
47 $rc = $handle->writeImage( "./tmp/tmp.file_popup");
49 $handle->readImage("./tmp/tmp.file_org");
50 $infoheight = floor($this->infowidth * $faktor);
51 $handle->thumbnailImage( $this->infowidth, $infoheight);
52 $rc = $handle->writeImage( "./tmp/tmp.file_info");
56 function fromERP($image) {
57 if ( $this->ERPftphost == 'localhost' ) {
58 exec("cp $this->ERPimgdir/$image ./tmp/tmp.file_org",$aus,$rc2);
59 if ( $rc2>0 ) { $this->err->out("[Downloadfehler: $image]",true); return false; };
61 $conn_id = ftp_connect($this->ERPftphost);
62 $rc = @ftp_login($conn_id,$this->ERPftpuser,$this->ERPftppwd);
63 $src = $this->ERPimgdir."/".$image;
64 $upload = @ftp_get($conn_id,"tmp/tmp.file_org","$src",FTP_BINARY);
65 if ( !$upload ) { $this->err->out("[Ftp Downloadfehler! $image]",true); return false; };
68 $this->image = $image;
72 function toShop($id,$typ) {
73 $picname = $id."_0.".$typ;
74 if ( $this->SHOPftphost == 'localhost' ) {
75 exec("cp ./tmp/tmp.file_org $this->SHOPimgdir/original_images/$picname",$aus,$rc1);
76 exec("cp ./tmp/tmp.file_info $this->SHOPimgdir/info_images/$picname",$aus,$rc2);
77 exec("cp ./tmp/tmp.file_popup $this->SHOPimgdir/popup_images/$picname",$aus,$rc3);
78 exec("cp ./tmp/tmp.file_thumb $this->SHOPimgdir/thumbnail_images/$picname",$aus,$rc4);
79 if ( $rc1>0 || $rc2>0 || $rc3>0 || $rc4>0 ) { $this->err->out("[Uploadfehler: $this->image / $picname]",true); return false; };
81 $conn_id = ftp_connect($this->SHOPftphost);
82 @ftp_login($conn_id,$this->SHOPftpuser,$this->SHOPftppwd);
83 @ftp_chdir($conn_id,$this->SHOPimgdir);
84 $upload = @ftp_put($conn_id,$this->SHOPimgdir."/original_images/$picname","tmp/tmp.file_org",FTP_BINARY);
85 if ( !$upload ) { $this->err->out("[Ftp Uploadfehler! original_images/$picname]",true); return false; };
86 $upload = @ftp_put($conn_id,$this->SHOPimgdir."/info_images/$picname","tmp/tmp.file_info",FTP_BINARY);
87 if ( !$upload ) { $this->err->out("[Ftp Uploadfehler! info_images/$picname]",true); return false; };
88 $upload = @ftp_put($conn_id,$this->SHOPimgdir."/popup_images/$picname","tmp/tmp.file_popup",FTP_BINARY);
89 if ( !$upload ) { $this->err->out("[Ftp Uploadfehler! popup_images/$picname]",true); return false; };
90 $upload = @ftp_put($conn_id,$this->SHOPimgdir."/thumbnail_images/$picname","tmp/tmp.file_thumb",FTP_BINARY);
91 if ( !$upload ) { $this->err->out("[Ftp Uploadfehler! thumb_images/$picname]",true); return false; };