/** * Sends an E-Mail to the offerer of the book. * * Known usages: * - add.php * - book.php - "Anfrage: " * - Cleaner.php - "Erneuern: " * * @param int $bookId database id of th book, this mail is about * @param string $subjectStart beginning of the subject, the title will * follow * @param string $message some text for the user, greeting will be added * @param string $replyTo mail address for the Reply-To field (optional) * @return bool false on failure */ public static function send($bookId, $subjectStart, $message, $replyTo = null) { include_once 'mysql_conn.php'; $query = 'select mail, id, author, title, price, year, isbn,' . ' description, auth_key from books where id="' . $bookId . '"'; $result = mysql_query($query); if (mysql_num_rows($result) != 1) { return false; } $book = Book::fromMySql($result); $subject = $subjectStart . $book->get('title'); $tmpl = Template::fromFile('view/mail.txt'); $tmpl->assign('message', $message); $tmpl->assign('bookText', $book->asText()); if ($replyTo == null || $replyTo == $book->get('mail')) { $subTmpl = $tmpl->addSubtemplate('editBook'); $link = self::editLink($book->get('id'), $book->get('auth_key')); $subTmpl->assign('editLink', $link); $books = new UsersBooks($book->get('mail')); $subTmpl->assign('usersBooks', $books->toString()); } else { $subTmpl = $tmpl->addSubtemplate('viewBook'); $link = self::bookLink($book->get('id')); $subTmpl->assign('bookLink', $link); } $content = $tmpl->result(); return self::mail($book->get('mail'), $subject, $content, $replyTo); }
public function __construct($bookId, $output) { $this->bookId = $bookId; $this->output = $output; $this->tmpl = Template::fromFile('view/book.html'); $this->book = $this->selectBook($bookId); $this->tmpl->assign('id', $bookId); }
public function __construct() { $this->selectableCategories = new SelectableCategories(); $this->output = new Output(); $this->output->setExpires('43200'); $this->output->addNavigationLink('first', 'Erste', 'add.php'); $this->addForm = Template::fromFile('view/add_form.html'); }
public function asText() { $tmpl = Template::fromFile('view/book.txt'); foreach ($this->data as $k => $v) { $tmpl->assign($k, $v); } return $tmpl->result(); }
function testFromFileFailing() { try { Template::fromFile('/'); } catch (Exception $expected) { // This should happen return; } $this->fail('Exception expected.'); }
} if (isset($_GET['activate'])) { ExternalServer::activate($_GET['activate']); } if (isset($_GET['delete'])) { ExternalServer::delete($_GET['delete']); } } if (sizeof($_GET)) { AdminServers::reload(); } if (sizeof($_POST)) { AdminServers::reload(); } $output = new Output(); $template = Template::fromFile('view/admin_servers.html'); $template->assign('localServerName', $localServer->name()); if ($localServer->isEmpty() || AdminServers::$editName) { $template->addSubtemplate('defineName'); } else { $sub = $template->addSubtemplate('listServers'); if ($localServer->rememberNewServers()) { $sub->addSubtemplate('rememberingServers'); } else { $sub->addSubtemplate('notRememberingServers'); } if ($localServer->acceptSuggestedServers()) { $sub->addSubtemplate('acceptingSuggestedServers'); } else { $sub->addSubtemplate('notAcceptingSuggestedServers'); }
public function __construct() { $this->output = new Output(); $this->tmpl = Template::fromFile('view/index.html'); $this->basicOutput(); }
$indices = array('author', 'title', 'price', 'year', 'isbn', 'description'); $bookString = trim($bookString); $bookLines = split("\n", $bookString, sizeof($labels)); for ($i = 0; $i < sizeof($labels); $i++) { list($label, $value) = split(':', $bookLines[$i], 2); if (trim($label) != $labels[$i]) { $value = ''; } $value = Parser::text2html(stripslashes(trim($value))); $tmpl->assign($indices[$i], $value); } } $usermail = Parser::text2html(stripslashes(Mailer::mailFromUser('mail'))); if (isset($_POST['book_data'])) { $tmpl = Template::fromFile('view/add_form.html'); import_book($_POST['book_data'], $tmpl); if (isset($_POST['mail'])) { $tmpl->assign('mail', $usermail); } $selectableCategories = new SelectableCategories(); $categoryString = implode(' ', $selectableCategories->createSelectArray()); $tmpl->assign('categories', $categoryString); } else { $tmpl = Template::fromFile('view/import.html'); if (isset($_GET['mail'])) { $mailTmpl = $tmpl->addSubtemplate('mail'); $mailTmpl->assign('mail', $usermail); } } $output = new Output(); $output->send($tmpl->result());
<?php /* * This file is part of uBook - a website to buy and sell books. * Copyright © 2010 Maikel Linke * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ require_once 'tools/Output.php'; require_once 'text/Template.php'; $helpTpl = Template::fromFile('view/help.html'); $output = new Output(); $output->setExpires(43200); $output->unlinkMenuEntry('Tipps'); $output->send($helpTpl->result());
public function sendNotFound($content = null) { header('HTTP/1.0 404 Not Found'); if ($content === null) { $tmpl = Template::fromFile('view/NotFound.html'); $content = $tmpl->result(); } $this->send($content); }
<?php /* * This file is part of uBook - a website to buy and sell books. * Copyright © 2010 Maikel Linke * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ require_once 'text/Template.php'; require_once 'tools/WEBDIR.php'; $tmpl = Template::fromFile('view/openSearch.xml'); $tmpl->assign('siteurl', WEBDIR); header('Content-Type: application/opensearchdescription+xml;charset=utf-8'); //header('Content-Type: text/xml;charset=utf-8'); echo $tmpl->result();
* This file is part of uBook - a website to buy and sell books. * Copyright © 2010 Maikel Linke * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ require_once 'update/Updater.php'; require_once 'tools/Output.php'; require_once 'text/Template.php'; $output = new Output(); $tmpl = Template::fromFile('view/update.html'); $updater = new Updater(); if ($updater->hasWork()) { $updater->update(); $sub = $tmpl->addSubtemplate('working'); $sub->assign('version', $updater->getNextVersion()); $output->addRefreshLink('./admin_update.php'); } else { $tmpl->addSubtemplate('noWork'); } $output->send($tmpl->result());
if (!isset($_GET['id'])) { exit; } if (!isset($_GET['key'])) { exit; } $id = (int) $_GET['id']; $key = $_GET['key']; $query = 'select id from books where id="' . $id . '" and auth_key="' . $key . '";'; $result = mysql_query($query); if (mysql_num_rows($result) != 1) { exit; } // now we have valid access $output = new Output(); $tmpl = Template::fromFile('view/upload.html'); $tmpl->assign('id', $id); $tmpl->assign('key', $key); if (isset($_GET['upload'])) { if (Image::wasUploaded()) { if (Image::isStorable()) { $image = new Image($id); if ($image->moveUploaded()) { header('Location: book.php?id=' . $id . '&key=' . $key . '&uploaded=true'); } else { $tmpl->addSubtemplate('processingError'); } } else { $tmpl->addSubtemplate('notStorable'); } } else {
/* * This file is part of uBook - a website to buy and sell books. * Copyright © 2010 Maikel Linke * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ require_once 'tools/Output.php'; require_once 'tools/Statistics.php'; require_once 'text/Template.php'; $stat = new Statistics(); $statTpl = Template::fromFile('view/statistics.html'); if (file_exists(Statistics::STATS_FILE)) { $statTpl->addSubtemplate('stats'); $stat->fillTemplate($statTpl); } else { $statTpl->addSubtemplate('noStats'); } $output = new Output(); $output->setExpires(43200); $output->send($statTpl->result());
$error = 'not found'; } else { /* we have valid access to this book */ $selectableCategories = new SelectableCategories($id); if (isset($_POST['author'])) { /* update base book data */ $query = 'update books set author = "' . $_POST['author'] . '", title = "' . $_POST['title'] . '", year = "' . $_POST['year'] . '", isbn = "' . $_POST['isbn'] . '", price = "' . str_replace(',', '.', $_POST['price']) . '", description = "' . $_POST['desc'] . '" where id="' . $id . '" and auth_key="' . $key . '"'; mysql_query($query); /* update category relations */ $selectableCategories->update(); /* update expire date and look at the book */ require 'renew.php'; } $book = Book::fromMySql($result); require_once 'tools/Output.php'; require_once 'text/Template.php'; $tmpl = Template::fromFile('view/edit.html'); $book->assignHtmlToTemplate($tmpl); assignSelectableCategories($selectableCategories, $tmpl); $tmpl->assign('id', $_GET['id']); $tmpl->assign('key', $_GET['key']); $output = new Output(); $output->send($tmpl->result()); }
/** * Loads the content of an HTML template file. * * @param string $filename path to the template file relativ to the html * directory * @return HtmlTemplate instance with the content of the template file * @throws Exception see Template */ public static function fromFile($filename) { $tmpl = Template::fromFile('html/' . $filename); return new self($tmpl); }
<?php /* * This file is part of uBook - a website to buy and sell books. * Copyright © 2010 Maikel Linke * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ require_once 'tools/Output.php'; require_once 'text/Template.php'; // TODO: target attribute not allowed in xhtml strict (search in all docs) $tmpl = Template::fromFile('view/about.html'); $output = new Output(); $output->setExpires(43200); $output->unlinkMenuEntry('Impressum'); $output->send($tmpl->result());
private function createSelect($index, $selectedCats) { $cats = $this->categories->getArray(); $selectedCat = ''; if (isset($selectedCats[$index])) { $selectedCat = $selectedCats[$index]; } $select = Template::fromFile('view/select.html'); $select->assign('index', $index); foreach ($cats as $index => $category) { if ($category == $selectedCat) { $option = $select->addSubtemplate('selectedOption'); } else { $option = $select->addSubtemplate('option'); } $option->assign('category', $category); } return $select->result(); }
* (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ require_once 'books/SearchKey.php'; require_once 'notification/Searches.php'; require_once 'tools/Mailer.php'; $searchKey = new SearchKey(); if (!$searchKey->isGiven()) { header('Location: ./'); } $mail = Mailer::mailFromUser('mail'); if ($mail == null) { $mail = Mailer::mailFromUser('name'); } if ($mail) { $searches = new Searches(); $searches->addSearch($searchKey->asText(), $mail); header('Location: ./?search=' . urlencode($searchKey->asText()) . '&searchSaved=1'); } $tmpl = Template::fromFile("view/save_search.html"); $tmpl->assign('searchKey', $searchKey->asHtml()); $tmpl->assign('urlSearchKey', urlencode($searchKey->asHtml())); $output = new Output(); $output->send($tmpl->result());