<?php
error_reporting(0);
if($ac == "profile" and $view == "") {
    $titles="个人资料";
} elseif($ac == "profile" and $view == "applyCertify") {
    $titles="申请美女认证";
} elseif($ac == "upmusic" and $view == "") {
    $titles="分享音乐";
} elseif($ac == "upmusic" and $view == "passed") {
    $titles="待审音乐";
} elseif($ac == "upmusic" and $view == "list") {
    $titles="已审音乐";
} elseif($ac == "upvideo" and $view == "") {
    $titles="分享视频";
} elseif($ac == "upvideo" and $view == "passed") {
    $titles="待审视频";
} elseif($ac == "upvideo" and $view == "list") {
    $titles="已审视频";
} elseif($ac == "music" and $view == "") {
    $titles="我喜欢的音乐";
} elseif($ac == "music" and $view == "dislike") {
    $titles="我讨厌的音乐";
} elseif($ac == "music" and $view == "favorites") {
    $titles="我收藏的音乐";
} elseif($ac == "music" and $view == "down") {
    $titles="我下载的音乐";
} elseif($ac == "malbum" and $view == "") {
    $titles="创建音乐专辑";
} elseif($ac == "malbum" and $view == "passed") {
    $titles="待审音乐专辑";
} elseif($ac == "malbum" and $view == "list") {
    $titles="已审音乐专辑";
} elseif($ac == "malbum" and $view == "song") {
    $titles="添加到我的音乐专辑";
} elseif($ac == "valbum" and $view == "") {
    $titles="创建视频专辑";
} elseif($ac == "valbum" and $view == "passed") {
    $titles="待审视频专辑";
} elseif($ac == "valbum" and $view == "list") {
    $titles="已审视频专辑";
} elseif($ac == "valbum" and $view == "song") {
    $titles="添加到我的视频专辑";
} elseif($ac == "miniblog" and $view == "") {
    $titles="我的说说";
} elseif($ac == "miniblog" and $view == "following") {
    $titles="关注的说说";
} elseif($ac == "pic" and $view == "") {
    $titles="我的照片";
} elseif($ac == "pic" and $view == "imageSpaceSort") {
    $titles="空间首页照片排序";
} elseif($ac == "pic" and $view == "imageSort") {
    $titles="照片重新排序";
} elseif($ac == "pic" and $view == "following") {
    $titles="好友的照片";
} elseif($ac == "message" and $view == "") {
    $titles="全部通知";
} elseif($ac == "assets" and $view == "") {
    $titles="个人账户";
} elseif($ac == "assets" and $view == "scoreBill") {
    $titles="我的账单详情";
} elseif($ac == "assets" and $view == "topup") {
    $titles="在线充值";
} elseif($ac == "assets" and $view == "vip") {
    $titles="办理VIP";
} elseif($ac == "assets" and $view == "pointsorder") {
    $titles="充值订单";
} elseif($ac == "wall" and $view == "") {
    $titles="我的留言";
} elseif($ac == "pm" and $view == "") {
    $titles="消息列表";
} elseif($ac == "album" and $view == "") {
    $titles="乐迷相册";
} elseif($ac == "album" and $view == "new") {
    $titles="最新上传照片";
} elseif($ac == "privilege" and $view == "") {
    $titles="已通过认证的美女";
} elseif($ac == "list" and $view == "points") {
    $titles="富豪排行榜";
} elseif($ac == "list" and $view == "hits") {
    $titles="人气排行榜";
} elseif($ac == "list" and $view == "dj") {
    $titles="DJ分享人排行榜";
} elseif($ac == "list" and $view == "level") {
    $titles="等级排行榜";
} elseif($ac == "list" and $view == "foll") {
    $titles="关注排行榜";
} elseif($ac == "list" and $view == "fans") {
    $titles="粉丝排行榜";
} elseif($ac == "friend" and $view == "") {
    $titles="我的关注";
} elseif($ac == "user" and $view == "") {
    $titles="活跃会员";
} elseif($ac == "error" and $view == "") {
    $titles="信息报错";
} else {
    $titles="会员中心";
}

//rewrite链接
function rewrite_url($para)
{
    if(cd_userhtml == 1) {
		$para=str_replace('index.php?ac=','',$para);
        $para=str_replace(array('&','=','.php?'), array('-','-','-'), $para);
        return $para . '.html';
    } else {
        return $para;
    }
}
//动态
function GetFolloWing($cd_uid, $cd_type)
{
    global $db;
    $friend="";
    $query=$db->query("select cd_uids,cd_unames from " . tname('friend') . " where cd_uid=" . $cd_uid . " order by cd_addtime desc");
    while($row=$db->fetch_array($query)) {
        if($cd_type) {
            $friend=$friend . "'" . $row['cd_unames'] . "',";
        } else {
            $friend=$friend . $row['cd_uids'] . ",";
        }
    }
    $friend=$friend . "]";
    $friend=ReplaceStr($friend, ",]", "");
    if($friend == "]") {
        return "1000000000,2000000000";
    } else {
        return $friend;
    }
}
function checkEmail($inAddress)
{
    return preg_match('/^[a-z0-9!#$%&\'*+\/=?^`{}|~_-]+[.a-z0-9!#$%&\'*+\/=?^`{}|~_-]*@[a-z0-9]+[._a-z0-9-]*\.[a-z0-9]+$/ui', $inAddress);
}
function submitcheck($var)
{
    if(!empty($_POST[$var]) && $_SERVER['REQUEST_METHOD'] == 'POST') {
        if((empty($_SERVER['HTTP_REFERER']) || preg_replace("/https?:\/\/([^\:\/]+).*/i", "\\1", $_SERVER['HTTP_REFERER']) == preg_replace("/([^\:]+).*/", "\\1", $_SERVER['HTTP_HOST']))) {
            return true;
        } else {
            return false;
        }
    } else {
        return false;
    }
}
//获取在线IP
function getonlineip($format = 0)
{
    global $_SGLOBAL;

    if(empty($_SGLOBAL['onlineip'])) {
        if(getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown')) {
            $onlineip=getenv('HTTP_CLIENT_IP');
        } elseif(getenv('HTTP_X_FORWARDED_FOR') && strcasecmp(getenv('HTTP_X_FORWARDED_FOR'), 'unknown')) {
            $onlineip=getenv('HTTP_X_FORWARDED_FOR');
        } elseif(getenv('REMOTE_ADDR') && strcasecmp(getenv('REMOTE_ADDR'), 'unknown')) {
            $onlineip=getenv('REMOTE_ADDR');
        } elseif(isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], 'unknown')) {
            $onlineip=$_SERVER['REMOTE_ADDR'];
        }
        preg_match("/[\d\.]{7,15}/", $onlineip, $onlineipmatches);
        $_SGLOBAL['onlineip']=$onlineipmatches[0] ? $onlineipmatches[0] : 'unknown';
    }
    if($format) {
        $ips=explode('.', $_SGLOBAL['onlineip']);
        for($i=0; $i < 3; $i++) {
            $ips[$i]=intval($ips[$i]);
        }
        return sprintf('%03d%03d%03d', $ips[0], $ips[1], $ips[2]);
    } else {
        return $_SGLOBAL['onlineip'];
    }
}
//认证
function CheckCertify($music, $mm = '0', $vip = '0', $viprank = '0')
{
    $certify='';
    if($music) {
        $certify.='<a class="certify" href="javascript:void(0)" title="音乐认证" onclick="openWebsite.openTo(\'musiccertify\');"></a>';
    }
    if($mm == 1) {
        $certify.='<a class="certify_mm" href="javascript:void(0)" title="美女认证" onclick="openWebsite.openTo(\'certify\');"></a>';
    }
    if($vip) {
        $certify.='<a class="vip_style vip10' . getviprank($viprank, 0) . '" href="javascript:void(0)" title="VIP' . getviprank($viprank, 0) . '会员" onclick="openWebsite.openTo(\'vip\');"></a>';
    }
    return $certify;
}
//上下页
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);
    }
    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='" . rewrite_url("space.php?" . $url . "pages=1") . "' class='last' title='首页'>1&nbsp;...</a>";
    }
    if($pages > 1) {
        $str.="<a href='" . rewrite_url("space.php?" . $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='" . rewrite_url("space.php?" . $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='" . rewrite_url("space.php?" . $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='" . rewrite_url("space.php?" . $url . "pages=" . $i) . "'>" . $i . "</a>";
                }
            }
        }
    }
    if($pages < $pagejs) {
        $str.="<a href='" . rewrite_url("space.php?" . $url . "pages=" . ($pages+1)) . "' class='next' title='下一页'>&raquo;</a>";
    }
    if($pages < $pagejs-2) {
        $str.="<a href='" . rewrite_url("space.php?" . $url . "pages=" . $pagejs) . "' class='last' title='最后一页'>...&nbsp;" . $pagejs . "</a>";
    }
    while($row=$db->fetch_array($result)) {
    }
    $arr=array(
        $str,
        $result,
        $sql,
        $pagejs
    );
    return $arr;
}

function getwebpage($mysql, $pagesize, $url)
{
    global $db;
    $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='" . rewrite_url($url . "&pages=1") . "' class='last' title='首页'>1&nbsp;...</a>";
    }
    if($pages > 1) {
        $str.="<a href='" . rewrite_url($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='" . rewrite_url($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='" . rewrite_url($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='" . rewrite_url($url . "&pages=" . $i) . "'>" . $i . "</a>";
                }
            }
        }
    }
    if($pages < $pagejs) {
        $str.="<a href='" . rewrite_url($url . "&pages=" . ($pages+1)) . "' class='next' title='下一页'>&raquo;</a>";
    }
    if($pages < $pagejs-2) {
        $str.="<a href='" . rewrite_url($url . "&pages=" . $pagejs) . "' class='last' title='最后一页'>...&nbsp;" . $pagejs . "</a>";
    }
    while($row=$db->fetch_array($result)) {
    }
    $arr=array(
        $str,
        $result,
        $sql,
        $pagejs,
        $pages,
        $nums
    );
    return $arr;
}

function getwallpage($mysql, $pagesize, $url)
{
    global $db;
    $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=\"javascript:;\" onclick=\"wallLib.moreWall(" . $url . ",1);\" class='last' title='首页'>1&nbsp;...</a>";
    }
    if($pages > 1) {
        $str.="<a href=\"javascript:;\" onclick=\"wallLib.moreWall(" . $url . "," . ($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=\"javascript:;\" onclick=\"wallLib.moreWall(" . $url . "," . $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=\"javascript:;\" onclick=\"wallLib.moreWall(" . $url . "," . $i . ");\">" . $i . "</a>";
                    }
                }
            }
        } else {
            for($i=1; $i <= 8; $i++) {
                if($i == $pages) {
                    $str.="<strong title='第" . $i . "页'>" . $i . "</strong>";
                } else {
                    $str.="<a href=\"javascript:;\" onclick=\"wallLib.moreWall(" . $url . "," . $i . ");\">" . $i . "</a>";
                }
            }
        }
    }
    if($pages < $pagejs) {
        $str.="<a href=\"javascript:;\" onclick=\"wallLib.moreWall(" . $url . "," . ($pages+1) . ");\" class='next' title='下一页'>&raquo;</a>";
    }
    if($pages < $pagejs-2) {
        $str.="<a href=\"javascript:;\" onclick=\"wallLib.moreWall(" . $url . "," . $pagejs . ");\" class='last' title='最后一页'>...&nbsp;" . $pagejs . "</a>";
    }
    while($row=$db->fetch_array($result)) {
    }
    $arr=array(
        $str,
        $result,
        $sql,
        $pagejs
    );
    return $arr;
}

function getwebfavpage($mysql, $pagesize, $url)
{
    global $db;
    $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="";
    if($pagejs <= 6) {
        for($i=1; $i <= $pagejs; $i++) {
            if($i == $pages) {
                $str.="<li><a class=\"thispage\" href='" . rewrite_url($url . "&pages=" . $i) . "'><span>" . $i . "</span></a></li>";
            } else {
                $str.="<li><a href='" . rewrite_url($url . "&pages=" . $i) . "'><span>" . $i . "</span></a></li>";
            }
        }
    } else {
        if($pages >= 8) {
            for($i=$pages-3; $i <= $pages+4; $i++) {
                if($i <= $pagejs) {
                    if($i == $pages) {
                        $str.="<li><a class=\"thispage\" href='" . rewrite_url($url . "&pages=" . $i) . "'><span>" . $i . "</span></a></li>";
                    } else {
                        $str.="<li><a href='" . rewrite_url($url . "&pages=" . $i) . "'><span>" . $i . "</span></a></li>";
                    }
                }
            }
        } else {
            for($i=1; $i <= 8; $i++) {
                if($i == $pages) {
                    $str.="<li><a class=\"thispage\" href='" . rewrite_url($url . "&pages=" . $i) . "'><span>" . $i . "</span></a></li>";
                } else {
                    $str.="<li><a href='" . rewrite_url($url . "&pages=" . $i) . "'><span>" . $i . "</span></a></li>";
                }
            }
        }
    }
    while($row=$db->fetch_array($result)) {
    }
    $arr=array(
        $str,
        $result,
        $sql,
        $pagejs,
        $pages
    );
    return $arr;
}
?>