<?php
# Name: PHP版程氏音乐CMS管理系统 v3.0
# Author: 程氏<web@chshcms.com> [QQ:848769359]
# Homepage:http://www.chshcms.cn/
include_once(CSDJ_PATH.'/cs_conn.php');
include_once(CSDJ_PATH.'/cs_common.php');
//判断网站开关
if(CS_Weboff==1) exit(stripslashes(html_entity_decode(CS_Webnoneir)));
ob_start();
//允许动作
$dos = array('index', 'music', 'news', 'fav', 'down', 'topic', 'pic', 'gbook', 'hy', 'fs', 'picx', 'pick', 'tdance');
if(CS_UserFun==1) exit(Msg_Error('抱歉,本站会员功能已经关闭!','/'));
//获取变量
$usym=$_SERVER['HTTP_HOST'];
$uall=explode(".",$usym);
$op=CS_Request("op");
$uid=CS_Request("uid");
$mb=CS_Request("mbid");
$id=CS_Request("id");
$pages=CS_Request("pages");
if(empty($uid)) $uid=$uall[0];

$op = (!empty($op) && in_array($op, $dos))?$op:'index';

if(empty($uid)) exit(Msg_Error('抱歉,会员UID为空，参数错误!','/')); 

global $db;
$row=$db->getrow("Select * from ".Getdbname('user')." where CS_ID=".$uid."");
if($row){
    if($row['CS_SID']==1) exit(Msg_Error('抱歉,该会员已被锁定!','http://'.CS_WebUrl));
    $cscms_name=$row['CS_Name'];
    $cscms_nichen=$row['CS_Nichen'];
    $cscms_uid=$row['CS_ID'];
    $cscms_qqid=$row['CS_Qqid'];
    $cscms_cion=$row['CS_Cion'];
    $cscms_qq=$row['CS_QQ'];
    $cscms_mbid=$row['CS_Mbid'];
    $cscms_sex=$row['CS_Sex'];
    $cscms_hits=$row['CS_Hits'];
    $cscms_city=$row['CS_City'];
    if(!empty($cscms_city)){
         $city=explode("-",$cscms_city);
    }
    $cscms_email=$row['CS_Email'];
    $cscms_qianm=$row['CS_Qianm'];
    $cscms_link=userlink('index',$row['CS_ID']);
    if(empty($row['CS_Nichen'])) $cscms_nichen=$row['CS_Name'];
    $cscms_logo=piclink('logo',$row['CS_Logo']);
    $cscms_addtime=$row['CS_AddTime'];
    $cscms_logtime=$row['CS_LogTime'];
    $cscms_vipid=$row['CS_Vip'];
    $cscms_tid=$row['CS_TID'];
    $cscms_logoid=$row['CS_Logo'];
    if($row['CS_Vip']==0){
          $cscms_vip="普通会员";
    }else{
          $cscms_vip="VIP会员";
    }
    if(empty($row['CS_Bgpic'])){
          $cscms_bgpic='images/bg.jpg';
    }else{
          $cscms_bgpic='http://'.CS_WebUrl.CS_WebPath.'annex/bg/'.$row['CS_Bgpic'];
    }
    if(empty($row['CS_Toppic'])){
          $cscms_toppic='images/top.jpg';
    }else{
          $cscms_toppic='http://'.CS_WebUrl.CS_WebPath.'annex/top/'.$row['CS_Toppic'];
    }
    if(DateBj("n",$row['CS_LogTime'],date('Y-m-d H:i:s')<40)){
        $cscms_zx='在线';
    }else{
        $cscms_zx='离线';
    }
    $cscms_mp3=$row['CS_Mp3'];
    if(!empty($cscms_mp3)){
         $bmp3=explode("@@@",$cscms_mp3);
         $cscms_btop=$bmp3[0];
         $cscms_bleft=$bmp3[1];
         $cscms_bname=$bmp3[2];
         $cscms_bmp3=$bmp3[3];
         if(empty($cscms_bname)) $cscms_bname=$cscms_nichen.'欢迎您!';
    }else{
         $cscms_btop='40';
         $cscms_bleft='200';
         $cscms_bmp3='';
         $cscms_bname=$cscms_nichen.'欢迎您!';
    }
}else{
    exit(Msg_Error('抱歉,我使劲找过了，可是没有找到该会员!','http://'.CS_WebUrl));
}

//歌曲数量
$musicion= $db -> num_rows($db -> query("select * from ".Getdbname('dance')." where cs_user='".$cscms_name."' and CS_YID=0"));
//好友数量
$cscms_hycount= $db -> num_rows($db -> query("select * from ".Getdbname('friend')." where cs_usera='".$cscms_name."' and CS_TID=1"));
//粉丝数量
$cscms_fscount= $db -> num_rows($db -> query("select * from ".Getdbname('fans')." where cs_usera='".$cscms_name."'"));


//*************点亮图标*****************//
$vip="uvip";
$realname="urealname";
$musician="umusician";
$recommend="urecommend";
$star="ustar";
if($cscms_vipid==1) $vip="vip";
if(!empty($cscms_logoid)) $realname="realname";
if($cscms_tid==1) $recommend="recommend";
if($musicion>5) $musician="musician";
if($musicion>5) $star="star";
//*************************************//

//会员标题
if($op=='music'){
    $title=$cscms_nichen."的最新舞曲";
}elseif($op=='fav'){
    $title=$cscms_nichen."音乐收藏";
}elseif($op=='down'){
    $title=$cscms_nichen."音乐下载";
}elseif($op=='blog'){
    $title=$cscms_nichen."微博记录";
}elseif($op=='pic'){
    $title=$cscms_nichen."照片分享";
}elseif($op=='gbook'){
    $title=$cscms_nichen."留言中心";
}elseif($op=='topic'){
    $title=$cscms_nichen."专集分享";
}else{
    $title=$cscms_nichen."个人主页";
    $db->query("update ".Getdbname('user')." set CS_Hits=CS_Hits+1 where CS_ID=$uid");
}

//记录访客
if(isset($_COOKIE["cs_name"]) && $op=='index'){
       if($cscms_name!="".$_COOKIE["cs_name"].""){
       $sqlf="select * from ".Getdbname('funco')." where cs_usera='".$cscms_name."' and cs_userb='".$_COOKIE["cs_name"]."'";
           if($rowf=$db->Getrow($sqlf)){
                $db->query("update ".Getdbname('funco')." set CS_AddTime='".date('Y-m-d H:i:s')."' where cs_id=".$rowf['CS_ID']."");
           }else{
                $db->query("insert into ".Getdbname('funco')." (cs_usera,cs_userb,cs_addtime) values ('".$cscms_name."','".$_COOKIE["cs_name"]."','".date('Y-m-d H:i:s')."')");
           }
       }
}

//分页
function getuserpage($mysql,$pagesize,$op,$uid,$pages){
	global $db;
	$pagesok=$pagesize;//每页显示记录数
         if (!isset($pages)||$pages==""||!is_numeric($pages)||$pages<=0){
             $pages=1;
	 }
  	$sqlstr=$mysql;
  	$res=$db -> query($sqlstr);
 	$nums= $db -> num_rows($res);
	if($nums==0){$nums=1;}
        $pagejs=ceil($nums/$pagesok);//总页数
        if($pages>$pagejs){
             $pages=$pagejs;
        }
     $str="共<span>".$nums."</span>条记录&nbsp; <a href=".userlink($op,$uid,0,1).">首页</a>&nbsp;";
     $sql=$sqlstr." LIMIT ".$pagesok*($pages-1).",".$pagesok;                                                          ;
	$result = $db -> query($sql);
	if($pages>0){
	    $str.="<a href=".userlink($op,$uid,0,($pages-1)).">上一页</a>&nbsp;";

 	}
	if($pagejs>1){
	    $str.="<a href=".userlink($op,$uid,0,($pages+1)).">下一页</a>&nbsp;";
	}

        $str.="<a href=".userlink($op,$uid,0,$pagejs).">尾页</a>&nbsp;<span>第".$pages."/".$pagejs."页</span>";

	 while ($row = $db -> fetch_array($result) ){}
	 $arr=array($str,$result,$sql,$pagejs);
	 return $arr;
}
if(!empty($mb)) $cscms_mbid=$mb;
include_once('web_head.php');
include_once('web_'.$op.'.php');
include_once('web_bottom.php');