g ´day all here,

i am in need of a quick n dirty hack - can anybody help out here.

i traveled alot for examples and descriptions about the amazon web services. i came across many many sites for Amazon scripts that are easy.

i want to show on my homepage a number of 40 books. i am not a experienced php programmer - i am able to understand a bit of php but i am new to it. i had a look at a site with some nice scripts for Amazon web services.

http://www.chipdir.nl/amazon/

This site offers great insights into the AWS-technology.

But my server is limited to some restricted settings: i have no allow_url_fopen - to say it in other words my serverconfiguration option allow_url_fopen is set to OFF!

i only can make usage of fsockopen - so i only can make usage of scripts that work around the issues.

i want to run a site with a phpnuke. There is a great module that uses amazon web services - see http://preciogasolina.com/nukeamazon.html

but this script makes usage of the fopen. well i need a work around for this.

just another question - regarding another amazon script - here a PHP-Nuke module, called NukeAmazion:

the NukeAmazon, a phpnuke-module - makes usage of the fopen-function. it is a great and most wanted module. Since the mod runs in many many sites - and probably could run in much much more sites - somebody should replace the fopen with a method that is more appropiate here - your fsockopen. could you provide us with some guidlelines - how to replace the fopen with a better solution.

Well - here is the stuff.

http://preciogasolina.com/nukeamazon.html

see a thread of a user who complains the bad situation - and suggestes Curl as a solution

http://www.preciogasolina.com/modules.php?name=Forums&file=viewtopic&t=344

here is the stuff
http://www.preciogasolina.com/modules.php?name=Downloads&d_op=viewdownload&cid=1

well - the replacement should be only in one place - in the functions-file called functions.php : This file can be found in the includes-directory. the structure is the following:

http://www.preciogasolina.com

/admin
/blocks
/images
/includes/ functions.php
/modules

well - the only place where we can find fopen () function is here in the file

in the functions.php (which is in the includes-folder)

function AMZ_file_get_contents($filename)
{
$fp = @fopen($filename, "r");
if (!($fp))
{
return 0;
}
while (!feof($fp))
{
$temp .= utf8_decode(fread($fp, 4096));
}
fclose($fp);
return $temp;
}


that would be great. I try to do it on my own - and if you have some hints - how to patch then plz. let us know.

BTW; after this is done i will to patch the amazon-module
of this site. - also a great site; A standalone-script which is very very nice. http://www.accessories.me.uk a great script.... see it running. Well if you could guide us here it would be very nice.

if anybody could give some hints - if anybody could provide some advices and guidings then i would be very glad. You would make some most wanted script even more appropiate - and useable in real world scenarios. Since many many servers do not provide a fopen (), we could - should work around this serious bottlenneck.
What do you think

look forward to hear a answer

many greetings

bernard_hinault 😃

    assuming $filename is the url of the web service here is the translation

    function AMZ_file_get_contents($filename)
    {
      $url = parse_url($filename);
    
      $fp = @fsockopen($url['host'], $url['port'], $errno, $errstr, 10);
    
      if (!$fp) return 0;
    
      fputs($fp, "GET " . $url['path'] . "?" . @$url['query'] . " HTTP/1.0\r\n");
      fputs($fp, "Host: " . $url['host'] . "\r\n");
      fputs($fp, "Connection: close\r\n\r\n");
    
      $temp = "";
      while (!feof($fp)) {
        $temp .= utf8_decode(fgets($fp));
      }
    
      fclose($fp);
    
      return $temp;
    }
    

    also a good script i used to use was this:
    http://associatesshop.filzhut.de/download/index.php?LID=en
    it was very easy to setup and it uses fsockopen as well.
    i have an old demo on my page
    www.drew-phillips.com/books.php
    most of the books are old and unavailable but you can see the script in action a bit by clicking more details.

      hello drew010,

      many thanks for the reply and for your translation.

      Originally posted by drew010 assuming $filename is the url of the web service here is the translation

      function AMZ_file_get_contents($filename)
      {
        $url = parse_url($filename);
      
        $fp = @fsockopen($url['host'], $url['port'], $errno, $errstr, 10);
      
        if (!$fp) return 0;
      
        fputs($fp, "GET " . $url['path'] . "?" . @$url['query'] . " HTTP/1.0\r\n");
        fputs($fp, "Host: " . $url['host'] . "\r\n");
        fputs($fp, "Connection: close\r\n\r\n");
      
        $temp = "";
        while (!feof($fp)) {
          $temp .= utf8_decode(fgets($fp));
        }
      
        fclose($fp);
      
        return $temp;
      }
      

      thanks i had a look at it - [at a first trial it did not run out of the box]. For the better understanding: The red parts of your hack - what to do with those?

      btw. Since this is a phpnukemodule i am not shure where some other errors may cause troubles. The whole module is sometimes very difficult to setup and handle. So i think that there are some other issues - that stop the amazon-module form working.

      also a good script i used to use was this:
      http://associatesshop.filzhut.de/download/index.php?LID=en
      it was very easy to setup and it uses fsockopen as well.
      i have an old demo on my page
      www.drew-phillips.com/books.php
      most of the books are old and unavailable but you can see the script in action a bit by clicking more details.

      filzhut is certainly a nice solution - and i really like what isee on your site. But i want to concentrate on scripts that are free to use - without limitations.

      drew010. All scripts that make usage of fopen do not work on my server.
      I tested several scripts with amazon web services aws.
      i thought that it is worth looking at the script of this guy here.

      http://www.accessories.me.uk

      it looks nice - makes usage of ECS4 (/amazon web services 4) is set up in less than 10 minutes. But it makes usage of fopen - it requres servers with the option allow_url_fopen switched to ON!!

      so what?

      drew010 since you could provides some great ideas in the above solution - one additional question: can you assist and help out here - Can you show me where to patch the script here

      http://www.accessories.me.uk

      on a quick walkthrough i did not see any fopen () in the code of the files, but there must be somewhere hidden. And my server stopps this - does not allow such requests.

      drew010 i would appreciate your input here - do you have any ideas where to patch this standalone script with your fsockopen solution.

      i am looking forward to your answer - many thanks in advance.

      greetings,
      bernard_hinault

      ps. currently some people are discussing to patch the script. but so far noone has a solution. But i am sure that this is done by a experienced programmer within ten minutes.

        Write a Reply...