navigation  
content bookmark / link this page
  blog

bitfolge.de logo

Forum
Applications
MovieLauncher
SnailProxy
PHP
snif
BrowserEmulator
botproof email
PHP vCard
pseudo-cron
FeedCreator
nntp2rss
db tools
more PHP...
Java
Classes
EasySMTP
RBLChecker
SplashBitmap
SpamCleaner
Mausolizer
Popplet
SnailProxy
Publications

HTML menu


Copyright © 2000-2003
by Kai Blankenhorn

contact

deutsch  english


 

BrowserEmulator PHP class

Download v2.0.1 - implementation as a class, enhanced functionality (ZIP, 9 KB)
Download v1.5 - implementation as functions (ZIP, 9 KB), Source code

Talk to others and download addons at the forum!

Rate Our Program
@ Hotscripts.com
Some web sites (like IMDb) prevent external scripts from parsing their contents by denying request without a user-agent string. Though this can be circumvented by manually sending the necessary headers, this is usually too complicated.
This BrowserEmulator class with its methods fopen and file wraps the fsockopen calls and sends all the necessary headers before returning a file handle usable with any PHP function.

As a side-effect, you may be able to break the restrictions of allow_url_fopen = Off with these functions!

Features: completely transparent wrapper for fsockopen
PHP-like interfaces: BrowserEmulator::fopen (corresponds to fopen) and BrowserEmulator::file (corresponds to file)
usable with all PHP file handling methods (fgets and so on)
can send GET or POST requests
custom header lines can be sent
POST data can be sent
Basic HTTP Authentication
custom destination port numbers new in v2.0!
show last HTTP response new in v2.0!
New in v2.0: added a wrapper class; this has the advantage that you no longer need to specify a lot of parameters, just call the methods to set each option (see code examples below).




Example for v2.0:


<?
$be 
= new BrowserEmulator();
$be->addHeaderLine("Referer""http://previous.server.com/");
$be->addHeaderLine("Accept-Encoding""x-compress; x-zip");
$be->addPostData("Submit""OK");
$be->addPostData("item""42");
$be->setAuth("admin""secretpass");
// also possible:
// $be->setPort(10080);

$file $be->fopen("http://restricted.server.com:10080/somepage.html");
$response $be->getLastResponseHeaders();

while (
$line fgets($file1024)) {
    
// do something with the file
}
fclose($file);
?>



Example for v1.5:

<?
$headers 
= Array("Referer" => "http://previous.server.com/""Accept-Encoding" => "x-compress; x-zip");
$postData = Array("Submit" => "OK""item" => "42");
$file be_fopen("http://restricted.server.com/somepage.html"$headers$postData"admin" "secretpass");

while (
$line fgets($file1024)) {
    
// do something with the file
}
fclose($file);
?>




 
last changed on 01-17-04
  Quick feedback



Feedback heard: New support board!
by Kai Blankenhorn
(11-17-04)

Some of you seem to like the idea to have a forum here, so there it is! It is still quite empty, but I've just put links to it all over my site so everybody at leasts notices. Now all you have to do is post :-)


Feedback requested: Support board?
by Kai Blankenhorn
(10-11-04)

Thinking of how to give better support for my scripts: Do you think a support board would be useful? I don't know if I can reach the critical mass of users - right now I have around 100 visits per day for the scripts. Tell me if you would use it!


Processed some email
by Kai Blankenhorn
(10-11-04)

I've finally got the time to process some of the email I've got in the last few weeks. Sorry to anybody whom I couldn't answer! It's pretty hard for me to answer support requests in the little time I can spare.
Anyway, I've found some treasures among the emails :-) FeedCreator is used in the Mambo CMS, and will probably soon be used in TWiki. Snif has two new translations, and pseudocron will have a bugfix in a few days.


finally new releases
by Kai Blankenhorn
(10-11-04)

At last I've managed to put up two new releases of my scripts, snif and FeedCreator. Especially FeedCreator has had much user input and definitely needed a freshup. New feed types are HTML and JavaScript feeds, which can be included in any web page right away.
Snif has become more configurable with the new version. You may now create central configuration files to use the same settings for multiple installations of snif within one webspace. Colors can now be configured using external stylesheets. If you have made a new color set for snif, send it to me and I'll put it on my site!


disadvantages of having a job
by Kai Blankenhorn
(07-07-04)

I've started working in a full-time job last week (at sd&m, to be exact, which appears to be a great company so far). Unfortunately this means that I'll have less time for improving my scripts. But I definitely will! Pending are Brazilian Portuguese, Spanish and Greek translations for snif, and some fixes for FeedCreator. I'll see what I can do to create the new releases ASAP.
I'm alway happy to receive your code changes, so if you've made some improvements to one of my scripts, send them to me so other users can profit from them as well!




Archives:
Japanese and Danish translations
translations still requested
Just to be sure...
gimme feedback!
snif updates and upgrades
minor updates
simple and nice index file
Rename and updates
Movielauncher in c't special edition
rename: nntp2rss
RSSCreator
nntp2rdf
RDF feed



XML/RDF

[Valid RSS]
0.0143 sec