Balise PHP

Fermé
enams90 Messages postés 16 Date d'inscription mardi 3 juin 2008 Statut Membre Dernière intervention 5 décembre 2016 - 7 juin 2008 à 15:46
gluo Messages postés 233 Date d'inscription mardi 28 août 2007 Statut Membre Dernière intervention 13 janvier 2010 - 7 juin 2008 à 16:47
Bonjour,
J'ai un problème avec mes plugins. Lorsque je fais la page Plugins et la page Option Plugins, on m'affiche des erreurs dans la valeur foreach qui introduit les tableaux des plugins. J'ai joins deux captures d'écran et le fichier admin php pour ceux qui veulent m'aider.
http://ed2k.paradise.free.fr/admin.zip
Merci de m'aider.
A voir également:

3 réponses

gluo Messages postés 233 Date d'inscription mardi 28 août 2007 Statut Membre Dernière intervention 13 janvier 2010 105
7 juin 2008 à 16:15
Tu aurais pu nous dire qu'il s'agissais de zenphoto, on pouvais pas deviner.
0
enams90 Messages postés 16 Date d'inscription mardi 3 juin 2008 Statut Membre Dernière intervention 5 décembre 2016
7 juin 2008 à 16:26
Je vais mettre le code pour ceux qui soupçonne un virus dans le fichier. Mais il sera po complet puisqu'il il est trop lent. Merci de bien vouloir téléchargé le fichier en hau.
0
gluo Messages postés 233 Date d'inscription mardi 28 août 2007 Statut Membre Dernière intervention 13 janvier 2010 105
7 juin 2008 à 16:47
Je sais pas trop pourquoi tu as cette erreur, le code est long et c'est impossible de s'y retrouver.
Tente de leur soumettre le problème içi : https://forum.zenphoto.org/
0
enams90 Messages postés 16 Date d'inscription mardi 3 juin 2008 Statut Membre Dernière intervention 5 décembre 2016
7 juin 2008 à 16:28
DSl,sinon voila le code PHP.
DSL, ça s'agit de la galerie Zenphoto mais sinon ça change quoi.
 Pour ceux qui craignent que j'ai mis un virus dans le fichier, voila le code complet.
<code><?php  /* Don't put anything before this line! */
define('OFFSET_PATH', true);
require_once("sortable.php");
if (!$session_started) session_start();
$sortby = array(gettext('Filename') => 'Filename', gettext('Date') => 'Date', gettext('Title') => 'Title', gettext('ID') => 'ID' );
$standardOptions = array(	'gallery_title','website_title','website_url','time_offset',
 													'mod_rewrite','mod_rewrite_image_suffix',
 													'server_protocol','charset','image_quality',
 													'thumb_quality','image_size','image_use_longest_side',
 													'image_allow_upscale','thumb_size','thumb_crop',
 													'thumb_crop_width','thumb_crop_height','thumb_sharpen',
 													'albums_per_page','images_per_page','perform_watermark',
 													'watermark_image','watermark_scale', 'watermark_allow_upscale', 'current_theme', 'spam_filter',
 													'email_new_comments', 'perform_video_watermark', 'video_watermark_image',
 													'gallery_sorttype', 'gallery_sortdirection', 'feed_items', 'feed_imagesize', 'search_fields',
 													'gallery_password', 'gallery_hint', 'search_password', 'search_hint',
 													'allowed_tags', 'full_image_quality', 'persistent_archive',
 													'protect_full_image', 'album_session', 'watermark_h_offset', 'watermark_w_offset',
 													'Use_Captcha', 'locale', 'date_format', 'hotlink_protection', 'image_sortdirection',
													'admin_reset_date', 'comment_name_required', 'comment_email_required',
													'comment_web_required', 'full_image_download', 'zenphoto_release'
												 );
$charsets = array("ASMO-708" => "Arabic",
									"big5" => "Chinese Traditional",
									"CP1026" => "IBM EBCDIC (Turkish Latin-5)",
									"cp866" => "Cyrillic (DOS)",
									"CP870" => "IBM EBCDIC (Multilingual Latin-2)",
									"csISO2022JP" => "Japanese (JIS-Allow 1 byte Kana)",
									"DOS-720" => "Arabic (DOS)",
									"DOS-862" => "Hebrew (DOS)",
									"ebcdic-cp-us" => "IBM EBCDIC (US-Canada)",
									"EUC-CN" => "Chinese Simplified (EUC)",
									"euc-jp" => "Japanese (EUC)",
									"euc-kr" => "Korean (EUC)",
									"gb2312" => "Chinese Simplified (GB2312)",
									"hz-gb-2312" => "Chinese Simplified (HZ)",
									"IBM437" => "OEM United States",
									"ibm737" => "Greek (DOS)",
									"ibm775" => "Baltic (DOS)",
									"ibm850" => "Western European (DOS)",
									"ibm852" => "Central European (DOS)",
									"ibm857" => "Turkish (DOS)",
									"ibm861" => "Icelandic (DOS)",
									"ibm869" => "Greek, Modern (DOS)",
									"iso-2022-jp" => "Japanese (JIS)",
									"iso-2022-jp" => "Japanese (JIS-Allow 1 byte Kana - SO/SI)",
									"iso-2022-kr" => "Korean (ISO)",
									"iso-8859-1" => "Western European (ISO)",
									"iso-8859-15" => "Latin 9 (ISO)",
									"iso-8859-2" => "Central European (ISO)",
									"iso-8859-3" => "Latin 3 (ISO)",
									"iso-8859-4" => "Baltic (ISO)",
									"iso-8859-5" => "Cyrillic (ISO)",
									"iso-8859-6" => "Arabic (ISO)",
									"iso-8859-7" => "Greek (ISO)",
									"iso-8859-8" => "Hebrew (ISO-Visual)",
									"iso-8859-8-i" => "Hebrew (ISO-Logical)",
									"iso-8859-9" => "Turkish (ISO)",
									"Johab" => "Korean (Johab)",
									"koi8-r" => "Cyrillic (KOI8-R)",
									"koi8-u" => "Cyrillic (KOI8-U)",
									"ks_c_5601-1987" => "Korean",
									"macintosh" => "Western European (Mac)",
									"shift_jis" => "Japanese (Shift-JIS)",
									"unicode" => "Unicode",                  
									"unicodeFFFE" => "Unicode (Big-Endian)",
									"us-ascii" => "US-ASCII",
									"utf-7" => "Unicode (UTF-7)",
									"utf-8" => "Unicode (UTF-8)",
									"windows-1250" => "Central European (Windows)",
									"windows-1251" => "Cyrillic (Windows)",
									"Windows-1252" => "Western European (Windows)",
									"windows-1253" => "Greek (Windows)",
									"windows-1254" => "Turkish (Windows)",
									"windows-1255" => "Hebrew (Windows)",
									"windows-1256" => "Arabic (Windows)",
									"windows-1257" => "Baltic (Windows)",                  
									"windows-1258" => "Vietnamese (Windows)",
									"windows-874" => "Thai (Windows)",
									"x-Chinese-CNS" => "Chinese Traditional (CNS)",
									"x-Chinese-Eten" => "Chinese Traditional (Eten)",
									"x-EBCDIC-Arabic" => "IBM EBCDIC (Arabic)",
									"x-ebcdic-cp-us-euro" => "IBM EBCDIC (US-Canada-Euro)",
									"x-EBCDIC-CyrillicRussian" => "IBM EBCDIC (Cyrillic Russian)",
									"x-EBCDIC-CyrillicSerbianBulgarian" => "IBM EBCDIC (Cyrillic Serbian-Bulgarian)",
									"x-EBCDIC-DenmarkNorway" => "IBM EBCDIC (Denmark-Norway)",
									"x-ebcdic-denmarknorway-euro" => "IBM EBCDIC (Denmark-Norway-Euro)",
									"x-EBCDIC-FinlandSweden" => "IBM EBCDIC (Finland-Sweden)",
									"x-ebcdic-finlandsweden-euro" => "IBM EBCDIC (Finland-Sweden-Euro)",
									"x-ebcdic-finlandsweden-euro" => "IBM EBCDIC (Finland-Sweden-Euro)",
									"x-ebcdic-france-euro" => "IBM EBCDIC (France-Euro)",
									"x-EBCDIC-Germany" => "IBM EBCDIC (Germany)",
									"x-ebcdic-germany-euro" => "IBM EBCDIC (Germany-Euro)",
									"x-EBCDIC-Greek" => "IBM EBCDIC (Greek)",
									"x-EBCDIC-GreekModern" => "IBM EBCDIC (Greek Modern)",
									"x-EBCDIC-Hebrew" => "IBM EBCDIC (Hebrew)",
									"x-EBCDIC-Icelandic" => "IBM EBCDIC (Icelandic)",
									"x-ebcdic-icelandic-euro" => "IBM EBCDIC (Icelandic-Euro)",
									"x-ebcdic-international-euro" => "IBM EBCDIC (International-Euro)",
									"x-EBCDIC-Italy" => "IBM EBCDIC (Italy)",
									"x-ebcdic-italy-euro" => "IBM EBCDIC (Italy-Euro)",
									"x-EBCDIC-JapaneseAndJapaneseLatin" => "IBM EBCDIC (Japanese and Japanese-Latin)",
									"x-EBCDIC-JapaneseAndKana" => "IBM EBCDIC (Japanese and Japanese Katakana)",
									"x-EBCDIC-JapaneseAndUSCanada" => "IBM EBCDIC (Japanese and US-Canada)",                  
									"x-EBCDIC-JapaneseKatakana" => "IBM EBCDIC (Japanese katakana)",
									"x-EBCDIC-KoreanAndKoreanExtended" => "IBM EBCDIC (Korean and Korean Extended)",
									"x-EBCDIC-KoreanExtended" => "IBM EBCDIC (Korean Extended)",
									"x-EBCDIC-SimplifiedChinese" => "IBM EBCDIC (Simplified Chinese)",
									"X-EBCDIC-Spain" => "IBM EBCDIC (Spain)",
									"x-ebcdic-spain-euro" => "IBM EBCDIC (Spain-Euro)",
									"x-EBCDIC-Thai" => "IBM EBCDIC (Thai)",
									"x-EBCDIC-TraditionalChinese" => "IBM EBCDIC (Traditional Chinese)",
									"x-EBCDIC-Turkish" => "IBM EBCDIC (Turkish)",
									"x-EBCDIC-UK" => "IBM EBCDIC (UK)",
									"x-ebcdic-uk-euro" => "IBM EBCDIC (UK-Euro)",
									"x-Europa" => "Europa",
									"x-IA5" => "Western European (IA5)",
									"x-IA5-German" => "German (IA5)",
									"x-IA5-Norwegian" => "Norwegian (IA5)",
									"x-IA5-Swedish" => "Swedish (IA5)",
									"x-iscii-as" => "ISCII Assamese",
									"x-iscii-be" => "ISCII Bengali",
									"x-iscii-de" => "ISCII Devanagari",
									"x-iscii-gu" => "ISCII Gujarathi",
									"x-iscii-ka" => "ISCII Kannada",
									"x-iscii-ma" => "ISCII Malayalam",
									"x-iscii-or" => "ISCII Oriya",
									"x-iscii-pa" => "ISCII Panjabi",
									"x-iscii-ta" => "ISCII Tamil",
									"x-iscii-te" => "ISCII Telugu",
									"x-mac-arabic" => "Arabic (Mac)",
									"x-mac-ce" => "Central European (Mac)",
									"x-mac-chinesesimp" => "Chinese Simplified (Mac)",
									"x-mac-chinesetrad" => "Chinese Traditional (Mac)",
									"x-mac-cyrillic" => "Cyrillic (Mac)",
									"x-mac-greek" => "Greek (Mac)",
									"x-mac-hebrew" => "Hebrew (Mac)",
									"x-mac-icelandic" => "Icelandic (Mac)",
									"x-mac-japanese" => "Japanese (Mac)",
									"x-mac-korean" => "Korean (Mac)",
									"x-mac-turkish" => "Turkish (Mac)"
									);
if (zp_loggedin()) { /* Display the admin pages. Do action handling first. */
	
	//check for security incursions
	if (isset($_GET['album'])) {
		if (!($_zp_loggedin & ADMIN_RIGHTS)) {
			if (!isMyAlbum(urldecode(strip($_GET['album'])), $_zp_loggedin)) {
				unset($_GET['album']);
				unset($_GET['page']);
				$page = 'home';
			}
		}
	}
	

	$gallery = new Gallery();
	if (isset($_GET['prune'])) {
		if ($_GET['prune'] != 'done') {
			if ($gallery->garbageCollect(true, true)) {
				$param = '?prune=continue';
			} else {
				$param = '?prune=done';
			}
			header("Location: " . FULLWEBPATH . "/" . ZENFOLDER . "/admin.php" . $param);
		}
	} else {
		$gallery->garbageCollect();
	}

	if (isset($_GET['action'])) {
		$action = $_GET['action'];

		/** clear the cache ***********************************************************/
		/******************************************************************************/
		if ($action == "clear_cache") {
			$gallery->clearCache();
		}

		/** Publish album  ************************************************************/
		/******************************************************************************/
		if ($action == "publish") {
			$folder = urldecode(strip($_GET['album']));
			$album = new Album($gallery, $folder);
			$album->setShow($_GET['value']);
			$album->save();
			header('Location: ' . FULLWEBPATH . '/' . ZENFOLDER . '/admin.php?page=edit');
			exit();

			/** un-moderate comment *********************************************************/
			/********************************************************************************/
		} else if ($action == "moderation") {
			$sql = 'UPDATE ' . prefix('comments') . ' SET `inmoderation`=0 WHERE `id`=' . $_GET['id'] . ';';
			query($sql);
			header('Location: ' . FULLWEBPATH . '/' . ZENFOLDER . '/admin.php?page=comments');
			exit();

			/** Reset hitcounters ***********************************************************/
			/********************************************************************************/
		} else if ($action == "reset_hitcounters") {
			if (isset($_GET['albumid'])) $id = $_GET['albumid'];
			if (isset($_POST['albumid'])) $id = $_POST['albumid'];
			if(isset($id)) {
				$where = ' WHERE `id`='.$id;
				$imgwhere = ' WHERE `albumid`='.$id;
				$return = '?page=edit';
				if (isset($_GET['return'])) $rt = $_GET['return'];
				if (isset($_POST['return'])) $rt = $_POST['return'];
				if (isset($rt)) {
					$return .= '&album=' . $rt .'&counters_reset';
				}
			} else {
				$where = '';
				$imgwhere = '';
				$return = '?counters_reset';
			}
			query("UPDATE " . prefix('albums') . " SET `hitcounter`= 0" . $where);
			query("UPDATE " . prefix('images') . " SET `hitcounter`= 0" . $imgwhere);
			header('Location: ' . FULLWEBPATH . '/' . ZENFOLDER . '/admin.php' . $return);
			exit();

			/** SAVE **********************************************************************/
			/******************************************************************************/
		} else if ($action == "save") {

			/** SAVE A SINGLE ALBUM *******************************************************/
			if ($_POST['album']) {

				$folder = urldecode(strip($_POST['album']));
				$album = new Album($gallery, $folder);
				$notify = '';
				if (isset($_POST['savealbuminfo'])) {
					$notify = processAlbumEdit(0, $album);
				}

				if (isset($_POST['totalimages'])) {
					for ($i = 0; $i < $_POST['totalimages']; $i++) {
						$filename = strip($_POST["$i-filename"]);

						// The file might no longer exist
						$image = new Image($album, $filename);
						if ($image->exists) {
							$image->setTitle(strip($_POST["$i-title"]));
							$image->setDesc(strip($_POST["$i-desc"]));
							$image->setLocation(strip($_POST["$i-location"]));
							$image->setCity(strip($_POST["$i-city"]));
							$image->setState(strip($_POST["$i-state"]));
							$image->setCountry(strip($_POST["$i-country"]));
							$image->setCredit(strip($_POST["$i-credit"]));
							$image->setCopyright(strip($_POST["$i-copyright"]));

							$tagsprefix = 'tags_'.$i.'-';
							$tags = array();
							for ($j=0; $j<4; $j++) {
								$tag = trim(strip($_POST[$tagsprefix.'new_tag_value_'.$j]));
								unset($_POST[$tagsprefix.'new_tag_value_'.$j]);
								if (!empty($tag)) {
									$tags[] = $tag;
								}
							}
							$l = strlen($tagsprefix);
							foreach ($_POST as $key => $value) {
								$key = postIndexDecode($key);
								if (substr($key, 0, $l) == $tagsprefix) {
									if ($value) {
										$tags[] = substr($key, $l);
									}
								}
							}
							$tags = array_unique($tags);
							$image->setTags($tags);


							$image->setDateTime(strip($_POST["$i-date"]));
							$image->setShow(strip($_POST["$i-Visible"]));
							$image->setCommentsAllowed(strip($_POST["$i-allowcomments"]));
							if (isset($_POST["$i-reset_hitcounter"])) {
								$id = $image->id;
								query("UPDATE " . prefix('images') . " SET `hitcounter`= 0 WHERE `id` = $id");
							}
							$image->setCustomData(strip($_POST["$i-custom_data"]));
							$image->save();
						}
					}
				}

				/** SAVE MULTIPLE ALBUMS ******************************************************/
			} else if ($_POST['totalalbums']) {
				for ($i = 1; $i <= $_POST['totalalbums']; $i++) {
					$folder = urldecode(strip($_POST["$i-folder"]));
					$album = new Album($gallery, $folder);
					$rslt = processAlbumEdit($i, $album);
					if (!empty($rslt)) { $notify = $rslt; }
				}
			}
			// Redirect to the same album we saved.
			$qs_albumsuffix = "&massedit";
			if ($_GET['album']) {
				$folder = urldecode(strip($_GET['album']));
				$qs_albumsuffix = '&album='.urlencode($folder);
			}
			header('Location: ' . FULLWEBPATH . '/' . ZENFOLDER . '/admin.php?page=edit' . $qs_albumsuffix . $notify . '&saved');
			exit();

			/** DELETION ******************************************************************/
			/*****************************************************************************/
		} else if ($action == "deletealbum") {
			$albumdir = "";
			if ($_GET['album']) {
				$folder = urldecode(strip($_GET['album']));
				$album = new Album($gallery, $folder);
				if ($album->deleteAlbum()) {
					$nd = 3;
				} else {
					$nd = 4;
				}
				$pieces = explode('/', $folder);
				if (($i = count($pieces)) > 1) {
					unset($pieces[$i-1]);
					$albumdir = "&album=" . urlencode(implode('/', $pieces));
				}
			}
			header("Location: " . FULLWEBPATH . "/" . ZENFOLDER . "/admin.php?page=edit" . $albumdir . "&ndeleted=" . $nd);
			exit();

		} else if ($action == "deleteimage") {
			if ($_GET['album'] && $_GET['image']) {
				$folder = urldecode(strip($_GET['album']));
				$file = urldecode(strip($_GET['image']));
				$album = new Album($gallery, $folder);
				$image = new Image($album, $file);
				if ($image->deleteImage(true)) {
					$nd = 1;
				} else {
					$nd = 2;
				}
			}
			header("Location: ". FULLWEBPATH . "/" . ZENFOLDER . "/admin.php?page=edit&album=" . urlencode($folder) . "&ndeleted=" . $nd);
			exit();

			/** UPLOAD IMAGES *************************************************************/
			/*****************************************************************************/
		} else if ($action == "upload") {

			// Check for files.
			$files_empty = true;
			if (isset($_FILES['files']))
			foreach($_FILES['files']['name'] as $name) { if (!empty($name)) $files_empty = false; }

			// Make sure the folder exists. If not, create it.
			if (isset($_POST['processed'])
			&& !empty($_POST['folder'])
			&& !$files_empty) {

				$folder = strip($_POST['folder']);
				$uploaddir = $gallery->albumdir . $folder;
				if (!is_dir($uploaddir)) {
					mkdir ($uploaddir, CHMOD_VALUE);
				}
				@chmod($uploaddir, CHMOD_VALUE);

				$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];
						$name = seoFriendlyURL($name);
						if (is_valid_image($name)) {
							$uploadfile = $uploaddir . '/' . $name;
							move_uploaded_file($tmp_name, $uploadfile);
							@chmod($uploadfile, 0666 & CHMOD_VALUE);
						} else if (is_zip($name)) {
							unzip($tmp_name, $uploaddir);
						}
					}
				}

				$album = new Album($gallery, $folder);
				if ($album->exists) {
					if (!isset($_POST['publishalbum'])) {
						$album->setShow(false);
					}
					$title = strip($_POST['albumtitle']);
					if (!(false === ($pos = strpos($title, ' (')))) {
						$title = substr($title, 0, $pos);
					}
					if (!empty($title)  && isset($_POST['newalbum'])) {
						$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 ."
, "
. gettext("or use your FTP program to give everyone write permissions to those folders."));
}

header("Location: " . FULLWEBPATH . "/" . ZENFOLDER . "/admin.php?page=edit&album=" . urlencode($folder));
exit();

} else {
// Handle the error and return to the upload page.
$page = "upload";
$error = true;
if ($files_empty) {
$errormsg = gettext("You must upload at least one file.");
} else if (empty($_POST['folder'])) {
$errormsg = gettext("You must enter a folder name for your new album.");
} else if (empty($_POST['processed'])) {
$errormsg = gettext("You've most likely exceeded the upload limits. Try uploading fewer files at a time, or use a ZIP file.");

} else {
$errormsg = gettext("There was an error submitting the form. Please try again. If this keeps happening, check your server and PHP configuration (make sure file uploads are enabled, and upload_max_filesize is set high enough)")
. gettext("If you think this is a bug, file a bug report. Thanks!");
}
}

/** COMMENTS ******************************************************************/
/*****************************************************************************/

} else if ($action == 'deletecomments') {

if (isset($_POST['ids']) || isset($_GET['id'])) {
if (isset($_GET['id'])) {
$ids = array($_GET['id']);
} else {
$ids = $_POST['ids'];
}
$total = count($ids);
if ($total > 0) {
$n = 0;
$sql = "DELETE FROM ".prefix('comments')." WHERE ";
foreach ($ids as $id) {
$n++;
$sql .= "id='$id' ";
if ($n < $total) $sql .= "OR ";
}
query($sql);
}
header("Location: " . FULLWEBPATH . "/" . ZENFOLDER . "/admin.php?page=comments&ndeleted=$n");
exit();
} else {
header("Location: " . FULLWEBPATH . "/" . ZENFOLDER . "/admin.php?page=comments&ndeleted=0");
exit();
}

} else if ($action == 'savecomment') {
if (!isset($_POST['id'])) {
header("Location: " . FULLWEBPATH . "/" . ZENFOLDER . "/admin.php?page=comments");
exit();
}
$id = $_POST['id'];
$name = escape($_POST['name']);
$email = escape($_POST['email']);
$website = escape($_POST['website']);
$date = escape($_POST['date']);
$comment = escape($_POST['comment']);

// TODO: Update date as well; no good input yet, so leaving out.
$sql = "UPDATE ".prefix('comments')." SET `name` = '$name', `email` = '$email', `website` = '$website', `comment` = '$comment' WHERE id = $id";
query($sql);

header("Location: " . FULLWEBPATH . "/" . ZENFOLDER . "/admin.php?page=comments&sedit");
exit();

/** OPTIONS ******************************************************************/
/*****************************************************************************/

} else if ($action == 'deleteadmin') {
$id = $_GET['adminuser'];
$sql = "DELETE FROM ".prefix('administrators')." WHERE `id`=$id";
query($sql);
$sql = "DELETE FROM ".prefix('admintoalbum')." WHERE `adminid`=$id";
query($sql);
header("Location: " . FULLWEBPATH . "/" . ZENFOLDER . "/admin.php?page=options&deleted");
exit();
} else if ($action == 'saveoptions') {
$table = 'options';
$wm = getOption('watermark_image');
$vwm = getOption('video_watermark_image');
$wmo = getOption('perform_watermark');
$vwmo = getOption('perform_video_watermark');
$woh = getOption('watermark_h_offset');
$wow = getOption('watermark_w_offset');
$ws = getOption('watermark_scale');
$wus = getOption('watermark_allow_upscale');
$notify = '';
$returntab = "";

/*** admin options ***/
if (isset($_POST['saveadminoptions'])) {
for ($i = 0; $i < $_POST['totaladmins']; $i++) {
$pass = trim($_POST[$i.'-adminpass']);
$user = trim($_POST[$i.'-adminuser']);
if (!empty($user)) {
if ($pass == trim($_POST[$i.'-adminpass_2'])) {
$admin_n = trim($_POST[$i.'-admin_name']);
$admin_e = trim($_POST[$i.'-admin_email']);
$admin_r = $_POST[$i.'-admin_rights'];
$comment_r = $_POST[$i.'-comment_rights'];
$upload_r = $_POST[$i.'-upload_rights'];
$edit_r = $_POST[$i.'-edit_rights'];
$options_r = $_POST[$i.'-options_rights'];
$themes_r = $_POST[$i.'-themes_rights'];
if (!isset($_POST['alter_enabled'])) {
$rights = MAIN_RIGHTS + $admin_r + $comment_r + $upload_r + $edit_r + $options_r + $themes_r;

$managedalbums = array();

$l = strlen($albumsprefix = 'managed_albums_'.$i.'_');
foreach ($_POST as $key => $value) {
$key = postIndexDecode($key);
if (substr($key, 0, $l) == $albumsprefix) {
if ($value) {
$managedalbums[] = substr($key, $l);
}
}
}
if (count($$managedalbums > 0)) {
$albums = array_unique($managedalbums);
} else {
$albums = NULL;
}
} else {
$rights = null;
$albums = NULL;
}
if (empty($pass)) {
$pwd = null;
} else {
$pwd = md5($_POST[$i.'-adminuser'] . $pass);
}
saveAdmin($user, $pwd, $admin_n, $admin_e, $rights, $albums);
} else {
$notify = '&mismatch=password';
}
}
}
setOption('admin_reset_date', '1');
$returntab = "#tab_admin";
}

/*** Gallery options ***/
if (isset($_POST['savegalleryoptions'])) {
setOption('gallery_title', $_POST['gallery_title']);
setOption('website_title', $_POST['website_title']);
$web = $_POST['website_url'];
setOption('website_url', $web);
setOption('time_offset', $_POST['time_offset']);
setOption('gmaps_apikey', $_POST['gmaps_apikey']);
setBoolOption('mod_rewrite', $_POST['mod_rewrite']);
setOption('mod_rewrite_image_suffix', $_POST['mod_rewrite_image_suffix']);
setOption('server_protocol', $_POST['server_protocol']);
setOption('charset', $_POST['charset']);
setOption('gallery_sorttype', $_POST['gallery_sorttype']);
if ($_POST['gallery_sorttype'] == 'Manual') {
setBoolOption('gallery_sortdirection', 0);
} else {
setBoolOption('gallery_sortdirection', $_POST['gallery_sortdirection']);
}
setOption('feed_items', $_POST['feed_items']);
setOption('feed_imagesize', $_POST['feed_imagesize']);
$search = new SearchEngine();
setOption('search_fields', 32767, false); // make SearchEngine allow all options so parseQueryFields() will gives back what was choosen this time
setOption('search_fields', $search->parseQueryFields());
if ($_POST['gallerypass'] == $_POST['gallerypass_2']) {
$pwd = trim($_POST['gallerypass']);
if (empty($pwd)) {
if (empty($_POST['gallerypass'])) {
setOption('gallery_password', NULL); // clear the gallery password
}
} else {
setOption('gallery_password', md5($pwd));
}
} else {
$notify = '&mismatch=gallery';
}
if ($_POST['searchpass'] == $_POST['searchpass_2']) {
$pwd = trim($_POST['searchpass']);
if (empty($pwd)) {
if (empty($_POST['searchpass'])) {
setOption('search_password', NULL); // clear the gallery password
}
} else {
setOption('search_password', md5($pwd));
}
} else {
$notify = '&mismatch=search';
}
setOption('gallery_hint', $_POST['gallery_hint']);
setOption('search_hint', $_POST['search_hint']);
setBoolOption('persistent_archive', $_POST['persistent_archive']);
setBoolOption('album_session', $_POST['album_session']);
setOption('locale', $_POST['locale']);
$f = $_POST['date_format_list'];
if ($f == 'custom') $f = $_POST['date_format'];
setOption('date_format', $f);
$returntab = "#tab_gallery";
}

/*** Image options ***/
if (isset($_POST['saveimageoptions'])) {
setOption('image_quality', $_POST['image_quality']);
setOption('thumb_quality', $_POST['thumb_quality']);
setBoolOption('image_allow_upscale', $_POST['image_allow_upscale']);
setBoolOption('thumb_sharpen', $_POST['thumb_sharpen']);
setBoolOption('perform_watermark', $_POST['perform_watermark']);
setOption('watermark_image', 'watermarks/' . $_POST['watermark_image'] . '.png');
setOption('watermark_scale', $_POST['watermark_scale']);
setBoolOption('watermark_allow_upscale', $_POST['watermark_allow_upscale']);
setOption('watermark_h_offset', $_POST['watermark_h_offset']);
setOption('watermark_w_offset', $_POST['watermark_w_offset']);
setBoolOption('perform_video_watermark', $_POST['perform_video_watermark']);
setOption('video_watermark_image', 'watermarks/' . $_POST['video_watermark_image'] . '.png');
setOption('full_image_quality', $_POST['full_image_quality']);
setOption('protect_full_image', $_POST['protect_full_image']);
setBoolOption('hotlink_protection', $_POST['hotlink_protection']);
setOption('image_sorttype', $_POST['image_sorttype']);
setBoolOption('image_sortdirection', $_POST['image_sortdirection']);
$returntab = "#tab_image";
}
/*** Comment options ***/
if (isset($_POST['savecommentoptions'])) {
setOption('spam_filter', $_POST['spam_filter']);
setBoolOption('email_new_comments', $_POST['email_new_comments']);
$tags = $_POST['allowed_tags'];
$test = "(".$tags.")";
$a = parseAllowedTags($test);
if ($a !== false) {
setOption('allowed_tags', $tags);
$notify = '';
} else {
$notify = '&tag_parse_error';
}
setBoolOption('comment_name_required', $_POST['comment_name_required']);
setBoolOption('comment_email_required', $_POST['comment_email_required']);
setBoolOption('comment_web_required', $_POST['comment_web_required']);
setBoolOption('Use_Captcha', $_POST['Use_Captcha']);
$returntab = "#tab_comments";

}
/*** Theme options ***/
if (isset($_POST['savethemeoptions'])) {
$returntab = "#tab_theme";
// all theme specific options are custom options, handled below
if (!empty($_POST['themealbum'])) {
$alb = urldecode($_POST['themealbum']);
$table = $alb.'_options';
$returntab = '&themealbum='.urlencode($alb).'#tab_theme';
} else {
$table = 'options';
}
setThemeOption($table, 'image_size', $_POST['image_size']);
setBoolThemeOption($table, 'image_use_longest_side', $_POST['image_use_longest_side']);
setThemeOption($table, 'thumb_size', $_POST['thumb_size']);
setBoolThemeOption($table, 'thumb_crop', $_POST['thumb_crop']);
setThemeOption($table, 'thumb_crop_width', $_POST['thumb_crop_width']);
setThemeOption($table, 'thumb_crop_height', $_POST['thumb_crop_height']);
setThemeOption($table, 'albums_per_page', $_POST['albums_per_page']);
setThemeOption($table, 'images_per_page', $_POST['images_per_page']);
}
/*** Plugin Options ***/
if (isset($_POST['savepluginoptions'])) {
// all plugin options are handled by the custom option code.
$returntab = "#tab_plugin";
}
/*** custom options ***/
$templateOptions = GetOptionList();

foreach($standardOptions as $option) {
unset($templateOptions[$option]);
}
unset($templateOptions['saveoptions']);
$keys = array_keys($templateOptions);
$i = 0;
while ($i < count($keys)) {
if (isset($_POST[$keys[$i]])) {
setThemeOption($table, $keys[$i], $_POST[$keys[$i]]);
} else {
if (isset($_POST['chkbox-' . $keys[$i]])) {
setThemeOption($table, $keys[$i], 0);
}
}
$i++;
}

if (($wmo != getOption('perform_watermark')) ||
($vwmo != getOption('perform_video_watermark')) ||
($woh != getOption('watermark_h_offset')) ||
($wow != getOption('watermark_w_offset')) ||
($wm != getOption('watermark_image')) ||
($ws != getOption('watermark_scale')) ||
($wus != getOption('watermark_allow_upscale')) ||
($vwm != getOption('video_watermark_image'))) {
$gallery->clearCache(); // watermarks (or lack there of) are cached, need to start fresh if the options haave changed
}
if (empty($notify)) $notify = '&saved';
header("Location: " . FULLWEBPATH . "/" . ZENFOLDER . "/admin.php?page=options".$notify.$returntab);
exit();

/** THEMES ******************************************************************/
/*****************************************************************************/
} else if ($action == 'settheme') {
if (isset($_GET['theme'])) {
$alb = urldecode($_GET['themealbum']);
$newtheme = strip($_GET['theme']);
if (empty($alb)) {
$gallery->setCurrentTheme($newtheme);
} else {
$album = new Album($gallery, $alb);
$oldtheme = $album->getAlbumTheme();
$tbl_options = prefix($album->name.'_options');
if (!empty($oldtheme) && empty($newtheme)) {
// clean out old theme option table
$sql = "DROP TABLE $tbl_options";
query($sql);
$album->setAlbumTheme($newtheme);
$album->save();
}
if (!empty($newtheme)) {
$sql = "CREATE TABLE IF NOT EXISTS $tbl_options (
`id` int(11) unsigned NOT NULL auto_increment,
`name` varchar(64) NOT NULL,
`value` text NOT NULL,
PRIMARY KEY (`id`),
UNIQUE (`name`)
);";
query($sql);
$album->setAlbumTheme($newtheme);
$album->save();
}
}
header("Location: " . FULLWEBPATH . "/" . ZENFOLDER . "/admin.php?page=themes&themealbum=".$_GET['themealbum']);
}

/** PLUGINS ******************************************************************/
/*****************************************************************************/
} else if ($action == 'saveplugins') {


$curdir = getcwd();
chdir(SERVERPATH . "/" . ZENFOLDER . PLUGIN_FOLDER);
$filelist = safe_glob('*'.'php');
chdir($curdir);
foreach ($filelist as $extension) {
$opt = 'zp_plugin_'.substr($extension, 0, strlen($extension)-4);
setBoolOption($opt, $_POST[$opt]);
}
header("Location: " . FULLWEBPATH . "/" . ZENFOLDER . "/admin.php?page=plugins&saved");
}
}

// Redirect to a page if it's set
// (NOTE: Form POST data will be resent on refresh. Use header(Location...) instead, unless there's an error message.
if (isset($_GET['page'])) { $page = $_GET['page']; } else if (empty($page)) { $page = "home"; }

}

/* NO Admin-only content between this and the next check. */

/************************************************************************************/
/** End Action Handling *************************************************************/
/************************************************************************************/

if (issetPage('edit')) {
zenSortablesPostHandler('albumOrder', 'albumList', 'albums');
}

// Print our header
printAdminHeader();

if (issetPage('edit')) {
zenSortablesHeader('albumList','albumOrder','div', "handle:'handle'");
}
echo "\n</head>";
?>

<body>

<?php
// If they are not logged in, display the login form and exit

if (!zp_loggedin()) {
printLoginForm();
exit();

} else { /* Admin-only content safe from here on. */
printLogoAndLinks();
?>
<div id="main"><?php printTabs(); ?>
<div id="content"><?php
if ($_zp_null_account = ($_zp_loggedin == ADMIN_RIGHTS)) {
$page = 'options';
echo "<div class=\"errorbox space\">";
echo "<h2>".gettext("Password reset request.<br/>You may now set admin usernames and passwords.")."</h2>";
echo "</div>";
}
switch ($page) {
case 'comments':
if (!($_zp_loggedin & COMMENT_RIGHTS)) $page = '';
break;
case 'upload':
if (!($_zp_loggedin & UPLOAD_RIGHTS)) $page = '';
break;
case 'edit':
if (!($_zp_loggedin & EDIT_RIGHTS)) $page = '';
break;
case 'themes':
if (!($_zp_loggedin & THEMES_RIGHTS)) $page = '';
break;
case 'plugins':
if (!($_zp_loggedin & ADMIN_RIGHTS)) $page = '';
break;
}
/** EDIT ****************************************************************************/
/************************************************************************************/

if ($page == "edit") {

/** SINGLE ALBUM ********************************************************************/
if (isset($_GET['album']) && !isset($_GET['massedit'])) {
$folder = strip($_GET['album']);
$album = new Album($gallery, $folder);
$images = $album->getImages();
$totalimages = sizeof($images);
// TODO: Perhaps we can build this from the meta array of Album? Moreover, they should be a set of constants!
$albumdir = "";
$pieces = explode('/', $folder);
if (($i = count($pieces)) > 1) {
unset($pieces[$i-1]);
$albumdir = "&album=" . urlencode(implode('/', $pieces));
}
if (isset($_GET['subalbumsaved'])) {
$album->setSubalbumSortType('Manual');
$album->setSortDirection('album', 0);
$album->save();
echo '<div class="messagebox" id="fade-message">';
echo "<h2>".gettext("Subalbum order saved")."</h2>";
echo '</div>';
}
?>
<h1>Edit Album: <em><?php echo $album->name; ?></em></h1>
<p><?php printAdminLinks(gettext("edit") . $albumdir, "« ".gettext("Back"), gettext("Back to the list of albums (go up one level)"));?>
| <?php printSortLink($album, gettext("Sort Album"), gettext("Sort Album")); ?> | <?php printViewLink($album, gettext("View Album"), gettext("View Album")); ?>
</p>

<?php displayDeleted(); /* Display a message if needed. Fade out and hide after 2 seconds. */ ?>
<?php
if (isset($_GET['saved'])) {
if (isset($_GET['mismatch'])) {
?>
<div class="errorbox" id="fade-message">
<h2><?php echo gettext("Your passwords did not match"); ?></h2>
</div>
<?php
} else {
?>
<div class="messagebox" id="fade-message">
<h2><?php echo gettext("Save Successful"); ?></h2>
</div>
<?php
}
?>
<?php
}
?>
<!-- Album info box -->

<form name="albumedit1"
action="?page=edit&action=save<?php echo "&album=" . urlencode($album->name); ?>"
method="post"><input type="hidden" name="album"
value="<?php echo $album->name; ?>" /> <input type="hidden"
name="savealbuminfo" value="1" /> <?php printAlbumEditForm(0, $album); ?>
</form>
<?php printAlbumButtons($album) ?> <?php if (!$album->isDynamic()) {?>
<!-- Subalbum list goes here --> <a name="subalbumList"> <?php

$subalbums = $album->getSubAlbums();
if (count($subalbums) > 0) {
if ($album->getNumImages() > 0) { ?>
<p>

</a><a href="#imageList" title="<?php echo gettext('Scroll down to the image list.'); ?>">
<?php echo gettext("Image List"); ?> »</a>

<?php } ?>

<table class="bordered" width="100%">
<input type="hidden" name="subalbumsortby" value="Manual" />
<tr>
<th colspan="8">
<h1><?php echo gettext("Albums"); ?></h1>
</th>
</tr>
<tr>
<td colspan="8"><?php echo gettext("Drag the albums into the order you wish them displayed. Select an album to edit its description and data, or"); ?>
<a href="?page=edit&album=<?php echo urlencode($album->name)?>&massedit"><?php echo gettext("mass-edit all album data"); ?></a>.</td>
</tr>
<tr>
<td style="padding: 0px 0px;" colspan="8">
<div id="albumList" class="albumList"><?php
foreach ($subalbums as $folder) {
$subalbum = new Album($album, $folder);
printAlbumEditRow($subalbum);
}
?></div>

</tr>
<tr>
<td colspan="8">
<p align="right"><img src="images/lock.png" style="border: 0px;"
alt="Protected" /><?php echo gettext("Has Password"); ?>  <img src="images/pass.png"
style="border: 0px;" alt="Published" /><?php echo gettext("Published"); ?>  <img
src="images/action.png" style="border: 0px;" alt="Unpublished" /><?php echo gettext("Unpublished"); ?> 
<img src="images/cache.png" style="border: 0px;" alt="Cache the album" /><?php echo gettext("Cache the album"); ?>  <img src="images/warn.png" style="border: 0px;"
alt="Refresh image metadata" /><?php echo gettext("Refresh image metadata"); ?>  <img
src="images/reset.png" style="border: 0px;" alt="Reset hitcounters" /><?php echo gettext("Reset hitcounters"); ?>  <img src="images/fail.png" style="border: 0px;"
alt="Delete" />Delete</p>
<?php
zenSortablesSaveButton("?page=edit&album=" . urlencode($album->name) . "&subalbumsaved", gettext("Save Order"));
?></td>
</tr>
</table>

<?php
} ?>
<!-- Images List --> <a name="imageList"></a> <?php if (count($album->getSubalbums()) > 10) { ?>
<p><a href="#subalbumList" title="<?php gettext('Scroll up to the sub-album list'); ?>">«
<?php echo gettext("Subalbum List"); ?></a></p>
<?php }
if (count($album->getImages())) {
?>

<form name="albumedit2"
action="?page=edit&action=save<?php echo "&album=" . urlencode($album->name); ?>"
method="post"><input type="hidden" name="album"
value="<?php echo $album->name; ?>" /> <input type="hidden"
name="totalimages" value="<?php echo $totalimages; ?>" />

<table class="bordered">
<tr>
<th colspan="3">
<h1><?php echo gettext("Images"); ?></h1>
</th>
</tr>
<tr>
<td><input type="submit" value="save" /></td>
<td colspan="2"><?php echo gettext("Click the images for a larger version"); ?></td>
</tr>

<?php
$currentimage = 0;
foreach ($images as $filename) {
$image = new Image($album, $filename);
?>

<tr id=""
<?php echo ($currentimage % 2 == 0) ? "class=\"alt\"" : ""; ?>>
<td valign="top" width="100"><img id="thumb-<?php echo $currentimage; ?>"
src="<?php echo $image->getThumb();?>"
alt="<?php echo $image->filename;?>"
onclick="toggleBigImage('thumb-<?php echo $currentimage; ?>', '<?php echo $image->getSizedImage(getOption('image_size')); ?>');" />
</td>

<td >
<input type="hidden"
name="<?php echo $currentimage; ?>-filename"
value="<?php echo $image->filename; ?>" />
<table border="0" class="formlayout">
<tr>
<td align="right" valign="top" width="100">Title:</td>
<td><input type="text" size="56" style="width: 360px"
name="<?php echo $currentimage; ?>-title"
value="<?php echo $image->getTitle(); ?>" /></td>
</tr>
<?php
$id = $image->id;
$result = query_single_row("SELECT `hitcounter` FROM " . prefix('images') . " WHERE `id` = $id");
$hc = $result['hitcounter'];
if (empty($hc)) { $hc = '0'; }
echo "<td></td><td>". gettext("Hit counter:"). $hc . " <input type=\"checkbox\" name=\"".gettext("reset_hitcounter")."\"> ".gettext("Reset")."</td>";
?>
<tr>
<td align="right" valign="top"><?php echo gettext("Description:"); ?></td>
<td><textarea name="<?php echo $currentimage; ?>-desc" cols="60"
rows="4" style="width: 360px"><?php echo $image->getDesc(); ?></textarea></td>
</tr>
<tr>
<td align="right" valign="top"><?php echo gettext("Location:"); ?></td>
<td><input type="text" size="56" style="width: 360px"
name="<?php echo $currentimage; ?>-location"
value="<?php echo $image->getLocation(); ?>" /></td>
</tr>
<tr>
<td align="right" valign="top"><?php echo gettext("City:"); ?></td>
<td><input type="text" size="56" style="width: 360px"
name="<?php echo $currentimage; ?>-city"
value="<?php echo $image->getCity(); ?>" /></td>
</tr>
<tr>
<td align="right" valign="top"><?php echo gettext("State:"); ?></td>
<td><input type="text" size="56" style="width: 360px"
name="<?php echo $currentimage; ?>-state"
value="<?php echo $image->getState(); ?>" /></td>
</tr>
<tr>
<td align="right" valign="top"><?php echo gettext("Country:"); ?></td>
<td><input type="text" size="56" style="width: 360px"
name="<?php echo $currentimage; ?>-country"
value="<?php echo $image->getCountry(); ?>" /></td>
</tr>
<tr>
<td align="right" valign="top"><?php echo gettext("Credit:"); ?></td>
<td><input type="text" size="56" style="width: 360px"
name="<?php echo $currentimage; ?>-credit"
value="<?php echo $image->getCredit(); ?>" /></td>
</tr>
<tr>
<td align="right" valign="top"><?php echo gettext("Copyright:"); ?></td>
<td><input type="text" size="56" style="width: 360px"
name="<?php echo $currentimage; ?>-copyright"
value="<?php echo $image->getCopyright(); ?>" /></td>
</tr>
<tr>
<td align="right" valign="top"><?php echo gettext("Date:"); ?></td>
<td><input type="text" size="56" style="width: 360px"
name="<?php echo $currentimage; ?>-date"
value="<?php $d=$image->getDateTime(); if ($d!='0000-00-00 00:00:00') { echo $d; } ?>" /></td>
</tr>
<tr>
<td align="right" valign="top"><?php echo gettext("Custom data:"); ?></td>
<td><textarea rows="3" cols="60" style="width: 360px"
name="<?php echo $currentimage; ?>-custom_data"><?php echo trim($image->getCustomData()); ?></textarea></td>
</tr>
<tr>
<td align="right" valign="top" colspan="2"><label
for="<?php echo $currentimage; ?>-allowcomments"><input
type="checkbox" id="<?php echo $currentimage; ?>-allowcomments"
name="<?php echo $currentimage; ?>-allowcomments" value="1"
<?php if ($image->getCommentsAllowed()) { echo "checked=\"checked\""; } ?> />
<?php echo gettext("Allow Comments"); ?></label>     <label
for="<?php echo $currentimage; ?>-Visible"><input type="checkbox"
id="<?php echo $currentimage; ?>-Visible"
name="<?php echo $currentimage; ?>-Visible" value="1"
<?php if ($image->getShow()) { echo "checked=\"checked\""; } ?> />
<?php echo gettext("Visible"); ?></label></td>
</tr>
</table>
</td>

<td>
<table>
<tr>
<td style="padding-left: 1em;">
<a href="javascript: confirmDeleteImage('?page=edit&action=deleteimage&album=<?php echo urlencode($album->name); ?>&image=<?php echo urlencode($image->filename); ?>','<?php echo gettext("Are you sure you want to delete the image? THIS CANNOT BE UNDONE!"); ?>');"
title="<?php gettext('Delete the image'); ?> <?php echo xmlspecialchars($image->filename); ?>"> <img
src="images/fail.png" style="border: 0px;"
alt="<?php gettext('Delete the image'); ?> <?php echo xmlspecialchars($image->filename); ?>" /></a>
</td>
</tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr>
<td>
<?php
echo gettext("Tags:");
tagSelector($image, 'tags_'.$currentimage.'-')
?>
</td>
</tr>
</table>
</td>


</tr>

<?php
$currentimage++;
}
?>
<tr>
<td colspan="3"><input type="submit" value="<?php echo gettext('save'); ?>" /></td>
</tr>

</table>


</form>

<?php if (count($album->getSubalbums())) { ?>
<p><a href="#subalbumList" title="<?php gettext('Scroll up to the sub-album list'); ?>"> 
   ^ <?php echo gettext("Subalbum List"); ?></a></p>
<?php
}
}
}?> <!-- page trailer -->
<p><a href="?page=edit<?php echo $albumdir ?>"
title="<?php echo gettext('Back to the list of albums (go up one level)'); ?>">« <?php echo gettext("Back"); ?></a></p>


<?php

/*** MULTI-ALBUM ***************************************************************************/

} else if (isset($_GET['massedit'])) {
if (isset($_GET['saved'])) {
if (isset($_GET['mismatch'])) {
echo "\n<div class=\"errorbox\" id=\"fade-message\">";
echo "\n<h2>".gettext("Your passwords did not match")."</h2>";
echo "\n</div>";
} else {
echo "\n<div class=\"messagebox\" id=\"fade-message\">";
echo "\n<h2>".gettext("Save Successful")."</h2>";
echo "\n</div>";
}
}
$albumdir = "";
if (isset($_GET['album'])) {
$folder = strip($_GET['album']);
if (isMyAlbum($folder, EDIT_RIGHTS)) {
$album = new Album($gallery, $folder);
$albums = $album->getSubAlbums();
$pieces = explode('/', $folder);
if (($i = count($pieces)) > 1) {
unset($pieces[$i-1]);
$albumdir = "&album=" . urlencode(implode('/', $pieces));
} else {
$albumdir = "";
}
} else {
$albums = array();
}
} else {
$albumsprime = $gallery->getAlbums();
$albums = array();
foreach ($albumsprime as $album) { // check for rights
if (isMyAlbum($album, EDIT_RIGHTS)) {
$albums[] = $album;
}
}
}
?>
<h1><?php echo gettext("Edit All Albums in"); ?> <?php if (!isset($_GET['album'])) { echo gettext("Gallery");} else {echo "<em>" . $album->name . "</em>";}?></h1>
<p><a href="?page=edit<?php echo $albumdir ?>"
title="<?php gettext('Back to the list of albums (go up a level)'); ?>">« <?php echo gettext("Back"); ?></a></p>
<div class="box" style="padding: 15px;">

<form name="albumedit"
action="?page=edit&action=save<?php echo $albumdir ?>" method="POST"><input
type="hidden" name="totalalbums" value="<?php echo sizeof($albums); ?>" />
<?php
$currentalbum = 0;
foreach ($albums as $folder) {
$currentalbum++;
$album = new Album($gallery, $folder);
$images = $album->getImages();
echo "\n<!-- " . $album->name . " -->\n";
printAlbumEditForm($currentalbum, $album);
}
?></form>

</div>
<?php

/*** EDIT ALBUM SELECTION *********************************************************************/

} else { /* Display a list of albums to edit. */ ?>
<h1><?php echo gettext("Edit Gallery"); ?></h1>
<?php displayDeleted(); /* Display a message if needed. Fade out and hide after 2 seconds. */ ?>

<?php
if (isset($_GET['saved'])) {
setOption('gallery_sorttype', 'Manual');
setOption('gallery_sortdirection', 0);
echo '<div class="messagebox" id="fade-message">';
echo "<h2>".gettext("Album order saved")."</h2>";
echo '</div>';
}
?>
<p><?php if ($_zp_loggedin & ADMIN_RIGHTS) { ?><?php echo gettext('Drag the albums into the order you wish them displayed.') ?><?php } ?> <?php echo gettext('Select an album to edit its description and data, or'); ?><a href="?page=edit&massedit"> <?php echo gettext('mass-edit all album data'); ?></a>.</p>

<table class="bordered" width="100%">
<tr>
<th style="text-align: left;"><?php echo gettext("Edit this album"); ?></th>
</tr>
<tr>
<td style="padding: 0px 0px;" colspan="2">
<div id="albumList" class="albumList"><?php
$albumsprime = $gallery->getAlbums();
$albums = array();
foreach ($albumsprime as $album) { // check for rights
if (isMyAlbum($album, EDIT_RIGHTS)) {
$albums[] = $album;
}
}
if (is_array($albums)) {
foreach ($albums as $folder) {
$album = new Album($gallery, $folder);
printAlbumEditRow($album);
}
}
?></div>
</td>
</tr>
</table>
<div>
<p align="right"><img src="images/lock.png" style="border: 0px;"
alt="<?php gettext('Protected'); ?>" /><?php echo gettext("Has Password"); ?>  <img src="images/pass.png"
style="border: 0px;" alt="<?php gettext('Published'); ?>" /><?php echo gettext("Published"); ?>  <img
src="images/action.png" style="border: 0px;" alt="<?php gettext('Unpublished'); ?>" /><?php echo gettext("Unpublished"); ?> 
<img src="images/cache.png" style="border: 0px;" alt="<?php gettext('Cache the album'); ?>" /><?php echo gettext("Cache the album"); ?>  <img src="images/warn.png" style="border: 0px;"
alt="<?php gettext('Refresh image metadata'); ?>" /><?php echo gettext("Refresh image metadata"); ?>  <img
src="images/reset.png" style="border: 0px;" alt="<?php gettext('Reset hitcounters'); ?>" /><?php echo gettext("Reset hitcounters"); ?>  <img src="images/fail.png" style="border: 0px;"
alt="Delete" /><?php echo gettext("Delete"); ?></p>
<?php
if ($_zp_loggedin & ADMIN_RIGHTS) {
zenSortablesSaveButton("?page=edit&saved", gettext("Save Order"));
}
?></div>

<?php
}
/**** UPLOAD ************************************************************************/
/************************************************************************************/
} else if ($page == "upload") {
$albumlist = array();
genAlbumUploadList($albumlist);
?> <script type="text/javascript">
window.totalinputs = 5;
// Array of album names for javascript functions.
var albumArray = new Array (
<?php
$separator = '';
foreach($albumlist as $key => $value) {
echo $separator . "'" . addslashes($key) . "'";
$separator = ", ";
}
?> );
</script>

<h1><?php echo gettext("Upload Photos"); ?></h1>
<p><?php echo gettext("This web-based upload accepts image formats:"); ?>
0