Commit cf861c8e authored by Hugo Leisink's avatar Hugo Leisink

Release 6.5

parent 4aa6b7ff
banshee (6.5) stable; urgency=low
* Preview option and BBcode check in forum module.
* Removed Google Maps library (due to required license key crap).
* Added spam check to text fields in page forms.
* Improved setup.
* Small bugfixes.
-- Hugo Leisink <[email protected]> Sat, 16 Feb 2019 07:39:29 +0100
banshee (6.4) stable; urgency=low
* Added form functionality to page module.
......
Upgrading
=========
Before you start building a website with Banshee, you must understand how to
upgrade it to the next release. Banshee is a framework, with ready to use
modules. Those modules are MVC modules and its files are located in the
directories controllers, models and views. Most modules also have a stylesheet,
which is located in public/css. Optionally, a module can have a javascript,
which is located in public/js.
The framework part of Banshee can be found in libraries/core. You are advised
not to change those files. Banshee also uses other libraries from the libraries
directory. Only change those libraries if you know what you're doing and
document your changes.
To upgrade your Banshee-based website to a new version, install a new version
of Banshee and copy your modules to that new Banshee installation. You can use
the import script for that.
Download the latest release at https://www.banshee-php.org/.
......@@ -14,7 +14,7 @@
}
],
"support": {
"forum": "https://www.banshee-php.org/forum/1",
"forum": "https://www.banshee-php.org/forum",
"docs": "https://www.banshee-php.org/documentation"
},
"config": {
......
......@@ -53,7 +53,7 @@
while ($day < $last_day) {
$this->view->open_tag("week");
for ($dow = 1; $dow <= 7; $dow++) {
$params = array("nr" => date("j", $day), "dow" => $dow);
$params = array("nr" => date_string("j", $day), "dow" => $dow);
if ($day == $today) {
$params["today"] = " today";
}
......@@ -68,7 +68,7 @@
}
$this->view->close_tag();
$day = strtotime(date("d-m-Y", $day)." +1 day");
$day = strtotime(date_string("d-m-Y", $day)." +1 day");
}
$this->view->close_tag();
}
......@@ -87,8 +87,8 @@
}
private function show_appointment_record($appointment) {
$appointment["begin"] = date("l j F Y", $appointment["begin"]);
$appointment["end"] = date("l j F Y", $appointment["end"]);
$appointment["begin"] = date_string("l j F Y", $appointment["begin"]);
$appointment["end"] = date_string("l j F Y", $appointment["end"]);
$this->view->record($appointment, "appointment");
}
......@@ -99,7 +99,7 @@
$this->view->title = "Agenda";
if (isset($_SESSION["calendar_month"]) == false) {
$_SESSION["calendar_month"] = (int)date("m");
$_SESSION["calendar_month"] = (int)date_string("m");
$_SESSION["calendar_year"] = (int)date("Y");
}
......@@ -118,7 +118,7 @@
} else if ($this->page->parameters[0] == "current") {
/* Show current month
*/
$_SESSION["calendar_month"] = (int)date("m");
$_SESSION["calendar_month"] = (int)date_string("m");
$_SESSION["calendar_year"] = (int)date("Y");
$this->show_month($_SESSION["calendar_month"], $_SESSION["calendar_year"]);
} else if (valid_input($this->page->parameters[0], VALIDATE_NUMBERS, VALIDATE_NONEMPTY)) {
......
......@@ -40,7 +40,7 @@
}
if (is_true($page["form"])) {
$page_form = new Banshee\form_script($this->view, $this->settings, $page["content"]);
$page_form = new \Banshee\form_script($this->view, $this->settings, $page["content"]);
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if ($page_form->handle_post($_POST, $page["title"], $page["form_email"]) == false) {
$page["content"] = $page_form->generate_form($_POST);
......
......@@ -8,7 +8,7 @@
class captcha_controller extends Banshee\controller {
public function execute() {
$captcha = new Banshee\captcha;
$captcha = new \Banshee\captcha;
if ($captcha->created == false) {
exit;
}
......
......@@ -18,7 +18,7 @@
$_SESSION["admin_actionlog_size"] = $this->model->get_log_size();
}
$paging = new Banshee\pagination($this->view, "admin_actionlog", $this->settings->admin_page_size, $_SESSION["admin_actionlog_size"]);
$paging = new \Banshee\pagination($this->view, "admin_actionlog", $this->settings->admin_page_size, $_SESSION["admin_actionlog_size"]);
if (($log = $this->model->get_action_log($paging->offset, $paging->size)) === false) {
$this->view->add_tag("result", "Error reading action log.");
......
......@@ -57,7 +57,7 @@
$this->model->delete_referers($_POST);
}
$this->view->add_tag("width", floor($this->page_width / LOG_DAYS) - 1);
$this->view->add_tag("width", floor($this->page_width / ANALYTICS_DAYS) - 1);
$this->view->add_tag("height", $this->height);
$this->view->add_javascript("cms/analytics.js");
......@@ -66,14 +66,14 @@
/* Visits
*/
if (($visits = $this->model->get_visits(LOG_DAYS)) === false) {
if (($visits = $this->model->get_visits(ANALYTICS_DAYS)) === false) {
return false;
}
$this->show_graph($visits, "Visits");
/* Page views
*/
if (($pageviews = $this->model->get_page_views(LOG_DAYS)) === false) {
if (($pageviews = $this->model->get_page_views(ANALYTICS_DAYS)) === false) {
return false;
}
$this->show_graph($pageviews, "Page views");
......
......@@ -13,7 +13,7 @@
return;
}
$paging = new Banshee\pagination($this->view, "admin_dictionary", $this->settings->admin_page_size, $word_count);
$paging = new \Banshee\pagination($this->view, "admin_dictionary", $this->settings->admin_page_size, $word_count);
if (($words = $this->model->get_words($paging->offset, $paging->size)) === false) {
$this->view->add_tag("result", "Database error.");
......
......@@ -15,7 +15,7 @@
return false;
}
$paging = new Banshee\pagination($this->view, "admin_forum", $this->settings->admin_page_size, $message_count);
$paging = new \Banshee\pagination($this->view, "admin_forum", $this->settings->admin_page_size, $message_count);
if (($messages = $this->model->get_messages($paging->offset, $paging->size)) === false) {
$this->view->add_tag("result", "Database error.");
......
......@@ -19,7 +19,7 @@
}
handle_table_sort("adminguestbook_order", array("author", "message", "timestamp", "ip_address"), array("timestamp", "author"));
$paging = new Banshee\pagination($this->view, "admin_guestbook", $this->settings->admin_page_size, $message_count);
$paging = new \Banshee\pagination($this->view, "admin_guestbook", $this->settings->admin_page_size, $message_count);
if (($guestbook = $this->model->get_messages($_SESSION["adminguestbook_order"], $paging->offset, $paging->size)) === false) {
$this->view->add_tag("result", "Database error.");
......
......@@ -13,7 +13,7 @@
return;
}
$paging = new Banshee\pagination($this->view, "links", $this->settings->admin_page_size, $link_count);
$paging = new \Banshee\pagination($this->view, "links", $this->settings->admin_page_size, $link_count);
if (($links = $this->model->get_links($paging->offset, $paging->size)) === false) {
$this->view->add_tag("result", "Database error.");
......
......@@ -51,7 +51,7 @@
header("X-Hiawatha-Cache-Remove: all");
if (is_true(MENU_PERSONALIZED)) {
$cache = new Banshee\Core\cache($this->db, "banshee_menu");
$cache = new \Banshee\Core\cache($this->db, "banshee_menu");
$cache->store("last_updated", time(), 365 * DAY);
}
......
......@@ -36,7 +36,7 @@
protected function handle_submit() {
parent::handle_submit();
$cache = new Banshee\Core\cache($this->db, "banshee_settings");
$cache = new \Banshee\Core\cache($this->db, "banshee_settings");
$cache->store("last_updated", time(), 365 * DAY);
}
}
......
......@@ -14,7 +14,7 @@
}
handle_table_sort("adminuser_order", array("id", "username", "fullname", "email", "status"), array("username", "id"));
$paging = new Banshee\pagination($this->view, "admin_users", $this->settings->admin_page_size, $user_count);
$paging = new \Banshee\pagination($this->view, "admin_users", $this->settings->admin_page_size, $user_count);
$users = $this->model->get_users($_SESSION["adminuser_order"], $paging->offset, $paging->size);
$roles = $this->model->get_roles();
......@@ -195,7 +195,7 @@
"status" => USER_STATUS_CHANGEPWD);
$this->show_user_form($user);
} else if (($this->page->parameters[0] == "authenticator") && $this->page->ajax_request) {
$authenticator = new Banshee\authenticator;
$authenticator = new \Banshee\authenticator;
$this->view->add_tag("secret", $authenticator->create_secret());
} else if (valid_input($this->page->parameters[0], VALIDATE_NUMBERS, VALIDATE_NONEMPTY)) {
/* Show the user webform
......@@ -203,7 +203,9 @@
if (($user = $this->model->get_user($this->page->parameters[0])) == false) {
$this->view->add_tag("result", "User not found.");
} else {
$user["authenticator_secret"] = null;
if (empty($user["authenticator_secret"]) == false) {
$user["authenticator_secret"] = str_repeat("*", strlen($user["authenticator_secret"]));
}
$this->show_user_form($user);
}
} else {
......
......@@ -15,7 +15,7 @@
return;
}
$paging = new Banshee\pagination($this->view, "admin_forum", $this->settings->admin_page_size, $weblog_count);
$paging = new \Banshee\pagination($this->view, "admin_forum", $this->settings->admin_page_size, $weblog_count);
if (($weblogs = $this->model->get_weblogs($paging->offset, $paging->size)) === false) {
$this->view->add_tag("result", "Database error.");
......
......@@ -13,7 +13,7 @@
return;
}
$paging = new Banshee\pagination($this->view, "comments", $this->settings->admin_page_size, $comment_count);
$paging = new \Banshee\pagination($this->view, "comments", $this->settings->admin_page_size, $comment_count);
if (($comments = $this->model->get_comments($paging->offset, $paging->size)) === false) {
$this->view->add_tag("result", "Database error.");
......
......@@ -13,7 +13,7 @@
return;
}
$paging = new Banshee\pagination($this->view, "articles", $this->settings->admin_page_size, $article_count);
$paging = new \Banshee\pagination($this->view, "articles", $this->settings->admin_page_size, $article_count);
if (($articles = $this->model->get_articles($paging->offset, $paging->size)) === false) {
$this->view->add_tag("result", "Database error.");
......
......@@ -19,7 +19,7 @@
if ($closed) {
$paging_id .= "_closed";
}
$paging = new Banshee\pagination($this->view, $paging_id, $this->settings->admin_page_size, $order_count);
$paging = new \Banshee\pagination($this->view, $paging_id, $this->settings->admin_page_size, $order_count);
if (($orders = $this->model->get_orders($closed, $paging->offset, $paging->size)) === false) {
$this->view->add_tag("result", "Database error.");
......
<?php
class demos_alphabetize_controller extends Banshee\controller {
public function execute() {
$alphabetize = new Banshee\alphabetize($this->view, "demo");
$alphabetize = new \Banshee\alphabetize($this->view, "demo");
$words = $this->model->get_words($alphabetize->char);
$this->view->open_tag("words");
......
......@@ -5,7 +5,7 @@
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$valid = Banshee\captcha::valid_code($_POST["code"]);
$this->view->add_tag("valid", show_boolean($valid));
$this->view->add_message("Valid code: %s.", show_boolean($valid));
}
}
}
......
<?php
class demos_googlemaps_controller extends Banshee\controller {
private $origin = "Amsterdam, NL";
private $destination = "Paris, FR";
private function show_static_map() {
$google_map = new Banshee\Google_Maps($this->db);
$google_map->add_route($this->origin, $this->destination);
$google_map->add_marker("D", "red", "Den Haag, NL");
$google_map->add_marker("L", "yellow", "London, EN");
$google_map->add_marker("B", "green", "Bonn, DE");
$google_map->set_visibility("Stuttgart, DE");
$this->view->disable();
$google_map->show_static_map(640, 350);
}
public function execute() {
if ($this->page->parameters[0] == "image") {
$this->show_static_map();
return;
}
$google_map = new Banshee\Google_Maps($this->db);
$google_map->add_route($this->origin, $this->destination);
$steps = $google_map->route_description;
$distance = $google_map->route_distance;
$duration = $google_map->route_duration;
$hours = $duration / 3600;
$minutes = ($duration % 3600) / 60;
$this->view->open_tag("route");
$this->view->add_tag("origin", $this->origin);
$this->view->add_tag("destination", $this->destination);
$this->view->add_tag("distance", sprintf("%2.1f km", $distance / 1000));
$this->view->add_tag("duration", sprintf("%d:%2d", $hours, $minutes));
foreach ($steps as $step) {
$this->view->add_tag("step", $step["description"], array(
"distance" => $step["distance"],
"duration" => $step["duration"]));
}
$this->view->close_tag();
}
}
?>
<?php
class demos_graph_controller extends Banshee\controller {
public function execute() {
$graph = new Banshee\graph($this->view);
$graph = new \Banshee\graph($this->view);
$graph->title = "Demo graph";
$graph->width = 600;
$graph->height = 200;
......
......@@ -8,7 +8,7 @@
array_push($list, "List item ".($i + 1));
}
$paging = new Banshee\pagination($this->view, "demo", 15, count($list));
$paging = new \Banshee\pagination($this->view, "demo", 15, count($list));
$items = array_slice($list, $paging->offset, $paging->size);
$this->view->open_tag("items");
......
......@@ -3,7 +3,7 @@
public function execute() {
$this->view->title = "Poll demo";
$poll = new Banshee\poll($this->db, $this->view, $this->settings);
$poll = new \Banshee\poll($this->db, $this->view, $this->settings);
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$poll->vote($_POST["vote"]);
......
......@@ -6,7 +6,7 @@
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$input = $_POST["input"];
$message = new Banshee\message($input);
$message = new \Banshee\message($input);
if ($message->is_spam == false) {
$message->unescaped_output();
$message->translate_bbcodes();
......
......@@ -18,7 +18,7 @@
public function execute() {
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$validator = new Banshee\validator($this->view);
$validator = new \Banshee\validator($this->view);
if ($validator->execute($this->pattern)) {
$this->view->add_system_message("Data validation oke.");
......
......@@ -34,7 +34,7 @@
return;
}
$paging = new Banshee\pagination($this->view, "forum_".$forum_id, $this->settings->forum_page_size, $count);
$paging = new \Banshee\pagination($this->view, "forum_".$forum_id, $this->settings->forum_page_size, $count);
if (($forum = $this->model->get_forum($forum_id, $paging->offset, $paging->size)) === false) {
$this->view->add_tag("result", "Forum not found.", $this->url);
......@@ -52,7 +52,7 @@
$topic["unread"] = show_boolean($this->model->last_topic_view($topic["id"]) < $topic["timestamp"]);
}
$topic["starter"] = isset($topic["visitor"]) ? $topic["visitor"] : $topic["user"];
$topic["timestamp"] = date("j F Y, H:i", $topic["timestamp"]);
$topic["timestamp"] = date_string("j F Y, H:i", $topic["timestamp"]);
$this->view->record($topic, "topic");
}
$this->view->close_tag();
......@@ -101,10 +101,10 @@
} else {
$message["usertype"] = "registered";
}
$message["timestamp"] = date("j F Y, H:i", $message["timestamp"]);
$message["timestamp"] = date_string("j F Y, H:i", $message["timestamp"]);
$message["content"] = preg_replace("/\[(config|code|quote)\]([\r\n]*)/", "[$1]", $message["content"]);
$post = new Banshee\message($message["content"]);
$post = new \Banshee\message($message["content"]);
$post->unescaped_output();
$post->translate_bbcodes();
$post->translate_smilies();
......@@ -141,8 +141,22 @@
$this->view->add_message("Database error while creating topic.");
$this->show_topic_form($_POST);
} else {
$this->model->send_notifications($_POST["content"], $this->db->last_insert_id(2));
$this->show_topic($this->db->last_insert_id(2));
}
} else if ($_POST["submit_button"] == "Preview response") {
/* Peview response
*/
if ($this->model->response_oke($_POST)) {
$post = new \Banshee\message($_POST["content"]);
$post->unescaped_output();
$post->translate_bbcodes();
$post->translate_smilies();
$this->view->add_tag("preview", $post->content, array(
"name" => $this->user->logged_in ? $this->user->fullname : $_POST["username"]));
}
$this->show_topic($_POST["topic_id"], $_POST);
} else if ($_POST["submit_button"] == "Post response") {
/* Respond to topic
*/
......@@ -150,8 +164,9 @@
$this->show_topic($_POST["topic_id"], $_POST);
} else if ($this->model->create_response($_POST) == false) {
$this->view->add_message("Database error while saving response.");
$this->show_topic_form($_POST);
$this->show_topic($_POST["topic_id"], $_POST);
} else {
$this->model->send_notifications($_POST["content"], $_POST["topic_id"], $this->db->last_insert_id);
$this->show_topic($_POST["topic_id"]);
}
} else {
......
......@@ -33,7 +33,7 @@
return;
}
$paging = new Banshee\pagination($this->view, "guestbook", $this->settings->guestbook_page_size, $message_count);
$paging = new \Banshee\pagination($this->view, "guestbook", $this->settings->guestbook_page_size, $message_count);
if (($guestbook = $this->model->get_messages($paging->offset, $paging->size)) === false) {
$this->view->add_tag("result", "Database error.");
......@@ -41,8 +41,8 @@
$this->view->open_tag("guestbook", array("skip_sign_link" => show_boolean($skip_sign_link)));
foreach ($guestbook as $item) {
$item["timestamp"] = date("j F Y, H:i", $item["timestamp"]);
$message = new Banshee\message($item["message"]);
$item["timestamp"] = date_string("j F Y, H:i", $item["timestamp"]);
$message = new \Banshee\message($item["message"]);
$item["message"] = $message->unescaped_output();
unset($item["ip_address"]);
$this->view->record($item, "item");
......
......@@ -47,7 +47,7 @@
}
private function show_mail($mail) {
$message = new Banshee\message($mail["message"]);
$message = new \Banshee\message($mail["message"]);
$mail["message"] = $message->unescaped_output();
if ($mail["to_user_id"] == $this->user->id) {
......
......@@ -16,7 +16,7 @@
if ($this->page->type == "xml") {
/* RSS feed
*/
$rss = new Banshee\Protocols\RSS($this->view);
$rss = new \Banshee\Protocols\RSS($this->view);
if ($rss->fetch_from_cache("news_rss") == false) {
$rss->title = $this->settings->head_title." news";
$rss->description = $this->settings->head_description;
......@@ -36,7 +36,7 @@
$this->view->add_tag("result", "Unknown news item");
} else {
$this->view->title = $item["title"]." - News";
$item["timestamp"] = date("j F Y, H:i", strtotime($item["timestamp"]));
$item["timestamp"] = date_string("j F Y, H:i", strtotime($item["timestamp"]));
$this->view->record($item, "news");
}
} else {
......@@ -47,7 +47,7 @@
return;
}
$paging = new Banshee\pagination($this->view, "news", $this->settings->news_page_size, $count);
$paging = new \Banshee\pagination($this->view, "news", $this->settings->news_page_size, $count);
if (($news = $this->model->get_news($paging->offset, $paging->size)) === false) {
$this->view->add_tag("result", "Database error");
......@@ -55,7 +55,7 @@
}
foreach ($news as $item) {
$item["timestamp"] = date("j F Y, H:i", $item["timestamp"]);
$item["timestamp"] = date_string("j F Y, H:i", $item["timestamp"]);
$this->view->record($item, "news");
}
......
......@@ -18,7 +18,7 @@
return;
}
$paging = new Banshee\pagination($this->view, "photo_albums", $this->settings->photo_page_size, $count);
$paging = new \Banshee\pagination($this->view, "photo_albums", $this->settings->photo_page_size, $count);
if (($albums = $this->model->get_albums($paging->offset, $paging->size)) === false) {
$this->view->add_tag("result", "Database error retrieving albums");
......@@ -32,7 +32,7 @@
$this->view->open_tag("albums");
foreach ($albums as $album) {
$album["timestamp"] = date("j F Y", strtotime($album["timestamp"]));
$album["timestamp"] = date_string("j F Y", strtotime($album["timestamp"]));
$this->view->record($album, "album");
}
$this->view->close_tag();
......@@ -56,7 +56,7 @@
return;
}
$paging = new Banshee\pagination($this->view, "photo_album_".$album_id, $this->settings->photo_album_size, $count);
$paging = new \Banshee\pagination($this->view, "photo_album_".$album_id, $this->settings->photo_album_size, $count);
if (($photos = $this->model->get_photo_info($album_id, $paging->offset, $paging->size)) === false) {
$this->view->add_tag("result", "Database error retrieving photos.");
......@@ -69,7 +69,7 @@
$this->view->title = sprintf("%s - %s", $album["name"], $this->view->title);
$this->view->open_tag("photos", array(
"timestamp" => date("j F Y", strtotime($album["timestamp"])),
"timestamp" => date_string("j F Y", strtotime($album["timestamp"])),
"info" => $album["description"],
"listed" => show_boolean($album["listed"])));
foreach ($photos as $photo) {
......
......@@ -8,7 +8,7 @@
class poll_controller extends Banshee\controller {
private function show_active_poll() {
$poll = new Banshee\poll($this->db, $this->view, $this->settings);
$poll = new \Banshee\poll($this->db, $this->view, $this->settings);
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$poll->vote($_POST["vote"]);
......
......@@ -10,8 +10,9 @@
private function show_profile_form($profile = null) {
if ($profile === null) {
$profile = array(
"fullname" => $this->user->fullname,
"email" => $this->user->email);
"fullname" => $this->user->fullname,
"email" => $this->user->email,
"authenticator_secret" => str_repeat("*", strlen($this->user->authenticator_secret)));
}
if (($organisation = $this->model->get_organisation()) === false) {
......@@ -19,12 +20,17 @@
return false;
}
$this->view->open_tag("edit");
if (is_true(USE_AUTHENTICATOR)) {
$this->view->add_javascript("profile.js");
}
$this->view->open_tag("edit", array("authenticator" => show_boolean(USE_AUTHENTICATOR)));
$this->view->add_tag("username", $this->user->username);
$this->view->add_tag("fullname", $profile["fullname"]);
$this->view->add_tag("organisation", $organisation);
$this->view->add_tag("email", $profile["email"]);
$this->view->add_tag("authenticator_secret", $profile["authenticator_secret"]);
if ($this->user->status == USER_STATUS_CHANGEPWD) {
$this->view->add_tag("cancel", "Logout", array("previous" => LOGOUT_MODULE));
} else {
......@@ -66,7 +72,10 @@
}
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (($this->page->parameters[0] == "authenticator") && $this->page->ajax_request) {
$authenticator = new \Banshee\authenticator;
$this->view->add_tag("secret", $authenticator->create_secret());
} else if ($_SERVER["REQUEST_METHOD"] == "POST") {
/* Update profile
*/
if (