[geeklog-cvs] geeklog-1.3/public_html lib-common.php,1.207,1.208
dhaun at geeklog.net
dhaun at geeklog.net
Fri Mar 21 08:55:41 EST 2003
Update of /usr/cvs/geeklog/geeklog-1.3/public_html
In directory internal.geeklog.net:/tmp/cvs-serv25190/public_html
Modified Files:
lib-common.php
Log Message:
Integrated Vincent Furia's improvements to COM_exportRDF() and COM_rdfUpToDateCheck(). Also added an option to include the story's introtext to the RDF feed and fixed a bug with unescaped special characters in the feed's title.
Index: lib-common.php
===================================================================
RCS file: /usr/cvs/geeklog/geeklog-1.3/public_html/lib-common.php,v
retrieving revision 1.207
retrieving revision 1.208
diff -C2 -d -r1.207 -r1.208
*** lib-common.php 16 Mar 2003 10:25:28 -0000 1.207
--- lib-common.php 21 Mar 2003 13:55:39 -0000 1.208
***************
*** 1274,1278 ****
*
* The core of this code has been lifted from phpweblog which is licenced
! * under the GPL.
*
* @see function COM_rdfUpToDateCheck
--- 1274,1278 ----
*
* The core of this code has been lifted from phpweblog which is licenced
! * under the GPL. It has since been heavily modified.
*
* @see function COM_rdfUpToDateCheck
***************
*** 1282,1296 ****
function COM_exportRDF()
{
! global $_TABLES, $_CONF, $_COM_VERBOSE, $LANG01;
! if ($_CONF['backend']>0)
{
$outputfile = $_CONF['rdf_file'];
$rdencoding = 'UTF-8';
! $rdtitle = $_CONF['site_name'];
$rdlink = $_CONF['site_url'];
! $rddescr = $_CONF['site_slogan'];
$rdlang = $_CONF['locale'];
! $result = DB_query( "SELECT * FROM {$_TABLES['stories']} WHERE draft_flag = 0 AND date <= NOW() ORDER BY date DESC limit 20" );
if( !$file = @fopen( $outputfile, w ))
--- 1282,1335 ----
function COM_exportRDF()
{
! global $_TABLES, $_CONF, $LANG01;
! if( $_CONF['backend'] > 0 )
{
$outputfile = $_CONF['rdf_file'];
$rdencoding = 'UTF-8';
! $rdtitle = htmlspecialchars( $_CONF['site_name'] );
$rdlink = $_CONF['site_url'];
! $rddescr = htmlspecialchars( $_CONF['site_slogan'] );
$rdlang = $_CONF['locale'];
!
! $where = '';
! if( !empty( $_CONF['rdf_limit'] ))
! {
! if( substr( $_CONF['rdf_limit'], -1 ) == 'h' ) // last xx hours
! {
! $limit = '';
! $hours = substr( $_CONF['rdf_limit'], 0, -1 );
! $where = " AND date >= DATE_SUB(NOW(),INTERVAL $hours HOUR)";
! }
! else
! {
! $limit = ' LIMIT ' . $_CONF['rdf_limit'];
! }
! }
! else
! {
! $limit = ' LIMIT 10';
! }
!
! // get list of topics that anonymous users have access to
! $tresult = DB_query( "SELECT tid FROM {$_TABLES['topics']}"
! . COM_getPermSQL( 'WHERE', 1 ));
! $tnumrows = DB_numRows( $tresult );
! $tlist = '';
! for( $i = 1; $i <= $tnumrows; $i++ )
! {
! $T = DB_fetchArray( $tresult );
! $tlist .= "'" . $T['tid'] . "'";
! if( $i < $tnumrows )
! {
! $tlist .= ',';
! }
! }
! if( !empty( $tlist ))
! {
! $where .= " AND (tid IN ($tlist))";
! }
!
! $result = DB_query( "SELECT sid,title,introtext FROM {$_TABLES['stories']} WHERE draft_flag = 0 AND date <= NOW() $where AND perm_anon > 0 ORDER BY date DESC $limit" );
if( !$file = @fopen( $outputfile, w ))
***************
*** 1311,1348 ****
$sids = '';
$nrows = DB_numRows( $result );
- $actualcount = 0;
! for( $i = 1; $i <= $nrows AND $actualcount < 10; $i++ )
{
$row = DB_fetchArray( $result );
! $topic_anon = DB_getItem( $_TABLES['topics'], 'perm_anon', "tid='{$row['tid']}'" );
! // Only add to RDF feed if anonymous has access to it
! if( $row['perm_anon'] == 2 AND $topic_anon == 2 )
{
! $sids .= $row['sid'];
! if( $i <> $nrows )
{
! $sids .= ',';
}
! $title = 'title';
! $link = 'sid';
! $author = 'author';
!
! fputs ( $file, "<item>\n" );
! $title = '<title>' . htmlspecialchars( stripslashes( $row[$title] )) . "</title>\n";
! $author = '<author>' . htmlspecialchars( stripslashes( $row[$author] )) . "</author>\n";
! $link = "<link>{$_CONF['site_url']}/article.php?story={$row[$link]}</link>\n";
! fputs( $file, $title );
! fputs( $file, $link );
! fputs( $file, "</item>\n\n" );
! $actualcount++;
}
}
--- 1350,1406 ----
$sids = '';
$nrows = DB_numRows( $result );
! for( $i = 1; $i <= $nrows; $i++ )
{
$row = DB_fetchArray( $result );
! $sids .= $row['sid'];
! if( $i <> $nrows )
! {
! $sids .= ',';
! }
! $title = 'title';
! $link = 'sid';
!
! if( $_CONF['rdf_storytext'] > 0 )
{
! $desc = '<description>';
! $storytext = stripslashes( strip_tags( $row['introtext'] ));
! $storytext = trim( $storytext );
! $storytext = preg_replace( "/(\015)/", "", $storytext);
!
! if( $_CONF['rdf_storytext'] > 1 )
{
! if( strlen( $storytext ) > $_CONF['rdf_storytext'] )
! {
! $storytext = substr( $storytext, 0,
! $_CONF['rdf_storytext'] ) . '...';
! }
}
! $desc .= $storytext . "</description>\n";
! }
! else
! {
! $desc = '';
! }
! fputs ( $file, "<item>\n" );
! $title = '<title>'
! . htmlspecialchars( stripslashes( $row[$title] ))
! . "</title>\n";
! $link = '<link>' . $_CONF['site_url'] . '/article.php?story='
! . $row[$link] . "</link>\n";
! fputs( $file, $title );
! fputs( $file, $link );
! if( !empty( $desc ))
! {
! fputs( $file, $desc );
}
+ fputs( $file, "</item>\n\n" );
}
***************
*** 1358,1362 ****
/**
*
! * Checks to see if RDF file needs updating and updates it if sol
* Checks to see if we need to update the RDF as a result
* of an article with a future publish date reaching it's
--- 1416,1420 ----
/**
*
! * Checks to see if RDF file needs updating and updates it if so.
* Checks to see if we need to update the RDF as a result
* of an article with a future publish date reaching it's
***************
*** 1369,1394 ****
function COM_rdfUpToDateCheck()
{
! global $_TABLES;
!
! $result = DB_query( "SELECT sid FROM {$_TABLES['stories']} WHERE draft_flag = 0 AND date <= NOW() ORDER BY date DESC limit 10" );
! $nrows = DB_numRows( $result );
! $sids = '';
! for( $i = 1; $i <= $nrows; $i++ )
{
! $A = DB_fetchArray( $result );
! $sids .= $A['sid'];
! if( $i <> $nrows )
{
! $sids .= ',';
}
- }
! $last_rdf_sids = DB_getItem( $_TABLES['vars'], 'value', "name = 'rdf_sids'" );
! if( $sids <> $last_rdf_sids )
! {
! COM_exportRDF();
}
}
--- 1427,1494 ----
function COM_rdfUpToDateCheck()
{
! global $_TABLES, $_CONF;
! if( $_CONF['backend'] > 0 )
{
! $where = '';
! if( !empty( $_CONF['rdf_limit'] ))
! {
! if( substr( $_CONF['rdf_limit'], -1 ) == 'h' ) // last xx hours
! {
! $limit = '';
! $hours = substr( $_CONF['rdf_limit'], 0, -1 );
! $where = " AND date >= DATE_SUB(NOW(),INTERVAL $hours HOUR)";
! }
! else
! {
! $limit = ' LIMIT ' . $_CONF['rdf_limit'];
! }
! }
! else
! {
! $limit = ' LIMIT 10';
! }
! // get list of topics that anonymous users have access to
! $tresult = DB_query( "SELECT tid FROM {$_TABLES['topics']}"
! . COM_getPermSQL( 'WHERE', 1 ));
! $tnumrows = DB_numRows( $tresult );
! $tlist = '';
! for( $i = 1; $i <= $tnumrows; $i++ )
{
! $T = DB_fetchArray( $tresult );
! $tlist .= "'" . $T['tid'] . "'";
! if( $i < $tnumrows )
! {
! $tlist .= ',';
! }
! }
! if( !empty( $tlist ))
! {
! $where .= " AND (tid IN ($tlist))";
}
! $result = DB_query( "SELECT sid FROM {$_TABLES['stories']} WHERE draft_flag = 0 AND date <= NOW() $where AND perm_anon > 0 ORDER BY date DESC $limit" );
! $nrows = DB_numRows( $result );
! $sids = '';
! for( $i = 1; $i <= $nrows; $i++ )
! {
! $A = DB_fetchArray( $result );
! $sids .= $A['sid'];
!
! if( $i <> $nrows )
! {
! $sids .= ',';
! }
! }
!
! $last_rdf_sids = DB_getItem( $_TABLES['vars'], 'value',
! "name = 'rdf_sids'" );
!
! if( $sids <> $last_rdf_sids )
! {
! COM_exportRDF ();
! }
}
}
***************
*** 1397,1403 ****
* Checks and Updates the featured status of all articles.
*
! * Checks to see if any articles that were published for the future have been published and, if
! * so, will see if they are featured. If they are featured, this will set old featured article (if
! * if there is one) to normal
*
*/
--- 1497,1503 ----
* Checks and Updates the featured status of all articles.
*
! * Checks to see if any articles that were published for the future have been
! * published and, if so, will see if they are featured. If they are featured,
! * this will set old featured article (if there is one) to normal
*
*/
More information about the geeklog-cvs
mailing list