Solved

include() with value

Posted on 2000-04-12
9
217 Views
Last Modified: 2013-11-18

Ok, this is from the php manuel:
-------------------------------------

Please note that both include() and require() actually pull the contents of the target file into the calling script file itself; they do not call the target via HTTP or anything like that. So any variable set in the scope in which the inclusion happens will be available within the included file
automatically, since it has effectively become a part of the calling file.

include( "file.inc?varone=1&vartwo=2" ); /* Won't work. */

$varone = 1;
$vartwo = 2;
include( "file.inc" );  /* $varone and $vartwo will be available in file.inc */
-----------------------------------

and I understand that.... but... I need to have an unnamed variable attached the the file, so it would be like:

file.inc?example

because I already have a script that uses the variable like that (unnamed).  How would I do this?

Chris

0
Comment
Question by:ChrisAndrews
  • 4
  • 4
9 Comments
 
LVL 8

Expert Comment

by:us111
ID: 2710852
I don't understand what your problem is...???
I think maxkir will have the solution. He always has :)
0
 
LVL 2

Expert Comment

by:maxkir
ID: 2711179
It isn't the case ... What is your real problem ?
If forget about include stuff, what task you're attempting to solve ?
0
 

Author Comment

by:ChrisAndrews
ID: 2712126


My goal is to use php to mirror a page.  The page I want to mirror has a variable.

The page:

http://www.example.com

will be:

<? require( "http://ex.com?abc" );?>

but the ?abc causes an error, as indicated in the manuel.  The manuel gives examples of how to put the variable in as a 'var1=abc'   but how do I put it in as just 'abc'?

<? $=awc;
require( "http://ex.com?abc" );?>

doesn't work.

In a related question, when I mirror this page, I would like to parse out everything between the body tags and just use that, so that I can enter my own title and metatags.  Is that difficult to do?  I can increase pts to 200 if you can tell me how to do that also.

Thanks

Chris

ps - mirroring this page is something I have permission to do :)
0
 
LVL 2

Accepted Solution

by:
maxkir earned 100 total points
ID: 2712194
<?php
$fp = fopen("http://ex.com?abc", "r");
while (!feof($fp))
{
    print fgets($fp, 4096);
}
flose($fp);
?>
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

by:ChrisAndrews
ID: 2712333

H Maxkir,

That seems to look in my home directory for the web page I want to mirror, when it needs to go to an entirely different site to get it, is that fixable?

Thank you for trying :)

Chris
0
 
LVL 2

Expert Comment

by:maxkir
ID: 2712369
place in place of ex.com any site you want. And the script will output the page.
0
 

Author Comment

by:ChrisAndrews
ID: 2712465

Hi,

Got it :)

For some reason I had to make it http://www.ex.com/?abc  (with a slant after ex.com) for it to work for me.  But that works out great, thank you.

Now for the body part... is there a way to parse it and just use what's in the body tags or does that get really difficult?

Thanks again,

Chris
0
 
LVL 2

Expert Comment

by:maxkir
ID: 2712477
Is it quite another question ... The answer is - yes, you can do some parsing using regular expressions.
0
 

Author Comment

by:ChrisAndrews
ID: 2712525

Thanks,  I will play around with this and see what I can do on my own first :)  Don't know how far I will get, learning by doing ya know,

Chris
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
scandir() not reads all files 4 26
Page showing diff display 4 22
php variable basic question 12 29
PHP json decode 9 26
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now