📄 pcfuncs.php
字号:
if ($oldmodified!="") { if (($pos = strpos($oldmodified, ';')) !== false) $oldmodified = substr($oldmodified, 0, $pos); $oldtime=strtotime($oldmodified); } else $oldtime=0; if ($modifytime - $oldtime < 60 * $updatetime ) { header("HTTP/1.1 304 Not Modified"); header("Cache-Control: max-age=" . "$expiretime"); return TRUE; } header("Last-Modified: " . gmdate("D, d M Y H:i:s", $modifytime) . " GMT"); header("Expires: " . gmdate("D, d M Y H:i:s", $modifytime+$expiretime) . " GMT"); header("Cache-Control: max-age=" . "$expiretime"); return FALSE;}function pc_logs($link , $action , $comment = "" , $pri_id = "" , $sec_id = ""){ global $currentuser; if( !$action ) return FALSE; $query = "INSERT INTO `logs` ( `lid` , `username` , `hostname` , `ACTION` , `pri_id` , `sec_id` , `COMMENT` , `logtime` )". "VALUES ('', '".addslashes($currentuser[userid])."', '".addslashes($_SERVER["REMOTE_ADDR"])."', '".addslashes($action)."', '".addslashes($pri_id)."', '".addslashes($sec_id)."', '".addslashes($comment)."', NOW( ) );"; mysql_query($query,$link); return TRUE;}function pc_counter($link){ global $pc,$currentuser; if(!$pc || !is_array($pc)) return FALSE; @$visitcount = $_COOKIE["BLOGVISITCOUNT"]; $action = $currentuser["userid"]." visit ".$pc["USER"]."'s Blog(www)"; if(!$visitcount) { /* $query = "SELECT UNIX_TIMESTAMP(logtime) FROM logs WHERE hostname = '".addslashes($_SERVER["REMOTE_ADDR"])."' AND username = '".addslashes($currentuser[userid])."' AND pri_id = '".addslashes($pc["USER"])."' ORDER BY lid DESC LIMIT 0,1;"; $result = mysql_query($query,$link); $rows = mysql_fetch_row($result); mysql_free_result($result); if( !$rows ) { */ pc_visit_counter($link,$pc["UID"]);//计数器加1 //pc_logs($link,$action,"",$pc["USER"]);//记一下访问日志 $pc["VISIT"] ++; $visitcount = ",".$pc["UID"].","; setcookie("BLOGVISITCOUNT",$visitcount); return; /* } elseif( time () - $rows[0] > 3600 )//1个小时log一次 { pc_visit_counter($link,$pc["UID"]);//计数器加1 pc_logs($link,$action,"",$pc["USER"]);//记一下访问日志 $pc["VISIT"] ++; $visitcount = ",".$pc["UID"].","; setcookie("BLOGVISITCOUNT",$visitcount); return; } else return; */ } elseif(!stristr($visitcount,",".$pc["UID"].",")) { pc_visit_counter($link,$pc["UID"]);//计数器加1 //pc_logs($link,$action,"",$pc["USER"]);//记一下访问日志 $pc["VISIT"] ++; $visitcount .= $pc["UID"].","; setcookie("BLOGVISITCOUNT",$visitcount); return; } }function pc_node_counter($link,$nid){ $query = "UPDATE nodes SET visitcount = visitcount + 1 , changed = changed WHERE `nid` = '".$nid."' ;"; mysql_query($query,$link);}function pc_ncounter($link,$nid){ if(!@$_COOKIE["BLOGREADNODES"]) { $readnodes = ",".$nid.","; setcookie("BLOGREADNODES",$readnodes); pc_node_counter($link,$nid); } elseif(!stristr($_COOKIE["BLOGREADNODES"],",".$nid.",")) { $readnodes = $_COOKIE["BLOGREADNODES"] . $nid.","; setcookie("BLOGREADNODES",$readnodes); pc_node_counter($link,$nid); }}/*** 0: XSL ** 1: CSS*/function pc_load_stylesheet($link,$pc){ $query = "SELECT stylesheet FROM userstyle WHERE uid = '".$pc["UID"]."' LIMIT 0 , 1;"; $result = mysql_query($query,$link); $rows = mysql_fetch_array($result); if(!$rows) return FALSE; return intval($rows[stylesheet]);}function html_format_fix_length($str,$length){ if(strlen($str) <= $length ) return $str; $str = substr($str,0,$length); $str .= "..."; return $str; }function myAddslashes($str){ $str = addslashes($str); $str = str_replace("_","\_",$str); $str = str_replace("%","\%",$str); return $str;}function pc_load_topic($link,$uid,$tid,&$topicname,$access=9){ $uid = intval($uid); $tid = intval($tid); $access = intval($access); if($access == 9) $query = "SELECT topicname FROM topics WHERE tid = ".$tid." AND uid = ".$uid." LIMIT 0 , 1;"; else $query = "SELECT topicname FROM topics WHERE tid = ".$tid." AND uid = ".$uid." AND access = ".$access." LIMIT 0 , 1;"; $result = mysql_query($query,$link); $rows = mysql_fetch_array($result); if(!$rows) return FALSE; mysql_free_result($result); $topicname = $rows["topicname"]; return $tid;}function pc_load_directory($link,$uid,$pid){ $uid = intval($uid); $pid = intval($pid); $query = "SELECT `nid` FROM nodes WHERE `uid` = '".$uid."' AND `access` = 3 AND `nid` = '".$pid."' AND `type` = 1 LIMIT 1;"; $result = mysql_query($query,$link); $rows = mysql_fetch_array($result); if(!$rows) return FALSE; mysql_free_result($result); return TRUE;}/*** auto-detect trackback pings from a text*/function pc_detect_trackbackpings($body,&$detecttbps,$tbpUrl){ $text = $body; $text = undo_html_format(trim($text)); $text = str_replace("'"," ",str_replace("\""," ",stripslashes($text))); //convert " and ' to nth $detecttbps = array(); $detectnids = array(); $detectnum = 0; preg_match_all("/[b\/]([^\/]+)\/pc\/pccon.php\?\id\=([0-9]+)&n\id\=([0-9]+)/i",$text,$matches); for($i=0; $i< count($matches[0]); $i++) { if($detectnids[intval($matches[3][$i])]) continue; $detectnids[intval($matches[3][$i])] = 1; $url = "http://".$matches[1][$i]."/pc/tb.php?id=".intval($matches[3][$i]); if ($url != $tbpUrl) { $detecttbps[] = $url; $detectnum ++ ; } } return $detectnum;}/*** add a node** $pc : pc infor-->load by pc_load_infor() function** return 0 :seccess** -1 :缺少主题** -2 :收藏夹目录不存在** -3 :目标文件夹超过文章上限** -4 :目标分类不存在** -5 :数据库添加错误** -6 :系统错误导致引用通告发送失败** -7 :引用通告的url错误** -8 :引用通告目标服务器连接超时** -9 :被审核** -10:群体Blog缺少发布者*/function pc_add_node($link,$pc,$pid,$tid,$emote,$comment,$access,$htmlTag,$trackback,$theme,$subject,$body,$nodeType,$autodetecttbp,$tbpUrl,$tbpArt,$convert_encoding,$filtered,$address,$publisher){ global $pcconfig,$support_encodings,$sending_encoding; $pid = intval($pid); $tid = intval($tid); $emote = intval($emote); $comment = ($comment==1)?1:0; $access = intval($access); $htmlTag = ($htmlTag==1)?1:0; $trackback = ($trackback==1)?1:0; $subject = addslashes(trim($subject)); $body = html_editorstr_format(trim($body)); $nodeType = intval($nodeType); //0: 普通;1: log,不可删除 if ($convert_encoding) { if (!strstr($support_encodings,$convert_encoding)) $convert_encoding = $sending_encoding; } else $convert_encoding = $sending_encoding; if(!$pc || !is_array($pc)) return FALSE; if(!$subject) //检查主题 return -1; if($access < 0 || $access > 4 ) $access = 2;//如果参数错误先在私人区发表 if($access == 3) //若是发表在收藏区,检查目标文件夹 { if(!pc_load_directory($link,$pc["UID"],$pid)) return -2; if(pc_used_space($link,$pc["UID"],3,$pid) >= $pc["NLIM"]) //目标文件夹使用空间 return -3; $tid = 0; } else { $pid = 0; if(pc_used_space($link,$pc["UID"],$access) >= $pc["NLIM"]) //目标文件夹使用空间 return -3; if($tid != 0) //如果是发布在一个分类下面,需要检查分类 { if(!pc_load_topic($link,$pc["UID"],$tid,$topicname,$access)) return -4; } } if($access != 0) //公开区以外不发布引用通告 { $tbpUrl = ""; $autodetecttbp = FALSE; } $into_filter = false; if (!$filtered) //未经过过滤检查的要先检查一次 if (bbs_checkbadword($subject) || bbs_checkbadword($body)) $into_filter = true; if (!pc_is_groupwork($pc)) $publisher = ""; elseif (!$publisher) return -10; else ; if (!$into_filter) { if($tbpUrl && pc_tbp_check_url($tbpUrl) && $tbpArt) //若有引用通告的相关文章,加上链接 { if($htmlTag) $body .= "<br /><br /><strong>相关文章</strong><br />\n". "<a href='".$tbpArt."'>".$tbpArt."</a>"; else $body .= "\n\n[相关文章]\n".$tbpArt; } if (pc_is_groupwork($pc)) { //群体BLOG文章要加一个头 $body = pc_groupwork_addhead($pc,$body,$htmlTag,$publisher); } } if (!isset($pcconfig["SECTION"][$theme])) $theme = "others"; $theme = addslashes($theme); $body = addslashes($body); if (!$address) $address = $_SERVER["REMOTE_ADDR"]; //日志入库 if ($into_filter) $query = "INSERT INTO `filter` ( `pid` , `nid` , `tid` , `type` , `state` , `recuser` , `emote` , `hostname` , `changed` , `created` , `uid` , `username` , `comment` , `commentcount` , `subject` , `body` , `access` , `visitcount` , `htmltag`,`trackback` ,`trackbackcount`,`nodetype`,`tbp_url`,`tbp_art`,`auto_tbp`,`tbpencoding`,`theme`,`publisher`) ". "VALUES ( '".$pid."', 0 , '".$tid."' , '0', '0' , '', '".$emote."' , '".addslashes($_SERVER["REMOTE_ADDR"])."',NOW( ) , NOW( ), '".$pc["UID"]."' , '".addslashes($pc["USER"])."' , '".$comment."', '0', '".$subject."', '".$body."', '".$access."', '0' , '".$htmlTag."' ,'".$trackback."','0','".$nodeType."','".addslashes($tbpUrl)."','".addslashes($tbpArt)."','".intval($autodetecttbp)."','".addslashes($convert_encoding)."','".$theme."','".addslashes($publisher)."');"; else $query = "INSERT INTO `nodes` ( `pid` , `tid` , `type` , `recuser` , `emote` , `hostname` , `changed` , `created` , `uid` , `comment` , `commentcount` , `subject` , `body` , `access` , `visitcount` , `htmltag`,`trackback` ,`trackbackcount`,`nodetype`,`theme`,`publisher`) ". "VALUES ( '".$pid."', '".$tid."' , '0', '', '".$emote."' , '".addslashes($address)."',NOW( ) , NOW( ), '".$pc["UID"]."', '".$comment."', '0', '".$subject."', '".$body."', '".$access."', '0' , '".$htmlTag."' ,'".$trackback."','0','".$nodeType."','".$theme."','".addslashes($publisher)."');"; if(!mysql_query($query,$link)) return -5; //公开区文章发布后更新文章数 if (!$into_filter) if($access == 0) pc_update_record($link,$pc["UID"],"+1"); if (!$into_filter) { $detectnum = 0; if($autodetecttbp) //自动发掘引用通告 { $detecttbps = array(); $detectnum = pc_detect_trackbackpings($body,$detecttbps,$tbpUrl); } if($tbpUrl || $detectnum) //发送引用通告前提取NID { //提取日志的nid $query = "SELECT `nid` FROM nodes WHERE `subject` = '".$subject."' AND `body` = '".$body."' AND `uid` = '".$pc["UID"]."' AND `access` = '".$access."' AND `pid` = '".$pid."' AND `tid` = '".$tid."' ORDER BY nid DESC LIMIT 0,1;"; $result = mysql_query($query,$link); $rows = mysql_fetch_array($result); if(!$rows) return -6; $thisNid = $rows[nid]; mysql_free_result($result); if($htmlTag) $tbbody = undo_html_format(strip_tags(stripslashes($body))); else $tbbody = stripslashes($body); if(strlen($tbbody) > 255 ) $tbbody = substr($tbbody,0,251)." ..."; $subject = stripslashes($subject); $blogname = undo_html_format($pc["NAME"]); if ($pcconfig["ENCODINGTBP"]) { iconv_set_encoding("internal_encoding", $convert_encoding); iconv_set_encoding("output_encoding", $convert_encoding); $subject = iconv ($default_encoding,$convert_encoding,$subject); $tbbody = iconv ($default_encoding,$convert_encoding,$tbbody); $blogname = iconv ($default_encoding,$convert_encoding,$blogname); } $tbarr = array( "title" => $subject, "excerpt" => $tbbody, "url" => "http://".$pcconfig["SITE"]."/pc/pccon.php?id=".$pc["UID"]."&tid=".$tid."&nid=".$thisNid."&s=all", "blogname" => $blogname ); if($tbpUrl) //发送引用通告 pc_tbp_trackback_ping($tbpUrl,$tbarr); for($i = 0 ; $i < $detectnum ; $i ++) //发送自动发掘的引用通告 { pc_tbp_trackback_ping($detecttbps[$i],$tbarr); } } } if ($into_filter) return -9; else return 0;}//群体blog添加头function pc_groupwork_addhead($pc,$body,$htmltag,$publisher) { if ($htmltag) $ret = '<p align="right"><a href="/bbsqry.php?userid='.$publisher.'"><font class="f2">发布者: '.$publisher.'</font></a> </p>'; else $ret = ' 发布者: '.$publisher.' \n'; $ret .= $body; /* if ($htmltag) $ret .= '<p align="center">[<a href="/bbsqry.php?userid='.$publisher.'">'.$publisher.'</a>@<a href="index.php?id='.$pc['USER'].'">'.html_format($pc['NAME']).'</a>]</p>'; else $ret .= ' '.$publisher.'@'.$pc['NAME'].' \n'; */ return $ret;}//获取收藏夹根目录的pidfunction pc_fav_rootpid($link,$uid){ $query = "SELECT `nid` FROM nodes WHERE `access` = '3' AND `uid` = '".intval($uid)."' AND `pid` = '0' AND `type` = '1' LIMIT 0 , 1 ;"; $result = mysql_query($query,$link); $rows = mysql_fetch_array($result); if(!$rows) return FALSE; mysql_free_result($result); return $rows["nid"];}//一个Blog是否为群体BLOG/*pctype字段:参数 类型(0:普通;1:公有) 用户统计 文章(含评论)统计 新文章(评论)统计(含RSS) 0 0 1 1 1 1 1 1 1 1 2 0 0 1 1 3 1 0 1 1 4 0 0 0 1 5 1 0 0 1 6 0 0 0 0 7 1 0 0 0*/function pc_is_groupwork($pc){ if(!$pc || !is_array($pc)) return FALSE; if($pc["TYPE"] == 1 || $pc["TYPE"] == 3 || $pc["TYPE"] == 5 || $pc["TYPE"] == 7)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -