Page 1 of 3
Problems Embdedding Serendipity Into HTML
Posted: Wed May 02, 2007 4:49 pm
by Lil
Hi All,
I've been trying to bring the content into a test page but keep failing at the first hurdle.
I've just reinstalled it all and this is my latest error:
Fatal error: main() [function.require]: Failed opening required 'index.php' (include_path='.;c:\php4\pear') in C:\Domains\peoplepassionplanet.com\wwwroot\wrapper.php on line 4
I can access the blog here:
http://www.peoplepassionplanet.com/blog/ and it seems to work fine, any ideas why I can't get it to embed would be greatly appreciated.
Posted: Wed May 02, 2007 4:50 pm
by Lil
Posted: Wed May 02, 2007 5:48 pm
by Lil
by the way, this is what I have in my wrapper.php page
<?php
ob_start();
chdir("/blog/");
require("index.php");
chdir("../");
$serendipity_contents = ob_get_contents();
ob_end_clean();
?>
and I have changed the index file in the admin configuration part to wrapper.php
Posted: Wed May 02, 2007 8:55 pm
by judebert
The problem would appear to be that the Serendipity index.php isn't in /blog/. I'd try it without the first / and see what happens.
You might also want to see if your chdir is actually working:
Code: Select all
<?php
if (chdir("blog/"))
{
ob_start();
require("index.php");
chdir("../");
$serendipity_contents = ob_get_contents();
ob_end_clean();
}
else
{
$serendipity_contents = "Couldn't change directory!\n";
}
?>
Posted: Thu May 03, 2007 10:38 am
by Lil
Thanks Judebert,
If I do this:
Code: Select all
<?php
if (chdir("blog/"))
{
ob_start();
require("index.php");
chdir("../");
$serendipity_contents = ob_get_contents();
ob_end_clean();
}
else
{
$serendipity_contents = "Couldn't change directory!\n";
}
?>
I get a page cannot be displayed.
And if I do this:
Code: Select all
<?php
if (chdir("/blog/"))
{
ob_start();
require("index.php");
chdir("../");
$serendipity_contents = ob_get_contents();
ob_end_clean();
}
else
{
$serendipity_contents = "Couldn't change directory!\n";
}
?>
It gives me
"Your non-Serendipity content goes here. Couldn't change directory! More non-Serendipity content here."
So you were right - it can't change directory, any idea why?
I tried changing permissions on the blog directory, but this didn't seem to work

Posted: Thu May 03, 2007 10:48 am
by Lil
I have found that if I put wrapper.php and test.php into the blog/ directory and then use
Code: Select all
<?php
ob_start();
chdir("/");
require("index.php");
chdir("/");
$serendipity_contents = ob_get_contents();
ob_end_clean();
?>
then test.php takes me to the serendipity_admin.php page! AAh so close yet so far!

Posted: Thu May 03, 2007 3:29 pm
by Lil
having tried just about every combination of how to change directories I can think of, if I put the full path to everything in so my wrapper.php looks like this:
Code: Select all
<?php
ob_start();
chdir("http://www.peoplepassionplanet.com/blog/");
require("index.php");
chdir("http://www.peoplepassionplanet.com/");
$serendipity_contents = ob_get_contents();
ob_end_clean();
?>
and my test.php looks like this:
Code: Select all
<?php
require("http://www.peoplepassionplanet.com/blog/wrapper.php"); // stores S9Y in a variable
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
Your non-Serendipity content goes here.
<?php
echo $serendipity_contents; // Print the variable
?>
More non-Serendipity content here.
</body>
</html>
It does then display the html - but not the serendipity contents.
back to more head scratching

Posted: Thu May 03, 2007 3:43 pm
by garvinhicking
Hi!
You cannot chdir() to a HTTP path location! You need to use proper relative or absolute paths. What you do now works via HTTP inclusion, which does not do what you want.
What judebert said was right, you need to check what the absolute path of your /blog directory is and use chdir with that one.
HTH,
Garvin
Posted: Thu May 03, 2007 4:01 pm
by Lil
ah ok
is there any way to know what this path is without just trying different combinations of guessed paths?
the index.php and wrapper .php are in
wwwroot/blog/
and my test.php page is in
wwwroot
so i've tried
chdir("/blog/");
and
chdir("../");
and
chdir("blog/");
and
chdir("/");
and
chdir("blog/");
and
chdir(".");
and combinations of those but as yet can't get it!!

Posted: Thu May 03, 2007 4:10 pm
by garvinhicking
Hi!
Try to put
<?php die(dirname(__FILE__)); ?>
into the index.php file or wrapper.php file to see theoutput of the full path where the script currently resides in!
HTH,
Garvin
Posted: Thu May 03, 2007 4:14 pm
by Lil
it returns this
C:\Domains\peoplepassionplanet.com\wwwroot\blog
so will try wwwroot in front...
Posted: Thu May 03, 2007 4:25 pm
by garvinhicking
Hi!
Actually you will need to use
Code: Select all
chdir('/Domains/peoplepassionplanet.com/wwwroot/blog');
HTH,
Garvin
Posted: Thu May 03, 2007 4:30 pm
by Lil
Thanks Garvin,
I get this again now...
Fatal error: main() [function.require]: Failed opening required 'Domains/peoplepassionplanet.com/wwwroot/blog/wrapper.php' (include_path='.;c:\php4\pear') in C:\Domains\peoplepassionplanet.com\wwwroot\test.php on line 2
I'm getting somewhere though I think

Posted: Thu May 03, 2007 4:33 pm
by garvinhicking
Hi!
You can only get this error message if you used
Code: Select all
chdir('Domains/peoplepassionplanet.com/wwwroot/blog');
instead of what I wrote:
Code: Select all
chdir('/Domains/peoplepassionplanet.com/wwwroot/blog');
...?
Posted: Thu May 03, 2007 4:40 pm
by Lil
Yes - you're right. So if I have this in wrapper.php
<?php
ob_start();
chdir("/Domains/peoplepassionplanet.com/wwwroot/blog/");
require("index.php");
chdir("/Domains/peoplepassionplanet.com/wwwroot/");
$serendipity_contents = ob_get_contents();
ob_end_clean();
?>
and this in the top of test.php
<?php
require("blog/wrapper.php");
?>
I get a page cannot be displayed. Can you correct what I'm doing wrong? (I have tried a few other combinations)