Adding ability to disable the sites API functions
Addresses #467 and will fix upon merge.
This commit is contained in:
parent
82f29de293
commit
d492b532b7
@ -22,6 +22,7 @@ require_once(INCLUDE_DIR . '/database.inc.php');
|
||||
require_once(INCLUDE_DIR . '/smarty.inc.php');
|
||||
// Load classes that need the above as dependencies
|
||||
require_once(CLASS_DIR . '/base.class.php');
|
||||
require_once(CLASS_DIR . '/api.class.php');
|
||||
require_once(CLASS_DIR . '/mail.class.php');
|
||||
require_once(CLASS_DIR . '/tokentype.class.php');
|
||||
require_once(CLASS_DIR . '/token.class.php');
|
||||
|
||||
23
public/include/classes/api.class.php
Normal file
23
public/include/classes/api.class.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
// Make sure we are called from index.php
|
||||
if (!defined('SECURITY')) die('Hacking attempt');
|
||||
|
||||
/**
|
||||
* Helper class for our API
|
||||
**/
|
||||
class Api extends Base {
|
||||
function isActive($error=true) {
|
||||
if (!$this->config['website']['api']['disabled']) {
|
||||
return true;
|
||||
} else {
|
||||
if ($error == true) {
|
||||
header('HTTP/1.1 501 Not implemented');
|
||||
die('501 Not implemented');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$api = new Api();
|
||||
$api->setConfig($config);
|
||||
@ -96,22 +96,24 @@ $config['ap_threshold']['max'] = 250;
|
||||
* Website specific configuration settings
|
||||
*
|
||||
* Explanation:
|
||||
* title : Website title used in master template
|
||||
* name : The pool name, displayed in the header and mails
|
||||
* slogan : A special slogan, also displayed in the header below name
|
||||
* email : `From` addresses used in notifications
|
||||
* theme : Theme used for desktop browsers
|
||||
* mobile : Enable/Disable mobile theme support
|
||||
* mobile_theme : Theme used for mobile browsers
|
||||
* title : Website title used in master template
|
||||
* name : The pool name, displayed in the header and mails
|
||||
* slogan : A special slogan, also displayed in the header below name
|
||||
* email : `From` addresses used in notifications
|
||||
* theme : Theme used for desktop browsers
|
||||
* mobile : Enable/Disable mobile theme support
|
||||
* mobile_theme : Theme used for mobile browsers
|
||||
* api disabled : Disable the sites API functions
|
||||
*
|
||||
* Defaults:
|
||||
* title = `The Pool - Mining Evolved`
|
||||
* name = `The Pool`
|
||||
* slogan = `Resistance is futile`
|
||||
* email = `test@example.com`
|
||||
* theme = `mmcFE`
|
||||
* mobile = true
|
||||
* mobile_theme = `mobile`
|
||||
* title = `The Pool - Mining Evolved`
|
||||
* name = `The Pool`
|
||||
* slogan = `Resistance is futile`
|
||||
* email = `test@example.com`
|
||||
* theme = `mmcFE`
|
||||
* mobile = true
|
||||
* mobile_theme = `mobile`
|
||||
* api disbabled = false
|
||||
**/
|
||||
$config['website']['title'] = 'The Pool - Mining Evolved';
|
||||
$config['website']['name'] = 'The Pool';
|
||||
@ -120,6 +122,7 @@ $config['website']['email'] = 'test@example.com';
|
||||
$config['website']['theme'] = 'mmcFE';
|
||||
$config['website']['mobile'] = true;
|
||||
$config['website']['mobile_theme'] = 'mobile';
|
||||
$config['website']['api']['disabled'] = false;
|
||||
|
||||
/**
|
||||
* Account specific settings
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
// Make sure we are called from index.php
|
||||
if (!defined('SECURITY'))
|
||||
die('Hacking attempt');
|
||||
if (!defined('SECURITY')) die('Hacking attempt');
|
||||
|
||||
// Check if the API is activated
|
||||
$api->isActive();
|
||||
|
||||
// Check for valid API key
|
||||
$id = $user->checkApiKey($_REQUEST['api_key']);
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
// Make sure we are called from index.php
|
||||
if (!defined('SECURITY'))
|
||||
die('Hacking attempt');
|
||||
if (!defined('SECURITY')) die('Hacking attempt');
|
||||
|
||||
// Check if the API is activated
|
||||
$api->isActive();
|
||||
|
||||
// Check user token
|
||||
$id = $user->checkApiKey($_REQUEST['api_key']);
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
// Make sure we are called from index.php
|
||||
if (!defined('SECURITY'))
|
||||
die('Hacking attempt');
|
||||
if (!defined('SECURITY')) die('Hacking attempt');
|
||||
|
||||
// Check if the API is activated
|
||||
$api->isActive();
|
||||
|
||||
// Check user token
|
||||
$id = $user->checkApiKey($_REQUEST['api_key']);
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
// Make sure we are called from index.php
|
||||
if (!defined('SECURITY'))
|
||||
die('Hacking attempt');
|
||||
if (!defined('SECURITY')) die('Hacking attempt');
|
||||
|
||||
// Check if the API is activated
|
||||
$api->isActive();
|
||||
|
||||
// Check user token
|
||||
$id = $user->checkApiKey($_REQUEST['api_key']);
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
// Make sure we are called from index.php
|
||||
if (!defined('SECURITY'))
|
||||
die('Hacking attempt');
|
||||
if (!defined('SECURITY')) die('Hacking attempt');
|
||||
|
||||
// Check if the API is activated
|
||||
$api->isActive();
|
||||
|
||||
// Check user token
|
||||
$id = $user->checkApiKey($_REQUEST['api_key']);
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
// Make sure we are called from index.php
|
||||
if (!defined('SECURITY'))
|
||||
die('Hacking attempt');
|
||||
if (!defined('SECURITY')) die('Hacking attempt');
|
||||
|
||||
// Check if the API is activated
|
||||
$api->isActive();
|
||||
|
||||
// Check user token
|
||||
$id = $user->checkApiKey($_REQUEST['api_key']);
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
// Make sure we are called from index.php
|
||||
if (!defined('SECURITY'))
|
||||
die('Hacking attempt');
|
||||
if (!defined('SECURITY')) die('Hacking attempt');
|
||||
|
||||
// Check if the API is activated
|
||||
$api->isActive();
|
||||
|
||||
// Check user token
|
||||
$id = $user->checkApiKey($_REQUEST['api_key']);
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
// Make sure we are called from index.php
|
||||
if (!defined('SECURITY'))
|
||||
die('Hacking attempt');
|
||||
if (!defined('SECURITY')) die('Hacking attempt');
|
||||
|
||||
// Check if the API is activated
|
||||
$api->isActive();
|
||||
|
||||
// Check user token
|
||||
$id = $user->checkApiKey($_REQUEST['api_key']);
|
||||
|
||||
@ -3,6 +3,9 @@
|
||||
// Make sure we are called from index.php
|
||||
if (!defined('SECURITY')) die('Hacking attempt');
|
||||
|
||||
// Check if the API is activated
|
||||
$api->isActive();
|
||||
|
||||
// Check user token
|
||||
$user_id = $user->checkApiKey($_REQUEST['api_key']);
|
||||
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
// Make sure we are called from index.php
|
||||
if (!defined('SECURITY'))
|
||||
die('Hacking attempt');
|
||||
if (!defined('SECURITY')) die('Hacking attempt');
|
||||
|
||||
// Check if the API is activated
|
||||
$api->isActive();
|
||||
|
||||
// Check user token
|
||||
$id = $user->checkApiKey($_REQUEST['api_key']);
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
// Make sure we are called from index.php
|
||||
if (!defined('SECURITY'))
|
||||
die('Hacking attempt');
|
||||
if (!defined('SECURITY')) die('Hacking attempt');
|
||||
|
||||
// Check if the API is activated
|
||||
$api->isActive();
|
||||
|
||||
// Check user token
|
||||
$user_id = $user->checkApiKey($_REQUEST['api_key']);
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
// Make sure we are called from index.php
|
||||
if (!defined('SECURITY'))
|
||||
die('Hacking attempt');
|
||||
if (!defined('SECURITY')) die('Hacking attempt');
|
||||
|
||||
// Check if the API is activated
|
||||
$api->isActive();
|
||||
|
||||
// Check user token
|
||||
$user_id = $user->checkApiKey($_REQUEST['api_key']);
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
// Make sure we are called from index.php
|
||||
if (!defined('SECURITY'))
|
||||
die('Hacking attempt');
|
||||
if (!defined('SECURITY')) die('Hacking attempt');
|
||||
|
||||
// {"pool_name":"Pool-X.eu","hashrate":"511128.99","workers":"2104","shares_this_round":92450,"last_block":"365294","network_hashrate":17327056.06}
|
||||
// Check if the API is activated
|
||||
$api->isActive();
|
||||
|
||||
// Fetch last block information
|
||||
$aLastBlock = $block->getLast();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user