With the help of a friend, I have a nice script which allows other people to use my page content. It automatically parses any page of mine between two markers, turns it into javascript, so the end user can just put a javascript insert code on his or her page, and pull down the content. Please use it on your own pages if you find it useful!
One thing I still need to do is get over the problem of relative links. Obviously when it parses a relative link, it stays relative on the end-users site - no use. So what is needed is the script to look at a link, and if it containts a href but no http://, it will need to add my specified base url to each link.
A further need is that offsite links on my site are made in this form:
Code: Select all
href="frameforlinks.php?id=http://www.offsitelink.org.uk/&referer=<? echo $_SERVERї"SCRIPT_URL"];?>Code: Select all
<? echo $_SERVERї"SCRIPT_URL"];?>If anyone can see the way to do these things - AND tell me just where to put the code into the existing code below - I'm not that bright - I'd be very grateful!
Code: Select all
<?php
function getPageContent( $url ){
return( implode( file( $url ), "" ) );
}
function parseContentByTagName( $content ){
preg_match_all( '/<div id="mycontentuniqueID">(ї\n\r\w\W.]*?)<\/div>/i', $content, $contentArray );
return( implode( $contentArrayї0], "" ) );
}
if( $pageID == "" )
print( "You have passed an invalid page, please include the paramater: pageID" );
else{
$pageContent = getPageContent( $pageID );
$pageContent = parseContentByTagName( $pageContent );
if( $pageContent == "" )
print( "document.write( "<ul><li><a href='http://www.gospelcom.net/guide/resources/$pageID'>Click here for Web Evangelism Guide page: $pageID</a></ul>" );");
$pageContent = str_replace( '"', '"', $pageContent );
$pageContent = str_replace( "\n", " ", $pageContent );
$pageContent = str_replace( "\r", " ", $pageContent );
$copyrightDate = date("Y"); $pageContent = $pageContent . "<p><span style=''color:black;font-size=80%;margin-left:3em;''>© $copyrightDate web-evangelism.com. Used by permission. <a href=''http://www.mysite.com/conditions.php''>Conditions for re-use</a></span><p><ul style=''margin-left:3em;''><li>Visit the <a href=''http://www.mysite.com''>This site</a> for more pages.</ul>";
print( "document.write( "" . $pageContent . "" );" );
}
?>Tony