/** * Returns a new "image" object based on the file extension * * @param object $album the owner album * @param string $filename the filename * @param bool $quiet set true to supress error messages (used by loadimage) * @return object */ function newImage($album, $filename = NULL, $quiet = false) { global $_zp_missing_image; if (is_array($album)) { $xalbum = newAlbum($album['folder'], true, true); $filename = $album['filename']; $dyn = false; } else { if (is_array($filename)) { $xalbum = newAlbum($filename['folder'], true, true); $filename = $filename['filename']; $dyn = is_object($album) && $album->isDynamic(); } else { if (is_object($album) && $album->isDynamic()) { $dyn = true; $album->getImages(); $xalbum = array_keys($album->imageNames, $filename); $xalbum = array_shift($xalbum); $xalbum = newAlbum(dirname($xalbum), true, true); } else { $xalbum = $album; $dyn = false; } } } if (!is_object($xalbum) || !$xalbum->exists || !isAlbumClass($xalbum)) { $msg = sprintf(gettext('Bad album object parameter to newImage(%s)'), $filename); } else { if ($object = Gallery::imageObjectClass($filename)) { $image = new $object($xalbum, $filename, $quiet); if ($album && is_subclass_of($album, 'AlbumBase') && $dyn) { $image->albumname = $album->name; $image->albumlink = $album->linkname; $image->albumnamealbum = $album; } zp_apply_filter('image_instantiate', $image); if ($image->exists) { return $image; } return $_zp_missing_image; } $msg = sprintf(gettext('Bad filename suffix in newImage(%s)'), $filename); } if (!$quiet) { zp_error($msg, E_USER_WARNING); } return $_zp_missing_image; }
/** * emits the html for editing album information * called in edit album and mass edit * @param string $index the index of the entry in mass edit or '0' if single album * @param object $album the album object * @param bool $buttons set true for "apply" buttons * @since 1.1.3 */ function printAlbumEditForm($index, $album, $buttons = true) { global $_zp_sortby, $_zp_gallery, $mcr_albumlist, $_zp_albumthumb_selector, $_zp_current_admin_obj; $isPrimaryAlbum = ''; if (!zp_loggedin(MANAGE_ALL_ALBUM_RIGHTS)) { $myalbum = $_zp_current_admin_obj->getAlbum(); if ($myalbum && $album->getID() == $myalbum->getID()) { $isPrimaryAlbum = ' disabled="disabled"'; } } $tagsort = getTagOrder(); if ($index == 0) { $suffix = $prefix = ''; } else { $prefix = "{$index}-"; $suffix = "_{$index}"; echo '<p><em><strong><a href="' . WEBPATH . '/' . ZENFOLDER . '/admin-edit.php?page=edit&album=' . urlencode($album->name) . '&tab=albuminfo">' . urlencode($album->name) . '</a></strong></em></p>'; } if (isset($_GET['subpage'])) { ?> <input type="hidden" name="subpage" value="<?php echo html_encode(sanitize($_GET['subpage'])); ?> " /> <?php } ?> <input type="hidden" name="<?php echo $prefix; ?> folder" value="<?php echo $album->name; ?> " /> <input type="hidden" name="tagsort" value="<?php echo html_encode($tagsort); ?> " /> <input type="hidden" name="password_enabled<?php echo $suffix; ?> " id="password_enabled<?php echo $suffix; ?> " value="0" /> <?php if ($buttons) { ?> <span class="buttons"> <?php $parent = dirname($album->name); if ($parent == '/' || $parent == '.' || empty($parent)) { $parent = ''; } else { $parent = '&album=' . $parent . '&tab=subalbuminfo'; } ?> <a href="<?php echo WEBPATH . '/' . ZENFOLDER . '/admin-edit.php?page=edit' . $parent; ?> "> <img src="images/arrow_left_blue_round.png" alt="" /> <strong><?php echo gettext("Back"); ?> </strong> </a> <button type="submit"> <img src="images/pass.png" alt="" /> <strong><?php echo gettext("Apply"); ?> </strong> </button> <button type="reset" onclick="$('.deletemsg').hide();" > <img src="images/fail.png" alt="" /> <strong><?php echo gettext("Reset"); ?> </strong> </button> <div class="floatright"> <?php if (!$album->isDynamic()) { ?> <button type="button" title="<?php echo addslashes(gettext('New subalbum')); ?> " onclick="newAlbumJS('<?php echo pathurlencode($album->name); ?> ', false);"> <img src="images/folder.png" alt="" /> <strong><?php echo gettext('New subalbum'); ?> </strong> </button> <button type="button" title="<?php echo addslashes(gettext('New dynamic subalbum')); ?> " onclick="newAlbumJS('<?php echo pathurlencode($album->name); ?> ', true);"> <img src="images/folder.png" alt="" /> <strong><?php echo gettext('New dynamic subalbum'); ?> </strong> </button> <?php } ?> <a href="<?php echo WEBPATH . "/index.php?album=" . html_encode(pathurlencode($album->getFileName())); ?> "> <img src="images/view.png" alt="" /> <strong><?php echo gettext('View Album'); ?> </strong> </a> </div> </span> <?php } ?> <br class="clearall" /><br /> <table class="formlayout"> <tr> <td valign="top"> <table class="width100percent"> <tr> <td class="leftcolumn"> <?php echo gettext("Album Title"); ?> : </td> <td class="middlecolumn"> <?php print_language_string_list($album->getTitle('all'), $prefix . "albumtitle", false, null, '', '100%'); ?> </td> </tr> <tr> <td class="leftcolumn"> <?php echo linkPickerIcon($album, 'pick_link'); ?> </td> <td class="middlecolumn"> <?php echo linkPickerItem($album, 'pick_link'); ?> </td> </tr> <?php if ($album->isDynamic()) { ?> <tr> <td align="left" valign="top" width="150"><em><?php echo get_class($album); ?> </em></td> <td class="noinput"> <?php switch ($album->isDynamic()) { case 'alb': echo html_encode(str_replace(',', ', ', urldecode($album->getSearchParams()))); break; case 'fav': echo html_encode($album->owner); if ($album->instance) { echo ' [' . html_encode($album->instance) . ']'; } break; } ?> </td> </tr> <?php } ?> <tr> <td class="leftcolumn"> <?php echo gettext("Album Description:"); ?> </td> <td> <?php print_language_string_list($album->getDesc('all'), $prefix . "albumdesc", true, NULL, 'texteditor', '100%'); ?> </td> </tr> <?php if (GALLERY_SECURITY == 'public') { ?> <tr class="password<?php echo $suffix; ?> extrashow"> <td class="leftcolumn"> <a onclick="toggle_passwords('<?php echo $suffix; ?> ', true);"> <?php echo gettext("Album password:"******"middlecolumn"> <?php $x = $album->getPassword(); if (empty($x)) { ?> <a onclick="toggle_passwords('<?php echo $suffix; ?> ', true);"> <img src="images/lock_open.png" /> <?php echo gettext('No album password is currently set. Click to set one.'); ?> </a> <?php } else { $x = ' '; ?> <a onclick="resetPass('<?php echo $suffix; ?> ');" title="<?php echo addslashes(gettext('clear password')); ?> "> <img src="images/lock.png" /> <?php echo gettext('An album password is currently set. Click to clear or change the password.'); ?> </a> <?php } ?> </td> </tr> <tr class="password<?php echo $suffix; ?> extrahide" style="display:none" > <td class="leftcolumn"> <a onclick="toggle_passwords('<?php echo $suffix; ?> ', false);"> <?php echo gettext("Album guest user:"******"checkbox" name="disclose_password<?php echo $suffix; ?> " id="disclose_password<?php echo $suffix; ?> " onclick="passwordClear('<?php echo $suffix; ?> '); togglePassword('<?php echo $suffix; ?> ');" /><?php echo addslashes(gettext('Show password')); ?> </label> </td> <td> <input type="text" class="passignore<?php echo $suffix; ?> ignoredirty" autocomplete="off" size="<?php echo TEXT_INPUT_SIZE; ?> " onkeydown="passwordClear('<?php echo $suffix; ?> ');" id="user_name<?php echo $suffix; ?> " name="user<?php echo $suffix; ?> " value="<?php echo $album->getUser(); ?> " /> </td> </tr> <tr class="password<?php echo $suffix; ?> extrahide" style="display:none" > <td class="leftcolumn"> <p> <span id="strength<?php echo $suffix; ?> "><?php echo gettext("Album password:"******"match<?php echo $suffix; ?> " class="password_field_<?php echo $suffix; ?> "> <?php echo gettext("repeat password:"******"Password hint:"); ?> </p> </td> <td> <p> <input type="password" class="passignore<?php echo $suffix; ?> ignoredirty" autocomplete="off" id="pass<?php echo $suffix; ?> " name="pass<?php echo $suffix; ?> " onkeydown="passwordClear('<?php echo $suffix; ?> ');" onkeyup="passwordStrength('<?php echo $suffix; ?> ');" value="<?php echo $x; ?> " /> <br /> <span class="password_field_<?php echo $suffix; ?> "> <input type="password" class="passignore<?php echo $suffix; ?> ignoredirty" autocomplete="off" id="pass_r<?php echo $suffix; ?> " name="pass_r<?php echo $suffix; ?> " disabled="disabled" onkeydown="passwordClear('<?php echo $suffix; ?> ');" onkeyup="passwordMatch('<?php echo $suffix; ?> ');" value="<?php echo $x; ?> " /> </span> </p> <p> <?php print_language_string_list($album->getPasswordHint('all'), "hint" . $suffix, false, NULL, 'hint', '100%'); ?> </p> </td> </tr> <?php } $sort = $_zp_sortby; if (!$album->isDynamic()) { $sort[gettext('Manual')] = 'manual'; } $sort[gettext('Custom')] = 'custom'; /* * not recommended--screws with peoples minds during pagination! $sort[gettext('Random')] = 'random'; */ ?> <tr> <td class="leftcolumn"><?php echo gettext("Sort subalbums by:"); ?> </td> <td> <span class="nowrap"> <select id="albumsortselect<?php echo $prefix; ?> " name="<?php echo $prefix; ?> subalbumsortby" onchange="update_direction(this, 'album_direction_div<?php echo $suffix; ?> ', 'album_custom_div<?php echo $suffix; ?> ');"> <?php if (is_null($album->getParent())) { $globalsort = gettext("*gallery album sort order"); } else { $globalsort = gettext("*parent album subalbum sort order"); } echo "\n<option value =''>{$globalsort}</option>"; $cvt = $type = strtolower($album->get('subalbum_sort_type')); if ($type && !in_array($type, $sort)) { $cv = array('custom'); } else { $cv = array($type); } generateListFromArray($cv, $sort, false, true); ?> </select> <?php if ($type == 'manual' || $type == 'random' || $type == '') { $dsp = 'none'; } else { $dsp = 'inline'; } ?> <label id="album_direction_div<?php echo $suffix; ?> " style="display:<?php echo $dsp; ?> ;white-space:nowrap;"> <?php echo gettext("Descending"); ?> <input type="checkbox" name="<?php echo $prefix; ?> album_sortdirection" value="1" <?php if ($album->getSortDirection('album')) { echo "CHECKED"; } ?> /> </label> </span> <?php $flip = array_flip($sort); if (empty($type) || isset($flip[$type])) { $dsp = 'none'; } else { $dsp = 'block'; } ?> <span id="album_custom_div<?php echo $suffix; ?> " class="customText" style="display:<?php echo $dsp; ?> ;white-space:nowrap;"> <br /> <?php echo gettext('custom fields:'); ?> <span class="tagSuggestContainer"> <input id="customalbumsort<?php echo $suffix; ?> " class="customalbumsort" name="<?php echo $prefix; ?> customalbumsort" type="text" value="<?php echo html_encode($cvt); ?> " /> </span> </span> </td> </tr> <tr> <td class="leftcolumn"><?php echo gettext("Sort images by"); ?> </td> <td> <span class="nowrap"> <select id="imagesortselect<?php echo $prefix; ?> " name="<?php echo $prefix; ?> sortby" onchange="update_direction(this, 'image_direction_div<?php echo $suffix; ?> ', 'image_custom_div<?php echo $suffix; ?> ')"> <?php if (is_null($album->getParent())) { $globalsort = gettext("*gallery image sort order"); } else { $globalsort = gettext("*parent album image sort order"); } ?> <option value =""><?php echo $globalsort; ?> </option> <?php $cvt = $type = strtolower($album->get('sort_type')); if ($type && !in_array($type, $sort)) { $cv = array('custom'); } else { $cv = array($type); } generateListFromArray($cv, $sort, false, true); ?> </select> <?php if ($type == 'manual' || $type == 'random' || $type == '') { $dsp = 'none'; } else { $dsp = 'inline'; } ?> <label id="image_direction_div<?php echo $suffix; ?> " style="display:<?php echo $dsp; ?> ;white-space:nowrap;"> <?php echo gettext("Descending"); ?> <input type="checkbox" name="<?php echo $prefix; ?> image_sortdirection" value="1" <?php if ($album->getSortDirection('image')) { echo ' checked="checked"'; } ?> /> </label> </span> <?php $flip = array_flip($sort); if (empty($type) || isset($flip[$type])) { $dsp = 'none'; } else { $dsp = 'block'; } ?> <span id="image_custom_div<?php echo $suffix; ?> " class="customText" style="display:<?php echo $dsp; ?> ;white-space:nowrap;"> <br /> <?php echo gettext('custom fields:'); ?> <span class="tagSuggestContainer"> <input id="customimagesort<?php echo $suffix; ?> " class="customimagesort" name="<?php echo $prefix; ?> customimagesort" type="text" value="<?php echo html_encode($cvt); ?> " /> </span> </span> </td> </tr> <?php if (is_null($album->getParent())) { ?> <tr> <td class="leftcolumn"><?php echo gettext("Album theme:"); ?> </td> <td> <select id="album_theme" class="album_theme" name="<?php echo $prefix; ?> album_theme" <?php if (!zp_loggedin(THEMES_RIGHTS)) { echo 'disabled="disabled" '; } ?> > <?php $themes = $_zp_gallery->getThemes(); $oldtheme = $album->getAlbumTheme(); if (empty($oldtheme)) { $selected = 'selected="selected"'; } else { $selected = ''; } ?> <option value="" style="background-color:LightGray" <?php echo $selected; ?> ><?php echo gettext('*gallery theme'); ?> </option> <?php foreach ($themes as $theme => $themeinfo) { if ($oldtheme == $theme) { $selected = 'selected="selected"'; } else { $selected = ''; } ?> <option value = "<?php echo $theme; ?> " <?php echo $selected; ?> ><?php echo $themeinfo['name']; ?> </option> <?php } ?> </select> </td> </tr> <?php } if (!$album->isDynamic()) { ?> <tr> <td class="leftcolumn"><?php echo gettext("Album watermarks:"); ?> </td> <td> <?php $current = $album->getWatermark(); ?> <select id="album_watermark<?php echo $suffix; ?> " name="<?php echo $prefix; ?> album_watermark"> <option value="<?php echo NO_WATERMARK; ?> " <?php if ($current == NO_WATERMARK) { echo ' selected="selected"'; } ?> style="background-color:LightGray"><?php echo gettext('*no watermark'); ?> </option> <option value="" <?php if (empty($current)) { echo ' selected="selected"'; } ?> style="background-color:LightGray"><?php echo gettext('*default'); ?> </option> <?php $watermarks = getWatermarks(); generateListFromArray(array($current), $watermarks, false, false); ?> </select> <em><?php echo gettext('Images'); ?> </em> </td> </tr> <tr> <td class="leftcolumn"></td> <td> <?php $current = $album->getWatermarkThumb(); ?> <select id="album_watermark_thumb<?php echo $suffix; ?> " name="<?php echo $prefix; ?> album_watermark_thumb"> <option value="<?php echo NO_WATERMARK; ?> " <?php if ($current == NO_WATERMARK) { echo ' selected="selected"'; } ?> style="background-color:LightGray"><?php echo gettext('*no watermark'); ?> </option> <option value="" <?php if (empty($current)) { echo ' selected="selected"'; } ?> style="background-color:LightGray"><?php echo gettext('*default'); ?> </option> <?php $watermarks = getWatermarks(); generateListFromArray(array($current), $watermarks, false, false); ?> </select> <em><?php echo gettext('Thumbs'); ?> </em> </td> </tr> <?php } if ($index == 0) { // suppress for mass-edit $showThumb = $_zp_gallery->getThumbSelectImages(); $album->getAlbumThumbImage(); // prime the thumbnail since we will get the field below $thumb = $album->get('thumb'); $selections = array(); $selected = array(); foreach ($_zp_albumthumb_selector as $key => $selection) { $selections[$selection['desc']] = $key; if ($key == $thumb) { $selected[] = $key; } } ?> <tr> <td class="leftcolumn"><?php echo gettext("Thumbnail:"); ?> </td> <td> <?php if ($showThumb) { ?> <script type="text/javascript"> // <!-- <![CDATA[ updateThumbPreview(document.getElementById('thumbselect')); // ]]> --> </script> <?php } ?> <select style="width:320px" <?php if ($showThumb) { ?> class="thumbselect" onchange="updateThumbPreview(this);" <?php } ?> name="<?php echo $prefix; ?> thumb"> <?php generateListFromArray($selected, $selections, false, true); $imagelist = $album->getImages(0); $subalbums = $album->getAlbums(0); foreach ($subalbums as $folder) { $newalbum = newAlbum($folder); if ($images = $_zp_gallery->getSecondLevelThumbs()) { $images = $newalbum->getImages(0); foreach ($images as $filename) { if (is_array($filename)) { $imagelist[] = $filename; } else { $imagelist[] = '/' . $folder . '/' . $filename; } } } if (empty($images)) { $t = $newalbum->getAlbumThumbImage(); if (strtolower(get_class($t)) !== 'transientimage' && $t->exists) { $imagelist[] = '/' . $t->getAlbumName() . '/' . $t->filename; } } } if ($thumb && !is_numeric($thumb)) { // check for current thumb being in the list. If not, add it $target = $thumb; $targetA = array('folder' => dirname($thumb), 'filename' => basename($thumb)); if (!in_array($target, $imagelist) && !in_array($targetA, $imagelist)) { array_unshift($imagelist, $target); } } if (!empty($imagelist)) { // there are some images to choose from foreach ($imagelist as $imagename) { if (is_array($imagename)) { $image = newImage($imagename); $imagename = '/' . $imagename['folder'] . '/' . $imagename['filename']; $filename = basename($imagename); } else { $albumname = trim(dirname($imagename), '/'); if (empty($albumname) || $albumname == '.') { $thumbalbum = $album; } else { $thumbalbum = newAlbum($albumname); } $filename = basename($imagename); $image = newImage($thumbalbum, $filename); } $selected = $imagename == $thumb; if (Gallery::imageObjectClass($filename) == 'Image' || !is_null($image->objectsThumb)) { echo "\n<option"; if ($_zp_gallery->getThumbSelectImages()) { echo " class=\"thumboption\""; echo " style=\"background-image: url(" . html_encode(pathurlencode(getAdminThumb($image, 'medium'))) . "); background-repeat: no-repeat;\""; } echo " value=\"" . $imagename . "\""; if ($selected) { echo " selected=\"selected\""; } echo ">" . $image->getTitle(); if ($filename != $image->getTitle()) { echo " ({$filename})"; } echo "</option>"; } } } ?> </select> </td> </tr> <?php } echo $custom = zp_apply_filter('edit_album_custom_data', '', $album, $prefix); ?> </table> </td> <?php $bglevels = array('#fff', '#f8f8f8', '#efefef', '#e8e8e8', '#dfdfdf', '#d8d8d8', '#cfcfcf', '#c8c8c8'); ?> <td class="rightcolumn" valign="top"> <h2 class="h2_bordered_edit"><?php echo gettext("General"); ?> </h2> <div class="box-edit"> <label class="checkboxlabel"> <input type="checkbox" name="<?php echo $prefix; ?> Published" value="1" <?php if ($album->getShow()) { echo ' checked="checked"'; } ?> onclick="$('#<?php echo $prefix; ?> publishdate').val(''); $('#<?php echo $prefix; ?> expirationdate').val(''); $('#<?php echo $prefix; ?> publishdate').css('color', 'black'); $('.<?php echo $prefix; ?> expire').html('');" /> <?php echo gettext("Published"); ?> </label> <?php if (extensionEnabled('comment_form')) { ?> <label class="checkboxlabel"> <input type="checkbox" name="<?php echo $prefix . 'allowcomments'; ?> " value="1" <?php if ($album->getCommentsAllowed()) { echo ' checked="checked"'; } ?> /> <?php echo gettext("Allow Comments"); ?> </label> <?php } if (extensionEnabled('hitcounter')) { $hc = $album->get('hitcounter'); if (empty($hc)) { $hc = '0'; } ?> <label class="checkboxlabel"> <input type="checkbox" name="reset_hitcounter<?php echo $prefix; ?> "<?php if (!$hc) { echo ' disabled="disabled"'; } ?> /> <?php echo sprintf(ngettext("Reset hit counter (%u hit)", "Reset hit counter (%u hits)", $hc), $hc); ?> </label> <?php } if (extensionEnabled('rating')) { $tv = $album->get('total_value'); $tc = $album->get('total_votes'); if ($tc > 0) { $hc = $tv / $tc; ?> <label class="checkboxlabel"> <input type="checkbox" id="reset_rating<?php echo $suffix; ?> " name="<?php echo $prefix; ?> reset_rating" value="1" /> <?php printf(gettext('Reset rating (%u stars)'), $hc); ?> </label> <?php } else { ?> <label class="checkboxlabel"> <input type="checkbox" name="<?php echo $prefix; ?> reset_rating" value="1" disabled="disabled"/> <?php echo gettext('Reset rating (unrated)'); ?> </label> <?php } } $publishdate = $album->getPublishDate(); $expirationdate = $album->getExpireDate(); ?> <script type="text/javascript"> // <!-- <![CDATA[ $(function () { $("#<?php echo $prefix; ?> publishdate,#<?php echo $prefix; ?> expirationdate").datepicker({ dateFormat: 'yy-mm-dd', showOn: 'button', buttonImage: '../zp-core/images/calendar.png', buttonText: '<?php echo addslashes(gettext("calendar")); ?> ', buttonImageOnly: true }); $('#<?php echo $prefix; ?> publishdate').change(function () { var today = new Date(); var pub = $('#<?php echo $prefix; ?> publishdate').datepicker('getDate'); if (pub.getTime() > today.getTime()) { $("<?php echo $prefix; ?> Published").removeAttr('checked'); $('#<?php echo $prefix; ?> publishdate').css('color', 'blue'); } else { $("<?php echo $prefix; ?> Published").attr('checked', 'checked'); $('#<?php echo $prefix; ?> publishdate').css('color', 'black'); } }); $('#<?php echo $prefix; ?> expirationdate').change(function () { var today = new Date(); var expiry = $('#<?php echo $prefix; ?> expirationdate').datepicker('getDate'); if (expiry.getTime() > today.getTime()) { $(".<?php echo $prefix; ?> expire").html(''); } else { $(".<?php echo $prefix; ?> expire").html('<br /><?php echo addslashes(gettext('Expired!')); ?> '); } }); }); // ]]> --> </script> <br class="clearall" /> <hr /> <p> <label for="<?php echo $prefix; ?> publishdate"><?php echo gettext('Publish date'); ?> <small>(YYYY-MM-DD)</small></label> <br /><input value="<?php echo $publishdate; ?> " type="text" size="20" maxlength="30" name="publishdate-<?php echo $prefix; ?> " id="<?php echo $prefix; ?> publishdate" <?php if ($publishdate > date('Y-m-d H:i:s')) { echo 'style="color:blue"'; } ?> /> <label for="<?php echo $prefix; ?> expirationdate"><?php echo gettext('Expiration date'); ?> <small>(YYYY-MM-DD)</small></label> <br /><input value="<?php echo $expirationdate; ?> " type="text" size="20" maxlength="30" name="expirationdate-<?php echo $prefix; ?> " id="<?php echo $prefix; ?> expirationdate" /> <strong class="<?php echo $prefix; ?> expire" style="color:red"> <?php if (!empty($expirationdate) && $expirationdate <= date('Y-m-d H:i:s')) { echo '<br />' . gettext('Expired!'); } ?> </strong> </p> </div> <!-- **************** Move/Copy/Rename ****************** --> <h2 class="h2_bordered_edit"><?php echo gettext("Utilities"); ?> </h2> <div class="box-edit"> <label class="checkboxlabel"> <input type="radio" id="a-<?php echo $prefix; ?> move" name="a-<?php echo $prefix; ?> MoveCopyRename" value="move" onclick="toggleAlbumMCR('<?php echo $prefix; ?> ', 'move');"<?php echo $isPrimaryAlbum; ?> /> <?php echo gettext("Move"); ?> </label> <label class="checkboxlabel"> <input type="radio" id="a-<?php echo $prefix; ?> copy" name="a-<?php echo $prefix; ?> MoveCopyRename" value="copy" onclick="toggleAlbumMCR('<?php echo $prefix; ?> ', 'copy');"/> <?php echo gettext("Copy"); ?> </label> <label class="checkboxlabel"> <input type="radio" id="a-<?php echo $prefix; ?> rename" name="a-<?php echo $prefix; ?> MoveCopyRename" value="rename" onclick="toggleAlbumMCR('<?php echo $prefix; ?> ', 'rename');" <?php echo $isPrimaryAlbum; ?> /> <?php echo gettext("Rename Folder"); ?> </label> <label class="checkboxlabel"> <input type="radio" id="Delete-<?php echo $prefix; ?> " name="a-<?php echo $prefix; ?> MoveCopyRename" value="delete" <?php if ($isPrimaryAlbum) { ?> disabled="disabled" <?php } else { ?> onclick="toggleAlbumMCR('<?php echo $prefix; ?> ', ''); deleteConfirm('Delete-<?php echo $prefix; ?> ', '<?php echo $prefix; ?> ', deleteAlbum1);" <?php } ?> /> <?php echo gettext("Delete album"); ?> </label> <br class="clearall" /> <div class="deletemsg" id="deletemsg<?php echo $prefix; ?> " style="padding-top: .5em; padding-left: .5em; color: red; display: none"> <?php echo gettext('Album will be deleted when changes are applied.'); ?> <br class="clearall" /> <p class="buttons"> <a onclick="toggleAlbumMCR('<?php echo $prefix; ?> ', '');"><img src="images/reset.png" alt="" /><?php echo addslashes(gettext("Cancel")); ?> </a> </p> </div> <div id="a-<?php echo $prefix; ?> movecopydiv" style="padding-top: .5em; padding-left: .5em; display: none;"> <?php echo gettext("to:"); ?> <select id="a-<?php echo $prefix; ?> albumselectmenu" name="a-<?php echo $prefix; ?> albumselect" onchange=""> <?php $exclude = $album->name; if (count(explode('/', $exclude)) > 1 && zp_loggedin(MANAGE_ALL_ALBUM_RIGHTS)) { ?> <option value="" selected="selected">/</option> <?php } foreach ($mcr_albumlist as $fullfolder => $albumtitle) { // don't allow copy in place or to subalbums if ($fullfolder == dirname($exclude) || $fullfolder == $exclude || strpos($fullfolder, $exclude . '/') === 0) { $disabled = ' disabled="disabled"'; } else { $disabled = ''; } // Get rid of the slashes in the subalbum, while also making a subalbum prefix for the menu. $singlefolder = $fullfolder; $saprefix = ''; $salevel = 0; while (strstr($singlefolder, '/') !== false) { $singlefolder = substr(strstr($singlefolder, '/'), 1); $saprefix = " " . $saprefix; $salevel = ($salevel + 1) % 8; } echo '<option value="' . $fullfolder . '"' . ($salevel > 0 ? ' style="background-color: ' . $bglevels[$salevel] . ';"' : '') . "{$disabled}>" . $saprefix . $singlefolder . "</option>\n"; } ?> </select> <br class="clearall" /><br /> <p class="buttons"> <a onclick="toggleAlbumMCR('<?php echo $prefix; ?> ', '');"><img src="images/reset.png" alt="" /><?php echo addslashes(gettext("Cancel")); ?> </a> </p> </div> <div id="a-<?php echo $prefix; ?> renamediv" style="padding-top: .5em; padding-left: .5em; display: none;"> <?php echo gettext("to:"); ?> <input name="a-<?php echo $prefix; ?> renameto" type="text" value="<?php echo basename($album->name); ?> "/><br /> <br class="clearall" /> <p class="buttons"> <a onclick="toggleAlbumMCR('<?php echo $prefix; ?> ', '');"><img src="images/reset.png" alt="" /><?php echo addslashes(gettext("Cancel")); ?> </a> </p> </div> <span class="clearall" ></span> <?php echo zp_apply_filter('edit_album_utilities', '', $album, $prefix); printAlbumButtons($album); ?> <span class="clearall" ></span> </div> </td> </tr> </table> <br class="clearall" /> <?php if ($buttons) { ?> <span class="buttons"> <a href="<?php echo WEBPATH . '/' . ZENFOLDER . '/admin-edit.php?page=edit' . $parent; ?> "> <img src="images/arrow_left_blue_round.png" alt="" /> <strong><?php echo gettext("Back"); ?> </strong> </a> <button type="submit"> <img src="images/pass.png" alt="" /> <strong><?php echo gettext("Apply"); ?> </strong> </button> <button type="reset" onclick="$('.deletemsg').hide();"> <img src="images/fail.png" alt="" /> <strong><?php echo gettext("Reset"); ?> </strong> </button> <div class="floatright"> <?php if (!$album->isDynamic()) { ?> <button type="button" title="<?php echo addslashes(gettext('New subalbum')); ?> " onclick="newAlbumJS('<?php echo pathurlencode($album->name); ?> ', false);"> <img src="images/folder.png" alt="" /> <strong><?php echo gettext('New subalbum'); ?> </strong> </button> <?php if (!$album->isDynamic()) { ?> <button type="button" title="<?php echo addslashes(gettext('New dynamic subalbum')); ?> " onclick="newAlbumJS('<?php echo pathurlencode($album->name); ?> ', true);"> <img src="images/folder.png" alt="" /> <strong><?php echo gettext('New dynamic subalbum'); ?> </strong> </button> <?php } } ?> <a href="<?php echo WEBPATH . "/index.php?album=" . html_encode(pathurlencode($album->getFileName())); ?> "> <img src="images/view.png" alt="" /> <strong><?php echo gettext('View Album'); ?> </strong> </a> </div> </span> <?php } ?> <br class="clearall" /> <?php }
/** * Load all of the filenames that are found in this Albums directory on disk. * Returns an array with all the names. * * @param $dirs Whether or not to return directories ONLY with the file array. * @return array */ protected function loadFileNames($dirs = false) { clearstatcache(); $albumdir = $this->localpath; $dir = @opendir($albumdir); if (!$dir) { if (is_dir($albumdir)) { $msg = sprintf(gettext("Error: The album %s is not readable."), html_encode($this->name)); } else { $msg = sprintf(gettext("Error: The album named %s cannot be found."), html_encode($this->name)); } zp_error($msg, E_USER_WARNING); return array(); } $files = array(); $others = array(); while (false !== ($file = readdir($dir))) { $file8 = filesystemToInternal($file); if (@$file8[0] != '.') { if ($dirs && (is_dir($albumdir . $file) || hasDynamicAlbumSuffix($file))) { $files[] = $file8; } else { if (!$dirs && is_file($albumdir . $file)) { if ($handler = Gallery::imageObjectClass($file)) { $files[] = $file8; if ($handler !== 'Image') { $others[] = $file8; } } } } } } closedir($dir); if (count($others) > 0) { $others_thumbs = array(); foreach ($others as $other) { $others_root = substr($other, 0, strrpos($other, ".")); foreach ($files as $image) { if ($image != $other) { $image_root = substr($image, 0, strrpos($image, ".")); if ($image_root == $others_root && Gallery::imageObjectClass($image) == 'Image') { $others_thumbs[] = $image; } } } } $files = array_diff($files, $others_thumbs); } if ($dirs) { return zp_apply_filter('album_filter', $files); } else { return zp_apply_filter('image_filter', $files); } }
$uri = getImageURI($args, dirname($i), basename($i), NULL); header("HTTP/1.0 302 Found"); header("Status: 302 Found"); header('Location: ' . $uri); exitZP(); } } } } if (isset($_GET['fromlogout'])) { header("HTTP/1.0 302 Found"); header("Status: 302 Found"); header('Location: ' . WEBPATH . '/index.php'); exitZP(); } if (empty($image) && Gallery::imageObjectClass($album)) { $image = basename($album); $album = dirname($album); } $_404_data = array($album, $image, $obj = @$_zp_gallery_page, @$_index_theme, @$_zp_page); $_zp_gallery_page = '404.php'; if (isset($_index_theme)) { $_zp_script = SERVERPATH . "/" . THEMEFOLDER . '/' . internalToFilesystem($_index_theme) . '/404.php'; } else { $_zp_script = NULL; } if (class_exists('ipBlocker')) { ipBlocker::notFound(); } header('Content-Type: text/html; charset=' . LOCAL_CHARSET); header("HTTP/1.0 404 Not Found");
} $album->setShow((int) ($_POST['publishalbum'] == 'true')); $album->save(); } else { $AlbumDirName = str_replace(SERVERPATH, '', $_zp_gallery->albumdir); zp_error(gettext("The album could not 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.")); } foreach ($_FILES['files']['error'] as $key => $error) { $filecount++; if ($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES['files']['tmp_name'][$key]; $name = sanitize_path($_FILES['files']['name'][$key]); $soename = seoFriendly($name); $error = zp_apply_filter('check_upload_quota', UPLOAD_ERR_OK, $tmp_name); if (!$error) { if (Gallery::imageObjectClass($name)) { if (strrpos($soename, '.') === 0) { $soename = md5($name) . $soename; } // soe stripped out all the name. if (!$error) { $uploadfile = $targetPath . '/' . internalToFilesystem($soename); if (file_exists($uploadfile)) { $append = '_' . time(); $soename = stripSuffix($soename) . $append . '.' . getSuffix($soename); $uploadfile = $targetPath . '/' . internalToFilesystem($soename); } move_uploaded_file($tmp_name, $uploadfile); @chmod($uploadfile, FILE_MOD); $image = newImage($album, $soename); $image->setOwner($_zp_current_admin_obj->getUser());
private function handle_file_upload($uploaded_file, $name, $size, $type, $error) { global $folder, $targetPath, $_zp_current_admin_obj; $file = new stdClass(); $name = $this->trim_file_name($name, $type); $seoname = seoFriendly($name); if (strrpos($seoname, '.') === 0) { $seoname = sha1($name) . $seoname; } // soe stripped out all the name. $targetFile = $targetPath . '/' . internalToFilesystem($seoname); if (file_exists($targetFile)) { $append = '_' . time(); $seoname = stripSuffix($seoname) . $append . '.' . getSuffix($seoname); $targetFile = $targetPath . '/' . internalToFilesystem($seoname); } $file->name = $seoname; $file->size = intval($size); $file->type = $type; $error = $this->has_error($uploaded_file, $file, $error); if (!$error && $file->name) { $file_path = $this->options['upload_dir'] . $file->name; $append_file = !$this->options['discard_aborted_uploads'] && is_file($file_path) && $file->size > filesize($file_path); clearstatcache(); if ($uploaded_file && is_uploaded_file($uploaded_file)) { // multipart/formdata uploads (POST method uploads) if ($append_file) { file_put_contents($file_path, fopen($uploaded_file, 'r'), FILE_APPEND); } else { move_uploaded_file($uploaded_file, $file_path); if (Gallery::imageObjectClass($name)) { @chmod($targetFile, FILE_MOD); $album = newAlbum($folder); $image = newImage($album, $seoname); $image->setOwner($_zp_current_admin_obj->getUser()); if ($name != $seoname && $image->getTitle() == substr($seoname, 0, strrpos($seoname, '.'))) { $image->setTitle(stripSuffix($name, '.')); } $image->save(); } else { if (is_zip($targetFile)) { unzip($targetFile, $targetPath); unlink($targetFile); } else { $file->error = $error = UPLOAD_ERR_EXTENSION; // invalid file uploaded } } } } else { // Non-multipart uploads (PUT method support) file_put_contents($file_path, fopen('php://input', 'r'), $append_file ? FILE_APPEND : 0); } $file_size = filesize($file_path); if ($file_size === $file->size) { $file->url = $this->options['upload_url'] . rawurlencode($file->name); foreach ($this->options['image_versions'] as $version => $options) { if ($this->create_scaled_image($file->name, $options)) { $file->{$version . '_url'} = $options['upload_url'] . rawurlencode($file->name); } } } else { if ($this->options['discard_aborted_uploads']) { @chmod($file_path, 0777); unlink($file_path); $file->error = 'abort'; } } $file->size = $file_size; $file->delete_url = $this->options['script_url'] . '?file=' . rawurlencode($file->name); $file->delete_type = 'DELETE'; } else { $file->error = $error; } return $file; }
/** * Handles the special cases of album/image[rewrite_suffix] * * Separates the image part from the album if it is an image reference * Strips off the mod_rewrite_suffix if present * Handles dynamic album names that do not have the .alb suffix appended * * @param string $albumvar $_GET index for "albums" * @param string $imagevar $_GET index for "images" */ function rewrite_get_album_image($albumvar, $imagevar) { global $_zp_rewritten, $_zp_albumHandlers; $ralbum = isset($_GET[$albumvar]) ? trim(sanitize($_GET[$albumvar]), '/') : NULL; $rimage = isset($_GET[$imagevar]) ? sanitize($_GET[$imagevar]) : NULL; // we assume that everything is correct if rewrite rules were not applied if ($_zp_rewritten) { if (!empty($ralbum) && empty($rimage)) { // rewrite rules never set the image part! $path = internalToFilesystem(getAlbumFolder(SERVERPATH) . $ralbum); if (IM_SUFFIX) { // require the rewrite have the suffix as well if (preg_match('|^(.*)' . preg_quote(IM_SUFFIX) . '$|', $ralbum, $matches)) { //has an IM_SUFFIX attached $rimage = basename($matches[1]); $ralbum = trim(dirname($matches[1]), '/'); $path = internalToFilesystem(getAlbumFolder(SERVERPATH) . $ralbum); } } else { // have to figure it out if (Gallery::imageObjectClass($ralbum)) { // it is an image request $rimage = basename($ralbum); $ralbum = trim(dirname($ralbum), '/'); $path = internalToFilesystem(getAlbumFolder(SERVERPATH) . $ralbum); } } if (!is_dir($path)) { if ($suffix = isHandledAlbum($path)) { // it is a dynamic album sans suffix $ralbum .= '.' . $suffix; } } } if (empty($ralbum)) { unset($_GET[$albumvar]); } else { $_GET[$albumvar] = $ralbum; } if (empty($rimage)) { unset($_GET[$imagevar]); } else { $_GET[$imagevar] = $rimage; } } return array($ralbum, $rimage); }