User and Render impl update
This commit is contained in:
parent
006d56fc8c
commit
a879fb7c4f
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
namespace Alphaland\Users {
|
namespace Alphaland\Users {
|
||||||
|
|
||||||
|
use Alphaland\Users\User;
|
||||||
use Alphaland\Users\Render;
|
use Alphaland\Users\Render;
|
||||||
use Exception;
|
use Exception;
|
||||||
use PDO;
|
use PDO;
|
||||||
|
|
@ -93,7 +94,7 @@ namespace Alphaland\Users {
|
||||||
$rightleg = (int)$wearingcolors->rl;
|
$rightleg = (int)$wearingcolors->rl;
|
||||||
|
|
||||||
//currently wearing items
|
//currently wearing items
|
||||||
$assets = wearingAssets($userid);
|
$assets = User::GetWearingAssetsString($userid);
|
||||||
|
|
||||||
//add to db
|
//add to db
|
||||||
$outfit = $GLOBALS['pdo']->prepare("INSERT INTO user_outfits(userid, assets, name, h, t, la, ra, ll, rl, headshotAngleRight, headshotAngleLeft, ThumbHash, HeadshotThumbHash, whenCreated) VALUES (:uid, :assets, :name, :h, :t, :la, :ra, :ll, :rl, :har, :hal, :th, :hth, UNIX_TIMESTAMP())");
|
$outfit = $GLOBALS['pdo']->prepare("INSERT INTO user_outfits(userid, assets, name, h, t, la, ra, ll, rl, headshotAngleRight, headshotAngleLeft, ThumbHash, HeadshotThumbHash, whenCreated) VALUES (:uid, :assets, :name, :h, :t, :la, :ra, :ll, :rl, :har, :hal, :th, :hth, UNIX_TIMESTAMP())");
|
||||||
|
|
|
||||||
|
|
@ -64,84 +64,103 @@ namespace Alphaland\Users {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static function SetPlayerRenderStats(int $userid)
|
||||||
|
{
|
||||||
|
$setrenderstat = $GLOBALS['pdo']->prepare("UPDATE users SET pendingRender = 1, pendingHeadshotRender = 1, renderCount = renderCount+1, lastRender = UNIX_TIMESTAMP(), lastHeadshotRender = UNIX_TIMESTAMP() WHERE id = :u");
|
||||||
|
$setrenderstat->bindParam(":u", $userid, PDO::PARAM_INT);
|
||||||
|
$setrenderstat->execute();
|
||||||
|
if ($setrenderstat->rowCount() > 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static function RenderPlayerCloseup(int $userid, bool $fork=false)
|
public static function RenderPlayerCloseup(int $userid, bool $fork=false)
|
||||||
{
|
{
|
||||||
if ($fork)
|
if (Render::SetPlayerRenderStats($userid))
|
||||||
{
|
{
|
||||||
$job = popen("cd C:/Webserver/nginx/Alphaland/WebserviceTools/RenderTools && start /B php backgroundRenderJob.php ".$userid." avatarcloseup", "r"); //throwaway background process
|
if ($fork)
|
||||||
if ($job !== FALSE);
|
|
||||||
{
|
{
|
||||||
pclose($job);
|
$job = popen("cd C:/Webserver/nginx/Alphaland/WebserviceTools/RenderTools && start /B php backgroundRenderJob.php ".$userid." avatarcloseup", "r"); //throwaway background process
|
||||||
return true;
|
if ($job !== FALSE);
|
||||||
|
{
|
||||||
|
pclose($job);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
else
|
||||||
}
|
{
|
||||||
else
|
$script = file_get_contents($GLOBALS['avatarcloseupthumbnailscript']);
|
||||||
{
|
|
||||||
$script = file_get_contents($GLOBALS['avatarcloseupthumbnailscript']);
|
$angleright = userInfo($userid)->headshotAngleRight;
|
||||||
|
$angleleft = userInfo($userid)->headshotAngleLeft;
|
||||||
$angleright = userInfo($userid)->headshotAngleRight;
|
|
||||||
$angleleft = userInfo($userid)->headshotAngleLeft;
|
$soap = new RccServiceHelper($GLOBALS['thumbnailArbiter']);
|
||||||
|
$soap = $soap->BatchJobEx(
|
||||||
$soap = new RccServiceHelper($GLOBALS['thumbnailArbiter']);
|
$soap->ConstructGenericJob(gen_uuid(), 25, 0, 3, "Render Player Closeup ".$userid, $script, array(
|
||||||
$soap = $soap->BatchJobEx(
|
$userid,
|
||||||
$soap->ConstructGenericJob(gen_uuid(), 25, 0, 3, "Render Player Closeup ".$userid, $script, array(
|
"https://www.alphaland.cc/",
|
||||||
$userid,
|
"https://api.alphaland.cc/users/avatar-accoutrements?userId=".$userid,
|
||||||
"https://www.alphaland.cc/",
|
"png",
|
||||||
"https://api.alphaland.cc/users/avatar-accoutrements?userId=".$userid,
|
"840",
|
||||||
"png",
|
"840",
|
||||||
"840",
|
(bool)$angleright, //angleRight
|
||||||
"840",
|
(bool)$angleleft //angleLeft
|
||||||
(bool)$angleright, //angleRight
|
))
|
||||||
(bool)$angleleft //angleLeft
|
);
|
||||||
))
|
|
||||||
);
|
if (!is_soap_fault($soap)) {
|
||||||
|
Render::Update($userid, $soap, true);
|
||||||
if (!is_soap_fault($soap)) {
|
return true;
|
||||||
Render::Update($userid, $soap, true);
|
} else {
|
||||||
return true;
|
die(print_r($soap));
|
||||||
} else {
|
}
|
||||||
die(print_r($soap));
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function RenderPlayer(int $userid, bool $fork=false)
|
public static function RenderPlayer(int $userid, bool $fork=false)
|
||||||
{
|
{
|
||||||
if ($fork)
|
if (Render::SetPlayerRenderStats($userid))
|
||||||
{
|
{
|
||||||
$job = popen("cd C:/Webserver/nginx/Alphaland/WebserviceTools/RenderTools && start /B php backgroundRenderJob.php ".$userid." avatar", "r"); //throwaway background process
|
if ($fork)
|
||||||
if ($job !== FALSE);
|
|
||||||
{
|
{
|
||||||
pclose($job);
|
$job = popen("cd C:/Webserver/nginx/Alphaland/WebserviceTools/RenderTools && start /B php backgroundRenderJob.php ".$userid." avatar", "r"); //throwaway background process
|
||||||
return true;
|
if ($job !== FALSE);
|
||||||
|
{
|
||||||
|
pclose($job);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
else
|
||||||
}
|
{
|
||||||
else
|
Render::RenderPlayerCloseup($userid, true); //run in the background so it will *hopefully* finish with this
|
||||||
{
|
$script = file_get_contents($GLOBALS['avatarthumbnailscript']);
|
||||||
Render::RenderPlayerCloseup($userid, true); //run in the background so it will *hopefully* finish with this
|
|
||||||
$script = file_get_contents($GLOBALS['avatarthumbnailscript']);
|
$soap = new RccServiceHelper($GLOBALS['thumbnailArbiter']);
|
||||||
|
$soap = $soap->BatchJobEx(
|
||||||
$soap = new RccServiceHelper($GLOBALS['thumbnailArbiter']);
|
$soap->ConstructGenericJob(gen_uuid(), 25, 0, 3, "Render Player ".$userid, $script, array(
|
||||||
$soap = $soap->BatchJobEx(
|
$userid,
|
||||||
$soap->ConstructGenericJob(gen_uuid(), 25, 0, 3, "Render Player ".$userid, $script, array(
|
"https://api.alphaland.cc/users/avatar-accoutrements?userId=".$userid,
|
||||||
$userid,
|
"https://www.alphaland.cc/",
|
||||||
"https://api.alphaland.cc/users/avatar-accoutrements?userId=".$userid,
|
"png",
|
||||||
"https://www.alphaland.cc/",
|
"840",
|
||||||
"png",
|
"840"
|
||||||
"840",
|
))
|
||||||
"840"
|
);
|
||||||
))
|
|
||||||
);
|
if (!is_soap_fault($soap)) {
|
||||||
|
Render::Update($userid, $soap);
|
||||||
if (!is_soap_fault($soap)) {
|
return true;
|
||||||
Render::Update($userid, $soap);
|
}
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function Update(int $userid, $soapobject, $headshot=false)
|
public static function Update(int $userid, $soapobject, $headshot=false)
|
||||||
|
|
|
||||||
|
|
@ -18,5 +18,53 @@ namespace Alphaland\Users {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function SetHeadshotAngleRight(int $userid)
|
||||||
|
{
|
||||||
|
$right = $GLOBALS['pdo']->prepare('UPDATE users SET headshotAngleRight = 1, headshotAngleLeft = 0 WHERE id = :uid');
|
||||||
|
$right->bindParam(":uid", $userid, PDO::PARAM_INT);
|
||||||
|
$right->execute();
|
||||||
|
if ($right->rowCount() > 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function SetHeadshotAngleLeft(int $userid)
|
||||||
|
{
|
||||||
|
$left = $GLOBALS['pdo']->prepare('UPDATE users SET headshotAngleRight = 0, headshotAngleLeft = 1 WHERE id = :uid');
|
||||||
|
$left->bindParam(":uid", $userid, PDO::PARAM_INT);
|
||||||
|
$left->execute();
|
||||||
|
if ($left->rowCount() > 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function SetHeadshotAngleCenter(int $userid)
|
||||||
|
{
|
||||||
|
$center = $GLOBALS['pdo']->prepare('UPDATE users SET headshotAngleRight = 0, headshotAngleLeft = 0 WHERE id = :uid');
|
||||||
|
$center->bindParam(":uid", $userid, PDO::PARAM_INT);
|
||||||
|
$center->execute();
|
||||||
|
if ($center->rowCount() > 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function GetWearingAssetsString(int $userid) //returns wearing asset list separated by ;
|
||||||
|
{
|
||||||
|
$wearingitems = $GLOBALS['pdo']->prepare('SELECT * FROM wearing_items WHERE uid = :uid ORDER BY aid ASC'); //wearing items from lowest to highest (EZ)
|
||||||
|
$wearingitems->bindParam(":uid", $userid, PDO::PARAM_INT);
|
||||||
|
$wearingitems->execute();
|
||||||
|
|
||||||
|
$iter = 0;
|
||||||
|
$wearingassets = "";
|
||||||
|
foreach($wearingitems as $item) {
|
||||||
|
$iter += 1;
|
||||||
|
$wearingassets .= ($iter == $wearingitems->rowCount()) ? $item['aid'] : $item['aid'] . ';';
|
||||||
|
}
|
||||||
|
return $wearingassets;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1376,72 +1376,6 @@ function configPermission($groupid)
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
//render utility functions
|
|
||||||
|
|
||||||
function setHeadshotAngleRight($userid)
|
|
||||||
{
|
|
||||||
$right = $GLOBALS['pdo']->prepare('UPDATE users SET headshotAngleRight = 1, headshotAngleLeft = 0 WHERE id = :uid');
|
|
||||||
$right->bindParam(":uid", $userid, PDO::PARAM_INT);
|
|
||||||
$right->execute();
|
|
||||||
if ($right->rowCount() > 0)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function setHeadshotAngleLeft($userid)
|
|
||||||
{
|
|
||||||
$left = $GLOBALS['pdo']->prepare('UPDATE users SET headshotAngleRight = 0, headshotAngleLeft = 1 WHERE id = :uid');
|
|
||||||
$left->bindParam(":uid", $userid, PDO::PARAM_INT);
|
|
||||||
$left->execute();
|
|
||||||
if ($left->rowCount() > 0)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function setHeadshotAngleCenter($userid)
|
|
||||||
{
|
|
||||||
$center = $GLOBALS['pdo']->prepare('UPDATE users SET headshotAngleRight = 0, headshotAngleLeft = 0 WHERE id = :uid');
|
|
||||||
$center->bindParam(":uid", $userid, PDO::PARAM_INT);
|
|
||||||
$center->execute();
|
|
||||||
if ($center->rowCount() > 0)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function wearingAssets($userid) //returns wearing asset list separated by ;
|
|
||||||
{
|
|
||||||
$wearingitems = $GLOBALS['pdo']->prepare('SELECT * FROM wearing_items WHERE uid = :uid ORDER BY aid ASC'); //wearing items from lowest to highest (EZ)
|
|
||||||
$wearingitems->bindParam(":uid", $userid, PDO::PARAM_INT);
|
|
||||||
$wearingitems->execute();
|
|
||||||
|
|
||||||
$iter = 0;
|
|
||||||
$wearingassets = "";
|
|
||||||
foreach($wearingitems as $item)
|
|
||||||
{
|
|
||||||
$iter += 1;
|
|
||||||
$wearingassets .= ($iter == $wearingitems->rowCount()) ? $item['aid'] : $item['aid'] . ';';
|
|
||||||
}
|
|
||||||
return $wearingassets;
|
|
||||||
}
|
|
||||||
|
|
||||||
function rerenderutility()
|
|
||||||
{
|
|
||||||
$localplayer = $GLOBALS['user']->id;
|
|
||||||
|
|
||||||
$setrenderstat = $GLOBALS['pdo']->prepare("UPDATE users SET pendingRender = 1, pendingHeadshotRender = 1, renderCount = renderCount+1, lastRender = UNIX_TIMESTAMP(), lastHeadshotRender = UNIX_TIMESTAMP() WHERE id = :u");
|
|
||||||
$setrenderstat->bindParam(":u", $localplayer, PDO::PARAM_INT);
|
|
||||||
$setrenderstat->execute();
|
|
||||||
UsersRender::RenderPlayer($localplayer);
|
|
||||||
}
|
|
||||||
|
|
||||||
//end local user render utility functions
|
|
||||||
|
|
||||||
//asset functions
|
//asset functions
|
||||||
|
|
||||||
function availableAssetId() {
|
function availableAssetId() {
|
||||||
|
|
@ -3181,7 +3115,7 @@ function deequipItem($assetId)
|
||||||
$deequip->bindParam(":a", $assetId, PDO::PARAM_INT);
|
$deequip->bindParam(":a", $assetId, PDO::PARAM_INT);
|
||||||
$deequip->execute();
|
$deequip->execute();
|
||||||
|
|
||||||
rerenderutility();
|
UsersRender::RenderPlayer($localuser);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -3243,7 +3177,7 @@ function equipItem($assetId)
|
||||||
$equip->bindParam(":a", $assetId, PDO::PARAM_INT);
|
$equip->bindParam(":a", $assetId, PDO::PARAM_INT);
|
||||||
$equip->execute();
|
$equip->execute();
|
||||||
|
|
||||||
rerenderutility();
|
UsersRender::RenderPlayer($localuser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ if(getBC($clr) != "-")
|
||||||
$upd->bindParam(":b", $clr, PDO::PARAM_INT);
|
$upd->bindParam(":b", $clr, PDO::PARAM_INT);
|
||||||
$upd->execute();
|
$upd->execute();
|
||||||
|
|
||||||
rerenderutility();
|
Render::RenderPlayer($localuser);
|
||||||
|
|
||||||
echo "s";
|
echo "s";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ Alphaland 2021
|
||||||
//headers
|
//headers
|
||||||
|
|
||||||
use Alphaland\Users\Render;
|
use Alphaland\Users\Render;
|
||||||
|
use Alphaland\Users\User;
|
||||||
|
|
||||||
header("Access-Control-Allow-Origin: https://www.alphaland.cc");
|
header("Access-Control-Allow-Origin: https://www.alphaland.cc");
|
||||||
header("access-control-allow-credentials: true");
|
header("access-control-allow-credentials: true");
|
||||||
|
|
@ -27,22 +28,22 @@ else
|
||||||
if (!Render::PendingRender($user->id))
|
if (!Render::PendingRender($user->id))
|
||||||
{
|
{
|
||||||
if ($angleRight) {
|
if ($angleRight) {
|
||||||
if (setHeadshotAngleRight($user->id)) {
|
if (User::SetHeadshotAngleRight($user->id)) {
|
||||||
$alert = true;
|
$alert = true;
|
||||||
}
|
}
|
||||||
} else if ($angleLeft) {
|
} else if ($angleLeft) {
|
||||||
if (setHeadshotAngleLeft($user->id)) {
|
if (User::SetHeadshotAngleLeft($user->id)) {
|
||||||
$alert = true;
|
$alert = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (setHeadshotAngleCenter($user->id)) {
|
if (User::SetHeadshotAngleCenter($user->id)) {
|
||||||
$alert = true;
|
$alert = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($alert) {
|
if ($alert) {
|
||||||
if (!Render::RenderCooldown($user->id)) {
|
if (!Render::RenderCooldown($user->id)) {
|
||||||
rerenderutility();
|
Render::RenderPlayer($localuser);
|
||||||
} else {
|
} else {
|
||||||
$alert = "Slow down!";
|
$alert = "Slow down!";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue