one last meow for today

This commit is contained in:
Pachira 2015-07-01 20:22:45 +02:00
parent 5bd78b73fa
commit 67259b560c
7 changed files with 78 additions and 10 deletions

View file

@ -3,3 +3,29 @@
_A backend that doesn't suck_
I'll write a more descriptive readme once it's in a stable state.
## Apache 2.x Virtualhosts
```
<VirtualHost *:80 *:443>
DocumentRoot [local path]/main
ServerName [site url]
ServerAlias www.[site url]
</VirtualHost>
<VirtualHost *:80 *:443>
DocumentRoot [local path]/content
ServerName content.[site url]
Header unset Cookie
Header unset Set-Cookie
</VirtualHost>
<VirtualHost *:80 *:443>
DocumentRoot [local path]/api
ServerName api.[site url]
Header unset Cookie
Header unset Set-Cookie
</VirtualHost>
```

View file

@ -1397,6 +1397,14 @@
{
"type": "FIX",
"change": "Moved expire variable for the complete page out of the url and take the data straight from the database."
},
{
"type": "UPD",
"change": "Made the maximum amount of month you get buy premium for changable."
},
{
"type": "ADD",
"change": "Added basic API handler."
}
]

View file

@ -1007,7 +1007,7 @@ class Users {
// Check if the user has static premium
if(Permissions::check('SITE', 'STATIC_PREMIUM', $id, 1))
return [1, 0, time() + 1];
return [2, 0, time() + 1];
// Attempt to retrieve the premium record from the database
$getRecord = Database::fetch('premium', false, [

View file

@ -15,8 +15,8 @@
Your current Tenshi tag
</div>
<div style="margin-bottom: 10px;">
<h3>Your Tenshi tag is valid till {{ page.current[2]|date("l \\t\\h\\e jS \\o\\f F o") }}.</h3>
<progress value="{{ page.current[1] / page.current[2] * 100 }}" max="100" style="width: 100%"></progress>
<h3>{% if page.current[0] == 2 %}Your rank has persistent Tenshi.{% else %}Your Tenshi tag is valid till {{ page.current[2]|date("l \\t\\h\\e jS \\o\\f F o") }}.{% endif %}</h3>
<progress value="{{ page.current[0] == 2 ? 100 : page.current[1] / page.current[2] * 100 }}" max="100" style="width: 100%"></progress>
</div>
{% endif %}
<div class="sectionHeader">
@ -86,7 +86,7 @@
</div>
{% if user.checklogin and perms.canGetPremium %}
<div class="slider">
<input class="inputStyling" type="range" min="1" max="24" value="1" onchange="document.getElementById('monthsNo').value = this.value; document.getElementById('monthNoBtn').innerHTML = this.value; document.getElementById('monthsTrailingS').innerHTML = (this.value == 1 ? '' : 's'); document.getElementById('totalAmount').innerHTML = (this.value * {{ page.price }}).formatMoney(2);" />
<input class="inputStyling" type="range" min="1" max="{{ page.amount_max }}" value="1" onchange="document.getElementById('monthsNo').value = this.value; document.getElementById('monthNoBtn').innerHTML = this.value; document.getElementById('monthsTrailingS').innerHTML = (this.value == 1 ? '' : 's'); document.getElementById('totalAmount').innerHTML = (this.value * {{ page.price }}).formatMoney(2);" />
</div>
<div class="checkout" style="line-height: 28px;">
<div style="float: left;">

View file

@ -1 +1,5 @@
# Empty .htaccess to make git realise this directory exists
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ api.php [QSA,L]

29
api/api.php Normal file
View file

@ -0,0 +1,29 @@
<?php
/*
* Sakura API
*/
// Declare Namespace
namespace Sakura;
// Include components
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) .'_sakura/sakura.php';
// Trim leading slashes
$path = ltrim($_SERVER['REQUEST_URI'], '/');
// Explode the elements
$elems = explode('/', $path);
// Correct the path if mod_rewrite isn't used
if($elems[0] == explode('/', ltrim($_SERVER['PHP_SELF'], '/'))[0]) {
// Remove the entry
unset($elems[0]);
// Resort the array
$elems = array_values($elems);
}
print_r($elems);

View file

@ -41,7 +41,7 @@ if(isset($_REQUEST['mode']) && Users::checkLogin() && Permissions::check('SITE',
}
// Half if shit isn't gucci
if(!isset($_POST['months']) || !is_numeric($_POST['months']) || (int)$_POST['months'] < 1 || (int)$_POST['months'] > 24) {
if(!isset($_POST['months']) || !is_numeric($_POST['months']) || (int)$_POST['months'] < 1 || (int)$_POST['months'] > Configuration::getConfig('premium_amount_max')) {
header('Location: /support?fail=true');
@ -125,10 +125,11 @@ if(isset($_REQUEST['mode']) && Users::checkLogin() && Permissions::check('SITE',
// Set default variables
$renderData['page'] = [
'title' => 'Support Flashii',
'fail' => isset($_GET['fail']),
'price' => Configuration::getConfig('premium_price_per_month'),
'current' => Users::checkUserPremium(Session::$userId)
'title' => 'Support Flashii',
'fail' => isset($_GET['fail']),
'price' => Configuration::getConfig('premium_price_per_month'),
'current' => Users::checkUserPremium(Session::$userId),
'amount_max' => Configuration::getConfig('premium_amount_max')
];
// Print page contents