Updated Project Source code (I don't remember what i did.)
This commit is contained in:
parent
fc2e4d5a73
commit
4879fdf36d
10 changed files with 289 additions and 10 deletions
|
@ -37,11 +37,7 @@ abstract class Method
|
|||
|
||||
try
|
||||
{
|
||||
if(!SessionManager::sessionExists($request->getSessionUuid()))
|
||||
{
|
||||
throw new StandardException(sprintf("The requested session %s was not found", $request->getSessionUuid()), StandardError::SESSION_NOT_FOUND);
|
||||
}
|
||||
|
||||
// NOTE: If the session UUID was provided, it has already been validated up until this point
|
||||
return SessionManager::getSession($request->getSessionUuid());
|
||||
}
|
||||
catch(DatabaseOperationException $e)
|
||||
|
|
27
src/Socialbox/Classes/Configuration.php
Normal file
27
src/Socialbox/Classes/Configuration.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace Socialbox\Classes;
|
||||
|
||||
class Configuration
|
||||
{
|
||||
private static ?array $configuration = null;
|
||||
|
||||
public static function getConfiguration(): array
|
||||
{
|
||||
if(self::$configuration === null)
|
||||
{
|
||||
$config = new \ConfigLib\Configuration('net.nosial.socialbox');
|
||||
|
||||
$config->setDefault('database.host', '127.0.0.1');
|
||||
$config->setDefault('database.port', 3306);
|
||||
$config->setDefault('database.username', 'root');
|
||||
$config->setDefault('database.password', null);
|
||||
$config->setDefault('database.name', 'test');
|
||||
$config->save();
|
||||
|
||||
self::$configuration = $config->getConfiguration();
|
||||
}
|
||||
|
||||
return self::$configuration;
|
||||
}
|
||||
}
|
|
@ -13,7 +13,7 @@ class Database
|
|||
private static ?PDO $instance = null;
|
||||
|
||||
/**
|
||||
* @return mysqli
|
||||
* @return PDO
|
||||
* @throws DatabaseOperationException
|
||||
*/
|
||||
public static function getConnection(): PDO
|
||||
|
@ -22,7 +22,7 @@ class Database
|
|||
{
|
||||
try
|
||||
{
|
||||
$dsn = 'mysql:host=172.27.0.1;dbname=socialbox;port=3306;charset=utf8mb4';
|
||||
$dsn = 'mysql:host=127.0.0.1;dbname=socialbox;port=3306;charset=utf8mb4';
|
||||
self::$instance = new PDO($dsn, 'root', 'root');
|
||||
|
||||
// Set some common PDO attributes for better error handling
|
||||
|
|
|
@ -32,12 +32,12 @@
|
|||
{
|
||||
if($publicKey === '')
|
||||
{
|
||||
throw new InvalidArgumentException('The public key cannot be empty', StandardError::RPC_INVALID_ARGUMENTS);
|
||||
throw new InvalidArgumentException('The public key cannot be empty', 400);
|
||||
}
|
||||
|
||||
if(!Cryptography::validatePublicKey($publicKey))
|
||||
{
|
||||
throw new InvalidArgumentException('The given public key is invalid', StandardError::INVALID_PUBLIC_KEY);
|
||||
throw new InvalidArgumentException('The given public key is invalid', 400);
|
||||
}
|
||||
|
||||
$publicKey = Utilities::base64decode($publicKey);
|
||||
|
|
18
src/Socialbox/Program.php
Normal file
18
src/Socialbox/Program.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace Socialbox;
|
||||
|
||||
class Program
|
||||
{
|
||||
/**
|
||||
* Socialbox main entry point
|
||||
*
|
||||
* @param string[] $args Command-line arguments
|
||||
* @return int Exit code
|
||||
*/
|
||||
public static function main(array $args): int
|
||||
{
|
||||
print("Hello World from net.nosial.socialbox!" . PHP_EOL);
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Socialbox;
|
||||
|
||||
use ConfigLib\Configuration;
|
||||
use Socialbox\Classes\RpcHandler;
|
||||
use Socialbox\Enums\StandardError;
|
||||
use Socialbox\Enums\StandardMethods;
|
||||
|
@ -9,6 +10,11 @@
|
|||
|
||||
class Socialbox
|
||||
{
|
||||
public static function getConfiguration(): array
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static function handleRpc(): void
|
||||
{
|
||||
try
|
||||
|
@ -29,7 +35,7 @@
|
|||
|
||||
if($method === false)
|
||||
{
|
||||
$response = $rpcRequest->produceError(StandardError::RPC_METHOD_NOT_FOUND, 'The requested method does not exist');;
|
||||
$response = $rpcRequest->produceError(StandardError::RPC_METHOD_NOT_FOUND, 'The requested method does not exist');
|
||||
if($response !== null)
|
||||
{
|
||||
$results[] = $response;
|
||||
|
|
8
src/Socialbox/Socialbox/Socialbox.php
Normal file
8
src/Socialbox/Socialbox/Socialbox.php
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Socialbox;
|
||||
|
||||
class Socialbox
|
||||
{
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue