📄 pcfuncs.php
字号:
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){ $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; $detecttbps[] = "http://".$matches[1][$i]."/pc/tb.php?id=".intval($matches[3][$i]); $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 :引用通告目标服务器连接超时*/function pc_add_node($link,$pc,$pid,$tid,$emote,$comment,$access,$htmlTag,$trackback,$subject,$body,$nodeType,$autodetecttbp=FALSE,$tbpUrl="",$tbpArt=""){ global $pcconfig; $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(!$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"],$tag) >= $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; } 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; } $body = addslashes($body); //日志入库 $query = "INSERT INTO `nodes` ( `pid` , `tid` , `type` , `source` , `emote` , `hostname` , `changed` , `created` , `uid` , `comment` , `commentcount` , `subject` , `body` , `access` , `visitcount` , `htmltag`,`trackback` ,`trackbackcount`,`nodetype`) ".
"VALUES ( '".$pid."', '".$tid."' , '0', '', '".$emote."' , '".addslashes($_SERVER["REMOTE_ADDR"])."',NOW( ) , NOW( ), '".$pc["UID"]."', '".$comment."', '0', '".$subject."', '".$body."', '".$access."', '0' , '".$htmlTag."' ,'".$trackback."','0','".$nodeType."');"; if(!mysql_query($query,$link)) return -5; //公开区文章发布后更新文章数 if($access == 0) pc_update_record($link,$pc["UID"],"+1"); $detectnum = 0; if($autodetecttbp) //自动发掘引用通告 { $detecttbps = array(); $detectnum = pc_detect_trackbackpings($body,$detecttbps); } 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($body)); else $tbbody = $body; if(strlen($tbbody) > 255 ) $tbbody = substr($tbbody,0,251)." ..."; $tbarr = array( "title" => stripslashes($subject), "excerpt" => stripslashes($tbbody), "url" => "http://".$pcconfig["SITE"]."/pc/pccon.php?id=".$pc["UID"]."&tid=".$tid."&nid=".$thisNid."&s=all", "blogname" => undo_html_format($pc["NAME"]) ); if($tbpUrl) //发送引用通告 pc_tbp_trackback_ping($tbpUrl,$tbarr); for($i = 0 ; $i < $detectnum ; $i ++) //发送自动发掘的引用通告 { pc_tbp_trackback_ping($detecttbps[$i],$tbarr); } } return 0;}//获取收藏夹根目录的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) return TRUE; return FALSE;}//公有BLOG的logfunction pc_group_logs($link,$pc,$action,$content=""){ global $currentuser; if(!pc_is_groupwork($pc)) return FALSE; if(!$action) return FALSE; $action = "[".date("Y-m-d H:i:s")."@".$_SERVER["REMOTE_ADDR"]."]".$currentuser["userid"]." ".$action; $ret = pc_add_node($link,$pc,0,$pc["LOGTID"],0,1,2,0,0,$action,$content,1); if($ret != 0) return FALSE; return TRUE;}//分区下添加分类function pc_add_topic($link,$pc,$access,$topicname){ if(!$pc || !is_array($pc)) return FALSE; if(!$topicname) return FALSE; $access = intval($access); if($access < 0 || $access > 2) $access = 2; $query = "INSERT INTO `topics` (`uid` , `access` , `topicname` , `sequen` ) ".
"VALUES ( '".$pc["UID"]."', '".$access."', '".addslashes($topicname)."', '0');"; if(!mysql_query($query,$link)) return FALSE; return TRUE;}/*** 把一个BLOG变成公有BLOG** return 0 : seccess** -1:$pc参数错误** -2:已是公有BLOG** -3:LOG目录初始化错误** -4:系统错误** -5:LOG 错误*/function pc_convertto_group($link,$pc){ if(!$pc || !is_array($pc)) return -1; if(pc_is_groupwork($pc)) return -2; if(!pc_add_topic($link,$pc,2,"GROUPWORK LOGs")) return -3; $query = "SELECT tid FROM topics WHERE uid = '".$pc["UID"]."' AND access = 2 AND topicname = 'GROUPWORK LOGs' ORDER BY tid DESC LIMIT 0,1;"; $result = mysql_query($query,$link); $rows = mysql_fetch_array($result); mysql_free_result($result); if(!$rows) return -3; $logtid = $rows[tid]; $query = "UPDATE users SET createtime = createtime , pctype = 1 , logtid = ".$logtid." WHERE uid = ".$pc["UID"]." LIMIT 1;"; if(!mysql_query($query,$link)) return -4; $pc["TYPE"] = 1; $pc["LOGTID"] = $logtid; if(!pc_group_logs($link,$pc,"CONVERT TO GROUPWORK")) return -5; return 0;}//修改Blog分类名function pc_edit_topics($link,$tid,$newname){ if(!$tid || !$newname) return FALSE; $query = "UPDATE topics SET `topicname` = '".addslashes($newname)."' WHERE `tid` = '".intval($tid)."' LIMIT 1;"; if(!mysql_query($query,$link)) return FALSE; else return TRUE;}//删除Blog分类/*** return 0: seccess** -1:node exist** -2:error*/function pc_del_topics($link,$tid){ $tid = intval($tid); $query = "SELECT `nid` FROM nodes WHERE `tid` = '".$tid."' ;"; $result = mysql_query($query,$link); $rows = mysql_fetch_array($result); mysql_free_result($result); if($rows) return -1; $query = "DELETE FROM topics WHERE `tid` = '".$tid."' ;"; if(!mysql_query($query,$link)) return -2; return 0;}/*** 收藏夹中添加目录** return 0: seccess** -1: 缺少blog资料** -2: 缺少父目录id** -3: 缺少目录名** -4: 超容** -5: 系统错误*/function pc_add_favdir($link,$pc,$pid,$dirname){ $pid = intval($pid); //parent's id $dirname = addslashes(trim($dirname)); if(!$pc || !is_array($pc)) return -1; if(!$pid) return -2; if(!$dirname) return -3; if(pc_dir_num($link,$pc["UID"],$pid)+1 > $pc["DLIM"]) return -4; $query = "INSERT INTO `nodes` ( `nid` , `pid` , `type` , `source` , `hostname` , `changed` , `created` , `uid` , `comment` , `commentcount` , `subject` , `body` , `access` , `visitcount` , `tid` , `emote` ) ". "VALUES ('', '".$pid."', '1', '', '".$_SERVER["REMOTE_ADDR"]."',NOW( ),NOW( ), '".$pc["UID"]."', '0', '0', '".$dirname."', NULL , '3', '0', '0', '0');"; if(!mysql_query($query,$link)) return -5; return 0;}function pc_ubb_parse($txt){
$bbcode_lib = $_SERVER["DOCUMENT_ROOT"]."/pc/bbcode.php"; if(file_exists($bbcode_lib)) include($bbcode_lib); else return $txt; return pc_bbcode_parse($txt);}
function pc_ubb_content($txt=""){?><SPAN class=gen><SPAN class=genmed></SPAN>
<TABLE cellSpacing=0 cellPadding=2 border=0>
<TBODY>
<TR vAlign=center align=left>
<TD width="35"><SPAN class=genmed><INPUT class=ubbbutton onmouseover="helpline('b')" style="FONT-WEIGHT: bold; WIDTH: 30px" accessKey=b onclick=bbstyle(0) type=button value=" B " name=addbbcode0>
</SPAN></TD>
<TD width="35"><SPAN class=genmed><INPUT class=ubbbutton onmouseover="helpline('i')" style="WIDTH: 30px; FONT-STYLE: italic" accessKey=i onclick=bbstyle(2) type=button value=" i " name=addbbcode2>
</SPAN></TD>
<TD width="35"><SPAN class=genmed><INPUT class=ubbbutton onmouseover="helpline('u')" style="WIDTH: 30px; TEXT-DECORATION: underline" accessKey=u onclick=bbstyle(4) type=button value=" u " name=addbbcode4>
</SPAN></TD>
<TD width="55"><SPAN class=genmed><INPUT class=ubbbutton onmouseover="helpline('q')" style="WIDTH: 50px" accessKey=q onclick=bbstyle(6) type=button value=Quote name=addbbcode6>
</SPAN></TD>
<TD width="45"><SPAN class=genmed><INPUT class=ubbbutton onmouseover="helpline('c')" style="WIDTH: 40px" accessKey=c onclick=bbstyle(8) type=button value=Code name=addbbcode8>
</SPAN></TD>
<TD width="45"><SPAN class=genmed><INPUT class=ubbbutton onmouseover="helpline('l')" style="WIDTH: 40px" accessKey=l onclick=bbstyle(10) type=button value=List name=addbbcode10>
</SPAN></TD>
<TD width="45"><SPAN class=genmed><INPUT class=ubbbutton onmouseover="helpline('o')" style="WIDTH: 40px" accessKey=o onclick=bbstyle(12) type=button value=List= name=addbbcode12>
</SPAN></TD>
<TD width="45"><SPAN class=genmed><INPUT class=ubbbutton onmouseover="helpline('p')" style="WIDTH: 40px" accessKey=p onclick=bbstyle(14) type=button value=Img name=addbbcode14>
</SPAN></TD>
<TD width="45"><SPAN class=genmed><INPUT class=ubbbutton onmouseover="helpline('w')" style="WIDTH: 40px; TEXT-DECORATION: underline" accessKey=w onclick=bbstyle(16) type=button value=URL name=addbbcode16>
</SPAN></TD> <TD width="500"><SPAN class=genmed> </TD> </TR>
<TR>
<TD colSpan=10>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD><SPAN class=genmed> 字体颜色: <SELECT
onmouseover="helpline('s')"
onchange="bbfontstyle('[color=' + this.form.addbbcode18.options[this.form.addbbcode18.selectedIndex].value + ']', '[/color]');this.selectedIndex=0;"
name=addbbcode18> <OPTION class=genmed
style="COLOR: black; BACKGROUND-COLOR: #fafafa"
value=#444444 selected>标准</OPTION> <OPTION
class=genmed
style="COLOR: darkred; BACKGROUND-COLOR: #fafafa"
value=darkred>深红</OPTION> <OPTION class=genmed
style="COLOR: red; BACKGROUND-COLOR: #fafafa"
value=red>红色</OPTION> <OPTION class=genmed
style="COLOR: orange; BACKGROUND-COLOR: #fafafa"
value=orange>橙色</OPTION> <OPTION class=genmed
style="COLOR: brown; BACKGROUND-COLOR: #fafafa"
value=brown>棕色</OPTION> <OPTION class=genmed
style="COLOR: yellow; BACKGROUND-COLOR: #fafafa"
value=yellow>黄色</OPTION> <OPTION class=genmed
style="COLOR: green; BACKGROUND-COLOR: #fafafa"
value=green>绿色</OPTION> <OPTION class=genmed
style="COLOR: olive; BACKGROUND-COLOR: #fafafa"
value=olive>橄榄</OPTION> <OPTION class=genmed
style="COLOR: cyan; BACKGROUND-COLOR: #fafafa"
value=cyan>青色</OPTION> <OPTION class=genmed
style="COLOR: blue; BACKGROUND-COLOR: #fafafa"
value=blue>蓝色</OPTION> <OPTION class=genmed
style="COLOR: darkblue; BACKGROUND-COLOR: #fafafa"
value=darkblue>深蓝</OPTION> <OPTION class=genmed
style="COLOR: indigo; BACKGROUND-COLOR: #fafafa"
value=indigo>靛蓝</OPTION> <OPTION class=genmed
style="COLOR: violet; BACKGROUND-COLOR: #fafafa"
value=violet>紫色</OPTION> <OPTION class=genmed
style="COLOR: white; BACKGROUND-COLOR: #fafafa"
value=white>白色</OPTION> <OPTION class=genmed
style="COLOR: black; BACKGROUND-COLOR: #fafafa"
value=black>黑色</OPTION></SELECT> 字体大小:<SELECT
onmouseover="helpline('f')"
onchange="bbfontstyle('[size=' + this.form.addbbcode20.options[this.form.addbbcode20.selectedIndex].value + ']', '[/size]')"
name=addbbcode20> <OPTION class=genmed
value=7>最小</OPTION> <OPTION class=genmed
value=9>小</OPTION> <OPTION class=genmed value=12
selected>正常</OPTION> <OPTION class=genmed
value=18>大</OPTION> <OPTION class=genmed
value=24>最大</OPTION></SELECT> </SPAN> <SPAN class=gensmall><A
class=genmed onmouseover="helpline('a')"
href="javascript:bbstyle(-1)">完成标签</A></SPAN> </TD>
<TD noWrap align=left> </TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD colSpan=10><SPAN class=gensmall><INPUT class=helpline
style="FONT-SIZE: 12px; WIDTH: 450px" maxLength=100 size=45
value="提示: 文字风格可以快速使用在选择的文字上" name=helpbox> </SPAN></TD></TR>
<TR>
<TD colSpan=10><SPAN class=gen>
<TEXTAREA onkeyup=storeCaret(this); onclick=storeCaret(this); tabIndex=3 onselect=storeCaret(this); name="blogbody" style="font-size: 14px ; line-height:20px;" cols="100" rows="20" id="blogbody" onkeydown='if(event.keyCode==87 && event.ctrlKey) {document.postform.submit(); return false;}' onkeypress='if(event.keyCode==10) return document.postform.submit()' wrap="physical"><?php echo $txt; ?></TEXTAREA>
</SPAN></TD></TR></TBODY></TABLE></SPAN><?php}?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -