403Webshell
Server IP : 104.21.21.239  /  Your IP : 216.73.217.99
Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.5
System : Linux ip-172-31-69-123.ec2.internal 6.1.176-223.369.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jul 24 13:34:27 UTC 2026 x86_64
User : ec2-user ( 1000)
PHP Version : 8.4.23
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/banners/public_html/leia/popcorn/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/banners/public_html/leia/popcorn/api.php
<?php
require_once(__DIR__ . '/../.credentials.php');
require_once '/home/banners/public_html/bway/db/mysql_bootstrap.php';
header('Content-Type: application/json');

$action = $_POST['action'] ?? $_GET['action'] ?? '';
$response = [];
$statusCode = 200;

try {
    switch ($action) {

        // SAVE SCORE
        case 'saveScore':
            $pName = substr(trim($_POST['player_name'] ?? 'Leia'), 0, 20);
            if (strlen($pName) === 0) $pName = 'Leia';
            $playerCookie = $_POST['player_cookie'] ?? '';
            $difficulty = $_POST['difficulty'] ?? 'easy';
            $wc = intval($_POST['word_count'] ?? 5);
            $timeSeconds = intval($_POST['time_seconds'] ?? 0);
            $wft = intval($_POST['words_first_try'] ?? 0);
            $totalWrong = intval($_POST['total_wrong_letters'] ?? 0);
            $accPct = ($wc > 0) ? round(($wft / $wc) * 100) : 0;

            // Insert score
            $pdo = new PDO('mysql:host=' . DB_WRITE_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PASS, mysqlPdoOptions([]));
            $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

            $stmt = $pdo->prepare('INSERT INTO leia_popcorn_scores (player_name, player_cookie, difficulty, word_count, time_seconds, words_first_try, total_wrong_letters, accuracy_pct, completed_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, NOW())');
            $stmt->execute([$pName, $playerCookie, $difficulty, $wc, $timeSeconds, $wft, $totalWrong, $accPct]);

            // Get rank
            $pdoRead = new PDO('mysql:host=' . DB_READ_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PASS, mysqlPdoOptions([]));
            $pdoRead->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

            $stmt = $pdoRead->prepare('SELECT COUNT(*) + 1 AS rnk FROM leia_popcorn_scores WHERE difficulty = ? AND time_seconds < ?');
            $stmt->execute([$difficulty, $timeSeconds]);
            $rank = $stmt->fetchColumn();

            // Check personal best
            $stmt = $pdoRead->prepare('SELECT MIN(time_seconds) AS best_time FROM leia_popcorn_scores WHERE player_cookie = ? AND difficulty = ? AND time_seconds < ?');
            $stmt->execute([$playerCookie, $difficulty, $timeSeconds]);
            $bestTime = $stmt->fetchColumn();
            $isPB = ($bestTime === false || $bestTime === null || $bestTime === '');

            $response = [
                'success' => true,
                'rank' => intval($rank),
                'personalBest' => $isPB
            ];
            break;

        // GET SCORES
        case 'getScores':
            $difficulty = $_GET['difficulty'] ?? 'easy';

            $pdoRead = new PDO('mysql:host=' . DB_READ_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PASS, mysqlPdoOptions([]));
            $pdoRead->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

            $stmt = $pdoRead->prepare('SELECT player_name, time_seconds, words_first_try, word_count, accuracy_pct, completed_at FROM leia_popcorn_scores WHERE difficulty = ? ORDER BY accuracy_pct DESC, time_seconds ASC LIMIT 25');
            $stmt->execute([$difficulty]);

            $scores = [];
            while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
                $scores[] = [
                    'player_name' => $row['player_name'],
                    'time_seconds' => intval($row['time_seconds']),
                    'words_first_try' => intval($row['words_first_try']),
                    'word_count' => intval($row['word_count']),
                    'accuracy_pct' => intval($row['accuracy_pct'])
                ];
            }

            $response = [
                'success' => true,
                'scores' => $scores
            ];
            break;

        default:
            $response = ['success' => false, 'error' => 'Invalid action'];
            $statusCode = 400;
            break;
    }
} catch (Exception $e) {
    $response = ['success' => false, 'error' => 'Server error'];
    $statusCode = 500;
}

http_response_code($statusCode);
echo json_encode($response);

Youez - 2016 - github.com/yon3zu
LinuXploit