Skip to content
Browse files

Release 4.0

  • Loading branch information...
1 parent 5c011ef commit ffc36cfdc2cddd387b6131d04b2413154004b1f6 @hsleisink committed May 1, 2013
Showing with 5,955 additions and 4,282 deletions.
  1. +5 −0 .htaccess
  2. +38 −2 ChangeLog
  3. +0 −35 INSTALL
  4. +6 −6 LICENSE
  5. +0 −1 README.md
  6. +6 −1 controllers/admin.php
  7. +7 −5 controllers/admin/agenda.php
  8. +43 −0 controllers/admin/apitest.php
  9. +3 −3 controllers/admin/collection.php
  10. +1 −1 controllers/admin/dictionary.php
  11. +5 −5 controllers/admin/faq.php
  12. +1 −1 controllers/admin/file.php
  13. +1 −1 controllers/admin/forum.php
  14. +13 −0 controllers/admin/forum/section.php
  15. +1 −1 controllers/admin/guestbook.php
  16. +32 −51 controllers/admin/menu.php
  17. +11 −4 controllers/admin/page.php
  18. +2 −2 controllers/admin/photos.php
  19. +6 −4 controllers/admin/poll.php
  20. +6 −3 controllers/admin/role.php
  21. +7 −0 controllers/admin/settings.php
  22. +5 −5 controllers/admin/user.php
  23. +4 −4 controllers/admin/weblog.php
  24. +1 −1 controllers/{system → banshee}/error.php
  25. +38 −0 controllers/banshee/login.php
  26. +3 −5 controllers/{system → banshee}/page.php
  27. +3 −3 controllers/{system → banshee}/sso.php
  28. +1 −4 controllers/captcha.php
  29. +2 −3 controllers/demos/ajax.php
  30. +1 −1 controllers/demos/banshee_website.php
  31. +7 −5 controllers/demos/calendar.php
  32. +2 −1 controllers/demos/captcha.php
  33. +19 −19 controllers/demos/ckeditor.php
  34. +1 −1 controllers/demos/googlemaps.php
  35. +1 −2 controllers/demos/openstreetmap.php
  36. +0 −9 controllers/demos/parameter.php
  37. +1 −1 controllers/demos/pdf.php
  38. +1 −1 controllers/demos/poll.php
  39. +8 −7 controllers/demos/posting.php
  40. +1 −0 controllers/demos/tablemanager.php
  41. +2 −2 controllers/demos/validation.php
  42. +1 −1 controllers/dictionary.php
  43. +3 −11 controllers/faq.php
  44. +11 −6 controllers/forum.php
  45. +2 −4 controllers/guestbook.php
  46. +0 −39 controllers/login.php
  47. +43 −14 controllers/mailbox.php
  48. +1 −1 controllers/news.php
  49. +15 −20 controllers/newsletter.php
  50. +2 −2 controllers/password.php
  51. +3 −3 controllers/photo.php
  52. +14 −2 controllers/profile.php
  53. +74 −12 controllers/search.php
  54. +2 −2 controllers/session.php
  55. +6 −14 controllers/weblog.php
  56. +1 −2 database/flush_cache
  57. +93 −70 database/mysql.sql
  58. +1 −1 database/private_pages
  59. +21 −10 database/remove_demo_content
  60. +5 −2 database/setup_database
  61. +89 −0 database/verify_referer_log
  62. +8 −8 extra/fpdf_fonts/courier.php
  63. +8 −8 extra/fpdf_fonts/courierb.php
  64. +8 −8 extra/fpdf_fonts/courierbi.php
  65. +8 −8 extra/fpdf_fonts/courieri.php
  66. +19 −19 extra/fpdf_fonts/helvetica.php
  67. +19 −19 extra/fpdf_fonts/helveticab.php
  68. +19 −19 extra/fpdf_fonts/helveticabi.php
  69. +19 −19 extra/fpdf_fonts/helveticai.php
  70. +373 −373 extra/fpdf_fonts/makefont/makefont.php
  71. +289 −289 extra/fpdf_fonts/makefont/ttfparser.php
  72. +19 −19 extra/fpdf_fonts/symbol.php
  73. +19 −19 extra/fpdf_fonts/times.php
  74. +19 −19 extra/fpdf_fonts/timesb.php
  75. +19 −19 extra/fpdf_fonts/timesbi.php
  76. +19 −19 extra/fpdf_fonts/timesi.php
  77. +19 −19 extra/fpdf_fonts/zapfdingbats.php
  78. +0 −120 helpers/anti_spam.php
  79. +0 −76 helpers/bbcodes.php
  80. +0 −99 helpers/crypto.php
  81. +0 −52 helpers/csv.php
  82. +0 −33 helpers/smilies.php
  83. +96 −0 libraries/aes256.php
  84. +1 −1 libraries/alphabetize.php
  85. +39 −24 libraries/banshee.php
  86. +4 −3 libraries/banshee_website.php
  87. +15 −1 libraries/captcha.php
  88. +1 −1 libraries/controller.php
  89. +211 −0 libraries/csvfile.php
  90. +40 −7 libraries/database/database_connection.php
  91. +0 −36 libraries/database/mysql_connection.php
  92. +101 −16 libraries/email.php
  93. +6 −8 libraries/error.php
  94. +1,616 −1,616 libraries/fpdf.php
  95. +2 −2 libraries/googlemaps.php
  96. 0 { → libraries}/helpers/console.php
  97. +6 −0 { → libraries}/helpers/http.php
  98. 0 { → libraries}/helpers/ics.php
  99. 0 { → libraries}/helpers/output.php
  100. +22 −6 libraries/http.php
  101. +24 −7 libraries/image.php
  102. +8 −10 libraries/logging.php
  103. +117 −44 libraries/menu.php
  104. +324 −0 libraries/message.php
  105. +24 −1 libraries/model.php
  106. +6 −2 libraries/newsletter.php
  107. +4 −5 libraries/openstreetmap.php
  108. +141 −39 libraries/output.php
  109. +20 −18 libraries/page.php
  110. +3 −3 libraries/pagination.php
  111. +10 −8 libraries/poll.php
  112. +13 −8 libraries/secure_cookie.php
  113. +10 −72 libraries/security.php
  114. +2 −2 libraries/session.php
  115. +18 −21 libraries/settings.php
  116. +1 −1 libraries/splitform_controller.php
  117. +42 −17 libraries/tablemanager_controller.php
  118. +6 −3 libraries/tablemanager_model.php
  119. +47 −10 libraries/user.php
  120. +5 −5 libraries/{post_data.php → validator.php}
  121. +30 −6 libraries/xml.php
  122. +183 −183 libraries/zipfile.php
  123. +62 −0 logfiles/last_login
  124. +2 −2 models/admin/access.php
  125. +112 −0 models/admin/apitest.php
  126. +3 −3 models/admin/faq.php
  127. +2 −2 models/admin/file.php
  128. +2 −2 models/admin/forum.php
  129. +35 −0 models/admin/forum/section.php
  130. +2 −2 models/admin/languages.php
  131. +6 −7 models/admin/logging.php
  132. +56 −66 models/admin/menu.php
  133. +2 −2 models/admin/organisation.php
  134. +1 −1 models/admin/page.php
  135. +18 −14 models/admin/photos.php
  136. +1 −1 models/admin/role.php
  137. +10 −14 models/admin/settings.php
  138. +23 −38 models/admin/user.php
  139. +2 −2 models/admin/weblog.php
  140. +10 −4 models/{ → banshee}/login.php
  141. +1 −1 models/{system → banshee}/page.php
  142. +1 −1 models/{system → banshee}/sso.php
  143. +2 −0 models/collection.php
  144. +1 −1 models/demos/alphabetize.php
  145. +2 −1 models/demos/layout.php
  146. +0 −5 models/demos/posting.php
  147. +6 −7 models/forum.php
  148. +7 −2 models/guestbook.php
  149. +4 −4 models/mailbox.php
  150. +37 −20 models/newsletter.php
  151. +5 −6 models/photo.php
  152. +31 −1 models/profile.php
  153. +178 −0 models/search.php
  154. +7 −6 models/weblog.php
  155. +10 −10 add_module → new_module
  156. +6 −5 public/.htaccess
  157. +1 −3 public/css/admin/agenda.css
  158. +4 −0 public/css/admin/albums.css
  159. +38 −0 public/css/admin/apitest.css
  160. +1 −1 public/css/admin/collection.css
  161. +1 −1 public/css/admin/dictionary.css
  162. +1 −1 public/css/admin/faq.css
  163. +4 −0 public/css/admin/file.css
  164. +10 −2 public/css/admin/forum.css
  165. +3 −0 public/css/admin/forum/section.css
  166. +4 −0 public/css/admin/guestbook.css
  167. +4 −0 public/css/admin/links.css
  168. +2 −37 public/css/admin/menu.css
  169. +4 −0 public/css/admin/news.css
  170. +2 −2 public/css/admin/newsletter.css
  171. +4 −0 public/css/admin/organisation.css
  172. +5 −1 public/css/admin/page.css
  173. +4 −0 public/css/admin/photos.css
  174. +2 −4 public/css/admin/poll.css
  175. +2 −4 public/css/admin/role.css
  176. +1 −2 public/css/admin/settings.css
  177. +4 −0 public/css/admin/subscriptions.css
  178. +4 −0 public/css/admin/switch.css
  179. +1 −1 public/css/admin/user.css
  180. +1 −4 public/css/admin/weblog.css
  181. +4 −2 public/css/agenda.css
  182. 0 public/css/{includes → banshee}/alphabetize.css
  183. +152 −121 public/css/{includes → banshee}/banshee.css
  184. 0 public/css/{system → banshee}/browser.css
  185. 0 public/css/{includes → banshee}/calendar.css
  186. +221 −0 public/css/banshee/datatables.css
  187. 0 public/css/{system → banshee}/error.css
  188. +60 −0 public/css/banshee/js_pagination.css
Sorry, we could not display the entire diff because too many files (883) changed.
View
5 .htaccess
@@ -0,0 +1,5 @@
+<IfModule rewrite_module>
+ RewriteEngine On
+ RewriteBase /
+ RewriteRule . /public/$1 [QSA]
+</IfModule>
View
40 ChangeLog
@@ -1,3 +1,39 @@
+banshee (4.0) stable; urgency=low
+
+ * Support for login via client SSL certificate.
+ * Improved support for mobile devices.
+ * Improved support for API requests.
+ * API test module added.
+ * Improved menu administration and menu library.
+ * Converted smilies, BBcodes and spam detection helpers to library
+ and improved BBcode rewriting.
+ * Converted CSV helper to CSV library.
+ * CKEditor updated to 4.1.
+ * jQuery updated to 1.9.1, jQuery UI updated to 1.10.2.
+ * Added DataTables jQuery plugin.
+ * Directory helpers moved to libraries.
+ * Account activity overview added to profile module.
+ * Replaced Slimbox2 with prettyPhoto.
+ * Renamed subdirectories includes and system to banshee.
+ * Renamed post_data library to validator.
+ * Renamed onload_javascript() to run_javascript().
+ * Removed MySQL driver, use MySQLi instead.
+ * Removed php.js.
+ * Small improvements.
+
+ -- Hugo Leisink <hugo@leisink.net> Tue, 30 Apr 2013 11:55:42 +0200
+
+banshee (3.7) stable; urgency=low
+
+ * Global button style. Replaced many buttons with anchor tag.
+ * Renewed secure cookie and AES256 library.
+ * jQuery updated to 1.8.3, jQuery UI updated to 1.9.1.
+ * CKEditor updated to 4.0.
+ * Inline image support in e-mail library.
+ * Small improvements.
+
+ -- Hugo Leisink <hugo@leisink.net> Mon, 24 Dec 2012 14:29:17 +0100
+
banshee (3.6) stable; urgency=low
* Removed SlimStat because there is no active development and Piwik
@@ -14,7 +50,7 @@ banshee (3.5) stable; urgency=low
* Photos are stored on disk instead of in database.
* Default password hash function changed from MD5 to SHA256.
* Several improvements and small bugfixes.
-
+
-- Hugo Leisink <hugo@leisink.net> Thu, 5 Jul 2012 22:11:43 +0200
banshee (3.4) stable; urgency=low
@@ -88,7 +124,7 @@ banshee (2.6) stable; urgency=low
* Session Manager module added.
* Separate file for settings class. Other stuff moved to
libraries/configuration.php
- * Error handling functions moved from libraries/output.php to
+ * Error handling functions moved from libraries/output.php to
libraries/error.php.
* Chunked content encoding support added to HTTP library.
* JSON output type added.
View
35 INSTALL
@@ -1,35 +0,0 @@
-CONFIGURE YOUR WEBSERVER
-=========================
-Use the directory 'public' as the webroot directory and allow PHP execution. If you use the Hiawatha webserver, you can use the following UrlToolkit configuration:
-
-UrlToolkit {
- ToolkitID = banshee
- RequestURI isfile Return
- Match ^/(css|files|images|js)($|/) Return
- Match ^/(favicon.ico|robots.txt)$ Return
- Match .*\?(.*) Rewrite /index.php?$1
- Match .* Rewrite /index.php
-}
-
-For Apache, there is a .htaccess file in the 'public' directory which contains the URL rewriting rules.
-
-
-CONFIGURE PHP
-==============
-Banshee needs PHP's MySQL and XSL module. Use the following PHP settings:
- cgi.fix_pathinfo = 0 (when using FastCGI PHP), 1 (otherwise)
- cgi.rfc2616_headers = 1 (when using Hiawatha), 0 (when using Apache)
- register_globals = Off
- allow_url_include = Off
-
-
-CONFIGURE YOUR DATABASE
-========================
-Change the database settings in 'settings/website.conf' and run the script 'database/setup_database'. This will create a MySQL user, a MySQL database and initialize the created database.
-
-The installed database already contains two users: 'admin' and 'user'. Both have the password 'banshee'.
-
-
-CONFIGURE BANSHEE
-==================
-Go to the Settings page in the CMS and replace the present e-mail addresses with your own.
View
12 LICENSE
@@ -16,14 +16,14 @@ In no event shall the author of Banshee be liable for any bug in this software.
The following files are not part of the Banshee PHP framework:
- CKeditor : public/js/ckeditor/*
- - The DHTML Calendar: public/js/calendar*.js
- public/css/includes/calendar.css
+ - DataTables : public/js/banshee/jquery.datatables.js
+ - The DHTML Calendar: public/js/banshee/calendar*.js
- FPDF : libraries/fpdf.php
- jQuery : public/js/jquery/*
- - MD5 javascript : public/js/md5.js
- - PHP.js : public/js/php.js
- - SHA1 javascript : public/js/sha1.js
- - SHA256 javascript : public/js/sha256.js
+ - MD5 javascript : public/js/banshee/md5.js
+ - prettyPhoto : public/js/banshee/jquery.prettyphoto.js
+ - SHA1 javascript : public/js/banshee/sha1.js
+ - SHA256 javascript : public/js/banshee/sha256.js
- ZIP library : libraries/zipfile.php
Look for copyright messages inside those files.
View
1 README.md
@@ -29,7 +29,6 @@ Banshee needs PHP's MySQL and XSL module. Use the following PHP settings:
magic_quotes_gpc = Off
register_globals = Off
-
Configure your database
-----------------------
Change the database settings in 'settings/website.conf' and run the script 'database/setup_database'. This will create a MySQL user, a MySQL database and initialize the created database.
View
7 controllers/admin.php
@@ -31,7 +31,8 @@ class admin_controller extends controller {
"System" => array(
"Logging" => array("admin/logging", "logging.png"),
"Action log" => array("admin/action", "action.png"),
- "Settings" => array("admin/settings", "settings.png")));
+ "Settings" => array("admin/settings", "settings.png"),
+ "API test" => array("admin/apitest", "apitest.png")));
public function execute() {
if (($this->user->id == 1) && ($this->user->password == "c10b391ff5e75af6ee8469539e6a5428f09eff7e693d6a8c4de0e5525cd9b287")) {
@@ -42,6 +43,10 @@ public function execute() {
$this->output->add_system_warning("Don't forget to change the secret_website_code setting.");
}
+ if (is_true(DEBUG_MODE)) {
+ $this->output->add_system_warning("Website is running in debug mode. Set DEBUG_MODE in settings/website.conf to 'no'.");
+ }
+
if (is_false(MULTILINGUAL)) {
unset($this->menu["Content"]["Languages"]);
}
View
12 controllers/admin/agenda.php
@@ -16,17 +16,19 @@ public function show_agenda_overview() {
}
public function show_appointment_form($appointment) {
+ $this->output->add_css("banshee/calendar.css");
+
$this->output->add_javascript("ckeditor/ckeditor.js");
- $this->output->add_javascript("start_ckeditor.js");
- $this->output->add_javascript("calendar.js");
- $this->output->add_javascript("calendar-en.js");
- $this->output->add_javascript("calendar-setup.js");
+ $this->output->add_javascript("banshee/start_ckeditor.js");
+ $this->output->add_javascript("banshee/calendar.js");
+ $this->output->add_javascript("banshee/calendar-en.js");
+ $this->output->add_javascript("banshee/calendar-setup.js");
$this->output->add_javascript("admin/agenda.js");
$appointment = $this->model->appointment_db_to_form($appointment);
$this->output->record($appointment, "edit");
- $this->output->onload_javascript("setup_calendars('".$appointment["all_day"]."')");
+ $this->output->run_javascript("setup_calendars('".$appointment["all_day"]."')");
}
public function execute() {
View
43 controllers/admin/apitest.php
@@ -0,0 +1,43 @@
+<?php
+ class admin_apitest_controller extends controller {
+ private function show_form($data) {
+ $this->output->open_tag("form");
+
+ $methods = array("GET", "POST", "PUT", "DELETE");
+ $this->output->open_tag("methods");
+ foreach ($methods as $method) {
+ $this->output->add_tag("method", $method);
+ }
+ $this->output->close_tag();
+
+ $types = array("ajax", "xml", "json");
+ $this->output->open_tag("types");
+ foreach ($types as $type) {
+ $this->output->add_tag("type", $type);
+ }
+ $this->output->close_tag();
+
+ $this->output->record($data);
+
+ $this->output->close_tag();
+ }
+
+ public function execute() {
+ if ($_SERVER["REQUEST_METHOD"] == "POST") {
+ if (($result = $this->model->request_result($_POST)) === false) {
+ $this->output->add_message("Request error.");
+ } else {
+ if ($result["status"] != 200) {
+ $this->output->add_message("Request result: %s", $result["status"]);
+ }
+ $this->output->add_tag("result", $result["body"]);
+ }
+
+ $this->show_form($_POST);
+ } else {
+ $data = array("url" => "/");
+ $this->show_form($data);
+ }
+ }
+ }
+?>
View
6 controllers/admin/collection.php
@@ -7,7 +7,7 @@ private function show_collection_overview() {
}
$this->output->open_tag("overview");
-
+
$this->output->open_tag("collections");
foreach ($collections as $collection) {
$this->output->record($collection, "collection");
@@ -61,7 +61,7 @@ public function execute() {
} else {
$this->show_collection_overview();
}
- } else {
+ } else {
/* Update collection
*/
if ($this->model->update_collection($_POST) == false) {
@@ -70,7 +70,7 @@ public function execute() {
$this->show_collection_overview();
}
}
- } else if ($_POST["submit_button"] == "Delete collection") {
+ } else if ($_POST["submit_button"] == "Delete collection") {
/* Delete collection
*/
if ($this->model->delete_collection($_POST["id"]) == false) {
View
2 controllers/admin/dictionary.php
@@ -32,7 +32,7 @@ private function show_word_form($word) {
}
$this->output->add_javascript("ckeditor/ckeditor.js");
- $this->output->add_javascript("start_ckeditor.js");
+ $this->output->add_javascript("banshee/start_ckeditor.js");
$this->output->record($word, "edit");
}
View
10 controllers/admin/faq.php
@@ -1,5 +1,5 @@
<?php
- require_once("../helpers/output.php");
+ require_once("../libraries/helpers/output.php");
class admin_faq_controller extends controller {
public function show_faq_overview() {
@@ -12,7 +12,7 @@ public function show_faq_overview() {
}
$this->output->open_tag("overview");
-
+
$this->output->open_tag("sections");
foreach ($sections as $section) {
$this->output->add_tag("section", $section["label"], array("id" => $section["id"]));
@@ -40,7 +40,7 @@ public function show_faq_form($faq) {
}
$this->output->add_javascript("ckeditor/ckeditor.js");
- $this->output->add_javascript("start_ckeditor.js");
+ $this->output->add_javascript("banshee/start_ckeditor.js");
$this->output->open_tag("edit");
@@ -88,10 +88,10 @@ public function execute() {
*/
if ($this->model->delete_faq($_POST["id"]) == false) {
$this->output->add_message("Error while deleting F.A.Q.");
- show_faq_form($_POST);
+ $this->show_faq_form($_POST);
} else {
$this->user->log_action("faq %d deleted", $_POST["id"]);
- show_faq_overview();
+ $this->show_faq_overview();
}
} else {
$this->show_faq_overview();
View
2 controllers/admin/file.php
@@ -70,7 +70,7 @@ public function execute() {
foreach ($files["files"] as $filename) {
$file = array(
"name" => $filename,
- "link" => "/".$directory."/".urlencode($filename),
+ "link" => "/".$directory."/".rawurlencode($filename),
"size" => $this->model->get_file_size($directory."/".$filename),
"delete" => "yes");
$this->output->record($file, "file");
View
2 controllers/admin/forum.php
@@ -1,5 +1,5 @@
<?php
- require_once("../helpers/output.php");
+ require_once("../libraries/helpers/output.php");
class admin_forum_controller extends controller {
private function show_message_overview() {
View
13 controllers/admin/forum/section.php
@@ -0,0 +1,13 @@
+<?php
+ class admin_forum_section_controller extends tablemanager_controller {
+ protected $name = "Forum section";
+ protected $pathinfo_offset = 3;
+ protected $back = "admin/forum";
+ protected $icon = null;
+ protected $page_size = 25;
+ protected $pagination_links = 7;
+ protected $pagination_step = 1;
+ protected $foreign_null = "---";
+ protected $browsing = "pagination";
+ }
+?>
View
2 controllers/admin/guestbook.php
@@ -1,5 +1,5 @@
<?php
- require_once("../helpers/output.php");
+ require_once("../libraries/helpers/output.php");
class admin_guestbook_controller extends controller {
public function execute() {
View
83 controllers/admin/menu.php
@@ -1,74 +1,55 @@
<?php
class admin_menu_controller extends controller {
- private $url = null;
+ private function show_menu($menu) {
+ $this->output->open_tag("branch");
+ foreach ($menu as $item) {
+ $this->output->open_tag("item");
+ $this->output->add_tag("text", $item["text"]);
+ $this->output->add_tag("link", $item["link"]);
+ if (isset($item["submenu"])) {
+ $this->show_menu($item["submenu"]);
+ }
+ $this->output->close_tag();
+ }
+ $this->output->close_tag();
+ }
- private function show_menu_form($menu_id, $menu) {
+ private function show_menu_form($menu) {
$this->output->add_javascript("jquery/jquery.js");
- $this->output->add_javascript("jquery/jquery.ui.core.js");
- $this->output->add_javascript("jquery/jquery.ui.widget.js");
- $this->output->add_javascript("jquery/jquery.ui.mouse.js");
- $this->output->add_javascript("jquery/jquery.ui.sortable.js");
+ $this->output->add_javascript("jquery/jquery-ui.js");
+ $this->output->add_javascript("banshee/jquery.menueditor.js");
$this->output->add_javascript("admin/menu.js");
- $this->output->open_tag("edit");
-
- if (($parent = $this->model->get_menu($menu_id)) != false) {
- $this->output->add_tag("parent", $parent["text"], array("id" => $parent["parent_id"]));
- }
+ $this->output->add_css("banshee/menueditor.css");
- $this->output->open_tag("menu", array("id" => $menu_id));
- $max_id = 0;
- foreach ($menu as $item) {
- unset($item["parent_id"]);
- $this->output->record($item, "item");
- if ($item["id"] > $max_id) {
- $max_id = $item["id"];
- }
- }
- $this->output->close_tag();
- $this->output->add_tag("max_menu_id", $max_id + 1);
+ $this->output->open_tag("edit");
+ $this->show_menu($menu);
$this->output->close_tag();
-
- if (count($menu) == 0) {
- $this->output->onload_javascript("add_item('editmenu', 1)");
- }
}
public function execute() {
- $this->url = array("url" => "admin/menu");
-
if ($_SERVER["REQUEST_METHOD"] == "POST") {
/* Update menu
*/
- if ($this->model->menu_oke($_POST) == false) {
- foreach ($_POST["menu"] as $id => $value) {
- $_POST["menu"][$id]["id"] = $id;
- }
- $this->show_menu_form($_POST["menu_id"], $_POST["menu"]);
- } else if ($this->model->update_menu($_POST["menu_id"], $_POST["menu"]) == false) {
- $this->output->add_tag("result", "Error while updating menu.", $url);
+ if ($this->model->menu_oke($_POST["menu"]) == false) {
+ $this->show_menu_form($_POST["menu"]);
+ } else if ($this->model->update_menu($_POST["menu"]) == false) {
+ $this->output->add_tag("result", "Error while updating menu.");
} else {
- $this->output->add_tag("result", "The menu has been updated.", array("url" => "admin/menu/".$_POST["menu_id"]));
- $this->output->remove_from_cache("menu");
- $this->user->log_action("menu %d updated", $_POST["menu_id"]);
+ $this->output->add_tag("result", "The menu has been updated.");
+ $this->user->log_action("menu updated");
header("X-Hiawatha-Cache-Remove: all");
+
+ $cache = new cache($this->db, "menu");
+ $cache->store("last_updated", time(), 365 * DAY);
}
} else {
/* Show menu
*/
- if (valid_input($this->page->pathinfo[2], VALIDATE_NUMBERS, VALIDATE_NONEMPTY) == false) {
- $menu_id = 0;
- } else if (($menu_id = (int)$this->page->pathinfo[2]) != 0) {
- if (($parent = $this->model->get_menu($menu_id)) == false) {
- $this->output->add_tag("result", "Menu not found.", $url);
- return;
- }
- }
-
- if (($menu = $this->model->get_menu_items($menu_id)) === false) {
- $this->output->add_tag("result", "Database error!", $url);
- } else {
- $this->show_menu_form($menu_id, $menu);
+ if (($menu = $this->model->get_menu()) === false) {
+ $this->output->add_tag("result", "Error loading menu.");
+ } else {
+ $this->show_menu_form($menu);
}
}
}
View
15 controllers/admin/page.php
@@ -4,7 +4,9 @@ private function show_page_overview() {
if (($pages = $this->model->get_pages()) === false) {
$this->output->add_tag("result", "Database error.");
} else {
- $this->output->open_tag("overview");
+ list($webserver) = explode(" ", $_SERVER["SERVER_SOFTWARE"], 2);
+
+ $this->output->open_tag("overview", array("hiawatha" => show_boolean($webserver == "Hiawatha")));
$this->output->open_tag("pages");
foreach ($pages as $page) {
$page["visible"] = show_boolean($page["visible"]);
@@ -15,7 +17,7 @@ private function show_page_overview() {
}
}
- private function show_page_form($page) {
+ private function show_page_form($page) {
global $supported_languages;
$this->output->set_xslt_parameter("admin_role_id", ADMIN_ROLE_ID);
@@ -30,7 +32,7 @@ private function show_page_form($page) {
}
$this->output->add_javascript("ckeditor/ckeditor.js");
- $this->output->add_javascript("start_ckeditor.js");
+ $this->output->add_javascript("banshee/start_ckeditor.js");
$this->output->open_tag("edit");
@@ -105,7 +107,8 @@ public function execute() {
}
$this->user->log_action("page %s updated", $name);
- if ($this->settings->hiawatha_cache_time > 0) {
+ list($webserver) = explode(" ", $_SERVER["SERVER_SOFTWARE"], 2);
+ if (($this->settings->hiawatha_cache_time > 0) && ($webserver == "Hiawatha")) {
if ($_POST["url"] == "/".$this->settings->start_page) {
header("X-Hiawatha-Cache-Remove: all");
} else {
@@ -127,6 +130,10 @@ public function execute() {
$this->user->log_action("page %s deleted", $url);
$this->show_page_overview();
}
+ } else if ($_POST["submit_button"] == "Clear Hiawatha cache") {
+ header("X-Hiawatha-Cache-Remove: all");
+ $this->output->add_system_message("Hiawatha webserver cache cleared.");
+ $this->show_page_overview();
} else {
$this->show_page_overview();
}
View
4 controllers/admin/photos.php
@@ -41,9 +41,9 @@ public function execute() {
/* Work-around for the most fucking annoying crap browser in the world: IE
*/
if ($_SERVER["REQUEST_METHOD"] == "POST") {
- foreach ($_FILES as &$file) {
+ foreach ($_FILES as $i => $file) {
if ($file["type"] == "image/pjpeg") {
- $file["type"] = "image/jpeg";
+ $files[$i]["type"] = "image/jpeg";
}
}
View
10 controllers/admin/poll.php
@@ -28,11 +28,13 @@ private function show_poll_form($poll) {
$params = array("id" => $poll["id"]);
}
- $this->output->add_javascript("calendar.js");
- $this->output->add_javascript("calendar-en.js");
- $this->output->add_javascript("calendar-setup.js");
+ $this->output->add_css("banshee/calendar.css");
+
+ $this->output->add_javascript("banshee/calendar.js");
+ $this->output->add_javascript("banshee/calendar-en.js");
+ $this->output->add_javascript("banshee/calendar-setup.js");
$this->output->add_javascript("admin/poll.js");
- $this->output->onload_javascript("setup_calendars()");
+ $this->output->run_javascript("setup_calendars()");
$this->output->open_tag("edit");
View
9 controllers/admin/role.php
@@ -46,16 +46,19 @@ public function show_role_form($role) {
}
$this->output->close_tag();
- $read_write = oproar_pages();
+ $rorw_pages = private_rorw_pages();
/* Roles
*/
$this->output->add_tag("role", $role["name"], $params);
$this->output->open_tag("pages");
foreach ($pages as $page) {
+ if (($value = $role[$page]) == null) {
+ $value = 0;
+ }
$this->output->add_tag("page", $page, array(
- "type" => in_array($page, $read_write) ? "select" : "checkbox",
- "value" => $role[$page]));
+ "type" => in_array($page, $rorw_pages) ? "select" : "checkbox",
+ "value" => $value));
}
$this->output->close_tag();
View
7 controllers/admin/settings.php
@@ -8,5 +8,12 @@ class admin_settings_controller extends tablemanager_controller {
protected $pagination_links = 7;
protected $pagination_step = 1;
protected $foreign_null = "---";
+
+ protected function handle_submit() {
+ parent::handle_submit();
+
+ $cache = new cache($this->db, "settings");
+ $cache->store("last_updated", time(), 365 * DAY);
+ }
}
?>
View
10 controllers/admin/user.php
@@ -63,11 +63,11 @@ private function show_user_form($user) {
$this->output->add_tag("result", "You are not allowed to edit this user.");
return;
}
- }
+ }
- $this->output->add_javascript(PASSWORD_HASH.".js");
+ $this->output->add_javascript("banshee/".PASSWORD_HASH.".js");
$this->output->add_javascript("admin/user.js");
- $this->output->onload_javascript("hash = window['".PASSWORD_HASH."'];");
+ $this->output->run_javascript("hash = window['".PASSWORD_HASH."'];");
$this->output->open_tag("edit");
@@ -101,7 +101,7 @@ private function show_user_form($user) {
$checked = in_array($role["id"], $user["roles"]);
$enabled = ($this->user->id != $user["id"]) || ($role["id"] != ADMIN_ROLE_ID); /* Don't disable yourself */
-
+
$this->output->add_tag("role", $role["name"], array(
"id" => $role["id"],
"checked" => show_boolean($checked),
@@ -121,7 +121,7 @@ public function execute() {
$_POST["password"] = random_string(10);
$_POST["password_hashed"] = false;
}
- if (is_false($_POST["password_hashed"])) {
+ if (is_false($_POST["password_hashed"]) && ($_POST["password"] != "")) {
$_POST["plaintext"] = $_POST["password"];
$_POST["password"] = hash(PASSWORD_HASH, $_POST["password"].hash(PASSWORD_HASH, $_POST["username"]));
}
View
8 controllers/admin/weblog.php
@@ -1,5 +1,5 @@
<?php
- require_once("../helpers/output.php");
+ require_once("../libraries/helpers/output.php");
class admin_weblog_controller extends controller {
private function show_weblog_overview() {
@@ -33,7 +33,7 @@ private function show_weblog_overview() {
private function show_weblog_form($weblog) {
$this->output->add_javascript("ckeditor/ckeditor.js");
- $this->output->add_javascript("start_ckeditor.js");
+ $this->output->add_javascript("banshee/start_ckeditor.js");
$this->output->open_tag("edit");
@@ -55,7 +55,7 @@ private function show_weblog_form($weblog) {
if (($tags = $this->model->get_tags()) != false) {
foreach ($tags as $tag) {
$this->output->add_tag("tag", $tag["tag"], array(
- "id" => $tag["id"],
+ "id" => $tag["id"],
"selected" => show_boolean(in_array($tag["id"], $tagged))));
}
}
@@ -100,7 +100,7 @@ public function execute() {
if ($this->model->save_oke($_POST) == false) {
$this->show_weblog_form($_POST);
} else if (isset($_POST["id"]) == false) {
- /* Create weblog
+ /* Create weblog
*/
if ($this->model->create_weblog($_POST) == false) {
$this->output->add_message("Database error while creating weblog.");
View
2 controllers/system/error.php → controllers/banshee/error.php
@@ -1,5 +1,5 @@
<?php
- class system_error_controller extends controller {
+ class banshee_error_controller extends controller {
public function execute() {
header("Status: ".$this->page->http_code);
View
38 controllers/banshee/login.php
@@ -0,0 +1,38 @@
+<?php
+ class banshee_login_controller extends controller {
+ public function execute() {
+ $this->output->description = "Login";
+ $this->output->keywords = "login";
+ $this->output->title = "Login";
+
+ $this->output->add_javascript("banshee/".PASSWORD_HASH.".js");
+ $this->output->add_javascript("banshee/login.js");
+ $this->output->run_javascript("set_focus(); hash = window['".PASSWORD_HASH."'];");
+
+ $this->output->open_tag("login");
+ $this->output->add_tag("url", $_SERVER["REQUEST_URI"]);
+
+ if ($_SERVER["REQUEST_METHOD"] != "POST") {
+ $this->output->add_tag("bind");
+ } else {
+ $this->output->add_tag("username", $_POST["username"]);
+ if (is_true($_POST["bind_ip"])) {
+ $this->output->add_tag("bind");
+ }
+ }
+
+ $this->output->add_tag("remote_addr", $_SERVER["REMOTE_ADDR"]);
+ $this->output->add_tag("challenge", $_SESSION["challenge"]);
+
+ if ($_SERVER["REQUEST_METHOD"] == "POST") {
+ if (strpos($_POST["username"], "'") !== false) {
+ $this->output->add_message("Sorry, this application does not support SQL injection.");
+ } else {
+ $this->output->add_message("Login incorrect");
+ }
+ }
+
+ $this->output->close_tag();
+ }
+ }
+?>
View
8 controllers/system/page.php → controllers/banshee/page.php
@@ -1,5 +1,5 @@
<?php
- class system_page_controller extends controller {
+ class banshee_page_controller extends controller {
public function execute() {
if (($page = $this->model->get_page($this->page->url)) == false) {
$this->output->add_tag("website_error", 500);
@@ -8,7 +8,7 @@ public function execute() {
/* Page header
*/
- if (trim($page["description"]) != "") {
+ if (trim($page["description"]) != "") {
$this->output->description = $page["description"];
}
if (trim($page["keywords"]) != "") {
@@ -22,9 +22,7 @@ public function execute() {
$this->output->set_layout($page["layout"]);
- if (($this->settings->hiawatha_cache_time > 0) && (isset($_SESSION["user_switch"]) == false) && is_false(DEBUG_MODE)) {
- header("X-Hiawatha-Cache: ".$this->settings->hiawatha_cache_time);
- }
+ $this->output->allow_hiawatha_cache();
/* Page content
*/
View
6 controllers/system/sso.php → controllers/banshee/sso.php
@@ -1,5 +1,5 @@
<?php
- class system_sso_controller extends controller {
+ class banshee_sso_controller extends controller {
/* Get login key of user at remote website
*/
private function website($index) {
@@ -63,14 +63,14 @@ private function image() {
print "\x00\x02\x00\x2c\x00\x00\x00\x00\x01\x00";
print "\x01\x00\x00\x02\x02\x4c\x01\x00\x3b";
- $this->output->disabled = true;
+ $this->output->disable();
}
/* Execute
*/
public function execute() {
if ($this->page->ajax_request == false) {
- $this->output->disabled = true;
+ $this->output->disable();
}
switch ($this->page->pathinfo[2]) {
View
5 controllers/captcha.php
@@ -1,6 +1,4 @@
<?php
- require("../libraries/captcha.php");
-
class captcha_controller extends controller {
public function execute() {
$captcha = new captcha;
@@ -9,8 +7,7 @@ public function execute() {
}
$captcha->to_output();
-
- $this->output->disabled = true;
+ $this->output->disable();
}
}
?>
View
5 controllers/demos/ajax.php
@@ -3,7 +3,6 @@ class demos_ajax_controller extends controller {
private function ajax_request() {
if (isset($_REQUEST["answer"])) {
$result = $_REQUEST["answer"] == 3 ? "correct" : "wrong";
- print "oke";
$this->output->add_tag("result", $result);
} else if (isset($_REQUEST["records"])) {
if (($records = $_REQUEST["records"]) > 10) {
@@ -30,9 +29,9 @@ public function execute() {
return;
}
- $this->output->add_javascript("ajax.js");
+ $this->output->add_javascript("banshee/ajax.js");
$this->output->add_javascript("demos/ajax.js");
- $this->output->onload_javascript("set_focus()");
+ $this->output->run_javascript("set_focus()");
}
}
?>
View
2 controllers/demos/banshee_website.php
@@ -9,7 +9,7 @@ public function execute() {
}
$this->output->add_tag("message", "Login successful.");
-
+
if (($result = $website->GET("/admin/user/1")) == false) {
$this->output->add_tag("message", "Error fetching webpage.");
return;
View
12 controllers/demos/calendar.php
@@ -3,14 +3,16 @@ class demos_calendar_controller extends controller {
public function execute() {
$this->output->title = "Calendar demo";
- if ($_SERVER["REQUEST_METHOD"] == "POST") {
+ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$this->output->add_tag("result", $_POST["date"]);
} else {
- $this->output->add_javascript("calendar.js");
- $this->output->add_javascript("calendar-en.js");
- $this->output->add_javascript("calendar-setup.js");
+ $this->output->add_css("banshee/calendar.css");
+
+ $this->output->add_javascript("banshee/calendar.js");
+ $this->output->add_javascript("banshee/calendar-en.js");
+ $this->output->add_javascript("banshee/calendar-setup.js");
$this->output->add_javascript("demos/calendar.js");
- $this->output->onload_javascript("setup_calendar()");
+ $this->output->run_javascript("setup_calendar()");
$this->output->open_tag("edit");
$this->output->add_tag("date", date("Y-m-d H:i:s"));
View
3 controllers/demos/captcha.php
@@ -4,7 +4,8 @@ public function execute() {
$this->output->title = "Captcha demo";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
- $this->output->add_tag("valid", show_boolean(valid_captcha_code($_POST["code"])));
+ $valid = captcha::valid_code($_POST["code"]);
+ $this->output->add_tag("valid", show_boolean($valid));
}
}
}
View
38 controllers/demos/ckeditor.php
@@ -1,19 +1,19 @@
-<?php
- class demos_ckeditor_controller extends controller {
- public function execute() {
- $this->output->title = "CKEditor demo";
-
- if ($_SERVER["REQUEST_METHOD"] == "POST") {
- $this->output->open_tag("result");
- $this->output->add_tag("editor", $_POST["editor"]);
- $this->output->close_tag();
- } else {
- $this->output->add_javascript("ckeditor/ckeditor.js");
- $this->output->add_javascript("demos/ckeditor.js");
- $this->output->onload_javascript("start_ckeditor()");
-
- $this->output->add_tag("edit");
- }
- }
- }
-?>
+<?php
+ class demos_ckeditor_controller extends controller {
+ public function execute() {
+ $this->output->title = "CKEditor demo";
+
+ if ($_SERVER["REQUEST_METHOD"] == "POST") {
+ $this->output->open_tag("result");
+ $this->output->add_tag("editor", $_POST["editor"]);
+ $this->output->close_tag();
+ } else {
+ $this->output->add_javascript("ckeditor/ckeditor.js");
+ $this->output->add_javascript("banshee/start_ckeditor.js");
+ $this->output->run_javascript("start_ckeditor()");
+
+ $this->output->add_tag("edit");
+ }
+ }
+ }
+?>
View
2 controllers/demos/googlemaps.php
@@ -16,7 +16,7 @@ private function show_static_map() {
$google_map->show_static_map(640, 350);
- $this->output->disabled = true;
+ $this->output->disable();
}
public function execute() {
View
3 controllers/demos/openstreetmap.php
@@ -12,11 +12,10 @@ private function show_static() {
$openstreetmap->set_center("Brussel, BE");
$openstreetmap->zoom = 6;
- $openstreetmap->type = "osmarender";
$openstreetmap->show_static_map(640, 350);
- $this->output->disabled = true;
+ $this->output->disable();
}
public function execute() {
View
9 controllers/demos/parameter.php
@@ -1,9 +0,0 @@
-<?php
- class demos_parameter_controller extends controller {
- public function execute() {
- $this->output->title = "Parameter inside URL";
-
- $this->output->add_tag("parameter", $this->page->pathinfo[1]);
- }
- }
-?>
View
2 controllers/demos/pdf.php
@@ -13,7 +13,7 @@ public function execute() {
$pdf->Link(10, 30, 40, 10, "/demos");
$pdf->Output();
- $this->output->disabled = true;
+ $this->output->disable();
}
}
?>
View
2 controllers/demos/poll.php
@@ -3,7 +3,7 @@ class demos_poll_controller extends controller {
public function execute() {
$this->output->title = "Poll demo";
- $poll = new poll($this->db, $this->settings, $this->output);
+ $poll = new poll($this->db, $this->output);
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$poll->vote($_POST["vote"]);
View
15 controllers/demos/posting.php
@@ -6,17 +6,18 @@ public function execute() {
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$input = $_POST["input"];
- if (message_is_spam($input) == false) {
- $output = $input;
- $output = unescaped_output($output);
- $output = translate_bbcodes($output);
- $output = translate_smilies($output);
+ $message = new message($input);
+ if ($message->is_spam == false) {
+ $message->unescaped_output();
+ $message->translate_bbcodes();
+ $message->translate_smilies();
- $this->output->add_tag("input", $input);
- $this->output->add_tag("output", $output);
+ $this->output->add_tag("output", $message->content);
} else {
$this->output->add_message("Message seen as spam.");
}
+
+ $this->output->add_tag("input", $input);
}
}
}
View
1 controllers/demos/tablemanager.php
@@ -5,5 +5,6 @@ class demos_tablemanager_controller extends tablemanager_controller {
protected $back = "demos";
protected $icon = "page.png";
protected $log_column = "line";
+ protected $browsing = "pagination";
}
?>
View
4 controllers/demos/validation.php
@@ -18,9 +18,9 @@ class demos_validation_controller extends controller {
public function execute() {
if ($_SERVER["REQUEST_METHOD"] == "POST") {
- $input = new post_data($this->output);
+ $validator = new validator($this->output);
- if ($input->validate($this->pattern)) {
+ if ($validator->execute($this->pattern)) {
$this->output->add_system_message("Data validation oke.");
}
}
View
2 controllers/dictionary.php
@@ -9,7 +9,7 @@ private function show_letters($letters, $first_letter) {
}
public function execute() {
- if (($letters = $this->model->get_first_letters()) === false) {
+ if (($letters = $this->model->get_first_letters()) === false) {
$this->output->add_tag("result", "Database error");
return;
}
View
14 controllers/faq.php
@@ -7,7 +7,7 @@ public function execute() {
$this->output->add_tag("result", "Database error.");
return;
}
-
+
if (($faqs = $this->model->get_all_faqs()) === false) {
$this->output->add_tag("result", "Database error.");
return;
@@ -16,26 +16,18 @@ public function execute() {
$this->output->add_javascript("jquery/jquery.js");
$this->output->open_tag("overview");
-
+
$this->output->open_tag("sections");
foreach ($sections as $section) {
$this->output->add_tag("section", $section["label"], array("id" => $section["id"]));
}
$this->output->close_tag();
$this->output->open_tag("faqs");
- $section_id = 0;
$number = 1;
foreach ($faqs as $faq) {
- if ($section_id != $faq["section_id"]) {
- $section_id = $faq["section_id"];
- #$number = 1;
- }
-
- $faq["question"] = $number.". ".$faq["question"];
+ $faq["question"] = ($number++).". ".$faq["question"];
$this->output->record($faq, "faq");
-
- $number++;
}
$this->output->close_tag();
View
17 controllers/forum.php
@@ -41,7 +41,7 @@ private function show_forum($forum_id) {
$this->output->add_tag("title", $forum["title"]);
$this->output->open_tag("topics");
- foreach ($forum["topics"] as $topic) {
+ foreach ($forum["topics"] as $topic) {
if ($this->user->logged_in) {
$topic["unread"] = show_boolean($this->model->last_topic_view($topic["id"]) < $topic["timestamp"]);
}
@@ -59,7 +59,7 @@ private function show_forum($forum_id) {
private function show_smilies() {
$smilies = config_file("smilies");
- $this->output->open_tag("smilies");
+ $this->output->open_tag("smilies");
foreach ($smilies as $smiley) {
$smiley = explode("\t", chop($smiley));
$text = array_shift($smiley);
@@ -98,9 +98,14 @@ private function show_topic($topic_id, $response = null) {
}
$message["timestamp"] = date("j F Y, H:i", $message["timestamp"]);
$message["content"] = preg_replace("/\[(config|code|quote)\]([\r\n]*)/", "[$1]", $message["content"]);
- $message["content"] = unescaped_output($message["content"]);
- $message["content"] = translate_bbcodes($message["content"]);
- $message["content"] = translate_smilies($message["content"]);
+
+ $post = new message($message["content"]);
+ $post->unescaped_output();
+ $post->translate_bbcodes();
+ $post->translate_smilies();
+ $message["content"] = $post->content;
+ unset($post);
+
$this->output->record($message, "message", array("moderate" => show_boolean($moderate)));
}
@@ -151,7 +156,7 @@ public function execute() {
/* Show topic
*/
$this->show_topic($this->page->pathinfo[2]);
- } else if (valid_input($this->page->pathinfo[1], VALIDATE_NUMBERS, VALIDATE_NONEMPTY)) {
+ } else if (valid_input($this->page->pathinfo[1], VALIDATE_NUMBERS, VALIDATE_NONEMPTY)) {
if ($this->page->pathinfo[2] == "new") {
/* Start new topic
*/
View
6 controllers/guestbook.php
@@ -13,9 +13,6 @@ public function execute() {
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if ($this->model->message_oke($_POST) == false) {
$this->show_guestbook_form($_POST);
- } else if (message_is_spam($_POST["message"])) {
- $this->output->add_message("Message seen as spam.");
- $this->show_guestbook_form($_POST);
} else if ($this->model->save_message($_POST) == false) {
$this->output->add_message("Database errors while saving message.");
$this->show_guestbook_form($_POST);
@@ -38,7 +35,8 @@ public function execute() {
foreach ($guestbook as $item) {
$item["timestamp"] = date("j F Y, H:i", $item["timestamp"]);
- $item["message"] = unescaped_output($item["message"]);
+ $message = new message($item["message"]);
+ $item["message"] = $message->unescaped_output();
unset($item["ip_address"]);
$this->output->record($item, "item");
}
View
39 controllers/login.php
@@ -1,39 +0,0 @@
-<?php
- class login_controller extends controller {
- public function execute() {
- if ($this->user->logged_in == false) {
- $this->output->description = "Login";
- $this->output->keywords = "login";
- $this->output->title = "Login";
-
- $this->output->add_javascript(PASSWORD_HASH.".js");
- $this->output->add_javascript("login.js");
- $this->output->onload_javascript("set_focus(); hash = window['".PASSWORD_HASH."'];");
-
- $this->output->open_tag("login");
-
- if (($url = $_SERVER["REQUEST_URI"]) == "/".LOGIN_MODULE) {
- $url = "/".$this->settings->page_after_login;
- }
- $this->output->add_tag("url", $url);
-
- if ($_SERVER["REQUEST_METHOD"] != "POST") {
- $this->output->add_tag("bind");
- } else if (is_true($_POST["bind_ip"])) {
- $this->output->add_tag("bind");
- }
-
- $this->output->add_tag("remote_addr", $_SERVER["REMOTE_ADDR"]);
- $this->output->add_tag("challenge", $_SESSION["challenge"]);
-
- if ($_SERVER["REQUEST_METHOD"] == "POST") {
- $this->output->add_message("Login incorrect");
- }
-
- $this->output->close_tag();
- } else {
- $this->output->add_tag("result", "You are already logged in.", array("url" => $this->settings->page_after_login));
- }
- }
- }
-?>
View
57 controllers/mailbox.php
@@ -1,7 +1,9 @@
<?php
class mailbox_controller extends controller {
- private function show_mails($mails) {
- $this->output->open_tag("mailbox");
+ private $title = "Mailbox";
+
+ private function show_mails($mails, $column) {
+ $this->output->open_tag("mailbox", array("column" => $column));
foreach ($mails as $mail) {
$mail["subject"] = truncate_text($mail["subject"], 55);
$mail["timestamp"] = date_string("l, j F Y H:i:s", $mail["timestamp"]);
@@ -11,27 +13,41 @@ private function show_mails($mails) {
$this->output->close_tag();
}
- private function show_mailbox() {
- if (($mails = $this->model->get_mailbox()) === false) {
+ private function show_inbox() {
+ $this->title = "Inbox";
+
+ if (($mails = $this->model->get_inbox()) === false) {
$this->output->add_tag("result", "Error reading mailbox.");
} else {
- $this->show_mails($mails);
- $this->output->add_tag("link", "Sentbox", array("url" => "/sent"));
+ $this->show_mails($mails, "From");
+ $this->output->add_tag("link", "Show sentbox", array("url" => "/sent"));
}
}
private function show_sentbox() {
+ $this->title = "Sentbox";
+
if (($mails = $this->model->get_sentbox()) === false) {
$this->output->add_tag("result", "Error reading sentbox.");
} else {
- $this->show_mails($mails);
- $this->output->add_tag("link", "Inbox", array("url" => ""));
+ $this->show_mails($mails, "To");
+ $this->output->add_tag("link", "Show inbox", array("url" => ""));
}
}
private function show_mail($mail) {
- $mail["message"] = unescaped_output($mail["message"]);
- $this->output->record($mail, "mail", array("actions" => show_boolean($mail["to_user_id"] == $this->user->id)));
+ $message = new message($mail["message"]);
+ $mail["message"] = $message->unescaped_output();
+
+ if ($mail["to_user_id"] == $this->user->id) {
+ $this->title = "Inbox";
+ } else {
+ $this->title = "Sentbox";
+ $back = "/sent";
+ }
+
+ $actions = show_boolean($mail["to_user_id"] == $this->user->id);
+ $this->output->record($mail, "mail", array("actions" => $actions, "back" => $back));
}
private function write_mail($mail) {
@@ -65,15 +81,25 @@ public function execute() {
$this->write_mail($_POST);
} else {
$this->output->add_system_message("Mail has been sent.");
- $this->show_mailbox();
+ $this->show_inbox();
+ $this->user->log_action("mail %d sent to %d", $this->db->last_insert_id, $_POST["to_user_id"]);
}
} else if ($_POST["submit_button"] == "Delete mail") {
/* Delete mail
*/
- if ($this->model->delete_mail($_POST["id"]) == false) {
+ if (($mail = $this->model->get_mail($_POST["id"])) === false) {
+ $this->output->add_system_warning("Unknown mail");
+ } else if ($this->model->delete_mail($_POST["id"]) == false) {
$this->output->add_system_warning("Error deleting mail.");
+ } else {
+ $this->user->log_action("mail %d deleted", $_POST["id"]);
+ }
+
+ if ($mail["to_user_id"] == $this->user->id) {
+ $this->show_inbox();
+ } else {
+ $this->show_sentbox();
}
- $this->show_mailbox();
}
} else if (valid_input($this->page->pathinfo[1], VALIDATE_NUMBERS, VALIDATE_NONEMPTY)) {
/* Show mail message
@@ -103,8 +129,11 @@ public function execute() {
} else {
/* Show mailbox
*/
- $this->show_mailbox();
+ $this->show_inbox();
}
+
+ $this->output->title = $this->title;
+ $this->output->add_tag("title", $this->title);
}
}
?>
View
2 controllers/news.php
@@ -1,5 +1,5 @@
<?php
- require_once("../helpers/output.php");
+ require_once("../libraries/helpers/output.php");
class news_controller extends controller {
public function execute() {
View
35 controllers/newsletter.php
@@ -1,12 +1,7 @@
<?php
class newsletter_controller extends controller {
- private function start_subscribing() {
- $info = array();
- $this->show_form($info);
- }
-
private function show_form($info) {
- $this->output->onload_javascript("document.getElementById('email').focus()");
+ $this->output->run_javascript("document.getElementById('email').focus()");
$this->output->add_tag("subscribe", $info["email"]);
}
@@ -20,35 +15,34 @@ public function execute() {
if ($this->model->info_oke($_POST) == false) {
$this->show_form($_POST);
} else if ($_POST["submit_button"] == "Subscribe") {
- if ($this->model->ask_confirmation($_POST, true) == false) {
+ if ($this->model->ask_confirmation($_POST, "subscribe") == false) {
$this->output->add_tag("result", "Subscribe error.");
} else {
$this->output->add_tag("result", "If the supplied e-mail address is not already on the newsletter list, an e-mail with a confirmation code will be sent to the supplied e-mail address. Please note that this code is only valid for ".$this->settings->newsletter_code_timeout.".", array("seconds" => "10"));
}
} else if ($_POST["submit_button"] == "Unsubscribe") {
- if ($this->model->ask_confirmation($_POST, false) == false) {
+ if ($this->model->ask_confirmation($_POST, "unsubscribe") == false) {
$this->output->add_tag("result", "Unsubscribe error.");
} else {
$this->output->add_tag("result", "If the supplied e-mail address is present on the newsletter list, an e-mail with a confirmation code will be sent to the supplied e-mail address. Please note that this code is only valid for ".$this->settings->newsletter_code_timeout.".", array("seconds" => "10"));
}
- } else {
- $this->start_subscribing();
+ } else {
+ $info = array();
+ $this->show_form($info);
}
- } else if (isset($_GET["code"])) {
+ } else if (isset($this->page->pathinfo[1])) {
/* (Un)subscribe to the newsletter
*/
- if (isset($_GET["subscribe"])) {
- if ($this->model->verify_code($_GET["subscribe"], $_GET["code"]) == false) {
- $this->output->add_tag("result", "The supplied confirmation code is invalid.");
- } else if ($this->model->subscribe($_GET["subscribe"]) == false) {
+ if (($data = $this->model->extract_data($this->page->pathinfo[1])) == false) {
+ $this->output->add_tag("result", "The supplied confirmation code is invalid.");
+ } else if ($data["mode"] == "subscribe") {
+ if ($this->model->subscribe($data["email"]) == false) {
$this->output->add_tag("result", "Error while adding your e-mail address to the ".$this->settings->head_title." newsletter list.");
} else {
$this->output->add_tag("result", "Your e-mail address has been added to the ".$this->settings->head_title." newsletter list.", array("seconds" => 10));
}
- } else if (isset($_GET["unsubscribe"])) {
- if ($this->model->verify_code($_GET["unsubscribe"], $_GET["code"]) == false) {
- $this->output->add_tag("result", "The supplied confirmation code is invalid.");
- } else if ($this->model->unsubscribe($_GET["unsubscribe"]) == false) {
+ } else if ($data["mode"] == "unsubscribe") {
+ if ($this->model->unsubscribe($data["email"]) == false) {
$this->output->add_tag("result", "Error while removing your e-mail address from the ".$this->settings->head_title." newsletter list.");
} else {
$this->output->add_tag("result", "Your e-mail address has been removed from the ".$this->settings->head_title." newsletter list.", array("seconds" => 10));
@@ -57,7 +51,8 @@ public function execute() {
} else {
/* Show form
*/
- $this->start_subscribing();
+ $info = array();
+ $this->show_form($info);
}
}
}
View
4 controllers/password.php
@@ -1,9 +1,9 @@
<?php
class password_controller extends controller {
private function show_password_form($key) {
- $this->output->add_javascript(PASSWORD_HASH.".js");