<?php 
error_reporting(0);
if(!$userlogined==true){exit("<script type=\"text/javascript\">location.href='".cd_webpath."user/login.php';</script>");}
?>
  <div class="spaceMain"> 
   <div class="mainTop"></div> 
   <div class="mainCenter"> 
    <div class="publicLeft"> 
     <div class="stageBox"> 
      <div class="stageBoxTop"> 
       <span></span> 
      </div> 
      <div class="stageBoxCenter"> 
       <div class="minHeight940"> 
        <div class="spaceMTitle2">
         <p>装扮皮肤</p>
        </div> 
        <div class="title_per"> 
        </div> 
        <div class="headerNav"> 
         <div class="nav_item"> 
          <span>颜色:</span> 
          <ul class="navTab"> 
           <li<?php if($classId == ""){echo " class=\"current\"";} ?>><a href="<?php echo cd_webpath.cd_webmlsinger; ?>/index.php?ac=skin&id=<?php echo $cctvai_web_userid?><?php if($orderBy){echo '&orderBy='.$orderBy;} ?>">全部</a></li>
<?php
global $db;
$query = $db->query("select cd_id,cd_name from ".tname('skin_class')." order by cd_id asc LIMIT 0,6");
while ($row = $db->fetch_array($query)) {
echo "<li";
if($classId == $row["cd_id"]){
echo " class=\"current\"";
}
if($orderBy){
$cd_orderBy = "&orderBy=".$orderBy;
}else{
$cd_orderBy = "";
}
echo "><a href=\"".cd_webpath.cd_webmlsinger."/index.php?ac=skin&id=".$cctvai_web_userid."&classId=".$row["cd_id"].$cd_orderBy."\">".$row["cd_name"]."</a><b></b></li>";
}
?>
          </ul> 
         </div> 
        </div> 
        <div class="homeSkin_list"> 
         <div class="homeSkin_list_header"> 
          <h4 class="list_headerName">全部</h4> 
          <p class="order">排序：<a<?php if($orderBy == ""){echo " class=\"bold\"";} ?> href="<?php echo cd_webpath.cd_webmlsinger; ?>/index.php?ac=skin&id=<?php echo $cctvai_web_userid?><?php if($classId){echo '&classId='.$classId;} ?>">最新上架</a><span> | </span><a<?php if($orderBy == "1"){echo " class=\"bold\"";} ?> href="<?php echo cd_webpath.cd_webmlsinger; ?>/index.php?ac=skin&id=<?php echo $cctvai_web_userid?><?php if($classId){echo '&classId='.$classId;} ?>&orderBy=1">超高人气</a></p>
         </div> 
         <ul class="homeSkin_list_body"> 
<?php
global $db;
$i=0;
if($orderBy){
$orderBysql = "cd_hits";
}else{
$orderBysql = "cd_addtime";
}
if($classId){
$sql="select * from ".tname('skin')." where cd_classid='$classId' order by $orderBysql desc";
}else{
$sql="select * from ".tname('skin')." order by $orderBysql desc";
}
$Arr=getsingerskinpage($sql,20);//sql,每页显示条数
$result=$db->query($Arr[2]);
$num=$db->num_rows($result);
if($num==0){
echo '<div class="nothing_feed">没有此款皮肤-.-!</div>';
}else{
if($result){
while ($row = $db ->fetch_array($result)){
$i=$i+1;

echo '<li class="ornament ornament-hovered ">';
echo '<div class="ornament-content" skinId="'.$row['cd_id'].'" skinPath="'.$row['cd_path'].'">';
echo '<img class="previewImg" title="'.$row['cd_name'].'" skinId="'.$row['cd_id'].'" src="'.cd_webpath.'user/static/space/skin/'.$row['cd_path'].'/thumb.jpg" onerror="$call(function(){libs.imageError(this);}, this)"/>';
echo '<span class="ornament-status status-new"></span>';
echo '<span class="click-preview" skinPath="'.$row['cd_path'].'" id="on'.$row['cd_id'].'">点击预览</span>';
echo '</div>';
echo '<div class="ornament-name">';
echo '<span>'.$row['cd_name'].'</span>';
echo '<p title="此皮肤需要消耗'.$row['cd_points'].'金币">'.$row['cd_points'].'金币</p>';
echo '</div>';
echo '</li>';
}
}
}
?>
         </ul> 
         <div class="page"> 
          <div class="acButton"> 
           <span class="button2-main"><span><button id="change" type="button" uid="<?php echo $cctvai_web_userid; ?>" BskinPath="<?php echo $cctvai_web_skinid; ?>">保存主题</button></span></span>
           <span class="button2-main"><span><button id="default" type="button" uid="<?php echo $cctvai_web_userid; ?>" BskinPath="<?php echo $cctvai_web_skinid; ?>">恢复默认</button></span></span>
          </div> 
          <div class="pages"> 
<?php echo $Arr[0]; ?><input type="text" maxlength="5" onkeydown="function c(event,val){e = event ? event :(window.event ? window.event : null);if(e.keyCode==13){val = parseInt(val);val=isNaN(val)||(val<=0)?1:val;window.location.href='<?php echo cd_webpath.cd_webmlsinger?>/index.php?ac=skin&id=<?php echo $cctvai_web_userid?><?php if($classId){echo '&classId='.$classId;} ?><?php if($orderBy){echo '&orderBy='.$orderBy;} ?>&pages='+val+'';return false;}else{return true;}};if(!c(event,this.value))return false;" title="输入页码，按回车快速跳转"/>
          </div> 
         </div> 
        </div> 
       </div> 
      </div> 
      <div class="stageBoxBottom"> 
       <span></span> 
      </div> 
     </div> 
    </div> 
    <div class="publicRight"> 
<?php include "source/cctvai_right.php"; ?> 
    </div> 
   </div> 
   <div class="mainBottom"></div> 
  </div> 
<?php include "source/cctvai_footer.php"; ?>  
  <script type="text/javascript" src="<?php echo cd_webpath?>user/static/js/jquery/jquery.min.js"></script>
  <script type="text/javascript" src="<?php echo cd_webpath?>user/static/js/core.js"></script>
  <script type="text/javascript" src="<?php echo cd_webpath?>user/static/js/card.js"></script>
  <script type="text/javascript" src="<?php echo cd_webpath?>user/static/js/dialog.js"></script>
  <script type="text/javascript" src="<?php echo cd_webpath?>user/static/js/jquery/jquery.plugins.js"></script>
  <script type="text/javascript" src="<?php echo cd_webpath?>user/static/space/js/common.js"></script>
  <script type="text/javascript">listenMsg.start();nav.init();nav.userMenu();</script>
  <script type="text/javascript" src="<?php echo cd_webpath?>user/static/space/js/skin.js"></script>
  <script type="text/javascript">skinLib.skinUpdate();</script>
</body>
</html>
<?php
//上下页
function getsingerskinpage($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);
    }
    if(IsNul($url)) {
        $url.="&";
    }
    $pages=SafeRequest("pages", "get");
    $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;
    }
    $sql=$sqlstr . " LIMIT " . $pagesok*($pages-1) . "," . $pagesok;
    $result=$db->query($sql);
    $str="<em title=\"总数量\">" . $nums . "</em>";
    if($pages > 3) {
        $str.="<a href='?" . $url . "pages=1' class='last' title='首页'>1&nbsp;...</a>";
    }
    if($pages > 1) {
        $str.="<a href='?" . $url . "pages=" . ($pages-1) . "' class='prev' title='上一页'>&laquo;</a>";
    }
    if($pagejs <= 6) {
        for($i=1; $i <= $pagejs; $i++) {
            if($i == $pages) {
                $str.="<strong title='第" . $i . "页'>" . $i . "</strong>";
            } else {
                $str.="<a href='?" . $url . "pages=" . $i . "'>" . $i . "</a>";
            }
        }
    } else {
        if($pages >= 8) {
            for($i=$pages-3; $i <= $pages+4; $i++) {
                if($i <= $pagejs) {
                    if($i == $pages) {
                        $str.="<strong title='第" . $i . "页'>" . $i . "</strong>";
                    } else {
                        $str.="<a href='?" . $url . "pages=" . $i . "'>" . $i . "</a>";
                    }
                }
            }
        } else {
            for($i=1; $i <= 8; $i++) {
                if($i == $pages) {
                    $str.="<strong title='第" . $i . "页'>" . $i . "</strong>";
                } else {
                    $str.="<a href='?" . $url . "pages=" . $i . "'>" . $i . "</a>";
                }
            }
        }
    }
    if($pages < $pagejs) {
        $str.="<a href='?" . $url . "pages=" . ($pages+1) . "' class='next' title='下一页'>&raquo;</a>";
    }
    if($pages < $pagejs-2) {
        $str.="<a href='?" . $url . "pages=" . $pagejs . "' class='last' title='最后一页'>...&nbsp;" . $pagejs . "</a>";
    }
    while($row=$db->fetch_array($result)) {
    }
    $arr=array(
        $str,
        $result,
        $sql,
        $pagejs
    );
    return $arr;
}
?>