Notice(s)
					
						
				';
				foreach ($_SESSION['statusMsg'] as $k => $v) {
					echo '- ' . $v . '';
				}
				echo '
 
				';
				
				// Reset the container for the next round.
				if (!isset($_GET['redirect'])) {
					$_SESSION['statusMsg'] = array();
				}
			}
			
			// Start processing of page content.
			if (!empty($_GET['file'])) {
				
				// Handle albums.
				if ($_GET['file'] == 'album') {
					
					// Set the current working directory.
					setCurrentDir(!empty($_GET['name']) ? $_GET['name'] : '');
					
					// Switch the requested action.
					if (!empty($_GET['action'])) {
						switch ($_GET['action']) {
						
						// Add an album.
						case 'add':
							addItem('album', $name = (!empty($_GET['name']) ? $_GET['name'] : ''));
							if (!empty($_POST['name'])) {
								echo '
									
								';
							}
							break;
							
						// Edit an album.
						case 'edit':
							if (!empty($_GET['name'])) {
								
								$name 		   = $_GET['name'];
								$renameSuccess = true;
								
								if (isset($_POST['saveConfiguration'])) {
									// Rename the album in the filesystem after 
									// the form was submitted.
									$renameSuccess = renameItem('album', $_POST['configData']['title']);
									
									if ($renameSuccess) {
										$name = convertStr($_POST['configData']['title'], false, true);
									}
									echo '
										
									';
								}
								
								// Get the config data for the current album.
								$albumConfig = getConfig($_SESSION['currentDir'] . 'imageData.xml');
								echo '
Album ' . ((isPhpOfVersion(5) == -1) ? utf8_encode($albumConfig['title']) : $albumConfig['title']) . '
';
								
								// Move an image as requested.
								moveImage();
								
								// Print the summary of all images within the 
								// current album.
								printSummary($name);
								addItem('image', $name);
								
								// Display the options.
								echo '
Options
';
								configure('album', $renameSuccess);
								deleteItem('album', $name);
								
							} else {
								$simpleViewer['error'] = true;
								$simpleViewer['errorMsg'] .= "No album name specified.\n";
							}
							break;
							
						// Delete an album.
						case 'delete':
							if (!empty($_GET['name'])) {
								deleteItem('album', $_GET['name']);
								if (isset($_POST['delete'])) {
									echo '
										
									';
								}
							} else {
								$simpleViewer['error'] = true;
								$simpleViewer['errorMsg'] .= "No album name specified.\n";
							}
							break;
							
						}
						
					// No action action argument provided.
					} else {
						$simpleViewer['error'] = true;
					}
				}
				
				// Handle images
				if ($_GET['file'] == 'image') {
					
					// Switch the requested action.
					if (!empty($_GET['action'])) {
						switch ($_GET['action']) {
							
						// Add an image.
						case 'add':
							addItem('image', $name = (!empty($_GET['name']) ? $_GET['name'] : ''));
							echo '
								
							';
							break;
							
						// Edit an image.
						case 'edit':
							if (isset($_POST['saveImageData'])) {
								$captionText = stripslashes($_POST['imageCaption']);
								if (!empty($_POST['autoCaption'])) {
									$tmpArr   	 = explode('.', $_POST['imageName']);
									$imageName	 = $tmpArr[0] . '.jpg';
									$captionText = '
Open image in new window';
								}
								saveImageToXML($_POST['imageName'], $captionText);
							}
							echo '
								
							';
							break;
							
						// Delete an image.
						case 'delete':
							if (!empty($_GET['name'])) {
								deleteItem('image', $_GET['name']);
								echo '
									
								';
							} else {
								$simpleViewer['error'] = true;
								$simpleViewer['errorMsg'] .= "No image name specified.\n";
							}
							break;
						}
						
					// No action action argument provided.
					} else {
						$simpleViewer['error'] = true;
					}
				}
			}
			
			// Handle the gallery configuration.
			if (!empty($_GET['configureGallery'])) {
				echo '
Edit gallery configuration
';
				configure('gallery');
				if (isset($_POST['saveConfiguration'])) {
					echo '
						
					';
				}
			}
			
			// An error occured somewhere above. Print a notice and show an error description
			if ($simpleViewer['error']) {
				echo '
Something bad happened!
					One or more errors occured.
					
Notice(s)
					' . nl2br($simpleViewer['errorMsg']);
				
			// This is the default case.
			// After the user is logged in, I show him the main page containing some introductory text.
			} else {
				if (empty($_SERVER['QUERY_STRING'])) {
					echo '
						
' . $simpleViewer['adminTitle'] . '
						Documentation
						
						Credits
						
						Legal
						
						Version
						
					';
				}
			}
			?>