1

此脚本显示照片,我包含在底部 footer.php 但 php 页面页脚未显示任何结果我该如何解决此问题请帮助我

这是照片库代码

$title="";

$logo='';

trouble turn it off.
//0=off 1=on
$makethumbs=1;

// default=thmb.jpeg
$thumbext='thumb.jpeg';


$twidth=170;
$theight=130;



$pwidth = 540;
$pheight = 540;


$rows=4;
$cols=2;


//0=off 1=on
$showfilename=1;
$showpathname=0;


//0=off 1=on
$showexifcomment=1;


//0=off 1=on
$window=1;


//0=off 1=on
$javascript=1;


//0=off 1=on
$linktophoto=1;


$header="NULL";
$footer="NULL";
$stylesheet="styles.css";
$divider=" | "; //
$pagedivider=" | "; //

//No need to mess with anything below here.
error_reporting(E_ALL & ~E_NOTICE);
//Part of this function comes from http://www.php.net/manual/en/function.getimagesize.php
function thumb_maker($filename, $minwidth, $minheight) {
    global $thumbext,$makethumbs;
    if ($makethumbs==1) {
        if (file_exists($filename.$thumbext)) {
            $photosize = getimagesize($filename.$thumbext);
            if (max($minwidth,$minheight)!=max($photosize[0],$photosize[1])) {
            unlink($filename.$thumbext);
            }
        }
        if (!file_exists($filename.$thumbext) && file_exists($filename)) {
            echo "<br/>";
            set_time_limit(60);
            $photosize = getimagesize($filename);
            // Get image size and scale ratio
            $scale = min($minwidth/$photosize[0], $minheight/$photosize[1]);
            if ($scale < 1) {
               $width = floor($scale*$photosize[0]);
               $height = floor($scale*$photosize[1]);
            }
            else {
               $width = $minwidth;
               $height = $minheight;
            }
            if ($photosize['mime']=="image/jpeg") {
                $resizedimage = imagecreatetruecolor($width, $height);
                $thumbimage = imagecreatefromjpeg($filename);
                imagecopyresampled($resizedimage, $thumbimage, 0, 0, 0, 0, $width, $height, $photosize[0], $photosize[1]);
                imagejpeg($resizedimage,$filename.$thumbext,50);
                imageDestroy($resizedimage);
                imageDestroy($thumbimage);
            }
        }
    }
}

//Part of this function comes from http://www.php.net/manual/en/function.getimagesize.php
function gallery_sizer($photo,$minwidth,$minheight) {
    if (file_exists($photo)) {
        $photosize = getimagesize("$photo");
        # Get image size and scale ratio
        $scale = min($minwidth/$photosize[0], $minheight/$photosize[1]);
        if ($scale <= 1) {
            $width = floor($scale*$photosize[0]);
            $height = floor($scale*$photosize[1]);
        }
        else {
            $width = floor($photosize[0]);
            $height = floor($photosize[1]);
        }
        return array($width,$height,$photosize[0],$photosize[1]);
    }
}

function exif_comment($photo) {
    $comment=NULL;
    if (file_exists($photo) && function_exists('exif_read_data')) {
        $exif = exif_read_data($photo, 0, true);
    if (array_key_exists('COMMENT', $exif)) {
            $comment=str_replace("\n", "<br />", strip_tags($exif['COMMENT'][0]));
    }
    }
    return $comment;
}


function getdirs($dir) {
    $dirs=array();
    chdir($dir);
    if ($handle = opendir($dir)) {
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != ".."){
                if (is_dir($file)) {
                    $dirs[] = $file;
                }
            }
        }
        closedir($handle);
    }
    sort($dirs);
    return $dirs;
}


function getphotos($photodir) {
        global $thumbext;
        $nphotos=array();
        if ($handle = opendir($photodir)) {
            while (false !== ($file = readdir($handle))) {
                if ($file != "." && $file != ".." && !eregi(".jpg".$thumbext."$",$file) && eregi(".jpg$",$file)){
           $mtime = filemtime($photodir."/".$file);
                        $nphotos[$mtime] = $file;
                }
            }
            closedir($handle);
        }
        krsort($nphotos);
        $photos = array();
        foreach ($nphotos as $key=>$value) {
            array_push($photos,$value);
        }
        return $photos;
}

function thumb_gallery($photonum) {
    global $photos, $photourl, $photodir, $twidth, $theight, $rows, $cols, $showfilename,$showpathname,$showexifcomment,$linktophoto,$thumbext, $wallpapers, $window, $javascript, $query, $pagedivider;
        if ($photonum>count($photos)-1) {
            $photonum=count($photos)-1;
        }
        if (($photonum)<=0) {
            $photonum=0;
        }

        if(isset($wallpapers)) { $query="&amp;wallpapers=".urlencode($wallpapers); }
        for ($tr = 1; $tr <= $rows; $tr++) {
            $photobody[]="<tr>";
            for ($td = 1; $td <= $cols; $td++) {
                $photobody[]="<td align=\"center\" valign=\"top\">";
                if (array_key_exists($photonum, $photos)) {
                if (file_exists($photodir."/".$photos[$photonum].$thumbext)) {
                    $size=gallery_sizer($photodir."/".$photos[$photonum].$thumbext,$twidth,$theight);
                    $comment=exif_comment($photodir."/".$photos[$photonum]);
                    $jswindowsize=gallery_sizer($photodir."/".$photos[$photonum],1,1);
                    $link = $photourl."/".$photos[$photonum].$thumbext;
                    if ($linktophoto==1) { $linktarget="http://".$_SERVER['HTTP_HOST'].$photourl."/".$photos[$photonum]; } else { $linktarget="http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."?p=".urlencode($photos[$photonum]).$query; }
                    if ($window==1) { if ($javascript==1) { $linktarget='javascript:Popup(\''.$linktarget.'\',\''.($jswindowsize[2]+15).'\',\''.($jswindowsize[3]+15).'\')';    } else { $target="_blank"; } } else { $target="_self"; }
                    if ($photonum<=count($photos)-1) {




                    if ($javascript==0) {
                        $photobody[]="<a href=\"$linktarget\" target=\"$target\">";
                        }
                    else {  $photobody[]="<a href=\"$linktarget\">"; }
                    }
                        $photobody[]="<img class=\"imagedropshadow\" src=\"$link\" width=\"$size[2]\" height=\"$size[3]\" alt=\"$photos[$photonum]\" border=\"1\" /></a><br />";
                }
                if ($photos[$photonum]) {
                    if ($showexifcomment==1 && !is_null($comment)) { $photobody[]='<p class="thmbcaption">'.$comment.'</p>'; }
                    if ($showfilename==1) { $photobody[]='<p class="thmbcaption">'.$dir.'</p>'; }
                    if ($showpathname==1) { $photobody[]='<p class="thmbcaption">http://'.$_SERVER['HTTP_HOST'].$photourl.'/'.$photos[$photonum].'</p>'; }
                }
                }
                $photobody[]="</td>";
                $photonum++;
            }
            $photobody[]="</tr>";
        }
        unset($tr, $td);

        #this is down here for a reason don't move it and use array_unshift instead. Trust me.
        if (($photonum-($rows*$cols))>0) { $prev="<a href=\"".$_SERVER['PHP_SELF']."?pn=".($photonum-(($rows*$cols)*2)).$query."\"class=\"style1\">&lt;&lt; <font face=\"Tahoma\" class=\"ws10\">Previous</font></a>"; } else { $prev=""; }
        if (($photonum)<(count($photos))) { $next="<a href=\"".$_SERVER['PHP_SELF']."?pn=".$photonum.$query."\"class=\"style1\"><font face=\"Tahoma\" class=\"ws10\">Next&gt;&gt;</font></a>"; } else { $next=""; }

        $photopage=array();
        $photopage[]="Pages: ";
        for ($pagelink=0, $pagenum=1; $pagelink<=count($photos); $pagelink+=($rows*$cols), $pagenum++) {
            //thanks to DC for this addition.
        if ($pagenum > 1){
            $photopage[]=$pagedivider."<a href=\"$_SERVER[PHP_SELF]?pn=".($pagelink).$query."\"class=\"style1\"><font face=\"Tahoma\" class=\"ws10\">$pagenum</font></a>  ";
            }
            else {
           $photopage[]=" <a href=\"$_SERVER[PHP_SELF]?pn=".($pagelink).$query."\" class=\"style1\"><font face=\"Tahoma\" class=\"ws10\">$pagenum</font></a>  ";
        }

        }
        unset($pagelink, $pagenum);
        $photopage=implode("", $photopage);

        if ($photonum >= count($photos)) { $endnum=count($photos); } else { $endnum=$photonum; }
        $photobody[]="<tr><td colspan=\"".$cols."\"><table width=\"100%\" border=\"0\"><tr><td width=\"33%\"><div align=\"left\" class=\"caption\">".$prev."</div></td><td width=\"33%\"><div align=\"center\" class=\"caption\">Photos <strong>".($photonum-(($rows*$cols)-1))."</strong> to <strong>".$endnum."</strong> of <strong>".count($photos)."</strong><br />".$photopage."</div></td><td width=\"33%\"><div align=\"right\" class=\"caption\">".$next."</div></td></tr></table></td></tr>";
        array_unshift($photobody, "<tr><td colspan=\"".$cols."\"><table width=\"100%\" border=\"0\"><tr><td width=\"33%\"><div align=\"left\" class=\"caption\">".$prev."</div></td><td width=\"33%\"><div align=\"center\" class=\"caption\">Photos <strong>".($photonum-(($rows*$cols)-1))."</strong> to <strong>".$endnum."</strong> of <strong>".count($photos)."</strong><br />".$photopage."</div></td><td width=\"33%\"><div align=\"right\" class=\"caption\">".$next."</div></td></tr></table></td></tr>");

        #put the table tag at the top of the array.
        array_unshift($photobody, '<table width="100%" border="0" cellspacing="0" cellpadding="3">');
        $photobody[]='</table>';

        if ($window==1 && $javascript==1) {
            array_unshift($photobody, '<SCRIPT language="JavaScript">function Popup(url,width,height) { PopupWindow = window.open (\'\', \'PopupWindow\',\'scrollbars=0,resizable=1,height=\'+height+\',width=\'+width+\',left=100,top=20\'); PopupWindow.focus(); PopupWindow.location.href = url; }</SCRIPT>');
        }

    return $photobody;
}

function photo_gallery($photo) {
    global $photodir, $photourl, $pwidth, $pheight, $thumbsurl, $window, $photos, $wallpapers, $thumbext, $header,$showfilename,$showpathname,$showexifcomment;
    $photobody=array();

    if (isset($photo)) {

        if(isset($wallpapers)) { $query="&amp;wallpapers=".urlencode($wallpapers); }
    foreach ($photos as $key => $value) {
         if($photo==$value) {
          if (array_key_exists($key+1, $photos)) {
            if($photos[$key+1]) {
              $nextphoto="<br /><a href=\"".$_SERVER['PHP_SELF']."?p=".$photos[$key+1].$query."\">Next Photo &gt;</a>";
              $nextphotothumb="<a href=\"".$_SERVER['PHP_SELF']."?p=".$photos[$key+1].$query."\"><img alt=\"\" src=\"".$photourl."/".$photos[$key+1].$thumbext."\" height=\"50\" border=\"1\" /></a>";
            }
          }
              else {
              $nextphoto=NULL;
              $nextphotothumb=NULL;
              }
          if (array_key_exists($key-1, $photos)) {
            if($photos[$key-1]) {
              $prevphoto="<br /><a href=\"".$_SERVER['PHP_SELF']."?p=".$photos[$key-1].$query."\">&lt; Previous Photo</a>";
              $prevphotothumb="<a href=\"".$_SERVER['PHP_SELF']."?p=".$photos[$key-1].$query."\"><img alt=\"\" src=\"".$photourl."/".$photos[$key-1].$thumbext."\" height=\"50\" border=\"1\" /></a>";
            }
          }
              else {
              $prevphoto=NULL;
              $prevphotothumb=NULL;
              }
         }
    }
        $size=gallery_sizer($photodir.'/'.$photo,$pwidth,$pheight);
        $comment=exif_comment($photodir.'/'.$photo);

        //close window or prev next menu section
        $photobody[]='<table width="100%" border="0" cellspacing="0" cellpadding="3">';
        $photobody[]="<tr class=\"imageborder\"><td width=\"33%\"></td><td align=\"center\" width=\"33%\"><div align=\"center\" class=\"caption\"></div></td><td align=\"right\" width=\"33%\"></td></tr>";

        if ($window==1) {
        $photobody[]="<tr class=\"imageborder\"><td width=\"33%\"><a href=\"javascript:window.close()\">Close Window</a></td><td align=\"center\" width=\"33%\"><div align=\"center\" class=\"caption\">";
        $photobody[]="</div></td><td align=\"right\" width=\"33%\"></td></tr>";
        }
        else {

        $photobody[]="<tr class=\"imageborder\"><td width=\"33%\"><div align=\"left\" class=\"caption\">".$prevphotothumb.$prevphoto."</div></td><td align=\"center\" width=\"33%\"><div align=\"center\" class=\"caption\">";
        if ($header=="NULL") {
            if (isset($wallpapers)) { $photobody[]="<a href=\"".$_SERVER['PHP_SELF']."?wallpapers=".urlencode($wallpapers)."&amp;p=".$photo."&amp;slide=1\">Start Slideshow</a>\n"; }
            else { $photobody[]="<a href=\"".$_SERVER['PHP_SELF']."?p=".$photo."&amp;slide=1\">Start Slideshow</a>\n"; }
        }
        $photobody[]="</div></td><td align=\"right\" width=\"33%\"><div align=\"right\" class=\"caption\">".$nextphotothumb.$nextphoto."</div></td></tr>";
        }


        $photobody[]='<tr><td colspan="3" align="center">';
        $photobody[]='<img src="'.$photourl.'/'.$photo.'" width="'.$size[0].'" height="'.$size[1].'" border="0" alt="" class="imageborder" />';

        if ($photo) {
            if ($showexifcomment==1) { $photobody[]='<p class="photocaption">'.$comment.'</p>'; }
            if ($showfilename==1) { $photobody[]='<p class="photocaption">'.$photo.'</p>'; }
            if ($showpathname==1) { $photobody[]='<p class="photocaption">http://'.$_SERVER['HTTP_HOST'].$photourl.'/'.$photo.'</p>'; }
        }

        $photobody[]='</td></tr>';
        $photobody[]='</table>';
    }
    return $photobody;
}

function photo_slides($photo) {
    global $photodir, $photourl, $pwidth, $pheight, $thumbsurl, $window, $photos, $wallpapers, $thumbext, $header,$showfilename,$showpathname,$showexifcomment;
    $photobody=array();

    if (isset($photo)) {

        if(isset($wallpapers)) { $query="&amp;wallpapers=".urlencode($wallpapers); }

    foreach ($photos as $key => $value) {

         if($photo==$value) {
          if (array_key_exists($key+1, $photos)) {
            if($photos[$key+1]) {
              $nextphoto="<br /><a href=\"".$_SERVER['PHP_SELF']."?p=".$photos[$key+1].$query."\">Next Photo &gt;</a>";
              $nextphotothumb="<a href=\"".$_SERVER['PHP_SELF']."?p=".$photos[$key+1].$query."\"><img alt=\"\" src=\"".$photourl."/".$photos[$key+1].$thumbext."\" height=\"50\" border=\"1\" /></a>";
            }
          }
              else {
              $nextphoto=NULL;
              $nextphotothumb=NULL;
              }
          if (array_key_exists($key-1, $photos)) {
            if($photos[$key-1]) {
              $prevphoto="<br /><a href=\"".$_SERVER['PHP_SELF']."?p=".$photos[$key-1].$query."\">&lt; Previous Photo</a>";
              $prevphotothumb="<a href=\"".$_SERVER['PHP_SELF']."?p=".$photos[$key-1].$query."\"><img alt=\"\" src=\"".$photourl."/".$photos[$key-1].$thumbext."\" height=\"50\" border=\"1\" /></a>";
            }
          }
              else {
              $prevphoto=NULL;
              $prevphotothumb=NULL;
              }
         }
    }
        $size=gallery_sizer($photodir.'/'.$photo,$pwidth,$pheight);
        $comment=exif_comment($photodir.'/'.$photo);
        $photobody[]='<table width="100%" border="0" cellspacing="0" cellpadding="3">';

        $photobody[]="<tr class=\"imageborder\"><td width=\"33%\"><div align=\"left\" class=\"caption\">".$prevphotothumb.$prevphoto."</div></td><td align=\"center\" width=\"33%\"><div align=\"center\" class=\"caption\">";
        if ($header=="NULL") {
        if (isset($wallpapers)) { $photobody[]="<a href=\"".$_SERVER['PHP_SELF']."?wallpapers=".urlencode($wallpapers)."&amp;p=".$photo."\">Stop Slideshow</a>\n"; }
        else { $photobody[]="<a href=\"".$_SERVER['PHP_SELF']."?p=".$photo."\">Stop Slideshow</a>\n"; }
        }
        $photobody[]="</div></td><td align=\"right\" width=\"33%\"><div align=\"right\" class=\"caption\">".$nextphotothumb.$nextphoto."</div></td></tr>";

        //if ($window==1) { $target="<a href=\"javascript:window.close()\">Close Window</a>"; } else { $target="<a href=\"".$_SERVER['HTTP_REFERER']."\">Back</a>"; }
        $photobody[]='<tr><td colspan="3" align="center">';
        $photobody[]='<img src="'.$photourl.'/'.$photo.'" width="'.$size[0].'" height="'.$size[1].'" border="0" alt="" class="imageborder" />';
        if ($photo) {
            if ($showexifcomment==1) { $photobody[]='<p class="photocaption">'.$comment.'</p>'; }
            if ($showfilename==1) { $photobody[]='<p class="photocaption">'.$photo.'</p>'; }
            if ($showpathname==1) { $photobody[]='<p class="photocaption">http://'.$_SERVER['HTTP_HOST'].$photourl.'/'.$photo.'</p>'; }
        }
        $photobody[]='</td></tr>';
        $photobody[]='</table>';
    }
    return $photobody;
}

function display($photobody) {
    global $photodir;
    getheader();
    echo "";
    wallpapers(dirname($_SERVER['SCRIPT_FILENAME']));
    echo "<div class=\"photobody\">";
    foreach ($photobody as $value) {
       echo $value."\n";
    }
    echo "</div>";
    getfooter();
    exit;
}

function wallpapers($dir) {
//for now only one level of wallpapers works.
    global $wallpapers, $title, $photos, $divider, $logo, $photo;
    $dirs=getdirs($dir);
    if (isset($logo)) { echo $logo; }
    if (isset($wallpapers)) { echo "<font face='Tahoma' class='ws10'><B>".$wallpapers." Wallpapers</B>"; } else { echo "<h1>".$title."</h1>"; }

    echo "<div class=\"wallpapers\"><p>";
    if (isset($wallpapers) || isset($photo)) { echo ""; }
    else {  }
    if (count($dirs)>0) {
        foreach ($dirs as $value) {
           echo "";
        }
    }
    echo "</p></div>";
}

//returns the header for the page. Checks for a user defined header.
function getheader() {
    global $header, $title, $slide, $photodir, $photourl, $pwidth, $pheight, $thumbsurl, $window,$photo, $photos, $wallpapers, $stylesheet;

    if(isset($wallpapers)) { $query="&amp;wallpapers=".urlencode($wallpapers); }
    if ($slide==1) { $query=$query."&amp;slide=1"; }

foreach ($photos as $key => $value) {
     if($photo==$value) {
    if (array_key_exists($key+1, $photos)) {
        if($photos[$key+1]) {
            $nextslide=$_SERVER['PHP_SELF']."?p=".$photos[$key+1].$query;
        }
    }
        else {
            $slide=0;
    }
    }
}


    if (isset($header) && $header!="NULL" && is_file ($header)) {
        require("$header");
    }
    else {
    echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"';
        echo "\n";
    echo '"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">';
        echo "\n";
    echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >';
        echo "\n";
        echo '<head>';
        echo '<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />';
        echo "\n";
        echo "<title>$title</title>\n";
        echo '<meta name="author" content="Lee Robertson"/>';
        if ($slide==1 && $header=="NULL") { echo "<META HTTP-EQUIV=refresh CONTENT=\"4; URL=".$nextslide." \">"; }
        echo '<style type="text/css" media="all">@import "'.$stylesheet.'";</style>';
        echo "\n";
        echo '</head>';
        echo "\n";
        echo '<body>';
        echo "\n";
    }
}

//returns the footer for the page. Checks for a user defined footer.
function getfooter() {
    global $footer;
    if (isset($footer) && $footer!="NULL" && is_file ($footer)) {
        require("$footer");
    }
    else {
        echo '';
        echo '</body></html>';
    }
}

$photodir=dirname($_SERVER['SCRIPT_FILENAME']);
$photourl=dirname($_SERVER['PHP_SELF']);
$thumbsurl=dirname($_SERVER['PHP_SELF']);
$photobody=array();

if (isset($_GET['wallpapers'])) {
    if (in_array($_GET['wallpapers'],getdirs(dirname($_SERVER['SCRIPT_FILENAME'])))==FALSE) {
        $wallpapers = NULL;
    }
    else {
        $wallpapers = urldecode($_GET['wallpapers']);
    }
    $photodir=dirname(realpath($_SERVER['SCRIPT_FILENAME']))."/".$wallpapers;
    $photourl=dirname($_SERVER['PHP_SELF'])."/".$wallpapers;
    $thumbsurl=dirname($_SERVER['PHP_SELF'])."/".$wallpapers;
}




//To make sure this works both on Linux and Win
$photodir = str_replace("\\", "/", $photodir);

//Get the jpegs from the folder.
$photos=getphotos($photodir);

//check to see if thumbnails are made if not it will make. Adds time to the processing of the script.
for ($i=0; $i<=count($photos)-1; $i++) {
    thumb_maker($photodir."/".$photos[$i], $twidth, $theight);
}

if (count($photos)<=0) {
    $photobody[]="";
    display($photobody);
    exit;
}
if (isset($_GET['pn'])) {
    $photonum = htmlentities(strip_tags($_GET['pn']));
    $photobody=thumb_gallery($photonum);
}
elseif (isset($_GET['slide'])) {
    $slide=$_GET['slide'];
    $photo=htmlentities(strip_tags(urldecode($_GET['p'])));
    if (file_exists($photodir.'/'.$photo)) {
        $photobody=photo_slides($photo,$pwidth,$pheight);
    }
    else {
        $photobody=thumb_gallery(0);
    }

}
elseif (isset($_GET['p'])) {
    $photo=htmlentities(strip_tags(urldecode($_GET['p'])));
    if (file_exists($photodir.'/'.$photo)) {
        $photobody=photo_gallery($photo,$pwidth,$pheight);
    }
    else {
        $photobody=thumb_gallery(0);
    }

}
else {
    $photobody=thumb_gallery(0);
}


//output it all to the browser.
display($photobody);
exit;
?>

这是页脚和菜单包括代码

      <td width="20%" valign="top"><?php include 'menu.php'; ?></td>
    </tr>
  </table>      
  <p align="center"><?php include 'footer.php'; ?></td>

4

3 回答 3

0

检查你的getfooter代码里面它看起来像下面

function getfooter()
{
    global $footer;
    //other code
}

现在$footer值在开始时设置为NULL并且您永远不会再次设置它,因此不会包含页脚。

于 2013-02-11T09:25:27.663 回答
0

我猜在页脚的某个地方代码被卡住了。你能把页脚中的代码删除一会儿,然后放一个回显看看它是否显示吗?如果它工作正常,然后尝试删除功能一段时间,看看会发生什么。让我知道。

于 2013-02-11T10:02:06.363 回答
-1

短语缺少关闭标签。

代替<p align="center"><?php include 'footer.php'; ?></td>

<p align="center"><?php include 'footer.php'; ?></p></td>

于 2013-02-11T08:43:07.590 回答