oracle|分页|数据|数据库|显示
程序分成四部份
1.. 初始化
2.. 取数据库中的数据
3.. 计算要显示的页数
4.. 送出资料
这个程序在 BIGLOBE 上有实作,由于这是一间 ISP 公司,因此在设定时限定连结或专线的会员才能看到,进入前要输入帐号及密码。为了保护留言者的隐私,留言以马赛克处理。
$WebmasterIPArray = array(
"10.0.1.30", // 管理人员甲的机器 IP
"10.0.2.28" // 管理人员乙的机器 IP
);
$WebmasterIP=false;
for ($i=0; $i<Count($WebmasterIPArray); $i++) {
if ($REMOTE_ADDR == $WebmasterIPArray[$i]) $WebmasterIP=true;
}
// 之后初始化 Oracle 程序略
显示程序和留言程序的初始化部份都差不多,但显示程序多加了一个功能,设定Webmaster 的电脑。将 Webmaster 使用的 IP Address 加在 $WebmasterIPArray 阵列变数中,可以在显示留言时,显示删除留言的字串,方便处理不当的留言。
$handle=ora_logon("user38@WWW","iam3849") or die;
$cursor=ora_open($handle);
ora_commitoff($handle);
$query="SELECT serial, ref, id, alias, ip, TO_CHAR(msgdate,
'yyyy/mm/dd hh:mi:ss'), email, msg FROM guestbook where flag='1' order by
msgdate desc";
ora_parse($cursor, $query) or die;
ora_exec($cursor);
$i=0;
while(ora_fetch($cursor)) {
$guestbook[$i][0] = ora_getcolumn($cursor,0);
$guestbook[$i][1] = ora_getcolumn($cursor,1);
$guestbook[$i][2] = ora_getcolumn($cursor,2);
$guestbook[$i][3] = ora_getcolumn($cursor,3);
$guestbook[$i][4] = ora_getcolumn($cursor,4);
$guestbook[$i][5] = ora_getcolumn($cursor,5);
$guestbook[$i][6] = ora_getcolumn($cursor,6);
$guestbook[$i][7] = ora_getcolumn($cursor,7);
$i++;
}
ora_close($cursor);
ora_logoff($handle);
在初始化后,就可以连上 Oracle 资料库,将留言的资料取出放在 $guestbook阵列中。取得资料后,就赶紧将资料库关闭,再来处理 $guestbook 阵列的资料了。
if ($QUERY_STRING!="") {$page = $QUERY_STRING;
} else {
$page = 0;
}
这一段程序判断是要显示第几页,内定值是显示第一页。要显示第三页的页面,需要使用 http://xxxxxx/index.php?2 的格式,也就是传入 $QUERY_STRING,余类推。之后的数行程序,都是用来处理显示的页数及笔数的资料。
$msgnum=20; // 每页二十笔
要改变每页的显示笔数,可以改 $msgnum 变数。程序的内定值为 20 笔。
for ($i=$start; $i<$end; $i++) {echo "<p><hr><p>\n";
echo "<p>\n<font color=e06060>".$guestbook[$i][5]."</font> ";
if ($guestbook[$i][6]!="") echo "<a
href=mailto:".$guestbook[$i][6].">";
echo "<strong>".$guestbook[$i][3]."</strong>";
if ($guestbook[$i][6]!="") echo "</a>";
echo "<br>\n";
if ($WebmasterIP) echo "<a href=erase.php?".$guestbook[$i][0].">删除
本篇!!</a> (".$guestbook[$i][2].") ";
echo "<font size=-1 color=c0c0c0>from:
".$guestbook[$i][4]."</font><p>\n";
$msg=base64_decode($guestbook[$i][7]);
$msg=nl2br($msg);
echo $msg;
echo "<p>\n";
}
这一段程序就是真正显示留言资料给使用者看的程序了。利用 for 回圈,将$guestbook 阵列的资料按照设定的页数取出,显示给使用者看。值得一提的是,若看留言的机器 IP 为 $WebmasterIPArray 变数阵列中的一个元素的话,则会在留言者的匿称后显示 "删除本篇!!" 的字串,供管理人员删除不当留言。
以下即为删除留言的程序。
<?php
file://---------------------------
// 留言删除程序 erase.php
// Author: Wilson Peng
// Copyright (C) 2000
file://---------------------------
putenv("ORACLE_SID=WWW");
putenv("NLS_LANG=american_taiwan.zht16big5");
putenv("ORACLE_HOME=/home/oracle/product/7.3.2");
putenv("LD_LIBRARY_PATH=/home/oracle/product/7.3.2/lib");
putenv("ORA_NLS=/home/oracle/product/7.3.2/ocommon/nls/admin/data");
putenv("ORA_NLS32=/home/oracle/product/7.3.2/ocommon/nls/admin/data");
$handle=ora_logon("user38@WWW","iam3849") or die;
$cursor=ora_open($handle);
ora_commitoff($handle);
$query="UPDATE guestbook set flag='0' where
serial='".$QUERY_STRING."'";
ora_parse($cursor, $query) or die;
ora_exec($cursor);
ora_close($cursor);
ora_logoff($handle);
Header("Location: ./index.php");
?>
其实这个程序很单纯,只要打开 Oracle 资料库,将欲删除的序号那笔资料的flag 栏位设成 0 就可以了,不用将资料真的从资料库上移除。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver Mac version
Visual web development tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 English version
Recommended: Win version, supports code prompts!

WebStorm Mac version
Useful JavaScript development tools
