init
This commit is contained in:
commit
a31a8e7fdd
17
add_feedback.php
Normal file
17
add_feedback.php
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
include('connection.php');
|
||||
$conn = OpenCon();
|
||||
|
||||
$address = $_GET['email'];
|
||||
$subject = $_GET['subject'];
|
||||
$message = $_GET['message'];
|
||||
|
||||
$sql = "INSERT INTO Feedbacks (email, subject, message) VALUES ('$address', '$subject', '$message')";
|
||||
|
||||
if(mysqli_query($conn, $sql)){
|
||||
echo "1";
|
||||
}else{
|
||||
echo "0";
|
||||
}
|
||||
?>
|
||||
24
add_game_history.php
Normal file
24
add_game_history.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
include('connection.php');
|
||||
$conn = OpenCon();
|
||||
|
||||
$address= $_GET['address'];
|
||||
$game = $_GET['game'];
|
||||
$master_score = $_GET['master_score'];
|
||||
$client_score = $_GET['client_score'];
|
||||
$winner = $_GET['winner'];
|
||||
$wager = $_GET['wager'];
|
||||
$master_id = $_GET['master_id'];
|
||||
$client_id = $_GET['client_id'];
|
||||
$reward_tx = $_GET['reward_tx'];
|
||||
|
||||
$insertSql = "INSERT INTO Game_History (address,game, master_score, client_score, winner, wager, master_id, client_id, reward_tx) VALUES('$address', '$game', $master_score, $client_score, '$winner', $wager, '$master_id', '$client_id','$reward_tx')";
|
||||
if(mysqli_query($conn,$insertSql)){
|
||||
echo "0";
|
||||
}else{
|
||||
echo "-1";
|
||||
}
|
||||
|
||||
CloseCon($conn);
|
||||
?>
|
||||
38
connection.php
Normal file
38
connection.php
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
$ref_bonus = 100;
|
||||
$review_bonus= 300;
|
||||
|
||||
function OpenCon()
|
||||
|
||||
{
|
||||
|
||||
$dbhost = "localhost";
|
||||
|
||||
$dbuser = "duelfi";
|
||||
|
||||
$dbpass = "HelloWorld@123";
|
||||
|
||||
$db = "duelfi";
|
||||
|
||||
$conn = new mysqli($dbhost, $dbuser, $dbpass,$db) or die("Connect failed: %s\n". $conn -> error);
|
||||
|
||||
|
||||
|
||||
return $conn;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function CloseCon($conn)
|
||||
|
||||
{
|
||||
|
||||
$conn -> close();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
19
get_game_completed.php
Normal file
19
get_game_completed.php
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
include('connection.php');
|
||||
$conn = OpenCon();
|
||||
|
||||
$address = $_GET['address'];
|
||||
|
||||
$sql = "SELECT * FROM Game_History WHERE address = '$address'";
|
||||
$result = mysqli_query($conn, $sql);
|
||||
|
||||
if(mysqli_num_rows($result) > 0){
|
||||
echo "1";
|
||||
}else{
|
||||
echo "0";
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
19
get_game_history.php
Normal file
19
get_game_history.php
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
include('connection.php');
|
||||
$conn = OpenCon();
|
||||
|
||||
$username= $_GET['uid'];
|
||||
|
||||
$selectSql = "SELECT * FROM Game_History WHERE master_id='$username' OR client_id='$username'";
|
||||
$selectQuery = mysqli_query($conn, $selectSql);
|
||||
|
||||
$arr = [];
|
||||
while($row = mysqli_fetch_assoc($selectQuery)){
|
||||
array_push($arr, $row);
|
||||
}
|
||||
|
||||
echo json_encode($arr);
|
||||
|
||||
|
||||
?>
|
||||
19
get_rematch_address.php
Normal file
19
get_rematch_address.php
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
include('connection.php');
|
||||
$conn = OpenCon();
|
||||
|
||||
$address = $_GET['address'];
|
||||
|
||||
$selectSql = "SELECT rematch_address FROM Game_History WHERE address='$address'";
|
||||
$selectQuery = mysqli_query($conn, $selectSql) or die("no record found");
|
||||
|
||||
if(mysqli_num_rows($selectQuery) > 0){
|
||||
echo mysqli_fetch_assoc($selectQuery)['rematch_address'];
|
||||
}else{
|
||||
echo "0";
|
||||
}
|
||||
|
||||
CloseCon($conn);
|
||||
|
||||
?>
|
||||
16
get_user_by_id.php
Normal file
16
get_user_by_id.php
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
include('connection.php');
|
||||
include('data_grabber.php');
|
||||
|
||||
$id = $_GET['id'];
|
||||
|
||||
$conn = OpenCon();
|
||||
|
||||
$selectSql = "SELECT * FROM Users WHERE id='$id'";
|
||||
$selectQuery = mysqli_query($conn, $selectSql);
|
||||
if(mysqli_num_rows($selectQuery) > 0){
|
||||
echo json_encode(mysqli_fetch_assoc($selectQuery));
|
||||
}else{
|
||||
echo "0";
|
||||
}
|
||||
?>
|
||||
17
get_user_by_username.php
Normal file
17
get_user_by_username.php
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
include('connection.php');
|
||||
include('data_grabber.php');
|
||||
|
||||
$username = $_GET['username'];
|
||||
|
||||
$conn = OpenCon();
|
||||
|
||||
$selectSql = "SELECT * FROM Users WHERE username='$username'";
|
||||
$selectQuery = mysqli_query($conn, $selectSql);
|
||||
|
||||
if(mysqli_num_rows($selectQuery) > 0){
|
||||
echo json_encode(mysqli_fetch_assoc($selectQuery));
|
||||
}else{
|
||||
echo "0";
|
||||
}
|
||||
?>
|
||||
24
register.php
Normal file
24
register.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
include('connection.php');
|
||||
|
||||
$id = $_GET['id'];
|
||||
$username = $_GET['username'];
|
||||
|
||||
$conn = OpenCon();
|
||||
|
||||
$namecheckquery = "SELECT * FROM Users WHERE id='$id'";
|
||||
$nameCheck = mysqli_query($conn, $namecheckquery) or die("namecheck failed");
|
||||
|
||||
if(mysqli_num_rows($nameCheck) > 0){
|
||||
echo "5. Failed! id exists";
|
||||
die();
|
||||
}
|
||||
|
||||
|
||||
$insertQuery = "INSERT INTO Users (id, username) VALUES ('$id','$username');";
|
||||
if(mysqli_query($conn, $insertQuery)){
|
||||
echo "0";
|
||||
}else{
|
||||
echo "1. Error creating new player";
|
||||
}
|
||||
?>
|
||||
23
set_rematch_address.php
Normal file
23
set_rematch_address.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
include('connection.php');
|
||||
$conn = OpenCon();
|
||||
|
||||
$address= $_GET['address'];
|
||||
$rematch_address =$_GET['rematch_address'];
|
||||
|
||||
$namecheckSql = "SELECT * FROM Game_History WHERE address='$address'";
|
||||
$namecheckQuery = mysqli_query($conn, $namecheckSql) or die('namecheck failed');
|
||||
|
||||
$updateSql = "UPDATE Game_History SET rematch_address='$rematch_address' WHERE address='$address'";
|
||||
// die($updateSql);
|
||||
if(mysqli_query($conn, $updateSql)){
|
||||
echo "0";
|
||||
}else{
|
||||
echo "-1";
|
||||
}
|
||||
|
||||
CloseCon($conn);
|
||||
|
||||
|
||||
?>
|
||||
21
update_profile.php
Normal file
21
update_profile.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
include('connection.php');
|
||||
|
||||
$conn = OpenCon();
|
||||
|
||||
$id=$_GET['id'];
|
||||
$username = $_GET['username'];
|
||||
$bio = $_GET['bio'];
|
||||
|
||||
$namecheckquery = "SELECT * FROM Users WHERE id='$id'";
|
||||
$nameCheck = mysqli_query($conn, $namecheckquery) or die("namecheck failed");
|
||||
|
||||
$updateSql = "UPDATE Users SET username='$username', bio='$bio' WHERE id='$id'";
|
||||
if(mysqli_query($conn,$updateSql)){
|
||||
echo "0";
|
||||
}else{
|
||||
echo "-1";
|
||||
}
|
||||
|
||||
?>
|
||||
21
update_x_pic_url.php
Normal file
21
update_x_pic_url.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
include('connection.php');
|
||||
|
||||
$conn = OpenCon();
|
||||
|
||||
$id=$_GET['id'];
|
||||
$url = $_GET['url'];
|
||||
|
||||
|
||||
$namecheckquery = "SELECT * FROM Users WHERE id='$id'";
|
||||
$nameCheck = mysqli_query($conn, $namecheckquery) or die("namecheck failed");
|
||||
|
||||
$updateSql = "UPDATE Users SET x_profile_url='$url' WHERE id='$id'";
|
||||
if(mysqli_query($conn,$updateSql)){
|
||||
echo "0";
|
||||
}else{
|
||||
echo "-1";
|
||||
}
|
||||
|
||||
?>
|
||||
44
upload_profile_picture.php
Normal file
44
upload_profile_picture.php
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
// upload_profile_picture.php
|
||||
|
||||
// Set temporary directory for file uploads if not already set
|
||||
ini_set('upload_tmp_dir', '/var/www/html/duelfi/tmp');
|
||||
|
||||
// Check if file is uploaded and privy_id is provided
|
||||
if ($_FILES['file']['error'] == UPLOAD_ERR_OK && isset($_POST['privy_id'])) {
|
||||
$privy_id = $_POST['privy_id']; // Retrieve privy_id from POST request
|
||||
$uploadDir = '/var/www/html/duelfi/profile_pics/'; // Directory to store the profile pictures
|
||||
$fileExtension = strtolower(pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION));
|
||||
|
||||
// Ensure the uploaded file is a valid image type (JPG, JPEG, PNG)
|
||||
if (!in_array($fileExtension, ['jpg', 'jpeg', 'png'])) {
|
||||
echo json_encode(['success' => false, 'message' => 'Invalid file type']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Define the target file path using privy_id
|
||||
$uploadFile = $uploadDir . $privy_id . '.jpg'; // File will be saved as {privy_id}.jpg
|
||||
|
||||
// Ensure the directory exists and has proper permissions
|
||||
if (!is_dir($uploadDir)) {
|
||||
mkdir($uploadDir, 0755, true); // Create directory if it doesn't exist
|
||||
}
|
||||
|
||||
// Check if the file already exists and remove it before uploading the new file
|
||||
if (file_exists($uploadFile)) {
|
||||
unlink($uploadFile); // Delete the existing file
|
||||
}
|
||||
|
||||
// Move the uploaded file to the target directory
|
||||
if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadFile)) {
|
||||
// The image URL for the uploaded file (publicly accessible)
|
||||
$imageUrl = 'https://vps.playpoolstudios.com/duelfi/profile_pics/' . $privy_id . '.jpg';
|
||||
echo json_encode(['success' => true, 'imageUrl' => $imageUrl]);
|
||||
} else {
|
||||
echo json_encode(['success' => false, 'message' => 'Failed to move uploaded file']);
|
||||
}
|
||||
} else {
|
||||
// Handle cases where no file is uploaded or privy_id is missing
|
||||
echo json_encode(['success' => false, 'message' => 'No file uploaded or missing privy_id']);
|
||||
}
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user