?php class comm { function checkLogin() { global $pp; if ($msg = $pp->isLogin()) { if (!isset($_SESSION["login"]["user"]) || !isset($_SESSION["login"]["pid"]) || $_SESSION["login"]["pid"] != $msg["id"]) { Response::sendRedirect("/login.php?go_to=" . urlencode($_SERVER["REQUEST_URI"])); } return $_SESSION["login"]; } Response::sendRedirect("/login.php?go_to=" . urlencode($_SERVER["REQUEST_URI"])); } //判断一个家伙是否登录了 function isLogin() { global $pp; if ($msg = $pp->isLogin()) { $msg["pid"] = $msg["id"]; return $msg; } return null; } // 得到图片存储表id function getTblId($userId) { $tblId = intval($userId)%10; if ($tblId > 9 || $tblId < 0) $tblId = 1; return $tblId; } //得到图片缩略图地址 function getTPath($path, $hostNo, $submitDate = null) { $full = comm::getFullPath($path, $hostNo); list($num) = explode(".", basename($full)); if ($submitDate == "" || @strtotime($submitDate) < strtotime("2005-09-09 02:10:10")) { return dirname($full) . "/{$num}_s.jpg"; } else { return dirname($full) . "/{$num}_t.jpg"; } } //得到加水印的图片地址 function getLPath($path, $hostNo, $submitDate = null) { $full = comm::getFullPath($path, $hostNo); list($num) = explode(".", basename($full)); if ($submitDate == "" || @strtotime($submitDate) < strtotime("2005-09-09 02:10:10")) { return dirname($full) . "/{$num}_s.jpg"; } else { return dirname($full) . "/{$num}_l.jpg"; } } //得到小图地址 function getSPath($path, $hostNo) { $full = comm::getFullPath($path, $hostNo); list($num) = explode(".", basename($full)); return dirname($full) . "/{$num}_s.jpg"; } //形象照 function getFace($pid) { $hostNo = ceil($pid/4000000); if ($hostNo < 1) $hostNo = 1; $str = $pid . "000"; return "http://face" . sprintf("%03d", $hostNo) . ".wangyou.com/" . $str[0] . $str[1] . "/" . $str[2] . $str[3] . "/" . $pid . "/"; } //小头像 function getIcon($pid) { $hostNo = ceil($pid/20000000); if ($hostNo < 1) $hostNo = 1; $str = $pid . "000"; return "http://icon" . sprintf("%03d", $hostNo) . ".wangyou.com/" . $str[0] . $str[1] . "/" . $str[2] . $str[3] . "/" . $pid . "/"; } //计算用户年龄 function getUserAge($date) { $birthday = date("Y-m-d",strtotime($date)); $t = (date("m-d",strtotime($birthday)) < date("m-d"))?0:-1; $age = date("Y") - date("Y",strtotime($birthday)) + $t; return $age; } //获得用户样式表路径 function getUserCss($mys) { return "/".$mys->UserCfgDir."/my.css"; } //获得用户样式表路径 function getUserCss1($mys) { if($mys->Style_type) { return "/".$mys->UserDir."/".$mys->Style.".css"; } else { return "/lib/css/s".$mys->Style.".css"; } } //获得用户样式表路径 function _get_user_css($mys) { if($mys->Style_type) { return $mys->UserDir."/".$mys->Style.".css"; } else { return $mys->doc_path."lib/css/s".$mys->Style.".css"; } } //获取鼠标路径 function getMousePath($mys) { if(is_object($mys)) { return "http://img2.wangyou.com/my/mouse/m".$mys->Cursor_id."/c.ani"; } else { $c_id = (int)$mys; if($c_id > 0) { return "\nbody{cursor:url('http://img2.wangyou.com/my/mouse/m{$c_id}/c.ani')}"; } } } //根据访问数返回图标 function getViewIcon($rv_) { $to_pv = 1; //定义多少个等级换一个草房 $to_floor = 4; //定义多少个草房换一个砖房 $to_villa = 16; //定义多少个草房换一个楼房 $_num["p1"] = 0; //初始化返回的草房数目 $_num["l1"] = 0; //初始化返回的砖房数目 $_num["b1"] = 0; //初始化返回的楼房数目 $_alt["p1"] = "平房"; //一级提示 $_alt["l1"] = "楼房"; //二级提示 $_alt["b1"] = "别墅"; //三级提示 $icon_path = "http://img2.wangyou.com/my/"; //定义输出图标的路经 $max_floor = 5; //定义输出楼房的最大直 $step = $to_villa*$max_floor; //定义输出楼房的最大直对应的等级 $unexpect_rv = $step*$step*10+30*$step; //定义人气直的最大直14040即为36个等级,四个楼房 $rv=(!is_numeric($rv_))?"0":intval($rv_); ($rv >= $unexpect_rv)?($rv = $unexpect_rv):""; $rv=(-10+sqrt(900+40*$rv))/20-1; #以下是人气直换算为等级的公式 ($rv % $to_pv ==0)?($rp=$rv / $to_pv):($rp=floor($rv / $to_pv)); $left_rv=10*($rp+1)*($rp+1)+30*($rp+1)-$rv_; //计算还剩多少人气达到下一级 //echo $rp; if($rp >= $to_floor) { if($rp >= $to_villa) { if($rp % $to_villa <> 0) { $_num["b1"] = floor($rp / $to_villa); $rl=$rp % $to_villa; if($rl >= 5) { $_num["l1"] = floor($rl / $to_floor); $_num["p1"] = $rl % $to_floor; } else $_num["p1"] = $rl; } else $_num["b1"] = $rp / $to_villa; } else { if($rp % $to_floor == 0) $_num["l1"] = $rp / $to_floor; else { $_num["l1"] = floor($rp / $to_floor); $_num["p1"] = $rp % $to_floor; } } } else $_num["p1"] = $rp; $num_arr = array_reverse($_num); $img_str = ""; foreach($num_arr as $k => $v) { $img_str.=str_repeat("".$_alt[$k]."(距离下一级还需要".floor($left_rv)."点人气值)",$num_arr[$k]); } //($img_str == "")?($img_str = "-"):""; return $img_str; } //获得用户得分 function getScore($pid) { global $_CONFIG; return 0; $score = @file_get_contents("{$_CONFIG['self']}/star/admin/get_score.php?id={$pid}"); $score = (!is_numeric($score))?"-":intval($score); return $score; } //获得用户目录 function getUserDir($un) { $md = md5(base64_encode(strtolower($un))); $user_dir = "un_ig/".substr($md,9,1).substr($md,6,1)."/".substr($md,3,1).substr($md,0,1)."/".substr($md,0,16); return $user_dir; } function getUserCfgDir($un) { $md = md5(base64_encode(strtolower($un))); $user_dir = "un_data/".substr($md,9,1).substr($md,6,1)."/".substr($md,3,1).substr($md,0,1)."/".substr($md,0,16); return $user_dir; } //从通行证取回用户资料,并添加用户 function insertUser($un) { global $_CONFIG; $sql = "select * from domain where username='{$un}' limit 1"; $db = new mysql(); $rs = $db->query($sql); if(empty($rs)) { if($_CONFIG["net"]) { $info_str = file_get_contents("{$_CONFIG['intranet_passport']}/interface/internal/getuserinfo.php?OUTER_SERVER=1&username={$un}&flag=".md5('my'.$un)); } else { $info_str = file_get_contents("{$_CONFIG['passport']}/interface/internal/getuserinfo.php?username={$un}&flag=".md5('my'.$un)); } if(trim($info_str)!="") { $ui = @unserialize($info_str); if(isset($ui["pid"])) { $ui["age"] = comm::getUserAge($ui['birthday']); $ui["title"] = $ui['nickname'] == "" ? $ui['username']:$ui['nickname']; $sql = "INSERT INTO domain (pid, username, domain_name, title, nickname, gender, age, from_area, submit_date, login_num, join_ip, status, show_num, astro,birthday) VALUES ({$ui['pid']}, '{$ui['username']}', '{$ui['username']}', '".addslashes($ui['title']."的个人地盘")."', '".addslashes($ui['nickname'])."',{$ui['gender']},{$ui['age']},'".addslashes($ui['place'])."',now(),0, '".Server::getIP()."',1,1,'{$ui['astro']}','{$ui['birthday']}')"; $db->query($sql); $db->query("insert into friends(pid, friend_pid, status) values({$ui['pid']},3271165,0)"); return array($ui['pid'],$ui['nickname']); } } } return 0; } //视频认证标志 function getVideoValidateIcon($v,$pid) { $re = ""; switch($v) { case 0: //还没有申请认证 //$re = "点击进行视频认证"; break; case 1: //审核中 //$re = "视频认证审核中..."; break; case 2: //审核通过 $re = "视频认证会员"; break; case 3: //未通过 //$re = "未通过认证, 点击再次进行视频认证"; break; } return $re; } function getVideoValidateCaption($v) { $re = ""; switch($v) { case 0: //还没有申请认证 //$re = "未认证"; break; case 1: //审核中 //$re = "认证审核中"; break; case 2: //审核通过 $re = "认证通过"; break; case 3: //未通过 //$re = "未认证"; break; } return $re; } //查询是站内消息个数 function getMsgNum($un) { global $_CONFIG; import("MessageClient"); return MessageClient::getNewNum($un); } //获得用户本站资料 function getUserInfo($pid,$flag=1) { $db = new mysql(); $rs = $db->query("SELECT * FROM domain WHERE pid={$pid} LIMIT 1"); if(!empty($rs)) { if($flag>0)//判断是否是接口调用 { $is_red = comm::isRed($pid); switch ($is_red) { case "2" : $red_pic= "red.gif"; $red_title ="鸿人"; break; case "1" : $red_pic= "red_outer.gif"; $red_title ="鸿外线"; break; case "0" : default : $red_pic= "host.gif"; $red_title ="主人"; break; } //在线判断 if($flag>1) { $online = comm::isUserOnline($pid); $keys = @array_keys($online); if(count($online) >0 && @in_array($pid,$keys) ) { $on_row = explode(">",$online[$pid][2]); $on_str = isset($on_row[1]) ? "看".$on_row[1] : ""; $title = "在线".$on_str."呢~"; $online_pic = "at_inline.gif"; $online_title = $title; $online_caption = "在线"; }else { $title = "下线了噢~"; $online_pic = "no_inline.gif"; $online_title = $title; $online_caption = "不在线"; } }else { $title = "下线了噢~"; $online_pic = "no_inline.gif"; $online_title = $title; $online_caption = "不在线"; } } //是否有形象照 $is_have_face_arr = comm::CheckUserFace($pid); $is_have_face = $is_have_face_arr[$pid] ; if ($is_have_face) $pic_is_face = ''; else $pic_is_face = "找TA要形象照"; $v = $rs[0]; $v_validateIcon = comm::getVideoValidateIcon($v["v_validate"],$pid); $sanguo = "" ; if($pid==10266803 && comm::getGamesg1($pid)==1){ } $u_data = array( "pid"=> $pid, "username"=> $v["username"], "nickname"=> $v["nickname"], "age"=> comm::getUserAge($v['birthday']), "is_have_face" => $is_have_face , "intro_is_face"=> $pic_is_face, "p_photo"=> comm::getFace($pid), "from_area"=> $v["from_area"], "gender"=> (($v["gender"]==1)?"帅哥":(($v["gender"]==2)?"美女":"未知")), "gender_class"=> (($v["gender"]==1)?"man":"woman"), "astro"=> $v["astro"]."座", "title"=> $v["title"], "view_num_icon"=> comm::getViewIcon($v["show_num"]), "view_num"=> $v["show_num"], "friend_num"=> $v["friend_num"], //comm::getFriendNum($pid), "fans_num"=> $v["fans_num"], "msg_num"=> 0,//comm::getMsgNum($v["username"]), "score_num"=> comm::getScore($pid), "note_content"=> nl2br(comm::desc($v["username"], $v["description"])), "v_validate_icon"=> $v_validateIcon, //视频认证标志 "v_validate_caption"=> comm::getVideoValidateCaption($v["v_validate"]), //视频认证标志 "status"=> $v["status"], "red_pic" => $red_pic, "red_caption" => $red_title, "online_pic" => $online_pic, "online_title" => $online_title, "online_caption" => $online_caption, "sanguo" => $sanguo ); } else { $u_data = array(); } return $u_data; } //生成select options function makeOptions($count,$sel=0,$start=1) { $out = ""; for($i=$start;$i<$count+$start;$i++) { $v = ($i==$sel)?" selected":""; $out .= ""; } return $out; } function slashes_arr($arr,$ac="add") { if(is_array($arr)) { $re = array(); foreach($arr as $k=>$v) { if(!is_array($v)) { $re[$k] = ($ac=="add")?addslashes($v):stripslashes($v); } else { $re[$k] = comm::slashes_arr($v,$ac); } } } else { $re = ($ac=="add")?addslashes($arr):stripslashes($arr); } return $re; } //字串截断 from pp old function. function m_substr($str, $len) { $ch_num = 0; $chr_len = strlen($str); if ($chr_len == min($len, $chr_len)) { return $str; //字符串长度小于截断长度,返回整个字串 } $ascii = 0; for ($i=0; $i<$len; $i++) { $ascii = ord($str[$i]); $ch_num ++; if (($ascii > 127) || ($ascii< 0)) { $ch_num ++; $i++; } } if ($ch_num%2 == 0) { return substr($str, 0, $len); } else { return substr($str, 0, $len - 1); } } // 截字符串到一定的长度,过多补.. **/ function substr($string, $length,$flag=true) { $new = string::left($string, $length, $flag); return ($new === $string)?$string:$new . ".."; } /** 得到一个家伙的个性宣言 **/ /** * $un 用户名 * $dd 数据库中的description字段数值 */ function desc($un, $dd) { //import("html"); $filename = comm::getUserDir($un) . "/cache/description.sav"; if(is_file($filename)) { $str = file_get_contents($filename); return preg_replace("/<(\/?script|\/?iframe)/i","<\\1", $str); } return preg_replace("/<(\/?script|\/?iframe)/i","<\\1", $dd); } /** * 得到左浮的tip */ function getTips() { $filename = "cache/system/tips.cache"; if (is_file($filename)) { return file_get_contents($filename); } return null; } //后台日志 function setLog($description) { $sql = "insert into admin_log(user_id,description,submit_date) values({$_SESSION['admin']['id']},'{$description}',now())"; $db = new mysql(); $db->query($sql); } //清除风格菜单缓存 2006-4-24 13:25 function clearMenuStyleListCache($cate_id) { $fn_t = "../cache/menu/c_{$cate_id}_1.cache"; $fn = "../cache/menu/c_{$cate_id}_*.cache"; if(file_exists($fn_t)) exec("/bin/rm -f {$fn}"); $fn_t = "../cache/menu/c_all_1.cache"; $fn = "../cache/menu/c_all_*.cache"; if(file_exists($fn_t)) exec("/bin/rm -f {$fn}"); } //清除用户风格菜单缓存 2006-4-28 19:51 function clearMenuUserStyleListCache($un) { if(!empty($un)) { $fn = "../".comm::getUserDir($un)."/menu_mycss.sav"; if(file_exists($fn)) unlink($fn); } } function getSelectFlash(&$tpl,$f_id) { global $db; //以下为处理flash输出 if($f_id > 0) { $fn = "cache/flash/"; if(!fso::folderExists($fn))fso::createFolder($fn); $fn .= "f{$f_id}"; if(!file_exists($fn.".sav")) { //print_r($css_settings); $rs = $db->query("SELECT * FROM flash WHERE id={$f_id}"); if(empty($rs))$rs=array(); $flash_cache = serialize($rs[0]); fso::write($fn.".sav",$flash_cache,"w"); } $property = trim(@file_get_contents($fn.".sav")); if($property<>"") { $flash_settings = unserialize($property); if(is_array($flash_settings)) { $tpl->setVar("flash_js","\n"); } } } } function getUserActivity($pid) { $url = "http://my.wangyou.com/star/cache2/".ceil($pid/2000) . "/" . ceil($pid/2000/2000) . "/".$pid; $t = @file_get_contents($url); $cap = ""; switch($t) { /* case 1: $cap = "超级美女地主"; break; case 2: $cap = "超级帅气地主"; break; case 3: $cap = "超级搞笑地主"; break; case 4: $cap = "超级阳光地主"; break; case 5: $cap = "超级猥琐地主"; break; case 6: $cap = "超级找抽地主"; break; //*/ case 1: case 2: case 3: case 4: case 5: case 6: $cap = "超级地主"; } if(!empty($cap)) { $re = "我正在参与{$cap}活动"; } else { $re = ""; } return $re; } //清除留言缓存 function clearMessageCache($pid,$flag) { if(file_exists("cache/guestbook/".ceil($pid/2000)."/".ceil($pid/2000/2000)."/".$pid."_".$flag.".html")) { unlink("cache/guestbook/".ceil($pid/2000)."/".ceil($pid/2000/2000)."/".$pid."_".$flag.".html"); } } //获得用户样式表路径 function get_user_css_dir($mys) { if($mys->Style_type) { return $mys->UserDir."/".$mys->Style.".css"; } else { return $mys->doc_path."lib/css/s".$mys->Style.".css"; } } //向my.css写入用户选择的鼠标地址 function modiffCss($mys) { if($mys->Style_type) { $fn = $mys->UserCfgDir."/my_css.sav"; if (file_exists($fn)) { $css_settings = unserialize(fso::read($fn)); //print_r($css_settings); $tpl = new Template("template"); $tpl->setFile("main","my_css_tpl.css"); $tpl->setVar($css_settings); //$tpl->save( $mys->UserDir."/my.css", "main"); $tpl->save( $mys->UserDataPath."/my.css", "main");//备份 } } else { //copy(ltrim(comm::getUserCss1($mys),"/") , $mys->UserDir."/my.css"); copy(ltrim(comm::getUserCss1($mys),"/") , $mys->UserDataPath."/my.css"); } $type=$mys->Cursor_type; $path = ""; if($type==0) { $cursor=$mys->Cursor_id; if($cursor > 0) { $path = comm::getMousePath($mys); //fso::write($mys->UserDir."/my.css","\r\n body{cursor:url(".$path.");}", "a+"); fso::write($mys->UserDataPath."/my.css","\r\n body{cursor:url(".$path.");}", "a+"); } } elseif($type==1) { $path = $mys->Cursor_url; //fso::write($mys->UserDir."/my.css","\r\n body{cursor:url(".$path.");}", "a+"); fso::write($mys->UserDataPath."/my.css","\r\n body{cursor:url(".$path.");}", "a+"); } return $path; } //向my.css写入用户选择的鼠标地址 function my_space_mod_css($mys) { if($mys->Style_type) { $fn = $mys->doc_path.$mys->UserCfgDir."/my_css.sav"; if (file_exists($fn)) { $css_settings = unserialize(fso::read($fn)); //print_r($css_settings); $tpl = new Template("../template"); $tpl->setFile("main","my_css_tpl.css"); $tpl->setVar($css_settings); //$tpl->save( $mys->UserDir."/my.css", "main"); $tpl->save($mys->UserDataPath."/my.css", "main");//备份 } } else { copy(comm::_get_user_css($mys) , $mys->UserDataPath."/my.css"); } $type=$mys->Cursor_type; $path = ""; if($type==0) { $cursor=$mys->Cursor_id; if($cursor > 0) { $path = comm::getMousePath($mys); //fso::write($mys->UserDir."/my.css","\r\n body{cursor:url(".$path.");}", "a+"); fso::write($mys->UserDataPath."/my.css","\r\n body{cursor:url(".$path.");}", "a+"); } } elseif($type==1) { $path = $mys->Cursor_url; //fso::write($mys->UserDir."/my.css","\r\n body{cursor:url(".$path.");}", "a+"); fso::write($mys->UserDataPath."/my.css","\r\n body{cursor:url(".$path.");}", "a+"); } return $path; } //清除图片缓存 function clearPhotoCache($url) { $cmd = "/bin/bash /usr/local/squid/bin/rm_cache.sh ".$url; //echo "$cmd
\n";exit; exec($cmd,$pp); return true; } //得到在线用户 function isOnline($data) { if(empty($data))return array(); $pid = array(); foreach ($data as $row) { $pid[] = $row["pid"]; } //$pid[]='2201606'; //print_r($pid); import("online"); $online = new Online(); return $online->get($pid,option_path); } //得到是否在鸿人堂出现 0.主人 ,1.鸿外线 ,2 ,鸿人 function isRed($pid) { global $_CONFIG; $url = $_CONFIG["red"]."/interface/is_red.php?pid={$pid}"; $is_red = @file_get_contents($url); return $is_red; } //查询单个用户是否在线. function isUserOnline($pid) { if(is_array($pid)) { $pids = $pid; }else { $pids[] = $pid; } //$pid[]='2201606'; //print_r($pid); import("online"); $online = new Online(); return $online->get($pids,option_path); } //得到通行证的用户详细信息 function getDxcUserInfo($username) { global $_CONFIG; $data = @file_get_contents($_CONFIG["dxc"] . "/request.php?username=" . urlencode($username) . "&package=passport&node=xml.profile&pw=aixnaituoygnaw&requester=my/profile.php".EXTRA_ARGS); import("DXC"); $info = DXC::decode($data); return $info; } function toutf8($str) { $str = mb_convert_encoding($str,"utf-8","gbk"); $convmap = array(0x0080, 0xffff, 0x0000, 0xffff); //0x0026, 0x0026, 0x0000, 0xffff); <-这个是转&号为& $str = mb_encode_numericentity($str, $convmap, "utf-8"); return $str; } //判断用户是否有Icon;返回一个数组 function CheckUserIcon($pid) { import("IconQueryClient"); return IconQueryClient::query($pid); } //判断用户是否有形象照片;返回一个数组 function CheckUserFace($pid) { import("FaceQueryClient"); return FaceQueryClient::query($pid); } //清楚特殊字符 function clearStr($str) { $str=strip_tags($str); $str=str_replace("'","’",$str); $str=str_replace("\n","",$str); $str=str_replace("\t","",$str); $str=str_replace("\r","",$str); $str=str_replace(",",",",$str); $str=str_replace("(","(",$str); $str=str_replace(")",")",$str); $str=str_replace('"',"",$str); //$str=addslashes($str); return $str; } //查询是站内消息个数 function getMessageNum($username) { import("MessageClient"); return MessageClient::getNewNum($username); } //发送WEB短消息 function SendWebMsg($subject,$to,$username,$from,$body,$ad_flag='my.good') { global $_CONFIG; import("MessageClient"); $mClient = new MessageClient(); $mClient->setFrom($username, $from); $mClient->setTo($to); $mClient->setMessage($subject, $body); $mClient->setFlagId($ad_flag); $result = $mClient->send(); return $result; } //网友站内消息发送成功记录日志 function mailSuccessLog($subject,$to , $username , $nickname, $body){ $path = 'send_mail_info/success_mail/'.date('Y-m-d').".log"; $ee = '给:' . $to . ':的信:' . $subject . ':发送成功,于' . $username . '<' . $nickname . ">\n"; comm::w2Log($path , $ee); } //发送消息失败记录日志 function mailFaultyLog($subject,$to , $username , $nickname , $body){ $path = 'send_mail_info/fault_mail/'.date('Y-m-d').".log"; $ee = '给:'.$to.':的信:'.$subject.':发送错误,于'.$username.'<'.$nickname.">\n"; comm::w2Log($path , $ee); } function w2Log($path,$content){ $path = realpath(dirname(__FILE__)).'/../../logs/'.$path; if(!is_dir(dirname($path))) fso::createFolder(dirname($path)); fso::write($path , $content); //file_put_contents($path , $content , FILE_APPEND); return false; } //得到用户信息-普通用法 by hanshu function getUserInfoByPid($pid=0 , $db=0){ if (!($pid&&$db)) return array(); $sql = 'select * from domain where pid='.$pid; $db->query($sql); $result = $db->query($sql , MYSQL_ASSOC); if(count($result) == 0) return array(); $result = $result[0]; return $result; } //得到用户信息-普通用法 by hanshu function getUserInfoByUsername($username=0 , $db=0){ if (!($username&&$db)) return array(); $username = trim($username); $sql = 'select * from domain where username like binary \''.$username.'\' limit 1'; $db->query($sql); $result = $db->query($sql , MYSQL_ASSOC); if(count($result) == 0) return array(); $result = $result[0]; return $result; } //得到黑名单用户 function getBlackUser($file,&$pid,&$username) { if(is_file($file)) { $msg = unserialize(@file_get_contents($file)); foreach ($msg as $k => $row) { $pid[] = $row["pid"]; $username[] = $row["username"]; } } } function getVisitorData($pid,$size) { import("VisitorClient"); $client = new VisitorClient(); $arr = $client->getVisitor($pid, $size);//size:条数 if (empty($arr))return array("result"=>1, "msg"=>"", "count"=>0,"online" => array() , "data" => array() ); //print_r($arr);//二维数组 $pids = array(); foreach ($arr as $row) { $pids[] = $row["g_pid"]; $data[] = array( "pid" => $row["g_pid"], "username" => $row["g_username"], "nickname" => $row["g_nickname"] == "" ? $row["g_username"] : $row["g_nickname"], "gender" => $row["g_gender"], "updatedtime" => $row["updatedtime"], "icon" => comm::getIcon($row["g_pid"]), ); } $is_online = comm::isUserOnline($pids);//查询在线信息. return array("result"=>1, "msg"=>"", "count"=>count($data),"online" => $is_online , "data" => $data); } /* 缓存控制函数, $content --> if it's empty ,then fetch,isn't write. $timeout -->cache expire time on second,10 minun = 60*10 $cache_path -->cache path */ function cache_control($content='' , $cache_path = '',$timeout = 3600){ //echo dirname(__FILE__).'/../../cache/'.$cache_path.'
'; $cache_path = realpath(dirname(__FILE__)).'/../../cache/'.$cache_path; //read if(empty($content) and is_file($cache_path)){ $is_vaild_file = filesize($cache_path) > 0; $is_timeout = filemtime($cache_path) > (time()-$timeout); if($is_vaild_file AND $is_timeout){ return file_get_contents($cache_path); } }else{ //write if(!is_dir(dirname($cache_path))) fso::createFolder(dirname($cache_path)); file_put_contents($cache_path , $content); return false; } return false; } //用户等级系统. function getUserLevel($pid) { import("RedLevelClient"); $red = new RedLevelClient(); $level = $red->getLevel($pid); // 取得级别(0-15),参数 pid return $level; } function getUserLevelCaption($level) { import("RedLevelClient"); return RedLevelClient::getDesc($level); } function getUserLevelStarNum($level) { import("RedLevelClient"); return RedLevelClient::getStarsNum($level); } function getUserLevelClass($level) { import("RedLevelClient"); $ret = RedLevelClient::getDesc($level,true); return chr(ord("a")+$ret["num"]-1); } function getUserLevelImg($level) { import("RedLevelClient"); if ($level == 0) $level = 1; $img = $red->getStars($level); return $img; } function getTagUrl($tag_type,$key_word,$url) { if($url !="") return $url; $domian = "http://search.wangyou.com/"; $style = array( "v" => "v,id,video,", "k" => "k,id,k,", "p" => "photo,id,", "blog" => "blog,id,", "f" => "f,", "boke" => "boke,id,", "q" => "q,id," ); if(isset($style[$tag_type])) { return $domian.$style[$tag_type]. urlencode($key_word) . ".html"; }else { return "#"; } } //设置背景音乐 function setBackgroundMusic($pid,$arr) { if($pid ==0 || count($arr) ==0)return false; common::dbConn(); $db = new mysql(); $rs = $db->query("SELECT * FROM bg_music WHERE pid={$pid} LIMIT 1"); if(count($rs)>0) { //如果仅关闭背景音乐,那么不替换以前的歌曲路径 if($arr['enable']){ $sql = "update bg_music set song_id= '{$arr["song_id"]}', enable='{$arr["enable"]}', url='{$arr["url"]}',attribute='{$arr["attribute"]}' where pid={$pid} "; }else{ $sql = "update bg_music set enable='0' where pid={$pid} "; } }else { $sql = "insert into bg_music (pid,song_id,enable,url,attribute,submit_date) values('{$pid}','{$arr["song_id"]}','{$arr["enable"]}','{$arr["url"]}','{$arr["attribute"]}',now())"; } //die($sql);exit; $db->query($sql); return true; } function getBackgroundMusic($pid) { if($pid ==0)return false; common::dbConn(); $db = new mysql(); $rs = $db->query("SELECT * FROM bg_music WHERE pid={$pid} LIMIT 1",MYSQL_ASSOC); if(count($rs)>0) return $rs[0]; return array(); } //设置页面参数 function doBackgroundMusic($pid,&$tpl) { if($pid ==0)return false; $arr = comm::getBackgroundMusic($pid); if(empty($arr)) { $tpl->setVar("BackgroundMusicStat","1"); $tpl->setVar("BackgroundMusicStatCaption","打开"); return false; } if($arr["enable"] == 0) { $stat = "1"; $caption = "打开"; }else { $stat = "0"; $caption = "关闭"; comm::doBackgroundMusicPlayer($tpl,$arr); } $tpl->setVar("BackgroundMusicStat","$stat"); $tpl->setVar("BackgroundMusicStatCaption","$caption"); return false; } //设置播放器 function doBackgroundMusicPlayer(&$tpl,$arr) { //$tpl = new Template("template");//写程序用 $url = $arr["url"]; $url = str_replace("wangyou.com/","wangyou.com/".time()."/",$url);//防盗链 $infos = @pathinfo($url); $extension = (isset($infos["extension"]))?strtolower($infos["extension"]):""; if (!in_array($extension, array("mp3", "rm", "wma","flv"))) { return false; } switch (strtolower($extension)) { case "flv": $player = "play/flv_one_v3.html";break; case "wma": case "mp3": $player = "play/mediaplay_one_v3.html";break; default: $player = "play/realplay_one_v3.html"; } $tpl->setFile("bgplayer",$player); $tpl->setFile("PlayImg","play/play_img.html"); $tpl->parse("BackgroundMusicPlayImg", "PlayImg"); $tpl->setVar("url",$url); $tpl->parse("BackgroundMusicPlayer","bgplayer"); return true; } function _get_gudie_k_list($pid){ return 'gudie/song_list/'.ceil($pid/2).'/'.ceil($pid/3).'/'.ceil($pid/4).'/'.$pid.'.list'; } function getOkSongList($pid) { global $_CONFIG; $pid = abs($pid); if($pid == 0) return array(); $path = comm::_get_gudie_k_list($pid); //cache_control($content='' , $cache_path = '',$timeout = 3600) $ee = comm::cache_control('' , $path , 600); if($ee !== false) return unserialize($ee);; $url = $_CONFIG['ok'].'/interface/get_song_list_from_pid.php?pid='.$pid; $ee = @file_get_contents($url); $ee = trim($ee); if(empty($ee)) return array(); $ee = unserialize($ee); if(count($ee) == 0) return array(); comm::cache_control(serialize($ee) , $path , 600); return $ee; } //屏蔽的关键字 function chkKeyWords($str) { //echo "{$str}";exit; $words = array("成人电影","成人小说","做爱","作爱","强奸","换妻","交换女友","淫欲","祼体","性交","春宫图","菊花蕾","鸡巴","屁眼","抽插","活塞运动","肉棍","泄身","鸡鸡","小穴","浪穴","套动","套弄","自慰","打手枪"); foreach ($words as $key) { if(strpos($str,$key)=== false) continue; else return false; } return true; } function getGamesg1($pid){ $result = intval(file_get_contents("http://gamesg1.wangyou.com/interface/isgamesg1.php?pid={$pid}")); return $result; } } ?> ?php class comm { function checkLogin() { global $pp; if ($msg = $pp->isLogin()) { if (!isset($_SESSION["login"]["user"]) || !isset($_SESSION["login"]["pid"]) || $_SESSION["login"]["pid"] != $msg["id"]) { Response::sendRedirect("/login.php?go_to=" . urlencode($_SERVER["REQUEST_URI"])); } return $_SESSION["login"]; } Response::sendRedirect("/login.php?go_to=" . urlencode($_SERVER["REQUEST_URI"])); } //判断一个家伙是否登录了 function isLogin() { global $pp; if ($msg = $pp->isLogin()) { $msg["pid"] = $msg["id"]; return $msg; } return null; } // 得到图片存储表id function getTblId($userId) { $tblId = intval($userId)%10; if ($tblId > 9 || $tblId < 0) $tblId = 1; return $tblId; } //得到图片缩略图地址 function getTPath($path, $hostNo, $submitDate = null) { $full = comm::getFullPath($path, $hostNo); list($num) = explode(".", basename($full)); if ($submitDate == "" || @strtotime($submitDate) < strtotime("2005-09-09 02:10:10")) { return dirname($full) . "/{$num}_s.jpg"; } else { return dirname($full) . "/{$num}_t.jpg"; } } //得到加水印的图片地址 function getLPath($path, $hostNo, $submitDate = null) { $full = comm::getFullPath($path, $hostNo); list($num) = explode(".", basename($full)); if ($submitDate == "" || @strtotime($submitDate) < strtotime("2005-09-09 02:10:10")) { return dirname($full) . "/{$num}_s.jpg"; } else { return dirname($full) . "/{$num}_l.jpg"; } } //得到小图地址 function getSPath($path, $hostNo) { $full = comm::getFullPath($path, $hostNo); list($num) = explode(".", basename($full)); return dirname($full) . "/{$num}_s.jpg"; } //形象照 function getFace($pid) { $hostNo = ceil($pid/4000000); if ($hostNo < 1) $hostNo = 1; $str = $pid . "000"; return "http://face" . sprintf("%03d", $hostNo) . ".wangyou.com/" . $str[0] . $str[1] . "/" . $str[2] . $str[3] . "/" . $pid . "/"; } //小头像 function getIcon($pid) { $hostNo = ceil($pid/20000000); if ($hostNo < 1) $hostNo = 1; $str = $pid . "000"; return "http://icon" . sprintf("%03d", $hostNo) . ".wangyou.com/" . $str[0] . $str[1] . "/" . $str[2] . $str[3] . "/" . $pid . "/"; } //计算用户年龄 function getUserAge($date) { $birthday = date("Y-m-d",strtotime($date)); $t = (date("m-d",strtotime($birthday)) < date("m-d"))?0:-1; $age = date("Y") - date("Y",strtotime($birthday)) + $t; return $age; } //获得用户样式表路径 function getUserCss($mys) { return "/".$mys->UserCfgDir."/my.css"; } //获得用户样式表路径 function getUserCss1($mys) { if($mys->Style_type) { return "/".$mys->UserDir."/".$mys->Style.".css"; } else { return "/lib/css/s".$mys->Style.".css"; } } //获得用户样式表路径 function _get_user_css($mys) { if($mys->Style_type) { return $mys->UserDir."/".$mys->Style.".css"; } else { return $mys->doc_path."lib/css/s".$mys->Style.".css"; } } //获取鼠标路径 function getMousePath($mys) { if(is_object($mys)) { return "http://img2.wangyou.com/my/mouse/m".$mys->Cursor_id."/c.ani"; } else { $c_id = (int)$mys; if($c_id > 0) { return "\nbody{cursor:url('http://img2.wangyou.com/my/mouse/m{$c_id}/c.ani')}"; } } } //根据访问数返回图标 function getViewIcon($rv_) { $to_pv = 1; //定义多少个等级换一个草房 $to_floor = 4; //定义多少个草房换一个砖房 $to_villa = 16; //定义多少个草房换一个楼房 $_num["p1"] = 0; //初始化返回的草房数目 $_num["l1"] = 0; //初始化返回的砖房数目 $_num["b1"] = 0; //初始化返回的楼房数目 $_alt["p1"] = "平房"; //一级提示 $_alt["l1"] = "楼房"; //二级提示 $_alt["b1"] = "别墅"; //三级提示 $icon_path = "http://img2.wangyou.com/my/"; //定义输出图标的路经 $max_floor = 5; //定义输出楼房的最大直 $step = $to_villa*$max_floor; //定义输出楼房的最大直对应的等级 $unexpect_rv = $step*$step*10+30*$step; //定义人气直的最大直14040即为36个等级,四个楼房 $rv=(!is_numeric($rv_))?"0":intval($rv_); ($rv >= $unexpect_rv)?($rv = $unexpect_rv):""; $rv=(-10+sqrt(900+40*$rv))/20-1; #以下是人气直换算为等级的公式 ($rv % $to_pv ==0)?($rp=$rv / $to_pv):($rp=floor($rv / $to_pv)); $left_rv=10*($rp+1)*($rp+1)+30*($rp+1)-$rv_; //计算还剩多少人气达到下一级 //echo $rp; if($rp >= $to_floor) { if($rp >= $to_villa) { if($rp % $to_villa <> 0) { $_num["b1"] = floor($rp / $to_villa); $rl=$rp % $to_villa; if($rl >= 5) { $_num["l1"] = floor($rl / $to_floor); $_num["p1"] = $rl % $to_floor; } else $_num["p1"] = $rl; } else $_num["b1"] = $rp / $to_villa; } else { if($rp % $to_floor == 0) $_num["l1"] = $rp / $to_floor; else { $_num["l1"] = floor($rp / $to_floor); $_num["p1"] = $rp % $to_floor; } } } else $_num["p1"] = $rp; $num_arr = array_reverse($_num); $img_str = ""; foreach($num_arr as $k => $v) { $img_str.=str_repeat("".$_alt[$k]."(距离下一级还需要".floor($left_rv)."点人气值)",$num_arr[$k]); } //($img_str == "")?($img_str = "-"):""; return $img_str; } //获得用户得分 function getScore($pid) { global $_CONFIG; return 0; $score = @file_get_contents("{$_CONFIG['self']}/star/admin/get_score.php?id={$pid}"); $score = (!is_numeric($score))?"-":intval($score); return $score; } //获得用户目录 function getUserDir($un) { $md = md5(base64_encode(strtolower($un))); $user_dir = "un_ig/".substr($md,9,1).substr($md,6,1)."/".substr($md,3,1).substr($md,0,1)."/".substr($md,0,16); return $user_dir; } function getUserCfgDir($un) { $md = md5(base64_encode(strtolower($un))); $user_dir = "un_data/".substr($md,9,1).substr($md,6,1)."/".substr($md,3,1).substr($md,0,1)."/".substr($md,0,16); return $user_dir; } //从通行证取回用户资料,并添加用户 function insertUser($un) { global $_CONFIG; $sql = "select * from domain where username='{$un}' limit 1"; $db = new mysql(); $rs = $db->query($sql); if(empty($rs)) { if($_CONFIG["net"]) { $info_str = file_get_contents("{$_CONFIG['intranet_passport']}/interface/internal/getuserinfo.php?OUTER_SERVER=1&username={$un}&flag=".md5('my'.$un)); } else { $info_str = file_get_contents("{$_CONFIG['passport']}/interface/internal/getuserinfo.php?username={$un}&flag=".md5('my'.$un)); } if(trim($info_str)!="") { $ui = @unserialize($info_str); if(isset($ui["pid"])) { $ui["age"] = comm::getUserAge($ui['birthday']); $ui["title"] = $ui['nickname'] == "" ? $ui['username']:$ui['nickname']; $sql = "INSERT INTO domain (pid, username, domain_name, title, nickname, gender, age, from_area, submit_date, login_num, join_ip, status, show_num, astro,birthday) VALUES ({$ui['pid']}, '{$ui['username']}', '{$ui['username']}', '".addslashes($ui['title']."的个人地盘")."', '".addslashes($ui['nickname'])."',{$ui['gender']},{$ui['age']},'".addslashes($ui['place'])."',now(),0, '".Server::getIP()."',1,1,'{$ui['astro']}','{$ui['birthday']}')"; $db->query($sql); $db->query("insert into friends(pid, friend_pid, status) values({$ui['pid']},3271165,0)"); return array($ui['pid'],$ui['nickname']); } } } return 0; } //视频认证标志 function getVideoValidateIcon($v,$pid) { $re = ""; switch($v) { case 0: //还没有申请认证 //$re = "点击进行视频认证"; break; case 1: //审核中 //$re = "视频认证审核中..."; break; case 2: //审核通过 $re = "视频认证会员"; break; case 3: //未通过 //$re = "未通过认证, 点击再次进行视频认证"; break; } return $re; } function getVideoValidateCaption($v) { $re = ""; switch($v) { case 0: //还没有申请认证 //$re = "未认证"; break; case 1: //审核中 //$re = "认证审核中"; break; case 2: //审核通过 $re = "认证通过"; break; case 3: //未通过 //$re = "未认证"; break; } return $re; } //查询是站内消息个数 function getMsgNum($un) { global $_CONFIG; import("MessageClient"); return MessageClient::getNewNum($un); } //获得用户本站资料 function getUserInfo($pid,$flag=1) { $db = new mysql(); $rs = $db->query("SELECT * FROM domain WHERE pid={$pid} LIMIT 1"); if(!empty($rs)) { if($flag>0)//判断是否是接口调用 { $is_red = comm::isRed($pid); switch ($is_red) { case "2" : $red_pic= "red.gif"; $red_title ="鸿人"; break; case "1" : $red_pic= "red_outer.gif"; $red_title ="鸿外线"; break; case "0" : default : $red_pic= "host.gif"; $red_title ="主人"; break; } //在线判断 if($flag>1) { $online = comm::isUserOnline($pid); $keys = @array_keys($online); if(count($online) >0 && @in_array($pid,$keys) ) { $on_row = explode(">",$online[$pid][2]); $on_str = isset($on_row[1]) ? "看".$on_row[1] : ""; $title = "在线".$on_str."呢~"; $online_pic = "at_inline.gif"; $online_title = $title; $online_caption = "在线"; }else { $title = "下线了噢~"; $online_pic = "no_inline.gif"; $online_title = $title; $online_caption = "不在线"; } }else { $title = "下线了噢~"; $online_pic = "no_inline.gif"; $online_title = $title; $online_caption = "不在线"; } } //是否有形象照 $is_have_face_arr = comm::CheckUserFace($pid); $is_have_face = $is_have_face_arr[$pid] ; if ($is_have_face) $pic_is_face = ''; else $pic_is_face = "找TA要形象照"; $v = $rs[0]; $v_validateIcon = comm::getVideoValidateIcon($v["v_validate"],$pid); $sanguo = "" ; if($pid==10266803 && comm::getGamesg1($pid)==1){ } $u_data = array( "pid"=> $pid, "username"=> $v["username"], "nickname"=> $v["nickname"], "age"=> comm::getUserAge($v['birthday']), "is_have_face" => $is_have_face , "intro_is_face"=> $pic_is_face, "p_photo"=> comm::getFace($pid), "from_area"=> $v["from_area"], "gender"=> (($v["gender"]==1)?"帅哥":(($v["gender"]==2)?"美女":"未知")), "gender_class"=> (($v["gender"]==1)?"man":"woman"), "astro"=> $v["astro"]."座", "title"=> $v["title"], "view_num_icon"=> comm::getViewIcon($v["show_num"]), "view_num"=> $v["show_num"], "friend_num"=> $v["friend_num"], //comm::getFriendNum($pid), "fans_num"=> $v["fans_num"], "msg_num"=> 0,//comm::getMsgNum($v["username"]), "score_num"=> comm::getScore($pid), "note_content"=> nl2br(comm::desc($v["username"], $v["description"])), "v_validate_icon"=> $v_validateIcon, //视频认证标志 "v_validate_caption"=> comm::getVideoValidateCaption($v["v_validate"]), //视频认证标志 "status"=> $v["status"], "red_pic" => $red_pic, "red_caption" => $red_title, "online_pic" => $online_pic, "online_title" => $online_title, "online_caption" => $online_caption, "sanguo" => $sanguo ); } else { $u_data = array(); } return $u_data; } //生成select options function makeOptions($count,$sel=0,$start=1) { $out = ""; for($i=$start;$i<$count+$start;$i++) { $v = ($i==$sel)?" selected":""; $out .= ""; } return $out; } function slashes_arr($arr,$ac="add") { if(is_array($arr)) { $re = array(); foreach($arr as $k=>$v) { if(!is_array($v)) { $re[$k] = ($ac=="add")?addslashes($v):stripslashes($v); } else { $re[$k] = comm::slashes_arr($v,$ac); } } } else { $re = ($ac=="add")?addslashes($arr):stripslashes($arr); } return $re; } //字串截断 from pp old function. function m_substr($str, $len) { $ch_num = 0; $chr_len = strlen($str); if ($chr_len == min($len, $chr_len)) { return $str; //字符串长度小于截断长度,返回整个字串 } $ascii = 0; for ($i=0; $i<$len; $i++) { $ascii = ord($str[$i]); $ch_num ++; if (($ascii > 127) || ($ascii< 0)) { $ch_num ++; $i++; } } if ($ch_num%2 == 0) { return substr($str, 0, $len); } else { return substr($str, 0, $len - 1); } } // 截字符串到一定的长度,过多补.. **/ function substr($string, $length,$flag=true) { $new = string::left($string, $length, $flag); return ($new === $string)?$string:$new . ".."; } /** 得到一个家伙的个性宣言 **/ /** * $un 用户名 * $dd 数据库中的description字段数值 */ function desc($un, $dd) { //import("html"); $filename = comm::getUserDir($un) . "/cache/description.sav"; if(is_file($filename)) { $str = file_get_contents($filename); return preg_replace("/<(\/?script|\/?iframe)/i","<\\1", $str); } return preg_replace("/<(\/?script|\/?iframe)/i","<\\1", $dd); } /** * 得到左浮的tip */ function getTips() { $filename = "cache/system/tips.cache"; if (is_file($filename)) { return file_get_contents($filename); } return null; } //后台日志 function setLog($description) { $sql = "insert into admin_log(user_id,description,submit_date) values({$_SESSION['admin']['id']},'{$description}',now())"; $db = new mysql(); $db->query($sql); } //清除风格菜单缓存 2006-4-24 13:25 function clearMenuStyleListCache($cate_id) { $fn_t = "../cache/menu/c_{$cate_id}_1.cache"; $fn = "../cache/menu/c_{$cate_id}_*.cache"; if(file_exists($fn_t)) exec("/bin/rm -f {$fn}"); $fn_t = "../cache/menu/c_all_1.cache"; $fn = "../cache/menu/c_all_*.cache"; if(file_exists($fn_t)) exec("/bin/rm -f {$fn}"); } //清除用户风格菜单缓存 2006-4-28 19:51 function clearMenuUserStyleListCache($un) { if(!empty($un)) { $fn = "../".comm::getUserDir($un)."/menu_mycss.sav"; if(file_exists($fn)) unlink($fn); } } function getSelectFlash(&$tpl,$f_id) { global $db; //以下为处理flash输出 if($f_id > 0) { $fn = "cache/flash/"; if(!fso::folderExists($fn))fso::createFolder($fn); $fn .= "f{$f_id}"; if(!file_exists($fn.".sav")) { //print_r($css_settings); $rs = $db->query("SELECT * FROM flash WHERE id={$f_id}"); if(empty($rs))$rs=array(); $flash_cache = serialize($rs[0]); fso::write($fn.".sav",$flash_cache,"w"); } $property = trim(@file_get_contents($fn.".sav")); if($property<>"") { $flash_settings = unserialize($property); if(is_array($flash_settings)) { $tpl->setVar("flash_js","\n"); } } } } function getUserActivity($pid) { $url = "http://my.wangyou.com/star/cache2/".ceil($pid/2000) . "/" . ceil($pid/2000/2000) . "/".$pid; $t = @file_get_contents($url); $cap = ""; switch($t) { /* case 1: $cap = "超级美女地主"; break; case 2: $cap = "超级帅气地主"; break; case 3: $cap = "超级搞笑地主"; break; case 4: $cap = "超级阳光地主"; break; case 5: $cap = "超级猥琐地主"; break; case 6: $cap = "超级找抽地主"; break; //*/ case 1: case 2: case 3: case 4: case 5: case 6: $cap = "超级地主"; } if(!empty($cap)) { $re = "我正在参与{$cap}活动"; } else { $re = ""; } return $re; } //清除留言缓存 function clearMessageCache($pid,$flag) { if(file_exists("cache/guestbook/".ceil($pid/2000)."/".ceil($pid/2000/2000)."/".$pid."_".$flag.".html")) { unlink("cache/guestbook/".ceil($pid/2000)."/".ceil($pid/2000/2000)."/".$pid."_".$flag.".html"); } } //获得用户样式表路径 function get_user_css_dir($mys) { if($mys->Style_type) { return $mys->UserDir."/".$mys->Style.".css"; } else { return $mys->doc_path."lib/css/s".$mys->Style.".css"; } } //向my.css写入用户选择的鼠标地址 function modiffCss($mys) { if($mys->Style_type) { $fn = $mys->UserCfgDir."/my_css.sav"; if (file_exists($fn)) { $css_settings = unserialize(fso::read($fn)); //print_r($css_settings); $tpl = new Template("template"); $tpl->setFile("main","my_css_tpl.css"); $tpl->setVar($css_settings); //$tpl->save( $mys->UserDir."/my.css", "main"); $tpl->save( $mys->UserDataPath."/my.css", "main");//备份 } } else { //copy(ltrim(comm::getUserCss1($mys),"/") , $mys->UserDir."/my.css"); copy(ltrim(comm::getUserCss1($mys),"/") , $mys->UserDataPath."/my.css"); } $type=$mys->Cursor_type; $path = ""; if($type==0) { $cursor=$mys->Cursor_id; if($cursor > 0) { $path = comm::getMousePath($mys); //fso::write($mys->UserDir."/my.css","\r\n body{cursor:url(".$path.");}", "a+"); fso::write($mys->UserDataPath."/my.css","\r\n body{cursor:url(".$path.");}", "a+"); } } elseif($type==1) { $path = $mys->Cursor_url; //fso::write($mys->UserDir."/my.css","\r\n body{cursor:url(".$path.");}", "a+"); fso::write($mys->UserDataPath."/my.css","\r\n body{cursor:url(".$path.");}", "a+"); } return $path; } //向my.css写入用户选择的鼠标地址 function my_space_mod_css($mys) { if($mys->Style_type) { $fn = $mys->doc_path.$mys->UserCfgDir."/my_css.sav"; if (file_exists($fn)) { $css_settings = unserialize(fso::read($fn)); //print_r($css_settings); $tpl = new Template("../template"); $tpl->setFile("main","my_css_tpl.css"); $tpl->setVar($css_settings); //$tpl->save( $mys->UserDir."/my.css", "main"); $tpl->save($mys->UserDataPath."/my.css", "main");//备份 } } else { copy(comm::_get_user_css($mys) , $mys->UserDataPath."/my.css"); } $type=$mys->Cursor_type; $path = ""; if($type==0) { $cursor=$mys->Cursor_id; if($cursor > 0) { $path = comm::getMousePath($mys); //fso::write($mys->UserDir."/my.css","\r\n body{cursor:url(".$path.");}", "a+"); fso::write($mys->UserDataPath."/my.css","\r\n body{cursor:url(".$path.");}", "a+"); } } elseif($type==1) { $path = $mys->Cursor_url; //fso::write($mys->UserDir."/my.css","\r\n body{cursor:url(".$path.");}", "a+"); fso::write($mys->UserDataPath."/my.css","\r\n body{cursor:url(".$path.");}", "a+"); } return $path; } //清除图片缓存 function clearPhotoCache($url) { $cmd = "/bin/bash /usr/local/squid/bin/rm_cache.sh ".$url; //echo "$cmd
\n";exit; exec($cmd,$pp); return true; } //得到在线用户 function isOnline($data) { if(empty($data))return array(); $pid = array(); foreach ($data as $row) { $pid[] = $row["pid"]; } //$pid[]='2201606'; //print_r($pid); import("online"); $online = new Online(); return $online->get($pid,option_path); } //得到是否在鸿人堂出现 0.主人 ,1.鸿外线 ,2 ,鸿人 function isRed($pid) { global $_CONFIG; $url = $_CONFIG["red"]."/interface/is_red.php?pid={$pid}"; $is_red = @file_get_contents($url); return $is_red; } //查询单个用户是否在线. function isUserOnline($pid) { if(is_array($pid)) { $pids = $pid; }else { $pids[] = $pid; } //$pid[]='2201606'; //print_r($pid); import("online"); $online = new Online(); return $online->get($pids,option_path); } //得到通行证的用户详细信息 function getDxcUserInfo($username) { global $_CONFIG; $data = @file_get_contents($_CONFIG["dxc"] . "/request.php?username=" . urlencode($username) . "&package=passport&node=xml.profile&pw=aixnaituoygnaw&requester=my/profile.php".EXTRA_ARGS); import("DXC"); $info = DXC::decode($data); return $info; } function toutf8($str) { $str = mb_convert_encoding($str,"utf-8","gbk"); $convmap = array(0x0080, 0xffff, 0x0000, 0xffff); //0x0026, 0x0026, 0x0000, 0xffff); <-这个是转&号为& $str = mb_encode_numericentity($str, $convmap, "utf-8"); return $str; } //判断用户是否有Icon;返回一个数组 function CheckUserIcon($pid) { import("IconQueryClient"); return IconQueryClient::query($pid); } //判断用户是否有形象照片;返回一个数组 function CheckUserFace($pid) { import("FaceQueryClient"); return FaceQueryClient::query($pid); } //清楚特殊字符 function clearStr($str) { $str=strip_tags($str); $str=str_replace("'","’",$str); $str=str_replace("\n","",$str); $str=str_replace("\t","",$str); $str=str_replace("\r","",$str); $str=str_replace(",",",",$str); $str=str_replace("(","(",$str); $str=str_replace(")",")",$str); $str=str_replace('"',"",$str); //$str=addslashes($str); return $str; } //查询是站内消息个数 function getMessageNum($username) { import("MessageClient"); return MessageClient::getNewNum($username); } //发送WEB短消息 function SendWebMsg($subject,$to,$username,$from,$body,$ad_flag='my.good') { global $_CONFIG; import("MessageClient"); $mClient = new MessageClient(); $mClient->setFrom($username, $from); $mClient->setTo($to); $mClient->setMessage($subject, $body); $mClient->setFlagId($ad_flag); $result = $mClient->send(); return $result; } //网友站内消息发送成功记录日志 function mailSuccessLog($subject,$to , $username , $nickname, $body){ $path = 'send_mail_info/success_mail/'.date('Y-m-d').".log"; $ee = '给:' . $to . ':的信:' . $subject . ':发送成功,于' . $username . '<' . $nickname . ">\n"; comm::w2Log($path , $ee); } //发送消息失败记录日志 function mailFaultyLog($subject,$to , $username , $nickname , $body){ $path = 'send_mail_info/fault_mail/'.date('Y-m-d').".log"; $ee = '给:'.$to.':的信:'.$subject.':发送错误,于'.$username.'<'.$nickname.">\n"; comm::w2Log($path , $ee); } function w2Log($path,$content){ $path = realpath(dirname(__FILE__)).'/../../logs/'.$path; if(!is_dir(dirname($path))) fso::createFolder(dirname($path)); fso::write($path , $content); //file_put_contents($path , $content , FILE_APPEND); return false; } //得到用户信息-普通用法 by hanshu function getUserInfoByPid($pid=0 , $db=0){ if (!($pid&&$db)) return array(); $sql = 'select * from domain where pid='.$pid; $db->query($sql); $result = $db->query($sql , MYSQL_ASSOC); if(count($result) == 0) return array(); $result = $result[0]; return $result; } //得到用户信息-普通用法 by hanshu function getUserInfoByUsername($username=0 , $db=0){ if (!($username&&$db)) return array(); $username = trim($username); $sql = 'select * from domain where username like binary \''.$username.'\' limit 1'; $db->query($sql); $result = $db->query($sql , MYSQL_ASSOC); if(count($result) == 0) return array(); $result = $result[0]; return $result; } //得到黑名单用户 function getBlackUser($file,&$pid,&$username) { if(is_file($file)) { $msg = unserialize(@file_get_contents($file)); foreach ($msg as $k => $row) { $pid[] = $row["pid"]; $username[] = $row["username"]; } } } function getVisitorData($pid,$size) { import("VisitorClient"); $client = new VisitorClient(); $arr = $client->getVisitor($pid, $size);//size:条数 if (empty($arr))return array("result"=>1, "msg"=>"", "count"=>0,"online" => array() , "data" => array() ); //print_r($arr);//二维数组 $pids = array(); foreach ($arr as $row) { $pids[] = $row["g_pid"]; $data[] = array( "pid" => $row["g_pid"], "username" => $row["g_username"], "nickname" => $row["g_nickname"] == "" ? $row["g_username"] : $row["g_nickname"], "gender" => $row["g_gender"], "updatedtime" => $row["updatedtime"], "icon" => comm::getIcon($row["g_pid"]), ); } $is_online = comm::isUserOnline($pids);//查询在线信息. return array("result"=>1, "msg"=>"", "count"=>count($data),"online" => $is_online , "data" => $data); } /* 缓存控制函数, $content --> if it's empty ,then fetch,isn't write. $timeout -->cache expire time on second,10 minun = 60*10 $cache_path -->cache path */ function cache_control($content='' , $cache_path = '',$timeout = 3600){ //echo dirname(__FILE__).'/../../cache/'.$cache_path.'
'; $cache_path = realpath(dirname(__FILE__)).'/../../cache/'.$cache_path; //read if(empty($content) and is_file($cache_path)){ $is_vaild_file = filesize($cache_path) > 0; $is_timeout = filemtime($cache_path) > (time()-$timeout); if($is_vaild_file AND $is_timeout){ return file_get_contents($cache_path); } }else{ //write if(!is_dir(dirname($cache_path))) fso::createFolder(dirname($cache_path)); file_put_contents($cache_path , $content); return false; } return false; } //用户等级系统. function getUserLevel($pid) { import("RedLevelClient"); $red = new RedLevelClient(); $level = $red->getLevel($pid); // 取得级别(0-15),参数 pid return $level; } function getUserLevelCaption($level) { import("RedLevelClient"); return RedLevelClient::getDesc($level); } function getUserLevelStarNum($level) { import("RedLevelClient"); return RedLevelClient::getStarsNum($level); } function getUserLevelClass($level) { import("RedLevelClient"); $ret = RedLevelClient::getDesc($level,true); return chr(ord("a")+$ret["num"]-1); } function getUserLevelImg($level) { import("RedLevelClient"); if ($level == 0) $level = 1; $img = $red->getStars($level); return $img; } function getTagUrl($tag_type,$key_word,$url) { if($url !="") return $url; $domian = "http://search.wangyou.com/"; $style = array( "v" => "v,id,video,", "k" => "k,id,k,", "p" => "photo,id,", "blog" => "blog,id,", "f" => "f,", "boke" => "boke,id,", "q" => "q,id," ); if(isset($style[$tag_type])) { return $domian.$style[$tag_type]. urlencode($key_word) . ".html"; }else { return "#"; } } //设置背景音乐 function setBackgroundMusic($pid,$arr) { if($pid ==0 || count($arr) ==0)return false; common::dbConn(); $db = new mysql(); $rs = $db->query("SELECT * FROM bg_music WHERE pid={$pid} LIMIT 1"); if(count($rs)>0) { //如果仅关闭背景音乐,那么不替换以前的歌曲路径 if($arr['enable']){ $sql = "update bg_music set song_id= '{$arr["song_id"]}', enable='{$arr["enable"]}', url='{$arr["url"]}',attribute='{$arr["attribute"]}' where pid={$pid} "; }else{ $sql = "update bg_music set enable='0' where pid={$pid} "; } }else { $sql = "insert into bg_music (pid,song_id,enable,url,attribute,submit_date) values('{$pid}','{$arr["song_id"]}','{$arr["enable"]}','{$arr["url"]}','{$arr["attribute"]}',now())"; } //die($sql);exit; $db->query($sql); return true; } function getBackgroundMusic($pid) { if($pid ==0)return false; common::dbConn(); $db = new mysql(); $rs = $db->query("SELECT * FROM bg_music WHERE pid={$pid} LIMIT 1",MYSQL_ASSOC); if(count($rs)>0) return $rs[0]; return array(); } //设置页面参数 function doBackgroundMusic($pid,&$tpl) { if($pid ==0)return false; $arr = comm::getBackgroundMusic($pid); if(empty($arr)) { $tpl->setVar("BackgroundMusicStat","1"); $tpl->setVar("BackgroundMusicStatCaption","打开"); return false; } if($arr["enable"] == 0) { $stat = "1"; $caption = "打开"; }else { $stat = "0"; $caption = "关闭"; comm::doBackgroundMusicPlayer($tpl,$arr); } $tpl->setVar("BackgroundMusicStat","$stat"); $tpl->setVar("BackgroundMusicStatCaption","$caption"); return false; } //设置播放器 function doBackgroundMusicPlayer(&$tpl,$arr) { //$tpl = new Template("template");//写程序用 $url = $arr["url"]; $url = str_replace("wangyou.com/","wangyou.com/".time()."/",$url);//防盗链 $infos = @pathinfo($url); $extension = (isset($infos["extension"]))?strtolower($infos["extension"]):""; if (!in_array($extension, array("mp3", "rm", "wma","flv"))) { return false; } switch (strtolower($extension)) { case "flv": $player = "play/flv_one_v3.html";break; case "wma": case "mp3": $player = "play/mediaplay_one_v3.html";break; default: $player = "play/realplay_one_v3.html"; } $tpl->setFile("bgplayer",$player); $tpl->setFile("PlayImg","play/play_img.html"); $tpl->parse("BackgroundMusicPlayImg", "PlayImg"); $tpl->setVar("url",$url); $tpl->parse("BackgroundMusicPlayer","bgplayer"); return true; } function _get_gudie_k_list($pid){ return 'gudie/song_list/'.ceil($pid/2).'/'.ceil($pid/3).'/'.ceil($pid/4).'/'.$pid.'.list'; } function getOkSongList($pid) { global $_CONFIG; $pid = abs($pid); if($pid == 0) return array(); $path = comm::_get_gudie_k_list($pid); //cache_control($content='' , $cache_path = '',$timeout = 3600) $ee = comm::cache_control('' , $path , 600); if($ee !== false) return unserialize($ee);; $url = $_CONFIG['ok'].'/interface/get_song_list_from_pid.php?pid='.$pid; $ee = @file_get_contents($url); $ee = trim($ee); if(empty($ee)) return array(); $ee = unserialize($ee); if(count($ee) == 0) return array(); comm::cache_control(serialize($ee) , $path , 600); return $ee; } //屏蔽的关键字 function chkKeyWords($str) { //echo "{$str}";exit; $words = array("成人电影","成人小说","做爱","作爱","强奸","换妻","交换女友","淫欲","祼体","性交","春宫图","菊花蕾","鸡巴","屁眼","抽插","活塞运动","肉棍","泄身","鸡鸡","小穴","浪穴","套动","套弄","自慰","打手枪"); foreach ($words as $key) { if(strpos($str,$key)=== false) continue; else return false; } return true; } function getGamesg1($pid){ $result = intval(file_get_contents("http://gamesg1.wangyou.com/interface/isgamesg1.php?pid={$pid}")); return $result; } } ?>
Fatal error: Class 'comm' not found in /home/web/v2_my/my_cache.php on line 13