diff --git a/public/include/autoloader.inc.php b/public/include/autoloader.inc.php index a5b21621..929e2f85 100644 --- a/public/include/autoloader.inc.php +++ b/public/include/autoloader.inc.php @@ -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'); diff --git a/public/include/classes/api.class.php b/public/include/classes/api.class.php new file mode 100644 index 00000000..36374162 --- /dev/null +++ b/public/include/classes/api.class.php @@ -0,0 +1,23 @@ +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); diff --git a/public/include/config/global.inc.dist.php b/public/include/config/global.inc.dist.php index e66197fe..173a47b7 100644 --- a/public/include/config/global.inc.dist.php +++ b/public/include/config/global.inc.dist.php @@ -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 diff --git a/public/include/pages/api.inc.php b/public/include/pages/api.inc.php index c2e64a60..c85ada42 100644 --- a/public/include/pages/api.inc.php +++ b/public/include/pages/api.inc.php @@ -1,8 +1,10 @@ isActive(); // Check for valid API key $id = $user->checkApiKey($_REQUEST['api_key']); diff --git a/public/include/pages/api/getblockcount.inc.php b/public/include/pages/api/getblockcount.inc.php index 2cbd06a5..6764f436 100644 --- a/public/include/pages/api/getblockcount.inc.php +++ b/public/include/pages/api/getblockcount.inc.php @@ -1,8 +1,10 @@ isActive(); // Check user token $id = $user->checkApiKey($_REQUEST['api_key']); diff --git a/public/include/pages/api/getblocksfound.inc.php b/public/include/pages/api/getblocksfound.inc.php index 00883dad..b238bdc3 100644 --- a/public/include/pages/api/getblocksfound.inc.php +++ b/public/include/pages/api/getblocksfound.inc.php @@ -1,8 +1,10 @@ isActive(); // Check user token $id = $user->checkApiKey($_REQUEST['api_key']); diff --git a/public/include/pages/api/getcurrentworkers.inc.php b/public/include/pages/api/getcurrentworkers.inc.php index 4e26cc1c..48864316 100644 --- a/public/include/pages/api/getcurrentworkers.inc.php +++ b/public/include/pages/api/getcurrentworkers.inc.php @@ -1,8 +1,10 @@ isActive(); // Check user token $id = $user->checkApiKey($_REQUEST['api_key']); diff --git a/public/include/pages/api/getdifficulty.inc.php b/public/include/pages/api/getdifficulty.inc.php index 0e9cb6f9..e84d4045 100644 --- a/public/include/pages/api/getdifficulty.inc.php +++ b/public/include/pages/api/getdifficulty.inc.php @@ -1,8 +1,10 @@ isActive(); // Check user token $id = $user->checkApiKey($_REQUEST['api_key']); diff --git a/public/include/pages/api/getestimatedtime.inc.php b/public/include/pages/api/getestimatedtime.inc.php index a48393fa..f06e28f3 100644 --- a/public/include/pages/api/getestimatedtime.inc.php +++ b/public/include/pages/api/getestimatedtime.inc.php @@ -1,8 +1,10 @@ isActive(); // Check user token $id = $user->checkApiKey($_REQUEST['api_key']); diff --git a/public/include/pages/api/getpoolhashrate.inc.php b/public/include/pages/api/getpoolhashrate.inc.php index 6f6763ec..5546d321 100644 --- a/public/include/pages/api/getpoolhashrate.inc.php +++ b/public/include/pages/api/getpoolhashrate.inc.php @@ -1,8 +1,10 @@ isActive(); // Check user token $id = $user->checkApiKey($_REQUEST['api_key']); diff --git a/public/include/pages/api/getpoolsharerate.inc.php b/public/include/pages/api/getpoolsharerate.inc.php index 8e9117f1..a87859f6 100644 --- a/public/include/pages/api/getpoolsharerate.inc.php +++ b/public/include/pages/api/getpoolsharerate.inc.php @@ -1,8 +1,10 @@ isActive(); // Check user token $id = $user->checkApiKey($_REQUEST['api_key']); diff --git a/public/include/pages/api/getpoolstatus.inc.php b/public/include/pages/api/getpoolstatus.inc.php index ece9f557..4cf0d5ef 100644 --- a/public/include/pages/api/getpoolstatus.inc.php +++ b/public/include/pages/api/getpoolstatus.inc.php @@ -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']); diff --git a/public/include/pages/api/gettimesincelastblock.inc.php b/public/include/pages/api/gettimesincelastblock.inc.php index 532da6bd..14575364 100644 --- a/public/include/pages/api/gettimesincelastblock.inc.php +++ b/public/include/pages/api/gettimesincelastblock.inc.php @@ -1,8 +1,10 @@ isActive(); // Check user token $id = $user->checkApiKey($_REQUEST['api_key']); diff --git a/public/include/pages/api/getuserstatus.inc.php b/public/include/pages/api/getuserstatus.inc.php index ac8f6654..afdd59fc 100644 --- a/public/include/pages/api/getuserstatus.inc.php +++ b/public/include/pages/api/getuserstatus.inc.php @@ -1,8 +1,10 @@ isActive(); // Check user token $user_id = $user->checkApiKey($_REQUEST['api_key']); diff --git a/public/include/pages/api/getuserworkers.inc.php b/public/include/pages/api/getuserworkers.inc.php index 9aaca562..06eb3411 100644 --- a/public/include/pages/api/getuserworkers.inc.php +++ b/public/include/pages/api/getuserworkers.inc.php @@ -1,8 +1,10 @@ isActive(); // Check user token $user_id = $user->checkApiKey($_REQUEST['api_key']); diff --git a/public/include/pages/api/public.inc.php b/public/include/pages/api/public.inc.php index 162e9134..5a98367a 100644 --- a/public/include/pages/api/public.inc.php +++ b/public/include/pages/api/public.inc.php @@ -1,10 +1,10 @@ isActive(); // Fetch last block information $aLastBlock = $block->getLast();