include using http://

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

    include using http://

    i am using include("http://".$_SERVER['SERVER_NAME']."/db.php"); to include
    a file. It isnt returning anything or connecting to the database (which is
    what it is supposed to be doing).

    any ideas? if i put in the path to the file it works, but I need it to do it
    over http the rest of the code is being run over a symbolic link and I need
    different connections per website.



  • Savut

    #2
    Re: include using http://

    If you use include with http://, then the included file contain the result
    after interpreted. What I mean is the php parser will see the included file
    as you see it in browser http://".$_SERVER['SERVER_NAME']."/db.php

    Savut


    "*" <*@*.com> wrote in message news:cedt3f$e3h $1@news.netkone ct.net...[color=blue]
    >i am using include("http://".$_SERVER['SERVER_NAME']."/db.php"); to include
    > a file. It isnt returning anything or connecting to the database (which is
    > what it is supposed to be doing).
    >
    > any ideas? if i put in the path to the file it works, but I need it to do
    > it
    > over http the rest of the code is being run over a symbolic link and I
    > need
    > different connections per website.
    >
    >
    >[/color]

    Comment

    • *

      #3
      Re: include using http://

      ooh, i see

      could i use a echo to write out stuff that could be parsed by the php
      scripts.
      so i echo out
      database=dbname

      and then take parse it in my script ?


      "Savut" <webki@hotmail. com> wrote in message
      news:DBvOc.9060 $pc.488501@news 20.bellglobal.c om...[color=blue]
      > If you use include with http://, then the included file contain the result
      > after interpreted. What I mean is the php parser will see the included[/color]
      file[color=blue]
      > as you see it in browser http://".$_SERVER['SERVER_NAME']."/db.php
      >
      > Savut
      > http://www.savut.com
      >
      > "*" <*@*.com> wrote in message news:cedt3f$e3h $1@news.netkone ct.net...[color=green]
      > >i am using include("http://".$_SERVER['SERVER_NAME']."/db.php"); to[/color][/color]
      include[color=blue][color=green]
      > > a file. It isnt returning anything or connecting to the database (which[/color][/color]
      is[color=blue][color=green]
      > > what it is supposed to be doing).
      > >
      > > any ideas? if i put in the path to the file it works, but I need it to[/color][/color]
      do[color=blue][color=green]
      > > it
      > > over http the rest of the code is being run over a symbolic link and I
      > > need
      > > different connections per website.
      > >
      > >
      > >[/color]
      >[/color]


      Comment

      • Savut

        #4
        Re: include using http://

        you could do such
        echo "database=dbnam e";

        but just a note that the including page, you have to play with it and make
        some workaround, why dont you just include it without using url ? Can you
        explain me your situation, maybe I can suggest you a better solution.

        Savut


        "*" <*@*.com> wrote in message news:cee2c7$fc2 $1@news.netkone ct.net...[color=blue]
        > ooh, i see
        >
        > could i use a echo to write out stuff that could be parsed by the php
        > scripts.
        > so i echo out
        > database=dbname
        >
        > and then take parse it in my script ?
        >
        >
        > "Savut" <webki@hotmail. com> wrote in message
        > news:DBvOc.9060 $pc.488501@news 20.bellglobal.c om...[color=green]
        >> If you use include with http://, then the included file contain the
        >> result
        >> after interpreted. What I mean is the php parser will see the included[/color]
        > file[color=green]
        >> as you see it in browser http://".$_SERVER['SERVER_NAME']."/db.php
        >>
        >> Savut
        >> http://www.savut.com
        >>
        >> "*" <*@*.com> wrote in message news:cedt3f$e3h $1@news.netkone ct.net...[color=darkred]
        >> >i am using include("http://".$_SERVER['SERVER_NAME']."/db.php"); to[/color][/color]
        > include[color=green][color=darkred]
        >> > a file. It isnt returning anything or connecting to the database (which[/color][/color]
        > is[color=green][color=darkred]
        >> > what it is supposed to be doing).
        >> >
        >> > any ideas? if i put in the path to the file it works, but I need it to[/color][/color]
        > do[color=green][color=darkred]
        >> > it
        >> > over http the rest of the code is being run over a symbolic link and I
        >> > need
        >> > different connections per website.
        >> >
        >> >
        >> >[/color]
        >>[/color]
        >
        >[/color]

        Comment

        • *

          #5
          Re: include using http://

          OK

          i want to have two (or more) websites on a server that use exactly the same
          code with only a couple of small differences in the site title, site id
          number (for database purposes). I did try using symbolic links but it didnt
          work very well.


          "Savut" <webki@hotmail. com> wrote in message
          news:KrxOc.195$ cE5.1921@news20 .bellglobal.com ...[color=blue]
          > you could do such
          > echo "database=dbnam e";
          >
          > but just a note that the including page, you have to play with it and make
          > some workaround, why dont you just include it without using url ? Can you
          > explain me your situation, maybe I can suggest you a better solution.
          >
          > Savut
          > http://www.savut.com
          >
          > "*" <*@*.com> wrote in message news:cee2c7$fc2 $1@news.netkone ct.net...[color=green]
          > > ooh, i see
          > >
          > > could i use a echo to write out stuff that could be parsed by the php
          > > scripts.
          > > so i echo out
          > > database=dbname
          > >
          > > and then take parse it in my script ?
          > >
          > >
          > > "Savut" <webki@hotmail. com> wrote in message
          > > news:DBvOc.9060 $pc.488501@news 20.bellglobal.c om...[color=darkred]
          > >> If you use include with http://, then the included file contain the
          > >> result
          > >> after interpreted. What I mean is the php parser will see the included[/color]
          > > file[color=darkred]
          > >> as you see it in browser http://".$_SERVER['SERVER_NAME']."/db.php
          > >>
          > >> Savut
          > >> http://www.savut.com
          > >>
          > >> "*" <*@*.com> wrote in message news:cedt3f$e3h $1@news.netkone ct.net...
          > >> >i am using include("http://".$_SERVER['SERVER_NAME']."/db.php"); to[/color]
          > > include[color=darkred]
          > >> > a file. It isnt returning anything or connecting to the database[/color][/color][/color]
          (which[color=blue][color=green]
          > > is[color=darkred]
          > >> > what it is supposed to be doing).
          > >> >
          > >> > any ideas? if i put in the path to the file it works, but I need it[/color][/color][/color]
          to[color=blue][color=green]
          > > do[color=darkred]
          > >> > it
          > >> > over http the rest of the code is being run over a symbolic link and[/color][/color][/color]
          I[color=blue][color=green][color=darkred]
          > >> > need
          > >> > different connections per website.
          > >> >
          > >> >
          > >> >
          > >>[/color]
          > >
          > >[/color]
          >[/color]


          Comment

          • Nikolai Chuvakhin

            #6
            Re: include using http://

            "*" <*@*.com> wrote in message
            news:<cedt3f$e3 h$1@news.netkon ect.net>...[color=blue]
            >
            > i am using include("http://".$_SERVER['SERVER_NAME']."/db.php");[/color]

            Bad idea. Use include('db.php ') instead. There is a HIGHLY
            insecure workaround. Rename your db.php into db.txt and

            include('http://' . $_SERVER['SERVER_NAME'] . '/db.txt');

            It will work, but your code (including database passwords) will be
            visible to anyone who by chance stumbles into your text/PHP file.
            [color=blue]
            > if i put in the path to the file it works,[/color]

            Which is exactly how it is supposed to work.
            [color=blue]
            > but I need it to do it over http[/color]

            No you don't.
            [color=blue]
            > the rest of the code is being run over a symbolic link and I need
            > different connections per website.[/color]

            So figure out a way to include() files by their local filenames
            per Web site.

            Cheers,
            NC

            Comment

            • Tim Van Wassenhove

              #7
              Re: include using http://

              In article <ceehft$k5r$1@n ews.netkonect.n et>, * wrote:[color=blue]
              > OK
              >
              > i want to have two (or more) websites on a server that use exactly the same
              > code with only a couple of small differences in the site title, site id
              > number (for database purposes). I did try using symbolic links but it didnt
              > work very well.[/color]

              if (isset($_SERVER['HTTP_HOST']))
              {
              $site = $_SERVER['HTTP_HOST'];
              }
              else
              {
              $site = 'default';
              }
              require_once('s ettings_'.$host );

              Offcourse you expand this to find differences between http and https,
              ports numbers, ...


              --
              Tim Van Wassenhove <http://home.mysth.be/~timvw>

              Comment

              • ChronoFish

                #8
                Re: include using http://

                If you have access to the webserver you're reading from you
                could rename or copy the "config" file to a text file such
                as:

                http://".$_SERVER['SERVER_NAME']."/db.txt

                That way apache won't execute it - it would just display it
                (the code) as plain text.

                Having said that, anything that can be read in by "include"
                using "http://..." can also be read by prying eyes. It may
                be convenient, or a "neat" trick, but it would not be a very
                good solution for a "real world" application.

                -CF

                "*" <*@*.com> wrote in message
                news:cee2c7$fc2 $1@news.netkone ct.net...[color=blue]
                > ooh, i see
                >
                > could i use a echo to write out stuff that could be parsed[/color]
                by the php[color=blue]
                > scripts.
                > so i echo out
                > database=dbname
                >
                > and then take parse it in my script ?
                >
                >
                > "Savut" <webki@hotmail. com> wrote in message
                > news:DBvOc.9060 $pc.488501@news 20.bellglobal.c om...[color=green]
                > > If you use include with http://, then the included file[/color][/color]
                contain the result[color=blue][color=green]
                > > after interpreted. What I mean is the php parser will[/color][/color]
                see the included[color=blue]
                > file[color=green]
                > > as you see it in browser[/color][/color]
                http://".$_SERVER['SERVER_NAME']."/db.php[color=blue][color=green]
                > >
                > > Savut
                > > http://www.savut.com
                > >
                > > "*" <*@*.com> wrote in message[/color][/color]
                news:cedt3f$e3h $1@news.netkone ct.net...[color=blue][color=green][color=darkred]
                > > >i am using[/color][/color][/color]
                include("http://".$_SERVER['SERVER_NAME']."/db.php"); to[color=blue]
                > include[color=green][color=darkred]
                > > > a file. It isnt returning anything or connecting to[/color][/color][/color]
                the database (which[color=blue]
                > is[color=green][color=darkred]
                > > > what it is supposed to be doing).
                > > >
                > > > any ideas? if i put in the path to the file it works,[/color][/color][/color]
                but I need it to[color=blue]
                > do[color=green][color=darkred]
                > > > it
                > > > over http the rest of the code is being run over a[/color][/color][/color]
                symbolic link and I[color=blue][color=green][color=darkred]
                > > > need
                > > > different connections per website.
                > > >
                > > >
                > > >[/color]
                > >[/color]
                >
                >[/color]


                Comment

                • Savut

                  #9
                  Re: include using http://

                  If there are on the same server, you can use include() with full path to the
                  file
                  web1 : include("/home/user1/website1/file.inc")
                  web2 : include("/home/user1/website1/file.inc")

                  If not, they you must play with javascript
                  web1 : <script src=http://www.site1.com/js/stuff1.php>
                  web2 : <script src=http://www.site1.com/js/stuff1.php>

                  in stuff1.php, you can write something like:
                  <?php
                  echo "document.write (\"".time()."\" );";
                  ?>

                  Savut


                  "*" <*@*.com> wrote in message news:ceehft$k5r $1@news.netkone ct.net...[color=blue]
                  > OK
                  >
                  > i want to have two (or more) websites on a server that use exactly the
                  > same
                  > code with only a couple of small differences in the site title, site id
                  > number (for database purposes). I did try using symbolic links but it
                  > didnt
                  > work very well.
                  >
                  >
                  > "Savut" <webki@hotmail. com> wrote in message
                  > news:KrxOc.195$ cE5.1921@news20 .bellglobal.com ...[color=green]
                  >> you could do such
                  >> echo "database=dbnam e";
                  >>
                  >> but just a note that the including page, you have to play with it and
                  >> make
                  >> some workaround, why dont you just include it without using url ? Can
                  >> you
                  >> explain me your situation, maybe I can suggest you a better solution.
                  >>
                  >> Savut
                  >> http://www.savut.com
                  >>
                  >> "*" <*@*.com> wrote in message news:cee2c7$fc2 $1@news.netkone ct.net...[color=darkred]
                  >> > ooh, i see
                  >> >
                  >> > could i use a echo to write out stuff that could be parsed by the php
                  >> > scripts.
                  >> > so i echo out
                  >> > database=dbname
                  >> >
                  >> > and then take parse it in my script ?
                  >> >
                  >> >
                  >> > "Savut" <webki@hotmail. com> wrote in message
                  >> > news:DBvOc.9060 $pc.488501@news 20.bellglobal.c om...
                  >> >> If you use include with http://, then the included file contain the
                  >> >> result
                  >> >> after interpreted. What I mean is the php parser will see the
                  >> >> included
                  >> > file
                  >> >> as you see it in browser http://".$_SERVER['SERVER_NAME']."/db.php
                  >> >>
                  >> >> Savut
                  >> >> http://www.savut.com
                  >> >>
                  >> >> "*" <*@*.com> wrote in message news:cedt3f$e3h $1@news.netkone ct.net...
                  >> >> >i am using include("http://".$_SERVER['SERVER_NAME']."/db.php"); to
                  >> > include
                  >> >> > a file. It isnt returning anything or connecting to the database[/color][/color]
                  > (which[color=green][color=darkred]
                  >> > is
                  >> >> > what it is supposed to be doing).
                  >> >> >
                  >> >> > any ideas? if i put in the path to the file it works, but I need it[/color][/color]
                  > to[color=green][color=darkred]
                  >> > do
                  >> >> > it
                  >> >> > over http the rest of the code is being run over a symbolic link and[/color][/color]
                  > I[color=green][color=darkred]
                  >> >> > need
                  >> >> > different connections per website.
                  >> >> >
                  >> >> >
                  >> >> >
                  >> >>
                  >> >
                  >> >[/color]
                  >>[/color]
                  >
                  >[/color]

                  Comment

                  • Savut

                    #10
                    Re: include using http://

                    Or include using include() but some server block include() using file on
                    another server, so I prefer script src when the application is distributed.

                    Savut


                    "Savut" <webki@hotmail. com> wrote in message
                    news:FJqPc.5938 $Jq2.340422@new s20.bellglobal. com...[color=blue]
                    > If there are on the same server, you can use include() with full path to
                    > the file
                    > web1 : include("/home/user1/website1/file.inc")
                    > web2 : include("/home/user1/website1/file.inc")
                    >
                    > If not, they you must play with javascript
                    > web1 : <script src=http://www.site1.com/js/stuff1.php>
                    > web2 : <script src=http://www.site1.com/js/stuff1.php>
                    >
                    > in stuff1.php, you can write something like:
                    > <?php
                    > echo "document.write (\"".time()."\" );";
                    > ?>
                    >
                    > Savut
                    > http://www.savut.com
                    >
                    > "*" <*@*.com> wrote in message news:ceehft$k5r $1@news.netkone ct.net...[color=green]
                    >> OK
                    >>
                    >> i want to have two (or more) websites on a server that use exactly the
                    >> same
                    >> code with only a couple of small differences in the site title, site id
                    >> number (for database purposes). I did try using symbolic links but it
                    >> didnt
                    >> work very well.
                    >>
                    >>
                    >> "Savut" <webki@hotmail. com> wrote in message
                    >> news:KrxOc.195$ cE5.1921@news20 .bellglobal.com ...[color=darkred]
                    >>> you could do such
                    >>> echo "database=dbnam e";
                    >>>
                    >>> but just a note that the including page, you have to play with it and
                    >>> make
                    >>> some workaround, why dont you just include it without using url ? Can
                    >>> you
                    >>> explain me your situation, maybe I can suggest you a better solution.
                    >>>
                    >>> Savut
                    >>> http://www.savut.com
                    >>>
                    >>> "*" <*@*.com> wrote in message news:cee2c7$fc2 $1@news.netkone ct.net...
                    >>> > ooh, i see
                    >>> >
                    >>> > could i use a echo to write out stuff that could be parsed by the php
                    >>> > scripts.
                    >>> > so i echo out
                    >>> > database=dbname
                    >>> >
                    >>> > and then take parse it in my script ?
                    >>> >
                    >>> >
                    >>> > "Savut" <webki@hotmail. com> wrote in message
                    >>> > news:DBvOc.9060 $pc.488501@news 20.bellglobal.c om...
                    >>> >> If you use include with http://, then the included file contain the
                    >>> >> result
                    >>> >> after interpreted. What I mean is the php parser will see the
                    >>> >> included
                    >>> > file
                    >>> >> as you see it in browser http://".$_SERVER['SERVER_NAME']."/db.php
                    >>> >>
                    >>> >> Savut
                    >>> >> http://www.savut.com
                    >>> >>
                    >>> >> "*" <*@*.com> wrote in message
                    >>> >> news:cedt3f$e3h $1@news.netkone ct.net...
                    >>> >> >i am using include("http://".$_SERVER['SERVER_NAME']."/db.php"); to
                    >>> > include
                    >>> >> > a file. It isnt returning anything or connecting to the database[/color]
                    >> (which[color=darkred]
                    >>> > is
                    >>> >> > what it is supposed to be doing).
                    >>> >> >
                    >>> >> > any ideas? if i put in the path to the file it works, but I need it[/color]
                    >> to[color=darkred]
                    >>> > do
                    >>> >> > it
                    >>> >> > over http the rest of the code is being run over a symbolic link
                    >>> >> > and[/color]
                    >> I[color=darkred]
                    >>> >> > need
                    >>> >> > different connections per website.
                    >>> >> >
                    >>> >> >
                    >>> >> >
                    >>> >>
                    >>> >
                    >>> >
                    >>>[/color]
                    >>
                    >>[/color]
                    >[/color]

                    Comment

                    Working...