|
Posted by Rik on 08/17/07 15:17
On Fri, 17 Aug 2007 17:02:52 +0200, Jerim <wyount@gmail.com> wrote:
>> The fact that these 2 servers can hardly communicate is a real proble=
m.
>> You'll either have to get the output data and link it to age 'manuall=
y'
>> with PHP, or you'll have to really think about the database(server) =
>> setup.
>> Preferably all related data on one server, possibly a master/slave
>> scenario.
>
> Just read where someone with a similar problem suggested renaming the
> include file to .txt. Is that what you mean by raw PHP?
Yep.
> This might
> work,
Nope.
> as the file that is being included, itself calls an include that
> connects to the database.
Which would be non-existant on the server it executes on. PHP-code serve=
d =
that way is plain text, NOTHING of the envirnoment on the other server =
will be accessable.
> So even if I were to read the include file
> as raw text, no one should be able to see the database connection
> info.
Clearly not.
TO give you an illustration of the terrible hoops you have to jump throu=
gh:
Server 1 (people.php):
<?php
mysql_connect();
mysql_select_db();
$q =3D mysql_query('SELECT id, name FROM people');
$return =3D array();
while($row =3D mysql_fetch_assoc($q)) $return[] =3D $row;
echo serialize($return);
?>
Server 2:
<?php
$people =3D unserialize(file_get_contents('http://server1/people.php'));=
//includes would be tedious:
// ob_start();
// include('http://server1/people.php');
// $people =3D unserialize(ob_get_clean());
//
if(is_array($people) && !empty($people)){
mysql_connect();
mysql_select_db();
foreach($people as $person){
$bday =3D mysql_query('SELECT `birthday` FROM `birthdays` WHERE id =3D=
=
'.$person['id']);
$date =3D $bday ? mysql_result($bday,0,'birthday') : 'unknown';
echo "{$person['id']} {$person['name']} {$date}<br>";
}
}
?>
Which might be somewhat streamlined by fetching all the birthdays in one=
=
query to an array indexed by 'id', and linking to it in the foreach loop=
=
of $persons, it's still terribly inconvenient.
-- =
Rik Wasmus
Navigation:
[Reply to this message]
|