r20150903

Signed-off-by: Flashwave <me@flash.moe>
This commit is contained in:
Pachira 2015-09-03 21:44:14 +02:00
parent e4289ff652
commit 153e6e132c
20 changed files with 176 additions and 145 deletions

View file

@ -55,7 +55,8 @@
"20150829",
"20150830",
"20150831",
"20150902"
"20150902",
"20150903"
]
@ -2369,6 +2370,56 @@
"user": "Flashwave"
}
],
"20150903": [
{
"type": "UPD",
"change": "Moved donation tracker functions to Main class.",
"user": "Flashwave"
},
{
"type": "ADD",
"change": "Added insert function to tracker.",
"user": "Flashwave"
},
{
"type": "ADD",
"change": "Added a link to the tracker on the support page.",
"user": "Flashwave"
},
{
"type": "FIX",
"change": "Fixed undefined index in settings.php.",
"user": "Flashwave"
},
{
"type": "FIX",
"change": "Fixed All Members view on the memberlist not remembering the view option.",
"user": "Flashwave"
},
{
"type": "ADD",
"change": "Created two new classes for future use (news and comments).",
"user": "Flashwave"
},
{
"type": "REM",
"change": "Removed code for Disqus SSO.",
"user": "Flashwave"
},
{
"type": "UPD",
"change": "Make unknown countries return XX instead of EU.",
"user": "Flashwave"
},
{
"type": "REM",
"change": "Removed Disqus.",
"user": "Flashwave"
}
]
}

View file

@ -0,0 +1,12 @@
<?php
/*
* A flexible comment system
*/
namespace Sakura;
class Comments {
}

View file

@ -275,34 +275,6 @@ class Main {
}
// Generate disqus hmac (https://github.com/disqus/DISQUS-API-Recipes/blob/master/sso/php/sso.php)
public static function dsqHmacSha1($data, $key) {
$blocksize = 64;
if(strlen($key) > $blocksize) {
$key = pack('H*', sha1($key));
}
$key = str_pad($key, $blocksize, chr(0x00));
$ipad = str_repeat(chr(0x36), $blocksize);
$opad = str_repeat(chr(0x5c), $blocksize);
$hmac = pack(
'H*', sha1(
($key ^ $opad) . pack(
'H*', sha1(
($key ^ $ipad) . $data
)
)
)
);
return bin2hex($hmac);
}
// Loading info pages
public static function loadInfoPage($id) {
@ -464,15 +436,15 @@ class Main {
}
// Get country code from CloudFlare header (which just returns EU if not found)
// Get country code from CloudFlare header (which just returns XX if not found)
public static function getCountryCode() {
// Check if the required header is set and return it
if(isset($_SERVER['HTTP_CF_IPCOUNTRY']))
return $_SERVER['HTTP_CF_IPCOUNTRY'];
// Return EU as a fallback
return 'EU';
// Return XX as a fallback
return 'XX';
}
@ -764,4 +736,56 @@ class Main {
}
// Get Premium tracker data
public static function getPremiumTrackerData() {
// Create data array
$data = [];
// Get database stuff
$table = Database::fetch('premium_log', true, null, ['id', true]);
// Add raw table data to data array
$data['table'] = $table;
// Create balance entry
$data['balance'] = 0.0;
// Create users entry
$data['users'] = [];
// Calculate the thing
foreach($table as $row) {
// Calculate balance
$data['balance'] = $data['balance'] + $row['amount'];
// Add userdata to table
if(!array_key_exists($row['uid'], $data['users'])) {
$data['users'][$row['uid']] = new User($row['uid']);
}
}
// Return the data
return $data;
}
// Update donation tracker
public static function updatePremiumTracker($id, $amount, $comment) {
Database::insert('premium_log', [
'uid' => $id,
'amount' => $amount,
'date' => time(),
'comment' => $comment
]);
}
}

View file

@ -0,0 +1,21 @@
<?php
/*
* The news page backend
*/
namespace Sakura;
class News {
// Posts array
public $posts = [];
// Initialise the news object
function __construct($category) {
// Get the news posts and assign them to $posts
$this->posts = Database::fetch('news', true, ['category' => [$category, '=']], ['id', true]);
}
}

View file

@ -66,7 +66,8 @@ class Permissions {
// Site management permissions
'MANAGE' => [
'USE_MANAGE' => 1
'USE_MANAGE' => 1,
'EDIT_INFO_PAGES' => 2
]

View file

@ -1435,49 +1435,4 @@ class Users {
}
// Get Premium tracker data
public static function getPremiumTrackerData() {
// Create data array
$data = [];
// Get database stuff
$table = Database::fetch('premium_log', true, null, ['id', true]);
// Add raw table data to data array
$data['table'] = $table;
// Create balance entry
$data['balance'] = 0.0;
// Create users entry
$data['users'] = [];
// Calculate the thing
foreach($table as $row) {
// Calculate balance
$data['balance'] = $data['balance'] + $row['amount'];
// Add userdata to table
if(!array_key_exists($row['uid'], $data['users'])) {
$data['users'][$row['uid']] = new User($row['uid']);
}
}
// Return the data
return $data;
}
// Update donation tracker
public static function updatePremiumTracker($id, $amount, $comment) {
}
}

View file

@ -8,7 +8,7 @@
namespace Sakura;
// Define Sakura version
define('SAKURA_VERSION', '20150902');
define('SAKURA_VERSION', '20150903');
define('SAKURA_VLABEL', 'Eminence');
define('SAKURA_COLOUR', '#6C3082');
define('SAKURA_STABLE', false);
@ -41,6 +41,8 @@ require_once ROOT .'_sakura/components/Sessions.php';
require_once ROOT .'_sakura/components/User.php';
require_once ROOT .'_sakura/components/Users.php';
require_once ROOT .'_sakura/components/Forum.php';
require_once ROOT .'_sakura/components/News.php';
require_once ROOT .'_sakura/components/Comments.php';
require_once ROOT .'_sakura/components/Manage.php';
require_once ROOT .'_sakura/components/Bans.php';
require_once ROOT .'_sakura/components/Whois.php';

View file

@ -1,8 +1,8 @@
{% if session.checkLogin %}
<div class="head">Hi, {{ user.data.username }}!</div>
<a href="/settings/avatar"><img src="/a/{{ user.data.id }}" class="default-avatar-setting homepage-menu-avatar" /></a>
<a href="/settings/appearance/avatar/"><img src="/a/{{ user.data.id }}" class="default-avatar-setting homepage-menu-avatar" /></a>
<ul class="panelQuickLinks">
<li><a href="/settings/friendrequests" title="Pending friend requests"><span class="fa fa-user-plus"></span><span class="count">{{ page.friend_req|length }}</span></a></li>
<li><a href="/settings/friends/requests/" title="Pending friend requests"><span class="fa fa-user-plus"></span><span class="count">{{ page.friend_req|length }}</span></a></li>
<li><a href="/messages" title="View private messages"><span class="fa fa-envelope"></span><span class="count">0</span></a></li>
</ul>
<div class="clear"></div>

View file

@ -12,5 +12,5 @@
</div>
<div class="clear"></div>
<div class="news-post-time">
Posted on {{ newsPost.date|date(sakura.dateFormat) }}{% if not page.view_post %} <a class="default" href="/news/{{ newsPost.id }}#disqus_thread">View comments</a>{% endif %}
Posted on {{ newsPost.date|date(sakura.dateFormat) }}{% if not page.view_post %} <a class="default" href="/news/{{ newsPost.id }}">View comments</a>{% endif %}
</div>

View file

@ -8,7 +8,7 @@
<div class="dropDown" style="margin: 0px auto; font-size: 1.5em; line-height: 1.5em; height: 30px;">
<div class="dropDownInner" style="float: left; color: #FFF;">
<a class="dropDownDesc">Rank:</a><!--
--><a href="/members/"{% if not page.active %} class="dropDownSelected"{% endif %}>All members</a><!--
--><a href="/members/{% if page.sort != page.sorts[0] %}{{ page.sort }}/{% endif %}"{% if not page.active %} class="dropDownSelected"{% endif %}>All members</a><!--
{% for rank in page.ranks %}
{% if not rank.hidden or (rank.hidden and page.active == rank.id) %}
--><a href="/members/{% if page.sort != page.sorts[0] %}{{ page.sort }}/{% endif %}{{ rank.id }}/" style="color: {{ rank.colour }};"{% if page.active == rank.id %} class="dropDownSelected"{% endif %}>{{ rank.name }}{% if rank.multi %}s{% endif %}</a><!--

View file

@ -39,43 +39,5 @@
</div>
{% endif %}
</div>
{% if page.view_post %}
<div id="disqus_thread">
</div>
<script type="text/javascript">
var disqus_shortname = '{{ sakura.disqus_shortname }}';
var disqus_identifier = 'news_{{ newsPosts[0].id }}';
var disqus_title = '{{ newsPosts[0].title }}';
var disqus_url = 'http://{{ sakura.urlMain }}/news/{{ newsPosts[0].id }}';
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
var disqus_config = function() {
this.page.remote_auth_s3 = '{{ page.disqus_sso }}';
this.page.api_key = '{{ sakura.disqus_api_key }}';
}
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
{% else %}
<script type="text/javascript">
var disqus_shortname = '{{ sakura.disqus_shortname }}';
(function () {
var s = document.createElement('script'); s.async = true;
s.type = 'text/javascript';
s.src = '//' + disqus_shortname + '.disqus.com/count.js';
(document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
}());
</script>
{% endif %}
</div>
{% include 'global/footer.tpl' %}

View file

@ -9,6 +9,7 @@
<div class="head">Support {{ sakura.siteName }}</div>
<div style="font-size: .9em; margin-bottom: 10px;">
<p>In order to keep the site, its services and improvements on it going I need money but I'm not that big of a fan of asking for money without giving anything special in return thus Tenshi exists. Tenshi is the name for our supporter rank which gives you access to an extra set of features (which are listed further down on this page). With your help we can keep adding new stuff, get new hardware and keep the site awesome!</p>
<h3><a href="/support/tracker" class="default">Ever wonder what happens on the financial side of things? View the donation tracker!</a></h3>
</div>
{% if page.current[0] %}
<div class="sectionHeader">

View file

@ -36,7 +36,7 @@
{% for supporter in page.premiumTable[page.currentPage] %}
<tr>
<td>
{{ page.premiumData.users[supporter.uid].data.username }}
<a href="/u/{{ page.premiumData.users[supporter.uid].data.id }}" class="default" style="color: {{ page.premiumData.users[supporter.uid].colour }}; text-shadow: 0 0 7px {% if page.premiumData.users[supporter.uid].colour != 'inherit' %}{{ page.premiumData.users[supporter.uid].colour }}{% else %}#222{% endif %};">{{ page.premiumData.users[supporter.uid].data.username }}</a>
</td>
<td style="color: {% if supporter.amount > 0 %}#0A0{% else %}#A00{% endif %};">
&#8364;{{ supporter.amount|number_format(2) }}

View file

@ -18,14 +18,16 @@ RewriteRule ^feedback/?$ https://github.com/circlestorm/Sakura/issues [L,QSA]
RewriteRule ^credits/?$ credits.php [L,QSA]
RewriteRule ^index/?$ index.php [L,QSA]
RewriteRule ^login/?$|^logout/?$|^activate/?$|^register/?$|^forgotpassword/?|^authenticate/?$ authenticate.php [L,QSA]
RewriteRule ^donate/?$|^support/?$ support.php [L,QSA]
RewriteRule ^support/?$ support.php [L,QSA]
RewriteRule ^support/tracker/?$ support.php?tracker=true [L,QSA]
RewriteRule ^support/tracker/([0-9]+)/?$ support.php?tracker=true&page=$1 [L,QSA]
RewriteRule ^contact/?$ infopage.php?p=contact [L,QSA]
RewriteRule ^changelog/?$ changelog.php [L,QSA]
RewriteRule ^faq/?$ faq.php [L,QSA]
RewriteRule ^search/?$ search.php [L,QSA]
# Info pages
RewriteRule ^p/([a-z]+)$ infopage.php?p=$1 [L,QSA]
RewriteRule ^p/([a-z]+)/?$ infopage.php?p=$1 [L,QSA]
# News
RewriteRule ^news/?$ news.php [L,QSA]

View file

@ -449,16 +449,17 @@ a#gotop.exit {
.dropDown .dropDownInner {
float: none !important;
margin-bottom: 5px;
text-align: center;
}
.dropDown .dropDownInner a {
padding: 3px 6px;
float: none !important;
display: inline-block !important;
display: block !important;
}
.dropDown .dropDownInner a:not(:last-child) {
border-right: 2px solid #9475B2;
border-bottom: 2px solid #9475B2;
}
.membersPageList {

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -15,12 +15,16 @@ $renderData['page'] = [
'content' => Main::mdParse("# Unable to load the requested info page.\r\n\r\nCheck the URL and try again.")
];
// Set page id
$pageId = isset($_GET['p']) ? strtolower($_GET['p']) : '';
// Get info page data from the database
if($ipData = Main::loadInfoPage(isset($_GET['p']) ? strtolower($_GET['p']) : '')) {
if($ipData = Main::loadInfoPage($pageId)) {
// Assign new proper variable
$renderData['page'] = [
'id' => $pageId,
'title' => $ipData['pagetitle'],
'content' => Main::mdParse($ipData['content'])

View file

@ -12,25 +12,12 @@ use DOMDocument;
// Include components
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) .'_sakura/sakura.php';
// Get user data
$disqus_user = new User(Session::$userId);
// Set disqus data
$disqus_data = [
$disqus_user->data['id'],
$disqus_user->data['username'],
$disqus_user->data['email'],
'http://'. Configuration::getConfig('url_main') .'/a/'. $disqus_user->data['id'],
'http://'. Configuration::getConfig('url_main') .'/u/'. $disqus_user->data['id']
];
// Add page specific things
$renderData['newsPosts'] = Main::getNewsPosts((isset($_GET['id']) && !isset($_GET['xml']) && is_numeric($_GET['id'])) ? $_GET['id'] : null, (isset($_GET['id']) && !isset($_GET['xml']) && is_numeric($_GET['id'])));
$renderData['page'] = [
'title' => (isset($_GET['id']) ? (count($renderData['newsPosts']) ? $renderData['newsPosts'][0]['title'] : 'Post does not exist!') : 'News'),
'disqus_sso' => (($disqus_message = base64_encode(json_encode($disqus_data))) .' '. Main::dsqHmacSha1($disqus_message .' '. time(), Configuration::getConfig('disqus_api_secret')) .' '. time()),
'view_post' => isset($_GET['id']) && count($renderData['newsPosts']),
'currentPage' => 0

View file

@ -974,8 +974,15 @@ if(Users::checkLogin()) {
];
// Current settings page
$category = isset($_GET['cat']) ? (array_key_exists($_GET['cat'], $pages) ? $_GET['cat'] : false) : array_keys($pages)[0];
$mode = isset($_GET['mode']) && $category ? (array_key_exists($_GET['mode'], $pages[$category]['modes']) ? $_GET['mode'] : false) : array_keys($pages[$category]['modes'])[0];
$category = isset($_GET['cat']) ? (array_key_exists($_GET['cat'], $pages) ? $_GET['cat'] : false) : array_keys($pages)[0];
$mode = false;
// Only continue setting mode if $category is true
if($category) {
$mode = isset($_GET['mode']) && $category ? (array_key_exists($_GET['mode'], $pages[$category]['modes']) ? $_GET['mode'] : false) : array_keys($pages[$category]['modes'])[0];
}
// Not found
if(!$category || empty($category) || !$mode || empty($mode) || !$pages[$category]['modes'][$mode]['access']) {

View file

@ -52,10 +52,10 @@ if(isset($_REQUEST['mode']) && Users::checkLogin() && Permissions::check('SITE',
$total = number_format($total, 2, '.', '');
// Generate item name
$itemName = 'Flashii Tenshi - '. (string)$_POST['months'] .' month'. ((int)$_POST['months'] == 1 ? '' : 's');
$itemName = Configuration::getConfig('sitename') .' Premium - '. (string)$_POST['months'] .' month'. ((int)$_POST['months'] == 1 ? '' : 's');
// Attempt to create a transaction
if($transaction = Payments::createTransaction($total, $itemName, 'Flashii Tenshi Purchase', 'http://'. Configuration::getConfig('url_main') .'/support')) {
if($transaction = Payments::createTransaction($total, $itemName, Configuration::getConfig('sitename') .' Premium Purchase', 'http://'. Configuration::getConfig('url_main') .'/support')) {
// Store the amount of months in the global session array
$_SESSION['premiumMonths'] = (int)$_POST['months'];
@ -90,6 +90,7 @@ if(isset($_REQUEST['mode']) && Users::checkLogin() && Permissions::check('SITE',
// Make the user premium
$expiration = Users::addUserPremium(Session::$userId, (2628000 * $_SESSION['premiumMonths']));
Users::updatePremiumMeta(Session::$userId);
Main::updatePremiumTracker(Session::$userId, ((float)Configuration::getConfig('premium_price_per_month') * $_SESSION['premiumMonths']), $currentUser->data['username'] .' bought premium for '. $_SESSION['premiumMonths'] .' month'. ($_SESSION['premiumMonths'] == 1 ? '' : 's') .'.');
// Redirect to the complete
header('Location: ?mode=complete');
@ -130,7 +131,7 @@ if(isset($_GET['tracker'])) {
'title' => 'Donation Tracker',
'currentPage' => isset($_GET['page']) && ($_GET['page'] - 1) >= 0 ? $_GET['page'] - 1 : 0,
'premiumData' => ($_PREMIUM = Users::getPremiumTrackerData()),
'premiumData' => ($_PREMIUM = Main::getPremiumTrackerData()),
'premiumTable' => array_chunk($_PREMIUM['table'], 20, true)
];