Re: [PHP] simple page not found 404 script - PHP



2007. 03. 30, péntek keltezéssel 15.10-kor Dwayne Heronimo ezt írta:
indeed.. it should be catcode instead of page.:-(. but still its not working
:S



<?php

/* function to get an external file into a vatiable */
function get_include_contents($filename) {
if (is_file($filename)) {
ob_start();
include $filename;
$contents = ob_get_contents();
ob_end_clean();
return $contents;
}
return false;
}

/* configuration file */

$errormsg = get_include_contents('404.php');
$pagename = $_GET['catcode'];

/* end configuration file */

if(file_exists("$pagename"))
{
include "$pagename";
}
else
{
echo "$errormsg";
}
?>


actually I don't know what the problem is, but I would do it in a much
shorter way:

$pagename = $_GET['catcode'];
if(file_exists("$pagename")) {
include "$pagename";
} else {
include "404.php";
}

about your original question, the script looks basically okay... what is
the error you get?

greets
Zoltán Németh



""Zoltn Nmeth"" <znemeth@xxxxxxxxxxxxxx> wrote in message
news:1175259498.5023.49.camel@xxxxxxxxxxxxxxx
2007. 03. 30, pntek keltezssel 14.45-kor Dwayne Heronimo ezt rta:
Dear All,

I have made a simple php script that will show an 404.php error page when
an
item is removed.

You can see the page here:
http://arubaguide.org/arubaguide/categories.php?catcode=art

But some how this is not working. It is displaying the 404 page and the
normal page.

in the above link you do not give a "page" parameter at all... so from
where should the script get it?

greets
Zoltn Nmeth



<?php

/* function to get an external file into a vatiable */
function get_include_contents($filename) {
if (is_file($filename)) {
ob_start();
include $filename;
$contents = ob_get_contents();
ob_end_clean();
return $contents;
}
return false;
}

/* configuration file */

$errormsg = get_include_contents('404.php');
$pagename = $_GET['page'];

/* end configuration file */

if(file_exists("$pagename"))
{
include "$pagename";
}
else
{
echo "$errormsg";
}
?>

is the $pagename not enough for this script?

Let me know..

Dwayne


.



Relevant Pages

  • NOCC Webmail <= 1.0 multiple vulnerabilities
    ... "NOCC is a webmail client written in PHP. ... remote code execution, there are two ways of execute arbitrary code on ... is defined in conf.php, by default no path is defined, but script suggests ... echo nl2br); ...
    (Bugtraq)
  • Re: [PHP] Help with an error...
    ... I am currently working on a php script that will be called by cron. ... echo 'This could not be display due to a system error. ...
    (php.general)
  • Re: [PHP] Help with an error...
    ... I am currently working on a php script that will be called by cron. ... echo 'This could not be display due to a system error. ...
    (php.general)
  • Re: nested conditional that can identify parent page?
    ... simply return the filename of the parent page; ... the name of its 'parent' file in a given instance. ... echo ''; ...
    (alt.php)
  • Re: [PHP] Help with an error...
    ... Also, if you want HTML tags in your PHP code, you need to end and start ... I am currently working on a php script that will be called by cron. ... echo 'This could not be display due to a system ...
    (php.general)