phpwind的功能很强悍,设计理念也非常不错,但代码写得有些乱,不过可能是php本身的特点导致,让我们这些写惯了java的开发人员看起来极不习惯,并且源码里的注释少得可怜,只能自己边看边加了,今天看了看了根目录下的index.php,带注释的源码如下:

<?php define('SCR','index'); require_once('global.php'); include_once(D_P.'data/bbscache/cache_index.php'); include_once(D_P.'data/bbscache/forum_cache.php'); //notice //公告处理 $noticedb = array(); foreach ($notice_A as $value) { if ($value['startdate']<=$timestamp && (!$value['enddate'] || $value['enddate']>=$timestamp)) { $value['startdate'] = $value['stime'] ? $value['stime'] : get_date($value['startdate'],'y-m-d'); !$value['url'] && $value['url'] = 'notice.php#'.$value['aid']; $noticedb[$value['aid']] = $value; } } $notice_A = $noticedb; unset($noticedb); $topics = $article = $tposts = 0; $cateid = (int)GetGP('cateid'); $secdomain = null; $m = GetGP('m'); //设置默认主页模式为门户 if (!$cateid && $db_modedomain && $secdomain = array_search($pwServer['HTTP_HOST'], $db_modedomain)) { $cateinfo = explode("_",$secdomain); if ('cate' == $cateinfo[0]) { $cateid = (int)$cateinfo[1]; $db_bbsurl = $_mainUrl; $m = 'area'; } unset($cateinfo); } //根据参数选择模式 selectMode($m); if (defined('M_P') && file_exists(M_P . ($cateid > 0 ? 'cate' : 'index') . '.php')) { //门户模式 if ($cateid > 0) { //门户模式的子版块 $_GET['fid'] = $_GET['cateid'] = $cateid; require_once M_P.'cate.php'; } else { //门户首页或圈子首页 require_once(M_P.'index.php'); $db_newinfoifopen = 0; } } else { //论坛模式 $pw_seoset = L::loadClass('seoset'); $webPageTitle = $pw_seoset->getPageTitle(); $metaDescription = $pw_seoset->getPageMetadescrip(); $metaKeywords = $pw_seoset->getPageMetakeyword(); $newpic = (int)GetCookie('newpic'); $forumdb = $catedb = $showsub = array(); $c_htm = 0; if ($db_forumdir) { require_once(R_P.'require/dirname.php'); } elseif ($cateid > 0) { $catestyle = $forum[$cateid]['style']; if ($catestyle && file_exists(D_P."data/style/$catestyle.php")) { $skin = $catestyle; } #SEO $pw_seoset->set_page('thread'); $pw_seoset->set_ifCMS($forum[$cateid]['ifcms']); $webPageTitle = $pw_seoset->getPageTitle($forum[$cateid]['title'],$forum[$cateid]['name']); $metaDescription = $pw_seoset->getPageMetadescrip($forum[$cateid]['metadescrip'],$forum[$cateid]['name']); $metaKeywords = $pw_seoset->getPageMetakeyword($forum[$cateid]['keywords'],$forum[$cateid]['name']); $sqlwhere = 'AND (f.fid=' . pwEscape($cateid) . ' OR f.fup=' . pwEscape($cateid) . ')'; unset($metakeyword); } require_once(R_P.'require/header.php'); !$db_showcms && $sqlwhere .= " AND f.cms!='1'"; /*The app client*/ //第三方app相关 if ($db_siteappkey && ($db_apps_list['17']['status'] == 1 || is_array($db_threadconfig))) { $appclient = L::loadClass('appclient'); if (is_array($db_threadconfig)) { $threadright = array(); $threadright = $appclient->getThreadRight(); } } /*The app client*/ if ($cookie_deploy = $_COOKIE['deploy']) { $deployfids = explode("/t",$cookie_deploy); $deployfids = array_flip($deployfids); unset($cookie_deploy); } else { $deployfids = array(); } //查询表pw_forums和pw_forumdata得到版块信息 $query = $db->query("SELECT f.fid,f.name,f.type,f.childid,f.fup,f.logo,f.descrip,f.metadescrip,f.forumadmin,f.across,f.allowhtm,f.password,f.allowvisit,f.showsub,f.ifcms,fd.tpost,fd.topic,fd.article,fd.subtopic,fd.top1,fd.lastpost FROM pw_forums f LEFT JOIN pw_forumdata fd USING(fid) WHERE f.ifsub='0' AND f.ifcms!=2 $sqlwhere ORDER BY f.vieworder"); while ($forums = $db->fetch_array($query)) { //循环取得每个版块信息 if ($forums['type'] === 'forum') { //若为具体版块 //子版块设置 if ($forums['showsub'] && $forums['childid']) { $showsub[$forums['fid']] = ''; } //取得主题总数 $forums['topics'] = $forums['topic']+$forums['subtopic']; if ($db_topped) { $forums['topics'] += $forums['top1']; $forums['article'] += $forums['top1']; } //计算帖子和回帖总数 $article += $forums['article']; $topics += $forums['topics']; $tposts += $forums['tpost']; $forums['au'] = $forums['admin'] = ''; if (!$forums['password'] && (!$forums['allowvisit'] || allowcheck($forums['allowvisit'],$groupid, $winddb['groups'],$forums['fid'],$winddb['visit']))) { //允许访问 //取得本版块最新贴的相关信息 list($forums['t'],$forums['au'],$forums['newtitle'],$forums['ft']) = explode("/t",$forums['lastpost']); $forums['pic'] = $newpic < $forums['newtitle'] && ($forums['newtitle'] + $db_newtime > $timestamp) ? 'new' : 'old'; $forums['newtitle'] = get_date($forums['newtitle']); $forums['t'] = substrs($forums['t'],26); } elseif ($forum[$forums['fid']]['f_type'] === 'hidden' && $groupid != 3) { //有权限或密码保护 if ($forums['password'] && allowcheck($forums['allowvisit'],$groupid,$winddb['groups'], $forums['fid'],$winddb['visit'])) { $forums['pic'] = 'lock'; } else { continue; } } else { $forums['pic'] = 'lock'; } $forums['allowhtm'] == 1 && $c_htm = 1; //取得版块logo if ($db_indexfmlogo == 2) { if(!empty($forums['logo']) && strpos($forums['logo'],'http://') === false && file_exists($attachdir.'/'.$forums['logo'])){ $forums['logo'] = "$attachpath/$forums[logo]"; } } elseif ($db_indexfmlogo == 1 && file_exists("$imgdir/$stylepath/forumlogo/$forums[fid].gif")) { $forums['logo'] = "$imgpath/$stylepath/forumlogo/$forums[fid].gif"; } else { $forums['logo'] = ''; } //取得版主信息 if ($forums['forumadmin']) { $forumadmin = explode(',',$forums['forumadmin']); foreach ($forumadmin as $value) { if ($value) { if (!$db_adminshow) { $forums['admin'] .= '<a href="u.php?action=show&username='.rawurlencode($value)." mce_href="u.php?action=show&username='.rawurlencode($value)."/">$value</a> "; } else { $forums['admin'] .= "<option value=/"$value/">$value</option>"; } } } } //第三方 app相关 /*The app client*/ if ($db_siteappkey && $db_apps_list['17']['status'] == 1) { $forums['forumappinfo'] = $appclient->showForumappinfo($forums['fid'],'forum_erect,forum_across','17'); } /*The app client*/ $forumdb[$forums['fup']][] = $forums; } elseif ($forums['type'] === 'category') { //若为版块分类 //取得图标和样式等显示信息 if (isset($deployfids[$forums['fid']])) { $forums['deploy_img'] = 'open'; $forums['tbody_style'] = 'none'; $forums['admin'] = ''; } else { $forums['deploy_img'] = 'fold'; $forums['tbody_style'] = $forums['admin'] = ''; } //取得版主信息 if ($forums['forumadmin']) { $forumadmin = explode(',',$forums['forumadmin']); foreach ($forumadmin as $key => $value) { if ($value) { if ($key==10) { $forums['admin'] .= '...'; break; } $forums['admin'] .= '<a href="u.php?action=show&username='.rawurlencode($value)." mce_href="u.php?action=show&username='.rawurlencode($value)."/" class=/"cfont/">$value</a> "; } } } $catedb[] = $forums; } } $db->free_result($query); // View sub if (!empty($showsub)) { foreach ($forum as $value) { if (isset($showsub[$value['fup']]) && $value['f_type'] != 'hidden') { $showsub[$value['fup']] .= ($showsub[$value['fup']] ? ' | ' : '')."<a href="/" mce_href="/""thread.php?fid=$value[fid]/">$value[name]</a>"; } } } unset($forums,$forum,$db_showcms); //info deploy if (isset($deployfids['info'])) { $cate_img = 'open'; $cate_info = 'none'; } else { $cate_img = 'fold'; $cate_info = ''; } // update birth day if ($db_indexshowbirth) { $brithcache = ''; require_once(R_P.'require/birth.php'); } } // Sharing Information //取得论坛基本统计信息 extract($db->get_one("SELECT * FROM pw_bbsinfo WHERE id=1")); //$rt = $db->get_one('SELECT newmember,totalmember,higholnum,higholtime,tdtcontrol,yposts,hposts,hit_tdtime,hit_control,plantime FROM pw_bbsinfo WHERE id=1'); //显示新会员 $newmember = '<a href="u.php?action=show&username='.rawurlencode($newmember).'" mce_href="u.php?action=show&username='.rawurlencode($newmember).'" target="_blank">'.$newmember.'</a>'; //取得主题和帖子总数 $article += $o_post; $topics += $o_post; $tposts += $o_tpost; // online users //更新在线信息 Update_ol(); $userinbbs = $guestinbbs = 0; //从cache或数据库取得在线信息 if (empty($db_online)) { include_once(D_P.'data/bbscache/olcache.php'); } else { $query = $db->query("SELECT uid!=0 as ifuser,COUNT(*) AS count FROM pw_online GROUP BY uid!='0'"); while ($rt = $db->fetch_array($query)) { if ($rt['ifuser']) { $userinbbs = $rt['count']; } else { $guestinbbs = $rt['count']; } } } //会员总数 $usertotal = $guestinbbs + $userinbbs; if ($db_indexonline) { InitGP(array('online')); empty($online) && $online = GetCookie('online'); if ($online == 'yes') { if ($usertotal > 2000 && !CkInArray($windid,$manager)) { $online = 'no'; Cookie('online',$online); } else { $index_whosonline = ''; $db_online = intval($db_online); include_once Pcv(R_P."require/online_{$db_online}.php"); } } } $showgroup = $db_showgroup ? explode(',',$db_showgroup) : array(); // Share union if ($db_indexmqshare && $sharelink[1]) { $sharelink[1] = "<marquee scrolldelay=/"100/" scrollamount=/"4/" οnmοuseοut=/"if (document.all!=null){this.start()}/" οnmοuseοver=/"if (document.all!=null){this.stop()}/" behavior=/"alternate/">$sharelink[1]</marquee>"; } //update pw_feed //更新好友动态 if ($winduid && PwStrtoTime(get_date($lastvisit,'Y-m-d')) < $tdtime && $db_hostweb == 1 && !$cateid && $groupid != 'guest' && !defined('M_P')) { $_flag = $db->get_value("SELECT id FROM pw_feed WHERE uid = ".pwEscape($winduid)." ORDER BY id DESC LIMIT 29,1"); $_flag && $db->update("DELETE FROM pw_feed WHERE uid = ".pwEscape($winduid)." AND id < ". pwEscape($_flag)); } //更新昨日发贴数和数据更新时间 if ($db_hostweb == 1 && $groupid != 'guest' && !$cateid && $tdtcontrol < $tdtime && !defined('M_P')) { require_once(R_P.'require/updateforum.php'); updateshortcut(); $db->update("UPDATE pw_bbsinfo SET".pwSqlSingle(array('yposts' => $tposts, 'tdtcontrol' => $tdtime,'o_tpost'=>0))."WHERE id='1'"); $db->update("UPDATE pw_forumdata SET tpost=0 WHERE tpost<>'0'"); // $db->update("DELETE FROM pw_feed WHERE timestamp<".pwEscape($tdtime - 604800)); } // update posts hits if ($c_htm || $db_hithour) { $db_hithour == 0 && $db_hithour = 4; $hit_wtime = $hit_control * $db_hithour; $hit_wtime > 24 && $hit_wtime = 0; $hitsize = @filesize(D_P.'data/bbscache/hits.txt'); if ($hitsize && ($hitsize > 1024 || ($timestamp - $hit_tdtime) > $hit_wtime * 3600) && procLock('hitupdate')) { require_once(R_P.'require/hitupdate.php'); procUnLock('hitupdate'); } } //更新最高在线数和最高在线时间 if ($higholnum < $usertotal) { $db->update("UPDATE pw_bbsinfo SET ".pwSqlSingle(array('higholnum' => $usertotal,'higholtime'=> $timestamp))." WHERE id=1"); $higholnum = $usertotal; } //更新最高日贴 if ($hposts < $tposts) { $db->update('UPDATE pw_bbsinfo SET hposts='.pwEscape($tposts).' WHERE id=1'); $hposts = $tposts; } $mostinbbstime = get_date($higholtime); if (!$ol_offset && $db_onlinelmt != 0 && $usertotal >= $db_onlinelmt) { Cookie('ol_offset','',0); Showmsg('most_online'); } if ($plantime && $timestamp > $plantime && procLock('task')) { require_once(R_P.'require/task.php'); procUnLock('task'); } $db_newinfoifopen && require_once(R_P."require/newinfo.php"); //取得index.htm模板,把上去取得的各个信息通过html展现出来,相当于control层到view层 require_once PrintEot('index'); if (isset($area_refresh_static) && $area_refresh_static && function_exists("area_static_deal")) { $area_static_content = ob_get_contents(); area_static_deal("saveStaticContent", array('content'=>$area_static_content)); ob_clean(); echo $area_static_header, $area_static_content; unset($area_static_header, $area_static_content); } footer(); ?>

phpwind源码解析------index.php相关推荐

  1. PHPWind 源码解析

    保留关键字  函数  类型  字符串  注释  括号       数字  运算符  预定义变量  PHP 开始结束标签 global.php QUOTE: <?php  /**  *  * Co ...

  2. hox 状态管理库源码解析

    文章目录 hox是什么 hox实现状态共享的方式 基本使用 全局状态共享 局部状态共享 源码解析 index.js 入口文件 coantainer.tsx 管理每个hook 全局状态共享的实现 Hox ...

  3. 谷歌BERT预训练源码解析(一):训练数据生成

    目录 预训练源码结构简介 输入输出 源码解析 参数 主函数 创建训练实例 下一句预测&实例生成 随机遮蔽 输出 结果一览 预训练源码结构简介 关于BERT,简单来说,它是一个基于Transfo ...

  4. Gin源码解析和例子——中间件(middleware)

    在<Gin源码解析和例子--路由>一文中,我们已经初识中间件.本文将继续探讨这个技术.(转载请指明出于breaksoftware的csdn博客) Gin的中间件,本质是一个匿名回调函数.这 ...

  5. Redis源码解析——双向链表

    相对于之前介绍的字典和SDS字符串库,Redis的双向链表库则是非常标准的.教科书般简单的库.但是作为Redis源码的一部分,我决定还是要讲一讲的.(转载请指明出于breaksoftware的csdn ...

  6. Redis源码解析——字典基本操作

    有了<Redis源码解析--字典结构>的基础,我们便可以对dict的实现进行展开分析.(转载请指明出于breaksoftware的csdn博客) 创建字典 一般字典创建时,都是没有数据的, ...

  7. 彻底理解OkHttp - OkHttp 源码解析及OkHttp的设计思想

    OkHttp 现在统治了Android的网络请求领域,最常用的框架是:Retrofit+okhttp.OkHttp的实现原理和设计思想是必须要了解的,读懂和理解流行的框架也是程序员进阶的必经之路,代码 ...

  8. Java集合---LinkedList源码解析

    一.源码解析 1. LinkedList类定义 2.LinkedList数据结构原理 3.私有属性 4.构造方法 5.元素添加add()及原理 6.删除数据remove() 7.数据获取get() 8 ...

  9. 【vuejs深入三】vue源码解析之二 htmlParse解析器的实现

    写在前面 一个好的架构需要经过血与火的历练,一个好的工程师需要经过无数项目的摧残. 昨天博主分析了一下在vue中,最为基础核心的api,parse函数,它的作用是将vue的模板字符串转换成ast,从而 ...

最新文章

  1. 从Web2.0到Enterprise 2.0(三)Enterprise 2.0的三个方向
  2. C 语言编程 — 程序的编译流程
  3. oracle原始数据类型,Oracle基本数据类型存储格式浅析——RAW类型
  4. makefile与make
  5. Swift中为什么输入“..”报错
  6. kafka处理流式数据_通过Apache Kafka集成流式传输大数据
  7. activiti7关联mysql_学习笔记:一个MySQL实例有多个Activiti数据库问题
  8. GO语言学习之路22
  9. 字节跳动李本超:一年成为 Committer,我与 Flink 社区的故事
  10. 重磅!解读国内唯一入选全球顶会SIGCOMM的阿里云网络论文
  11. Android apk签名详解——AS签名、获取签名信息、系统签名、命令行签名
  12. 串口485接法图_rs485通讯接口定义图详解
  13. 异速联应用交付解决方案的优势
  14. ppt矩形里面的图片怎么放大缩小_PPT中的背景图片,如何裁剪其大小?
  15. centos7图形界面和dos界面
  16. 安卓手机如何一键去水印
  17. 电子签章,一章通用还有多远?
  18. Js与Jq实战:第七讲:jQuery基础
  19. 冒泡排序、插入排序、选择排序、希尔排序、堆排序、归并排序等常用排序算法的比较
  20. Photoshop如何快速选择定位到锁定状态的图层

热门文章

  1. 科技论文的种类_如何快速对科技论文分类
  2. DG(Data Guard)
  3. Swift的UIImage裁剪,缩放等代码实现
  4. javaweb之Html/Hss/JavaScript/BootStrap小结
  5. java 根据已有word模板进行数据下载导出
  6. 转换HTML内容为PDF格式
  7. 申请一个免费美国手机号码
  8. YTU 《过瘾的打折季》
  9. Kata Containers创始人:安全容器导论
  10. 怎么用计算机做目录,word怎么生成目录,教您Word文档如何自动生成目录