$bOK = false; $sResponse = ""; $sURL = ""; if (isset($_REQUEST['CKEditor'])) { if ($oFU->bUploadOK()) { $oOriginalName = od_clone($oFU->oOriginalFilename()); if ($oOriginalName->bCheck(WYPATH_CHECK_NOSCRIPT | WYPATH_CHECK_NOPATH | WYPATH_CHECK_JUSTIMAGE)) { $sFilename = $oOriginalName->sPath; $sExtension = $oOriginalName->sExtension(); $sFilename = str_replace(".{$sExtension}", "", $sFilename); $sFilename = WYPath::sMakeFilename($sFilename); $oDestPath = od_clone($goApp->oDataPath); $sDestFilename = "rtimg-{$sFilename}.{$sExtension}"; $oDestPath->addComponent($sDestFilename); $oFile = new WYFile($oFU->oFilePath()); if (!$oFile->bCopyTo($oDestPath)) { $goApp->log("Could not copy uploaded image file"); $sResponse = WYTS("FileUploadErrorUnknown", false); } else { $sResponse = ""; $bOK = true; $oURL = od_clone($goApp->oDataURL); $oURL->addComponent($sDestFilename); $sURL = $oURL->sURL(false, false, true); } } else { $goApp->log("Illegal file/type on attachment upload: " . $oOFP->sPath); $sResponse = WYTS("FileUploadErrorUnknown", false); } $oFU->deleteTmpFile(); } else {
/** * Bereitet ein hochgeladenes Bild für die Verwendung durch WebYep vor * * Folgende Aktionen werden durchgeführt: * - es wird ein Name der Form /webyep-system/dat(a|en)/{Document-ID}-{Number}-gl-{Name}-{RND(1000-9999)}.ext vergeben * - prüfen, ob das Bild evtl. zu groß ist und ggf. verkleinern * - Vorschaubild erstellen * - Dateiberechtigungen setzen * - temporäre Dateien löschen * * @param object &$oFromPath temporärer Dateiname (/tmp/filename4711 vom Webserver vergeben) * @param object &$oOrgFilename Originalname der Datei vor dem Upload * @param int $iID imageID, welche dem Bild zugewiesen werden soll */ function useUploadedImageFileForID(&$oFromPath, &$oOrgFilename, $iID) { global $goApp; $sNewFilename = ""; $sExt = strtolower($oOrgFilename->sExtension()); $aItems =& $this->_aItems(); $dItem = array(); $bSuccess = false; if ($oFromPath && isset($aItems[$iID])) { $oFromFile = new WYFile($oFromPath); $oToPath = od_clone($goApp->oDataPath); $sNewFilename = $this->sDataFileName(true) . "-" . mt_rand(1000, 9999) . "." . $sExt; $oToPath->addComponent($sNewFilename); $bOK = false; $a = WYImage::aGetImageSize($oFromPath); $iW = $a[0]; $iH = $a[1]; if (!WYImage::bLimitSize($iW, $iH, $this->iImageWidth, $this->iImageHeight)) { if ($oFromFile->bMoveTo($oToPath)) { $bOK = true; } else { $goApp->log("WYGallery: could not move image file: " . $oFromPath->sPath . " to " . $oToPath->sPath); } } else { $oTMPPath = od_clone($goApp->oDataPath); $oTMPPath->addComponent("WYGalleryUpload_" . mt_rand(1000, 9999) . "." . $sExt); if ($oFromFile->bMoveTo($oTMPPath)) { if (WYImage::bResizeImage($oTMPPath, $oToPath, $iW, $iH)) { $bOK = true; } else { $goApp->log("WYGallery: could not resize uploaded image file: " . $oFromPath->sPath); } if (!@unlink($oTMPPath->sPath)) { $goApp->log("WYGallery: could not unlink uploaded image file: " . $oTMPPath->sPath); } } else { $goApp->log("WYGallery: could not move image file: " . $oFromPath->sPath . " to " . $oTMPPath->sPath); } } if ($bOK) { $this->_deleteImageFilesForID($iID); $dItem =& $aItems[$iID]; $dItem[WY_DK_GALLERY_FILENAME] = $sNewFilename; chmod($oToPath->sPath, 0644); if (!$this->_bCreateThumbNailFor($sNewFilename)) { $oTNPath = od_clone($oToPath); $oTNPath->removeLastComponent(); $oTNPath->addComponent($this->_sThumbnailName($sNewFilename)); $oTNPath->setExtension($oToPath->sExtension()); $oFile = new WYFile($oToPath); if (!$oFile->bCopyTo($oTNPath)) { $goApp->log("could not copy image {$sNewFilename} to thumbnail"); } else { chmod($oTNPath->sPath, 0644); } } } } }