403Webshell
Server IP : 158.247.231.215  /  Your IP : 216.73.216.111
Web Server : Apache/2.4.41 (Ubuntu)
System : Linux CTMS 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User : www-data ( 33)
PHP Version : 8.0.30
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /mnt/blockstorage/ctms/api/custom-api/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /mnt/blockstorage/ctms/api/custom-api/vr-download-requests-admin.php
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, OPTIONS');
header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Authorization");
header('Content-Type: application/json');

if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
    http_response_code(200);
    exit();
}

// Load WordPress and auth helper
require_once('/mnt/blockstorage/ctms/wp-load.php');
require_once('auth-helper.php');

include('../database.php');

// Verify JWT token
$user_id = verify_jwt_token();

if (!$user_id) {
    send_error_response('User not authenticated', 401);
}

if ($_SERVER['REQUEST_METHOD'] === 'GET') {
    try {
        // Get query parameters
        $status = isset($_GET['status']) ? $conn->real_escape_string($_GET['status']) : '';
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;
        $limit = isset($_GET['limit']) ? intval($_GET['limit']) : 20;

        $page = max(1, $page);
        $limit = min(100, max(1, $limit));
        $offset = ($page - 1) * $limit;

        // Build WHERE clause
        $where_clauses = array();
        if (!empty($status) && in_array($status, array('pending', 'approved', 'rejected'))) {
            $where_clauses[] = "r.status = '$status'";
        }

        $where_sql = !empty($where_clauses) ? 'WHERE ' . implode(' AND ', $where_clauses) : '';

        // Get total count
        $count_sql = "SELECT COUNT(*) as total FROM vr_download_requests r $where_sql";
        $count_result = $conn->query($count_sql);
        $total = $count_result->fetch_assoc()['total'];

        // Get requests with user info from wp_users
        $sql = "SELECT
                    r.id,
                    r.user_id,
                    r.content_id,
                    r.version_id,
                    r.device_type,
                    r.status,
                    r.is_downloaded,
                    r.approved_by,
                    r.approved_at,
                    r.downloaded_at,
                    r.created_at,
                    r.updated_at,
                    c.title as content_title,
                    v.version_number,
                    u.user_login,
                    u.user_email,
                    u.display_name,
                    admin.user_login as approved_by_name
                FROM vr_download_requests r
                INNER JOIN vr_contents c ON r.content_id = c.id
                INNER JOIN vr_content_versions v ON r.version_id = v.id
                LEFT JOIN wp_users u ON r.user_id = u.ID
                LEFT JOIN wp_users admin ON r.approved_by = admin.ID
                $where_sql
                ORDER BY r.created_at DESC
                LIMIT $limit OFFSET $offset";

        $result = $conn->query($sql);

        $requests = array();
        while ($row = $result->fetch_assoc()) {
            $requests[] = array(
                'id' => intval($row['id']),
                'user_id' => intval($row['user_id']),
                'user_login' => $row['user_login'],
                'user_email' => $row['user_email'],
                'user_name' => $row['display_name'],
                'content_id' => intval($row['content_id']),
                'content_title' => $row['content_title'],
                'version_id' => intval($row['version_id']),
                'version_number' => $row['version_number'],
                'device_type' => $row['device_type'],
                'status' => $row['status'],
                'is_downloaded' => (bool)$row['is_downloaded'],
                'approved_by' => $row['approved_by'] ? intval($row['approved_by']) : null,
                'approved_by_name' => $row['approved_by_name'],
                'approved_at' => $row['approved_at'],
                'downloaded_at' => $row['downloaded_at'],
                'created_at' => $row['created_at'],
                'updated_at' => $row['updated_at']
            );
        }

        $response = array(
            'status' => 'success',
            'data' => array(
                'requests' => $requests,
                'pagination' => array(
                    'page' => $page,
                    'limit' => $limit,
                    'total' => intval($total),
                    'total_pages' => ceil($total / $limit)
                )
            )
        );

        echo json_encode($response);

    } catch (Exception $e) {
        $response = array(
            'status' => 'error',
            'message' => $e->getMessage()
        );
        http_response_code(400);
        echo json_encode($response);
    }

    $conn->close();

} else {
    $response = array(
        'status' => 'error',
        'message' => 'Only GET requests are allowed'
    );
    http_response_code(405);
    echo json_encode($response);
}
?>

Youez - 2016 - github.com/yon3zu
LinuXploit