Right, my last try with fsocks etc didn't work so I tried a new approach and so far it's not going to bad.
I simply switched from http://www.blahblahblah to /home/etcetc and now the fopens are working a treat. However there is a problem with the following which I don't understand at all. It is returning false around the point I have labeled and I don't know why??? Grr.
function loadFile($lpszFileName, $iIndex)
{
if($iIndex < 0) {
return false;
}
// READ FILE
if(!($fh = @fOpen($lpszFileName, "rb"))) {
return false;
}
//EDITEI - in order to read remote files (HTTP(s) and FTP protocols)
if ( strpos($lpszFileName,"http") !== false or strpos($lpszFileName,"ftp") !== false )
{
$contents = '';
while (!feof($fh)) $contents .= @fread($fh, 8192);
}
else
{
$contents = @fread($fh,@filesize($lpszFileName) );
}
$this->m_lpData = $contents;
// $this->m_lpData = @fRead($fh, @fileSize($lpszFileName));
fClose($fh);
// GET FILE HEADER
if(!$this->m_gfh->load($this->m_lpData, $len = 0)) {
return false;
}
$this->m_lpData = substr($this->m_lpData, $len);
do {
if(!$this->m_img->load($this->m_lpData, $imgLen = 0)) {
//this returns false now
return false;
}
$this->m_lpData = substr($this->m_lpData, $imgLen);
}
while($iIndex-- > 0);
$this->m_bLoaded = true;
return true;
}
Is it something to do with a problem with the image headers/filesize etc. Is there a way I can solve it.
Thanks so much for the help on this it's way over my head! 🙂
P.S the function load() that the line giving me troubles is
function load($data, &$datLen)
{
$datLen = 0;
while(true) {
$b = ord($data{0});
$data = substr($data, 1);
$datLen++;
switch($b) {
case 0x21: // Extension
if(!$this->skipExt($data, $len = 0)) {
return false;
}
$datLen += $len;
break;
case 0x2C: // Image
// LOAD HEADER & COLOR TABLE
if(!$this->m_gih->load($data, $len = 0)) {
return false;
}
$data = substr($data, $len);
$datLen += $len;
// ALLOC BUFFER
if(!($this->m_data = $this->m_lzw->deCompress($data, $len = 0))) {
return false;
}
$data = substr($data, $len);
$datLen += $len;
if($this->m_gih->m_bInterlace) {
$this->deInterlace();
}
return true;
case 0x3B: // EOF
default:
return false;
}
}
return false;
}
Infact here is the whole file that is causing problems.