Author Topic: readfile() workaround  (Read 3090 times)

abemedia

  • Beginner
  • *
  • Posts: 10
    • abeMedia - Web Design Brighton
readfile() workaround
« on: July 18, 2009, 17:57:01 pm »
Hello!

I installed Virtuemart 1.1.3 on one of my clients servers, however readfile() is disabled and they don't allow modifications to php.ini

Is there a workaround? I found this: http://forum.virtuemart.net/index.php?topic=40289.0 but it didn't seem to work unless I was doing something wrong...

Any help would be greatly appreciated!

Thanks.

floren

  • Beginner
  • *
  • Posts: 4
Re: readfile() workaround
« Reply #1 on: October 10, 2009, 15:49:23 pm »
If you get a error when calling the image directly in the browser like this:

http://www.yourname.com/components/com_virtuemart/show_image_in_imgtag.php?filename=yourimage.jpg


And get this error:

<b>Warning</b>:  readfile() has been disabled for security reasons in <b>/home/yoursite/public_html/components/com_virtuemart/show_image_in_imgtag.php</b> on line <b>155</b><br />


You can ad the function to the named files in the tread named above like this (just above the first readfile call):


function rpl_readfile($file){
    $handle=@fopen($file,"r");
    echo @fread($handle,filesize($file));
    @fclose($handle);
}


and then change ALL the readfile cals in rpl_readfile like this:


if( file_exists( $fileout ) ) {
  /* We already have a resized image
  * So send the file to the browser */

     switch(strtolower($ext))
      {
         case ".gif":
            header ("Content-type: image/gif");
            rpl_readfile($fileout);
            break;
         case ".jpg":
            header ("Content-type: image/jpeg");
            rpl_readfile($fileout);
            break;
         case ".png":
            header ("Content-type: image/png");
            rpl_readfile($fileout);
            break;
      }
}



If you do this in the other mentioned files: (for vm 1.1 don't know if there are more in 1.13)
/components/com_virtuemart/fetchscript.php
/components/com_virtuemart/show_image_in_imgtag.php
/administrator/components/com_virtuemart/classes/shipping/minixml/classes/doc.inc.php

You can solve the problems not showing tumpnail images in browse pages and a lot of javascripts erros.... on other pages....



Uriel

  • Jr. Member
  • **
  • Posts: 78
    • Web design Hosting & Seo
Re: readfile() workaround
« Reply #2 on: March 25, 2010, 14:43:35 pm »
Sorry for opening this thread again but I am stuck and have tried most things in the Forum and can not get it right.

Running VM 1.1.2

The procedure you explained for the file : show_image_in_imgtag.php

Is it the same for VM 1.1.2 - please could you describe in a bit more detail what to do here to a NON CODER  ???

Managing Member of Hosting-Webdesign http://www.hosting-webdesign.co.za