PDA

View Full Version : iframes & permissions


brent1a
05-23-2005, 10:01 AM
In some parts of my site I use several iframe pages because I also incorporate several php scripts into my site. I want it so that only the iframe pages can access those folders and not have some random visitor be able to pull up a php script by itself outside of the iframe(the scripts also have to be executable by ANY user just not accessable outsideof the iframe). I think this can be accomplished via permissions but what exactly should I make them? chmod 755? I hope my question is clear and concise enough.
thanks in advance,
-Brent

_Aerospace_Eng_
05-23-2005, 10:47 AM
You can add this to the top of your php page
<?php
if(eregi("yourscript.php","$REQUEST_URI")){die("Please no attemptive hacking."); }
?>
That should work. You will still be able to include the files, but any type of direct access to them such as typing the exact url to the file will show the msg Please no attemptive hacking.

brent1a
05-23-2005, 10:49 AM
You can add this to the top of your php page
<?php
if(eregi("yourscript.php","$REQUEST_URI")){die("Please no attemptive hacking."); }
?>
That should work. You will still be able to include the files, but any type of direct access to them such as typing the exact url to the file will show the msg Please no attemptive hacking.I would assume that I need to replace the "yourscript.php" with the corresponding script name that I will be putting that line in? Also, adding this line will not affect any script that I add it into?
thanks,
-B

_Aerospace_Eng_
05-23-2005, 11:05 AM
that is correct, just add in the line in between the php <?php and ?> into your existing php script. What the line does is if the script is accessed directly per say typed into the users browser, it will return the msg in the die function.

brent1a
05-23-2005, 05:27 PM
I tired it on one script and when executed it gave me this:

Parse error: parse error, unexpected '}' in /home2/brent1a/public_html/randomscript.php on line 2

_Aerospace_Eng_
05-23-2005, 05:45 PM
Can you post that php script please before it hits the client, looks as if you you have one too many closing brackets somewhere. I use that same script on my site and it works fine. For example, here is my header.php file, that I include into my index page.
<?php
if(eregi("header.php","$REQUEST_URI")){die("Please no attemptive hacking."); }
?>
<div id="header">
<!--Begin Navbar-->
<div id="navbar">
<a href="index.php" title="Home">HOME</a>|
<a href="history.php" title="History">HISTORY</a>|
<a href="links.php" title="Links">LINKS</a>|
<a href="resume.php" title="Resume">RESUME</a>|
<a href="media.php" title="Media">MEDIA</a>|
<a href="about.php" title="About">ABOUT</a>|
<a href="contact.php" title="Contact">CONTACT</a>
</div>
<!--End Navbar-->
<!--Begin Jukebox-->
<!--Below is my "embedded" sound file, using embed tags
this page won't validate using the xhtml strict doctype-->
<div id="flash"><object type="application/x-shockwave-flash" data="videos/songcontrol.swf" width="200" height="25">
<param name="movie" value="videos/songcontrol.swf" />
<param name="wmode" value="transparent" />
<param name="menu" value="false" />
<param name="scale" value="noborder" />
</object></div>
<!--End Jukebox-->
<a href="/"><img id="index" src="images/logo.gif" width="340" height="105" alt="Index" /></a><img id="animation" src="images/future.gif" width="418" height="90" alt="Designing for the Future" />
</div>
The url to it is http://prdesignz.inraged-inc.com/includes/header.php you will see that the msg comes up, but if you go to my index page http://prdesignz.inraged-inc.com you will see that it works fine.

brent1a
05-23-2005, 06:24 PM
OH, I see what i did......I assumed that the ?> was meant to be the closing bracket at the end of the script......I now realize that I need to include that right after the rest of that line.
I'll try that after a bit
thanks

brent1a
05-23-2005, 06:54 PM
OH, I see what i did......I assumed that the ?> was meant to be the closing bracket at the end of the script......I now realize that I need to include that right after the rest of that line.
I'll try that after a bit
thankswell now I've made a lier out of myself again.....
fter I add your line (as seen below) I get this output:
Parse error: parse error, unexpected '{' in /home2/brent1a/public_html/myrandom.php on line 2

<?
*if(eregi("header.php","$REQUEST_URI")){die("Please no attemptive hacking.");*}
?>
###############################
# random php script v1.0.4 #
# Copyright Soft 2005 #
###############################

##################################
# Special Configuration Section: #
##################################
// Change only what is in single quotation marks. (')

// This script's file name:
define("script_file",'script.php');

// Change these values to change the page title (HTML tags are allowed.):
define("page_titlebar",'EO: for the rest of us...');
define("page_title",'EO: <i>random</i>');

#################
# Color Scheme: #
#################
// Use a hex color value here to change the page's background color:
define("page_bg",'#333333');
// Use a hex color value here to change the form's background color:
define("form_bg",'#666666');
// Use a hex color value here to change the controls' background color:
define("control_bg",'#FFFFFF');
// Use a hex color value here to change the form's text color:
define("text_color",'#000000');
#################

// Page to redirect to after the email is sent:
define("page_redirect",'http://www.random.com/useful/useful.html'); // Leave blank if none.

etc
etc

_Aerospace_Eng_
05-24-2005, 04:09 AM
You are closing out the php too early
<?php
if(eregi("myrandom.php","$REQUEST_URI")){die("Please no attemptive hacking.");}
###############################
# random php script v1.0.4 #
# Copyright Soft 2005 #
###############################

##################################
# Special Configuration Section: #
##################################
// Change only what is in single quotation marks. (')

// This script's file name:
define("script_file",'script.php');

// Change these values to change the page title (HTML tags are allowed.):
define("page_titlebar",'EO: for the rest of us...');
define("page_title",'EO: <i>random</i>');

#################
# Color Scheme: #
#################
// Use a hex color value here to change the page's background color:
define("page_bg",'#333333');
// Use a hex color value here to change the form's background color:
define("form_bg",'#666666');
// Use a hex color value here to change the controls' background color:
define("control_bg",'#FFFFFF');
// Use a hex color value here to change the form's text color:
define("text_color",'#000000');
#################

// Page to redirect to after the email is sent:
define("page_redirect",'http://www.random.com/useful/useful.html'); // Leave blank if none.
?>

You were also using header.php not myrandom.php.