This MOD provides for 2-3 times faster sNews page generation when applied in comparison with default sNews setup for versions 1.5.31 and 1.6.
Some time ago I was a lil' bit frustrated ( as if there is such a thing as a lil' bit frustrated Codie :mad: ) due to fact that bullet proof performance optimization tricks stopped to work at all on sNews (like in no improvements to notice). After resorting to some investigation I stumbled upon a singular performance killer item - function get_id().
So, here is my version of get_id() with decent performance profile (as in doesn't matter any more in great scheme of all performance relevant things):
v.1.2 - 2008-01-22 - minor bugfix (0) Backup snews.php (or just say something like 'hells bells' if U are true macho)
(1) First add following functions to snews.php right after original get_id() function (or include from separate file):
// Real GET parameter handler
function getGetParm( $parmName ) {
$url = explode('/', $_GET['category']);
switch ($parmName) {
case 'category' :
if ( $url[0] ) {
// Fix to support sitemap.xml
//$parmValue = cleanGetSef( $url[0] );
$parmValue = ($url[0] == 'sitemap.xml') ? $url[0] : cleanGetSef( $url[0] );
}
break;
case 'article' :
if ( $url[1] ) {
$parmValue = cleanGetSef( $url[1] );
}
break;
case 'commentspage' :
if ( $url[2] ) {
$parmValue = cleanGetSef( $url[2] );
}
break;
// Fix to support article subpage mod
case 'subtitle' :
if ( $url[2] ) {
$parmValue = cleanGetSef( $url[2] );
}
break;
default :
$parmValue = false;
break;
}
if ( isset($parmValue) && !($parmValue === false) ) {
return $parmValue;
}
}
// While called cleanGetSef() this actually doesn't 'clean' anything - it either returns value as is or returns nothing or boolean false
function cleanGetSef( $inSef ) {
if ( $inSef == '' ) {
$sef = '';
}
elseif ( is_numeric($inSef) && ( $inSef == (int) $inSef ) ) {
$sef = (int) $inSef;
}
else {
// String presumed
// Fix to deal with voluntary wrong filenames requested
//if (! preg_match('/^[a-z0-9-_#]+$/', $inSef) ) {
if (! preg_match('/^[a-z0-9\-_#\.]+$/', $inSef) ) {
// $inSef is malformed - ignored completely
$sef = false;
}
else {
// $inSef is ok - only lower case ascii, '-', '_', '#' and '.' characters are included
$sef = $inSef;
}
}
return $sef;
}
(2) Then comment out old get_id() and add next to it this, new one:
function get_id( $parameter ) {
return getGetParm($parameter);
}
(3) And at last ... fasten seatbelts, Your sNews instance is lightweight again :lol:
History
v.1.2 - 2008-01-22 - minor update of cleanGetSef() function to fix numeric sef value checking
v.1.1 - 2007-06-28 - added mod compatibility fixes
Rights
Addon code (c) 2007 Valdis Ozols aka codetwist
Released under
Creative Commons Attribution.
Special thanxes to bramsyuur (for setting up public demo) and tarmithius13 (for looking into paginator issues)

P.S. for coders: Actually, function to use with caution is cleanXSS(); use it only when really needed.