Advertisement:

Author Topic: 10 and Register  (Read 1800 times)

Offline edchapman

  • Jr. Member
  • **
  • Posts: 194
  • Gender: Male
    • Christian Youth Forum
10 and Register
« on: January 17, 2008, 12:43:03 PM »
I would like a feature that allowed guests to view a determined number of posts per visit or per day, and then require them to register to go any further.

Offline rsw686

  • Sophist Member
  • *****
  • Posts: 1,008
    • The Reptile File
Re: 10 and Register
« Reply #1 on: January 17, 2008, 01:15:07 PM »
Use a SESSION variable and increase it when a post is displayed. If past redirect them to the registration screen. Here's an example of what I use, same concept, but to limit searches to one per 60 seconds.

Code: [Select]
// Require guests to wait sixty seconds between searches.
if($user_info['is_guest'])
{
$time = time();
if(!isset($_SESSION['last_search']) || ($_SESSION['last_search'] + 60 < $time))
$_SESSION['last_search'] = $time;
else
{
$txt['guest_search_limit'] = preg_replace('/WAIT/', ($_SESSION['last_search'] + 60) - $time, $txt['guest_search_limit']);
fatal_lang_error('guest_search_limit', false);
}
}
The Reptile File
Everything reptile for anyone reptile friendly

Aquaria Talk
Community for freshwater and saltwater aquariums enthusiasts

Offline edchapman

  • Jr. Member
  • **
  • Posts: 194
  • Gender: Male
    • Christian Youth Forum
Re: 10 and Register
« Reply #2 on: January 21, 2008, 03:42:04 PM »
How would I apply that to viewing posts?

Offline karlbenson

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 15,629
  • Gender: Male
    • Criminal Brief UK
Re: 10 and Register
« Reply #3 on: January 21, 2008, 04:46:36 PM »
Do note though this will also limit Search Engine Spiders in the same way.

But do not attempt to give search engine robots unlimited access as that would be contrary to their Terms of Service.