PHP+MYSQL的文章管理系统(二)


Posted in PHP onOctober 09, 2006

###############index.php######################
<?session_start();
require"./inc/func.php";
mscon();
require "./inc/header.inc";
?>
<script language="javascript">
function opwin(filename)
{                window.open("read_article.php?id="+filename,"","height=500,width=585,resizable=no,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");
        }

</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#003399" height="23">
  <tr>
    <td width="80">
      <div id="Layer2" style="position:absolute; left:7px; top:17px; width:43px; height:44px; z-index:2"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="80" height="60">
          <param name=movie value="images/logo.swf">
          <param name=quality value=high>
          <param name="wmode" value="transparent">
          <embed src="images/logo.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="80" height="60" wmode="transparent">
          </embed>
        </object></div>
      <div id="Layer1" style="position:absolute; left:-5px; top:61px; width:49px; height:37px; z-index:1"><img src="images/11.gif" width="58" height="55"></div>
    </td>
    <td width="539"> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="468" height="60">
          <param name=movie value="images/ti1.swf">
          <param name=quality value=high>
          <param name="wmode" value="transparent">
          <embed src="images/ti1.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="468" height="60" wmode="transparent">
          </embed>

      </object> </td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td background="images/211.gif" height="2"> </td>
  </tr>
</table>
<table><FORM name=form1 action=search.php  method=post target=_blank>
  <table width="80%" border="0" cellspacing="0" cellpadding="0" bgcolor="#009933" align="center">
    <tr>
    <td align="center">
    <input type="text" name="key">
  <select name="type">
  <option value=>全部类别</option>
<? $typ=file("list.txt");
$num=count($typ);
for($i=2;$i<=$num;$i++)
{
  echo"<option value=$typ[$i]>$typ[$i]</option>";}
      ?>
  </select>
  <select name="whe">
  <option value=>全部内容</option>
  <option value=1>文章内容</option>
  <option value=2>文章标题</option>
  <option value=3>加入时间</option>
  </select>
  <input type="hidden" name="submit" value="1">
  <input type="submit" name="submit" value="提交查询">
  </td>
  </tr>
</table>
</FORM></table>
<?
$type=trim($type);
  if($comm)
    {
     $sec="and comm=1";
     $fir="where comm=1";
    }
  if(!empty($type))
    $query="select count(*) from $table where type='$type' $sec";
  else
    $query="select count(*) from $table $fir";
  $res=mysql_db_query("$database",$query);
  if(@mysql_num_rows($res)>0)
    $tot=mysql_fetch_array($res);
  $total=$tot[0];
  $total_page=ceil($total/$pagenum);
  echo "<table width="80%" border="0" cellspacing="0" cellpadding="0" align=center>";
  echo "<tr><td>共:".$total."篇".$total_page."页</td></tr>";
  if(empty($page))
    $page=0;
  if(empty($offset))
    $offset=0;
  $offset=$pagenum*$page;
  if(!empty($type))
     $query="select * from $table where type='$type' $sec order by id desc limit $offset,$pagenum";
  else
    $query="select * from $table $fir order by id desc limit $offset,$pagenum";
  $res=mysql_db_query("$database",$query);
  if(@mysql_num_rows($res)>0)
     while($topic=mysql_fetch_array($res))
       {
         if(strlen($topic[title])>40)
          {
            $topic[title]=substr($topic[title],0,40) ;
            $topic[title]=$topic[title].".....";
          }
         if(trim($topic[time])==date(Y年m月d日))
           $topic[time]="<font color=#FF9900>$topic[time]</font>";
           echo" <tr><td>[$topic[type]]<a href=# onClick="opwin($topic[id])";>$topic[title]</a><font size=1>($topic[time])</font>";
        if($topic[comm]==1)
          echo "<img src="./images/comm.gif" alt="精品文章">";
        if($topic[locked]==1)
          echo "<img src="./images/locked.gif" alt="文章已锁定">";
        echo "</td>
          <td>阅读:$topic[hits] 次;评论:$topic[p_num]次</td>
          </tr>";
     }
else
   echo " 对不起,本栏 目暂没有任何文章!!!";
echo "</table>";
  ?>

<br>
<table width="80%" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td>
  <?
     $pre=$page-1;
     $next=$page+1;
if($page>0)
   echo "<a href="$php_self?page=$pre&type=$type">上一页</a><br><br>";
else
  echo "上一页<br><br>";  ?></td>
    <td><?if($page<$total_page-1)
   echo "   <a href="$php_self?page=$next&type=$type">下一页</a><br><br>";
else echo "   下一页<br><br>";?></td>
    <td>
<form> 跳转到:
        <select name="page" onchange="top.location='<? echo $php_self;?>?page='+document.forms[1].elements[0].value+'&type=<?echo $type;?>';" class="border">
          <?
  for($i=0;$i<$total_page;$i++)
    {
     $p=$i+1;
     echo "<option value=$i";
     if($page==$i) echo " selected" ;
     echo ">第".$p."页</option>n";
     }
?>
        </select> </form>
</td>
<td>
<form >选择栏目:
        <select name="type"  onchange="top.location='<? echo $php_self;?>?type='+document.forms[2].elements[0].value<?if($comm) echo"+'&comm=1'";?>;" >
          <? $typ=file("list.txt");
$num=count($typ);
for($i=0;$i<$num;$i++)
{
  echo"<option value=$typ[$i] "; if(trim($typ[$i])==$type) {  echo "  selected"; } echo ">$typ[$i]</option>";}
      ?>
        </select>
    </form>
</td><td><form method="post" action=<? echo $PHP_SELF;?>?type=<?echo $type;?> target="_balnk"><input type="submit" name="comm" value="精品文章" class=border></form></td>
</tr>
</table>
<?require "./inc/footer.inc";?>
#####################read_article.php#########################
<?
require"./inc/func.php";
if(!$id)
{
  echo"<script>window.close();</script>";
   exit();
}
mscon();
$query="select * from $table where id='$id'";
$res=mysql_db_query("$database",$query);
if(!$res)
  {
    echo "this article has been deleted or no this article!!";
    exit();
  }
$data=mysql_fetch_array($res);
add_hits($data[id]);
$pre=$data[id]-1;
$next=$data[id]+1;
?>
<HTML>
<HEAD>
<TITLE>
<?   echo "$data[title]--[$data[type]]";?>
</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<style type=text/css>
<!--
body,table,td,input,textarea {  font-family: "宋体"; font-size: 9pt}
select {  font-family: "宋体"; font-size: 9pt}
code {font-family: "Courier" ; font-size: 10pt}
a {  color: #005500}
a:hover {  color: #CC0000}
.border {border: 1px #000000 solid; background-color:transparent; list-style-position: inside; list-style-type: square}
-->
</style>
<script language="javascript">
function name()
{
  var theResult = true;
  var elem4 = null;

  if (document.forms[0].elements[0].value == "" || document.forms[0].elements[0].value == "undefined" || document.forms[0].elements[0].value == "null")
  {
    elem4 = prompt("请输入您的姓名:","");
    theResult = false;
    document.forms[0].elements[0].value = elem4;
  }
  return theResult;
}
function mail()
{
  var theResult = true;
  var elem1 = null
  if ((document.forms[0].elements[1].value.indexOf('@') == -1 || document.forms[0].elements[1].value == "" || document.forms[0].elements[1].value.indexOf('.') == -1))
  {
    elem1 = prompt("请输入您的正确的电子邮件地址。谢谢!!","");
    theResult = false;
    document.forms[0].elements[1].value = elem1;
  }
  return theResult;
}
function go()
{
var theResult=true;
theResult = name()&&mail();
return theResult;
}
</script>
</HEAD>
<BODY text=#000000 bgColor=#ffffff>
<TABLE borderColor=#339933 cellSpacing=0 borderColorDark=#ffffff
cellPadding=0 align=center borderColorLight=#000000 border=1 width=545>
  <TBODY>
  <TR vAlign=center bgColor=#009900>
    <TD background=images/third-back3.gif>
      <TABLE cellSpacing=0 cellPadding=0 width=100% border=0>
        <TBODY>
        <TR>
          <TD width=17> </TD>
          <TD width=590>
            <TABLE width="36%" align=center border=0>
              <TBODY>
              <TR>
                <TD bgcolor="#009900">
                  <DIV align=center><FONT face="Verdana, Arial, Helvetica, sans-serif" color=#ffffff><b>
                    <? echo $data[title];?>
                    </b></FONT></DIV>
                </TD></TR></TBODY></TABLE></TD>
          <TD width=19>
            <DIV align=center><A href="javascript:window.close()"><IMG height=17
            src="images/third-close.gif" width=17 align=absMiddle
            border=0 name=content_r03_c28></A></DIV>
          </TD></TR></TBODY></TABLE></TD></TR>
  <TR vAlign=center align=left bgColor=#cccccc>
    <TD>
      <TABLE cellSpacing=0 cellPadding=0 border=0 align="center" width="100%">
        <TBODY>
        <TR>
          <TD>
            <DIV align=left><A class=whitetxt
            href="read_article.php?id=<? echo  $pre;?>"><img src="images/prethread.gif" width="48" height="12" border="0"></A></DIV>
          </TD>
          <TD>
            <DIV align=left><a class=whitetxt
            href="read_article.php?id=<? echo $next;?>"><img src="images/nextthread.gif" width="48" height="12" border="0"></a></DIV>
          </TD>
          <TD><IMG
            height=16 src="images/mail.gif" width=16></TD>
          <TD class=myfont><A class=redtxt
            href="commend.php?id=<? echo "$data[id]&title=$data[title]";?>">推荐给朋友</A></TD>
          <TD> 发表时间:
            <? echo $data[time];?>
            阅读次数:
            <? echo $data[hits];?>
          </TD>
          <TD>  </TD>
        </TR>
        </TBODY>
      </TABLE>
    </TD></TR>
    <TR vAlign=top>
    <TD class=tenpt>
<?
if($data[locked]<>0)
{
  echo "<img src=images/lock.gif>对不起!本文已经被管理员锁定!";
}
else
  if($data[html]==1)
     highlight_string($data[cont]);
  else
     echo nl2br($data[cont]);
?>
      </TD>
  </TR>
  </TBODY></TABLE>
<table bordercolor=#339933 cellspacing=0 bordercolordark=#ffffff
cellpadding=0 align=center bordercolorlight=#000000 border=1 width=545>
  <tbody>
<TR bgColor=#cccccc>
    <th>
      <DIV align=center>发表评论</DIV>
    </th>
  </TR>
  <tr>
    <td>
<form name="form1" method="post" action="ping.php" onsubmit="return go()">
        您的姓名:
        <input type="text" name="name" class="border">
         您的电子邮件:
        <input type="text" name="mail" size=20 class="border">
        仅站长可见:<input type="checkbox" name="pub" value="<? echo $data[title];?>">
        <input type="hidden" name="p_id" value="<? echo $id;?>">
        <br>
        发表评论:
        <textarea name="cont" rows="8" cols="85"></textarea>
        <br>
        <br>
        <center>
          <input type="submit" name="Submit" value="提交" class="border">
          <input type="reset" name="Submit2" value="重写" class="border">
        </center></form>
        </td>
  </tr>
  <TR bgColor=#cccccc>
    <th>
      <DIV align=center>相关评论</DIV>
    </th>
  </TR>
  <tr>
  <td>
<?  $query="select * from $ping_tab where p_id='$id' order by time desc";
  $res=mysql_db_query("$database",$query);
  if(mysql_num_rows($res)>0)
   {$i=1;
   while($ping=mysql_fetch_array($res))
    echo "评论人:$ping[name]   电子邮件:$ping[mail]<br>  ".nl2br($ping[p_cont])."<br>时间:$ping[time]  来自:$ping[ip]<hr size=1>n" ;
   }
   else
   echo "暂时没有本文章的相关评论!";
  ?>
  </td>
  </tr>
  <tr bgcolor=#cccccc>
    <td>
      <div align=center><a
  href="javascript:window.close()">关闭窗口</a></div>
    </td>
  </tr>
  </tbody>
</table>
<?require "./inc/footer.inc";?> 

PHP 相关文章推荐
PHP+APACHE实现用户论证的方法
Oct 09 PHP
php中通过Ajax如何实现异步文件上传的代码实例
May 07 PHP
PHP中集成PayPal标准支付的实现方法分享
Feb 06 PHP
php全局变量和类配合使用深刻理解
Jun 05 PHP
php 检查电子邮件函数(自写)
Jan 16 PHP
Zend Framework教程之Application用法实例详解
Mar 14 PHP
微信自定义菜单的创建/查询/取消php示例代码
Aug 05 PHP
php源码 fsockopen获取网页内容实例详解
Sep 24 PHP
thinkPHP商城公告功能开发问题分析
Dec 01 PHP
Yii 2.0中场景的使用教程
Jun 02 PHP
PHP实现生成数据字典功能示例
May 24 PHP
PHP单文件上传原理及上传函数的封装操作示例
Sep 02 PHP
使用sockets:从新闻组中获取文章(二)
Oct 09 #PHP
通过ODBC连接的SQL SERVER实例
Oct 09 #PHP
如何对PHP程序中的常见漏洞进行攻击(下)
Oct 09 #PHP
模拟OICQ的实现思路和核心程序(三)
Oct 09 #PHP
模拟OICQ的实现思路和核心程序(一)
Oct 09 #PHP
PHP自动更新新闻DIY
Oct 09 #PHP
模拟OICQ的实现思路和核心程序(二)
Oct 09 #PHP
You might like
一个简单的MySQL数据浏览器
2006/10/09 PHP
PHP一些有意思的小区别
2006/12/06 PHP
PHP批量生成静态HTML的简单原理和方法
2014/04/20 PHP
PHP获取用户客户端真实IP的解决方案
2016/10/10 PHP
PHP 芝麻信用接入的注意事项
2016/12/01 PHP
PHP实现简单的计算器
2020/08/28 PHP
JavaScript中“+=”的应用
2007/02/02 Javascript
asp.net下使用jquery 的ajax+WebService+json 实现无刷新取后台值的实现代码
2010/09/19 Javascript
基于jquery实现的鼠标滑过按钮改变背景图片
2011/07/15 Javascript
js的压缩及jquery压缩探讨(提高页面加载性能/保护劳动成果)
2013/01/29 Javascript
通过js获取div的background-image属性
2013/10/15 Javascript
JQuery实现Ajax加载图片的方法
2015/12/24 Javascript
基于jquery实现轮播焦点图插件
2016/03/31 Javascript
JS动态的把左边列表添加到右边的实现代码(可上下移动)
2016/11/17 Javascript
AngularJS中下拉框的基本用法示例
2017/10/11 Javascript
nodejs 使用nodejs-websocket模块实现点对点实时通讯
2018/11/28 NodeJs
如何从头实现一个node.js的koa框架
2019/06/17 Javascript
Vue实现返回顶部按钮实例代码
2020/10/21 Javascript
微信小程序实现加入购物车滑动轨迹
2020/11/18 Javascript
使用python实现递归版汉诺塔示例(汉诺塔递归算法)
2014/04/08 Python
在Python的Django框架中使用通用视图的方法
2015/07/21 Python
python 计算数组中每个数字出现多少次--“Bucket”桶的思想
2017/12/19 Python
python实现将汉字保存成文本的方法
2018/11/16 Python
Python如何把字典写入到CSV文件的方法示例
2020/08/23 Python
HTML5 本地存储实现购物车功能
2017/09/07 HTML / CSS
Bootstrap File Input文件上传组件
2020/12/01 HTML / CSS
英国最大的宠物食品和宠物用品网上零售商: Zooplus
2016/08/01 全球购物
建筑工程技术应届生自荐信
2013/09/27 职场文书
库房管理员岗位职责
2014/03/09 职场文书
新员工考核评语
2014/12/31 职场文书
我们的节日元宵节活动总结
2015/02/06 职场文书
大雁塔英文导游词
2015/02/10 职场文书
信访工作个人总结
2015/03/03 职场文书
南京南京观后感
2015/06/02 职场文书
2016年入党心得体会范文
2016/01/23 职场文书
vue 给数组添加新对象并赋值
2022/04/20 Vue.js