Including a .php file from another server?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • hntgzr

    Including a .php file from another server?

    I am trying to include a function in a .php file on a different server from
    the main .php files.

    I am using:

    include_path=ht tp://www.anotherserv er.com/foldername;
    include(http://www.anotherserver.com/foldern...letocall.inc);

    The .inc file is php formatted. Variables are passed to it (not via GET or
    POST though) and returned using return(variable names, etc);

    But for some reason it doesn't appear to work properly.

    Am I correct in using the .inc extension?
    Are the commands above correctly written?

    Basically I am trying to use the fsockopen function in a .php file on
    another server where I know it works and return the results to a server
    where the fsockopen command doesn't work.

    Any help or guidance would be greatly appreciated.
    TIA
    h


  • Jerry Stuckle

    #2
    Re: Including a .php file from another server?

    hntgzr wrote:[color=blue]
    > I am trying to include a function in a .php file on a different server from
    > the main .php files.
    >
    > I am using:
    >
    > include_path=ht tp://www.anotherserv er.com/foldername;
    > include(http://www.anotherserver.com/foldern...letocall.inc);
    >
    > The .inc file is php formatted. Variables are passed to it (not via GET or
    > POST though) and returned using return(variable names, etc);
    >
    > But for some reason it doesn't appear to work properly.
    >
    > Am I correct in using the .inc extension?
    > Are the commands above correctly written?
    >
    > Basically I am trying to use the fsockopen function in a .php file on
    > another server where I know it works and return the results to a server
    > where the fsockopen command doesn't work.
    >
    > Any help or guidance would be greatly appreciated.
    > TIA
    > h
    >
    >[/color]

    When you access your php file this way, it has already been parsed by
    the web server. It's just like accessing it from your browser.

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • Gordon Burditt

      #3
      Re: Including a .php file from another server?

      >I am trying to include a function in a .php file on a different server from[color=blue]
      >the main .php files.[/color]

      When you fetch a PHP file from a remote server, that server processes it
      and sends out the OUTPUT (not the PHP code) from the file. I don't
      know how Apache on the server you are trying to fetch from deals
      with .inc files as opposed to .php files.

      Here's an idea: why don't you COPY phpfiletocall.i nc to the local
      server and use it there?
      [color=blue]
      >include_path=h ttp://www.anotherserv er.com/foldername;
      >include(http://www.anotherserver.com/foldern...letocall.inc);
      >
      >The .inc file is php formatted. Variables are passed to it (not via GET or
      >POST though) and returned using return(variable names, etc);[/color]

      If you were expecting to *RUN* phpfiletocall.i nc on www.anotherserver.com,
      how do you pass variables to it by other than via $_GET or $_POST?
      [color=blue]
      >But for some reason it doesn't appear to work properly.
      >
      >Am I correct in using the .inc extension?
      >Are the commands above correctly written?
      >
      >Basically I am trying to use the fsockopen function in a .php file on
      >another server where I know it works and return the results to a server
      >where the fsockopen command doesn't work.[/color]

      If you are using 'include', you are fetching code from a server
      where fsockopen will work (but you're not running it there) and
      attempting to use it on a server where it won't work (but that's
      where you're trying to make it work), if I understand your problem
      correctly.

      Gordon L. Burditt

      Comment

      • hntgzr

        #4
        Re: Including a .php file from another server?


        "Gordon Burditt" <gordonb.2h4eq@ burditt.org> wrote in message
        news:11jc2fh2a2 ovc1@corp.super news.com...[color=blue][color=green]
        > >I am trying to include a function in a .php file on a different server
        > >from
        >>the main .php files.[/color]
        >
        > When you fetch a PHP file from a remote server, that server processes it
        > and sends out the OUTPUT (not the PHP code) from the file. I don't
        > know how Apache on the server you are trying to fetch from deals
        > with .inc files as opposed to .php files.
        >
        > Here's an idea: why don't you COPY phpfiletocall.i nc to the local
        > server and use it there?
        >[color=green]
        >>include_path= http://www.anotherserv er.com/foldername;
        >>include(http://www.anotherserver.com/foldern...letocall.inc);
        >>
        >>The .inc file is php formatted. Variables are passed to it (not via GET
        >>or
        >>POST though) and returned using return(variable names, etc);[/color]
        >
        > If you were expecting to *RUN* phpfiletocall.i nc on www.anotherserver.com,
        > how do you pass variables to it by other than via $_GET or $_POST?
        >[color=green]
        >>But for some reason it doesn't appear to work properly.
        >>
        >>Am I correct in using the .inc extension?
        >>Are the commands above correctly written?
        >>
        >>Basically I am trying to use the fsockopen function in a .php file on
        >>another server where I know it works and return the results to a server
        >>where the fsockopen command doesn't work.[/color]
        >
        > If you are using 'include', you are fetching code from a server
        > where fsockopen will work (but you're not running it there) and
        > attempting to use it on a server where it won't work (but that's
        > where you're trying to make it work), if I understand your problem
        > correctly.
        >
        > Gordon L. Burditt[/color]

        Thanks for the reply.

        Yup, you understand my problem correctly :)

        I am trying to run code on a server where fsockopen does work from the sites
        local server where fsockopen doesn't work.

        The code located on the remote server (i think that's the correct
        terminology) is:

        [This is the announce-connectable.inc file]
        ---------

        <?

        $sockres = @fsockopen($ip, $port, $errno, $errstr, 8);

        if (!$sockres)
        {
        $connectable = "no";
        // @fclose($sockre s);
        }

        else
        {
        $connectable = "yes";
        @fclose($sockre s);
        }

        @return($ip, $port, $errno, $errstr);

        ?>

        ---------

        The php file on the local server that's calling it is using:
        include_path="h ttp://www.anotherserv er.com/folder";

        include("http://www.anotherserv er.com/folder/announce-connectable.inc ");


        Included in that file are the variables $ip and $port. $errno and $errstr
        are not passed to the .inc file as they should always be null prior to be
        returned.

        Am I trying to do something that PHP can't do?

        TIA
        h


        Comment

        • hntgzr

          #5
          Re: Including a .php file from another server?


          "Gordon Burditt" <gordonb.2h4eq@ burditt.org> wrote in message
          news:11jc2fh2a2 ovc1@corp.super news.com...[color=blue][color=green]
          > >I am trying to include a function in a .php file on a different server
          > >from
          >>the main .php files.[/color]
          >
          > When you fetch a PHP file from a remote server, that server processes it
          > and sends out the OUTPUT (not the PHP code) from the file. I don't
          > know how Apache on the server you are trying to fetch from deals
          > with .inc files as opposed to .php files.
          >
          > Here's an idea: why don't you COPY phpfiletocall.i nc to the local
          > server and use it there?
          >[/color]

          Because the command fsockopen doesn't work on the local server.
          [color=blue][color=green]
          >>include_path= http://www.anotherserv er.com/foldername;
          >>include(http://www.anotherserver.com/foldern...letocall.inc);
          >>
          >>The .inc file is php formatted. Variables are passed to it (not via GET
          >>or
          >>POST though) and returned using return(variable names, etc);[/color]
          >
          > If you were expecting to *RUN* phpfiletocall.i nc on www.anotherserver.com,
          > how do you pass variables to it by other than via $_GET or $_POST?
          >[/color]

          I thought the variables would pass to it anyway. I'm not an expert in PHP
          and go only by the guidance on php.net! I've not programmed since the late
          80's, so I'm a little out of touch, lol!

          If I pass the variables in the URL as ?ip=$ip&port=$p ort would that work?

          As an alternative, I could try calling a function written in CGI, but again,
          I am stumped as to how to call a CGI function from a PHP file and have the
          results returned!

          TIA
          h


          Comment

          • juglesh

            #6
            Re: Including a .php file from another server?

            If you want to run the included code on your server (like access a db
            or files on the including server with this included script) you could
            try a non standard ext. so, try including
            anotherserver.c om/includedscript. blah. The disadvantage here is that
            someone could access www.anotherserver.com/includedscript.blah and see
            your code, so you cant have anything secret on it. You might work
            around this by using .htaccess on anotherserver.c om to allow this
            script only from your including server...but, I really dont know the
            ins and outs of doing that.

            --
            juglesh

            Comment

            Working...