$album->setTitle($title); } $album->save(); } else { $AlbumDirName = str_replace(SERVERPATH, '', $gallery->albumdir); zp_error(gettext("The album couldn't be created in the 'albums' folder. This is usually a permissions problem. Try setting the permissions on the albums and cache folders to be world-writable using a shell:") . " <code>chmod 777 " . $AlbumDirName . CACHEFOLDER . "</code>, " . gettext("or use your FTP program to give everyone write permissions to those folders.")); } $error = false; foreach ($_FILES['files']['error'] as $key => $error) { if ($_FILES['files']['name'][$key] == "") { continue; } if ($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES['files']['tmp_name'][$key]; $name = $_FILES['files']['name'][$key]; $soename = UTF8toFilesystem(seoFriendlyURL($name)); if (is_valid_image($name) || is_valid_other_type($name)) { $uploadfile = $uploaddir . '/' . $soename; move_uploaded_file($tmp_name, $uploadfile); @chmod($uploadfile, 0666 & CHMOD_VALUE); $image = newImage($album, $soename); if ($name != $soename) { $image->setTitle($name); $image->save(); } } else { if (is_zip($name)) { unzip($tmp_name, $uploaddir); } } }
/** * Unzips an image archive * * @param file $file the archive * @param string $dir where the images go */ function unzip($file, $dir) { //check if zziplib is installed if (function_exists('zip_open')) { $zip = zip_open($file); if ($zip) { while ($zip_entry = zip_read($zip)) { // Skip non-images in the zip file. $fname = zip_entry_name($zip_entry); $soename = UTF8toFilesystem(seoFriendlyURL($fname)); if (is_valid_image($soename) || is_valid_other_type($soename)) { if (zip_entry_open($zip, $zip_entry, "r")) { $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)); $path_file = str_replace("/", DIRECTORY_SEPARATOR, $dir . '/' . $soename); $fp = fopen($path_file, "w"); fwrite($fp, $buf); fclose($fp); zip_entry_close($zip_entry); $albumname = substr($dir, strlen(getAlbumFolder())); $album = new Album(new Gallery(), $albumname); $image = newImage($album, $soename); if ($fname != $soename) { $image->setTitle($name); $image->save(); } } } } zip_close($zip); } } else { // Use Zlib http://www.phpconcept.net/pclzip/index.en.php require_once dirname(__FILE__) . '/lib-pclzip.php'; $zip = new PclZip($file); if ($zip->extract(PCLZIP_OPT_PATH, $dir, PCLZIP_OPT_REMOVE_ALL_PATH) == 0) { die("Error : " . $zip->errorInfo(true)); } } }