summaryrefslogtreecommitdiff
path: root/includes/bitset.inc
diff options
context:
space:
mode:
Diffstat (limited to 'includes/bitset.inc')
-rw-r--r--includes/bitset.inc22
1 files changed, 19 insertions, 3 deletions
diff --git a/includes/bitset.inc b/includes/bitset.inc
index f8ac366..5106d80 100644
--- a/includes/bitset.inc
+++ b/includes/bitset.inc
@@ -1,6 +1,6 @@
<?php
-function parseBitset ($bitset) {
+function parseBitset($bitset, $birthData) {
$bin = str_repeat("0", 48 - strlen(decbin($bitset))) . decbin($bitset);
$sharedMemory = bindec(substr($bin, 24, 2));
@@ -63,7 +63,23 @@ function parseBitset ($bitset) {
default => null,
};
- if ($little === 1) $little = 0;
+ $little = 0;
+
+ if (isset($birthData["age"]) && $birthData["age"] !== 0) {
+ $age = $birthData["age"];
+ } else if (isset($birthData["year"]) && $birthData["year"] > 1900) {
+ $age = (int)date('Y') - $birthData["year"] + (strtotime(date('Y') . "-" . $birthData["date"]) <= time() ? 0 : -1);
+ } else {
+ $age = -2;
+ }
+
+ if ($age <= 10 && $age > 0) {
+ $little = 2;
+ }
+
+ if ($age < 16 && $age > 10) {
+ $little = 3;
+ }
return [
'shared_memory' => $sharedMemory,
@@ -106,7 +122,7 @@ function parseBitset ($bitset) {
function parseMetadata ($metadata) {
if (isset($metadata)) {
if ($metadata["bitset"]) {
- $m = parseBitset($metadata["bitset"]);
+ $m = parseBitset($metadata["bitset"], $metadata["birth"] ?? []);
$m["sexfriends"] = $metadata["sexfriends"] ?? [];
$m["marefriends"] = $metadata["marefriends"] ?? [];
$m["bitset"] = $metadata["bitset"] ?? 0;