www.gusucode.com > 08CMS空白站群系统 3.3 繁体 UTF-8 > upload/include/follow.fun.php
<?php !defined('M_COM') && exit('No Permission'); include_once M_ROOT.'./include/archive.fun.php'; function follow_dynamic($aid=0,$mode='down',$temparr=array()){ global $arc,$sptpls,$memberid,$cms_abs,$cache1circle,$timestamp,$currencys,$curuser; if($aid){ $arc->init(); $arc->arcid($aid); } if(empty($arc->aid)) message(lang('confirmchoose archive')); !$arc->archive['checked'] && message(lang('pointed archive nocheck')); switch_cache($arc->archive['sid']); $sid = $arc->archive['sid']; if_siteclosed($sid); !arc_allow($arc->archive,'aread') && message(lang('none archive browse permission')); if($crids = $arc->arc_crids(1)){//需要对当前用户扣值 $cridstr = ''; foreach($crids['total'] as $k => $v) $cridstr .= ($cridstr ? ',' : '').abs($v).$currencys[$k]['unit'].$currencys[$k]['cname']; $commu = read_cache('commu',8); if(empty($commu['setting']['autoatm'])){//不自动扣值的情况:提示出订阅链接,选择是否订阅 message(lang('subscribe this attachment want pay currency : ').$cridstr."<br><br><a href=\"subscribe.php?aid=$aid&isatm=1\">>>".lang('subscribe')."</a>"); }else{//自动扣值,当前会员扣值及向出售者支付积分 if(!$curuser->crids_enough($crids['total'])) message(lang('subscribe this attachment want pay currency : ').$cridstr.lang('<br><br> you nohave subscribe this attachment wanted enough currency !')); $curuser->updatecrids($crids['total'],0,lang('subscribe attachment')); $curuser->payrecord($arc->aid,1,$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 attachment')); unset($actuser); } } } $arc->detail_data(); $arc->parsedata(); if(empty($temparr['tmode'])){ if($temp = @unserialize($arc->archive[$temparr['tname']])){ $temparr = array_merge($temparr,@$temp[$temparr['fid']]); $temparr['url'] = view_atmurl($temparr['remote']); } }else{ if($temp = @explode('#',$arc->archive[$temparr['tname']])){ $temparr['url'] = view_atmurl($temp[0]); } } unset($temp); empty($temparr['url']) && message(lang('noattach')); save_nums($aid,$mode);//统计下载或播放数 !empty($sptpls[$mode]) && $arc->template = @load_tpl($sptpls[$mode],1); if(empty($arc->template)) follow_notpl(0,$mode,$temparr); $temparr = array_merge($arc->transarr(),$temparr); if($mode == 'down'){ $auth = authcode($memberid."\t".$arc->aid."\t".$temparr['tname']."\t".$temparr['tmode']."\t".$temparr['fid'],'ENCODE'); $temparr['trueurl'] = $cms_abs."down.php?auth=$auth&aid=".$arc->aid."&tname=$temparr[tname]&tmode=$temparr[tmode]&fid=$temparr[fid]"; }elseif($cache1circle){ $auth = authcode($temparr['tname']."\t".$temparr['tmode']."\t".$temparr['fid'],'ENCODE'); $cachefile = htmlcac_dir('fw',date('Ym',$arc->archive['createdate']),1).cac_namepre($arc->aid,$arc->archive['createdate']).'_'.$auth.'.php'; if(is_file($cachefile) && (filemtime($cachefile) > ($timestamp - $cache1circle * 60))){ mexit(read_htmlcac($cachefile)); } } nreplace($arc->template,'c',$temparr); $arc->nreplace($arc->template,'u',$temparr); $arc->nreplace($arc->template,'b',$temparr); code_parse($arc->template); ($mode != 'down' && $cache1circle) && save_htmlcac($arc->template,$cachefile); mexit($arc->template); } function follow_notpl($aid=0,$mode='down',$temparr=array()){ global $arc,$players,$player_width,$player_height;; if($aid){ $arc->init(); $arc->arcid($aid); } if(!empty($temparr['tmode'])){ $content = @$arc->archive[$temparr['tname']]; $temp = explode('#',$content); $temparr['url'] = view_atmurl($temp[0]); $mode != 'down' && ($temparr['player'] = empty($temp[1]) ? 0 : $temp[1]); } if($mode == 'down'){ down_url($temparr['url']); }else{ load_cache('players'); $plid = empty($temparr['player']) ? 0 : $temparr['player']; if(!$plid){ $ext = strtolower(mextension($temparr['url'])); foreach($players as $k => $player){ if($player['available'] && $player['ptype'] == $mode && in_array($ext,array_filter(explode(',',$player['exts'])))){ $plid = $k; break; } } } !$plid && message(lang('noplayer')); $player = read_cache('player',$plid); $temparr['width'] = empty($player_width) ? '100%' : $player_width; $temparr['height'] = empty($player_height) ? '100%' : $player_height; $result = $player['template']; nreplace($result,'b',$temparr); code_parse($result); mexit($result); } } function down_url($url){ if(islocal($url)){ file_down(local_file($url)); }else{ header("location:$url"); } mexit(); } function save_nums($aid=0,$mode='down'){//统计文档的下载数或播放数 global $sid; include_once M_ROOT.'./include/arcedit.cls.php'; $aedit = new cls_arcedit(); $aedit->set_aid($aid); $aedit->basic_data(); $aedit->arc_nums($mode == 'down' ? 'downs' : 'plays',1,1); unset($aedit); } ?>