"; ?>
0) { $final_string = $final_string.aes_decrypt($row['code']); //echo "FinalString: ".$final_string; // Get a list of ALL data which has the first comma delimited item called plot_id if (strpos($final_string, ',') !== false) { // String contains commas $data_array = explode($delimiter, $final_string); $id = $row['id']; if ($data_array[0] == "plotdata") { $sPlotBaseName_FromDB = $data_array[1]; if ($sPlotBaseName_FromDB == $sPlotBaseName) { $total_rows_with_plot_base = $total_rows_with_plot_base + 1; } } } } } //echo "
TOTAL ROWS FOUND: ".$total_rows_with_plot_base."
"; // IF No plots are found, then generate a brand new plot and add this user in if ($total_rows_with_plot_base == 0) { // No Data was found in the database. So ADD this baseplot and setup a new entry for it in the database along with THIS user entry. $sFinalPlotName = $sPlotBaseName."_1"; $sFinalPlotNameToExport = $sFinalPlotName; $sCurrentUsers = "1"; // This is the CURRENT user $string_to_add_to_database = "plotdata,".$sPlotBaseName.",".$sPlotMaxUsers.",".$sFinalPlotName.",".$sCurrentUsers; //echo "2 - INSERT STRING: ".$string_to_add_to_database."
";
$string_to_add_to_database = aes_encrypt($string_to_add_to_database);
$custom_id = uniqid();
$id = aes_encrypt($custom_id);
// Create the SQL command to insert a new entry
$sql = "INSERT INTO chrm_code_data (id, code) VALUES ('".$id."', '".$string_to_add_to_database."')";
// Execute the SQL command
$result = mysqli_query($con, $sql);
}
else if ($total_rows_with_plot_base > 0)
{
// Plots have been found, go through them all again, however this time check to see if even ONE has a spot available to add this user into
$plot_with_space_found = "false";
foreach ($rows as $row)
{
$final_string = ""; // Reset the variable here
if ($row['code'] !== null && strlen($row['code']) > 0)
{
$final_string = $final_string.aes_decrypt($row['code']);
if (strpos($final_string, ',') !== false) {
// String contains commas
$data_array = explode($delimiter, $final_string);
$id = $row['id'];
//echo "
FINAL STRING: ".$final_string." Data: ".$data_array."
"; if ($data_array[0] == "plotdata") { $sPlotBaseName_FromDB = $data_array[1]; $sPlotMaxUsers_FromDB = $data_array[2]; $sFinalPlotName_FromDB = $data_array[3]; $sCurrentUsers_FromDB = $data_array[4]; if ($sPlotBaseName_FromDB == $sPlotBaseName) { //echo "
Plot ".$id." Max: ".$sPlotMaxUsers_FromDB." Cur: ".$sCurrentUsers_FromDB."
";
if (intval($sCurrentUsers_FromDB) < intval($sPlotMaxUsers_FromDB) && $plot_with_space_found == "false")
{
//echo "
ID FOUND WITH SPACE: ".$id."
";
// Return THIS plot name as the final plot to go to
$sFinalPlotNameToExport = $sFinalPlotName_FromDB;
// A plot WITH space has been found, so no need to create a new plot
$plot_with_space_found = "true";
// UPDATE the found plot and INCREMENT the current user count
$nCurrentUsers = intval($sCurrentUsers_FromDB) + 1;
$sCurrentUsers = "".$nCurrentUsers;
$data_to_update = "plotdata".",".$sPlotBaseName_FromDB.",".$sPlotMaxUsers_FromDB.",".$sFinalPlotName_FromDB.",".$sCurrentUsers;
$newCode = aes_encrypt($data_to_update);
$sql = "UPDATE chrm_code_data SET code = '".$newCode."' WHERE id = '".$id."'";
$result = mysqli_query($con, $sql);
}
}
}
}
}
}
}
if ($plot_with_space_found == "false")
{
// Create a NEW plot with NEW id based on count
$new_plot_number = $total_rows_with_plot_base + 1;
$sFinalPlotName = $sPlotBaseName."_".$new_plot_number;
$sFinalPlotNameToExport = $sFinalPlotName;
$sCurrentUsers = "1"; // This is the CURRENT user
$string_to_add_to_database = "plotdata,".$sPlotBaseName.",".$sPlotMaxUsers.",".$sFinalPlotName.",".$sCurrentUsers;
//echo "1 - INSERT STRING: ".$string_to_add_to_database."
";
$string_to_add_to_database = aes_encrypt($string_to_add_to_database);
$custom_id = uniqid();
$id = aes_encrypt($custom_id);
// Create the SQL command to insert a new entry
$sql = "INSERT INTO chrm_code_data (id, code) VALUES ('".$id."', '".$string_to_add_to_database."')";
// Execute the SQL command
$result = mysqli_query($con, $sql);
}
echo $sFinalPlotNameToExport;
}
else if ($command_in == "PlotCloneExit")
{
// For the exit of plot clones, get the exact entry based on the plot clone user has entered and then remove them from there
// Reduce down to 0 users maximum and then destroy the entry
// EXAMPLE: https://metaverse.artplanet.ca/my-admin/enterprise/custom_data_plotclones.php?data=PlotCloneExit,genesis_3
// Break rest of data down into parts needed
$sPlotName = $data_in_split[1];
$bFoundPlotData = "false";
// Get total rows that have $sPlotBaseName
$total_rows_with_plot_base = 0;
foreach ($rows as $row)
{
$final_string = ""; // Reset the variable here
if ($row['code'] !== null && strlen($row['code']) > 0)
{
$final_string = $final_string.aes_decrypt($row['code']);
//echo "FinalString: ".$final_string;
// Get a list of ALL data which has the first comma delimited item called plot_id
if (strpos($final_string, ',') !== false) {
// String contains commas
$data_array = explode($delimiter, $final_string);
$id = $row['id'];
if ($data_array[0] == "plotdata")
{
$sPlotBaseName_FromDB = $data_array[1];
$sPlotMaxUsers_FromDB = $data_array[2];
$sFinalPlotName_FromDB = $data_array[3];
$sCurrentUsers_FromDB = $data_array[4];
if ($sFinalPlotName_FromDB == $sPlotName)
{
//echo "FOUND PLOT: ".$sFinalPlotName_FromDB;
$total_rows_with_plot_base = $total_rows_with_plot_base + 1;
// Reduce the amount of current users by 1
$nCurrentUsers = intval($sCurrentUsers_FromDB) - 1;
if ($nCurrentUsers <= 0)
{
// DELETE THIS ENTRY
$sql = "DELETE FROM chrm_code_data WHERE id = '".$id."'";
$result = mysqli_query($con, $sql);
}
else if ($nCurrentUsers > 0)
{
// UPDATE the found plot and DECREMENT the current user count
$nCurrentUsers = intval($sCurrentUsers_FromDB) - 1;
$sCurrentUsers = "".$nCurrentUsers;
$data_to_update = "plotdata".",".$sPlotBaseName_FromDB.",".$sPlotMaxUsers_FromDB.",".$sFinalPlotName_FromDB.",".$sCurrentUsers;
$newCode = aes_encrypt($data_to_update);
$sql = "UPDATE chrm_code_data SET code = '".$newCode."' WHERE id = '".$id."'";
$result = mysqli_query($con, $sql);
}
}
}
}
}
}
echo "removed";
}
else
{
echo "NO_DATA";
}
mysqli_close($con);
/*
LATER FOR ANALYTICS:
Add a counter in backend to analytics to see maximum users at a time who have accessed a plot. This should be done in plot update so ccu count is known and put in analytics data for plot information. Also put total times a plot has been accessed and viewed as well so that it can be called in frontend just like Roblox to know how many times a plot has been accessed. This data should allow for easily adding in information about each plot of land
Have an image pull flag set in backend. When set as true then take a screenshot from the vantage point of the user and upload it to the server
MSP custom and enterprise users only.
*/
?>