<?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('home', 'music', 'news', 'fav', 'down', 'edit', 'topic', 'pic', 'msg', 'friend', 'news', 'pay');
//获取变量
$ac=CS_Request("ac");
$op=CS_Request("op");
$id=CS_Request("id");
$ac = (!empty($ac) && in_array($ac, $dos))?$ac:'home';
if(CS_UserFun==1) exit(Msg_Error('抱歉,本站会员功能已经关闭!','/'));
if(!isset($_COOKIE["cs_name"]) || !isset($_COOKIE["cs_id"])) exit(Msg_Error('抱歉,您还没有登入或者登入超时!','login.php'));

//清理动态
$db->query("delete from ".Getdbname('dt')." where DATEDIFF(DATE(cs_addtime),'".date('Y-m-d')."') <=-30");

$row=$db->getrow("Select * from ".Getdbname('user')." where CS_ID=".$_COOKIE["cs_id"]." and cs_name='".$_COOKIE["cs_name"]."'");
if($row){
    if($row['CS_SID']==1) exit(Msg_Error('抱歉,对不起您的帐号已被锁定!','/'));
    $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_city=$row['CS_City'];
    $cscms_mp3=$row['CS_Mp3'];
    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_viptime=$row['CS_EndTime'];
    if($row['CS_Vip']==0){
          $cscms_vip="普通会员";
    }else{
          $cscms_vip="VIP会员";
    }
    if(empty($row['CS_Bgpic'])){
          $cscms_bgpic='../home/images/bg.jpg';
    }else{
          $cscms_bgpic='../annex/bg/'.$row['CS_Bgpic'];
    }
    if(empty($row['CS_Toppic'])){
          $cscms_toppic='../home/images/top.jpg';
    }else{
          $cscms_toppic='../annex/top/'.$row['CS_Toppic'];
    }
    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('抱歉,我使劲找过了，可是没有找到你!','/'));
}
//消息数量
$cscms_msgcount= $db -> num_rows($db -> query("select * from ".Getdbname('xiaoxi')." where cs_usera='".$_COOKIE["cs_name"]."' and CS_DID=0"));
//好友数量
$cscms_hycount= $db -> num_rows($db -> query("select * from ".Getdbname('friend')." where cs_usera='".$_COOKIE["cs_name"]."' and CS_TID=1"));
//粉丝数量
$cscms_fscount= $db -> num_rows($db -> query("select * from ".Getdbname('fans')." where cs_usera='".$_COOKIE["cs_name"]."'"));
//摸班颜色
$cscms_mb=array("蓝色","紫色","黑色","绿色","粉(透明)色","粉色","黑(白)色","黑(黄)色","粉(紫)色","黄色");
//会员标题
if($ac=='edit'){
    $title="个人资料";
}elseif($ac=='music'){
    $title="音乐分享";
}elseif($ac=='fav'){
    $title="音乐收藏";
}elseif($ac=='down'){
    $title="音乐下载";
}elseif($ac=='blog'){
    $title="微博发布";
}elseif($ac=='pic'){
    $title="照片上传";
}elseif($ac=='gbook'){
    $title="留言中心";
}elseif($ac=='msg'){
    $title="短信通知";
}elseif($ac=='topic'){
    $title="专集制作";
}elseif($ac=='pay'){
    $title="充值中心";
}else{
    $title="会员中心";
}

//分页
function getuserpage($mysql,$pagesize){
	global $db;
	$url=$_SERVER["QUERY_STRING"];
	if(stristr($url,'&pages')){
		$url=preg_replace('/&pages=([\S]+?)$/','',$url);
	}
	if(stristr($url,'pages')){
		$url=preg_replace('/pages=([\S]+?)$/','',$url);
	}
	$url.="&";

	$pages=CS_Request("pages");
	$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;}
 	$str="<em>".$nums."</em>";
        $pagejs=ceil($nums/$pagesok);//总页数
  
    if($pages>$pagejs){
     $pages=$pagejs;
    }
    if(empty($pages)) $pages=1;
    $sql=$sqlstr." LIMIT ".$pagesok*($pages-1).",".$pagesok;                                                             ;
	$result = $db -> query($sql);
	if($pages>1){
	$str.="<a href=?".$url."pages=".($pages-1)." title='上一页'><<</a>";
 	}
	if($pagejs<=1){
  		for($i=1;$i<=$pagejs;$i++){
   			$str.="<strong>".$i."</strong>";
 	 	}
	}else{
 		if($pages>=4){
 			for($i=$pages-3;$i<=$pages+3;$i++){
   			     if($i<=$pagejs){
                                 if($pages==$i){
   				         $str.="<strong><font color=#000>".$i."</font></strong>";
                                 }else{
   				         $str.="<a href='?".$url."pages=".$i."'>".$i."</a>";
                                 }
    			     }
  		        }
  		        if($i<=$pagejs){ 
	    		     $str.="<a href='?".$url."pages=".$pagejs." '>".$pagejs."</a>";
   		        }
   		}else{
  			for($i=1;$i<=4;$i++){
                                 if($pages==$i){
   				         $str.="<strong><font color=#000>".$i."</font></strong>";
                                 }else{
   				         $str.="<a href='?".$url."pages=".$i."'>".$i."</a>";
                                 }
 		        } 
 			if($i<=$pagejs){ 
	  		     $str.="<a href='?".$url."pages=".$pagejs." '>".$pagejs."</a>";
    			}
 		}
	}
	if($pages<$pagejs){
	$str.="<a href=?".$url."pages=".($pages+1)." title='下一页'>>></a>";
	}
	 while ($row = $db -> fetch_array($result) ){}
	 $arr=array($str,$result,$sql,$pagejs);
	 return $arr;
}

include_once('skin_head.php');
include_once('skin_'.$ac.'.php');
include_once('skin_bottom.php');
