Problems Embdedding Serendipity Into HTML

Having trouble installing serendipity?
Lil
Regular
Posts: 19
Joined: Wed May 02, 2007 4:43 pm

Problems Embdedding Serendipity Into HTML

Post 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.
Lil
Regular
Posts: 19
Joined: Wed May 02, 2007 4:43 pm

Post by Lil »

Lil
Regular
Posts: 19
Joined: Wed May 02, 2007 4:43 pm

Post 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
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post 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";
}
?> 
Judebert
---
Website | Wishlist | PayPal
Lil
Regular
Posts: 19
Joined: Wed May 02, 2007 4:43 pm

Post 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 :(
Lil
Regular
Posts: 19
Joined: Wed May 02, 2007 4:43 pm

Post 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! ;)
Lil
Regular
Posts: 19
Joined: Wed May 02, 2007 4:43 pm

Post 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 :)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Lil
Regular
Posts: 19
Joined: Wed May 02, 2007 4:43 pm

Post by Lil »

ah ok :D

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!! :lol:
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Lil
Regular
Posts: 19
Joined: Wed May 02, 2007 4:43 pm

Post by Lil »

it returns this

C:\Domains\peoplepassionplanet.com\wwwroot\blog

so will try wwwroot in front...
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Actually you will need to use

Code: Select all

chdir('/Domains/peoplepassionplanet.com/wwwroot/blog');
HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Lil
Regular
Posts: 19
Joined: Wed May 02, 2007 4:43 pm

Post 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 :D
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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'); 
...?
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Lil
Regular
Posts: 19
Joined: Wed May 02, 2007 4:43 pm

Post 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)
Post Reply