This commit is contained in:
edsea
2024-12-25 20:02:52 +01:00
commit 5309acd356
64 changed files with 86647 additions and 0 deletions

12
.htaccess Normal file
View File

@@ -0,0 +1,12 @@
# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
<IfModule php8_module>
</IfModule>
<IfModule lsapi_module>
</IfModule>
# END cPanel-generated php ini directives, do not edit

5
.user.ini Normal file
View File

@@ -0,0 +1,5 @@
; cPanel-generated php ini directives, do not edit
; Manual editing of this file may result in unexpected behavior.
; To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
; For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)

BIN
_conf.zip Normal file

Binary file not shown.

17
_conf/db_con.php Normal file
View File

@@ -0,0 +1,17 @@
<?php
$hostname = $_SERVER['HTTP_HOST'];
if($hostname == 'api.stellaamor.com.local'){
$server = 'localhost';
$username = "root";
$db = "stella_amor";
$db_con = new pdo("mysql:host=$server;dbname=$db;charset=utf8mb4", $username);
}else{
$server = 'localhost';
$username = 'mysinfu1_stella';
$db_pass = 'E1#j#W4Y4UcV';
$db = 'mysinfu1_stella';
$db_con = new pdo("mysql:host=$server;dbname=$db;charset=utf8mb4", $username, $db_pass);
}

15
_conf/globals.php Normal file
View File

@@ -0,0 +1,15 @@
<?php
$hostname = $_SERVER['HTTP_HOST'];
if ($hostname === 'api.stellaamor.com') {
// Production environment
header("Access-Control-Allow-Origin: https://stellaamor.com");
} else {
// Local environment
header("Access-Control-Allow-Origin: http://stellaamor.com.local");
}
header("Access-Control-Allow-Credentials: true");
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
session_start();
?>

18
admin/db_con.php Normal file
View File

@@ -0,0 +1,18 @@
<?php
$hostname = $_SERVER['HTTP_HOST'];
if($hostname == 'api.stellaamor.com.local'){
$server = 'localhost';
$username = "root";
$db = "stella_amor";
$db_con = new pdo("mysql:host=$server;dbname=$db;charset=utf8mb4", $username);
}else{
$server = 'localhost';
$username = 'mysinfu1_stella';
$db_pass = 'E1#j#W4Y4UcV';
$db = 'mysinfu1_stella';
$db_con = new pdo("mysql:host=$server;dbname=$db;charset=utf8mb4", $username, $db_pass);
}
?>

18
admin/error_log Normal file
View File

@@ -0,0 +1,18 @@
[24-Apr-2024 15:12:09 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 8
[24-Apr-2024 15:12:09 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 9
[24-Apr-2024 15:12:09 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 10
[24-Apr-2024 15:12:09 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 10
[24-Apr-2024 15:12:09 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 10
[24-Apr-2024 15:12:09 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 10
[24-Apr-2024 15:54:23 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 9
[24-Apr-2024 15:54:23 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 10
[24-Apr-2024 15:54:23 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 11
[24-Apr-2024 15:54:23 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 11
[24-Apr-2024 15:54:23 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 11
[24-Apr-2024 15:54:23 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 11
[24-Apr-2024 15:55:32 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 8
[24-Apr-2024 15:55:32 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 9
[24-Apr-2024 15:55:32 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 10
[24-Apr-2024 15:55:32 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 10
[24-Apr-2024 15:55:32 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 10
[24-Apr-2024 15:55:32 UTC] PHP Notice: Trying to get property of non-object in /home/mysinfu1/domains/api.stellaamor.com/admin/payments.php on line 10

37
admin/payments.php Normal file
View File

@@ -0,0 +1,37 @@
<?php
include('db_con.php');
$apiData = file_get_contents('php://input');
$apiData = json_decode($apiData);
$customer = $apiData->data->object->customer;
$status = $apiData->data->object->status;
$end = $apiData->data->object->lines->data[0]->period->end;
// echo "Customer: $customer\n";
// echo "Status: $status\n";
// echo "End: $end\n";
$sql = $db_con->prepare("SELECT id FROM stripe_user_data WHERE cu_name = :customer");
$sql->bindValue(':customer', $customer);
$sql->execute();
$numRows = $sql->rowCount();
if($numRows == 0){
$stmt = $db_con->prepare("INSERT INTO stripe_user_data (cu_name, exp_date) VALUES (:cu_name, :exp_date)");
$stmt->bindValue(':cu_name', $customer);
$stmt->bindValue(':exp_date', $end);
$stmt->execute();
}else{
$stripe_user = $sql->fetch(PDO::FETCH_ASSOC);
$stripe_user_id = $stripe_user['id'];
$stmt = $db_con->prepare("UPDATE stripe_user_data SET exp_date = :exp_date WHERE id = :id");
$stmt->bindValue(':id', $stripe_user_id);
$stmt->bindValue(':exp_date', $end);
$stmt->execute();
}
?>

42
admin/subscriptions.php Normal file
View File

@@ -0,0 +1,42 @@
<?php
include('db_con.php');
$apiDataEncoded = file_get_contents('php://input');
$apiData = json_decode($apiDataEncoded);
$uname = $apiData->data->object->custom_fields[0]->text->value;
$uemail = $apiData->data->object->customer_details->email;
$customerId = $apiData->data->object->customer;
$sql = $db_con->prepare('SELECT id FROM users WHERE uname = :uname');
$sql->bindValue(':uname', $uname);
$sql->execute();
$numRows = $sql->rowCount();
if($numRows > 0){
$userData = $sql->fetch(PDO::FETCH_ASSOC);
$user_id = $userData['id'];
$stmt = $db_con->prepare("UPDATE users SET stripe_cu = :customerId WHERE id = :id");
$stmt->bindValue(':customerId', $customerId);
$stmt->bindValue(':id', $user_id);
$stmt->execute();
}else{
$sql = $db_con->prepare('SELECT id FROM users WHERE u_email = :u_email');
$sql->bindValue(':u_email', $uemail);
$sql->execute();
$numRows = $sql->rowCount();
if($numRows > 0){
$userData = $sql->fetch(PDO::FETCH_ASSOC);
$user_id = $userData['id'];
$stmt = $db_con->prepare("UPDATE users SET stripe_cu = :customerId WHERE id = :id");
$stmt->bindValue(':customerId', $customerId);
$stmt->bindValue(':id', $user_id);
$stmt->execute();
}else{
die('Incorrect details');
}
}
die();
?>

26
core.php Normal file
View File

@@ -0,0 +1,26 @@
<?php
require_once('_conf/globals.php');
require_once('_conf/db_con.php');
$postData = file_get_contents('php://input');
$postData = json_decode($postData);
if($postData){
$postAction = $postData->action;
}else{
$postAction = 'Custom';
}
if($postAction == 'getAdminMessage'){
require_once('stella_core_class.php');
$core = new StellaCore();
$core->getAdminMessage();
}
if($postAction == 'sendMessage'){
require_once('stella_core_class.php');
$core = new StellaCore();
$u_email = isset($postData->u_email) && !empty($postData->u_email) ? $postData->u_email : '';
$u_message = isset($postData->message) && !empty($postData->message) ? $postData->message : '';
$u_title = isset($postData->title) && !empty($postData->title) ? $postData->title : '';
$core->sendMessage($u_email, $u_title, $u_message);
}

138
error_log Normal file
View File

@@ -0,0 +1,138 @@
[11-Sep-2024 19:52:51 UTC] PHP Warning: Undefined array key "authId" in /home/mysinfu1/domains/api.stellaamor.com/users_class.php on line 654
[11-Sep-2024 19:52:51 UTC] PHP Warning: Undefined array key "authId" in /home/mysinfu1/domains/api.stellaamor.com/users_class.php on line 270
[11-Sep-2024 19:52:51 UTC] PHP Warning: Trying to access array offset on value of type bool in /home/mysinfu1/domains/api.stellaamor.com/users_class.php on line 278
[11-Sep-2024 19:52:51 UTC] PHP Warning: Undefined array key "authId" in /home/mysinfu1/domains/api.stellaamor.com/users_class.php on line 302
[11-Sep-2024 19:52:51 UTC] PHP Warning: Undefined array key "authId" in /home/mysinfu1/domains/api.stellaamor.com/users_class.php on line 313
[11-Sep-2024 19:52:51 UTC] PHP Warning: Undefined array key "authId" in /home/mysinfu1/domains/api.stellaamor.com/users_class.php on line 197
[11-Sep-2024 19:52:51 UTC] PHP Warning: Undefined array key "authId" in /home/mysinfu1/domains/api.stellaamor.com/users_class.php on line 582
[11-Sep-2024 19:52:51 UTC] PHP Warning: Undefined array key "authId" in /home/mysinfu1/domains/api.stellaamor.com/users_class.php on line 654
[11-Sep-2024 19:53:01 UTC] PHP Warning: Undefined array key "authId" in /home/mysinfu1/domains/api.stellaamor.com/users_class.php on line 654
[31-Oct-2024 20:39:13 UTC] PHP Warning: Undefined property: stdClass::$acceptTerms in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 50
[12-Dec-2024 02:07:04 UTC] PHP Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 22
[12-Dec-2024 02:07:04 UTC] PHP Warning: file_get_contents(https://restcountries.com/v3.1/all): Failed to open stream: no suitable wrapper could be found in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 22
[12-Dec-2024 02:07:04 UTC] PHP Fatal error: Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, null given in /home/mysinfu1/domains/api.stellaamor.com/users.php:27
Stack trace:
#0 /home/mysinfu1/domains/api.stellaamor.com/users.php(27): array_map(Object(Closure), NULL)
#1 {main}
thrown in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 27
[12-Dec-2024 02:08:04 UTC] PHP Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 22
[12-Dec-2024 02:08:04 UTC] PHP Warning: file_get_contents(https://restcountries.com/v3.1/all): Failed to open stream: no suitable wrapper could be found in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 22
[12-Dec-2024 02:08:04 UTC] PHP Fatal error: Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, null given in /home/mysinfu1/domains/api.stellaamor.com/users.php:27
Stack trace:
#0 /home/mysinfu1/domains/api.stellaamor.com/users.php(27): array_map(Object(Closure), NULL)
#1 {main}
thrown in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 27
[12-Dec-2024 02:08:18 UTC] PHP Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 22
[12-Dec-2024 02:08:18 UTC] PHP Warning: file_get_contents(https://restcountries.com/v3.1/all): Failed to open stream: no suitable wrapper could be found in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 22
[12-Dec-2024 02:08:18 UTC] PHP Fatal error: Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, null given in /home/mysinfu1/domains/api.stellaamor.com/users.php:27
Stack trace:
#0 /home/mysinfu1/domains/api.stellaamor.com/users.php(27): array_map(Object(Closure), NULL)
#1 {main}
thrown in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 27
[12-Dec-2024 02:08:27 UTC] PHP Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 22
[12-Dec-2024 02:08:27 UTC] PHP Warning: file_get_contents(https://restcountries.com/v3.1/all): Failed to open stream: no suitable wrapper could be found in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 22
[12-Dec-2024 02:08:27 UTC] PHP Fatal error: Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, null given in /home/mysinfu1/domains/api.stellaamor.com/users.php:27
Stack trace:
#0 /home/mysinfu1/domains/api.stellaamor.com/users.php(27): array_map(Object(Closure), NULL)
#1 {main}
thrown in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 27
[12-Dec-2024 02:09:17 UTC] PHP Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 22
[12-Dec-2024 02:09:17 UTC] PHP Warning: file_get_contents(https://restcountries.com/v3.1/all): Failed to open stream: no suitable wrapper could be found in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 22
[12-Dec-2024 02:09:17 UTC] PHP Fatal error: Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, null given in /home/mysinfu1/domains/api.stellaamor.com/users.php:27
Stack trace:
#0 /home/mysinfu1/domains/api.stellaamor.com/users.php(27): array_map(Object(Closure), NULL)
#1 {main}
thrown in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 27
[12-Dec-2024 02:21:08 UTC] PHP Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 22
[12-Dec-2024 02:21:08 UTC] PHP Warning: file_get_contents(https://restcountries.com/v3.1/all): Failed to open stream: no suitable wrapper could be found in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 22
[12-Dec-2024 02:21:08 UTC] PHP Fatal error: Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, null given in /home/mysinfu1/domains/api.stellaamor.com/users.php:27
Stack trace:
#0 /home/mysinfu1/domains/api.stellaamor.com/users.php(27): array_map(Object(Closure), NULL)
#1 {main}
thrown in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 27
[12-Dec-2024 02:28:06 UTC] PHP Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 22
[12-Dec-2024 02:28:06 UTC] PHP Warning: file_get_contents(https://restcountries.com/v3.1/all): Failed to open stream: no suitable wrapper could be found in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 22
[12-Dec-2024 02:28:06 UTC] PHP Fatal error: Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, null given in /home/mysinfu1/domains/api.stellaamor.com/users.php:27
Stack trace:
#0 /home/mysinfu1/domains/api.stellaamor.com/users.php(27): array_map(Object(Closure), NULL)
#1 {main}
thrown in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 27
[12-Dec-2024 02:33:27 UTC] PHP Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 22
[12-Dec-2024 02:33:27 UTC] PHP Warning: file_get_contents(https://restcountries.com/v3.1/all): Failed to open stream: no suitable wrapper could be found in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 22
[12-Dec-2024 02:33:27 UTC] PHP Fatal error: Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, null given in /home/mysinfu1/domains/api.stellaamor.com/users.php:27
Stack trace:
#0 /home/mysinfu1/domains/api.stellaamor.com/users.php(27): array_map(Object(Closure), NULL)
#1 {main}
thrown in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 27
[12-Dec-2024 02:33:55 UTC] PHP Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 22
[12-Dec-2024 02:33:55 UTC] PHP Warning: file_get_contents(https://restcountries.com/v3.1/all): Failed to open stream: no suitable wrapper could be found in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 22
[12-Dec-2024 02:33:55 UTC] PHP Fatal error: Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, null given in /home/mysinfu1/domains/api.stellaamor.com/users.php:27
Stack trace:
#0 /home/mysinfu1/domains/api.stellaamor.com/users.php(27): array_map(Object(Closure), NULL)
#1 {main}
thrown in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 27
[12-Dec-2024 06:41:30 UTC] PHP Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 22
[12-Dec-2024 06:41:30 UTC] PHP Warning: file_get_contents(https://restcountries.com/v3.1/all): Failed to open stream: no suitable wrapper could be found in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 22
[12-Dec-2024 06:41:30 UTC] PHP Fatal error: Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, null given in /home/mysinfu1/domains/api.stellaamor.com/users.php:27
Stack trace:
#0 /home/mysinfu1/domains/api.stellaamor.com/users.php(27): array_map(Object(Closure), NULL)
#1 {main}
thrown in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 27
[12-Dec-2024 06:42:08 UTC] PHP Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 22
[12-Dec-2024 06:42:08 UTC] PHP Warning: file_get_contents(https://restcountries.com/v3.1/all): Failed to open stream: no suitable wrapper could be found in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 22
[12-Dec-2024 06:42:08 UTC] PHP Fatal error: Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, null given in /home/mysinfu1/domains/api.stellaamor.com/users.php:27
Stack trace:
#0 /home/mysinfu1/domains/api.stellaamor.com/users.php(27): array_map(Object(Closure), NULL)
#1 {main}
thrown in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 27
[12-Dec-2024 06:42:26 UTC] PHP Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 22
[12-Dec-2024 06:42:26 UTC] PHP Warning: file_get_contents(https://restcountries.com/v3.1/all): Failed to open stream: no suitable wrapper could be found in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 22
[12-Dec-2024 06:42:26 UTC] PHP Fatal error: Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, null given in /home/mysinfu1/domains/api.stellaamor.com/users.php:27
Stack trace:
#0 /home/mysinfu1/domains/api.stellaamor.com/users.php(27): array_map(Object(Closure), NULL)
#1 {main}
thrown in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 27
[12-Dec-2024 06:42:33 UTC] PHP Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 22
[12-Dec-2024 06:42:33 UTC] PHP Warning: file_get_contents(https://restcountries.com/v3.1/all): Failed to open stream: no suitable wrapper could be found in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 22
[12-Dec-2024 06:42:33 UTC] PHP Fatal error: Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, null given in /home/mysinfu1/domains/api.stellaamor.com/users.php:27
Stack trace:
#0 /home/mysinfu1/domains/api.stellaamor.com/users.php(27): array_map(Object(Closure), NULL)
#1 {main}
thrown in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 27
[12-Dec-2024 06:42:43 UTC] PHP Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 22
[12-Dec-2024 06:42:43 UTC] PHP Warning: file_get_contents(https://restcountries.com/v3.1/all): Failed to open stream: no suitable wrapper could be found in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 22
[12-Dec-2024 06:42:43 UTC] PHP Fatal error: Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, null given in /home/mysinfu1/domains/api.stellaamor.com/users.php:27
Stack trace:
#0 /home/mysinfu1/domains/api.stellaamor.com/users.php(27): array_map(Object(Closure), NULL)
#1 {main}
thrown in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 27
[12-Dec-2024 06:45:49 UTC] PHP Fatal error: Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, null given in /home/mysinfu1/domains/api.stellaamor.com/users.php:27
Stack trace:
#0 /home/mysinfu1/domains/api.stellaamor.com/users.php(27): array_map(Object(Closure), NULL)
#1 {main}
thrown in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 27
[12-Dec-2024 06:46:40 UTC] PHP Fatal error: Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, null given in /home/mysinfu1/domains/api.stellaamor.com/users.php:27
Stack trace:
#0 /home/mysinfu1/domains/api.stellaamor.com/users.php(27): array_map(Object(Closure), NULL)
#1 {main}
thrown in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 27
[12-Dec-2024 06:52:48 UTC] PHP Fatal error: Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, null given in /home/mysinfu1/domains/api.stellaamor.com/users.php:27
Stack trace:
#0 /home/mysinfu1/domains/api.stellaamor.com/users.php(27): array_map(Object(Closure), NULL)
#1 {main}
thrown in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 27
[12-Dec-2024 07:02:25 UTC] PHP Fatal error: Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, null given in /home/mysinfu1/domains/api.stellaamor.com/users.php:27
Stack trace:
#0 /home/mysinfu1/domains/api.stellaamor.com/users.php(27): array_map(Object(Closure), NULL)
#1 {main}
thrown in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 27
[14-Dec-2024 16:59:50 UTC] PHP Fatal error: Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, null given in /home/mysinfu1/domains/api.stellaamor.com/users.php:27
Stack trace:
#0 /home/mysinfu1/domains/api.stellaamor.com/users.php(27): array_map(Object(Closure), NULL)
#1 {main}
thrown in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 27
[14-Dec-2024 17:01:41 UTC] PHP Fatal error: Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, null given in /home/mysinfu1/domains/api.stellaamor.com/users.php:27
Stack trace:
#0 /home/mysinfu1/domains/api.stellaamor.com/users.php(27): array_map(Object(Closure), NULL)
#1 {main}
thrown in /home/mysinfu1/domains/api.stellaamor.com/users.php on line 27

88
filter.php Normal file
View File

@@ -0,0 +1,88 @@
<?php
require_once('_conf/globals.php');
require_once('_conf/db_con.php');
$postData = file_get_contents('php://input');
$postData = json_decode($postData);
if(isset($_GET) && !empty($_GET) && isset($_GET['countries']) && $_GET['countries'] == 'true'){
require_once('filter_class.php');
$filter = new StellaFilter();
echo $filter->returnCountries();
}
if(isset($_GET) && !empty($_GET) && isset($_GET['allowedFilter']) && $_GET['allowedFilter'] == 'true'){
require_once('includes/allowedFilter.php');
$allowedFilter = new stdClass();
$allowedFilter->sexualities = $sexualities;
$allowedFilter->lookingFor = $lookingFor;
$allowedFilter->hairs = $hairs;
$allowedFilter->hairColors = $hairColors;
$allowedFilter->facialHairs = $facialHairs;
$allowedFilter->pubicHairs = $pubicHairs;
$allowedFilter->bodyHairs = $bodyHairs;
$allowedFilter->tattoos = $tattoos;
$allowedFilter->piercings = $piercings;
$allowedFilter->eyeColors = $eyeColors;
$allowedFilter->breastSizes = $breastSizes;
$allowedFilter->abs = $abs;
$allowedFilter->bottomSizes = $bottomSizes;
$allowedFilter->bodyTypes = $bodyTypes;
$allowedFilter->ethnicities = $ethnicities;
$allowedFilter->fitnessLevels = $fitnessLevels;
$allowedFilter->dietaryPreferences = $dietaryPreferences;
$allowedFilter->healthHabits = $healthHabits;
$allowedFilter->exerciseFrequency = $exerciseFrequency;
$allowedFilter->sleepingHabits = $sleepingHabits;
$allowedFilter->foodAllergies = $foodAllergies;
$allowedFilter->alcoholConsumptions = $alcoholConsumptions;
$allowedFilter->smoking = $smoking;
$allowedFilter->jobs = $jobs;
$allowedFilter->mainLiving = $mainLiving;
$allowedFilter->financialGoals = $financialGoals;
$allowedFilter->spendingHabits = $spendingHabits;
$allowedFilter->financialIndependence = $financialIndependence;
$allowedFilter->fetishes = $fetishes;
$allowedFilter->personalities = $personalities;
$allowedFilter->hobbiesAndActivities = $hobbiesAndActivities;
$allowedFilter->movieGenres = $movieGenres;
$allowedFilter->bookGenres = $bookGenres;
$allowedFilter->highestGraduation = $highestGraduation;
$allowedFilter->education = $education;
$allowedFilter->travelPreferences = $travelPreferences;
$allowedFilter->communicationPreferences = $communicationPreferences;
$allowedFilter->religion = $religion;
$allowedFilter->languages = $languages;
$allowedFilter->currentSituation = $currentSituation;
$allowedFilter->pets = $pets;
$allowedFilter->sexualActivity = $sexualActivity;
header('Content-Type: application/json');
echo json_encode($allowedFilter);
}
if(isset($postData->action) && $postData->action == 'search'){
require_once('filter_class.php');
require_once('users_class.php');
$filter = new StellaFilter();
// Calculate age based on year range
$filter->minAge = $filter->calcYear($postData->filter->minAge);
$filter->maxAge = $filter->calcYear($postData->filter->maxAge);
unset($postData->filter->minAge); // Remove minAge from filter
unset($postData->filter->maxAge); // Remove maxAge from filter
$user = new Users();
if($user->isAuth()){
if($user->hasPaid()){
$searchTerms = $postData->filter;
foreach($searchTerms as $termName => $term){
if(isset($term) && !empty($term)){
$filter->setFilter($termName, $term); // Set the filter dynamically
}
}
// Call search with the dynamically set filters
$users = $filter->search($searchTerms);
echo $users;
}
}
}

414
filter_class.php Normal file
View File

@@ -0,0 +1,414 @@
<?php
class StellaFilter{
public $gender;
public $minAge;
public $maxAge;
public $sexuality;
public $lookingFor;
public $country;
public $city;
public $minHeight;
public $maxHeight;
public $minWeight;
public $maxWeight;
public $hair;
public $facialHair;
public $pubicHair;
public $bodyHair;
public $hairColor;
public $tattoo;
public $piercing;
public $eyeColor;
public $breastSize;
public $minPenisSize;
public $maxPenisSize;
public $abs;
public $bottomSizes;
public $bodyTypes;
public $ethnicities;
public $fitnessLevels;
public $dietaryPreferences;
public $healthHabits;
public $exerciseFrequency;
public $sleepingHabits;
public $foodAllergies;
public $alcoholConsumptions;
public $smoking;
public $jobs;
public $minNetWorth;
public $maxNetWorth;
public $minYearlySalary;
public $maxYearlySalary;
public $mainLiving;
public $financialGoals;
public $spendingHabits;
public $financialIndependence;
public $inDebt;
public $hasKids;
public $wantKids;
public $fetishes;
public $personalities;
public $hobbiesAndActivities;
public $movieGenres;
public $bookGenres;
public $highestGraduation;
public $education;
public $travelPreferences;
public $religion;
public $languages;
public $currentSituation;
public $pets;
public $sexualActivity;
public $activeFilters = array();
public $generalFilter = array('gender', 'minAge', 'maxAge', 'sexualities', 'sexualActivity', 'lookingFor', 'country', 'city');
public $bodyFeaturesFilter = array('minHeight','maxHeight','minWeight','maxWeight','hair','facialHair','pubicHair','bodyHair','hairColor','tattoo','piercing','eyeColor','breastSize','minPenisSize','maxPenisSize','abs','bottomSizes','bodyTypes','ethnicities');
public $bodyLifeStyleFilter = array('fitnessLevels','dietaryPreferences','healthHabits','exerciseFrequency','sleepingHabits','foodAllergies','alcoholConsumptions','smoking');
public $financialFilter = array('jobs','minNetWorth','maxNetWorth','minYearlySalary','maxYearlySalary','mainLiving','financialGoals','spendingHabits','financialIndependence','inDebt');
public $personalFilter = array('hasKids','wantKids','fetishes','personalities','hobbiesAndActivities','movieGenres','bookGenres','highestGraduation','education','travelPreferences','religion','languages','currentSituation','pets');
public $comparisionFilter = array('minAge', 'maxAge', 'minHeight', 'maxHeight', 'minWeight', 'maxWeight', 'minPenisSize', 'maxPenisSize', 'minNetWorth', 'maxNetWorth', 'minYearlySalary', 'maxYearlySalary');
public $comparisionInfo = array(
'minAge' => array(
'comp' => '>',
'pref' => 'dob'
),
'maxAge' => array(
'comp' => '<',
'pref' => 'dob'
),
'minHeight' => array(
'comp' => '>',
'pref' => 'height'
),
'maxHeight' => array(
'comp' => '<',
'pref' => 'height'
),
'minWeight' => array(
'comp' => '>',
'pref' => 'weight'
),
'maxWeight' => array(
'comp' => '<',
'pref' => 'weight'
),
'minPenisSize' => array(
'comp' => '>',
'pref' => 'penisSize'
),
'maxPenisSize' => array(
'comp' => '<',
'pref' => 'penisSize'
),
'minNetWorth' => array(
'comp' => '>',
'pref' => 'netWorth'
),
'maxNetWorth' => array(
'comp' => '<',
'pref' => 'netWorth'
),
'minYearlySalary' => array(
'comp' => '>',
'pref' => 'yearlySalary'
),
'maxYearlySalary' => array(
'comp' => '<',
'pref' => 'yearlySalary'
)
);
public $comparisionStatus = array(
'dob' => false,
'height' => false,
'weight' => false,
'penisSize' => false,
'netWorth' => false,
'yearlySalary' => false
);
public function returnCountries(){
$countries = file_get_contents('includes/countries.json');
return $countries;
}
public function setFilter($termName, $term){
if(property_exists($this, $termName)){
$this->$termName = $term;
$this->activeFilters[] = $termName;
}
}
public function search($terms){
global $db_con;
$sql = 'SELECT u.id, u.uname, u.avatar, u.bio, u.dob, ';
$aliasCount = 1;
$params = array();
try {
foreach($this->activeFilters as $filter){
if(in_array($filter, $this->comparisionFilter)){
$sql_info = $this->comparisionInfo[$filter];
$pref_name = $sql_info['pref'];
if(!$this->comparisionStatus[$pref_name]){
$alias = 'ud' . $aliasCount;
$sql .= $alias . '.data_value AS ' . $pref_name . ",\n";
$aliasCount++;
$this->comparisionStatus[$pref_name] = true;
}
}else{
$alias = 'ud' . $aliasCount;
$sql .= $alias . '.data_value AS ' . $filter . ",\n";
$aliasCount++;
}
}
$sql = rtrim($sql, ",\n");
$sql .= " \n" . 'FROM users AS u';
$aliasCount = 1;
$this->comparisionStatus = array(
'dob' => false,
'height' => false,
'weight' => false,
'penisSize' => false,
'netWorth' => false,
'yearlySalary' => false
);
foreach($this->activeFilters as $filter){
$value = $this->$filter;
if ($value !== null) {
if (is_array($value)) {
$value = implode(', ', $value);
}
$alias = 'ud' . $aliasCount;
if (in_array($filter, $this->comparisionFilter)) {
$sql_info = $this->comparisionInfo[$filter];
$pref_name = $sql_info['pref'];
if (!$this->comparisionStatus[$pref_name]) {
$sql .= "\n" . ' LEFT JOIN ' . 'user_data' . ' AS ' . $alias . ' ON u.id = ' . $alias . '.user_id AND ' . $alias . '.data_name = ? ';
$params[] = $pref_name;
$this->comparisionStatus[$pref_name] = true;
$aliasCount++;
}
} else {
$sql .= "\n" . ' LEFT JOIN ' . 'user_data' . ' AS ' . $alias . ' ON u.id = ' . $alias . '.user_id AND ' . $alias . '.data_name = ?';
$params[] = $filter;
$aliasCount++;
}
}
}
$aliasCount = 1;
$this->comparisionStatus = array(
'dob' => false,
'height' => false,
'weight' => false,
'penisSize' => false,
'netWorth' => false,
'yearlySalary' => false
);
if(count($this->activeFilters) > 0){
$sql .= "\n" . " WHERE ";
$conditions = array();
foreach ($this->activeFilters as $filter) {
if (isset($terms->$filter) && $terms->$filter && !empty($terms->$filter)) {
$filter_value = $terms->$filter;
} else {
throw new Exception('Malicious user input');
}
if(in_array($filter, $this->comparisionFilter)){
$sql_info = $this->comparisionInfo[$filter];
$pref_name = $sql_info['pref'];
if (!$this->comparisionStatus[$pref_name]) {
$alias = 'ud' . $aliasCount;
$prePref = str_replace('min', '', $filter);
$prePref = str_replace('max', '', $prePref);
$minPref = 'min' . ucfirst($prePref);
$maxPref = 'max' . ucfirst($prePref);
$minVal = $terms->$minPref;
$maxVal = $terms->$maxPref;
if ($prePref == 'Age') {
$isDate = true;
$isMax = intval($terms->maxAge) >= 99;
// Calculate age
$minVal = $this->calcYear($minVal);
$maxVal = $this->calcYear($maxVal);
} else {
$isDate = false;
// Check for max conditions
switch ($prePref) {
case 'Height':
$isMax = intval($terms->maxHeight) >= 240;
break;
case 'NetWorth':
$isMax = intval($terms->maxNetWorth) == 10000000;
break;
case 'PenisSize':
$isMax = intval($terms->maxPenisSize) == 40;
break;
case 'Weight':
$isMax = intval($terms->maxWeight) == 200;
break;
case 'YearlySalary':
$isMax = intval($terms->maxYearlySalary) == 1000000;
break;
default:
$isMax = false;
}
}
if ($isDate) {
if ($isMax) {
$conditions[] = "\n" . "STR_TO_DATE(" . $alias . ".data_value, '%Y-%m-%d') >= ?";
$params[] = "'" . date('Y-m-d', strtotime($minVal)) . "'";
} else {
$conditions[] = "\n" . "STR_TO_DATE(" . $alias . ".data_value, '%Y-%m-%d') >= ? AND STR_TO_DATE(" . $alias . ".data_value, '%Y-%m-%d') <= ?";
$params[] = "'" . date('Y-m-d', strtotime($minVal)) . "'";
$params[] = "'" . date('Y-m-d', strtotime($maxVal)) . "'";
}
} else {
if ($isMax) {
$conditions[] = "\n" . "CAST(" . $alias . ".data_value AS SIGNED) >= ?";
$params[] = intval($minVal);
} else {
$conditions[] = "\n" . "CAST(" . $alias . ".data_value AS SIGNED) >= ? AND CAST(" . $alias . ".data_value AS SIGNED) <= ?";
$params[] = intval($minVal);
$params[] = intval($maxVal);
}
}
$aliasCount++;
$this->comparisionStatus[$pref_name] = true;
}
}else {
$alias = 'ud' . $aliasCount;
if (is_array($filter_value)) {
$conditions[] = "\n" . '(' . rtrim(str_repeat($alias . '.data_value LIKE ? OR ', count($filter_value)), 'OR ') . ')';
foreach ($filter_value as $value) {
$params[] = "%" . $value . "%";
}
} else if($filter_value == 'male' || 'female'){
$conditions[] = "\n" . $alias . '.data_value = ?';
$params[] = $filter_value;
} else {
$conditions[] = "\n" . $alias . '.data_value LIKE ?';
$params[] = "%" . $filter_value . "%";
}
$aliasCount++;
}
}
$sql .= implode(" AND ", $conditions);
$sql .= "ORDER BY RAND() LIMIT 1000";
$stmt = $db_con->prepare($sql);
// echo $sql;
$stmt->execute($params);
}else{
$stmt = $db_con->prepare($sql);
$stmt->execute();
}
$executedQuery = $stmt->queryString;
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
$users = array();
foreach($rows as $row){
$user = new stdClass();
if(isset($row['dob']) && !empty($row['dob'])){
$dob = $row['dob'];
$calcDob = new DateTime($dob);
$calcDob = $calcDob->format('Y-m-d');
if($dob < $this->minAge && $dob > $this->maxAge){
// Get country
$stm = $db_con->prepare('SELECT data_value FROM user_data WHERE data_name = "country" AND user_id = :id');
$stm->bindValue(':id', $row['id']);
$stm->execute();
$_country = $stm->fetch(PDO::FETCH_ASSOC);
// Get gender
$stm = $db_con->prepare('SELECT data_value FROM user_data WHERE data_name = "gender" AND user_id = :id');
$stm->bindValue(':id', $row['id']);
$stm->execute();
$_gender = $stm->fetch(PDO::FETCH_ASSOC);
// Get orientation
$stm = $db_con->prepare('SELECT data_value FROM user_data WHERE data_name = "sexuality" AND user_id = :id');
$stm->bindValue(':id', $row['id']);
$stm->execute();
$_sexuality = $stm->fetch(PDO::FETCH_ASSOC);
// Get sexuality, gender and country
$user->id = $row['id'];
$user->username = $row['uname'];
$user->avatar = $row['avatar'];
$user->bio = isset($row['bio']) && !empty($row['bio']) ? $row['bio'] : '';
$user->age = $this->calcAge($dob);
$user->country = isset($_country['data_value']) && !empty($_country['data_value']) ? $_country['data_value'] : 'Unknown location';
$user->gender = isset($_gender['data_value']) && !empty($_gender['data_value']) ? $_gender['data_value'] : '';
$user->sexuality = isset($_sexuality['data_value']) && !empty($_sexuality['data_value']) ? $_sexuality['data_value'] : '';
$users[] = $user;
}
}
}
$filtered_users = json_encode($users);
return $filtered_users;
} catch (PDOException $e) {
echo "Error: " . $e->getMessage();
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
}
}
public function allowed_search_value($val){
require('includes/allowedFilter.php');
$countries = file_get_contents('includes/countries.json');
$countries = json_decode($countries);
$isAllowed = false;
if(in_array($val, $filterAllowed)){
$isAllowed = true;
}
foreach($countries as $country => $cities) {
if($country === $val || in_array($val, $cities)) {
$isAllowed = true;
break;
}
}
return $isAllowed;
}
public function calcYear($age) {
$currentDate = new DateTime();
$currentDate->sub(new DateInterval('P' . $age . 'Y'));
$dateOfBirth = $currentDate->format('Y-m-d');
return $dateOfBirth;
}
private function calcAge($dob) {
$dobDate = new DateTime($dob);
$currentDate = new DateTime();
$age = $currentDate->diff($dobDate);
return $age->y;
}
}

View File

@@ -0,0 +1,86 @@
<?php
$sexualities = array('Heterosexual (Straight)', 'Homosexual (Gay/Lesbian)', 'Bisexual', 'Pansexual', 'Asexual', 'Demisexual', 'Queer', 'Fluid', 'Non-binary Attracted', 'Questioning', 'Other');
$lookingFor = array('Not sure yet', 'Casual Dating', 'Friends with Benefits', 'Short-term Relationship', 'Long-term Relationship', 'Marriage', 'Exploring Connections', 'Other');
$hairs = array('Long', 'Very Long', 'Shoulder Length', 'Medium Length', 'Short', 'Pixie Cut', 'Bob Cut', 'Lob', 'Layered', 'Curly', 'Straight', 'Wavy', 'Braided', 'Ponytail', 'Bun', 'Top Knot', 'Mohawk', 'Undercut', 'Shaved', 'Dreadlocks', 'Afro', 'Comb Over', 'Messy', 'Wet Look', 'Spiky', 'Bald', 'Balding', 'Other');
$hairColors = array('Blonde', 'Brunette', 'Black', 'Red', 'Gray', 'White', 'Brown', 'Auburn', 'Chestnut', 'Platinum Blonde', 'Dirty Blonde', 'Strawberry Blonde', 'Sandy Blonde', 'Honey Blonde', 'Caramel', 'Mahogany', 'Burgundy', 'Copper', 'Silver', 'Salt and Pepper', 'Blue', 'Green', 'Purple', 'Pink', 'Rainbow', 'Multicolored', 'Other');
$facialHairs = array('None', 'Clean-Shaven', 'Stubble', 'Goatee', 'Circle Beard', 'Van Dyke', 'Mutton Chops', 'Soul Patch', 'Chin Strap', 'Beard without Mustache', 'French Fork', 'Imperial', 'Garibaldi', 'Ducktail', 'Verdi', 'Balbo', 'Anchor Beard', 'Extended Goatee', 'Corporate Beard', 'Hipster Beard', 'Bandholz', 'Yeard (Year-Long Beard)', 'Moustache Only', 'Handlebar Mustache', 'Horseshoe Mustache', 'Fu Manchu', 'Walrus Mustache', 'Pencil Mustache', 'Chevron Mustache', 'Toothbrush Mustache', 'Dali Mustache', 'English Mustache', 'Natural Full Beard', 'Other');
$pubicHairs = array('Bare', 'Smooth', 'Neatly Trimmed', 'Lightly Groomed', 'Short', 'Natural');
$bodyHairs = array('Smooth', 'Waxed', 'Shaved', 'Trimmed', 'Short', 'Groomed', 'Full');
$tattoos = array('None', 'Small', 'Medium', 'Large', 'Full Sleeve', 'Half Sleeve', 'Back Piece', 'Chest Piece', 'Neck Tattoo', 'Face Tattoo', 'Hand Tattoo', 'Finger Tattoos', 'Leg Tattoo', 'Ankle Tattoo', 'Foot Tattoo', 'Rib Tattoo', 'Collarbone Tattoo', 'Wrist Tattoo', 'Matching Tattoos', 'Colorful', 'Black and Gray', 'Watercolor', 'Traditional', 'New School', 'Geometric', 'Abstract', 'Script', 'Symbols', 'Portrait', 'Animal', 'Floral', 'Mandala', 'Japanese', 'Tribal', 'Maori', 'Dotwork', 'Minimalist', 'UV Tattoo', 'Scar Cover-up', '3D Tattoo', 'Biomechanical', 'Horror', 'Other');
$piercings = array('None', 'Earlobe', 'Helix', 'Tragus', 'Conch', 'Industrial', 'Rook', 'Daith', 'Snug', 'Nose', 'Septum', 'Lip', 'Tongue', 'Eyebrow', 'Nipple', 'Belly Button', 'Surface', 'Dermal', 'Genital', 'Multiple', 'Other');
$eyeColors = array('Amber', 'Blue', 'Brown', 'Gray', 'Green', 'Hazel', 'Red/Violet', 'Black', 'Multicolored', 'Albino', 'Other');
$breastSizes = array('A Cup', 'B Cup', 'C Cup', 'D Cup', 'DD Cup', 'E Cup', 'F Cup', 'G Cup', 'H Cup', 'I Cup', 'J Cup', 'K Cup and above');
$abs = array('None', 'Six Pack', 'Eight Pack', 'Flat', 'Toned', 'Ripped', 'Washboard Abs', 'Obliques', 'Muscular', 'Defined', 'Other');
$bottomSizes = array('Small', 'Medium', 'Curvy', 'Full-Figured', 'Voluptuous', 'Other');
$bodyTypes = array('Slim', 'Athletic', 'Muscular', 'Average', 'Curvy', 'Full-Figured', 'Voluptuous', 'Bodybuilder', 'Petite', 'Tall', 'Other');
$ethnicities = array('Caucasian', 'African American', 'Asian', 'Hispanic/Latino', 'Native American', 'Middle Eastern', 'Pacific Islander', 'Mixed Race', 'Other');
$fitnessLevels = array('Beginner', 'Intermediate', 'Advanced', 'Athlete', 'Fitness Enthusiast', 'Casual Exerciser', 'Sedentary', 'Other');
$dietaryPreferences = array('Vegetarian', 'Vegan', 'Pescatarian', 'Flexitarian', 'Paleo', 'Keto', 'Gluten-Free', 'Dairy-Free', 'Nut-Free', 'Other');
$healthHabits = array('Regular Exercise', 'Healthy Eating', 'Mindfulness/Meditation', 'Hydration', 'Limited Caffeine', 'No Smoking', 'Moderate Alcohol Consumption', 'Regular Health Checkups', 'Other');
$exerciseFrequency = array('Daily', '4-6 times a week', '2-3 times a week', 'Once a week', 'Occasional', 'Rarely', 'Never', 'Other');
$sleepingHabits = array('Early Riser', 'Night Owl', 'Regular Schedule', 'Irregular Schedule', 'Nap Enthusiast', 'Insomniac', 'Heavy Sleeper', 'Light Sleeper', 'Other');
$foodAllergies = array('Gluten', 'Dairy', 'Nuts', 'Shellfish', 'Soy', 'Egg', 'Fish', 'Other');
$alcoholConsumptions = array('Non-Drinker', 'Social Drinker', 'Moderate Drinker', 'Frequent Drinker', 'Heavy Drinker', 'Other');
$smoking = array('Non-Smoker', 'Occasional Smoker', 'Regular Smoker', 'Former Smoker', 'Other');
$jobs = array('Information Technology', 'Finance', 'Healthcare', 'Education', 'Engineering', 'Sales', 'Marketing', 'Customer Service', 'Human Resources', 'Construction', 'Retail', 'Hospitality', 'Manufacturing', 'Transportation', 'Arts and Design', 'Legal', 'Government', 'Nonprofit', 'Self-Employed', 'Agriculture', 'Biotechnology', 'Chemical', 'Environmental Services', 'Fashion', 'Fitness and Recreation', 'Food and Beverage', 'Journalism', 'Media and Broadcasting', 'Pharmaceutical', 'Real Estate', 'Social Services', 'Telecommunications', 'Utilities', 'Waste Management', 'Automotive', 'Aviation', 'Cosmetics', 'Energy', 'Insurance', 'Logistics', 'Mining', 'Pet Care', 'Science', 'Technology', 'Travel and Tourism', 'Writing and Editing', 'Other');
$mainLiving = array('Apartment', 'House', 'Condo', 'Townhouse', 'Mobile Home', 'Mansion', 'Tiny House', 'Duplex', 'Cabin', 'Loft', 'Farmhouse', 'Ranch', 'Cooperative', 'Bungalow', 'Villa', 'Castle', 'Houseboat', 'Treehouse', 'Earthship', 'Other');
$financialGoals = array('Saving for Retirement', 'Buying a Home', 'Paying Off Debt', 'Emergency Fund', 'Education', 'Travel', 'Starting a Business', 'Investing', 'Other');
$spendingHabits = array('Frugal', 'Moderate', 'Spendthrift', 'Budget-Conscious', 'Big Spender', 'Occasional Splurges', 'Other');
$financialIndependence = array('FIRE (Financial Independence, Retire Early)', 'Savings and Investments', 'Passive Income Streams', 'Debt-Free', 'Budgeting and Saving', 'Other');
$fetishes = array('BDSM', 'Foot Fetish', 'Roleplay', 'Lingerie', 'Leather', 'Latex', 'Domination', 'Submission', 'Voyeurism', 'Bondage', 'Cross-dressing', 'Spanking', 'Tickling', 'Food Play', 'Furry', 'Wax Play', 'Medical Play', 'Age Play', 'Shibari', 'Golden Shower', 'Pet Play', 'Humiliation', 'Cuckolding', 'Body Piercing', 'Hair Pulling', 'Electric Play', 'Pony Play', 'Uniforms', 'Objectification', 'Exhibitionism', 'Daddy/Mommy Dom', 'Brat', 'Switch', 'Age Regression', 'Transformation Fetish', 'Wet and Messy (WAM)', 'Balloon Fetish', 'Other');
$personalities = array('Introverted', 'Extroverted', 'Ambivert', 'Adventurous', 'Creative', 'Analytical', 'Empathetic', 'Spontaneous', 'Organized', 'Optimistic', 'Pessimistic', 'Open-minded', 'Conservative', 'Playful', 'Serious', 'Honest', 'Loyal', 'Independent', 'Dependent', 'Other');
$hobbiesAndActivities = array('Reading', 'Gaming', 'Sports', 'Cooking', 'Traveling', 'Art and Crafts', 'Music', 'Dancing', 'Hiking', 'Photography', 'Writing', 'Yoga', 'Camping', 'Fishing', 'Gardening', 'Fitness', 'Volunteering', 'Board Games', 'Collecting', 'Other');
$movieGenres = array('Action', 'Comedy', 'Drama', 'Romance', 'Science Fiction', 'Fantasy', 'Horror', 'Thriller', 'Adventure', 'Documentary', 'Animation', 'Musical', 'Mystery', 'Crime', 'Family', 'Historical', 'Western', 'War', 'Biography', 'Other');
$bookGenres = array('Fiction', 'Non-Fiction', 'Mystery', 'Thriller', 'Romance', 'Science Fiction', 'Fantasy', 'Horror', 'Historical', 'Biography', 'Autobiography', 'Self-Help', 'Philosophy', 'Business', 'Travel', 'Cookbook', 'Poetry', 'Children\'s', 'Young Adult', 'Other');
$highestGraduation = array('High School Diploma', 'Associate Degree', 'Bachelor\'s Degree', 'Master\'s Degree', 'Doctorate/Ph.D.', 'Other');
$education = array('Formal Education', 'Self-Taught', 'Online Courses', 'Vocational Training', 'Certifications', 'Ongoing Studies', 'Other');
$travelPreferences = array('Adventure Travel', 'Cultural Exploration', 'Relaxation/Spa', 'Nature Exploration', 'City Exploration', 'Solo Travel', 'Group Travel', 'Luxury Travel', 'Budget Travel', 'Road Trips', 'Cruise', 'Backpacking', 'Other');
$communicationPreferences = array('Texting', 'Phone Calls', 'Video Calls', 'In-Person', 'Email', 'Social Media Messaging', 'Written Letters', 'Other');
$religion = array('Christianity', 'Islam', 'Judaism', 'Hinduism', 'Buddhism', 'Sikhism', 'Other Religions', 'Spiritual, but not Religious', 'Atheist', 'Agnostic', 'Other');
$languages = array('English', 'Spanish', 'Chinese', 'Hindi', 'Arabic', 'Bengali', 'Portuguese', 'Russian', 'Japanese', 'Punjabi', 'German', 'French', 'Italian', 'Korean', 'Turkish', 'Urdu', 'Other');
$currentSituation = array('Single', 'In a Relationship', 'Engaged', 'Married', 'Divorced', 'Separated', 'Widowed', 'Dating', 'Open Relationship', 'It\'s Complicated', 'Other');
$pets = array('Dog', 'Cat', 'Fish', 'Bird', 'Rodent', 'Reptile', 'Amphibian', 'Exotic Pet', 'Multiple Pets', 'No Pets', 'Other');
$sexualActivity = array('Virgin', 'Frequent', 'Moderate', 'Occasional', 'Rare', 'Abstinent', 'Inactive', 'Active', 'Experimental');
$filterAllowed = array('male', 'female', 'other', 'yes', 'no', 'Heterosexual (Straight)', 'Homosexual (Gay/Lesbian)', 'Bisexual', 'Pansexual', 'Asexual', 'Demisexual', 'Queer', 'Fluid', 'Non-binary Attracted', 'Questioning', 'Other',
'Not sure yet', 'Casual Dating', 'Friends with Benefits', 'Short-term Relationship', 'Long-term Relationship', 'Marriage', 'Exploring Connections', 'Other',
'Long', 'Very Long', 'Shoulder Length', 'Medium Length', 'Short', 'Pixie Cut', 'Bob Cut', 'Lob', 'Layered', 'Curly', 'Straight', 'Wavy', 'Braided', 'Ponytail', 'Bun', 'Top Knot', 'Mohawk', 'Undercut', 'Shaved', 'Dreadlocks', 'Afro', 'Comb Over', 'Messy', 'Wet Look', 'Spiky', 'Bald', 'Balding', 'Other',
'Blonde', 'Brunette', 'Black', 'Red', 'Gray', 'White', 'Brown', 'Auburn', 'Chestnut', 'Platinum Blonde', 'Dirty Blonde', 'Strawberry Blonde', 'Sandy Blonde', 'Honey Blonde', 'Caramel', 'Mahogany', 'Burgundy', 'Copper', 'Silver', 'Salt and Pepper', 'Blue', 'Green', 'Purple', 'Pink', 'Rainbow', 'Multicolored', 'Other',
'None', 'Clean-Shaven', 'Stubble', 'Goatee', 'Circle Beard', 'Van Dyke', 'Mutton Chops', 'Soul Patch', 'Chin Strap', 'Beard without Mustache', 'French Fork', 'Imperial', 'Garibaldi', 'Ducktail', 'Verdi', 'Balbo', 'Anchor Beard', 'Extended Goatee', 'Corporate Beard', 'Hipster Beard', 'Bandholz', 'Yeard (Year-Long Beard)', 'Moustache Only', 'Handlebar Mustache', 'Horseshoe Mustache', 'Fu Manchu', 'Walrus Mustache', 'Pencil Mustache', 'Chevron Mustache', 'Toothbrush Mustache', 'Dali Mustache', 'English Mustache', 'Natural Full Beard', 'Other',
'Bare', 'Smooth', 'Neatly Trimmed', 'Lightly Groomed', 'Short', 'Natural',
'Smooth', 'Waxed', 'Shaved', 'Trimmed', 'Short', 'Groomed', 'Full',
'None', 'Small', 'Medium', 'Large', 'Full Sleeve', 'Half Sleeve', 'Back Piece', 'Chest Piece', 'Neck Tattoo', 'Face Tattoo', 'Hand Tattoo', 'Finger Tattoos', 'Leg Tattoo', 'Ankle Tattoo', 'Foot Tattoo', 'Rib Tattoo', 'Collarbone Tattoo', 'Wrist Tattoo', 'Matching Tattoos', 'Colorful', 'Black and Gray', 'Watercolor', 'Traditional', 'New School', 'Geometric', 'Abstract', 'Script', 'Symbols', 'Portrait', 'Animal', 'Floral', 'Mandala', 'Japanese', 'Tribal', 'Maori', 'Dotwork', 'Minimalist', 'UV Tattoo', 'Scar Cover-up', '3D Tattoo', 'Biomechanical', 'Horror', 'Other',
'None', 'Earlobe', 'Helix', 'Tragus', 'Conch', 'Industrial', 'Rook', 'Daith', 'Snug', 'Nose', 'Septum', 'Lip', 'Tongue', 'Eyebrow', 'Nipple', 'Belly Button', 'Surface', 'Dermal', 'Genital', 'Multiple', 'Other',
'Amber', 'Blue', 'Brown', 'Gray', 'Green', 'Hazel', 'Red/Violet', 'Black', 'Multicolored', 'Albino', 'Other',
'A Cup', 'B Cup', 'C Cup', 'D Cup', 'DD Cup', 'E Cup', 'F Cup', 'G Cup', 'H Cup', 'I Cup', 'J Cup', 'K Cup and above',
'None', 'Six Pack', 'Eight Pack', 'Flat', 'Toned', 'Ripped', 'Washboard Abs', 'Obliques', 'Muscular', 'Defined', 'Other',
'Small', 'Medium', 'Curvy', 'Full-Figured', 'Voluptuous', 'Other',
'Slim', 'Athletic', 'Muscular', 'Average', 'Curvy', 'Full-Figured', 'Voluptuous', 'Bodybuilder', 'Petite', 'Tall', 'Other',
'Caucasian', 'African American', 'Asian', 'Hispanic/Latino', 'Native American', 'Middle Eastern', 'Pacific Islander', 'Mixed Race', 'Other',
'Beginner', 'Intermediate', 'Advanced', 'Athlete', 'Fitness Enthusiast', 'Casual Exerciser', 'Sedentary', 'Other',
'Vegetarian', 'Vegan', 'Pescatarian', 'Flexitarian', 'Paleo', 'Keto', 'Gluten-Free', 'Dairy-Free', 'Nut-Free', 'Other',
'Regular Exercise', 'Healthy Eating', 'Mindfulness/Meditation', 'Hydration', 'Limited Caffeine', 'No Smoking', 'Moderate Alcohol Consumption', 'Regular Health Checkups', 'Other',
'Daily', '4-6 times a week', '2-3 times a week', 'Once a week', 'Occasional', 'Rarely', 'Never', 'Other',
'Early Riser', 'Night Owl', 'Regular Schedule', 'Irregular Schedule', 'Nap Enthusiast', 'Insomniac', 'Heavy Sleeper', 'Light Sleeper', 'Other',
'Gluten', 'Dairy', 'Nuts', 'Shellfish', 'Soy', 'Egg', 'Fish', 'Other',
'Non-Drinker', 'Social Drinker', 'Moderate Drinker', 'Frequent Drinker', 'Heavy Drinker', 'Other',
'Non-Smoker', 'Occasional Smoker', 'Regular Smoker', 'Former Smoker', 'Other',
'Information Technology', 'Finance', 'Healthcare', 'Education', 'Engineering', 'Sales', 'Marketing', 'Customer Service', 'Human Resources', 'Construction', 'Retail', 'Hospitality', 'Manufacturing', 'Transportation', 'Arts and Design', 'Legal', 'Government', 'Nonprofit', 'Self-Employed', 'Agriculture', 'Biotechnology', 'Chemical', 'Environmental Services', 'Fashion', 'Fitness and Recreation', 'Food and Beverage', 'Journalism', 'Media and Broadcasting', 'Pharmaceutical', 'Real Estate', 'Social Services', 'Telecommunications', 'Utilities', 'Waste Management', 'Automotive', 'Aviation', 'Cosmetics', 'Energy', 'Insurance', 'Logistics', 'Mining', 'Pet Care', 'Science', 'Technology', 'Travel and Tourism', 'Writing and Editing', 'Other',
'Apartment', 'House', 'Condo', 'Townhouse', 'Mobile Home', 'Mansion', 'Tiny House', 'Duplex', 'Cabin', 'Loft', 'Farmhouse', 'Ranch', 'Cooperative', 'Bungalow', 'Villa', 'Castle', 'Houseboat', 'Treehouse', 'Earthship', 'Other',
'Saving for Retirement', 'Buying a Home', 'Paying Off Debt', 'Emergency Fund', 'Education', 'Travel', 'Starting a Business', 'Investing', 'Other',
'Frugal', 'Moderate', 'Spendthrift', 'Budget-Conscious', 'Big Spender', 'Occasional Splurges', 'Other',
'FIRE (Financial Independence, Retire Early)', 'Savings and Investments', 'Passive Income Streams', 'Debt-Free', 'Budgeting and Saving', 'Other',
'BDSM', 'Foot Fetish', 'Roleplay', 'Lingerie', 'Leather', 'Latex', 'Domination', 'Submission', 'Voyeurism', 'Bondage', 'Cross-dressing', 'Spanking', 'Tickling', 'Food Play', 'Furry', 'Wax Play', 'Medical Play', 'Age Play', 'Shibari', 'Golden Shower', 'Pet Play', 'Humiliation', 'Cuckolding', 'Body Piercing', 'Hair Pulling', 'Electric Play', 'Pony Play', 'Uniforms', 'Objectification', 'Exhibitionism', 'Daddy/Mommy Dom', 'Brat', 'Switch', 'Age Regression', 'Transformation Fetish', 'Wet and Messy (WAM)', 'Balloon Fetish', 'Other',
'Introverted', 'Extroverted', 'Ambivert', 'Adventurous', 'Creative', 'Analytical', 'Empathetic', 'Spontaneous', 'Organized', 'Optimistic', 'Pessimistic', 'Open-minded', 'Conservative', 'Playful', 'Serious', 'Honest', 'Loyal', 'Independent', 'Dependent', 'Other',
'Reading', 'Gaming', 'Sports', 'Cooking', 'Traveling', 'Art and Crafts', 'Music', 'Dancing', 'Hiking', 'Photography', 'Writing', 'Yoga', 'Camping', 'Fishing', 'Gardening', 'Fitness', 'Volunteering', 'Board Games', 'Collecting', 'Other',
'Action', 'Comedy', 'Drama', 'Romance', 'Science Fiction', 'Fantasy', 'Horror', 'Thriller', 'Adventure', 'Documentary', 'Animation', 'Musical', 'Mystery', 'Crime', 'Family', 'Historical', 'Western', 'War', 'Biography', 'Other',
'Fiction', 'Non-Fiction', 'Mystery', 'Thriller', 'Romance', 'Science Fiction', 'Fantasy', 'Horror', 'Historical', 'Biography', 'Autobiography', 'Self-Help', 'Philosophy', 'Business', 'Travel', 'Cookbook', 'Poetry', 'Children\'s', 'Young Adult', 'Other',
'High School Diploma', 'Associate Degree', 'Bachelor\'s Degree', 'Master\'s Degree', 'Doctorate/Ph.D.', 'Other',
'Formal Education', 'Self-Taught', 'Online Courses', 'Vocational Training', 'Certifications', 'Ongoing Studies', 'Other',
'Adventure Travel', 'Cultural Exploration', 'Relaxation/Spa', 'Nature Exploration', 'City Exploration', 'Solo Travel', 'Group Travel', 'Luxury Travel', 'Budget Travel', 'Road Trips', 'Cruise', 'Backpacking', 'Other',
'Texting', 'Phone Calls', 'Video Calls', 'In-Person', 'Email', 'Social Media Messaging', 'Written Letters', 'Other',
'Christianity', 'Islam', 'Judaism', 'Hinduism', 'Buddhism', 'Sikhism', 'Other Religions', 'Spiritual, but not Religious', 'Atheist', 'Agnostic', 'Other',
'English', 'Spanish', 'Chinese', 'Hindi', 'Arabic', 'Bengali', 'Portuguese', 'Russian', 'Japanese', 'Punjabi', 'German', 'French', 'Italian', 'Korean', 'Turkish', 'Urdu', 'Other',
'Single', 'In a Relationship', 'Engaged', 'Married', 'Divorced', 'Separated', 'Widowed', 'Dating', 'Open Relationship', 'It\'s Complicated', 'Other',
'Dog', 'Cat', 'Fish', 'Bird', 'Rodent', 'Reptile', 'Amphibian', 'Exotic Pet', 'Multiple Pets', 'No Pets', 'Other', 'Virgin', 'Frequent', 'Moderate', 'Occasional', 'Rare', 'Abstinent', 'Inactive', 'Active', 'Experimental');
?>

View File

@@ -0,0 +1,46 @@
<?php
// sexualities: ['Heterosexual (Straight)', 'Homosexual (Gay/Lesbian)', 'Bisexual', 'Pansexual', 'Asexual', 'Demisexual', 'Queer', 'Fluid', 'Non-binary Attracted', 'Questioning', 'Other'],
// lookingFor: ['Not sure yet', 'Casual Dating', 'Friends with Benefits', 'Short-term Relationship', 'Long-term Relationship', 'Marriage', 'Exploring Connections', 'Other'],
// hairs: ['Long', 'Very Long', 'Shoulder Length', 'Medium Length', 'Short', 'Pixie Cut', 'Bob Cut', 'Lob', 'Layered', 'Curly', 'Straight', 'Wavy', 'Braided', 'Ponytail', 'Bun', 'Top Knot', 'Mohawk', 'Undercut', 'Shaved', 'Dreadlocks', 'Afro', 'Comb Over', 'Messy', 'Wet Look', 'Spiky', 'Bald', 'Balding', 'Other'],
// hairColors: ['Blonde', 'Brunette', 'Black', 'Red', 'Gray', 'White', 'Brown', 'Auburn', 'Chestnut', 'Platinum Blonde', 'Dirty Blonde', 'Strawberry Blonde', 'Sandy Blonde', 'Honey Blonde', 'Caramel', 'Mahogany', 'Burgundy', 'Copper', 'Silver', 'Salt and Pepper', 'Blue', 'Green', 'Purple', 'Pink', 'Rainbow', 'Multicolored', 'Other'],
// facialHairs: ['None', 'Clean-Shaven', 'Stubble', 'Goatee', 'Circle Beard', 'Van Dyke', 'Mutton Chops', 'Soul Patch', 'Chin Strap', 'Beard without Mustache', 'French Fork', 'Imperial', 'Garibaldi', 'Ducktail', 'Verdi', 'Balbo', 'Anchor Beard', 'Extended Goatee', 'Corporate Beard', 'Hipster Beard', 'Bandholz', 'Yeard (Year-Long Beard)', 'Moustache Only', 'Handlebar Mustache', 'Horseshoe Mustache', 'Fu Manchu', 'Walrus Mustache', 'Pencil Mustache', 'Chevron Mustache', 'Toothbrush Mustache', 'Dali Mustache', 'English Mustache', 'Natural Full Beard', 'Other'],
// pubicHairs: ['Bare', 'Smooth', 'Neatly Trimmed', 'Lightly Groomed', 'Short', 'Natural'],
// bodyHairs: ['Smooth', 'Waxed', 'Shaved', 'Trimmed', 'Short', 'Groomed', 'Full'],
// tattoos: ['None', 'Small', 'Medium', 'Large', 'Full Sleeve', 'Half Sleeve', 'Back Piece', 'Chest Piece', 'Neck Tattoo', 'Face Tattoo', 'Hand Tattoo', 'Finger Tattoos', 'Leg Tattoo', 'Ankle Tattoo', 'Foot Tattoo', 'Rib Tattoo', 'Collarbone Tattoo', 'Wrist Tattoo', 'Matching Tattoos', 'Colorful', 'Black and Gray', 'Watercolor', 'Traditional', 'New School', 'Geometric', 'Abstract', 'Script', 'Symbols', 'Portrait', 'Animal', 'Floral', 'Mandala', 'Japanese', 'Tribal', 'Maori', 'Dotwork', 'Minimalist', 'UV Tattoo', 'Scar Cover-up', '3D Tattoo', 'Biomechanical', 'Horror', 'Other'],
// piercings: ['None', 'Earlobe', 'Helix', 'Tragus', 'Conch', 'Industrial', 'Rook', 'Daith', 'Snug', 'Nose', 'Septum', 'Lip', 'Tongue', 'Eyebrow', 'Nipple', 'Belly Button', 'Surface', 'Dermal', 'Genital', 'Multiple', 'Other'],
// eyeColors: ['Amber', 'Blue', 'Brown', 'Gray', 'Green', 'Hazel', 'Red/Violet', 'Black', 'Multicolored', 'Albino', 'Other'],
// breastSizes: ['A Cup', 'B Cup', 'C Cup', 'D Cup', 'DD Cup', 'E Cup', 'F Cup', 'G Cup', 'H Cup', 'I Cup', 'J Cup', 'K Cup and above'],
// abs: ['Six Pack', 'Eight Pack', 'Flat', 'Toned', 'Ripped', 'Washboard Abs', 'Obliques', 'Muscular', 'Defined', 'Other'],
// bottomSizes: ['Small', 'Medium', 'Curvy', 'Full-Figured', 'Voluptuous', 'Other'],
// bodyTypes: ['Slim', 'Athletic', 'Muscular', 'Average', 'Curvy', 'Full-Figured', 'Voluptuous', 'Bodybuilder', 'Petite', 'Tall', 'Other'],
// ethnicities: ['Caucasian', 'African American', 'Asian', 'Hispanic/Latino', 'Native American', 'Middle Eastern', 'Pacific Islander', 'Mixed Race', 'Other'],
// fitnessLevels: ['Beginner', 'Intermediate', 'Advanced', 'Athlete', 'Fitness Enthusiast', 'Casual Exerciser', 'Sedentary', 'Other'],
// dietaryPreferences: ['Vegetarian', 'Vegan', 'Pescatarian', 'Flexitarian', 'Paleo', 'Keto', 'Gluten-Free', 'Dairy-Free', 'Nut-Free', 'Other'],
// healthHabits: ['Regular Exercise', 'Healthy Eating', 'Mindfulness/Meditation', 'Hydration', 'Limited Caffeine', 'No Smoking', 'Moderate Alcohol Consumption', 'Regular Health Checkups', 'Other'],
// exerciseFrequency: ['Daily', '4-6 times a week', '2-3 times a week', 'Once a week', 'Occasional', 'Rarely', 'Never', 'Other'],
// sleepingHabits: ['Early Riser', 'Night Owl', 'Regular Schedule', 'Irregular Schedule', 'Nap Enthusiast', 'Insomniac', 'Heavy Sleeper', 'Light Sleeper', 'Other'],
// foodAllergies: ['Gluten', 'Dairy', 'Nuts', 'Shellfish', 'Soy', 'Egg', 'Fish', 'Other'],
// alcoholConsumptions: ['Non-Drinker', 'Social Drinker', 'Moderate Drinker', 'Frequent Drinker', 'Heavy Drinker', 'Other'],
// smoking: ['Non-Smoker', 'Occasional Smoker', 'Regular Smoker', 'Former Smoker', 'Other'],
// jobs: ['Information Technology', 'Finance', 'Healthcare', 'Education', 'Engineering', 'Sales', 'Marketing', 'Customer Service', 'Human Resources', 'Construction', 'Retail', 'Hospitality', 'Manufacturing', 'Transportation', 'Arts and Design', 'Legal', 'Government', 'Nonprofit', 'Self-Employed', 'Agriculture', 'Biotechnology', 'Chemical', 'Environmental Services', 'Fashion', 'Fitness and Recreation', 'Food and Beverage', 'Journalism', 'Media and Broadcasting', 'Pharmaceutical', 'Real Estate', 'Social Services', 'Telecommunications', 'Utilities', 'Waste Management', 'Automotive', 'Aviation', 'Cosmetics', 'Energy', 'Insurance', 'Logistics', 'Mining', 'Pet Care', 'Science', 'Technology', 'Travel and Tourism', 'Writing and Editing', 'Other'],
// mainLiving: ['Apartment', 'House', 'Condo', 'Townhouse', 'Mobile Home', 'Mansion', 'Tiny House', 'Duplex', 'Cabin', 'Loft', 'Farmhouse', 'Ranch', 'Cooperative', 'Bungalow', 'Villa', 'Castle', 'Houseboat', 'Treehouse', 'Earthship', 'Other'],
// financialGoals: ['Saving for Retirement', 'Buying a Home', 'Paying Off Debt', 'Emergency Fund', 'Education', 'Travel', 'Starting a Business', 'Investing', 'Other'],
// spendingHabits: ['Frugal', 'Moderate', 'Spendthrift', 'Budget-Conscious', 'Big Spender', 'Occasional Splurges', 'Other'],
// financialIndependence: ['FIRE (Financial Independence, Retire Early)', 'Savings and Investments', 'Passive Income Streams', 'Debt-Free', 'Budgeting and Saving', 'Other'],
// fetishes: ['BDSM', 'Foot Fetish', 'Roleplay', 'Lingerie', 'Leather', 'Latex', 'Domination', 'Submission', 'Voyeurism', 'Bondage', 'Cross-dressing', 'Spanking', 'Tickling', 'Food Play', 'Furry', 'Wax Play', 'Medical Play', 'Age Play', 'Shibari', 'Golden Shower', 'Pet Play', 'Humiliation', 'Cuckolding', 'Body Piercing', 'Hair Pulling', 'Electric Play', 'Pony Play', 'Uniforms', 'Objectification', 'Exhibitionism', 'Daddy/Mommy Dom', 'Brat', 'Switch', 'Age Regression', 'Transformation Fetish', 'Wet and Messy (WAM)', 'Balloon Fetish', 'Other'],
// personalities: ['Introverted', 'Extroverted', 'Ambivert', 'Adventurous', 'Creative', 'Analytical', 'Empathetic', 'Spontaneous', 'Organized', 'Optimistic', 'Pessimistic', 'Open-minded', 'Conservative', 'Playful', 'Serious', 'Honest', 'Loyal', 'Independent', 'Dependent', 'Other'],
// hobbiesAndActivities: ['Reading', 'Gaming', 'Sports', 'Cooking', 'Traveling', 'Art and Crafts', 'Music', 'Dancing', 'Hiking', 'Photography', 'Writing', 'Yoga', 'Camping', 'Fishing', 'Gardening', 'Fitness', 'Volunteering', 'Board Games', 'Collecting', 'Other'],
// movieGenres: ['Action', 'Comedy', 'Drama', 'Romance', 'Science Fiction', 'Fantasy', 'Horror', 'Thriller', 'Adventure', 'Documentary', 'Animation', 'Musical', 'Mystery', 'Crime', 'Family', 'Historical', 'Western', 'War', 'Biography', 'Other'],
// bookGenres: ['Fiction', 'Non-Fiction', 'Mystery', 'Thriller', 'Romance', 'Science Fiction', 'Fantasy', 'Horror', 'Historical', 'Biography', 'Autobiography', 'Self-Help', 'Philosophy', 'Business', 'Travel', 'Cookbook', 'Poetry', 'Children\'s', 'Young Adult', 'Other'],
// highestGraduation: ['High School Diploma', 'Associate Degree', 'Bachelor\'s Degree', 'Master\'s Degree', 'Doctorate/Ph.D.', 'Other'],
// education: ['Formal Education', 'Self-Taught', 'Online Courses', 'Vocational Training', 'Certifications', 'Ongoing Studies', 'Other'],
// travelPreferences: ['Adventure Travel', 'Cultural Exploration', 'Relaxation/Spa', 'Nature Exploration', 'City Exploration', 'Solo Travel', 'Group Travel', 'Luxury Travel', 'Budget Travel', 'Road Trips', 'Cruise', 'Backpacking', 'Other'],
// communicationPreferences: ['Texting', 'Phone Calls', 'Video Calls', 'In-Person', 'Email', 'Social Media Messaging', 'Written Letters', 'Other'],
// religion: ['Christianity', 'Islam', 'Judaism', 'Hinduism', 'Buddhism', 'Sikhism', 'Other Religions', 'Spiritual, but not Religious', 'Atheist', 'Agnostic', 'Other'],
// languages: ['English', 'Spanish', 'Chinese', 'Hindi', 'Arabic', 'Bengali', 'Portuguese', 'Russian', 'Japanese', 'Punjabi', 'German', 'French', 'Italian', 'Korean', 'Turkish', 'Urdu', 'Other'],
// currentSituation: ['Single', 'In a Relationship', 'Engaged', 'Married', 'Divorced', 'Separated', 'Widowed', 'Dating', 'Open Relationship', 'It\'s Complicated', 'Other'],
// pets: ['Dog', 'Cat', 'Fish', 'Bird', 'Rodent', 'Reptile', 'Amphibian', 'Exotic Pet', 'Multiple Pets', 'No Pets', 'Other'],

84146
includes/countries.json Normal file

File diff suppressed because it is too large Load Diff

7
index.php Normal file
View File

@@ -0,0 +1,7 @@
<?php
require_once('_conf/globals.php');
require_once('_conf/db_con.php');
$postData = file_get_contents('php://input');
$postData = json_decode($postData);
// Login

6
php.ini Normal file
View File

@@ -0,0 +1,6 @@
; cPanel-generated php ini directives, do not edit
; Manual editing of this file may result in unexpected behavior.
; To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
; For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
allow_url_fopen = 1

23
sitemap.xml Normal file
View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<!-- Homepage -->
<url>
<loc>https://stellaamor.com/</loc>
<lastmod>2024-12-15</lastmod>
<priority>1.0</priority>
</url>
<!-- Login/Sign-Up Page -->
<url>
<loc>https://stellaamor.com/login</loc>
<lastmod>2024-12-15</lastmod>
<priority>0.8</priority>
</url>
<!-- About Us Page -->
<url>
<loc>https://stellaamor.com/about</loc>
<lastmod>2024-12-15</lastmod>
<priority>0.6</priority>
</url>
</urlset>

BIN
static/logo2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
stella.zip Normal file

Binary file not shown.

32
stella_core_class.php Normal file
View File

@@ -0,0 +1,32 @@
<?php
require_once('_conf/globals.php');
require_once('_conf/db_con.php');
class StellaCore{
public $userId;
public function preference_exists($preference, $value){
global $db_con;
}
public function getAdminMessage(){
global $db_con;
$sql = $db_con->prepare('SELECT * FROM website_misc WHERE misc_name = "admin_message"');
$sql->execute();
if($sql->rowCount() > 0){
$_message = $sql->fetch(PDO::FETCH_ASSOC);
$message = $_message['misc_value'];
if(strlen($message) > 0){
echo json_encode($message);
}
}
}
public function sendMessage($uemail, $utitle, $umessage){
global $db_con;
$sql = $db_con->prepare('INSERT INTO message_table (user_email, message_title, user_message) VALUES (:user_email, :message_title, :user_message)');
$sql->bindValue(':user_email', $uemail);
$sql->bindValue(':message_title', $utitle);
$sql->bindValue(':user_message', $umessage);
$sql->execute();
}
}

BIN
stellaamorapizip.zip Normal file

Binary file not shown.

17
taca/_conf/db_con.php Normal file
View File

@@ -0,0 +1,17 @@
<?php
$hostname = $_SERVER['HTTP_HOST'];
if($hostname == 'api.stellaamor.com.local'){
$server = 'localhost';
$username = "root";
$db = "stella_amor";
$db_con = new pdo("mysql:host=$server;dbname=$db;charset=utf8mb4", $username);
}else{
$server = 'localhost';
$username = 'mysinfu1_stella';
$db_pass = 'E1#j#W4Y4UcV';
$db = 'mysinfu1_stella';
$db_con = new pdo("mysql:host=$server;dbname=$db;charset=utf8mb4", $username, $db_pass);
}

14
taca/_conf/globals.php Normal file
View File

@@ -0,0 +1,14 @@
<?php
$hostname = $_SERVER['HTTP_HOST'];
if ($hostname === 'api.stellaamor.com') {
// Production environment
header("Access-Control-Allow-Origin: https://taca.stellaamor.com");
} else {
// Local environment
header("Access-Control-Allow-Origin: http://admin.stellaamor.com.local");
}
header("Access-Control-Allow-Credentials: true");
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
?>

61
taca/settings.php Normal file
View File

@@ -0,0 +1,61 @@
<?php
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
require_once('_conf/globals.php');
require_once('_conf/db_con.php');
if(isset($_GET['allowedFilter']) && $_GET['allowedFilter'] == true){
require_once('../includes/allowedFilter.php');
$allowedFilter = new stdClass();
$allowedFilter->sexualities = $sexualities;
$allowedFilter->lookingFor = $lookingFor;
$allowedFilter->hairs = $hairs;
$allowedFilter->hairColors = $hairColors;
$allowedFilter->facialHairs = $facialHairs;
$allowedFilter->pubicHairs = $pubicHairs;
$allowedFilter->bodyHairs = $bodyHairs;
$allowedFilter->tattoos = $tattoos;
$allowedFilter->piercings = $piercings;
$allowedFilter->eyeColors = $eyeColors;
$allowedFilter->breastSizes = $breastSizes;
$allowedFilter->abs = $abs;
$allowedFilter->bottomSizes = $bottomSizes;
$allowedFilter->bodyTypes = $bodyTypes;
$allowedFilter->ethnicities = $ethnicities;
$allowedFilter->fitnessLevels = $fitnessLevels;
$allowedFilter->dietaryPreferences = $dietaryPreferences;
$allowedFilter->healthHabits = $healthHabits;
$allowedFilter->exerciseFrequency = $exerciseFrequency;
$allowedFilter->sleepingHabits = $sleepingHabits;
$allowedFilter->foodAllergies = $foodAllergies;
$allowedFilter->alcoholConsumptions = $alcoholConsumptions;
$allowedFilter->smoking = $smoking;
$allowedFilter->jobs = $jobs;
$allowedFilter->mainLiving = $mainLiving;
$allowedFilter->financialGoals = $financialGoals;
$allowedFilter->spendingHabits = $spendingHabits;
$allowedFilter->financialIndependence = $financialIndependence;
$allowedFilter->fetishes = $fetishes;
$allowedFilter->personalities = $personalities;
$allowedFilter->hobbiesAndActivities = $hobbiesAndActivities;
$allowedFilter->movieGenres = $movieGenres;
$allowedFilter->bookGenres = $bookGenres;
$allowedFilter->highestGraduation = $highestGraduation;
$allowedFilter->education = $education;
$allowedFilter->travelPreferences = $travelPreferences;
$allowedFilter->communicationPreferences = $communicationPreferences;
$allowedFilter->religion = $religion;
$allowedFilter->languages = $languages;
$allowedFilter->currentSituation = $currentSituation;
$allowedFilter->pets = $pets;
$allowedFilter->sexualActivity = $sexualActivity;
header('Content-Type: application/json');
echo json_encode($allowedFilter);
}
if(isset($_GET) && !empty($_GET) && isset($_GET['countries']) && $_GET['countries'] == 'true'){
$countries = file_get_contents('../includes/countries.json');
echo $countries;
}

235
taca/users.php Normal file
View File

@@ -0,0 +1,235 @@
<?php
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
require_once('_conf/globals.php');
require_once('_conf/db_con.php');
$postData = file_get_contents('php://input');
$postData = json_decode($postData);
$postAction = isset($postData->action) && !empty($postData->action) ? $postData->action : 'custom';
if($postAction == 'login'){
$sql = $db_con->prepare('SELECT * FROM admins WHERE username = :username');
$sql->bindValue(':username', $postData->userData->username);
$sql->execute();
$numRows = $sql->rowCount();
if($numRows){
$user = $sql->fetch(PDO::FETCH_ASSOC);
if(password_verify($postData->userData->password, $user['psw'])){
$hex = bin2hex(random_bytes(36 / 2));
$_SESSION['admin'] = true;
$_SESSION['auth'] = $hex;
$_SESSION['userid'] = $user['ID'];
$response = new stdClass();
$response->status = true;
$sql = $db_con->prepare('UPDATE admins SET session_hex = :hex WHERE ID = :id');
$sql->bindValue(':hex', $hex);
$sql->bindValue(':id', $user['ID']);
$sql->execute();
}else{
$response = new stdClass();
$response->status = false;
}
}else{
$response = new stdClass();
$response->status = false;
}
echo json_encode($response);
}
if($postAction == 'isAuth'){
if (session_status() === PHP_SESSION_ACTIVE) {
$session_hex = isset($_SESSION['auth']) && !empty($_SESSION['auth']) ? $_SESSION['auth'] : '';
$user_id = isset($_SESSION['userid']) && !empty($_SESSION['userid']) ? $_SESSION['userid'] : '';
$sql = $db_con->prepare('SELECT * FROM admins WHERE ID = :id AND session_hex = :hex');
$sql->bindValue(':id', $user_id);
$sql->bindValue(':hex', $session_hex);
$sql->execute();
$rowC = $sql->rowCount();
if($rowC){
$response = new stdClass();
$response->status = true;
}else{
session_destroy();
$response = new stdClass();
$response->status = false;
}
echo json_encode($response);
}
}
function privAuth(){
global $db_con;
if (session_status() === PHP_SESSION_ACTIVE) {
$session_hex = isset($_SESSION['auth']) && !empty($_SESSION['auth']) ? $_SESSION['auth'] : '';
$user_id = isset($_SESSION['userid']) && !empty($_SESSION['userid']) ? $_SESSION['userid'] : '';
$sql = $db_con->prepare('SELECT * FROM admins WHERE ID = :id AND session_hex = :hex');
$sql->bindValue(':id', $user_id);
$sql->bindValue(':hex', $session_hex);
$sql->execute();
$rowC = $sql->rowCount();
if($rowC){
return true;
}else{
session_destroy();
return false;
}
}
}
if($postAction == 'logout'){
if (session_status() === PHP_SESSION_ACTIVE) {
$session_hex = isset($_SESSION['auth']) && !empty($_SESSION['auth']) ? $_SESSION['auth'] : '';
$user_id = isset($_SESSION['userid']) && !empty($_SESSION['userid']) ? $_SESSION['userid'] : '';
$sql = $db_con->prepare('UPDATE admins SET session_hex = "" WHERE ID = :id AND session_hex = :hex');
$sql->bindValue(':id', $user_id);
$sql->bindValue(':hex', '');
$sql->execute();
$rowC = $sql->rowCount();
session_destroy();
}
}
if($postAction == 'getUsers'){
if(privAuth()){
$sql = $db_con->prepare('SELECT * FROM users');
$sql->execute();
$_users = $sql->fetchAll(PDO::FETCH_ASSOC);
$users = array();
foreach($_users as $user){
$_user = new stdClass();
$_user->usid = isset($user['id']) && !empty($user['id']) ? $user['id'] : '';
$_user->email = isset($user['u_email']) && !empty($user['u_email']) ? $user['u_email'] : '';
$_user->username = isset($user['uname']) && !empty($user['uname']) ? $user['uname'] : '';
$_user->regDate = isset($user['date_signed_up']) && !empty($user['date_signed_up']) ? $user['date_signed_up'] : '';
$_user->stripe_cu = isset($user['stripe_cu']) && !empty($user['stripe_cu']) ? $user['stripe_cu'] : '';
$users[] = $_user;
}
echo json_encode($users);
}
}
if(isset($_POST['action']) && $_POST['action'] == 'insertUser'){
$userData = json_decode($_POST['userData'], true);
$username = isset($userData['username']) && !empty($userData['username']) ? $userData['username'] : '';
$email = isset($userData['email']) && !empty($userData['email']) ? $userData['email'] : '';
$password = isset($userData['password']) && !empty($userData['password']) ? $userData['password'] : '';
$bio = isset($userData['bio']) && !empty($userData['bio']) ? $userData['bio'] : '';
$pass = password_hash($password, PASSWORD_BCRYPT, ['cost' => 12]);
if(isset($username) && !empty($username) && isset($email) && !empty($email) && isset($password) && !empty($password)){
$sql = $db_con->prepare('INSERT INTO users (uname, psw, u_email, bio) VALUES (:uname, :psw, :email, :bio)');
$sql->bindValue(':uname', $username);
$sql->bindValue(':psw', $pass);
$sql->bindValue(':email', $email);
$sql->bindValue(':bio', $bio);
$sql->execute();
$rowC = $sql->rowCount();
if($rowC > 0){
$user_id = $db_con->lastInsertId();
if(isset($_FILES['avatar']) && $_FILES['avatar']['error'] === UPLOAD_ERR_OK){
$avatar = $_FILES['avatar']['tmp_name'];
$image_name = $_FILES['avatar']['name'];
$image_size = $_FILES['avatar']['size'];
$ext = strtolower(pathinfo($_FILES['avatar']['name'], PATHINFO_EXTENSION));
$image_content = file_get_contents($avatar);
$allowedPhotos = array('jpg', 'jpeg', 'png', 'gif');
$name = generateRandomName();
$name = $name . '.' . $ext;
$path = $_SERVER['DOCUMENT_ROOT'] . '/uploads/';
if (in_array($ext, $allowedPhotos)) {
move_uploaded_file($avatar, $path . $name);
}
$stmt = $db_con->prepare('UPDATE users SET avatar = :avatar WHERE id = :id');
$stmt->bindValue(':avatar', $name);
$stmt->bindValue(':id', $user_id);
$stmt->execute();
}
if(isset($_FILES['banner']) && $_FILES['banner']['error'] === UPLOAD_ERR_OK){
$banner = $_FILES['banner']['tmp_name'];
$image_name = $_FILES['banner']['name'];
$image_size = $_FILES['banner']['size'];
$ext = strtolower(pathinfo($_FILES['banner']['name'], PATHINFO_EXTENSION));
$image_content = file_get_contents($banner);
$allowedPhotos = array('jpg', 'jpeg', 'png', 'gif');
$name = generateRandomName();
$name = $name . '.' . $ext;
$path = $_SERVER['DOCUMENT_ROOT'] . '/uploads/';
if (in_array($ext, $allowedPhotos)) {
move_uploaded_file($banner, $path . $name);
}
$stmt = $db_con->prepare('UPDATE users SET banner = :banner WHERE id = :id');
$stmt->bindValue(':banner', $name);
$stmt->bindValue(':id', $user_id);
$stmt->execute();
}
foreach ($userData as $setting => $value) {
if ($setting != 'username' || $setting != 'password' || $setting != 'email' || $setting != 'bio' || $setting != 'avatar' || $setting != 'banner') {
if (isset($value) && !empty($value)) {
update_user_data($setting, $value, $user_id);
}
}
}
}
}else{
die();
}
}
function generateRandomName($length = 32) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$randomName = '';
$maxIndex = strlen($characters) - 1;
for ($i = 0; $i < $length; $i++) {
$randomName .= $characters[rand(0, $maxIndex)];
}
return $randomName;
}
function update_user_data($name, $value, $user){
global $db_con;
if(is_array($value)){
$value = implode(",", $value);
}
$sql_con = $db_con->prepare('SELECT * FROM user_data WHERE data_name = :data_name AND user_id = :user_id');
$sql_con->bindValue(':data_name', $name);
$sql_con->bindValue(':user_id', $user);
$sql_con->execute();
$num_rows = $sql_con->rowCount();
if($num_rows > 0){
$sql_con = $db_con->prepare('UPDATE user_data SET data_value = :data_value WHERE user_id = :user_id AND data_name = :data_name');
$sql_con->bindValue(':data_name', $name);
$sql_con->bindValue(':data_value', $value);
$sql_con->bindValue(':user_id', $user);
$sql_con->execute();
}else{
$sql_con = $db_con->prepare('INSERT INTO user_data (data_name, data_value, user_id) VALUES (:data_name, :data_value, :user_id)');
$sql_con->bindValue(':data_name', $name);
$sql_con->bindValue(':data_value', $value);
$sql_con->bindValue(':user_id', $user);
$sql_con->execute();
}
// echo 'Executed ' . $name . ' with value ' . $value . '<br>';
}
?>

44
test.php Normal file
View File

@@ -0,0 +1,44 @@
<?php
require_once('_conf/globals.php');
require_once('_conf/db_con.php');
// $stmt = $db_con->prepare("SELECT * FROM users");
// $stmt->execute();
// $users = $stmt->fetch(PDO::FETCH_ASSOC);
// var_dump($users);
$fields = json_decode(file_get_contents('php://input'));
function register_user($fields){
global $db_con;
if($fields->username && $fields->email){
$_username = $fields->username;
$_email = $fields->email;
$sql_con = $db_con->prepare('INSERT INTO users SET uname = :username, u_email = :email');
$sql_con->bindValue(':username', $_username);
$sql_con->bindValue(':email', $_email);
$sql_con->execute();
$ret_sql = $db_con->prepare('SELECT * FROM users WHERE uname = :username');
$ret_sql->bindValue(':username', $_username);
$ret_sql->execute();
$user = $ret_sql->fetch(PDO::FETCH_ASSOC);
return $user;
}
}
if(isset($fields->action)){
if($fields->action === 'register'){
$user = new stdClass();
$userInfo = register_user($fields);
$_username = $userInfo['uname'];
$user->uname = $_username;
$user = json_encode($user);
echo $user;
}
}
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 434 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 KiB

BIN
uploads/defaultavatar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
uploads/dfbg.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 796 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 304 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 KiB

420
users.php Normal file
View File

@@ -0,0 +1,420 @@
<?php
require_once('_conf/globals.php');
require_once('_conf/db_con.php');
$postData = file_get_contents('php://input');
$postData = json_decode($postData);
// Allowed genders
$allowed_genders = array('male', 'female', 'other');
// Register
if($postData){
$postAction = $postData->action;
}else{
$postAction = 'Custom';
}
if($postAction === 'signup'){
$userData = $postData->userData;
$response = new stdClass();
require_once('users_class.php');
// Fetch countries
$url = 'https://restcountries.com/v3.1/all?fields=name';
$pre_countries = file_get_contents($url);
if ($pre_countries !== null) {
$pre_countries = json_decode($pre_countries, true);
$countries = array_map(function ($country) {
return $country['name']['common'];
}, $pre_countries);
}
// Validate
if(!isset($userData->country) || empty($userData->country)){
$response->status = 'fail';
$response->fail_status = 'country';
$response->message = 'You need to select a country';
echo json_encode($response);
exit();
}
if(!in_array($userData->country, $countries)){
$response->status = 'fail';
$response->fail_status = 'country';
$response->message = 'Invalid country';
echo json_encode($response);
exit();
}
if(!$userData->acceptTerms){
$response->status = 'fail';
$response->fail_status = 'tos';
$response->message = 'You need to accept the terms of use';
echo json_encode($response);
exit();
}
if(!isset($userData->username) || empty($userData->username)){
$response->status = 'fail';
$response->fail_status = 'username';
$response->message = 'Empty username';
echo json_encode($response);
exit();
}
if (strlen($userData->username) < 3) {
$response->status = 'fail';
$response->fail_status = 'username';
$response->message = 'Username is too short, minimum 3 characters';
echo json_encode($response);
exit();
}
if(!isset($userData->gender) || empty($userData->gender)){
$response->status = 'fail';
$response->fail_status = 'gender';
$response->message = 'Empty gender';
echo json_encode($response);
exit();
}
if(!in_array($userData->gender, $allowed_genders)){
$response->status = 'fail';
$response->fail_status = 'gender';
$response->message = 'Invalid gender';
echo json_encode($response);
exit();
}
if(!isset($userData->email) || empty($userData->email)){
$response->status = 'fail';
$response->fail_status = 'email';
$response->message = 'Empty email';
echo json_encode($response);
exit();
}
if (!filter_var($userData->email, FILTER_VALIDATE_EMAIL)) {
$response->status = 'fail';
$response->fail_status = 'email';
$response->message = 'Invalid email';
echo json_encode($response);
exit();
}
if(!isset($userData->password) || empty($userData->password)){
$response->status = 'fail';
$response->fail_status = 'password';
$response->message = 'Empty password';
echo json_encode($response);
exit();
}
if (strlen($userData->password) < 6) {
$response->status = 'fail';
$response->fail_status = 'password';
$response->message = 'Password is too short, minimum 6 characters';
echo json_encode($response);
exit();
}
if(!isset($userData->password2) || empty($userData->password2)){
$response->status = 'fail';
$response->fail_status = 'password2';
$response->message = 'Confirm password';
echo json_encode($response);
exit();
}
if($userData->password !== $userData->password2){
$response->status = 'fail';
$response->fail_status = 'passwords';
$response->message = 'Passwords does not match';
echo json_encode($response);
exit();
}
// Assign information
$_psw = password_hash($userData->password, PASSWORD_BCRYPT, ["cost" => 12]);
$user = new Users();
$user->username = $userData->username;
$user->country = $userData->country;
$user->gender = $userData->gender;
$user->email = $userData->email;
$user->password = $_psw;
$user->dob = $userData->dob;
if($user->username_exists()){
$response->status = 'fail';
$response->fail_status = 'username';
$response->message = 'Username is already in use';
echo json_encode($response);
exit();
}
if($user->email_exists()){
$response->status = 'fail';
$response->fail_status = 'email';
$response->message = 'Email is already in use';
echo json_encode($response);
exit();
}
$user->register();
}
// Login
if($postAction === 'login'){
$userData = $postData->userData;
$response = new stdClass();
require_once('users_class.php');
$user = new Users();
if($user->isAuth()){
$response->status = 'error';
$response->fail_status = 'login';
$response->message = 'Already logged in';
echo json_encode($response);
exit();
}
$user->username = $userData->username;
$user->password = $userData->password;
if(!isset($userData->username) || empty($userData->username)){
$response->status = 'fail';
$response->fail_status = 'username';
$response->message = 'Fill out your username';
echo json_encode($response);
exit();
}
if(!isset($userData->password) || empty($userData->password)){
$response->status = 'fail';
$response->fail_status = 'password';
$response->message = 'Fill out your password';
echo json_encode($response);
exit();
}
$userInfo = $user->login();
if($userInfo){
if(password_verify($user->password, $userInfo['psw'])){
$session_code = $user->setLogin($userInfo['id']);
setcookie('authCookie', $session_code, time() + (10 * 365 * 24 * 60 * 60));
setcookie('authId', $userInfo['id'], time() + (10 * 365 * 24 * 60 * 60));
$response->status = 'success';
$response->fail_status = 'login';
$response->message = 'Login success';
echo json_encode($response);
exit();
}else{
$response->status = 'fail';
$response->fail_status = 'password';
$response->message = 'Incorrect password';
echo json_encode($response);
exit();
}
}else{
$response->status = 'fail';
$response->fail_status = 'username';
$response->message = 'Incorrect details';
echo json_encode($response);
exit();
}
}
if ($postAction === 'updateUserSettings') {
$uSettings = $postData->settings;
require_once('users_class.php');
$user = new Users();
if($user->isAuth()){
foreach ($uSettings as $setting => $value) {
if ($user->allowedSetting($setting)) {
if (isset($value) && !empty($value)) {
$user->update_user_data($setting, $value, $_COOKIE['authId']);
}
}
}
}
}
if (isset($_GET['getUserSettings']) && $_GET['getUserSettings'] == true){
require_once('users_class.php');
$user = new Users();
if($user->isAuth()){
$userSettings = $user->initUserSettings();
echo $userSettings;
}
}
if(isset($_GET['isAuth']) && $_GET['isAuth'] == true){
require_once('users_class.php');
$user = new Users();
if($user->isAuth()){
$response = new stdClass();
$response->status = true;
echo json_encode($response);
}else{
if(isset($_COOKIE['authId'])){
$user->logout();
}
$response = new stdClass();
$response->status = false;
echo json_encode($response);
}
}
if(isset($_GET['logout']) && $_GET['logout'] == 'true'){
setcookie('authCookie','', time() - 3600);
setcookie('authId', '', time() - 3600);
require_once('users_class.php');
$user = new Users();
$user->logout();
}
if(isset($_POST['action']) && $_POST['action'] == 'updatePublicProfile'){
require_once('users_class.php');
$users = new Users();
if($users->isAuth()){
if(isset($_FILES['avatar']) && $_FILES['avatar']['error'] === UPLOAD_ERR_OK){
$avatar_temp = $_FILES['avatar']['tmp_name'];
$avatar_name = $_FILES['avatar']['name'];
$avatar_size = $_FILES['avatar']['size'];
$fileExtension = strtolower(pathinfo($_FILES['avatar']['name'], PATHINFO_EXTENSION));
$avatar_content = file_get_contents($avatar_temp);
$users->updateAvatar($avatar_temp, $fileExtension);
}
if(isset($_FILES['banner']) && $_FILES['banner']['error'] === UPLOAD_ERR_OK){
$banner_temp = $_FILES['banner']['tmp_name'];
$banner_name = $_FILES['banner']['name'];
$banner_size = $_FILES['banner']['size'];
$fileExtension = strtolower(pathinfo($_FILES['banner']['name'], PATHINFO_EXTENSION));
$banner_content = file_get_contents($banner_temp);
$users->updateBanner($banner_temp, $fileExtension);
}
if(isset($_POST['bio']) && !empty($_POST['bio'])){
$bio = htmlspecialchars($_POST['bio']);
$users->updateBio($bio);
}
}
}
if($postAction == 'userInit'){
require_once('users_class.php');
$users = new Users();
if($users->isAuth()){
$userData = $users->initUser();
echo $userData;
}
}
if($postAction == 'getUser'){
require_once('users_class.php');
$users = new Users();
if($users->isAuth()){
if($users->hasPaid()){
$userId = intval($postData->userId);
$userData = $users->getUser($userId);
echo $userData;
}
}
}
if(isset($_POST['action']) && $_POST['action'] == 'uploadGalleryImage'){
require_once('users_class.php');
$users = new Users();
if($users->isAuth()){
if(isset($_FILES['image']) && $_FILES['image']['error'] === UPLOAD_ERR_OK){
$image_temp = $_FILES['image']['tmp_name'];
$image_name = $_FILES['image']['name'];
$image_size = $_FILES['image']['size'];
$fileExtension = strtolower(pathinfo($_FILES['image']['name'], PATHINFO_EXTENSION));
$image_content = file_get_contents($image_temp);
$users->uploadGalleryImage($image_temp, $fileExtension);
}
}
}
if($postAction == 'deleteImage'){
require_once('users_class.php');
$users = new Users();
if($users->isAuth()){
if($users->hasPaid()){
$users->deleteImage($postData->image);
}
}
}
if($postAction == 'getMessages'){
require_once('users_class.php');
$users = new Users();
$user_id = $postData->user_id;
if($users->isAuth()){
if($users->hasPaid()){
$messages = $users->receive_messages($user_id);
echo $messages;
}
}
}
if($postAction == 'sendMessage'){
require_once('users_class.php');
$users = new Users();
$user_id = $postData->user_id;
$message = $postData->newMessage;
if($users->isAuth()){
if($users->hasPaid()){
$users->sendMessage($user_id, $message);
$messages = $users->receive_messages($user_id);
echo $messages;
}
}
}
if($postAction == 'getConversations'){
require_once('users_class.php');
$users = new Users();
if($users->isAuth()){
if($users->hasPaid()){
$conversations = $users->get_conversations();
echo $conversations;
}
}
}
if($postAction == 'unread'){
require_once('users_class.php');
$users = new Users();
if($users->isAuth()){
$status = $users->checkUnread();
echo $status;
}
}
if($postAction == 'updatePassword'){
require_once('users_class.php');
$users = new Users();
if($users->isAuth()){
$status = $users->updatePassword($postData->currPass, $postData->newPass, $postData->confPass);
echo $status;
}
}
if($postAction == 'isPaid'){
require_once('users_class.php');
$user = new Users();
if($user->isAuth()){
$status = $user->hasPaid();
$response = new stdClass();
$response->status = $status;
echo json_encode($response);
}
}

680
users_class.php Normal file
View File

@@ -0,0 +1,680 @@
<?php
class Users{
public $username;
public $email;
public $pass;
public $gender;
public $password;
public $country;
public $city;
public $dob;
public $allowedSettings = array('gender', 'dob', 'sexuality', 'sexualActivity', 'lookingFor', 'country', 'city', 'height', 'weight', 'hair', 'facialHair', 'pubicHair', 'bodyHair', 'hairColor', 'tattoo', 'piercing', 'eyeColor', 'breastSize', 'penisSize', 'abs', 'bottomSizes', 'bodyTypes', 'ethnicities', 'fitnessLevels', 'dietaryPreferences', 'healthHabits', 'exerciseFrequency', 'sleepingHabits', 'foodAllergies', 'alcoholConsumptions', 'smoking', 'jobs', 'netWorth', 'yearlySalary', 'mainLiving', 'financialGoals', 'spendingHabits', 'financialIndependence', 'inDebt', 'hasKids', 'wantKids', 'fetishes', 'personalities', 'hobbiesAndActivities', 'movieGenres', 'bookGenres', 'highestGraduation', 'education', 'travelPreferences', 'religion', 'languages', 'currentSituation', 'pets');
public $personalSettings = array(
'gender' => array(
'function' => 'update_general_preference',
'name' => 'gender',
),
'dob' => array(
'function' => 'update_general_preference',
'name' => 'dob',
),
'sexuality' => array(
'function' => 'update_general_preference',
'name' => 'sexuality'
),
'lookingFor' => array(
'function' => 'update_general_preference',
'name' => 'lookingFor',
),
'country' => array(
'function' => 'update_general_preference',
'name' => 'country',
),
'city' => array(
'function' => 'update_general_preference',
'name' => 'city',
),
);
// public function __construct(){
// }
public function email_exists(){
global $db_con;
$pre_sql = $db_con->prepare('SELECT u_email FROM users WHERE u_email = :email');
$pre_sql->bindValue(':email', $this->email);
$pre_sql->execute();
$_res = $pre_sql->rowCount();
if($_res > 0){
return true;
}else{
return false;
}
}
public function username_exists(){
global $db_con;
$pre_sql = $db_con->prepare('SELECT uname FROM users WHERE uname = :uname');
$pre_sql->bindValue(':uname', $this->username);
$pre_sql->execute();
$_res = $pre_sql->rowCount();
if($_res > 0){
return true;
}else{
return false;
}
}
public function setLogin($id){
global $db_con;
$hex = bin2hex(random_bytes(36 / 2));
$sql_con = $db_con->prepare("UPDATE users SET login_session_id = :hex WHERE id = :id");
$sql_con->bindValue(':hex', $hex);
$sql_con->bindValue(':id', $id);
$sql_con->execute();
return $hex;
}
public function logout(){
global $db_con;
$sql = $db_con->prepare("UPDATE users SET login_session_id = '' WHERE id = :id");
$sql->bindValue(':id', $_COOKIE['authId']);
$sql->execute();
setcookie('authCookie','', time() - 7200);
setcookie('authId', '', time() - 7200);
session_destroy();
}
public function isAuth(){
global $db_con;
if(isset($_COOKIE['authCookie'])){
$token = $_COOKIE['authCookie'];
$uId = $_COOKIE['authId'];
$sql_con = $db_con->prepare('SELECT * FROM users WHERE login_session_id = :session_key AND id = :id');
$sql_con->bindValue(':session_key', $token);
$sql_con->bindValue(':id', $uId);
$sql_con->execute();
$rowCount = $sql_con->rowCount();
if($rowCount !== 0){
return true;
}else{
return false;
}
}else{
return false;
}
}
public function register(){
global $db_con;
$sql_con = $db_con->prepare('INSERT INTO users SET uname = :username, u_email = :email, psw = :psw, dob = :dob');
$sql_con->bindValue(':username', $this->username);
$sql_con->bindValue(':email', $this->email);
$sql_con->bindValue(':psw', $this->password);
$sql_con->bindValue(':dob', $this->dob);
$sql_con->execute();
$sql_con = $db_con->prepare('SELECT id FROM users WHERE u_email = :u_email');
$sql_con->bindValue(':u_email', $this->email);
$sql_con->execute();
$temp_user_data = $sql_con->fetch(PDO::FETCH_ASSOC);
$user_id = $temp_user_data['id'];
if(!empty($user_id)){
$this->update_user_data('gender', $this->gender, $user_id);
$this->update_user_data('country', $this->country, $user_id);
$this->update_user_data('dob', '', $user_id);
}
$cu_name = md5(time());
$date = new DateTime();
$date->modify('+30 days');
$cu_exp = $date->getTimestamp();
$sql = $db_con->prepare('INSERT INTO stripe_user_data (cu_name, exp_date) VALUES (:cu_name, :exp)');
$sql->bindValue(':cu_name', $cu_name);
$sql->bindValue(':exp', $cu_exp);
$sql->execute();
$sql_con = $db_con->prepare('UPDATE users SET stripe_cu = :stripe_cu WHERE id = :user_id');
$sql_con->bindValue(':stripe_cu', $cu_name);
$sql_con->bindValue(':user_id', $user_id);
$sql_con->execute();
}
public function login(){
global $db_con;
$sql_con = $db_con->prepare('SELECT * FROM users WHERE uname = :uname');
$sql_con->bindValue(':uname', $this->username);
$sql_con->execute();
$user = $sql_con->fetch(PDO::FETCH_ASSOC);
return $user;
}
public function update_user_data($name, $value, $user){
global $db_con;
if(is_array($value)){
$value = implode(",", $value);
}
$sql_con = $db_con->prepare('SELECT * FROM user_data WHERE data_name = :data_name AND user_id = :user_id');
$sql_con->bindValue(':data_name', $name);
$sql_con->bindValue(':user_id', $user);
$sql_con->execute();
$num_rows = $sql_con->rowCount();
if($num_rows > 0){
$sql_con = $db_con->prepare('UPDATE user_data SET data_value = :data_value WHERE user_id = :user_id AND data_name = :data_name');
$sql_con->bindValue(':data_name', $name);
$sql_con->bindValue(':data_value', $value);
$sql_con->bindValue(':user_id', $user);
$sql_con->execute();
}else{
$sql_con = $db_con->prepare('INSERT INTO user_data (data_name, data_value, user_id) VALUES (:data_name, :data_value, :user_id)');
$sql_con->bindValue(':data_name', $name);
$sql_con->bindValue(':data_value', $value);
$sql_con->bindValue(':user_id', $user);
$sql_con->execute();
}
// echo 'Executed ' . $name . ' with value ' . $value . '<br>';
}
public function allowedSetting($setting){
if(in_array($setting, $this->allowedSettings)){
return true;
}else{
return false;
}
}
public function locateAtts($setting){
if(key_exists($setting, $this->personalSettings)){
return $this->personalSettings;
}
}
public function initUserSettings(){
global $db_con;
if($this->isAuth()){
$sql_con = $db_con->prepare("SELECT u.uname, u.u_email, ud.data_name, ud.data_value
FROM users u
JOIN user_data ud ON u.id = ud.user_id
WHERE ud.user_id = :user_id");
$sql_con->bindValue(':user_id', $_COOKIE['authId']);
$sql_con->execute();
$sql_rows = $sql_con->fetchaLL(PDO::FETCH_ASSOC);
$userSettings = new stdClass();
foreach($sql_rows as $row){
$userSettings->{$row['data_name']} = $row['data_value'];
}
$userSettings = json_encode($userSettings);
return $userSettings;
}else{
return null;
}
}
public function updateAvatar($avatar, $ext){
global $db_con;
$uid = $_COOKIE['authId'];
$allowedPhotos = array('jpg', 'jpeg', 'png', 'gif');
$name = $this->generateRandomName();
$name = $name . '.' . $ext;
$path = $_SERVER['DOCUMENT_ROOT'] . '/uploads/';
if (in_array($ext, $allowedPhotos)) {
move_uploaded_file($avatar, $path . $name);
}
$stmt = $db_con->prepare('UPDATE users SET avatar = :avatar WHERE id = :id');
$stmt->bindValue(':avatar', $name);
$stmt->bindValue(':id', $uid);
$stmt->execute();
}
public function updateBanner($banner, $ext){
global $db_con;
$uid = $_COOKIE['authId'];
$allowedPhotos = array('jpg', 'jpeg', 'png', 'gif');
$name = $this->generateRandomName();
$name = $name . '.' . $ext;
$path = $_SERVER['DOCUMENT_ROOT'] . '/uploads/';
if (in_array($ext, $allowedPhotos)) {
move_uploaded_file($banner, $path . $name);
}
$stmt = $db_con->prepare('UPDATE users SET banner = :banner WHERE id = :id');
$stmt->bindValue(':banner', $name);
$stmt->bindValue(':id', $uid);
$stmt->execute();
}
public function updateBio($bio){
global $db_con;
$uid = $_COOKIE['authId'];
$stmt = $db_con->prepare('UPDATE users SET bio = :bio WHERE id = :id');
$stmt->bindValue(':bio', $bio);
$stmt->bindValue(':id', $uid);
$stmt->execute();
}
public function generateRandomName($length = 32) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$randomName = '';
$maxIndex = strlen($characters) - 1;
for ($i = 0; $i < $length; $i++) {
$randomName .= $characters[rand(0, $maxIndex)];
}
return $randomName;
}
public function initUser(){
global $db_con;
$id = $_COOKIE['authId'];
$stmt = $db_con->prepare('SELECT * FROM users WHERE id = :id');
$stmt->bindValue(':id', $id);
$stmt->execute();
$defaultUser = $stmt->fetch(PDO::FETCH_ASSOC);
$user = new stdClass();
$user->username = $defaultUser['uname'];
$user->avatar = isset($defaultUser['avatar']) && !empty($defaultUser['avatar']) ? $defaultUser['avatar'] : 'default.png';
$user->banner = isset($defaultUser['banner']) && !empty($defaultUser['banner']) ? $defaultUser['banner'] : 'defaultBG.png';
$user->bio = isset($defaultUser['bio']) && !empty($defaultUser['bio']) ? $defaultUser['bio'] : '';
$user->country = $this->get_data_value('country', $id);
$user->city = $this->get_data_value('city', $id);
$user->gender = $this->get_data_value('gender', $id);
$user->sexuality = $this->get_data_value('sexuality', $id);
$dob = isset($defaultUser['dob']) && !empty($defaultUser['dob']) ? $defaultUser['dob'] : '';
if(isset($dob) && !empty($dob)){
$user->age = $this->calcAge($dob);
}else{
$user->age = '';
}
if(isset($user->username)){
$user->status = "Success";
}
// Get userData:
$sql_con = $db_con->prepare("SELECT u.uname, u.u_email, ud.data_name, ud.data_value
FROM users u
JOIN user_data ud ON u.id = ud.user_id
WHERE ud.user_id = :user_id");
$sql_con->bindValue(':user_id', $_COOKIE['authId']);
$sql_con->execute();
$sql_rows = $sql_con->fetchaLL(PDO::FETCH_ASSOC);
$userData = new stdClass();
foreach($sql_rows as $row){
$userData->{$row['data_name']} = $row['data_value'];
}
$user->userData = $userData;
// Get user images:
$sql_con = $db_con->prepare("SELECT image_name FROM user_gallery WHERE user_id = :user_id");
$sql_con->bindValue(':user_id', $_COOKIE['authId']);
$sql_con->execute();
$sql_rows = $sql_con->fetchaLL(PDO::FETCH_ASSOC);
$userGallery = array();
foreach($sql_rows as $row){
$userGallery[] = $row['image_name'];
}
$user->userGallery = $userGallery;
$user = json_encode($user);
return $user;
}
public function getUser($id){
global $db_con;
$stmt = $db_con->prepare('SELECT * FROM users WHERE id = :id');
$stmt->bindValue(':id', $id);
$stmt->execute();
$defaultUser = $stmt->fetch(PDO::FETCH_ASSOC);
$user = new stdClass();
$user->id = $defaultUser['id'];
$user->username = $defaultUser['uname'];
$user->avatar = isset($defaultUser['avatar']) && !empty($defaultUser['avatar']) ? $defaultUser['avatar'] : 'default.png';
$user->banner = isset($defaultUser['banner']) && !empty($defaultUser['banner']) ? $defaultUser['banner'] : 'defaultBG.png';
$user->bio = isset($defaultUser['bio']) && !empty($defaultUser['bio']) ? $defaultUser['bio'] : '';
$user->country = $this->get_data_value('country', $id);
$user->city = $this->get_data_value('city', $id);
$user->gender = $this->get_data_value('gender', $id);
$user->sexuality = $this->get_data_value('sexuality', $id);
$dob = isset($defaultUser['dob']) && !empty($defaultUser['dob']) ? $defaultUser['dob'] : '0';
if(isset($dob) && !empty($dob)){
$user->age = $this->calcAge($dob);
}else{
$user->age = '';
}
if(isset($user->username)){
$user->status = "Success";
}
// Get userData:
$sql_con = $db_con->prepare("SELECT u.uname, u.u_email, ud.data_name, ud.data_value
FROM users u
JOIN user_data ud ON u.id = ud.user_id
WHERE ud.user_id = :user_id");
$sql_con->bindValue(':user_id', $id);
$sql_con->execute();
$sql_rows = $sql_con->fetchaLL(PDO::FETCH_ASSOC);
$userData = new stdClass();
foreach($sql_rows as $row){
$userData->{$row['data_name']} = $row['data_value'];
}
$user->userData = $userData;
// Get user images:
$sql_con = $db_con->prepare("SELECT image_name FROM user_gallery WHERE user_id = :user_id");
$sql_con->bindValue(':user_id', $id);
$sql_con->execute();
$sql_rows = $sql_con->fetchaLL(PDO::FETCH_ASSOC);
$userGallery = array();
foreach($sql_rows as $row){
$userGallery[] = $row['image_name'];
}
$user->userGallery = $userGallery;
$user = json_encode($user);
return $user;
}
private function get_data_value($name, $id){
global $db_con;
$stmt = $db_con->prepare("SELECT data_value FROM user_data WHERE data_name = :data_name AND user_id = :user_id");
$stmt->bindValue(':data_name', $name);
$stmt->bindValue(':user_id', $id);
$stmt->execute();
$holder = $stmt->fetch(PDO::FETCH_ASSOC);
if(isset($holder['data_value']) && !empty($holder['data_value'])){
$value = $holder['data_value'];
}else{
$value = '';
}
return $value;
}
private function calcAge($dob) {
$dobDate = new DateTime($dob);
$currentDate = new DateTime();
$age = $currentDate->diff($dobDate);
return $age->y;
}
public function uploadGalleryImage($image, $ext){
global $db_con;
$uid = $_COOKIE['authId'];
$allowedPhotos = array('jpg', 'jpeg', 'png', 'gif');
$name = $this->generateRandomName();
$name = $name . '.' . $ext;
$path = $_SERVER['DOCUMENT_ROOT'] . '/uploads/';
if (in_array($ext, $allowedPhotos)) {
move_uploaded_file($image, $path . $name);
}
$stmt = $db_con->prepare('INSERT INTO user_gallery (user_id, image_name) VALUES (:id, :image_name)');
$stmt->bindValue(':image_name', $name);
$stmt->bindValue(':id', $uid);
$stmt->execute();
}
public function deleteImage($image){
global $db_con;
$path = $_SERVER['DOCUMENT_ROOT'] . '/uploads/';
$sql = $db_con->prepare("SELECT * FROM user_gallery WHERE user_id = :user_id AND image_name = :image_name");
$sql->bindValue(':image_name', $image);
$sql->bindValue(':user_id', $_COOKIE['authId']);
$sql->execute();
$nums = $sql->rowCount();
if($nums > 0){
if(file_exists($path . $image)){
unlink($path . $image);
$sql = $db_con->prepare('DELETE FROM user_gallery WHERE user_id = :user_id AND image_name = :image_name');
$sql->bindValue(':image_name', $image);
$sql->bindValue(':user_id', $_COOKIE['authId']);
$sql->execute();
}
}
}
public function receive_messages($user_id){
global $db_con;
$current_user = intval($_COOKIE['authId']);
$message_user = intval($user_id);
// Receive user data
$sql = $db_con->prepare("SELECT uname, avatar FROM users WHERE id = :id");
$sql->bindValue(':id', $current_user);
$sql->execute();
$current_user_data = $sql->fetch(PDO::FETCH_ASSOC);
// Receive messager data
$sql = $db_con->prepare("SELECT uname, avatar FROM users WHERE id = :id");
$sql->bindValue(':id', $message_user);
$sql->execute();
$message_user_data = $sql->fetch(PDO::FETCH_ASSOC);
// Set username and avatar
$cua = $current_user_data['avatar'];
$cuu = $current_user_data['uname'];
$mua = $message_user_data['avatar'];
$muu = $message_user_data['uname'];
// Receive messages
$sql = $db_con->prepare('SELECT *
FROM user_chats
WHERE (sender_id = :current_user AND receiver_id = :message_user)
OR (sender_id = :message_user AND receiver_id = :current_user)
ORDER BY id ASC');
$sql->bindValue(':message_user', $message_user);
$sql->bindValue(':current_user', $current_user);
$sql->execute();
$sql_messages = $sql->fetchAll(PDO::FETCH_ASSOC);
$messages = array();
foreach($sql_messages as $message){
$msg = new stdClass();
if($message['sender_id'] == $current_user){
$msg->uid = $current_user;
$msg->sender = 'me';
$msg->avatar = $cua;
$msg->username = $cuu;
}else{
$msg->uid = $message_user;
$msg->sender = 'other';
$msg->avatar = $mua;
$msg->username = $muu;
}
$msg->content = $message['user_message'];
$messages[] = $msg;
}
$stm = $db_con->prepare("UPDATE user_chats SET readStatus = 0 WHERE receiver_id = :user_id AND sender_id = :sender_id");
$stm->bindValue(':user_id', $current_user);
$stm->bindValue(':sender_id', $message_user);
$stm->execute();
$messages = json_encode($messages);
return $messages;
}
public function sendMessage($user_id, $message){
global $db_con;
$user_id = intval($user_id);
$current_user = $_COOKIE['authId'];
$message = htmlspecialchars($message);
$sql = $db_con->prepare('INSERT INTO user_chats (sender_id, receiver_id, user_message, message_type) VALUES (:sender_id, :receiver_id, :user_message, :message_type)');
$sql->bindValue(':sender_id', $current_user);
$sql->bindValue(':receiver_id', $user_id);
$sql->bindValue(':user_message', $message);
$sql->bindValue(':message_type', 'text');
$sql->execute();
}
public function get_conversations(){
global $db_con;
$user_id = $_COOKIE['authId'];
$sql = $db_con->prepare("SELECT DISTINCT IF(sender_id = :user_id, receiver_id, sender_id) AS chat_partner_id
FROM user_chats
WHERE sender_id = :user_id OR receiver_id = :user_id");
$sql->bindParam(':user_id', $user_id);
$sql->execute();
$chat_partners = $sql->fetchAll(PDO::FETCH_COLUMN);
// $chat_partners = array_diff($chat_partners, [$user_id]);
$conversations = array();
foreach($chat_partners as $chat){
$conversation = new stdClass();
$msg_id = intval($chat);
// Get last message
$sql = $db_con->prepare("SELECT user_message, time_received
FROM user_chats
WHERE (sender_id = :user_id AND receiver_id = :msg_id)
OR (sender_id = :msg_id AND receiver_id = :user_id)
ORDER BY id DESC
LIMIT 1");
$sql->bindValue(':msg_id', $msg_id);
$sql->bindValue(':user_id', $user_id);
$sql->execute();
$_msg = $sql->fetch(PDO::FETCH_ASSOC);
$msg = $_msg['user_message'];
$time_rec = $_msg['time_received'];
$stmt = $db_con->prepare('SELECT uname, avatar FROM users WHERE id = :id');
$stmt->bindValue(':id', $msg_id);
$stmt->execute();
$msg_info = $stmt->fetch(PDO::FETCH_ASSOC);
$conversation->avatar = $msg_info['avatar'];
$conversation->username = $msg_info['uname'];
$conversation->message = $msg;
$conversation->time = $time_rec;
$conversation->user_id = $msg_id;
$conversations[] = $conversation;
}
usort($conversations, function($a, $b) {
return strtotime($b->time) - strtotime($a->time);
});
return json_encode($conversations);
}
public function checkUnread(){
global $db_con;
$id = $_COOKIE['authId'];
$sql = $db_con->prepare('SELECT * FROM user_chats WHERE receiver_id = :user_id AND readStatus = 1');
$sql->bindValue(':user_id', $id);
$sql->execute();
$numRows = $sql->rowCount();
if($numRows > 0){
$status = true;
}else{
$status = false;
}
$response = new stdClass();
$response->status = $status;
$response = json_encode($response);
return $response;
}
public function updatePassword($current_password, $new_password, $confirm_password){
global $db_con;
$id = $_COOKIE['authId'];
$sql = $db_con->prepare("SELECT psw FROM users WHERE id = :id");
$sql->bindValue(':id', $id);
$sql->execute();
$_psw = $sql->fetch(PDO::FETCH_ASSOC);
$psw = $_psw['psw'];
$response = new stdClass();
if(password_verify($current_password, $psw)){
if($new_password == $confirm_password){
$new_psw = password_hash($new_password, PASSWORD_BCRYPT, ["cost" => 12]);
$stmt = $db_con->prepare("UPDATE users SET psw = :psw WHERE id = :id");
$stmt->bindValue(':psw', $new_psw);
$stmt->bindValue(':id', $id);
$stmt->execute();
$response->status = 'success';
}else{
$response->status = 'error';
$response->message = 'Passwords does not match';
}
}else{
$response->status = 'error';
$response->message = 'Incorrect password';
}
$response = json_encode($response);
return $response;
}
public function isPaid(){
global $db_con;
$id = intval($_COOKIE['authId']);
$sql = $db_con->prepare('SELECT u.stripe_cu, st.exp_date FROM users u LEFT JOIN stripe_user_data st ON st.cu_name = u.stripe_cu WHERE u.id = :id');
$sql->bindValue(':id', $id);
$sql->execute();
if($sql->rowCount() > 0){
$date_query = $sql->fetch(PDO::FETCH_ASSOC);
$sub_date = intval($date_query['exp_date']);
$current_date = intval(time());
if($current_date > $sub_date){
return false;
}else{
return true;
}
}else{
return false;
}
}
public function hasPaid(){
global $db_con;
$id = intval($_COOKIE['authId']);
$sql = $db_con->prepare('SELECT u.stripe_cu, st.exp_date FROM users u LEFT JOIN stripe_user_data st ON st.cu_name = u.stripe_cu WHERE u.id = :id');
$sql->bindValue(':id', $id);
$sql->execute();
if($sql->rowCount() > 0){
$date_query = $sql->fetch(PDO::FETCH_ASSOC);
$sub_date = intval($date_query['exp_date']);
$current_date = intval(time());
if($current_date > $sub_date){
return false;
}else{
return true;
}
}else{
return false;
}
}
}
?>