Merge branch 'master' of https://github.com/Astrologies/Alphaland-Website
This commit is contained in:
commit
c1f467b613
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
namespace Alphaland\Assets {
|
||||
class AssetType
|
||||
class AssetTypeHelper
|
||||
{
|
||||
public function IsPurchasable($id)
|
||||
{
|
||||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
/*
|
||||
Alphaland 2021
|
||||
Nikita TODO: ALPHA-22 (Response Models for things that definitely have a known response (like specific SOAP actions))
|
||||
https://jira.mfdlabs.local/browse/ALPHA-22
|
||||
*/
|
||||
|
||||
namespace Alphaland\Grid {
|
||||
|
|
@ -14,16 +16,15 @@ namespace Alphaland\Grid {
|
|||
$this->ServiceIp = $ServiceIp;
|
||||
}
|
||||
|
||||
private function soapCallService(string $name, array $arguments = [])
|
||||
private function SoapCallService(string $name, array $arguments = []): mixed
|
||||
{
|
||||
$soapcl = new \SoapClient($GLOBALS['RCCwsdl'], ["location" => "http://".$this->ServiceIp, "uri" => "http://roblox.com/", "exceptions" => false]);
|
||||
$soapcl = new \SoapClient($GLOBALS['RCCwsdl'], ["location" => "http://" . $this->ServiceIp, "uri" => "http://roblox.com/", "exceptions" => false]);
|
||||
return $soapcl->{$name}($arguments); //thanks BrentDaMage didnt know u can do this
|
||||
}
|
||||
|
||||
private function verifyLuaValue($value) //mostly due to booleans, but maybe something will come up in the future
|
||||
private function VerifyLuaValue(mixed $value): string //mostly due to booleans, but maybe something will come up in the future
|
||||
{
|
||||
switch ($value)
|
||||
{
|
||||
switch ($value) {
|
||||
case is_bool(json_encode($value)) || $value == 1:
|
||||
return json_encode($value);
|
||||
default:
|
||||
|
|
@ -31,10 +32,9 @@ namespace Alphaland\Grid {
|
|||
}
|
||||
}
|
||||
|
||||
private function getLuaType($value): string //currently only supports booleans, integers and strings
|
||||
private function GetLuaType(string $value): string //currently only supports booleans, integers and strings
|
||||
{
|
||||
switch ($value)
|
||||
{
|
||||
switch ($value) {
|
||||
case $value == "true" || $value == "false": //this is so gay but php hates me
|
||||
return "LUA_TBOOLEAN";
|
||||
case !is_string($value) && !is_bool($value) && filter_var($value, FILTER_VALIDATE_INT):
|
||||
|
|
@ -44,23 +44,23 @@ namespace Alphaland\Grid {
|
|||
}
|
||||
}
|
||||
|
||||
private function luaArguments(array $arguments=[]) //arguments for a script being executed
|
||||
private function ConstructLuaArguments(array $arguments = []): array //arguments for a script being executed
|
||||
{
|
||||
if (!empty($arguments)) {
|
||||
$luavalue = array("LuaValue"=>array());
|
||||
foreach ($arguments as $argument) {
|
||||
$luavalue = array("LuaValue" => array());
|
||||
foreach ($arguments as $argument) {
|
||||
array_push($luavalue['LuaValue'], array(
|
||||
"type" => $this->getLuaType($argument),
|
||||
"value" => $this->verifyLuaValue($argument)
|
||||
"type" => $this->GetLuaType($argument),
|
||||
"value" => $this->VerifyLuaValue($argument)
|
||||
));
|
||||
}
|
||||
return $luavalue;
|
||||
}
|
||||
}
|
||||
|
||||
private function soapJobTemplate(string $servicename, string $jobid, int $expiration, int $category, int $cores, string $scriptname, string $script, array $arguments=[])
|
||||
private function ConstructJobTemplate(string $servicename, string $jobid, int $expiration, int $category, int $cores, string $scriptname, string $script, array $arguments = []): mixed
|
||||
{
|
||||
return $this->soapCallService(
|
||||
return $this->SoapCallService(
|
||||
$servicename,
|
||||
array(
|
||||
"job" => array(
|
||||
|
|
@ -72,83 +72,87 @@ namespace Alphaland\Grid {
|
|||
"script" => array(
|
||||
"name" => $scriptname,
|
||||
"script" => $script,
|
||||
"arguments" => $this->luaArguments($arguments)
|
||||
"arguments" => $this->ConstructLuaArguments($arguments)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function soapGetVersion()
|
||||
public function GetVersion(): mixed
|
||||
{
|
||||
return $this->soapCallService("GetVersion");
|
||||
return $this->SoapCallService("GetVersion");
|
||||
}
|
||||
|
||||
public function soapHelloWorld()
|
||||
public function HelloWorld(): mixed
|
||||
{
|
||||
return $this->soapCallService("HelloWorld");
|
||||
return $this->SoapCallService("HelloWorld");
|
||||
}
|
||||
|
||||
public function soapCloseAllJobs()
|
||||
public function CloseAllJobs(): mixed
|
||||
{
|
||||
return $this->soapCallService("CloseAllJobs");
|
||||
return $this->SoapCallService("CloseAllJobs");
|
||||
}
|
||||
|
||||
public function soapCloseExpiredJobs()
|
||||
public function CloseExpiredJobs(): mixed
|
||||
{
|
||||
return $this->soapCallService("CloseExpiredJobs");
|
||||
return $this->SoapCallService("CloseExpiredJobs");
|
||||
}
|
||||
|
||||
public function soapGetAllJobsEx()
|
||||
public function GetAllJobsEx(): mixed
|
||||
{
|
||||
return $this->soapCallService("GetAllJobsEx");
|
||||
return $this->SoapCallService("GetAllJobsEx");
|
||||
}
|
||||
|
||||
public function soapGetStatus()
|
||||
public function GetStatus(): mixed
|
||||
{
|
||||
return $this->soapCallService("GetStatus");
|
||||
return $this->SoapCallService("GetStatus");
|
||||
}
|
||||
|
||||
public function soapDiagEx(string $type, string $jobid)
|
||||
public function DiagEx(string $type, string $jobid): mixed
|
||||
{
|
||||
return $this->soapCallService("DiagEx", array("type" => $type, "jobID" => $jobid));
|
||||
return $this->SoapCallService("DiagEx", array("type" => $type, "jobID" => $jobid));
|
||||
}
|
||||
|
||||
public function soapCloseJob(string $jobid)
|
||||
// this doesn't return anything
|
||||
// https://pastebin.com/raw/pr5NDBwC
|
||||
public function CloseJob(string $jobid): mixed
|
||||
{
|
||||
return $this->soapCallService("CloseJob", array("jobID" => $jobid));
|
||||
return $this->SoapCallService("CloseJob", array("jobID" => $jobid));
|
||||
}
|
||||
|
||||
public function soapGetExpiration(string $jobid)
|
||||
public function GetExpiration(string $jobid): mixed
|
||||
{
|
||||
return $this->soapCallService("GetExpiration", array("jobID" => $jobid));
|
||||
return $this->SoapCallService("GetExpiration", array("jobID" => $jobid));
|
||||
}
|
||||
|
||||
public function soapExecuteEx(string $jobid, string $scriptname, string $script, array $arguments=[])
|
||||
public function ExecuteEx(string $jobid, string $scriptname, string $script, array $arguments = []): mixed
|
||||
{
|
||||
return $this->soapCallService("ExecuteEx", array(
|
||||
"jobID" => $jobid,
|
||||
return $this->SoapCallService(
|
||||
"ExecuteEx",
|
||||
array(
|
||||
"jobID" => $jobid,
|
||||
"script" => array(
|
||||
"name" => $scriptname,
|
||||
"script" => $script,
|
||||
"arguments" => $this->luaArguments($arguments)
|
||||
"arguments" => $this->ConstructLuaArguments($arguments)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function soapRenewLease(string $jobid, int $expiration)
|
||||
public function RenewLease(string $jobid, int $expiration): mixed
|
||||
{
|
||||
return $this->soapCallService("RenewLease", array("jobID" => $jobid, "expirationInSeconds" => $expiration));
|
||||
return $this->SoapCallService("RenewLease", array("jobID" => $jobid, "expirationInSeconds" => $expiration));
|
||||
}
|
||||
|
||||
public function soapOpenJobEx(string $jobid, int $expiration, string $scriptname, string $script, array $arguments=[])
|
||||
public function OpenJobEx(string $jobid, int $expiration, string $scriptname, string $script, array $arguments = []): mixed
|
||||
{
|
||||
return $this->soapJobTemplate("OpenJobEx", $jobid, $expiration, 1, 3, $scriptname, $script, $arguments);
|
||||
return $this->ConstructJobTemplate("OpenJobEx", $jobid, $expiration, 1, 3, $scriptname, $script, $arguments);
|
||||
}
|
||||
|
||||
public function soapBatchJobEx(string $jobid, int $expiration, string $scriptname, string $script, array $arguments=[])
|
||||
public function BatchJobEx(string $jobid, int $expiration, string $scriptname, string $script, array $arguments = []): mixed
|
||||
{
|
||||
return $this->soapJobTemplate("BatchJobEx", $jobid, $expiration, 1, 3, $scriptname, $script, $arguments);
|
||||
return $this->ConstructJobTemplate("BatchJobEx", $jobid, $expiration, 1, 3, $scriptname, $script, $arguments);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,54 +6,57 @@
|
|||
|
||||
namespace Alphaland\Users {
|
||||
|
||||
use Alphaland\Common\HashingUtiltity;
|
||||
use PDO;
|
||||
|
||||
class Activation
|
||||
{
|
||||
private function generateActivationCode()
|
||||
|
||||
private static PDO $pdo = $GLOBALS['pdo'];
|
||||
|
||||
private static function GenerateActivationCode(): string
|
||||
{
|
||||
$hash = "";
|
||||
while (true) {
|
||||
$hash = genHash(32);
|
||||
do {
|
||||
$hash = HashingUtiltity::GenerateByteHash(32);
|
||||
|
||||
$keycheck = $GLOBALS['pdo']->prepare("SELECT * FROM `alphaland_verification` WHERE `activationcode` = :ac");
|
||||
$keycheck->bindParam(":ac", $hash, PDO::PARAM_STR);
|
||||
$keycheck->execute();
|
||||
if ($keycheck->rowCount() == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
$query = Activation::$pdo->prepare("SELECT COUNT(*) FROM `alphaland_verification` WHERE `activationcode` = :ac");
|
||||
$query->bindParam(":ac", $hash, PDO::PARAM_STR);
|
||||
$query->execute();
|
||||
} while ($query->fetchColumn(0) != 0);
|
||||
|
||||
return $hash;
|
||||
}
|
||||
|
||||
public function getUserActivationCode(int $userid)
|
||||
public static function GetUserActivationCode(int $userid): string
|
||||
{
|
||||
$query = $GLOBALS['pdo']->prepare("SELECT * FROM `alphaland_verification` WHERE `uid` = :uid");
|
||||
$query = Activation::$pdo->prepare("SELECT `activationcode` FROM `alphaland_verification` WHERE `uid` = :uid");
|
||||
$query->bindParam(":uid", $userid, PDO::PARAM_INT);
|
||||
$query->execute();
|
||||
|
||||
if ($query->rowCount() == 1) {
|
||||
return $query->fetch(PDO::FETCH_OBJ)->activationcode;
|
||||
return (string)$query->fetch(PDO::FETCH_OBJ)->activationcode;
|
||||
}
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
public function isUserActivated(int $userid)
|
||||
public static function IsUserActivated(int $userid): bool
|
||||
{
|
||||
$query = $GLOBALS['pdo']->prepare("SELECT * FROM `alphaland_verification` WHERE `isactivated` = 1 AND `uid` = :uid");
|
||||
$query = Activation::$pdo->prepare("SELECT COUNT(*) FROM `alphaland_verification` WHERE `isactivated` = 1 AND `uid` = :uid");
|
||||
$query->bindParam(":uid", $userid, PDO::PARAM_INT);
|
||||
$query->execute();
|
||||
if ($query->rowCount() > 0) {
|
||||
if ($query->fetchColumn(0) > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function setupUserActivation(int $userid) //this should be ran when the user first signs up
|
||||
public static function SetupUserActivation(int $userid): bool //this should be ran when the user first signs up
|
||||
{
|
||||
if (!$this->isUserActivated($userid)) {
|
||||
$activationcode = $this->generateActivationCode();
|
||||
if (!Activation::IsUserActivated($userid)) {
|
||||
$activationcode = Activation::GenerateActivationCode();
|
||||
|
||||
$n = $GLOBALS['pdo']->prepare("INSERT INTO `alphaland_verification`(`activationcode`,`uid`) VALUES(:ac, :userid)");
|
||||
$n = Activation::$pdo->prepare("INSERT INTO `alphaland_verification`(`activationcode`,`uid`) VALUES(:ac, :userid)");
|
||||
$n->bindParam(":ac", $activationcode, PDO::PARAM_STR);
|
||||
$n->bindParam(":userid", $userid, PDO::PARAM_INT);
|
||||
$n->execute();
|
||||
|
|
|
|||
|
|
@ -5,8 +5,11 @@
|
|||
This is extremely sensitive.
|
||||
|
||||
Fuck u nsg
|
||||
Fuck you too Austin :)
|
||||
*/
|
||||
|
||||
use Alphaland\Users\Activation;
|
||||
|
||||
try
|
||||
{
|
||||
//php config
|
||||
|
|
@ -125,8 +128,8 @@ try
|
|||
forceHttpsCloudflare();
|
||||
}
|
||||
|
||||
$activated = new Alphaland\Users\Activation();
|
||||
$activated = $activated->isUserActivated($GLOBALS['user']->id);
|
||||
// TODO: WebContextManager::CurrentUser instead of $GLOBALS['user']!!
|
||||
$activated = Activation::IsUserActivated($GLOBALS['user']->id);
|
||||
$maintenance = checkIfUnderMaintenance();
|
||||
$banned = checkIfBanned($GLOBALS['user']->id);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
User class
|
||||
*/
|
||||
|
||||
use Alphaland\Users\Activation;
|
||||
|
||||
class user {
|
||||
public $id = -1;
|
||||
public $name = "";
|
||||
|
|
@ -65,8 +67,7 @@ class user {
|
|||
// ..
|
||||
|
||||
//activation stuff
|
||||
$activated = new Alphaland\Users\Activation();
|
||||
$activated = $activated->isUserActivated($this->id);
|
||||
$activated = Activation::IsUserActivated($this->id);
|
||||
|
||||
if (!banned($this->id))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
<?php
|
||||
$activation = new Alphaland\Users\Activation();
|
||||
|
||||
if ($activation->isUserActivated($user->id)) {
|
||||
use Alphaland\Users\Activation;
|
||||
|
||||
if (Activation::IsUserActivated($user->id)) {
|
||||
redirect("/");
|
||||
}
|
||||
|
||||
$activationcode = $activation->getUserActivationCode($user->id);
|
||||
$activationcode = Activation::GetUserActivationCode($user->id);
|
||||
|
||||
$body = '
|
||||
<div class="container-fluid" style="display: flex;justify-content: center;align-items: center;text-align: center;min-height: 100vh;">
|
||||
|
|
|
|||
Loading…
Reference in New Issue