PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hey Folks im back again im having an issue with getting a script to execute mabye a new set of eyes would help. when i add this to teh top of the page i want to secure it outputs the code and does not execute it
What am i Missing???
<?php
$abs = getcwd();
$viewer = $HTTP_USER_AGENT;
echo "<?php<br><br>
//prevents caching<br>
header(\"Expires: Sat, 01 Jan 2000 00:00:00 GMT\");<br>
header(\"Last-Modified: \".gmdate(\"D, d M Y H:i:s\").\" GMT\");<br>
header(\"Cache-Control: post-check=0, pre-check=0\",false);<br>
session_cache_limiter();<br>
session_start();<br>
<br>";
if (preg_match("/Windows NT/", $viewer))
{
echo "require('$abs/secure/config.php');<br>
<br>
require('$abs/secure/functions.php'); <br>
<br>";
}
else
{
echo "require('$abs/secure/config.php');<br>
<br>
require('$abs/secure/functions.php'); <br>
<br>";
}
echo "
//this is group name or username of the group or person that you wish to allow access to<br>
// - please be advise that the Administrators Groups has access to all pages.<br>
if (allow_access(Administrators) != \"yes\")<br>
{ <br>
";
if (preg_match("/Windows NT/", $viewer))
{
echo "
include ('$abs\\no_access.html'); <br>
";
}
else
{
echo "include ('$abs/no_access.html'); <br>";
}
echo "
exit;<br>
}<br>
?>";
?>
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
echo "
//this is group name or username of the group or person that you wish to allow access to<br>
// - please be advise that the Administrators Groups has access to all pages.<br>
if (allow_access(Administrators) != \"yes\")<br>
{ <br>
";
The Ninja Space Goat wrote:
Why are you echoing php code?
This is a Script i got off the web. Im Modifing it for my site its been going smooth so far but i cant get this script to secure my page. Im drawing a blank as to why it wont work.
Even when i removed the Echo tags from all the code it still isnt securing the page
<?php
$abs = getcwd();
$viewer = $HTTP_USER_AGENT;
echo "<?php<br><br>
//prevents caching<br>
header("Expires: Sat, 01 Jan 2000 00:00:00 GMT");<br>
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");<br>
header("Cache-Control: post-check=0, pre-check=0",false);<br>
session_cache_limiter();<br>
session_start();<br>
<br>";
if (preg_match("/Windows NT/", $viewer))
{
echo "require('$abs\config.php');<br>
<br>
require('$abs\functions.php'); <br>
<br>";
}
else
{
echo "require('$abs/config.php');<br>
<br>
require('$abs/functions.php'); <br>
<br>";
}
echo "
//this is group name or username of the group or person that you wish to allow access to<br>
// - please be advise that the Administrators Groups has access to all pages.<br>
if (allow_access(Administrators) != "yes")<br>
{ <br>
";
if (preg_match("/Windows NT/", $viewer))
{
echo "
include ('$abs\\no_access.html'); <br>
";
}
else
{
echo "include ('$abs/no_access.html'); <br>";
}
echo "
exit;<br>
}<br>
?>";
?>
<?php
$abs = getcwd();
$viewer = $HTTP_USER_AGENT;
"<
<br><br>
//prevents caching<br>
header("Expires: Sat, 01 Jan 2000 00:00:00 GMT");<br>
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");<br>
header("Cache-Control: post-check=0, pre-check=0",false);<br>
session_cache_limiter();<br>
session_start();<br>
<br>";
if (preg_match("/Windows NT/", $viewer))
{
"require('$abs/secure/config.php');<br>
<br>
require('$abs/secure/functions.php'); <br>
<br>";
}
else
{
"require('$abs/secure/config.php');<br>
<br>
require('$abs/secure/functions.php'); <br>
<br>";
}
"
//this is group name or username of the group or person that you wish to allow access to<br>
// - please be advise that the Administrators Groups has access to all pages.<br>
if (allow_access(Administrators) != "yes")<br>
{ <br>
";
if (preg_match("/Windows NT/", $viewer))
{
"
include ('$abs\\no_access.html'); <br>
";
}
else
{
"include ('$abs/no_access.html'); <br>";
}
"
exit;<br>
}<br>
?>";
?>
And i am posting the code before anything else on the page.
<?php
$abs = getcwd();
$viewer = $_SERVER['HTTP_USER_AGENT'];
//prevents caching
header("Expires: Sat, 01 Jan 2000 00:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: post-check=0, pre-check=0",false);
session_cache_limiter();
session_start();
if (preg_match("/Windows NT/", $viewer))
{
require $abs . '/secure/config.php';
require $abs . '/secure/functions.php';
}
else
{
require $abs . '/secure/config.php';
require $abs . '/secure/functions.php';
}
//this is group name or username of the group or person that you wish to allow access to
// - please be advise that the Administrators Groups has access to all pages.
if (allow_access(Administrators) != 'yes')
{
if (preg_match("/Windows NT/", $viewer))
{
include ($abs . '\\no_access.html');
}
else
{
include ($abs . '/no_access.html');
}
exit;
}
?>
Whew, that took a few passes to get all the bugs out...
Last edited by RobertGonzalez on Thu Jul 20, 2006 10:38 am, edited 1 time in total.
notice how different the syntax highlighting is in everah's modified code compared to yours (on this page), If there is a big chunk of red code... obviously there is a problem.
Warning: main($abs/secure/config.php): failed to open stream: No such file or directory in /home/assuredm/public_html/welcome.php on line 14
Warning: main($abs/secure/config.php): failed to open stream: No such file or directory in /home/assuredm/public_html/welcome.php on line 14
Warning: main($abs/secure/config.php): failed to open stream: No such file or directory in /home/assuredm/public_html/welcome.php on line 14
Fatal error: main(): Failed opening required '$abs/secure/config.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/assuredm/public_html/welcome.php on line 14