📄 pcfuncs.php
字号:
"EDITOR" => $rows[htmleditor], "INDEX" => array("nodeNum"=> $rows[indexnodes],"nodeChars" => $rows[indexnodechars]), "CSSFILE" => htmlspecialchars(stripslashes($rows[cssfile])), "EMAIL" => htmlspecialchars(stripslashes($rows[useremail])), "FAVMODE" => (int)($rows[favmode]), "UPDATE" => (int)($rows[updatetime]), "INFOR" => str_replace("<?","<?",stripslashes($rows[userinfor])), "TYPE" => $rows[pctype], "LOGTID" => $rows[logtid], "DEFAULTTOPIC" => $rows[defaulttopic] ); if($pc["CSSFILE"]) $cssFile = $pc["CSSFILE"]; else $cssFile = ""; return $pc; }}function pc_get_theme($theme,$stripSlashes=TRUE){ global $pcconfig; if($stripSlashes) $theme = stripslashes($theme) ; $theme = explode("/",$theme); if(!$pcconfig["SECTION"][$theme[0]]) $theme[0] = "others"; return $theme;}function pc_init_fav($link,$uid){ $query = "INSERT INTO `nodes` ( `nid` , `pid` , `tid` , `type` , `source` , `hostname` , `changed` , `created` , `uid` , `comment` , `commentcount` , `subject` , `body` , `access` , `visitcount` ) ".
" VALUES ('', '0', '0', '1', '', '".$_SERVER["REMOTE_ADDR"]."', '".date("YmdHis")."' , '".date("YmdHis")."', '".$uid."', '0', '0', '', NULL , '3', '0');"; $r = mysql_query($query,$link); return $r;}function pc_update_record($link,$uid,$addstr="+0"){ $query = "UPDATE users SET `createtime` = `createtime` , `modifytime` = '".date("YmdHis")."' , `nodescount` = `nodescount` ".$addstr." WHERE `uid` = '".$uid."' "; mysql_query($query,$link);}function pc_visit_counter($link,$uid){ $query = "UPDATE users SET `createtime` = `createtime` , `visitcount` = `visitcount` + 1 WHERE `uid` = '".$uid."' ;"; mysql_query($query,$link);}function pc_used_space($link,$uid,$access,$pid=0){ if($access == 3) $query = "SELECT COUNT(*) FROM nodes WHERE `uid` = '".$uid."' AND `access` = '3' AND `pid` = '".$pid."' AND `type` = 0 ;"; else $query = "SELECT COUNT(*) FROM nodes WHERE `uid` = '".$uid."' AND `access` = '".$access."' AND `type` = 0 ;"; $result = mysql_query($query); $rows = mysql_fetch_row($result); mysql_free_result($result); return $rows[0];}function pc_dir_num($link,$uid,$pid=0){ $query = "SELECT COUNT(*) FROM nodes WHERE `uid` = '".$uid."' AND `access` = '3' AND `pid` = '".$pid."' AND `type` = 1 ;"; $result = mysql_query($query); $rows = mysql_fetch_row($result); mysql_free_result($result); return $rows[0];}function pc_file_num($link,$uid,$pid=0){ $query = "SELECT COUNT(*) FROM nodes WHERE `uid` = '".$uid."' AND `access` = '3' AND `pid` = '".$pid."' AND `type` = 0 ;"; $result = mysql_query($query); $rows = mysql_fetch_row($result); mysql_free_result($result); return $rows[0];}function pc_blog_menu($link,$pc,$tag=9){ if(!$pc || !is_array($pc) || !$pc["UID"]) return NULL; if($tag == 9) $query = "SELECT * FROM topics WHERE `uid` = '".intval($pc["UID"])." ' ORDER BY `sequen` ;"; else $query = "SELECT * FROM topics WHERE `uid` = '".intval($pc["UID"])." ' AND ( `access` = '".intval($tag)."' OR `access` = 9 ) ORDER BY `sequen` DESC ;"; $result = mysql_query($query,$link); $blog = array(); while($rows = mysql_fetch_array($result)) { $blog[] = array( "TID" => $rows[tid], "NAME" => $rows[topicname], "SEQ" => $rows[sequen], "TAG" => $rows[access] ); } mysql_free_result($result); if($tag==0 && $pc["DEFAULTTOPIC"]) //自定义公开区默认分类 { $blog[] = array( "TID" => 0, "NAME" => $pc["DEFAULTTOPIC"], "SEQ" => 0, "TAG" => 9 ); } elseif($tag != 0 && $tag != 9) { $blog[] = array( "TID" => 0, "NAME" => "其他类别", "SEQ" => 0, "TAG" => 9 ); } else { // nth :p } return $blog;}function pc_style_array($i){ switch($i) { case 1: $style = array( "SID" => 1, "INDEXFUNC" => "display_blog_smth", "TOPIMG" => "style/default/p1.jpg", "CSSFILE" => "default.css" ); break; case 2: $style = array( "SID" => 2, "INDEXFUNC" => "display_blog_earthsong", "TOPIMG" => "style/default/p1.jpg", "CSSFILE" => "style/earthsong/earthsong.css" ); break; case 9: $style = array( "SID" => 9, ); break; default: $style = array( "SID" => 0, "INDEXFUNC" => "display_blog_default", "TOPIMG" => "style/default/p1.jpg", "CSSFILE" => "default.css" ); } return $style;}function get_next_month($yy,$mm){ $mm ++; if($mm > 12) { $mm = 1; $yy ++ ; } return array($yy,$mm);}function get_pre_month($yy,$mm){ $mm --; if($mm < 1) { $mm = 12; $yy --; } return array($yy,$mm);}function display_blog_catalog(){ global $pcconfig; $secNum = count($pcconfig["SECTION"]); $secKeys = array_keys($pcconfig["SECTION"]);?><center><table cellspacing=0 cellpadding=3 border=0 width=90% class=t1><tr> <td class=t8><strong>Blog分类>></strong></td></tr><tr> <td class=t4> <table cellspacing=0 cellpadding=3 border=0 width=98% class=f1><?php for($i = 0 ; $i < $secNum ; $i ++ ) { if( $i % 6 == 0 ) echo "<tr>"; echo "<td class=f1 align=center><a href=\"pcsec.php?sec=".htmlspecialchars($secKeys[$i])."\">".htmlspecialchars($pcconfig["SECTION"][$secKeys[$i]])."</a></td>"; if( $i % 6 == 5 ) echo "</tr>"; }?> </table> </td></tr></table></center><br /><?php }function pc_get_user_permission($currentuser,$pc){ global $loginok; if(pc_is_admin($currentuser,$pc) && $loginok == 1) { $sec = array("公开区","好友区","私人区","收藏区","删除区","设定好友","Blog管理","参数设定"); $pur = 3; $tags = array(1,1,1,1,1,1,1,1); } elseif(pc_is_friend($currentuser["userid"],$pc["USER"]) || pc_is_manager($currentuser)) { $sec = array("公开区","好友区"); $pur = 1; $tags = array(1,1,0,0,0,0,0,0); if($pc["FAVMODE"] == 1 || $pc["FAVMODE"] == 2)//收藏夹模式 { $sec[3] = "收藏区"; $tags[3] = 1; } } else { $sec = array("公开区"); $pur = 0; $tags = array(1,0,0,0,0,0,0,0); if($pc["FAVMODE"] == 2)//收藏夹模式 { $sec[3] = "收藏区"; $tags[3] = 1; } } return array( "tags" => $tags , "pur" => $pur , "sec" => $sec );}function pc_select_blogtheme($theme,$themeValue="pcthem"){ global $pcconfig;?><select name="<?php echo $themeValue; ?>" class="f1"><?php reset($pcconfig["SECTION"]); while( list($sec , $secName) = each($pcconfig["SECTION"]) ) { if($theme[0] == $sec) echo "<option value=\"".htmlspecialchars($sec)."\" selected>".htmlspecialchars($secName)."</option>"; else echo "<option value=\"".htmlspecialchars($sec)."\">".htmlspecialchars($secName)."</option>"; } ?></select><?php}function pc_cache( $modifytime ){ $lastmodifytime = time_format( $modifytime ); $lastmodifytime = strtotime( $lastmodifytime ); if (cache_header("public",$lastmodifytime,300)) return TRUE; else return FALSE;}function pc_main_navigation_bar(){ global $pcconfig;?><p align="center">[<a href="pcmain.php">首页</a>][<a href="pc.php">用户</a>][<a href="pclist.php">热门排行</a>][<a href="pcsec.php">分类</a>][<a href="pcreclist.php">推荐文章</a>][<a href="pcnew.php">最新日志</a>][<a href="pcnew.php?t=c">最新评论</a>][<a href="pcsearch2.php">博客搜索</a>][<a href="pcnsearch.php">日志搜索</a>][<a href="/bbsdoc.php?board=<?php echo $pcconfig["BOARD"]; ?>">论坛</a>][<a href="pcapp0.html"><font color=red>申请</font></a>]<?php if( $pcconfig["ADMIN"] ){?>[<a href="index.php?id=<?php echo $pcconfig["ADMIN"]; ?>">帮助主题</a>]<?php }?></p><p align="center">[<b><img src="images/xml.gif" border="0" align="absmiddle" alt="XML">RSS频道</b> <a href="rssnew.php">最新日志</a><a href="rssrec.php">推荐文章</a><a href="opml.php?t=2">新用户(OPML)</a><a href="opml.php">最近更新(OPML)</a><a href="opml.php?t=1">访问最多(OPML)</a>]</p><?php }function pc_update_cache_header($updatetime = 10){ global $cachemode; $scope = "public"; $modifytime=time(); $expiretime=300; session_cache_limiter($scope); $cachemode=$scope; @$oldmodified=$_SERVER["HTTP_IF_MODIFIED_SINCE"]; if ($oldmodified!="") { $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 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_array($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( date("YmdHis") - $rows[logtime] > 10000 )//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;";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -