以下是我们目前正在进行的网站设计/迁移(MAJOR HEADACHES)从直接的PHP / HTML网站到基于Drupal的网站的交易。我们有我们的家乡人(即我)在做事情,然后我们有设计人员,他们也有第三方做事。几个星期前,我使用旧网站的一些代码创建了一个视图 - drupal视图,它扫描目录并列出目录中有关我们员工报告的所有内容。从那时起我就没有碰过它,它一直很好,因为其他6页以同样的方式完成。星期四下午,该页面突然停止工作,只会呈现一个空白页面。我没碰过它,尽可能地告诉我其他人也没有。我将它与其他页面进行了比较,但我看不出有什么不妥。我错过了什么吗?或者这是Drupal问题吗?
<?php
$PHP_SELF = '/' . current_path();
$base = DRUPAL_ROOT . "/staff-reports";
$thisyear = date("Y");
# Strip out any HTML tags to eliminate cross-site scripting.
foreach ($_GET as $value) {
$value = preg_replace("/<(.*?)>/","",$value);
}
# Then grab each GET value into a variable.
foreach ($_GET as $varname => $value) {
$$varname = $value;
}
# If a year was not specified, use the current year by default.
if (!$year) {
$year = $thisyear;
}
# List the year folders in the base directory (2001, 2002, et cetera).
if ($handle = opendir($base)) {
while (false !== ($file = readdir($handle))) {
// echo $file . '<br />';
if( is_dir( $base . '/' . $file ) ){
// echo $file . 'Is a directory <br />';
if (preg_match("/\d\d\d\d/",$file)) {
$years[count($years)] = $file;
}
}
}
closedir($handle);
rsort($years);
}
# List the target year directory.
$reports = array();
$directory = $base . '/' . $year;
if ($handle = opendir($directory)) {
while (false !== ($file = readdir($handle))) {
if (preg_match("/staff-report-\d\d\d\d-\d\d-\d\d\..../",$file)) {
$reports[count($reports)] = $file;
}
}
closedir($handle);
if (count($reports)) {
sort($reports);
}
}
print "<table cellpadding=\"5\" border=\"1\" summary=\"Meetings\"><tr valign=\"top\">";
# Print the year index in the first column.
print "<td align=\"center\"><p><span class=\"bold\">Year index</span></p>\n";
for ($i = 0; $i < count($years); $i++) {
if ($years[$i] == $year) {
print "<b>";
}
print "<a href=\"$PHP_SELF?year=$years[$i]\">$years[$i]</a><br />\n";
if ($years[$i] == $year) {
print "</b>";
}
}
print "</td>";
# Print the list of issues for the specified year in the other column.
print "<td align=\"center\"><p><span class=\"bold\">$year reports</span></p>\n";
if (count($reports)) {
# print count($reports) . " issues<p>";
for ($i = 0; $i < count($reports); $i++) {
$y = substr($reports[$i],13,4);
$m = substr($reports[$i],18,2);
$d = substr($reports[$i],21,2);
# print "<a href=\"/staff-reports/$year/$reports[$i]\">$m/$d/$y</a><br />\n";
print "<a href=\"/staff-reports/$year/$reports[$i] \ "> ";
print date("F j, Y", mktime(0,0,0,$m,$d,$y));
print "</a><br />\n";
}
} else {
print "No reports";
}
print "<br />\n";
print "</td></tr></table>\n";
?>
<p>To view these documents, you need a PDF reader such as the <a
href="http://www.adobe.com/products/acrobat/readstep2.html">Adobe Reader</a>.</p>
<hr />
<?php
?>
答案 0 :(得分:3)
基本PHP:"
- 引用的字符串不能包含"
- 引号,除非它们被转义:
print "<a href=\"/staff-reports/$year/$reports[$i] \ "> ";
^^
您的baskslash正在逃避空格,而不是"
字符。