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 %}