PHP Include

Having trouble installing serendipity?
siringo
Regular
Posts: 92
Joined: Fri Jul 28, 2006 5:39 am
Location: Australia
Contact:

PHP Include

Post by siringo »

I am trying to include a PHP include statement in a sticky posting.

I have the include statement running OK on my web sites index.php (not my blogs) so I know that is all working.

I'm getting this error ...

Warning: show() [function.include]: Failed opening '' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php:/home/gallons/public_html/radio/blog/:/home/gallons/public_html/radio/blog/bundled-libs/') in /home/gallons/public_html/radio/blog/plugins/serendipity_event_externalphp/serendipity_event_externalphp.php on line 104

Once I get this working, how do I then include the output within my sticky posting?

many thanks.
Thanks,

Matt.
siringo
Regular
Posts: 92
Joined: Fri Jul 28, 2006 5:39 am
Location: Australia
Contact:

Post by siringo »

Forgot to mention I am using the PHP external application plug in.

You can see the error here - http://radio.10gallons.com/blog/index.p ... pname.html
Thanks,

Matt.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

The includePHP script operates in the class context, thus your PHP script needs to properly utilize global variables and function scopes.

Thus your PHP script seems to not be able to run within a class context because of the "show()" function/method.

More can only be said if you show us your included PHP script.

Regards,
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/
siringo
Regular
Posts: 92
Joined: Fri Jul 28, 2006 5:39 am
Location: Australia
Contact:

Post by siringo »

I think I kind of understand all that, thanks for replying.

Here's the script ...

<?php
//connect to shoutcast server
include('./config.php'); //you may edit this path to fit your server environment otherwise leave it alone
$scfp = fsockopen("$scip", $scport, &$errno, &$errstr, 30);
if(!$scfp) {
$scsuccs=1;
echo''.$scdef.' is Offline';
}
if($scsuccs!=1){

//for newer shoutcast servers
fputs ($scfp, "GET /admin.cgi?mode=viewxml HTTP/1.1\r\nHost: $scip:$scport\r\n .
User-Agent: SHOUTcast Song (author: dstjohn@mediacast1.com)(Mozilla Compatible)\r\n .
Authorization: Basic ".base64_encode ("admin:$scpass")."\r\n\r\n");
while(!feof($scfp)) {
$page .= fgets($scfp, 1000);
}

//define xml elements
$loop = array("STREAMSTATUS", "BITRATE");
$y=0;
while($loop[$y]!=''){
$pageed = ereg_replace(".*<$loop[$y]>", "", $page);
$scphp = strtolower($loop[$y]);
$$scphp = ereg_replace("</$loop[$y]>.*", "", $pageed);
if($loop[$y]==SERVERGENRE || $loop[$y]==SERVERTITLE || $loop[$y]==SONGTITLE)
$$scphp = urldecode($$scphp);

// uncomment the next line to see all variables
// echo'$'.$scphp.' = '.$$scphp.'<br>';
$y++;
}
//end intro xml elements

//get song info and history
$pageed = ereg_replace(".*<SONGHISTORY>", "", $page);
$pageed = ereg_replace("</SONGHISTORY>.*", "", $pageed);
$songatime = explode("<SONG>", $pageed);
$r=1;
while($songatime[$r]!=""){
$t=$r-1;
$playedat[$t] = ereg_replace(".*<PLAYEDAT>", "", $songatime[$r]);
$playedat[$t] = ereg_replace("</PLAYEDAT>.*", "", $playedat[$t]);
$song[$t] = ereg_replace(".*<TITLE>", "", $songatime[$r]);
$song[$t] = ereg_replace("</TITLE>.*", "", $song[$t]);
$song[$t] = urldecode($song[$t]);


//format the date
$frmt_date[$t] = date('l dS of F Y h:i:s A',$playedat[$t]);

//you may edit the html below, make sure to keep variables intact
echo'
<b>* </b>'.$song[$t].'<BR>
';


$r++;
}

fclose($scfp);
}
?>

It would be great if I can get this to run as it is pretty much an important piece of information that site visitors will be wanting to see. My site is for my online radio station and this script displays the last 10 songs played.

Many thanks in advance.
Last edited by siringo on Tue Nov 21, 2006 12:41 pm, edited 1 time in total.
Thanks,

Matt.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Hm, the problem doesn'T seem to be the PHP file - it'S rather that the s9y externalphp plugin cannot find the file you want to include!

Are you sure you entered the right absolute path to the PHP file? Also edit the PHP code you use to use a full path on the "include('config.php');" line, like "include('/httpd/serendipity/config.php');"

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/
siringo
Regular
Posts: 92
Joined: Fri Jul 28, 2006 5:39 am
Location: Australia
Contact:

Post by siringo »

Thanks for your help Garvin. In your reply you mentioned to change the line in my php file from this - "include('config.php');" to this - "include('/httpd/serendipity/config.php');"

I've actually got the blog running in a subdomain of my main domain called 'radio'. So I've altered the line to read "include('/httpd/radio/blog/config.php');"

Is that the correct path?

Many thanks.
Thanks,

Matt.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Yes, you must just put the propper path in there - mine was just an example because I don't know your paths :)

Best regards,
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/
siringo
Regular
Posts: 92
Joined: Fri Jul 28, 2006 5:39 am
Location: Australia
Contact:

Post by siringo »

I'm really chasing my tail here. These are the errors I'm getting ...

Warning: show() [function.include]: Failed opening '' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php:/home/gallons/public_html/radio/blog/:/home/gallons/public_html/radio/blog/bundled-libs/') in /home/gallons/public_html/radio/blog/plugins/serendipity_event_externalphp/serendipity_event_externalphp.php on line 104

The php script that grabs the song details is called sc_song.php. It reads a config file called config.php for log in info etc, so sc_song.php can get all the details it needs. I have both of these files in the same folder which is public_html/radio (the subdomain I mentioned previously)/songlist

Serendipity is installed into a folder called /blog at public_html/radio/blog

In the External PHP Application plugin, I have placed - /home/mydomain/public_html/radio/songlist/sc_song.php - in the 'File to include' field.

Does this look correct?

Thanks in advance.
Thanks,

Matt.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Hm, the plugin is not able to get the file you are trying to include. Are you sure you saved the plugin config where you entered

/home/mydomain/public_html/radio/songlist/sc_song.php

?

Maybe on your server the 'realpath' function is disalbed? Can you try to edit the serendipity_event_externalphp.php file and replace this at around line 104:

Code: Select all

            $include_file = realpath($this->get_config('include'));
            ob_start();
            include $include_file;
            $content = ob_get_contents();
            ob_end_clean();
with this:

Code: Select all

            $include_file = realpath($this->get_config('include'));
echo "Will include file '" . $this->get_config('include') . "' / '$include_file' <br />\n";
            include $include_file;
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/
siringo
Regular
Posts: 92
Joined: Fri Jul 28, 2006 5:39 am
Location: Australia
Contact:

Post by siringo »

Thanks for your help Garvin, I really appreciate it. I'm operating outside my area of expertise here, so excuse me if I ask some dumb questions.

I got it working!!! :D :D But I still have this text displayed above the text generated by the php scripts ...

Will include file '/home/gallons/public_html/sc_song.php' / '/home/gallons/public_html/sc_song.php'

Can I get rid of that? I really need to.

:D :D :D
Thanks,

Matt.
siringo
Regular
Posts: 92
Joined: Fri Jul 28, 2006 5:39 am
Location: Australia
Contact:

Post by siringo »

And now, how can I place the desired text into a sticky posting on my blogs' index.php page?

:D :D
Thanks,

Matt.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

So what did you change so that it works now?!

You can create a sticky blog posting by installing the "Extended properties for entries" plugin and then you have a checkbox "Sticky entry" for each entry you create!

Best regards,
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/
siringo
Regular
Posts: 92
Joined: Fri Jul 28, 2006 5:39 am
Location: Australia
Contact:

Post by siringo »

I didn't provide the correct path in the config.php file that accompanies the sc_song.php file. Once I did that it all came together.

It still displays this though above the text I want to see ...

Will include file '/home/gallons/public_html/radio/songlist/sc_song.php' / '/home/gallons/public_html/radio/songlist/sc_song.php'

You can see it here - http://radio.10gallons.com/blog/index.p ... pname.html. How can I get rid of that? It looks like it is echo'd or something???

It's the text on the page I listed above generated by the sc_song.php script that I want to place into my 'sticky posting' on my blogs index.php page here ...
http://radio.10gallons.com/blog/

I want the song list to display under the 'STICKY POSTING' title. I just can't work out how to combine the two halves together.

Any ideas?

Thanks again. :D
Thanks,

Matt.
siringo
Regular
Posts: 92
Joined: Fri Jul 28, 2006 5:39 am
Location: Australia
Contact:

Post by siringo »

Here's a copy of the php script in case that text I need to remove is being generated by it.

Here's the sc_song.php script ...

<?php
//connect to shoutcast server
include('/home/gallons/public_html/radio/songlist/config.php'); //you may edit this path to fit your server environment otherwise leave it alone
$scfp = fsockopen("$scip", $scport, &$errno, &$errstr, 30);
if(!$scfp) {
$scsuccs=1;
echo''.$scdef.' is Offline';
}
if($scsuccs!=1){

//for newer shoutcast servers
fputs ($scfp, "GET /admin.cgi?mode=viewxml HTTP/1.1\r\nHost: $scip:$scport\r\n .
User-Agent: SHOUTcast Song (author: dstjohn@mediacast1.com)(Mozilla Compatible)\r\n .
Authorization: Basic ".base64_encode ("admin:$scpass")."\r\n\r\n");
while(!feof($scfp)) {
$page .= fgets($scfp, 1000);
}

//define xml elements
$loop = array("STREAMSTATUS", "BITRATE");
$y=0;
while($loop[$y]!=''){
$pageed = ereg_replace(".*<$loop[$y]>", "", $page);
$scphp = strtolower($loop[$y]);
$$scphp = ereg_replace("</$loop[$y]>.*", "", $pageed);
if($loop[$y]==SERVERGENRE || $loop[$y]==SERVERTITLE || $loop[$y]==SONGTITLE)
$$scphp = urldecode($$scphp);

// uncomment the next line to see all variables
// echo'$'.$scphp.' = '.$$scphp.'<br>';
$y++;
}
//end intro xml elements

//get song info and history
$pageed = ereg_replace(".*<SONGHISTORY>", "", $page);
$pageed = ereg_replace("</SONGHISTORY>.*", "", $pageed);
$songatime = explode("<SONG>", $pageed);
$r=1;
while($songatime[$r]!=""){
$t=$r-1;
$playedat[$t] = ereg_replace(".*<PLAYEDAT>", "", $songatime[$r]);
$playedat[$t] = ereg_replace("</PLAYEDAT>.*", "", $playedat[$t]);
$song[$t] = ereg_replace(".*<TITLE>", "", $songatime[$r]);
$song[$t] = ereg_replace("</TITLE>.*", "", $song[$t]);
$song[$t] = urldecode($song[$t]);


//format the date
$frmt_date[$t] = date('l dS of F Y h:i:s A',$playedat[$t]);

//you may edit the html below, make sure to keep variables intact
echo'
<b>* </b>'.$song[$t].'<BR>
';


$r++;
}

fclose($scfp);
}
?>


Many thanks again, I do appreciate all your help.
Thanks,

Matt.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Just undo the change you did to your externalphp file, the echo snippet is the one I told you to insert, so just put it back to how it was. :)

Regards,
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/
Post Reply