API shit
This commit is contained in:
parent
67259b560c
commit
866d7aa89f
8 changed files with 120 additions and 20 deletions
|
@ -27,7 +27,9 @@
|
|||
"20150628",
|
||||
"20150629",
|
||||
"20150630",
|
||||
"20150701"
|
||||
"20150701",
|
||||
"20150702",
|
||||
"20150703"
|
||||
|
||||
]
|
||||
|
||||
|
@ -1407,6 +1409,28 @@
|
|||
"change": "Added basic API handler."
|
||||
}
|
||||
|
||||
],
|
||||
|
||||
"20150702": [
|
||||
|
||||
{
|
||||
"type": "FIX",
|
||||
"change": "Fixed a mistake in the stylesheet causing the support page to deform when resized."
|
||||
},
|
||||
{
|
||||
"type": "FIX",
|
||||
"change": "Made the sitename config variable shown on the title of the suport page instead of just Flashii"
|
||||
}
|
||||
|
||||
],
|
||||
|
||||
"20150703": [
|
||||
|
||||
{
|
||||
"type": "ADD",
|
||||
"change": "Add basic example of the version 1 API framework."
|
||||
}
|
||||
|
||||
]
|
||||
|
||||
}
|
||||
|
|
|
@ -16,9 +16,7 @@ class Forum {
|
|||
'forum_category' => 0,
|
||||
'forum_type' => 1,
|
||||
'forum_posts' => 0,
|
||||
'forum_topics' => 0,
|
||||
'forum_last_post_id' => 0,
|
||||
'forum_last_poster_id' => 0
|
||||
'forum_topics' => 0
|
||||
];
|
||||
|
||||
// Getting the forum list
|
||||
|
@ -48,9 +46,14 @@ class Forum {
|
|||
// For link and reg. forum add it to the category
|
||||
$return[$forum['forum_category']]['forums'][$forum['forum_id']] = $forum;
|
||||
|
||||
// Get last post in forum
|
||||
$lastPost = Database::fetch('posts', false, [
|
||||
'forum_id' => [$forum['forum_id'], '=']
|
||||
], ['post_id', true]);
|
||||
|
||||
// Add last poster data and the details about the post as well
|
||||
$return[$forum['forum_category']]['forums'][$forum['forum_id']]['last_poster'] = [
|
||||
'user' => ($_LAST_POSTER = Users::getUser($forum['forum_last_poster_id'])),
|
||||
'user' => ($_LAST_POSTER = Users::getUser($lastPost['poster_id'])),
|
||||
'rank' => Users::getRank($_LAST_POSTER['rank_main'])
|
||||
];
|
||||
|
||||
|
@ -105,8 +108,13 @@ class Forum {
|
|||
// Get the userdata related to last posts
|
||||
foreach($forum['forums'] as $key => $sub) {
|
||||
|
||||
// Get last post in forum
|
||||
$lastPost = Database::fetch('posts', false, [
|
||||
'forum_id' => [$sub['forum_id'], '=']
|
||||
], ['post_id', true]);
|
||||
|
||||
$forum['forums'][$key]['last_poster'] = [
|
||||
'user' => ($_LAST_POSTER = Users::getUser($sub['forum_last_poster_id'])),
|
||||
'user' => ($_LAST_POSTER = Users::getUser($lastPost['poster_id'])),
|
||||
'rank' => Users::getRank($_LAST_POSTER['rank_main'])
|
||||
];
|
||||
|
||||
|
@ -120,8 +128,13 @@ class Forum {
|
|||
// Get the userdata related to first and last posts
|
||||
foreach($forum['topics'] as $key => $topic) {
|
||||
|
||||
// Get last post in forum
|
||||
$firstPost = Database::fetch('posts', false, [
|
||||
'topic_id' => [$topic['topic_id'], '=']
|
||||
]);
|
||||
|
||||
$forum['topics'][$key]['first_poster'] = [
|
||||
'user' => ($_FIRST_POSTER = Users::getUser($topic['topic_first_poster_id'])),
|
||||
'user' => ($_FIRST_POSTER = Users::getUser($firstPost['topic_first_poster_id'])),
|
||||
'rank' => Users::getRank($_FIRST_POSTER['rank_main'])
|
||||
];
|
||||
|
||||
|
|
|
@ -584,7 +584,7 @@ class Main {
|
|||
}
|
||||
|
||||
// Indent JSON
|
||||
public static function jsonIndent($json) {
|
||||
public static function jsonPretty($json) {
|
||||
|
||||
// Defines
|
||||
$tab = ' ';
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
namespace Sakura;
|
||||
|
||||
// Define Sakura version
|
||||
define('SAKURA_VERSION', '20150701');
|
||||
define('SAKURA_VERSION', '20150703');
|
||||
define('SAKURA_VLABEL', 'Eminence');
|
||||
define('SAKURA_STABLE', false);
|
||||
define('SAKURA_COLOUR', '#6C3082');
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
<div class="content support">
|
||||
<div class="head">Support Flashii</div>
|
||||
<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>
|
||||
</div>
|
||||
|
|
53
api/api.php
53
api/api.php
|
@ -9,6 +9,9 @@ namespace Sakura;
|
|||
// Include components
|
||||
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) .'_sakura/sakura.php';
|
||||
|
||||
// Change to content type to text/plain and set the charset to UTF-8
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
|
||||
// Trim leading slashes
|
||||
$path = ltrim($_SERVER['REQUEST_URI'], '/');
|
||||
|
||||
|
@ -24,6 +27,54 @@ if($elems[0] == explode('/', ltrim($_SERVER['PHP_SELF'], '/'))[0]) {
|
|||
// Resort the array
|
||||
$elems = array_values($elems);
|
||||
|
||||
// Make sure there's at least one entry (even if empty)
|
||||
if(!isset($elems[0]))
|
||||
$elems[] = "";
|
||||
|
||||
}
|
||||
|
||||
print_r($elems);
|
||||
// Make sure the GET requests aren't present in the last entry
|
||||
if(strpos($elems[max(array_keys($elems))], '?')) {
|
||||
|
||||
// If there are cut them all
|
||||
$elems[max(array_keys($elems))] = strstr($elems[max(array_keys($elems))], '?', true);
|
||||
|
||||
}
|
||||
|
||||
// Predefine the return variable
|
||||
$return = [];
|
||||
|
||||
// Select API version
|
||||
switch(isset($elems[0]) ? $elems[0] : false) {
|
||||
|
||||
// API Version 1
|
||||
case 'v1':
|
||||
switch(isset($elems[1]) ? $elems[1] : false) {
|
||||
|
||||
// Authentication
|
||||
case 'authenticate':
|
||||
switch(isset($elems[2]) ? $elems[2] : false) {
|
||||
|
||||
case 'login':
|
||||
$return = ['success' => 'LOGIN_PROCESS_HERE'];
|
||||
break;
|
||||
|
||||
default:
|
||||
$return = ['error' => ['NO_DATA_REQ']];
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$return = ['error' => ['NO_DATA_REQ']];
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
// Default fallback
|
||||
default:
|
||||
$return = ['error' => ['NO_API_VERSION']];
|
||||
|
||||
}
|
||||
|
||||
echo isset($_GET['pretty']) ? Main::jsonPretty(json_encode([$return])) : json_encode([$return]);
|
||||
|
|
|
@ -1382,12 +1382,28 @@ a.gotop.exit {
|
|||
color: #503170;
|
||||
}
|
||||
|
||||
.support .featureBox.final {
|
||||
width: 818px;
|
||||
@media (min-width: 840px) {
|
||||
|
||||
.support .featureBox.final {
|
||||
width: 818px;
|
||||
}
|
||||
|
||||
.support .featureBox.final .featureBoxDesc {
|
||||
font-size: 1.3em;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.support .featureBox.final .featureBoxDesc {
|
||||
font-size: 1.3em;
|
||||
@media (max-width: 840px) {
|
||||
|
||||
.support .featureBox.final .featureBoxDesc {
|
||||
line-height: 25px;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.support .featureBoxIcon.right {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.support .featureBox:hover {
|
||||
|
@ -1403,10 +1419,6 @@ a.gotop.exit {
|
|||
font-size: 2.8em;
|
||||
}
|
||||
|
||||
.support .featureBoxIcon.right {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.support .featureBoxDesc {
|
||||
display: block;
|
||||
line-height: 50px;
|
||||
|
|
|
@ -125,7 +125,7 @@ if(isset($_REQUEST['mode']) && Users::checkLogin() && Permissions::check('SITE',
|
|||
|
||||
// Set default variables
|
||||
$renderData['page'] = [
|
||||
'title' => 'Support Flashii',
|
||||
'title' => 'Support '. Configuration::getConfig('sitename'),
|
||||
'fail' => isset($_GET['fail']),
|
||||
'price' => Configuration::getConfig('premium_price_per_month'),
|
||||
'current' => Users::checkUserPremium(Session::$userId),
|
||||
|
|
Reference in a new issue