<?php
if (!defined('R_P')) exit('Access Denied');
$id = intval($_GET['id']);
$page = intval($_GET['page']) > 0 ? intval($_GET['page']) : 1;
$cid = 0;
$_output = qbase::get_object('content', $channelid, $id)->get();
if (empty($_output)) qbase::showmsg("not found the" . $channeltitle, $skin , toPath($channelid));

$cid = $_output['cid'];

$_output['picfromname'] = $_output['picfromname'] ? $_output['picfromname'] : "来自网络";
$ordering = abs($page - 1);

$_output['data'] = qbase::get_object('content', $channelid, $id)->get_s();
if(isset($_output['data'][$ordering])){
	$_output['show'] = $_output['data'][$ordering] ;
}else{
	$_output['show'] = $_output['data'][0] ;
	$page = 1;
}

$_category_info = getCidInfo($channelid, $cid);
if (empty($_category_info)) qbase::purviewCheckDie("bad request");

$iif = !($_category_info['pur_browse'] || $_category_info['html'] || $_output['pay']);

if (($_category_info['pur_browse'] || $_output['pay']) && !qbase::is_admin()) { // 权限检测
	require_once(R_P . '/include/class.userpay.php');
	$pay_purview = array(
		'id' => $id,
		'cid' => $cid,
		'point' => $_output['requirepoint'],
		'read_purview' => $_output['read_purview'],
		'pay_type' => $_output['pay_type'],
		'read_last' => $_output['read_last'],
	);
	$_output['paid'] = 1;
	$_output['pay_param'] = '';
	$purview = new userpay($channelid, $pay_purview, trim(urldecode($_GET['param'])));
	$_output['paid'] = $purview->checkSureLink('view');
	$_output['paid']++;
	if ($_output['paid'] == 1){
		//未付费
		unset($_output['message'], $_SET['text']);
		$_output['page'] = 1;
		$_output['pay_param'] = $purview->createSureLink('check');
	}
} 

$page_total = $_output['page'];
$showphp || $showphp = qbase::GetCidSkin(2);
include qbase::template($showphp);
qbase::obHtml(3);

?>