Solved

open php file

Posted on 2004-03-21
9
228 Views
Last Modified: 2008-03-06
hi,
i have recently made a script to check the whois records for a domain my user inputs.
i now want to make a page which will check if the domain has a whois record or not and so display whether the domain is available or not.
i want to do this by running the page whois.php which returns the whois record for the domain but i don't want to use include or require because they will just echo whatever whois.php returns.
i want to get the source of whois.php after the script has been run but not have it echoed.
is there a function to do this or do i need to find a way of opening "php.exe whois.php" and getting whatever that returns?
thanks in advance
mark
0
Comment
Question by:enasni_mark
  • 4
  • 3
9 Comments
 

Expert Comment

by:dneff68
Comment Utility
Hello,

You can try using fopen() and pass the url rather than a filename.  You may however have some problems if you are passing parameters, you'll have to try.

I believe there is also a way to redirect the output buffer to a custom function.  You could then parse it and wipe out the buffer, or replace it.  I can't remember the functions to do this.  I'll find it and post unless somebody posts it before me.

-David
0
 

Author Comment

by:enasni_mark
Comment Utility
i was thinking of using fopen() but i also need to use GET to state the domain name.
0
 

Accepted Solution

by:
dneff68 earned 125 total points
Comment Utility
Here's how I did it.  You can disable the buffer output and redirect it to a function you write, then kill ther buffer.

In my case, I was trying to export a dynamically generated page to a static HTML page, also without outputting the contents back to the client.  I have a callback($buffer) function that handles what would normally be pumped back to the client, and my exportPage function that does a require on the file I'm interested in.  The ob_end_flush() returns things to normal.

function callback($buffer)
{
  // do whatever you want with the buffer contents
}

ob_start("callback");
exportPage($file);  // does a require on $file
ob_end_flush();

Hope this helps.

-David
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:enasni_mark
Comment Utility
how does the ob_start() function work? why do you have "callback" in ob_start?
0
 

Expert Comment

by:dneff68
Comment Utility
"callback" is the name of the function you'll write to parse the results of your 'include'.  You can call it whatever you like, so long as your function name matches.  The function you write (in this case, 'callback') take a parameter that wil hold the buffer contents.  You can then parse that $buffer variable to see if 'whois' contains what you're looking for.

To make sure this doesn't get back to the client, you can also call ob_clean() when you're finished parsing.  Be sure that you don't already have content going back to the client that you don't want wiped out (such as echo's, or content outside <? ?>).

-David
0
 

Author Comment

by:enasni_mark
Comment Utility
that seems to be what i need but how can i use an include or a require with get fields?
i've just tried but i don't think you can send get fields with require or include
0
 

Expert Comment

by:dneff68
Comment Utility
Ooo... that may be where my needs differed.  I was hitting a local PHP page and could just have global variables. The PHP documentation for 'include' does state that pamameters can be passed, but that you must make sure allow_url_fopen is set on.

I'll try this a bit more when I get the chance.  Take a look at the online php docs for include.

-David
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

763 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

7 Experts available now in Live!

Get 1:1 Help Now