mirror of
https://github.com/Vlad-BloodMoon/opensim-currency-Transactions.git
synced 2026-08-14 00:57:48 +00:00
Add files via upload
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
// Configuration de la base de données
|
||||
$host = "localhost";
|
||||
$dbname = "currency";
|
||||
$username = "userDBname";
|
||||
$password = "passwordDBname";
|
||||
|
||||
try {
|
||||
$pdo = new PDO("mysql:host=$host;dbname=$dbname;charset=utf8", $username, $password);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
} catch (PDOException $e) {
|
||||
die("Erreur de connexion : " . $e->getMessage());
|
||||
}
|
||||
|
||||
// Informations d'utilisateur pour l'authentification sur transactions global
|
||||
$auth_users = array(
|
||||
"user" => "password"
|
||||
);
|
||||
?>
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
include('config_db.php'); // Connexion centralisée
|
||||
|
||||
$offset = isset($_GET['offset']) ? (int)$_GET['offset'] : 0;
|
||||
$limit = isset($_GET['limit']) ? (int)$_GET['limit'] : 50;
|
||||
|
||||
// Vérification de la connexion
|
||||
if (!$pdo) {
|
||||
die(json_encode(["error" => "Database connection failed."]));
|
||||
}
|
||||
|
||||
// Requête SQL modifiée pour récupérer les noms d'avatar et le serveur
|
||||
$stmt = $pdo->prepare("
|
||||
SELECT
|
||||
t.UUID,
|
||||
COALESCE(u1.avatar, t.sender) AS sender_name,
|
||||
COALESCE(u2.avatar, t.receiver) AS receiver_name,
|
||||
t.amount,
|
||||
t.senderBalance,
|
||||
t.receiverBalance,
|
||||
t.objectName,
|
||||
t.description,
|
||||
t.time,
|
||||
u1.serverurl AS sender_server,
|
||||
u2.serverurl AS receiver_server
|
||||
FROM transactions t
|
||||
LEFT JOIN userinfo u1 ON t.sender = u1.user
|
||||
LEFT JOIN userinfo u2 ON t.receiver = u2.user
|
||||
ORDER BY t.time DESC
|
||||
LIMIT :limit OFFSET :offset
|
||||
");
|
||||
|
||||
$stmt->bindValue(':limit', $limit, PDO::PARAM_INT);
|
||||
$stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
$transactions = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Extraction du nom du serveur depuis serverurl
|
||||
foreach ($transactions as &$transaction) {
|
||||
$transaction['sender_server'] = parse_url($transaction['sender_server'], PHP_URL_HOST) ?? "Local Grid";
|
||||
$transaction['receiver_server'] = parse_url($transaction['receiver_server'], PHP_URL_HOST) ?? "Local Grid";
|
||||
}
|
||||
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($transactions);
|
||||
?>
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
include('config_db.php');
|
||||
|
||||
$uuid = isset($_GET['uuid']) ? $_GET['uuid'] : null;
|
||||
$offset = isset($_GET['offset']) ? (int)$_GET['offset'] : 0;
|
||||
$limit = isset($_GET['limit']) ? (int)$_GET['limit'] : 50;
|
||||
|
||||
if (!$uuid) {
|
||||
die(json_encode(["error" => "Missing user UUID."]));
|
||||
}
|
||||
|
||||
$stmt = $pdo->prepare("
|
||||
SELECT
|
||||
t.UUID,
|
||||
COALESCE(u1.avatar, t.sender) AS sender_name,
|
||||
COALESCE(u2.avatar, t.receiver) AS receiver_name,
|
||||
t.amount,
|
||||
CASE
|
||||
WHEN t.sender = :uuid THEN t.senderBalance
|
||||
ELSE NULL
|
||||
END AS senderBalance,
|
||||
CASE
|
||||
WHEN t.receiver = :uuid THEN t.receiverBalance
|
||||
ELSE NULL
|
||||
END AS receiverBalance,
|
||||
t.objectName,
|
||||
t.description,
|
||||
t.time,
|
||||
u1.serverurl AS sender_server,
|
||||
u2.serverurl AS receiver_server
|
||||
FROM transactions t
|
||||
LEFT JOIN userinfo u1 ON t.sender = u1.user
|
||||
LEFT JOIN userinfo u2 ON t.receiver = u2.user
|
||||
WHERE (t.sender = :uuid OR t.receiver = :uuid)
|
||||
AND NOT (t.amount = 0 AND t.description LIKE 'Asset upload%')
|
||||
ORDER BY t.time DESC
|
||||
LIMIT :limit OFFSET :offset
|
||||
");
|
||||
|
||||
$stmt->bindValue(':uuid', $uuid);
|
||||
$stmt->bindValue(':limit', $limit, PDO::PARAM_INT);
|
||||
$stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
|
||||
$transactions = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
foreach ($transactions as &$transaction) {
|
||||
$transaction['sender_server'] = parse_url($transaction['sender_server'], PHP_URL_HOST) ?? "Local Grid";
|
||||
$transaction['receiver_server'] = parse_url($transaction['receiver_server'], PHP_URL_HOST) ?? "Local Grid";
|
||||
}
|
||||
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($transactions);
|
||||
?>
|
||||
@@ -0,0 +1,20 @@
|
||||
//Auteur: Vlad Helsing of BloodMoon GRID
|
||||
//V1 version du 21 mars 2025
|
||||
// Script LSL : place this in a clickable object in-world
|
||||
|
||||
string WEB_URL = "https://bloodmoonpack.com/transactions/transactions_user.php"; // Change this to the location of the transactions.php file on your web server
|
||||
|
||||
default
|
||||
{
|
||||
state_entry()
|
||||
{
|
||||
llSetText("Click to view your BM$ transactions", <0.5, 1.0, 0.5>, 1.0); // Change to your currency
|
||||
}
|
||||
|
||||
touch_start(integer total_number)
|
||||
{
|
||||
key avatar = llDetectedKey(0);
|
||||
string url = WEB_URL + "?uuid=" + (string)avatar;
|
||||
llLoadURL(avatar, "View your transaction history", url);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
<?php
|
||||
include('config_db.php'); // Centralized database connection
|
||||
|
||||
session_start();
|
||||
|
||||
// Vérifier si l'utilisateur est déjà authentifié
|
||||
if (!isset($_SESSION['authenticated'])) {
|
||||
// Vérifier les informations d'identification
|
||||
if (isset($_POST['username']) && isset($_POST['password'])) {
|
||||
$username = $_POST['username'];
|
||||
$password = $_POST['password'];
|
||||
|
||||
if (isset($auth_users[$username]) && $auth_users[$username] == $password) {
|
||||
$_SESSION['authenticated'] = true;
|
||||
} else {
|
||||
$error = "Nom d'utilisateur ou mot de passe incorrect.";
|
||||
}
|
||||
}
|
||||
|
||||
// Si l'utilisateur n'est pas authentifié, afficher le formulaire de connexion
|
||||
if (!isset($_SESSION['authenticated'])) {
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Connexion</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Connexion</h2>
|
||||
<?php if (isset($error)) { echo "<p style='color:red;'>$error</p>"; } ?>
|
||||
<form method="post">
|
||||
<label for="username">USER :</label>
|
||||
<input type="text" id="username" name="username" required>
|
||||
<br>
|
||||
<label for="password">PASSWORD :</label>
|
||||
<input type="password" id="password" name="password" required>
|
||||
<br>
|
||||
<input type="submit" value="Se connecter">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// Default number of transactions displayed (configurable)
|
||||
$transactions_per_page = 50;
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Transactions History</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
margin: 20px;
|
||||
}
|
||||
h1 {
|
||||
text-align: center;
|
||||
}
|
||||
#transactions-container {
|
||||
height: 700px;
|
||||
overflow-y: auto;
|
||||
border: 1px solid #ccc;
|
||||
padding: 10px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
th, td {
|
||||
border: 1px solid black;
|
||||
padding: 8px;
|
||||
text-align: left;
|
||||
}
|
||||
th {
|
||||
background-color: #f2f2f2;
|
||||
}
|
||||
.avatar-info {
|
||||
font-weight: bold;
|
||||
}
|
||||
.server-info {
|
||||
font-size: 0.9em;
|
||||
color: gray;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>Transactions History</h1>
|
||||
<div id="transactions-container">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Transaction UUID</th>
|
||||
<th>Sender</th>
|
||||
<th>Receiver</th>
|
||||
<th>Amount</th>
|
||||
<th>Sender Balance</th>
|
||||
<th>Receiver Balance</th>
|
||||
<th>Object</th>
|
||||
<th>Description</th>
|
||||
<th>Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="transactions-body">
|
||||
<!-- Transactions will be dynamically loaded here -->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let offset = 0;
|
||||
const limit = <?= $transactions_per_page ?>;
|
||||
let loading = false;
|
||||
|
||||
function loadTransactions() {
|
||||
if (loading) return;
|
||||
loading = true;
|
||||
|
||||
fetch(`load_transactions.php?offset=${offset}&limit=${limit}`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.error) {
|
||||
console.error("Error:", data.error);
|
||||
loading = false;
|
||||
return;
|
||||
}
|
||||
|
||||
let tableBody = document.getElementById("transactions-body");
|
||||
data.forEach(transaction => {
|
||||
let row = document.createElement("tr");
|
||||
row.innerHTML = `
|
||||
<td>${transaction.UUID}</td>
|
||||
<td>
|
||||
<span class="avatar-info">${transaction.sender_name || "Unknown"}</span><br>
|
||||
<span class="server-info">${transaction.sender_server}</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="avatar-info">${transaction.receiver_name || "Unknown"}</span><br>
|
||||
<span class="server-info">${transaction.receiver_server}</span>
|
||||
</td>
|
||||
<td>${transaction.amount} BM$</td>
|
||||
<td>${transaction.senderBalance}</td>
|
||||
<td>${transaction.receiverBalance}</td>
|
||||
<td>${transaction.objectName || "N/A"}</td>
|
||||
<td>${transaction.description || "No description"}</td>
|
||||
<td>${new Date(transaction.time * 1000).toLocaleString()}</td>
|
||||
`;
|
||||
tableBody.appendChild(row);
|
||||
});
|
||||
offset += limit;
|
||||
loading = false;
|
||||
})
|
||||
.catch(error => console.error("Error loading transactions:", error));
|
||||
}
|
||||
|
||||
document.getElementById("transactions-container").addEventListener("scroll", function() {
|
||||
if (this.scrollTop + this.clientHeight >= this.scrollHeight - 10) {
|
||||
loadTransactions();
|
||||
}
|
||||
});
|
||||
|
||||
// Load initial transactions on page load
|
||||
loadTransactions();
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
include('config_db.php');
|
||||
|
||||
$transactions_per_page = 50;
|
||||
$uuid = isset($_GET['uuid']) ? $_GET['uuid'] : null;
|
||||
if (!$uuid) {
|
||||
die("Missing user UUID.");
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Your Transactions</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
margin: 20px;
|
||||
}
|
||||
h1 {
|
||||
text-align: center;
|
||||
}
|
||||
#transactions-container {
|
||||
height: 700px;
|
||||
overflow-y: auto;
|
||||
border: 1px solid #ccc;
|
||||
padding: 10px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
th, td {
|
||||
border: 1px solid black;
|
||||
padding: 8px;
|
||||
text-align: left;
|
||||
}
|
||||
th {
|
||||
background-color: #f2f2f2;
|
||||
}
|
||||
.avatar-info {
|
||||
font-weight: bold;
|
||||
}
|
||||
.server-info {
|
||||
font-size: 0.9em;
|
||||
color: gray;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>Your Transactions</h1>
|
||||
<div id="transactions-container">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Transaction UUID</th>
|
||||
<th>Sender</th>
|
||||
<th>Receiver</th>
|
||||
<th>Amount</th>
|
||||
<th id="sender-balance-header">Sender Balance</th>
|
||||
<th id="receiver-balance-header">Receiver Balance</th>
|
||||
<th>Object</th>
|
||||
<th>Description</th>
|
||||
<th>Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="transactions-body"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let offset = 0;
|
||||
const limit = <?= $transactions_per_page ?>;
|
||||
let loading = false;
|
||||
const uuid = "<?= $uuid ?>";
|
||||
|
||||
function loadTransactions() {
|
||||
if (loading) return;
|
||||
loading = true;
|
||||
|
||||
fetch(`load_transactions_user.php?uuid=${uuid}&offset=${offset}&limit=${limit}`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.error) {
|
||||
console.error("Error:", data.error);
|
||||
loading = false;
|
||||
return;
|
||||
}
|
||||
|
||||
let tableBody = document.getElementById("transactions-body");
|
||||
data.forEach(transaction => {
|
||||
let senderBalance = transaction.senderBalance !== null ? transaction.senderBalance : "N/A";
|
||||
let receiverBalance = transaction.receiverBalance !== null ? transaction.receiverBalance : "N/A";
|
||||
|
||||
let row = document.createElement("tr");
|
||||
row.innerHTML = `
|
||||
<td>${transaction.UUID}</td>
|
||||
<td>
|
||||
<span class="avatar-info">${transaction.sender_name || "Unknown"}</span><br>
|
||||
<span class="server-info">${transaction.sender_server}</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="avatar-info">${transaction.receiver_name || "Unknown"}</span><br>
|
||||
<span class="server-info">${transaction.receiver_server}</span>
|
||||
</td>
|
||||
<td>${transaction.amount} BM$</td>
|
||||
<td>${senderBalance}</td>
|
||||
<td>${receiverBalance}</td>
|
||||
<td>${transaction.objectName || "N/A"}</td>
|
||||
<td>${transaction.description || "No description"}</td>
|
||||
<td>${new Date(transaction.time * 1000).toLocaleString()}</td>
|
||||
`;
|
||||
tableBody.appendChild(row);
|
||||
});
|
||||
|
||||
offset += limit;
|
||||
loading = false;
|
||||
})
|
||||
.catch(error => console.error("Error loading transactions:", error));
|
||||
}
|
||||
|
||||
document.getElementById("transactions-container").addEventListener("scroll", function () {
|
||||
if (this.scrollTop + this.clientHeight >= this.scrollHeight - 10) {
|
||||
loadTransactions();
|
||||
}
|
||||
});
|
||||
|
||||
loadTransactions();
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user