Beispiel #1
0
 * Date: 16/03/16
 * Time: 11:33
 */
require_once 'Autoloader.php';
session_start();
// not logged in or id of photo not set
if (!isset($_SESSION['user_id'])) {
    header('Location: index.php');
}
$user = new \models\Korisnik();
$user->load($_SESSION['user_id']);
if (!empty($_POST['submitted'])) {
    if (isset($_POST['btnDelete'])) {
        $user->delete();
        unset($_SESSION['user_id']);
        DAO::getConnection()->header('Location: registration.php');
        exit;
    }
    $rules = array();
    $rules['name'] = 'length[40]';
    $rules['surname'] = 'length[40]';
    $rules['email'] = 'required|email|length[50]';
    $rules['password'] = '******';
    $rules['confirm_password'] = '******';
    $validation = new \validation_library\FormValidation();
    $validation->set_rules($rules);
    $allGood = $validation->validate();
    if (strcmp($_POST['password'], $_POST['confirm_password']) != 0) {
        $allGood = false;
    }
    if ($allGood) {
Beispiel #2
0
$body->add_child($link1);
$body->add_child(new \html_library\HTMLBrElement());
$title = new \html_library\HTMLTitleElement();
$title->add_child(new \html_library\HTMLTextNode('Your photos: '));
$body->add_child($title);
$body->add_child(new \html_library\HTMLBrElement());
$listElements = new \html_library\HTMLUlElement();
$images = DAO::getConnection()->getImagesByUser($_SESSION['user_id']);
foreach ($images as $imageId => $image) {
    $listElement = new \html_library\HTMLLiElement();
    $imgContent = new \html_library\HTMLImageElement();
    $imgContent->add_attribute(new \html_library\HTMLAttribute('src', "picture.php?id={$imageId}&size=small"));
    $imgTitle = new \html_library\HTMLTitleElement(3);
    $imgTitle->add_child(new \html_library\HTMLTextNode($image->getTitle()));
    $galleryTitle = new \html_library\HTMLTitleElement(5);
    $galleryTitle->add_child(new \html_library\HTMLTextNode(DAO::getConnection()->getGallery($image->getGalleryId())->getTitle()));
    $editLink = new \html_library\HTMLAElement();
    $editLink->add_attribute(new \html_library\HTMLAttribute('href', "editphoto.php?id={$imageId}"));
    $editLink->add_child(new \html_library\HTMLTextNode('Edit photo'));
    $listElement->add_child($imgTitle);
    $listElement->add_child(new \html_library\HTMLBrElement());
    $listElement->add_child($imgContent);
    $listElement->add_child(new \html_library\HTMLBrElement());
    $listElement->add_child($galleryTitle);
    $listElement->add_child(new \html_library\HTMLBrElement());
    $listElement->add_child($editLink);
    $listElement->add_child(new \html_library\HTMLBrElement());
    $listElements->add_child($listElement);
}
$body->add_child($listElements);
echo $page;
Beispiel #3
0
 * Time: 14:38
 */
require_once 'Autoloader.php';
session_start();
if (!isset($_SESSION['user_id'])) {
    header('Location: index.php');
    exit;
}
if (!empty($_POST['submitted'])) {
    $rules = array();
    $rules['name'] = 'required|length[100]';
    $rules['description'] = 'length[500]';
    $formValidation = new \validation_library\FormValidation();
    $formValidation->set_rules($rules);
    if ($formValidation->validate()) {
        DAO::getConnection()->create(new \models\Galerija(htmlentities(trim($_POST['name'])), $_SESSION['user_id'], htmlentities(trim($_POST['description']))));
        header('Location: upload.php');
        exit;
    } else {
        $formValidation->display_validation_errors();
    }
}
//page rendering
$page = new html_library\HTMLHtmlElement();
$page->add_child(new html_library\HTMLHeadElement());
$body = new html_library\HTMLBodyElement();
$page->add_child($body);
$form = new \html_library\HTMLFormElement();
$body->add_child($form);
$form->add_attribute(new \html_library\HTMLAttribute('id', 'new_gallery'));
$form->add_attribute(new \html_library\HTMLAttribute('action', ''));
Beispiel #4
0
$fieldset->add_child($labelDescription);
$textArea = new \html_library\HTMLTextAreaElement();
$textArea->add_attribute(new \html_library\HTMLAttribute('name', 'description'));
$textArea->add_attribute(new \html_library\HTMLAttribute('form', 'pic_upload'));
$textArea->add_attribute(new \html_library\HTMLAttribute('maxlength', 500));
$fieldset->add_child($textArea);
$textArea->add_child(new \html_library\HTMLTextNode($pictureDescription));
$fieldset->add_child(new \html_library\HTMLBrElement());
//gallery
$labelGallery = new \html_library\HTMLLabelElement();
$labelGallery->add_attribute(new \html_library\HTMLAttribute('for', 'gallery'));
$labelGallery->add_child(new \html_library\HTMLTextNode('Gallery: '));
$fieldset->add_child($labelGallery);
$selectGallery = new \html_library\HTMLSelectElement();
$selectGallery->add_attribute(new \html_library\HTMLAttribute('name', 'galleryOption'));
$galleries = DAO::getConnection()->getGalleriesByUserId($_SESSION['user_id']);
//napravi izbor korisnikovih galerija
foreach ($galleries as $galleryId => $gallery) {
    $option = new \html_library\HTMLOptionElement();
    $option->add_attribute(new \html_library\HTMLAttribute('value', $galleryId));
    $option->add_child(new \html_library\HTMLTextNode($gallery->getTitle()));
    if ($galleryId === $picture->getGalleryId()) {
        $option->add_attribute(new \html_library\HTMLAttribute('selected', 'selected'));
    }
    $selectGallery->add_child($option);
}
$fieldset->add_child($selectGallery);
$submitInput = new \html_library\HTMLInputElement();
$submitInput->add_attribute(new \html_library\HTMLAttribute('type', 'submit'));
$submitInput->add_attribute(new \html_library\HTMLAttribute('name', 'btnSubmit'));
$submitInput->add_attribute(new \html_library\HTMLAttribute('value', 'Save changes'));
Beispiel #5
0
 * Date: 10/03/16
 * Time: 10:26
 */
require_once 'Autoloader.php';
session_start();
if (isset($_SESSION['user_id'])) {
    header('Location: index.php');
}
if (!empty($_POST['submitted'])) {
    $formValidation = new \validation_library\FormValidation();
    $rules = array();
    $rules['usermail'] = 'required|email|length[100]';
    $rules['password'] = '******';
    $formValidation->set_rules($rules);
    if ($formValidation->validate()) {
        $user = DAO::getConnection()->getUser($_POST['usermail'], sha1($_POST['password']));
        if ($user != false) {
            $_SESSION['user_id'] = $user;
            header('Location: index.php');
            exit;
        } else {
            echo "Invalid usermail or password";
        }
    } else {
        $formValidation->display_validation_errors();
    }
}
$page = new html_library\HTMLHtmlElement();
$page->add_child(new html_library\HTMLHeadElement());
$body = new html_library\HTMLBodyElement();
$page->add_child($body);
Beispiel #6
0
if (!empty($_POST['submitted'])) {
    $rules = array();
    $rules['name'] = 'required|length[50]';
    $rules['surname'] = 'required|length[50]';
    $rules['email'] = 'required|email|length[100]';
    $rules['password'] = '******';
    $rules['confirm_password'] = '******';
    $validation = new \validation_library\FormValidation();
    $validation->set_rules($rules);
    $allGood = $validation->validate();
    if (strcmp($_POST['password'], $_POST['confirm_password']) != 0) {
        $allGood = false;
    }
    if ($allGood) {
        $user = new \models\Korisnik(htmlentities($_POST['name']), htmlentities($_POST['surname']), htmlentities($_POST['email']), sha1($_POST['password']));
        DAO::getConnection()->create($user);
        header('Location: login.php');
        echo "Sve ok";
        //  exit;
    } else {
        if (empty($validation->validation_errors())) {
            echo "Password doesn't match";
        } else {
            $validation->display_validation_errors();
        }
    }
}
$page = new html_library\HTMLHtmlElement();
$page->add_child(new html_library\HTMLHeadElement());
$body = new html_library\HTMLBodyElement();
$page->add_child($body);