具体实现代码如下:
<?
//从环境变量中得到文件的相对路径
$page=substr($SCRIPT_NAME,1);
// 显示一个图标并连接到打印页
// 便于打印页面的生成程序pfp.php
?>
<a href="/blog_article/pfp/page/lt;/$page/gt;.html">;<img src="/blog_article/printer.gif" width="36" height="36" border="0" alt="点我跳转打印页面">打印本页</a>
把当前页面的名称传递到pfp.php程序中,这个程序使用PHP的“file”函数把页面作为一个字符串来处理。当这个页面被载入的时候,程序就可以增加、改写或删除HTML片段。
<?
ereg('^.*/',$SCRIPT_FILENAME,$tmp);
$page_path = substr($tmp[0],0,-1);
?>
<html>
<head>
<base href="http://<? echo $HTTP_HOST ?>/">
<meta name="robots" content="no index, no follow">
<title>Printer Friendly Page</title>
</head>
<body bgcolor="white">
<table border="0" cellpadding="5" cellspacing="0" width="630" >
<tr>
<td valign="top">
<?
// check if the filename for the page exists
if (!file_exists("$page.inc"))
{
echo "<strong>Error - The page <?=$page?>".
"does not exist on this site.</strong>";
}
else
{
// 得到页面的内容并把它放到一个字符串中
$fcontents = join('', file("$page.inc"));
// 忽略颜色属性,转换以'ignore'替代'color'
$fcontents = ereg_replace('color','ignore',$fcontents);
// 去除超链接中的 “_blank”
$fcontents = ereg_replace('target=\"_blank\"','',$fcontents);
// 替换</a>标记
$fcontents = ereg_replace('</a>','',$fcontents);
// 显示URL的绝对地址
$fcontents = ereg_replace('<a[^h]*href="/blog_article/(http_/[^/index.html"]*)"[^>]*>;([^]*)',
'<strong>\\2</strong><em>(\\1)</em>',$fcontents);
// 把相对链接转为绝对链接
$fcontents = ereg_replace(
'<a[^h]*href="/blog_article/([^/index.html"]*)"[^>]*>([^]*)',
"<strong>\\2</strong><em>(http://$HTTP_HOST/\\1)</em>";,
$fcontents);
// 背景颜色改回白色
$fcontents = ereg_replace('<body bgignore','<body bgcolor', $fcontents);
// if any markers left restore link end element
$fcontents = ereg_replace('','</a>',$fcontents);
// 输出页面
echo $fcontents;
}
?>
</td>
</tr>
<tr>
<td align="center"><hr width="90%"></td>
</tr>
<tr>
<td align="center">
<? include("$page_path/footer.inc"); ?>
</td></tr></table>
</body></html>
具体实现代码如下:
<?php
/***
* 多地址发邮件的类
* 示例:
$m = new email ( "hello there", // subject
"how are you?", // message body
"paul", // sender's name
"foo@foobar.com", // sender's email
array("paul@foobar.com", "foo@bar.com"), // To: recipients
"paul@whereever.com" // Cc: recipient
);
print "mail sent, result was" . $m->send();
*/
if ( ! defined( 'MAIL_CLASS_DEFINED' ) ) {
define('MAIL_CLASS_DEFINED', 1 );
class email {
// the constructor!
function email ( $subject, $message, $senderName, $senderEmail, $toList, $ccList=0, $bccList=0, $replyTo=0) {
$this->sender = $senderName . " <$senderEmail>";
$this->replyTo = $replyTo;
$this->subject = $subject;
$this->message = $message;
// set the To: recipient(s)
if ( is_array($toList) ) {
$this->to = join( $toList, "," );
} else {
$this->to = $toList;
}
// set the Cc: recipient(s)
if ( is_array($ccList) && sizeof($ccList) ) {
$this->cc = join( $ccList, "," );
} elseif ( $ccList ) {
$this->cc = $ccList;
}
// set the Bcc: recipient(s)
if ( is_array($bccList) && sizeof($bccList) ) {
$this->bcc = join( $bccList, "," );
} elseif ( $bccList ) {
$this->bcc = $bccList;
}
}
// send the message; this is actually just a wrapper for
// PHP's mail() function; heck, it's PHP's mail function done right :-)
// you could override this method to:
// (a) use sendmail directly
// (b) do SMTP with sockets
function send () {
// create the headers needed by PHP's mail() function
// sender
$this->headers = "From: " . $this->sender . "\n";
// reply-to address
if ( $this->replyTo ) {
$this->headers .= "Reply-To: " . $this->replyTo . "\n";
}
// Cc: recipient(s)
if ( $this->cc ) {
$this->headers .= "Cc: " . $this->cc . "\n";
}
// Bcc: recipient(s)
if ( $this->bcc ) {
$this->headers .= "Bcc: " . $this->bcc . "\n";
}
return mail ( $this->to, $this->subject, $this->message, $this->headers );
}
}
}
?>
具体实现代码如下:
<?php
/**
* 上一页 下一页
* site www.
*/
$limit=20; // 每页显示的行数
$numresults=mysql_query()("select * from TABLE where YOUR CONDITIONAL HERE order by WHATEVER");//换成你所需要的sql语句
$numrows=mysql_num_rows($numresults);
// next determine if offset has been passed to script, if not use 0
if (empty($offset)) {
$offset=1;
}
// 得到查询结果
$result=mysql_query("select id,name,phone ".
"from TABLE where YOUR CONDITIONAL HERE ".
"order by WHATEVER limit $offset,$limit");
// 现在显示查询结果
while ($data=mysql_fetch_array($result)) {
// 在这里插入您要显示的结果以及样式
}
// 显示按钮
if ($offset!=1) { // bypass PREV link if offset is 1
$prevoffset=$offset-20;
print "<a href=/index.html"$PHP_SELF?offset=$prevoffset\">上一页</a> \n";
}
// 计算页面数
$pages=intval($numrows/$limit);
if ($numrows%$limit) {
// has remainder so add one page
$pages++;
}
for ($i=1;$i<=$pages;$i++) { // 显示页数
$newoffset=$limit*($i-1);
print "<a href=/index.html"$PHP_SELF?offset=$newoffset\">$i</a> \n";
}
//检测是否最后一页了
if (!(($offset/$limit)==$pages) && $pages!=1) {
// not last page so give NEXT link
$newoffset=$offset+$limit;
print "<a href=/index.html"$PHP_SELF?offset=$newoffset\">下一页</a><p>\n";
}
?>