diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md new file mode 100644 index 0000000..bc4cd82 --- /dev/null +++ b/CONTRIBUTORS.md @@ -0,0 +1,19 @@ +# Contributors + +This is a list of people who have contributed to Sakura and also a list of the libraries that we use. + +## People + +| Name | Contribution | +| ---- | ------------ | +| Flashwave | Project leader and main developer. | +| MallocNull | Internal advice and pointing out my (Flashwave) stupidity. | +| kamilrakowski | Providing a huge pile of security advice and fixes. | +| RandomGuy | Mostly security advice as well. | + +## Libraries + +- [Twig](http://twig.sensiolabs.org/) +- [Parsedown](http://parsedown.org/) +- [PHPMailer](https://github.com/PHPMailer/PHPMailer) +- [PayPal API](https://paypal.com/) diff --git a/_sakura/changelog.json b/_sakura/changelog.json index a85d5ed..18e90a8 100644 --- a/_sakura/changelog.json +++ b/_sakura/changelog.json @@ -56,7 +56,8 @@ "20150830", "20150831", "20150902", - "20150903" + "20150903", + "20150904" ] @@ -2420,6 +2421,41 @@ "user": "Flashwave" } + ], + + "20150904": [ + + { + "type": "ADD", + "change": "Added Urls class.", + "user": "Flashwave" + }, + { + "type": "REM", + "change": "Removed credits page in favour of a markdown file in the root.", + "user": "Flashwave" + }, + { + "type": "REM", + "change": "Removed /contact symlink, use /p/contact instead.", + "user": "Flashwave" + }, + { + "type": "UPD", + "change": "Implemented urls.format across templates.", + "user": "Flashwave" + }, + { + "type": "UPD", + "change": "Moved infopage.php into index.php.", + "user": "Flashwave" + }, + { + "type": "REM", + "change": "Removed the special URL case for the messages section.", + "user": "Flashwave" + } + ] } diff --git a/_sakura/components/Urls.php b/_sakura/components/Urls.php new file mode 100644 index 0000000..8f20099 --- /dev/null +++ b/_sakura/components/Urls.php @@ -0,0 +1,88 @@ + ['/', '/'], + 'SITE_NEWS' => ['/news.php', '/news'], + 'SITE_NEWS_PAGE' => ['/news.php?page=%u', '/news/p%u'], + 'SITE_NEWS_POST' => ['/news.php?id=%u', '/news/%u'], + 'SITE_NEWS_RSS' => ['/news.php?xml=true', '/news.xml'], + 'SITE_SEARCH' => ['/search.php', '/search'], + 'SITE_MEMBERS' => ['/members.php', '/members'], + 'SITE_PREMIUM' => ['/support.php', '/support'], + 'SITE_FAQ' => ['/faq.php', '/faq'], + 'SITE_LOGIN' => ['/authenticate.php', '/login'], + 'SITE_REGISTER' => ['/authenticate.php', '/register'], + 'CHANGELOG' => ['/changelog.php', '/changelog'], + 'INFO_PAGE' => ['/index.php?p=%s', '/p/%s'], + 'AUTH_ACTION' => ['/authenticate.php', '/authenticate'], + + // Forums + 'FORUM_INDEX' => ['/index.php?forum=true', '/forum'], + 'FORUM_SUB' => ['/viewforum.php?f=%u', '/forum/%u'], + 'FORUM_THREAD' => ['/viewtopic.php?t=%u', '/forum/thread/%u'], + 'FORUM_POST' => ['/viewtopic.php?p=%u', '/forum/post/%u'], + 'FORUM_REPLY' => ['/posting.php?t=%u', '/forum/thread/%u/reply'], + 'FORUM_NEW_THREAD' => ['/posting.php?f=%u', '/forum/%u/new'], + 'FORUM_EDIT_POST' => ['/posting.php?p=%1$u&edit=%1$u', '/forum/post/%u/edit'], + 'FORUM_DELETE_POST' => ['/posting.php?p=%1$u&delete=%1$u', '/forum/post/%u/delete'], + 'FORUM_QUOTE_POST' => ['/posting.php?p=%1$u"e=%1$u', '/forum/post/%u/quote'], + + // Image serve references + 'IMAGE_AVATAR' => ['/imageserve.php?m=avatar&u=%u', '/a/%u'], + 'IMAGE_BACKGROUND' => ['/imageserve.php?m=background&u=%u', '/bg/%u'], + 'IMAGE_HEADER' => ['/imageserve.php?m=header&u=%u', '/u/%u/header'], + + // User actions + 'USER_LOGOUT' => ['/authenticate.php?mode=logout&time=%u&session=%s&redirect=%s', '/logout?mode=logout&time=%u&session=%s&redirect=%s'], + 'USER_PROFILE' => ['/profile.php?u=%s', '/u/%s'], + 'USER_REPORT' => ['/report.php?mode=user&u=%u', '/u/%u/report'], + + // Settings urls + 'SETTINGS_INDEX' => ['/settings.php', '/settings'], + 'SETTING_CAT' => ['/settings.php?cat=%s', '/settings/%s'], + 'SETTING_MODE' => ['/settings.php?cat=%s&mode=%s', '/settings/%s/%s'], + 'MESSAGES_INDEX' => ['/settings.php?cat=messages', '/messages'], + 'MESSAGES_MODE' => ['/settings.php?cat=messages&mode=%s', '/messages/%s'], + + // Friend Actions + 'FRIEND_ACTION' => ['/settings.php?friend-action=true', '/friends'], + 'FRIEND_ADD' => ['/settings.php?friend-action=true&add=%u&session=%s&time=%u&redirect=%s', '/friends?add=%u&session=%s&time=%u&redirect=%s'], + 'FRIEND_REMOVE' => ['/settings.php?friend-action=true&remove=%u&session=%s&time=%u&redirect=%s', '/friends?remove=%u&session=%s&time=%u&redirect=%s'], + + // Manage urls + 'MANAGE_INDEX' => ['/manage.php', '/manage'] + + ]; + + // Get a formatted url + public function format($id, $args = [], $rewrite = null) { + + // Check if the requested url exists + if(!array_key_exists($id, $this->urls)) { + + return null; + + } + + // Check if mod_rewrite is enabled + $rewrite = ($rewrite === null ? Configuration::getConfig('url_rewrite') : $rewrite) ? 1 : 0; + + // Format urls + $formatted = vsprintf($this->urls[$id][$rewrite], $args); + + // Return the formatted url + return $formatted; + + } + +} diff --git a/_sakura/components/Users.php b/_sakura/components/Users.php index 08643e1..ccc1eca 100644 --- a/_sakura/components/Users.php +++ b/_sakura/components/Users.php @@ -30,7 +30,7 @@ class Users { 'lastunamechange' => 0, 'birthday' => '', 'posts' => 0, - 'country' => 'EU', + 'country' => 'XX', 'userData' => '[]' ]; diff --git a/_sakura/sakura.php b/_sakura/sakura.php index a127654..a63f51c 100644 --- a/_sakura/sakura.php +++ b/_sakura/sakura.php @@ -35,6 +35,7 @@ require_once ROOT .'_sakura/components/Main.php'; require_once ROOT .'_sakura/components/Hashing.php'; require_once ROOT .'_sakura/components/Configuration.php'; require_once ROOT .'_sakura/components/Database.php'; +require_once ROOT .'_sakura/components/Urls.php'; require_once ROOT .'_sakura/components/Templates.php'; require_once ROOT .'_sakura/components/Permissions.php'; require_once ROOT .'_sakura/components/Sessions.php'; @@ -71,6 +72,9 @@ ob_start(Configuration::getConfig('use_gzip') ? 'ob_gzhandler' : null); // Create a user object for the current logged in user $currentUser = new User(Session::$userId); +// Create the Urls object +$urls = new Urls(); + // Prepare the name of the template to load (outside of SAKURA_NO_TPL because it's used in imageserve.php) $templateName = defined('SAKURA_MANAGE') ? Configuration::getConfig('manage_style') : ( ( @@ -163,7 +167,8 @@ if(!defined('SAKURA_NO_TPL')) { ], - 'user' => $currentUser + 'user' => $currentUser, + 'urls' => $urls ]; diff --git a/_sakura/templates/yuuno/elements/indexPanel.tpl b/_sakura/templates/yuuno/elements/indexPanel.tpl index 36d4e79..0810332 100644 --- a/_sakura/templates/yuuno/elements/indexPanel.tpl +++ b/_sakura/templates/yuuno/elements/indexPanel.tpl @@ -1,9 +1,9 @@ {% if session.checkLogin %}
Hi, {{ user.data.username }}!
- +
{% else %} @@ -17,20 +17,20 @@
Welcome!
Welcome to Flashii! This is a site for a bunch of friends to hang out, nothing special. Anyone is pretty much welcome to register so why not have a go? {% endif %} {% endif %}
Stats
We have {{ stats.userCount }} user{% if stats.userCount != 1 %}s{% endif %}, -{{ stats.newestUser.data.username }} is the newest user, +{{ stats.newestUser.data.username }} is the newest user, it has been {{ stats.lastRegDate }} since the last user registered and the forum has {{ stats.topicCount }} thread{% if stats.topicCount != 1 %}s{% endif %} and {{ stats.postCount }} post{% if stats.postCount != 1 %}s{% endif %}.
Online Users
{% if stats.onlineUsers %} All active users in the past 5 minutes:
{% for amount,onlineUser in stats.onlineUsers %} - {{ onlineUser.username }}{% if amount != (stats.onlineUsers|length - 1) %}, {% endif %} + {{ onlineUser.username }}{% if amount != (stats.onlineUsers|length - 1) %}, {% endif %} {% endfor %} {% else %} There were no online users in the past 5 minutes. diff --git a/_sakura/templates/yuuno/elements/newsPost.tpl b/_sakura/templates/yuuno/elements/newsPost.tpl index a183557..c67aad3 100644 --- a/_sakura/templates/yuuno/elements/newsPost.tpl +++ b/_sakura/templates/yuuno/elements/newsPost.tpl @@ -1,9 +1,9 @@ -{% if not page.view_post %}{{ newsPost.title }}{% endif %} +{% if not page.view_post %}{{ newsPost.title }}{% endif %}
- +
- {{ newsPost.udata.username }} -

{{ newsPost.udata.username }}

+ {{ newsPost.udata.username }} +

{{ newsPost.udata.username }}

@@ -12,5 +12,5 @@
- Posted on {{ newsPost.date|date(sakura.dateFormat) }}{% if not page.view_post %} View comments{% endif %} + Posted on {{ newsPost.date|date(sakura.dateFormat) }}{% if not page.view_post %} X comments{% endif %}
diff --git a/_sakura/templates/yuuno/elements/settingsNav.tpl b/_sakura/templates/yuuno/elements/settingsNav.tpl index f90a2e2..b1c6fb4 100644 --- a/_sakura/templates/yuuno/elements/settingsNav.tpl +++ b/_sakura/templates/yuuno/elements/settingsNav.tpl @@ -6,7 +6,7 @@
{{ category.title }}
{% for mname,mode in category.modes %} {% if mode.access %} - {{ mode.title }} + {{ mode.title }} {% endif %} {% endfor %} {% endfor %} diff --git a/_sakura/templates/yuuno/errors/banned.tpl b/_sakura/templates/yuuno/errors/banned.tpl index 9e6c6a2..b8e60b1 100644 --- a/_sakura/templates/yuuno/errors/banned.tpl +++ b/_sakura/templates/yuuno/errors/banned.tpl @@ -17,7 +17,7 @@
  • You were banned on {{ ban.issued|date(sakura.dateFormat) }}.
  • {% if ban.expires %}This ban expires on {{ ban.expires|date(sakura.dateFormat) }}.{% else %}You are permanently banned.{% endif %}
  • {% if ban.expires %} -
  • You were banned by {{ ban.issuer.username }}.
  • +
  • You were banned by {{ ban.issuer.username }}.
  • {% endif %}
    diff --git a/_sakura/templates/yuuno/forum/forumBtns.tpl b/_sakura/templates/yuuno/forum/forumBtns.tpl index 657bec6..8b402e6 100644 --- a/_sakura/templates/yuuno/forum/forumBtns.tpl +++ b/_sakura/templates/yuuno/forum/forumBtns.tpl @@ -1,11 +1,11 @@ diff --git a/_sakura/templates/yuuno/global/header.tpl b/_sakura/templates/yuuno/global/header.tpl index 79640c3..d71882b 100644 --- a/_sakura/templates/yuuno/global/header.tpl +++ b/_sakura/templates/yuuno/global/header.tpl @@ -162,31 +162,29 @@