OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
cream
/
quiz
/
yt_subscription
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
05/19/2025 10:07:16 AM
rwxr-xr-x
📄
callback.php
846 bytes
05/19/2025 10:07:16 AM
rw-r--r--
📁
data
-
02/15/2025 11:20:32 AM
rwxr-xr-x
📄
function.php
4.97 KB
05/19/2025 10:07:16 AM
rw-r--r--
📄
index.html
2.27 KB
02/15/2025 11:21:44 AM
rw-r--r--
📄
oauth.php
332 bytes
05/19/2025 10:07:16 AM
rw-r--r--
📄
subscription_check.php
1.7 KB
05/19/2025 10:07:16 AM
rw-r--r--
Editing: subscription_check.php
Close
<?php include '../assets/php/validate.logged.php'; include '../assets/php/db_config.php'; // Include the functions file require_once('function.php'); function subscriptionStatus() { global $gUserId, $conn; $stmt = $conn->prepare("UPDATE candidate SET subscriptionStatus = 'Y' WHERE id = ?"); $stmt->bind_param("i", $gUserId); $stmt->execute(); } // Step 1: Ensure the user is authenticated (access token is available) if (!isset($_SESSION['access_token'])) { // If not authenticated, send back a message to prompt login echo json_encode(['error' => 'User not authenticated', 'login_required' => true]); exit(); } // Step 2: Get the access token from session $access_token = getAccessTokenFromSession(); try { $subscriptions_data = fetchYouTubeSubscriptions($access_token); // If the response is empty or not valid, handle as an error if (!$subscriptions_data || !isset($subscriptions_data['items'])) { echo json_encode(['error' => 'Failed to fetch subscriptions', 'login_required' => false]); exit(); } } catch (Exception $e) { // If there's an exception (e.g., network error, invalid response) echo json_encode(['error' => 'An error occurred while fetching subscriptions', 'login_required' => false]); exit(); } $channel_id_to_check = 'UC4MqIPSKb2FLYyPZQTDuqPQ'; // Replace with the channel ID you want to check // Step 5: Check if the user is subscribed to the specified channel $is_subscribed = checkIfSubscribed($subscriptions_data, $channel_id_to_check); if($is_subscribed){ subscriptionStatus(); } // Step 6: Return the result as JSON echo json_encode(['is_subscribed' => $is_subscribed]); ?>