source.php查看源文件
程序员文章站
2022-04-22 15:25:10
<?php
/**
* show source
*
* @author avenger <avenger@php.net>
* @version $id 2003-07-10 9:09:03 $
*/
require_once 'header.inc.php';
tpl_load('left.tpl');
// check url value
if (!isset($_get['file'])) {
$body = "no page url specified.";
} else {
// fix the security hole, thx for jun_test#hotmail.com
$url = str_replace('..', '', $_get['file']);
if(file_exists($url)) {
$body = "<h4>source of: /".htmlentities($url)."</h4><hr size=1>";
// if this is a legal dir, then it is under the docroot, else use basename
if (dirname($url)) {
$page_name = $global['path']."/$url";
} else {
$page_name = basename($url);
}
if (strpos($page_name,'header.inc.php') || $page_name=='header.inc.php') {$page_name='header.inc.bak';}
if (strpos($page_name,'config.php') || $page_name=='config.php') {$page_name='my/config.php.bak';}
$body .= "<!-- ".htmlentities($page_name)." -->\n<code>";
$body .= highlight_file($page_name,true);
$body .= "</code>\n<br><hr size=1><br><br>\n";
} else {
$body .= "<table border='0'><tr><td><img hspace='5' vspace='5' src='/images/page.gif' width='25' height='33' border='0' alt=''></td><td valign='bottom'><h4>该文件不存在!</h4></td></tr></table><hr size=1><font style='color: black; font: 8pt/11pt verdana'>exceed php was unable to link to the page you requested. the page might be temporarily unavailable.</font>\n";
}
}
$left_1 = ' "open source"(开放源码)被非赢利软件组织(美国的open source initiative协会)注册为认证标记,并对其进行了正式的定义,用于描述那些源码可以被公众使用的软件,并且此软件的使用、修改和发行也不受许可证的限制。开放源码软件通常是有版权 ( copyright ) 的 ...<div align="right">[<a href="/?n=showfaq&a=9" class="en1">more...</a>]<div>';
$left_2 = '
这里是站点所用到的一些公共文件:
<ul>
<li><a href="/?n=source&file=main.php">main.php</a></li>
<li><a href="/?n=source&file=header.inc.php">header.inc.php</a></li>
<li><a href="/?n=source&file=inc/global.php">global.php</a></li>
<li><a href="/?n=source&file=inc/function.inc.php">function.inc.php</a></li>
<li><a href="/?n=source&file=inc/layerout.inc.php">layerout.inc.php</a></li>
<li><a href="/?n=source&file=inc/calendar.inc.php">calendar.inc.php</a></li>
</ul>
<a href="/?n=source&file=source.php">source.php文件本身。</a>
<br><br>
';
// my name :)
$s_name = 'source.php';
// import template now !!!
$tpl->setfile("main","left.tpl");
// import block
$tpl->setblock("main","aleft","left1");
$tpl->setvar(
array(
'ltitle' => '关于 open source',
'left' => $left_1,
));
$tpl->parse('left1','aleft',true);
$tpl->setvar(
array(
'ltitle' => '其它页面代码',
'left' => $left_2,
));
$tpl->parse('left1','aleft',true);
$tpl->setvar("filehead",file_head());
$tpl->setvar("filepic",'');
$tpl->setvar("title","show source - ".htmlentities($url));
$tpl->setvar("desc","开放源码,show source,php");
$tpl->setvar("keywords","开放源码,show source,php");
$tpl->setvar("bar",'');
$tpl->setvar("body",$body);
$tpl->setvar("filefoot",file_foot());
tpl_output();
?>
/**
* show source
*
* @author avenger <avenger@php.net>
* @version $id 2003-07-10 9:09:03 $
*/
require_once 'header.inc.php';
tpl_load('left.tpl');
// check url value
if (!isset($_get['file'])) {
$body = "no page url specified.";
} else {
// fix the security hole, thx for jun_test#hotmail.com
$url = str_replace('..', '', $_get['file']);
if(file_exists($url)) {
$body = "<h4>source of: /".htmlentities($url)."</h4><hr size=1>";
// if this is a legal dir, then it is under the docroot, else use basename
if (dirname($url)) {
$page_name = $global['path']."/$url";
} else {
$page_name = basename($url);
}
if (strpos($page_name,'header.inc.php') || $page_name=='header.inc.php') {$page_name='header.inc.bak';}
if (strpos($page_name,'config.php') || $page_name=='config.php') {$page_name='my/config.php.bak';}
$body .= "<!-- ".htmlentities($page_name)." -->\n<code>";
$body .= highlight_file($page_name,true);
$body .= "</code>\n<br><hr size=1><br><br>\n";
} else {
$body .= "<table border='0'><tr><td><img hspace='5' vspace='5' src='/images/page.gif' width='25' height='33' border='0' alt=''></td><td valign='bottom'><h4>该文件不存在!</h4></td></tr></table><hr size=1><font style='color: black; font: 8pt/11pt verdana'>exceed php was unable to link to the page you requested. the page might be temporarily unavailable.</font>\n";
}
}
$left_1 = ' "open source"(开放源码)被非赢利软件组织(美国的open source initiative协会)注册为认证标记,并对其进行了正式的定义,用于描述那些源码可以被公众使用的软件,并且此软件的使用、修改和发行也不受许可证的限制。开放源码软件通常是有版权 ( copyright ) 的 ...<div align="right">[<a href="/?n=showfaq&a=9" class="en1">more...</a>]<div>';
$left_2 = '
这里是站点所用到的一些公共文件:
<ul>
<li><a href="/?n=source&file=main.php">main.php</a></li>
<li><a href="/?n=source&file=header.inc.php">header.inc.php</a></li>
<li><a href="/?n=source&file=inc/global.php">global.php</a></li>
<li><a href="/?n=source&file=inc/function.inc.php">function.inc.php</a></li>
<li><a href="/?n=source&file=inc/layerout.inc.php">layerout.inc.php</a></li>
<li><a href="/?n=source&file=inc/calendar.inc.php">calendar.inc.php</a></li>
</ul>
<a href="/?n=source&file=source.php">source.php文件本身。</a>
<br><br>
';
// my name :)
$s_name = 'source.php';
// import template now !!!
$tpl->setfile("main","left.tpl");
// import block
$tpl->setblock("main","aleft","left1");
$tpl->setvar(
array(
'ltitle' => '关于 open source',
'left' => $left_1,
));
$tpl->parse('left1','aleft',true);
$tpl->setvar(
array(
'ltitle' => '其它页面代码',
'left' => $left_2,
));
$tpl->parse('left1','aleft',true);
$tpl->setvar("filehead",file_head());
$tpl->setvar("filepic",'');
$tpl->setvar("title","show source - ".htmlentities($url));
$tpl->setvar("desc","开放源码,show source,php");
$tpl->setvar("keywords","开放源码,show source,php");
$tpl->setvar("bar",'');
$tpl->setvar("body",$body);
$tpl->setvar("filefoot",file_foot());
tpl_output();
?>