<?php
	
	if(!defined('VI_BASE')) {
		ob_clean();
		exit('Access Denied');
	}
	
	/////////////////////////////////
	
	require VI_ROOT.'module/member/config.php';
	
	$sql="SELECT * FROM `mod:value` WHERE fid=".$fid." order BY id desc";	
    
    //查询数据库_总记录数
    $row_count = System :: $db -> getCount( $sql );

    //分页参数
    $page=getpage("page");
    $page_start=$_G['setting']['global']['pagesize']*($page-1);
    $sql=$sql." limit $page_start,".$_G['setting']['global']['pagesize'];	
    
    //分页链接
    $url="?action=state&id=".$fid."&page=";
	
	$result = System :: $db -> getAll( $sql );
	
	//处理用户数据
	foreach( $result as $idx => $row ){
		
		//解析数据
		$result[$idx]["config"] = fix_json( $result[$idx]["config"] );
		
		//var_dump( $result[$idx]["config"] );
		
		//隐藏电话
		if( isset( $result[$idx]["config"]["PHONE"] ) ){
			$result[$idx]["config"]["PHONE"] = hide_phone( $result[$idx]["config"]["PHONE"] );
		}
		
		//隐藏姓名
		if( isset( $result[$idx]["config"]["NAME"] ) ){
			$result[$idx]["config"]["NAME"] = ( $config['SHOW_NAME'] == 'ALL' ? $result[$idx]["config"]["NAME"] : hide_name( $result[$idx]["config"]["NAME"] ) );
		}
		
		//扩展注册用户信息
		if( $row['uid'] ){
			
			$sql="SELECT name,phone from `mod:member` WHERE id='".$row['uid']."'";
			
			System :: $db -> query($sql);
			$result[$idx]["member"] = System :: $db -> fetchRow();
			
			//隐藏电话
			$result[$idx]["member"]["phone"] = hide_phone( $result[$idx]["member"]["phone"] );
			
			//隐藏电话
			$result[$idx]["member"]["name"] = ( $config['SHOW_NAME'] == 'ALL' ? $result[$idx]["member"]["name"] : hide_name( $result[$idx]["member"]["name"] ) );
			
		}
	}

	//查询结果
	$smarty->assign("sign", $_G['module']['member']["sign"] );
	
	//查询结果
	$smarty->assign("result", $result );
	
	//分页链接
	$smarty->assign("multi", multipage($page,$row_count,$_G['setting']['global']['pagesize'],$url,"pp-page") );


?>