[geeklog-devel] Article throttle.

Justin Carlson justin.carlson at gmail.com
Thu Dec 16 17:41:16 EST 2004

Some sites get nailed, by links from slashdot, or other similar sites.
An example would be GrokLaw.  

I've got what I think is an incredibly simple solution.
I've taken the current version of Geeklog, and added these lines: to
the conf file:

// Article
// This will allow you to setup a throttle based on guests and direct links to
// stories. For example, if you set the throttle to 300, and there are 300 guest
// users online, any story or article linked from another site will only display
// the text of the item, no layout or general site graphics. This very
// method of bandwidth protection could save your site in the event of a 
// sudden surge of activity.
$_CONF['throttle'] = '0';
// A value of '0' will shut the throttle off. (default)

Then in public_html/article.php, I've added the following code at or
near line 73 ( after the if (isset ($HTTP_POST_VARS['mode'])) { }

 // Throttle
 $rs = DB_query( "SELECT DISTINCT uid,remote_ip FROM
{$_TABLES['sessions']} WHERE uid = 1" );
 if($_CONF['throttle']>0 && DB_numRows($rs)>=$_CONF['throttle'] &&
!eregi($_CONF['site_url'],$_SERVER['HTTP_REFERER'])) $mode='print';

What this does is extremely simple. The owner of the website sets a
throttle, which is a number of guest users. Once this number is
reached, any article accessed from an external link or directly
accessed will display in print mode. This should greatly reduce the
number of database queries, as well as the number of GET requests to
the server. ( No site graphics, only story graphics ).

For GL2, I'd like to build more into the site, to allow any page to be
throttled, but for the current release I feel is pretty decent.

I have not contributed before. I am looking for thoughts and, I guess,
someone to place this into the test site for including in the next

More information about the geeklog-devel mailing list