<?php
wp_head();
?>
<link rel="stylesheet" href="https://npm.elemecdn.com/gahotx-cdn@1.0.14/fonts/harmony/regular.min.css" media="all" onload="this.media='all'">
<?php
$pid = !empty($_GET['pid']) ? $_GET['pid'] : 0;
$current_user = wp_get_current_user();
$user_id = $current_user->ID;
$today = date('Y-m-d');

$meta = get_post_meta($pid,'_ppo_post_options',true);
$logo_adv = get_op('dp_logo_adv','');

if(is_array($meta) && !empty($meta)) {
    $data = $meta['dd_box_data'];
    $data['pid'] = $pid;
    $bought = PPO_Down::check_user_bought($data);
    $logo = get_op('dp_logo');
    $logo = $logo === THEME_URL . '/img/logo.png' ? '' : $logo;
    $logo = !empty($logo) ? $logo : pix_global_logo_url('dark');
    $logo = !empty($logo) ? '<img src="'.$logo.'">' : '';

    if($bought) {
        $down_data = PPO_Down::get_user_down_num($user_id);
        if($down_data['time'] !== $today){
            $update_arr = get_user_down_num_arr($user_id);
            update_user_meta($user_id,'user_down_num',$update_arr);
        }

        $content = PPO_Down::get_ppo_down_item($pid,$user_id);

        echo '<div class="downpage-wrap">
                <div class="dp-logo">'.$logo.'</div>
                <div class="dp-logo-adv">'.$logo_adv.'</div>
                <div class="dp-content">
                    <div class="dp-title">'.$data['title'].'</div>
                    '.$content.'
                </div>
                </div>';
    } else {
        echo '<div class="downpage-wrap">
                <div class="dp-content">
                    <div class="dp-error"><i class="ri-error-warning-line"></i>未购买，无法下载</div>
                </div>
                </div>';
    }
    

} 






wp_footer();        
