コード例 #1
0
ファイル: mypictures.php プロジェクト: Cibale/sofascoreEDU
<?php

/**
 * Created by PhpStorm.
 * User: martinmatak
 * Date: 20/02/16
 * Time: 18:33
 */
include 'htmllibrary.php';
include 'DAO.php';
session_start();
if (!isset($_SESSION['user_id'])) {
    header('Location: index.php');
}
$images = getImagesByUser('slike.txt');
$imgGallery = getGalleriesIds(array_keys($images), 'slike.txt');
$galleries = getGalleriesNames(array_values($imgGallery), 'galerije.txt');
$brElement = create_element("br", false, null);
create_doctype();
begin_html();
begin_head();
echo create_element("a", true, ["href" => "index.php", "contents" => "Home page"]), $brElement;
echo create_element("a", true, ["href" => "upload.php", "contents" => "Upload a new photo"]), $brElement;
echo create_element("a", true, ["href" => "new_gallery.php", "contents" => "Create a new gallery"]), $brElement;
echo create_element("h1", true, ["contents" => "Your photos:"]);
end_head();
begin_body();
$listElements = array();
foreach ($images as $key => $value) {
    $imgContent = create_element("img", false, ["src" => "picture.php?id={$key}&size=small"]);
    $imgTitle = create_element("h3", true, ['contents' => $value]);
コード例 #2
0
ファイル: editphoto.php プロジェクト: Cibale/sofascoreEDU
        }
    }
    $data['description'] = element('description', $_POST, '');
    foreach ($data as $key => $value) {
        $data[$key] = htmlentities($value);
    }
    if ($allGood) {
        //save to database
        updatePicture($_GET['id'], $data['title'], $data['description'], $data['galleryOption']);
        header('Location: mypictures.php');
    } else {
        echo "Not all required fields are filled..";
    }
}
$galleries = getGalleries($_SESSION['user_id']);
$galleryId = array_values(getGalleriesIds(array($_GET['id']), 'slike.txt'))[0];
//napravi izbor korisnikovih galerija
$options = array();
foreach ($galleries as $key => $value) {
    if ($key == $galleryId) {
        array_push($options, create_element("option", true, ["contents" => $value, "value" => $key, "selected" => "selected"]));
    } else {
        array_push($options, create_element("option", true, ["contents" => $value, "value" => $key]));
    }
}
$input = create_select(["name" => "galleryOption", "contents" => $options]);
$pictureId = $_GET['id'];
$pictureTitle = getImageName($pictureId);
$pictureDescription = getImageDescription($pictureId);
echo create_element("img", false, ["src" => "picture.php?id={$pictureId}&size=original"]);
?>