<?php
/*
  PHP version 5
  Copyright (c) 2002-2018 ECISP.CN、EarcLink.COM
  警告：这不是一个免费的软件，请在许可范围内使用，请尊重知识产权，侵权必究，举报有奖
  作者：黄祥云 E-mail:6326420@qq.com  QQ:6326420 TEL:18665655030
  ESPCMS官网介绍：http://www.ecisp.cn	企业建站：http://www.earclink.cn

 */

use modul_application\ESPCMS_MemberAuthority;

class lib_viewper {

    public static function call_viewper($parameter, $filename = 'viewper', $outHTML = null) {
        $espcms_lib_template = espcms_web_template();
        $espcms_lib_template->libfile = true;
        $para = espcms_array_getvalue($parameter);
        if (!espcms_ismatches($para['did']) || !$para['did']) {
            return false;
        }
        if (!$para['purview'] || !espcms_ismatches($para['purview'], '/^[\d]+(\-[\d]+)*$/i')) {
            return false;
        }
        $attr = $para['attr'];
        $purview_array = explode('-', $para['purview']);
        $member_cookie_info = ESPCMS_MemberAuthority::getMemberInfo();

        $isreawd = in_array($member_cookie_info['mcid'], $purview_array) && $member_cookie_info['mcid'] && espcms_ismatches($member_cookie_info['mcid']) ? 1 : 0;
        $espcms_lib_template->into('isreawd', $isreawd);
        $espcms_lib_template->into('attr', $attr);
        $espcms_lib_template->into('para', $para);
        if (!empty($outHTML)) {
            $output = $espcms_lib_template->fetch(null, null, $outHTML);
        } else {
            $output = $espcms_lib_template->fetch('lib/' . $filename);
        }
        return $output;
    }
}