www.gusucode.com > 08CMS空白站群系统 3.3 繁体 UTF-8 > upload/subscribe.php

    <?php
include_once './include/general.inc.php';
include_once M_ROOT.'./include/common.fun.php';
include_once M_ROOT.'./include/archive.cls.php';
$ajax = empty($ajax) ? 0 : 1;
$aid = empty($aid) ? 0 : max(0,intval($aid));
$isatm = empty($isatm) ? 0 : max(0,intval($isatm));
!$aid && cumessage('confirmchoose archive');
!$memberid && cumessage(lang('nouser nohave purchase permission'));

$commu = read_cache('commu',8);
empty($commu) && cumessage(lang('confirmchoose commu item'));
!$commu['available'] && cumessage(lang('this commu item closed'));
!$curuser->pmsbyugids(explode(',',$commu['setting']['ugids'])) && cumessage(lang('you nohave this item permission'));
$arc = new cls_archive();
!$arc->arcid($aid) && cumessage(lang('confirmchoose archive'));
!$arc->archive['checked'] && cumessage(lang('pointed archive nocheck')); 
switch_cache($arc->archive['sid']);
$sid = $arc->archive['sid'];

$stritem = $isatm ? 'attachment' : 'archive';
if(!($crids = $arc->arc_crids($isatm))) cumessage(lang("you already purchase this $stritem !")); 

$cridstr = '';
foreach($crids['total'] as $k => $v) $cridstr .= ($cridstr ? ',' : '').abs($v).$currencys[$k]['unit'].$currencys[$k]['cname'];
if(!$curuser->crids_enough($crids['total'])) cumessage(lang("you nohave purchase this $stritem wanted enough currency !"));
$curuser->updatecrids($crids['total'],0,lang("purchase $stritem"));
$curuser->payrecord($arc->aid,$isatm,$cridstr,1);
if(!empty($crids['sale'])){
	$actuser = new cls_userinfo;
	$actuser->activeuser($arc->archive['mid']);
	foreach($crids['sale'] as $k => $v) $crids['sale'][$k] = -$v;
	$actuser->updatecrids($crids['sale'],1,lang("sale $stritem"));
	unset($actuser);
}
cumessage($ajax ? 'succeed' : lang('operate succeed'));
?>