$frm = new Form("field", "createAlbum", "galleries.php?gid=" . $_GET["gid"], "addAlbum"); $frm->addHidden("gid", $_GET["gid"]); $frm->addFormElement("album_name", "text", "Name", "", true); $frm->addFormElement("album_description", "textarea", "Description", "", true); $frm->addFormElement("album_files", "file", "Zip File", "", true); $frm->method = "post"; $frm->draw(); } } else { writeHeader(3, "Nerdery Pictures", "Picture Galleries"); writeCP(); $sh = new SectionHeader("Picture Galleries", true); $sh->start(); $sh->end(); echo '<table border="0" cellpadding="2" cellspacing="0" width="700">'; $each = getGalleries(); $i = 0; while ($g = $each[$i]) { //print_r ($g); if (strtotime($g->lastModified) > strtotime($_SESSION["PrevVisit"])) { $classname = "modifiedLink"; } else { $classname = "unmodifiedLink"; } echo "<tr><td colspan=\"2\"><a href=\"galleries.php?gid=" . $g->id . "\"><span class=\"" . $classname . "\">" . $g->name . "</span></a></td></tr><tr><td width=\"20\"></td><td width=\"680\"><span class=\"itemText\">" . $g->description . " (" . strtotime($g->lastModified) . " - " . strtotime($_SESSION["PrevVisit"]) . " - " . (strtotime($g->lastModified) > strtotime($_SESSION["PrevVisit"])) . ")</span></td></tr>"; $i++; } echo '</table><br>'; writeSectionHeader("Create a Gallery"); $frm = new Form("field", "createGallery", "galleries.php", "addGallery"); $frm->addDescription("All users can add pictures to public galleries.");
foreach ($data as $key => $value) { $data[$key] = htmlentities($value); } if ($allGood) { if (validatePicture($_FILES['file']['tmp_name'])) { storePicture($_FILES['file']['tmp_name'], $data['title'], $data['description'], $_SESSION['user_id'], $data['galleryOption']); header('Location: mypictures.php'); exit; } else { echo "Image not valid. Please try again."; } } else { echo "Not all required fields are filled.."; } } $galleries = getGalleries($_SESSION['user_id']); //ako nema ni jednu galeriju dosad - nek ju napravi if (empty($galleries)) { header('Location: new_gallery.php'); exit; } //napravi izbor korisnikovih galerija $options = array(); foreach ($galleries as $key => $value) { array_push($options, create_element("option", true, ["contents" => $value, "value" => $key])); } $input = create_select(["name" => "galleryOption", "contents" => $options]); function validatePicture($picture) { $MIN_WIDTH = 128; $MIN_HEIGHT = 128;
function getGallerContentsExec($name) { $galleries = getGalleries(); $result = FALSE; $contents = FALSE; foreach ($galleries as $k => $v) { if ($v['name'] == $name) { $contents = getDirectoryContents(GALLERIES_DIR . $name); break; } } if ($contents) { foreach ($contents as $k => $v) { if ($v['kind'] == 'file') { $extension = strtolower($v['extension']); if ($extension == 'jpg' || $extension == 'jpeg' || $extension == 'gif' || $extension == 'png') { $result[] = $v; } } } } return $result; }
//some startup checks of configuration etc function notify($message) { if (NOTIFICATIONS) { echo '<div class="notification">' . $message . '</div>'; } } if (!getDirectoryReadability(GALLERIES_DIR)) { notify('Warning: The galleries directory is not readable or does not exist.'); } if (!getDirectoryWritability(THUMBS_DIR)) { notify('Warning: The thumbs directory is not writable or does not exist. This will severely affect performance!'); } if ($gallery == '') { if (LIST_GALLERIES) { $galleries = getGalleries(); if ($galleries) { //render gallery list foreach ($galleries as $k => $v) { $name = $v['name']; $url = './?gallery=' . urlencode($name); echo <<<EOD \t<div class="gallery"> \t\t<div class="galleryname"><a href="{$url}">{$name}</a></div> \t</div> EOD; } } } } else { if ($photo == '') {