Merge pull request #29 from pxgamer/feature/blacklist-refactor
Refactor the blacklist to a class
This commit is contained in:
7
api.php
7
api.php
@@ -65,6 +65,8 @@ OR OTHER DEALINGS IN THE SOFTWARE.
|
|||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Arionum\Blacklist;
|
||||||
|
|
||||||
require_once("include/init.inc.php");
|
require_once("include/init.inc.php");
|
||||||
error_reporting(0);
|
error_reporting(0);
|
||||||
$ip = san_ip($_SERVER['REMOTE_ADDR']);
|
$ip = san_ip($_SERVER['REMOTE_ADDR']);
|
||||||
@@ -429,10 +431,7 @@ if ($q == "getAddress") {
|
|||||||
api_err("Invalid public key");
|
api_err("Invalid public key");
|
||||||
}
|
}
|
||||||
if ($_config['use_official_blacklist']!==false) {
|
if ($_config['use_official_blacklist']!==false) {
|
||||||
$blacklisted=["PZ8Tyr4Nx8MHsRAGMpZmZ6TWY63dXWSCvVQcHHCNLfiP9LmzWhhpCHx39Bhc67P5HMQM9cctEFvcsUdgrkGqy18taz9ZMrAGtq7NhBYpQ4ZTHkKYiZDaSUqQ", //faucet abuser
|
if (Blacklist::checkPublicKey($public_key)) {
|
||||||
"PZ8Tyr4Nx8MHsRAGMpZmZ6TWY63dXWSCxYDeQHk7Ke66UB2Un3UMmMoJ7RF5vDZXihdEXi8gk8ZBRAi35aFrER2ZLX1mgND7sLFXKETGTjRYjoHcuRNiJN1g" // octaex
|
|
||||||
];
|
|
||||||
if (in_array($public_key, $blacklisted)) {
|
|
||||||
api_err("Blacklisted account");
|
api_err("Blacklisted account");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
30
include/Blacklist.php
Normal file
30
include/Blacklist.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Arionum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Blacklist
|
||||||
|
*/
|
||||||
|
final class Blacklist
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The official list of blacklisted public keys
|
||||||
|
*/
|
||||||
|
public const PUBLIC_KEYS = [
|
||||||
|
// phpcs:disable Generic.Files.LineLength
|
||||||
|
'PZ8Tyr4Nx8MHsRAGMpZmZ6TWY63dXWSCvVQcHHCNLfiP9LmzWhhpCHx39Bhc67P5HMQM9cctEFvcsUdgrkGqy18taz9ZMrAGtq7NhBYpQ4ZTHkKYiZDaSUqQ' => 'Faucet Abuser',
|
||||||
|
'PZ8Tyr4Nx8MHsRAGMpZmZ6TWY63dXWSCxYDeQHk7Ke66UB2Un3UMmMoJ7RF5vDZXihdEXi8gk8ZBRAi35aFrER2ZLX1mgND7sLFXKETGTjRYjoHcuRNiJN1g' => 'Octaex Exchange',
|
||||||
|
// phpcs:enable
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a public key is blacklisted
|
||||||
|
*
|
||||||
|
* @param string $publicKey
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function checkPublicKey(string $publicKey): bool
|
||||||
|
{
|
||||||
|
return key_exists($publicKey, static::PUBLIC_KEYS);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@ if (php_sapi_name() !== 'cli' && substr_count($_SERVER['PHP_SELF'], "/") > 1) {
|
|||||||
require_once("include/config.inc.php");
|
require_once("include/config.inc.php");
|
||||||
require_once("include/db.inc.php");
|
require_once("include/db.inc.php");
|
||||||
require_once("include/functions.inc.php");
|
require_once("include/functions.inc.php");
|
||||||
|
require_once __DIR__.'/Blacklist.php';
|
||||||
require_once("include/block.inc.php");
|
require_once("include/block.inc.php");
|
||||||
require_once("include/account.inc.php");
|
require_once("include/account.inc.php");
|
||||||
require_once("include/transaction.inc.php");
|
require_once("include/transaction.inc.php");
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Arionum\Blacklist;
|
||||||
|
|
||||||
class Transaction
|
class Transaction
|
||||||
{
|
{
|
||||||
// reverse and remove all transactions from a block
|
// reverse and remove all transactions from a block
|
||||||
@@ -225,11 +227,7 @@ class Transaction
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($_config['use_official_blacklist']!==false) {
|
if ($_config['use_official_blacklist']!==false) {
|
||||||
$blacklisted=[
|
if (Blacklist::checkPublicKey($x['public_key'])) {
|
||||||
"PZ8Tyr4Nx8MHsRAGMpZmZ6TWY63dXWSCvVQcHHCNLfiP9LmzWhhpCHx39Bhc67P5HMQM9cctEFvcsUdgrkGqy18taz9ZMrAGtq7NhBYpQ4ZTHkKYiZDaSUqQ", //faucet abuser
|
|
||||||
"PZ8Tyr4Nx8MHsRAGMpZmZ6TWY63dXWSCxYDeQHk7Ke66UB2Un3UMmMoJ7RF5vDZXihdEXi8gk8ZBRAi35aFrER2ZLX1mgND7sLFXKETGTjRYjoHcuRNiJN1g" // octaex
|
|
||||||
];
|
|
||||||
if (in_array($x['public_key'], $blacklisted)) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user