Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Passing data from one site to another

0 views
Skip to first unread message

Florent

unread,
Feb 2, 2005, 10:24:09 AM2/2/05
to
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


ppal...@gmail.com

unread,
Feb 2, 2005, 12:59:55 PM2/2/05
to
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

unread,
Feb 2, 2005, 1:12:33 PM2/2/05
to
>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

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


NC

unread,
Feb 2, 2005, 2:01:24 PM2/2/05
to

Florent wrote:
>
> 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?
...

> 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

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=status');

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($query);
while ($record = mysql_fetch_array($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

Florent

unread,
Feb 3, 2005, 5:52:36 AM2/3/05
to
> 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.

Looking at your example I am not sure I understand where there would be a
performance lag.

>
> 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=status');

don't you mean 'www.siteA.com' rather?
Site B will request from SiteA...

>
>
> 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.

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.

>
> 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.

I don't think i wwill go down this road.

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

A biut of an overkill wouldn't it be?

>
> Cheers,
> NC

Many thanks,
Regards

Simon


NC

unread,
Feb 3, 2005, 1:02:06 PM2/3/05
to
Florent wrote:
>
> Looking at your example I am not sure I understand where
> there would be a performance lag.

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=status');


>
> don't you mean 'www.siteA.com' rather?
> Site B will request from SiteA...

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.


>
> Does it really have to be html, CS or TD text?

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

Cheers,
NC

0 new messages