Esempio n. 1
0
function viewDVDList()
{
    $dbh = new Database();
    $sth = $dbh->prepare("SELECT id FROM " . DB_PREFIX . "dvds WHERE status = 1 OR status = 2 AND show_frontpage = true ORDER BY id DESC");
    $sth->execute();
    $dvdCount = 0;
    while ($id = $sth->fetchColumn()) {
        $dvdCount++;
        $dvd = new DVD();
        $dvd->load($id);
        include '../views/frontpage/singleDVD.php';
    }
    if ($dvdCount == 0) {
        include '../views/frontpage/noDVDs.php';
    }
}
Esempio n. 2
0
<?php

$dvd = (int) $URL[0];
$url = urlencode($URL[1]);
$adminHash = $URL[2];
$dbh = new Database();
$sth = $dbh->prepare("SELECT id FROM " . DB_PREFIX . "dvds WHERE id = ? AND admin_hash = ?");
$sth->execute(array($dvd, $adminHash));
$result = $sth->fetchColumn();
if (empty($result)) {
    header('Location: ' . SITE_URL);
}
$publicUrl = SITE_URL . '/' . $dvd . '/' . $url;
$adminUrl = SITE_URL . '/' . $dvd . '/' . $url . '/' . $adminHash;
$currentDVD = new DVD();
$currentDVD->load($dvd);
if (empty($_POST)) {
    $data = array('title' => $currentDVD->title, 'author' => $currentDVD->author, 'email' => $currentDVD->email, 'description' => $currentDVD->description);
    if (!empty($currentDVD->publishDate)) {
        $data['publishDate'] = date("Y-m-d", strtotime($currentDVD->publishDate));
    }
    if (!empty($currentDVD->deadlineDate)) {
        $data['deadlineDate'] = date("Y-m-d", strtotime($currentDVD->deadlineDate));
    }
    switch ($currentDVD->status) {
        case 1:
            $data['status'] = 'active';
        case 2:
            $data['status'] = 'published';
        default:
            $data['status'] = 'inactive';
Esempio n. 3
0
    $errors[] = 'DVD:n tekijä on pakollinen.';
}
if (!filter_var($data['email'], FILTER_VALIDATE_EMAIL)) {
    $errors[] = 'Email on virheellinen.';
}
if (!empty($data['publishDate']) && !preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])\$/", $data['publishDate'])) {
    $errors[] = 'Julkaisupäivämäärän muoto tulee olla YYYY-MM-DD';
}
if (!empty($data['deadlineDate']) && !preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])\$/", $data['deadlineDate'])) {
    $errors[] = 'Ehdotusten deadlinen muoto tulee olla YYYY-MM-DD';
}
if (!empty($errors)) {
    include '../controllers/admin.php';
} else {
    $dvd = new DVD();
    $dvd->load($dvdID);
    $dvd->title = htmlspecialchars($data['title']);
    $dvd->author = htmlspecialchars($data['author']);
    $dvd->email = htmlspecialchars($data['email']);
    $dvd->publishDate = empty($data['publishDate']) ? null : $data['publishDate'];
    $dvd->deadlineDate = empty($data['deadlineDate']) ? null : $data['deadlineDate'];
    $dvd->description = empty($data['description']) ? null : htmlspecialchars($data['description']);
    if (!empty($data['status']) && $data['status'] == 'active') {
        $dvd->status = 1;
    } else {
        $dvd->status = 0;
    }
    if (!empty($data['showFrontpage']) && $data['showFrontpage'] == 'show') {
        $dvd->showFrontpage = 1;
    } else {
        $dvd->showFrontpage = 0;