Hi,
I have a problem using a URL fetching algorithm (HTTP 1.0).
To download an image, I used to use this algorithm:
<?php
Header("Content-type: image/gif");
$referer = "http://www.creators.co m/comics_show.cfm ?comicname=mrh" ;
$url = "http://www.creators.co m/1130/mrh/mrh1202g.gif";
$url = str_replace("&a mp;","&",$url) ;
$tmp = parse_url($url) ;
$host = $tmp["host"];
$page = $tmp["path"];
if(isset($tmp["query"]))
$page .= "?". $tmp["query"];
if(isset($tmp["fragment"]))
$page .= "#". $tmp["fragment"];
$fp = fsockopen ($host, 80, $errno, $errstr, 15);
if($fp)
{
$response = "";
$header = "";
$request = "GET $page HTTP/1.0\r\nHost: $host\r\nUser-Agent:
Mozilla/4.0\r\nAccept:i mage/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1\r\nAcce pt-Language:
en-us,en;q=0.5\r\n Accept-Charset:
ISO-8859-1,utf-8;q=0.7,*;q=0.7 \r\nKeep-Alive: 300\r\nConnecti on:
keep-alive\r\nRefere r: ". $referer. "\r\n\r\n";
fputs ($fp, $request);
do
{
$header.=fgets( $fp, 1024);
if(feof($fp))
break;
}
while (!preg_match("/\\r\\n\\r\\n$/",$header)) ;
$tmp_response = fread ($fp, 2048);
while (!feof($fp))
{
$tmp_response .= fread ($fp, 4096);
}
echo $tmp_response;
@fclose ($fp);
}
?>
while it works in *most* web sites, it does not work in creators.com
and in a few more web sites.
If I use curl:
<?php
Header("Content-type: image/gif");
$referer = "http://www.creators.co m/comics_show.cfm ?comicname=mrh" ;
$url = "http://www.creators.co m/1130/mrh/mrh1202g.gif";
$ch = curl_init();
curl_setopt($ch , CURLOPT_URL,$ur l);
curl_setopt($ch , CURLOPT_REFERER , $referer);
curl_setopt($ch , CURLOPT_USERAGE NT, "Mozilla/4.0");
curl_exec ($ch);
curl_close ($ch);
?>
it works.
The problem is that I have no curl support in my web site. Any one can
detect the error in my code?
Thanks in advance,
Andres 0 2063 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: martin.mrazek |
last post by:
Hello,
when installing the followin modulue from CPAN under MDK Linux I
receive the error message (in the end of STDERR output) which I don't
understand. Can you tell me what's wrong there? Shall I follow the
message and install it with force?
Regards
Martin
|
by: Bob |
last post by:
I have an ASP.NET web application that has been running without any problems for a while. I recently transferred the site to shared hosting and had multiple users start to use the site. The problem I'm experiencing is that when many users are hitting the site at once, occasionaly I will see errors. The 3 most common ones are: "The SqlCommand is currently busy Open, Fetching. ", "Internal Connection Fatal Error", "object reference not set to...
|
by: Jack |
last post by:
Hi,
Here is my problem:
I am logging in to a page, where the page retrieves a record from a database.
The text boxes are used in the display formto let the users update the
fields,
if they desire to.
The colorpreference and foodpreference fields are text fields
while the FinalUpdate field is a yes/no field in Access Database.
|
by: Eric J. Holtman |
last post by:
I feel like the answer to this should be blinding obvious. I also
feel like it's probably an exercise in an undergraduate database
design course. I'm off to google for an answer, but I figure I'd
throw it out here to see if there's a quick and dirty solution.
I have in my database a table of every position we have here called
Holdings. It would be equivalent to an Inventory table in every
basic design course.
There are many users...
|
by: Shujun Huang |
last post by:
Hi,
I am working on converting Informix database to Postgre. I have one
question for fetching records using PostgreSQL. The record I am fetching
is a variable size text string. Before fetching the record, a
preallocated static buffer size will have to be declared beforehand in
the declaration section. Since the record sizes vary a lot, instead of
using the static buffer, is there a dynamic way to fetch these records?
Informix (Oracle...
| |
by: Sandman |
last post by:
So, I have this content management system I've developed myself. The
system has a solid community part where members can register and then
participate in forums, write weblogs and a ton of other things.
So, in instances where I list, for example, the latest weblogs. I list
the headline of the weblog, the date and the name of the member who
wrote it.
Now, the name isn't just "Smith", but rather Smith's online status,
his nick and his...
|
by: Bhavesh |
last post by:
Hi Bruce,
Thanks For Reply.
U were right, Needed to pass string , but also need to pass size of
Data( instead of 16, passed actual length of data). So that worked for
me & didn't get any error.
But now problem in fetching, not able to fetch data from table
correctly. Here is my code. I hav following problems with this coding
|
by: SunshineInTheRain |
last post by:
I'm trying to modify a long long code within a button click by make the insert/update/delete/select using the same transaction. Purpose is to make sure every operation can be rollback instead of some table inserted but some not. But I get this error:
The SqlCommand is currently busy Open, Fetching.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information...
|
by: spatro |
last post by:
Hi,
I am trying to install DBD::mysql using the CPAN and I am facing the following error:
cpan> install DBD::mysql
CPAN: Storable loaded ok
Going to read /root/.cpan/Metadata
Warning: Found only 0 objects in /root/.cpan/Metadata
CPAN: LWP::UserAgent loaded ok
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |