mirror of
https://github.com/Nereziel/cs2-WeaponPaints.git
synced 2026-02-17 18:39:07 +00:00
next
This commit is contained in:
@@ -1,10 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
ini_set('display_startup_errors', 1);
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
// Set security headers to enhance security
|
// Set security headers to enhance security
|
||||||
header("X-Frame-Options: SAMEORIGIN");
|
// header("X-Frame-Options: SAMEORIGIN");
|
||||||
header("X-XSS-Protection: 1; mode=block");
|
// header("X-XSS-Protection: 1; mode=block");
|
||||||
header("X-Content-Type-Options: nosniff");
|
// header("X-Content-Type-Options: nosniff");
|
||||||
header("Referrer-Policy: no-referrer-when-downgrade");
|
// header("Referrer-Policy: no-referrer-when-downgrade");
|
||||||
header("Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net https://code.jquery.com; style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net; img-src 'self' data: https://cdn.jsdelivr.net https://steamcommunity-a.akamaihd.net https://raw.githubusercontent.com;");
|
// header("Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net https://code.jquery.com; style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net; img-src 'self' data: https://cdn.jsdelivr.net https://steamcommunity-a.akamaihd.net https://raw.githubusercontent.com;");
|
||||||
|
|
||||||
|
|
||||||
// Include necessary classes and files
|
// Include necessary classes and files
|
||||||
@@ -29,11 +33,14 @@ if (isset($_SESSION['steamid'])) {
|
|||||||
// Get weapons and skins information
|
// Get weapons and skins information
|
||||||
$weapons = UtilsClass::getWeaponsFromArray();
|
$weapons = UtilsClass::getWeaponsFromArray();
|
||||||
$skins = UtilsClass::skinsFromJson();
|
$skins = UtilsClass::skinsFromJson();
|
||||||
|
$gloves = UtilsClass::glovesFromJson();
|
||||||
|
|
||||||
// Retrieve user's selected skins and knife
|
// Retrieve user's selected skins and knife
|
||||||
$querySelected = $db->select("SELECT `weapon`, `paint`, `wear`, `seed`, `nametag` FROM `wp_users_items` WHERE `user_id` = :user_id", ["user_id" => $userDbIndex]);
|
$querySelected = $db->select("SELECT `weapon`, `paint`, `wear`, `seed`, `nametag` FROM `wp_users_items` WHERE `user_id` = :user_id", ["user_id" => $userDbIndex]);
|
||||||
$selectedSkins = UtilsClass::getSelectedSkins($querySelected);
|
$selectedSkins = UtilsClass::getSelectedSkins($querySelected);
|
||||||
$selectedKnifeResult = $db->select("SELECT `knife` FROM `wp_users_knife` WHERE `user_id` = :user_id", ["user_id" => $userDbIndex]);
|
$selectedKnifeResult = $db->select("SELECT `knife` FROM `wp_users_knife` WHERE `user_id` = :user_id", ["user_id" => $userDbIndex]);
|
||||||
|
$selectedGlovesResult = $db->select("SELECT `weapon_defindex` FROM `wp_users_gloves` WHERE `user_id` = :user_id", ["user_id" => $userDbIndex]);
|
||||||
|
$selectedGloves = !empty($selectedGlovesResult) ? $selectedGlovesResult[0] : $gloves[0][0];
|
||||||
|
|
||||||
// Determine user's selected knife or set default knife
|
// Determine user's selected knife or set default knife
|
||||||
if (!empty($selectedKnifeResult)) {
|
if (!empty($selectedKnifeResult)) {
|
||||||
|
|||||||
@@ -33,7 +33,53 @@ class UtilsClass
|
|||||||
|
|
||||||
return $skins;
|
return $skins;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Retrieve music data from the JSON file.
|
||||||
|
*
|
||||||
|
* @return array An associative array containing music data.
|
||||||
|
*/
|
||||||
|
public static function musicFromJson()
|
||||||
|
{
|
||||||
|
$music = array();
|
||||||
|
$jsonFilePath = __DIR__ . "/../data/music.json";
|
||||||
|
|
||||||
|
if (file_exists($jsonFilePath) && is_readable($jsonFilePath)) {
|
||||||
|
$json = json_decode(file_get_contents($jsonFilePath), true);
|
||||||
|
|
||||||
|
foreach ($json as $track) {
|
||||||
|
$music[$track['id']] = array(
|
||||||
|
'name' => $track['name'],
|
||||||
|
'image' => $track['image'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Handle file not found or unreadable error
|
||||||
|
// You can throw an exception or log an error message
|
||||||
|
}
|
||||||
|
|
||||||
|
return $music;
|
||||||
|
}
|
||||||
|
public static function glovesFromJson()
|
||||||
|
{
|
||||||
|
$gloves = array();
|
||||||
|
$jsonFilePath = __DIR__ . "/../data/gloves.json";
|
||||||
|
|
||||||
|
if (file_exists($jsonFilePath) && is_readable($jsonFilePath)) {
|
||||||
|
$json = json_decode(file_get_contents($jsonFilePath), true);
|
||||||
|
|
||||||
|
foreach ($json as $glove) {
|
||||||
|
$gloves[$glove['weapon_defindex']][$glove['paint']] = array(
|
||||||
|
'paint_name' => $glove['paint_name'],
|
||||||
|
'image_url' => $glove['image'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Handle file not found or unreadable error
|
||||||
|
// You can throw an exception or log an error message
|
||||||
|
}
|
||||||
|
|
||||||
|
return $gloves;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Retrieve weapons data from the skin data array.
|
* Retrieve weapons data from the skin data array.
|
||||||
*
|
*
|
||||||
|
|||||||
54
website/db-sqlite.sql
Normal file
54
website/db-sqlite.sql
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
PRAGMA foreign_keys = ON;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `wp_players` (
|
||||||
|
`user_id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
`steamid` INTEGER NOT NULL,
|
||||||
|
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
`updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
UNIQUE(`steamid`)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `wp_player_skins` (
|
||||||
|
`user_id` INTEGER NOT NULL,
|
||||||
|
`team` INTEGER NOT NULL,
|
||||||
|
`weapon_defindex` INTEGER NOT NULL,
|
||||||
|
`paint` INTEGER NOT NULL,
|
||||||
|
`wear` REAL NOT NULL DEFAULT 0.001,
|
||||||
|
`seed` INTEGER NOT NULL DEFAULT 0,
|
||||||
|
`nametag` TEXT DEFAULT NULL,
|
||||||
|
`stattrack` INTEGER NOT NULL DEFAULT 0,
|
||||||
|
`stattrack_enabled` INTEGER NOT NULL DEFAULT 0,
|
||||||
|
`quality` INTEGER NOT NULL DEFAULT 0,
|
||||||
|
PRIMARY KEY (`user_id`,`team`,`weapon_defindex`),
|
||||||
|
FOREIGN KEY (`user_id`) REFERENCES `wp_players`(`user_id`) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `wp_players_knife` (
|
||||||
|
`user_id` INTEGER NOT NULL,
|
||||||
|
`knife` TEXT DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`user_id`),
|
||||||
|
FOREIGN KEY (`user_id`) REFERENCES `wp_players`(`user_id`) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `wp_players_gloves` (
|
||||||
|
`user_id` INTEGER NOT NULL,
|
||||||
|
`weapon_defindex` INTEGER DEFAULT NULL,
|
||||||
|
`team` INTEGER DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`user_id`,`team`),
|
||||||
|
FOREIGN KEY (`user_id`) REFERENCES `wp_players`(`user_id`) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `wp_players_music` (
|
||||||
|
`user_id` INTEGER NOT NULL,
|
||||||
|
`music` INTEGER DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`user_id`),
|
||||||
|
FOREIGN KEY (`user_id`) REFERENCES `wp_players`(`user_id`) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `wp_players_agents` (
|
||||||
|
`user_id` INTEGER NOT NULL,
|
||||||
|
`agent_ct` TEXT DEFAULT NULL,
|
||||||
|
`agent_t` TEXT DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`user_id`),
|
||||||
|
FOREIGN KEY (`user_id`) REFERENCES `wp_players`(`user_id`) ON DELETE CASCADE
|
||||||
|
);
|
||||||
53
website/db.sql
Normal file
53
website/db.sql
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS `wp_players` (
|
||||||
|
`user_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||||
|
`steamid` BIGINT UNSIGNED NOT NULL,
|
||||||
|
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
`updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
PRIMARY KEY (`user_id`),
|
||||||
|
UNIQUE KEY `unique_steamid` (`steamid`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `wp_player_skins` (
|
||||||
|
`user_id` INT UNSIGNED NOT NULL,
|
||||||
|
`team` SMALLINT UNSIGNED NOT NULL,
|
||||||
|
`weapon_defindex` SMALLINT UNSIGNED NOT NULL,
|
||||||
|
`paint` SMALLINT UNSIGNED NOT NULL,
|
||||||
|
`wear` FLOAT NOT NULL DEFAULT 0.001,
|
||||||
|
`seed` SMALLINT UNSIGNED NOT NULL DEFAULT 0,
|
||||||
|
`nametag` VARCHAR(20) DEFAULT NULL,
|
||||||
|
`stattrack` INT UNSIGNED NOT NULL DEFAULT 0,
|
||||||
|
`stattrack_enabled` SMALLINT NOT NULL DEFAULT 0,
|
||||||
|
`quality` SMALLINT UNSIGNED NOT NULL DEFAULT 0,
|
||||||
|
PRIMARY KEY (`user_id`,`team`,`weapon_defindex`),
|
||||||
|
FOREIGN KEY (`user_id`) REFERENCES `wp_players`(`user_id`) ON DELETE CASCADE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `wp_players_knife` (
|
||||||
|
`user_id` INT UNSIGNED NOT NULL,
|
||||||
|
`knife` VARCHAR(32) DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`user_id`),
|
||||||
|
FOREIGN KEY (`user_id`) REFERENCES `wp_players`(`user_id`) ON DELETE CASCADE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `wp_players_gloves` (
|
||||||
|
`user_id` INT UNSIGNED NOT NULL,
|
||||||
|
`weapon_defindex` SMALLINT UNSIGNED DEFAULT NULL,
|
||||||
|
`team` SMALLINT UNSIGNED DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`user_id`,`team`),
|
||||||
|
FOREIGN KEY (`user_id`) REFERENCES `wp_players`(`user_id`) ON DELETE CASCADE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `wp_players_music` (
|
||||||
|
`user_id` INT UNSIGNED NOT NULL,
|
||||||
|
`music` SMALLINT UNSIGNED DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`user_id`),
|
||||||
|
FOREIGN KEY (`user_id`) REFERENCES `wp_players`(`user_id`) ON DELETE CASCADE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `wp_players_agents` (
|
||||||
|
`user_id` INT UNSIGNED NOT NULL,
|
||||||
|
`agent_ct` varchar(64) DEFAULT NULL,
|
||||||
|
`agent_t` varchar(64) DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`user_id`),
|
||||||
|
FOREIGN KEY (`user_id`) REFERENCES `wp_players`(`user_id`) ON DELETE CASCADE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||||
@@ -20,8 +20,11 @@ require 'class/header.php';
|
|||||||
<div class='card-group mt-2'>
|
<div class='card-group mt-2'>
|
||||||
<!-- Display user's selected knife -->
|
<!-- Display user's selected knife -->
|
||||||
<?php require_once 'view/display_knife.php'; ?>
|
<?php require_once 'view/display_knife.php'; ?>
|
||||||
|
<!-- Display user's selected gloves -->
|
||||||
|
<?php require_once 'view/display_gloves.php'; ?>
|
||||||
<!-- Display user's selected skins for different weapons -->
|
<!-- Display user's selected skins for different weapons -->
|
||||||
<?php require_once 'view/display_weapons.php'; ?>
|
<?php require_once 'view/display_weapons.php'; ?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<!-- Footer section -->
|
<!-- Footer section -->
|
||||||
|
|||||||
@@ -3,40 +3,69 @@
|
|||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<?php
|
<?php
|
||||||
// Determine the user's selected knife
|
// Determine the user's selected knife
|
||||||
$actualGloves = $gloves[0];
|
$actualGloves = $selectedGloves;
|
||||||
if ($selectedGloves != null) {
|
/*if ($selectedGloves != null) {
|
||||||
foreach ($gloves as $glove) {
|
foreach ($gloves as $glove) {
|
||||||
if ($selectedGloves == $glove['weapon_defindex']) {
|
if ($selectedGloves == $glove['weapon_defindex']) {
|
||||||
$actualGloves = $glove;
|
$actualGloves = $glove;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
// Display user's selected knife information
|
// Display user's selected knife information
|
||||||
echo "<div class='card-header'>";
|
echo "<div class='card-header'>";
|
||||||
echo "<h6 class='card-title item-name'>Knife type</h6>";
|
|
||||||
echo "<h5 class='card-title item-name'>{$actualGloves["paint_name"]}</h5>";
|
echo "<h5 class='card-title item-name'>{$actualGloves["paint_name"]}</h5>";
|
||||||
echo "</div>";
|
echo "</div>";
|
||||||
echo "<img src='{$actualGloves["image_url"]}' class='skin-image'>";
|
echo "<img id='glove-image' src='{$actualGloves["image_url"]}' class='skin-image'>";
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-footer">
|
<div class="card-footer">
|
||||||
<!-- Form for selecting user's knife -->
|
<div class="form-group">
|
||||||
<form action="" method="POST">
|
<label for="glovesSelect">Select Gloves:</label>
|
||||||
<select name="forma" class="form-control select" onchange="this.form.submit()" class="SelectWeapon">
|
<select id="glovesSelect" class="form-control" onchange="updateGlovePaints(this.value)">
|
||||||
<option disabled>Select knife</option>
|
<option disabled selected>Select Gloves</option>
|
||||||
<?php
|
<?php
|
||||||
// Display options for selecting different knives
|
foreach ($gloves as $weapon_defindex => $glove) {
|
||||||
foreach ($gloves as $gloveKey => $glove) {
|
echo "<option value=\"{$weapon_defindex}\">{$weapon_defindex}</option>";
|
||||||
if ($selectedGlove == $glove['weapon_defindex'])
|
|
||||||
echo "<option selected value=\"knife-{$gloveKey}\">{$glove['paint_name']}</option>";
|
|
||||||
else
|
|
||||||
echo "<option value=\"knife-{$gloveKey}\">{$glove['paint_name']}</option>";
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
</form>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="paintSelect">Select Paint:</label>
|
||||||
|
<select id="paintSelect" class="form-control" onchange="updateGloveImage(this)" >
|
||||||
|
<option disabled selected>Select Paint</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var gloves = <?php echo json_encode($gloves); ?>;
|
||||||
|
|
||||||
|
function updateGlovePaints(weapon_defindex) {
|
||||||
|
var paintSelect = document.getElementById('paintSelect');
|
||||||
|
paintSelect.innerHTML = ""; // Clear the select options
|
||||||
|
|
||||||
|
for (var defindex in gloves) {
|
||||||
|
if (defindex == weapon_defindex) {
|
||||||
|
for (var paint in gloves[defindex]) {
|
||||||
|
var option = document.createElement('option');
|
||||||
|
option.value = paint;
|
||||||
|
option.text = gloves[defindex][paint].paint_name;
|
||||||
|
paintSelect.appendChild(option);
|
||||||
|
document.getElementById('glove-image').src = gloves[defindex][paint].image_url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function updateGloveImage(select) {
|
||||||
|
// here it will update glove-image with the selected paint from updateGlovePaints
|
||||||
|
var weapon_defindex = document.getElementById('glovesSelect').value;
|
||||||
|
var paint = select.value;
|
||||||
|
document.getElementById('glove-image').src = gloves[weapon_defindex][paint].image_url;
|
||||||
|
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user