Avatar billede sqren Nybegynder
17. maj 2003 - 08:01 Der er 7 kommentarer og
1 løsning

PHP include

Jeg har et problem med PHP include.

Jeg får denne fejlmeddelelse:

Warning: Cannot add header information - headers already sent by (output started at /customers/sjovert.dk/sjovert.dk/httpd.www/download/pafiledb.php:11) in /customers/sjovert.dk/sjovert.dk/httpd.www/download/includes/download.php on line 15

Jeg bruger dette skelet:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Sjovert</title>
</head>
<body>
<table align="center" cellpadding="0">

<tr>
<td colspan="2" height="19"><div align="center">
<?php
require("top.php");
?>
</div></td></tr>

<tr height"100%"><td valign="top" height="100%"><div>
<?php
require("menu.php");?></div></td>

<td valign="top" class="midten">
/*indholdet kommer her*/
</td></tr>

<tr><td height="40"> <div align="center"> <br>
</div></td>
           
<td height="40"><div align="center">
<?php
require("bund.php");
?>
</div></td>
</tr>
</table>
</body>
</html>



Det er gået fint indtil jeg satte dette indhold ind:

<?php
if (file_exists("./install.php")) { die("Error: The file install.php (paFileDB installer) still exists on the server! This is a security risk! Please delete the file to continue using paFileDB."); }
$starttime = microtime();   
$starttime = explode(" ",$starttime);
$starttime = $starttime[1] + $starttime[0];
$authmethod = "cookies"; //Set this to 'cookies' to use cookies to log you in (recommended.) If you're having problems with cookies, set this to 'sessions' and make sure a 'sessions' directory exists and is CHMODed to 777 (on *nix servers)
if ($authmethod == "sessions") {
    session_save_path("./sessions");
    session_start();
}
require "./includes/mysql.php";
require "./includes/functions.php";
$pafiledb_sql->connect($db);
$config = $pafiledb_sql->query($db,"SELECT * FROM $db[prefix]_settings",1);
require "./lang/$config[13].php";
if ($login == "do") { include "./includes/$action/login.php"; exit; }
if ($ad == "logout") { include "./includes/admin/logout.php"; exit; }
if ($tm == "logout") { include "./includes/team/logout.php"; exit; }
$logged = "";
require "./includes/admin/auth.php";
require "./includes/team/auth.php";
if ($action == "download") {
    include "./includes/download.php";
    exit();
}
if ($logged == 1 && $ad == "backupdb") {
    include "includes/admin/backupdb.php";
    exit();
}
?>
<html>
<head>
<title>Sjoverts Downloads</title>
<style type="text/css">
<?php include "./styles/$config[11]/style.css"; ?>
</style>
<script language="JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>
<body>
<center>
<!--Begin main table-->
<table width="100%" height="99%" border="0" cellpadding="2" cellspacing="0" bgcolor="#FFFFFF" class="table">
<tr>
<td width="100%" height="100%" valign="top">
<!--Begin header table-->
<table width="100%" height="100" border="0" cellpadding="2" cellspacing="0" class="table">
<tr>
<td width="25%" valign="center" align="center">
<a href="pafiledb.php"><font size="5">Start</font></a>
</td><td width="75%" valign="center" align="right">
<font size="5">
<a href="pafiledb.php?action=search">Søg</a>&nbsp;&nbsp;<a href="pafiledb.php?action=stats">Statestik</a>&nbsp;&nbsp;<a href="<?php echo $config[5]; ?>">Sjovert</a>
</font>
</td></tr></table>
<!--End header table-->
<!--Begin page table-->
<?php
if ($logged == 1 && $ad != "logout") {
    $width = 100;
} else {
    $width = 80;
}
?>
<table width="<?php echo $width; ?>%" height="30" border="0" cellpadding="2" cellspacing="0" class="table" align="center">
<tr>
<td width="100%" valign="top" align="left" colspan="2">
<?php
$disable = $config[16];

if ($logged)
$disable = 0;
if ($action == "admin")
$disable = 0;
if ($teamlogged == 1 && $action !== "team")
tmlocbar("",$tuser,$str);
if ($teamlogged == 1 && $action == "team")
tmlocbar("<a href=\"pafiledb.php\" class=\"small\">$config[1]</a> :: $str[teamcenter]",$tuser, $str);
if (!$disable) {
    switch ($action) {
        case category:
            include "./includes/category.php";
        break;
        case file:
            include "./includes/file.php";
        break;
        case viewall:
            include "./includes/viewall.php";
        break;
        case search:
            include "./includes/search.php";
        break;
        case license:
            include "./includes/license.php";
        break;
        case rate:
            include "./includes/rate.php";
        break;
        case admin:
            include "./includes/admin.php";
        break;
        case team:
            include "./includes/team.php";
        break;
        case email:
            include "./includes/email.php";
        break;
        case stats:
            include "./includes/stats.php";
        break;
        default:
            include "./includes/main.php";
        break;
    }
} else {
    ?>
    <table width="100%" border="1" cellpadding="2" cellspacing="0" class="headertable" bordercolor="#000000">
    <tr><td width="100%" colspan="2" class="headercell"><center><b>paFileDB</b></center></td></tr>
    <tr><td width="5%" class="datacell" align="center" valign="middle"><img src="styles/<?php echo $config[11]; ?>/images/error.gif" border="0"></td><td width="95%" class="datacell"><?php echo $str[isdisabled]; ?>
    </td></tr></table>
    <?php
}
?>
</td></tr>
<tr>
<td width="50%" align="left">
<?php jumpmenu($db,$HTTP_SERVER_VARS['REQUEST_URI'],$pafiledb_sql,$str); ?>
</td><td width="50%" align="right"><?php echo "$str[time] $config[8]"; ?></td></tr></table>
<!--End page table-->
<!--Begin footer table-->
<table width="100%" height="30" border="0" cellpadding="2" cellspacing="0" class="footer">
<tr>
<td width="100%" valign="center" align="center">
</td></tr>
<tr><td width="100%" valign="center" align="center">
<?php
$endtime = microtime();
$endtime = explode(" ",$endtime);
$endtime = $endtime[1] + $endtime[0];
$stime = $endtime - $starttime;
if ($config[12] == 1) {
    ?>
    <table width="30%" border="1" cellpadding="2" class="stats" bordercolor="#000000">
    <tr><td width="50%" align="left"><?php echo $str[exectime]; ?>:</td><td width="50%" align="right"><?php echo round($stime,4); ?> Seconds</td></tr>
    <tr><td width="50%" align="left"><?php echo $str[numqueries]; ?>:</td><td width="50%" align="right"><?php echo $query_count; ?> Queries</td></tr>
    </table>
    <?php
    if ($showqueries == 1) {
        ?>
        <p>
        <table width="100%" border="1" cellpadding="2" class="headertable" bordercolor="#000000">
        <tr><td width="100%" class="headercell" align="center"><b>Queries Used</b></td></tr>
        <?php echo $queries_used; ?>
        </table>
        <?php
    }
}
?>


Ved godt at det er noget med at det også bruger includes, men kan ikke løse det.
Avatar billede erikjacobsen Ekspert
17. maj 2003 - 08:17 #1
<?php
require("top.php");
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Sjovert</title>
</head>
<body>
<table align="center" cellpadding="0">

<tr>
<td colspan="2" height="19"><div align="center">
Avatar billede asand Nybegynder
17. maj 2003 - 11:26 #2
Prøv at skrive

exit;

til sidst i det sidste stykke med PHP.
Avatar billede sqren Nybegynder
17. maj 2003 - 13:36 #3
Nu har jeg sat pointtallet op. Kan i ikke prøve at downloade  paFileDB fra: http://www.phparena.net/pafiledb.php og se hvad der er galt.
Det skal lige siges at filen vi arbejder med er: paFileDB og den skal ind i mit skelet som er dette:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Sjovert</title>
</head>
<body>
<table align="center" cellpadding="0">

<tr>
<td colspan="2" height="19"><div align="center">
<?php
require("top.php");
?>
</div></td></tr>

<tr height"100%"><td valign="top" height="100%"><div>
<?php
require("menu.php");?></div></td>

<td valign="top" class="midten">
Indhold
</td></tr>

<tr><td height="40"> <div align="center"> <br>
</div></td>
           
<td height="40"><div align="center">
<?php
require("bund.php");
?>
</div></td>
</tr>
</table>
</body>
</html>
Avatar billede erikjacobsen Ekspert
17. maj 2003 - 13:42 #4
Du kan også bare

<? ob_start(); ?>
<html>
...resten
Avatar billede ztyxx Nybegynder
17. maj 2003 - 13:44 #5
erikjacobsens løsning er nok det nemmeste, du kan se mere i manualos
http://www.php.net/manual/en/function.ob-start.php
Avatar billede erikjacobsen Ekspert
17. maj 2003 - 14:00 #6
Jeg betragter nu min løsning som en nødløsning. Man bør klare
alle sine beregninger, herunder cookies, redirect, osv. inden
man tænker på sit HTML.
Avatar billede ztyxx Nybegynder
17. maj 2003 - 14:02 #7
erik> det kan vi ikke være uenige om, men når nu php har lavet muligheden for outputbuffering på den måde, kan det ikke være totalt langt ude, og der kan vel egentlig også være situationer hvor man har behovet for at sende flere headers, inden html output kommer ind i billedet, men det er vel også mest det funktionen er lavet til :-)
Avatar billede sqren Nybegynder
17. maj 2003 - 14:06 #8
Har fundet ud af det. Det var fordi jeg skulle sætte det sådan:

<?php
/*
  paFileDB 3.1
  ©2001/2002 PHP Arena
  Written by Todd
  todd@phparena.net
  http://www.phparena.net
  Keep all copyright links on the script visible
  Please read the license included with this script for more information.
*/
if (file_exists("./install.php")) { die("Error: The file install.php (paFileDB installer) still exists on the server! This is a security risk! Please delete the file to continue using paFileDB."); }
$starttime = microtime();   
$starttime = explode(" ",$starttime);
$starttime = $starttime[1] + $starttime[0];
$authmethod = "cookies"; //Set this to 'cookies' to use cookies to log you in (recommended.) If you're having problems with cookies, set this to 'sessions' and make sure a 'sessions' directory exists and is CHMODed to 777 (on *nix servers)
if ($authmethod == "sessions") {
    session_save_path("./sessions");
    session_start();
}
require "./includes/mysql.php";
require "./includes/functions.php";
$pafiledb_sql->connect($db);
$config = $pafiledb_sql->query($db,"SELECT * FROM $db[prefix]_settings",1);
require "./lang/$config[13].php";
if ($login == "do") { include "./includes/$action/login.php"; exit; }
if ($ad == "logout") { include "./includes/admin/logout.php"; exit; }
if ($tm == "logout") { include "./includes/team/logout.php"; exit; }
$logged = "";
require "./includes/admin/auth.php";
require "./includes/team/auth.php";
if ($action == "download") {
    include "./includes/download.php";
    exit();
}
if ($logged == 1 && $ad == "backupdb") {
    include "includes/admin/backupdb.php";
    exit();
}
?>
<html>
<head>
<title>Sjoverts Downloads</title>
<style type="text/css">
<?php include "./styles/$config[11]/style.css"; ?>
</style>
<script language="JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>
<body>
<center>
<!--Begin main table-->

<table align="center" cellpadding="0">

<tr>
<td colspan="2" height="19"><div align="center">
<?php
require("../top.php");
?>
</div></td></tr>

<tr height"100%"><td valign="top" height="100%"><div>
<?php
require("../menu.php");?></div></td>

<td valign="top" class="midten">


<table width="100%" height="99%" border="0" cellpadding="2" cellspacing="0" class="table">
<tr>
<td width="100%" height="100%" valign="top">
<!--Begin header table-->
<table width="100%" height="100" border="0" cellpadding="2" cellspacing="0" class="table">
<tr>
<td width="25%" valign="center" align="center">
<a href="pafiledb.php"><font size="5">Start</font></a>
</td><td width="75%" valign="center" align="right">
<font size="5">
<a href="pafiledb.php?action=search">Søg</a>
&nbsp;&nbsp;<a href="pafiledb.php?action=stats">Statestik</a>
&nbsp;&nbsp;<a href="<?php echo $config[5]; ?>">Sjovert</a>
</font>
</td></tr></table>
<!--End header table-->
<!--Begin page table-->
<?php
if ($logged == 1 && $ad != "logout") {
    $width = 100;
} else {
    $width = 80;
}
?>
<table width="<?php echo $width; ?>%" height="30" border="0" cellpadding="2" cellspacing="0" class="table" align="center">
<tr>
<td width="100%" valign="top" align="left" colspan="2">
<?php
$disable = $config[16];

if ($logged)
$disable = 0;
if ($action == "admin")
$disable = 0;
if ($teamlogged == 1 && $action !== "team")
tmlocbar("",$tuser,$str);
if ($teamlogged == 1 && $action == "team")
tmlocbar("<a href=\"pafiledb.php\" class=\"small\">$config[1]</a> :: $str[teamcenter]",$tuser, $str);
if (!$disable) {
    switch ($action) {
        case category:
            include "./includes/category.php";
        break;
        case file:
            include "./includes/file.php";
        break;
        case viewall:
            include "./includes/viewall.php";
        break;
        case search:
            include "./includes/search.php";
        break;
        case license:
            include "./includes/license.php";
        break;
        case rate:
            include "./includes/rate.php";
        break;
        case admin:
            include "./includes/admin.php";
        break;
        case team:
            include "./includes/team.php";
        break;
        case email:
            include "./includes/email.php";
        break;
        case stats:
            include "./includes/stats.php";
        break;
        default:
            include "./includes/main.php";
        break;
    }
} else {
    ?>
    <table width="100%" border="1" cellpadding="2" cellspacing="0" class="headertable" bordercolor="#000000">
    <tr><td width="100%" colspan="2" class="headercell"><center><b>paFileDB</b></center></td></tr>
    <tr><td width="5%" class="datacell" align="center" valign="middle"><img src="styles/<?php echo $config[11]; ?>/images/error.gif" border="0"></td><td width="95%" class="datacell"><?php echo $str[isdisabled]; ?>
    </td></tr></table>
    <?php
}
?>
</td></tr>
<tr>
<td width="50%" align="left">
<?php jumpmenu($db,$HTTP_SERVER_VARS['REQUEST_URI'],$pafiledb_sql,$str); ?>
</td><td width="50%" align="right"><?php echo "$str[time] $config[8]"; ?></td></tr></table>
<!--End page table-->
<!--Begin footer table-->
<table width="100%" height="30" border="0" cellpadding="2" cellspacing="0" class="footer">
<tr>
<td width="100%" valign="center" align="center">
</td></tr>
<tr><td width="100%" valign="center" align="center">
<?php
$endtime = microtime();
$endtime = explode(" ",$endtime);
$endtime = $endtime[1] + $endtime[0];
$stime = $endtime - $starttime;
if ($config[12] == 1) {
    ?>
    <table width="30%" border="1" cellpadding="2" class="stats" bordercolor="#000000">
    <tr><td width="50%" align="left"><?php echo $str[exectime]; ?>:</td><td width="50%" align="right"><?php echo round($stime,4); ?> Seconds</td></tr>
    <tr><td width="50%" align="left"><?php echo $str[numqueries]; ?>:</td><td width="50%" align="right"><?php echo $query_count; ?> Queries</td></tr>
    </table>
    <?php
    if ($showqueries == 1) {
        ?>
        <p>
        <table width="100%" border="1" cellpadding="2" class="headertable" bordercolor="#000000">
        <tr><td width="100%" class="headercell" align="center"><b>Queries Used</b></td></tr>
        <?php echo $queries_used; ?>
        </table>
        <?php
    }
}
?>
</table>


<table width="100%" border="0" cellpadding="0" cellspacing="0" class="upload" bordercolor="#000000">
<tr><td width="100%" class="headercell">
    <p align="center"><b></b></p>
  </td></tr>
<tr><td width="100%" class="datacell">
<?
$extlimit = "no"; //Do you want to limit the extensions of files uploaded
$limitedext = array(".exe"); //Extensions you want files uploaded limited to.
$sizelimit = "no"; //Do you want a size limit, yes or no?
$sizebytes = "200000"; //size limit in bytes
$dl = "http://www.sjovert.dk/Upload/programmer"; //url where files are uploaded
$absolute_path = "/customers/sjovert.dk/sjovert.dk/httpd.www/Upload/programmer"; //Absolute path to where files are uploaded
$websiteurl = "http://www.sjovert.dk/Efter_index.htm"; //Url to you website
$websitename = "Start";

switch($action) {
default:
echo"
<p>
<a href=$PHP_SELF?action=upload>Upload en Fil</a>

<p>";
break;
case "download":
echo "
<p><a href=$PHP_SELF?action=upload>Upload en Fil</a> <a href=$websiteurl>Gå tilbage til $websitename</a>";
$list = "<table width=700 border=1 bordercolor=#000000 style=\"border-collapse: collapse\">";
$list .= "<tr><td width=700><center><b>Kilk på en fil for at download den</b></center></td></tr>";
$dir = opendir($absolute_path);
while($file = readdir($dir)) {
if (($file != "..") and ($file != ".")) {
//Sjovert.dk Styrer
$list .= "<tr><td width=700><a href='$dl/$file'>$file</a></center></td></tr>";
}
}
$list .= "</table>";
echo $list;
echo"
<p>";
break;

case "upload":
echo"

<form method=POST action=$PHP_SELF?action=doupload enctype=multipart/form-data>
<p>Vælg en Fil:<br>
<input type=file name=file size=30>
<p><button name=submit type=submit>
Upload
</button>
</form>


";
break;


//Fil Upload
case "doupload":
$dir = "dir";
if ($file != "") {

if (file_exists("$absolute_path/$file_name")) {
die("Filen eksisterer allerede");
}

if (($sizelimit == "yes") && ($file_size > $sizebytes)) {
die("Filen er for stor. Den må højest fylde $sizebytes bytes.");
}

$ext = strrchr($file_name,'.');
if (($extlimit == "yes") && (!in_array($ext,$limitedext))) {
die("Filen er en forkert filtype.");
}

@copy($file, "$absolute_path/$file_name") or die("Filen kunne ikke kopieres til serveren");

} else {
die("Husk at vælge en fil");
}
echo "
<p>";
echo $file_name." blev uploaded";
echo "<br>
<a href=$PHP_SELF?action=upload>Upload en ny Fil</a>
<p>";
break;

}
?></td></tr></table>



<!--End footer table-->
<!--End main table-->
</td></tr></table>
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester