<?php
include 'session.php';

if (!function_exists('site_url')) {
    include __DIR__ . '/../config/url_helper.php';
}

if (empty($_SESSION['user'])) {
    header('Location: ' . site_url('m'));
    exit;
}

require_once __DIR__ . '/includes/member_referral.php';

$user = mysqli_query($conn, "SELECT * FROM tb_user WHERE username = '" . mysqli_real_escape_string($conn, $_SESSION['user']) . "'");
$u = mysqli_fetch_array($user);

if (!$u || !member_referral_is_member($u)) {
    header('Location: ' . site_url('m'));
    exit;
}

$ref = member_referral_prepare($conn, $u);

include 'header.php';
include __DIR__ . '/includes/referral_member_content.php';
include 'footer.php';
