Exemplo n.º 1
0
 public function index($message = '')
 {
     $movie = new Movie();
     $movies = $movie->getAllMovies();
     if (count($movies) === 0) {
         $movies = -1;
     }
     $this->registry->template->show('movies', array('movies' => $movies, 'type' => 'title', 'val' => '', 'message' => $message));
 }
Exemplo n.º 2
0
    return $response;
});
$app->post('/login', function ($request, $response, $args) {
    $data = $request->getParsedBody();
    $user = new User(db::getInstance());
    $result = $user->checkUser($data['username'], $data['password']);
    if ($result === false) {
        $response->write(json_encode(array('error' => array('message' => 'Wrong login information.'))));
    } else {
        $response->write(json_encode(array('token' => $result)));
    }
    return $response;
});
$app->get('/movies', function ($request, $response, $args) {
    $movie = new Movie(db::getInstance());
    $result = $movie->getAllMovies();
    if ($result === false) {
        $response->write(json_encode(array('error' => array('message' => 'No records found.'))));
    } else {
        $response->write(json_encode($result));
    }
    return $response;
})->add($auth_mw);
$app->get('/catmail/{email}', function ($request, $response, $args) {
    $recipient = $args['email'];
    //Unfortunately, mail transport is used instead of smtp, since smtp is unavailable for free on my server
    $transport = Swift_MailTransport::newInstance();
    $mailer = Swift_Mailer::newInstance($transport);
    $message = Swift_Message::newInstance();
    $message->setSubject('Your subject')->setFrom(array('*****@*****.**' => 'Cat Mail'))->setTo(array($recipient))->setBody('<html>' . '<head></head>' . '<body>' . 'Here is an image of cute kitty: <img src="' . $message->embed(Swift_Image::fromPath('http://a-melnichuk-projects.hol.es/res/cutecat.jpg', 'image/jpeg')) . '" alt="Cat Pic" />' . 'It\'s adorable!' . '</body>' . '</html>', 'text/html')->attach(Swift_Attachment::fromPath('http://a-melnichuk-projects.hol.es/res/cutecat.jpg', 'image/jpeg'));
    $result = $mailer->send($message);
Exemplo n.º 3
0
<?php

// we now in presentation layer
// we will include business layer to load business logic
include 'model/movie.php';
// init Movie Model from Business Logic
$movie = new Movie();
// now load all Movies
$data = $movie->getAllMovies();
// prepare HTML Table
function getHTMLTable($tabledata)
{
    $html = '<br />';
    $html .= '<h1>Liste der bereits erstellten Filme:</h1>';
    $html .= '<table id="moviestable">';
    $html .= '<thead><tr>';
    $html .= '<th>Filmtitel</th>';
    $html .= '<th>Jahr</th>';
    $html .= '<th>Sprache</th>';
    $html .= '<th>Medium</th>';
    $html .= '<th>E-Mail</th>';
    $html .= '</tr></thead>';
    foreach ($tabledata as $movie) {
        $html .= '<tbody><tr>';
        $html .= '<td>' . $movie['name'] . '</td>';
        $html .= '<td>' . $movie['year'] . '</td>';
        $html .= '<td>' . $movie['language'] . '</td>';
        $html .= '<td>' . $movie['medium'] . '</td>';
        $html .= '<td><a href="mailto:' . $movie['email'] . '">' . $movie['email'] . ' </a></td>';
        $html .= '</tr></tbody>';
    }