Passing data from one site to another

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

    Passing data from one site to another

    Hi,

    I run a few sites and I want to log in my main site database when/if there
    is a problem, (like a page not found or an unknown agent).

    But I don't want to give direct access to my database to the other sites, so
    how could I safely pass data, (without passwords), from one site to another?

    Thanks.
    Simon


  • ppalmieri@gmail.com

    #2
    Re: Passing data from one site to another

    i think i follow your question,

    Something i am doing is i built a listener...
    www.page12.com/errors.php (not a real url)

    then in all my apps, i have an error class-- then i curl with a post
    to errors.php.

    i also use this for other stuff like tracking and all

    Phil


    Florent wrote:[color=blue]
    > Hi,
    >
    > I run a few sites and I want to log in my main site database when/if[/color]
    there[color=blue]
    > is a problem, (like a page not found or an unknown agent).
    >
    > But I don't want to give direct access to my database to the other[/color]
    sites, so[color=blue]
    > how could I safely pass data, (without passwords), from one site to[/color]
    another?[color=blue]
    >
    > Thanks.
    > Simon[/color]

    Comment

    • Florent

      #3
      Re: Passing data from one site to another

      >i think i follow your question,[color=blue]
      >
      > Something i am doing is i built a listener...
      > www.page12.com/errors.php (not a real url)
      >
      > then in all my apps, i have an error class-- then i curl with a post
      > to errors.php.
      >
      > i also use this for other stuff like tracking and all
      >
      > Phil[/color]

      No, What I mean was if site A wants to send data to site B.
      I guess I could "www.B.com/msg.php?a=10"
      but what I was really after is site A sending long information to B without
      redirecting to A

      Simon


      Comment

      • NC

        #4
        Re: Passing data from one site to another


        Florent wrote:[color=blue]
        >
        > I run a few sites and I want to log in my main site
        > database­ when/if there is a problem, (like a page not
        > found or an unknown agent).
        >
        > But I don't want to give direct access to my database
        > to the­ other sites, so how could I safely pass data,
        > (without passwords), from one ­site to another?[/color]
        ....[color=blue]
        > What I mean was if site A wants to send data to site B.
        > I guess I could "www.B.com/msg.php?a=10"
        > but what I was really after is site A sending long
        > information to B without redirecting to A[/color]

        This is entirely possible, but will likely result in a
        performance drag. If you are prepared to live with it,
        here are a few recommendations .

        The easiest thing to do would be to implement a report
        generator of sorts on site A and have site B request
        reports by name. Example:

        Site B code:

        readfile('http://www.siteB.com/report.php?id=s tatus');

        Site A code:

        if (isset($_GET['id'])) {
        $id = $_GET['id'];
        } else {
        die();
        }
        switch($id) {
        case 'status':
        $query = 'SELECT this FROM that ...';
        break;
        // many other cases here...
        default:
        die();
        }
        $result = mysql_query($qu ery);
        while ($record = mysql_fetch_arr ay($result, MYSQL_NUM)) {
        echo "<tr>\r\n";
        foreach ($record as $field) {
        echo "<td>$field </td>\r\n";
        echo "</tr>\r\n";
        }
        }

        In other words, site A would return fully-formatted HTML in
        response to a request from site B. Alternatively, you can
        return comma-separated or tab-delimited text and have it
        formatted on site B.

        A less secure alternative is to send actual queries from
        site B to site A. The danger is that a hacker could send
        a query which would destroy or modify your data. So if
        you want to go this route, you will have to make sure that
        the report generator script connects to the database as a
        user with SELECT-only rights.

        Finally, you can implement a Web service with a similar
        functionality.. .

        Cheers,
        NC

        Comment

        • Florent

          #5
          Re: Passing data from one site to another

          > This is entirely possible, but will likely result in a[color=blue]
          > performance drag. If you are prepared to live with it,
          > here are a few recommendations .[/color]

          Looking at your example I am not sure I understand where there would be a
          performance lag.
          [color=blue]
          >
          > The easiest thing to do would be to implement a report
          > generator of sorts on site A and have site B request
          >reports by name. Example:
          >
          > Site B code:
          >
          > readfile('http://www.siteB.com/report.php?id=s tatus');[/color]

          don't you mean 'www.siteA.com' rather?
          Site B will request from SiteA...
          [color=blue]
          >
          >
          > In other words, site A would return fully-formatted HTML in
          > response to a request from site B. Alternatively, you can
          > return comma-separated or tab-delimited text and have it
          > formatted on site B.[/color]

          Does it really have to be html, CS or TD text?
          Can it not be any format I like? The reason I ask is that I could return
          encrypted text of some sort to be certain that the data is 'fairly' safe.
          [color=blue]
          >
          > A less secure alternative is to send actual queries from
          > site B to site A. The danger is that a hacker could send
          > a query which would destroy or modify your data. So if
          > you want to go this route, you will have to make sure that
          > the report generator script connects to the database as a
          > user with SELECT-only rights.[/color]

          I don't think i wwill go down this road.
          [color=blue]
          >
          > Finally, you can implement a Web service with a similar
          > functionality.. .[/color]

          A biut of an overkill wouldn't it be?
          [color=blue]
          >
          > Cheers,
          > NC[/color]

          Many thanks,
          Regards

          Simon


          Comment

          • NC

            #6
            Re: Passing data from one site to another

            Florent wrote:[color=blue]
            >
            > Looking at your example I am not sure I understand where
            > there would be a performance lag.[/color]

            OK, if you allow site B direct access to site A's database
            server, here's what going to happen:

            1. Site B opens a TCP connection to site A's database
            server.

            That's it; a single step.

            If you prefer to go through site A as an intermediary,
            there's going to be an extra step involved:

            1. Site B opens an HTTP connection to site A.
            2. Site A opens a TCP or socket connection to its database
            server.

            Opening a connection takes time. In the first scenario,
            only one connection needs to be opened. In the second
            scenario, two connections need to be established.

            NC> Site B code:
            NC>
            NC> readfile('http://www.siteB.com/report.php?id=s tatus');[color=blue]
            >
            > don't you mean 'www.siteA.com' rather?
            > Site B will request from SiteA...[/color]

            Of course. My apologies for confusion.

            NC> In other words, site A would return fully-formatted HTML in
            NC> response to a request from site B. Alternatively, you can
            NC> return comma-separated or tab-delimited text and have it
            NC> formatted on site B.[color=blue]
            >
            > Does it really have to be html, CS or TD text?[/color]

            No, it can be anything you want. HTML or text were just the
            most obvious and easiest to implement examples.

            Cheers,
            NC

            Comment

            Working...