function actionAdd() { // We return to the default action $action = 'default'; // Process the form if ($this->form->validate()) { // Move the uploaded file $file = $this->form->getElement('image'); if ($file->isUploaded()) { // Get the new filename $filename = YDStringUtil::stripSpecialCharacters($file->getBaseName()); // Move the upload if (!is_dir($this->dir_rel)) { @mkdir($this->dir_rel); } @$file->moveUpload($this->dir_rel, $filename); // Convert it to an object $fileObj = new YDFSFile($this->dir_rel . $file->getBaseName()); // Check if it's a ZIP file if (strtolower($fileObj->getExtension() == 'zip')) { // Include the unzip library include YD_DIR_HOME . '/3rdparty/zip/unzip.lib.php'; // Convert it to a ZIP object $zip = new SimpleUnzip($fileObj->getAbsolutePath()); // Get the directory as a path $dir = new YDFSDirectory($this->dir_rel); // Extract the images foreach ($zip->Entries as $entry) { // Save it as a filee $entryFile = $dir->createFile($entry->Name, $entry->Data); // Delete it if it's not an image if (!$entryFile->isImage()) { @unlink($entryFile->getAbsolutePath()); } else { $entryFile = $this->weblog->resizeUploadedImage($entryFile); } } } // Check if it's an image if (!$fileObj->isImage()) { @unlink($fileObj->getAbsolutePath()); } else { $fileObj = $this->weblog->resizeUploadedImage($fileObj); } // Delete the thumbnails @unlink($this->dir_rel . 's_' . $file->getBaseName()); @unlink($this->dir_rel . 'm_' . $file->getBaseName()); } } // Redirect to the list view $this->redirect(YD_SELF_SCRIPT . '?id=' . $this->item['id']); }