Sayfa görüntüleme sınırı

Başlatan avlak, 03 Ağu 2017 08:21

« önceki - sonraki »

0 Üye ve 1 Ziyaretçi konuyu incelemekte.

avlak

Merhaba smf 2.1 de ziyaretçilerin görüntüleyebileceği sayfaya limit koyabilmenin bir yöntemi var mı?
Modsuz yada şu mod gibi ;
https://www.simplemachines.org/community/index.php?topic=506839.0

snrj

gösterdiğiniz modun manuel kurulumu alttaki gibi
yedek alıp bir deneyin
ben fırsat bulursam deneyip smf 2.1 için paylaşırım inş veya siz deneyip olursa paylaşırsınız :D

index.php
bul:
Kod [Seç]
  // Load the current user's permissions.
loadPermissions();

Sonrasına ekle:

Kod [Seç]
// Start of Limit A Guests Daily PageViews Mod

// Extra globals we need access to (if not already got access)
global $txt, $context, $func;

// Sanitize - cast as integer / prevent undefined index - especially after initial install of mod
$modSettings['limited_views'] = !empty($modSettings['limited_views']) ? (int) $modSettings['limited_views'] : 0 ;

// Only if guest access is enabled, and a limit is set, AND the user is a guest
if(!empty($modSettings['allow_guestAccess']) && !empty($modSettings['limited_views']) && $context['user']['is_guest'])
{
   if(!isset($_SESSION['limited_views']))
      // Setup the array
      $_SESSION['limited_views'] = array(
         'views' => 1,
         'last_view' => time()
      );
   // Have viewed pages before
   else
   {
      // Sanitize - cast as integers
      $_SESSION['limited_views']['views'] = ((int) $_SESSION['limited_views']['views'])   1;
      $_SESSION['limited_views']['last_view'] = (int) $_SESSION['limited_views']['last_view'];
 
      // Last view yesterday (done on forum time)
      $date  = date('dm',forum_time(null, $_SESSION['limited_views']['last_view']));
 
      // Update the session info. If new day set views to 1, else increase by 1.
      // Don't increase if already exceeds the limit (prevents views from getting out of control eg bots/spiders)
      $_SESSION['limited_views']['views'] = ($date != date('dm')) ? 1 : ($_SESSION['limited_views']['views'] > $modSettings['limited_views'] ? $modSettings['limited_views']   1 : $_SESSION['limited_views']['views']);
      //  Set the latest view to now, unless we've reached the limit - we will keep this timestamp until tomorrow.
      $_SESSION['limited_views']['last_view'] = $_SESSION['limited_views']['views'] > $modSettings['limited_views'] ? $_SESSION['limited_views']['last_view'] : time();
      // Tidy up
      unset($date);
   
      // Don't be stupid - If they've reached the limit, we must allow them the guest actions of register/login
      // Also, note you can add other actions (must be on the action array) here to exempt
      $temp = array('login', 'login2', 'register', 'register2', 'reminder', 'activate', 'smstats', 'help', '.xml', 'verificationcode');
      if (empty($_REQUEST['action']) || !in_array(strtolower($_REQUEST['action']), $temp))
      {
   
         // Fatal error, must register as exceeded no. of page views
         if($_SESSION['limited_views']['views'] > $modSettings['limited_views'])
         {
            // Mr Search Engine, don't index this page (its just an error message)
            $context['robot_no_index'] = true;
         
            // Switcharoo on smf language string to set the page title for header and <title> for browser
            // Make html safe so doesn't break the forum.
            $context['page_title'] = $txt['106'] = strtr($func['htmlspecialchars']($txt['limited_views_title']), array("r" => '', "n" => '', "t" => ''));
         
            fatal_lang_error('limited_views_message', false, array($modSettings['limited_views']));
         }
      }
      // Tidy up
      unset($temp);
   }
 
   // Prepare and make html safe the remaining string
   if(!empty($modSettings['limited_views']) && !empty($_SESSION['limited_views']['views']))
   {
      $context['limited_views_remaining'] = strtr(' - '.
         $func['htmlspecialchars'](
            ($_SESSION['limited_views']['views'] > $modSettings['limited_views'] ? 0 :
               ($modSettings['limited_views'] - $_SESSION['limited_views']['views'])
            ).
            $txt['limited_views_remaining_'.
               ($modSettings['limited_views'] - $_SESSION['limited_views']['views'] == 1 ? 'singular' : 'plural')
            ]
         ),
         array(
            "r" => '',
            "n" => '',
            "t" => ''
         )
      );
      if($modSettings['limited_views'] - $_SESSION['limited_views']['views'] >= 0)
      {
         // Avoid undefined error
         $context['html_headers'] = !empty($context['html_headers']) ? '' : $context['html_headers'];
       
         // Now build javascript message (javascript to try to keep the information title out of the search engine)
         // Keep on new line (as there maybe extra headers above/below)
         // Tabbed out of sync to keep inline with html output
         $context['html_headers'] .= '
   <script language="JavaScript" type="text/javascript"><!-- // -->'.
   chr(60) . chr(33) . chr(91) . chr(67) . chr(68) . chr(65) . chr(84) . chr(65) . chr(91).'
      document.title = document.title   ''.$context['limited_views_remaining'].'';
   // '.chr(93) . chr(93) . chr(62).'</script>
   ';
      }
   }
}
// Either a user and/or guest access is disabled or no limit is set, in which case
else
{
   // If a session variable for this exists, its no longer needed.
   if(isset($_SESSION['limited_views']))
      unset($_SESSION['limited_views']);
}

// End of Limit A Guests Daily PageViews Mod

./Sources/ModSettings.php
Bul:
Kod [Seç]
        array('check', 'allow_guestAccess'),
Sonrasına ekle:
Kod [Seç]
        array('int', 'limited_views'),
./Themes/default/languages/Help.english.php
Bul:
Kod [Seç]
?>
Öncesine ekle:

Kod [Seç]
$helptxt['limited_views'] = 'Limit the no. of page views that guests can view. Warning, spiders/bots WILL be limited by this. <br /><br />(As excluding them would be seen as Black Hat and likely to violate Google & other search engines Terms of Service).';
Bul:
./Themes/default/languages/Help.english-uft8.php
Öncesine ekle:

Kod [Seç]
$helptxt['limited_views'] = 'Limit the no. of page views that guests can view. Warning, spiders/bots WILL be limited by this. <br /><br />(As excluding them would be seen as Black Hat and likely to violate Google & other search engines Terms of Service).';
./Themes/default/languages/Modifications.english.php
Bul:
Kod [Seç]
?>
Öncesine ekle:

Kod [Seç]
$txt['limited_views_remaining_singular'] = ' page view remaining today';
$txt['limited_views_remaining_plural'] = ' page views remaining today';
$txt['limited_views'] = 'Limit guests to x page views per day<div class="smalltext">0 to disable</div>';
$txt['limited_views_message'] = 'All guests are limited to %s page views per day.<br /> We now invite you to <a href="' . $scripturl . '?action=login">login</a> or <a href="' . $scripturl . '?action=register">register</a> to continue accessing the forum.';
$txt['limited_views_title'] = 'Please Login or Register';

./Themes/default/languages/Modifications.english-uft8.php
Bul:
Kod [Seç]
?>
Öncesine ekle:

Kod [Seç]
$txt['limited_views_remaining_singular'] = ' page view remaining today';
$txt['limited_views_remaining_plural'] = ' page views remaining today';
$txt['limited_views'] = 'Limit guests to x page views per day<div class="smalltext">0 to disable</div>';
$txt['limited_views_message'] = 'All guests are limited to %s page views per day.<br /> We now invite you to <a href="' . $scripturl . '?action=login">login</a> or <a href="' . $scripturl . '?action=register">register</a> to continue accessing the forum.';
$txt['limited_views_title'] = 'Please Login or Register';

./Themes/default/languages/Modifications.turkish.php
Bul:

Kod [Seç]
?>
Öncesine ekle:

Kod [Seç]
$txt['limited_views_remaining_singular'] = ' bugun kalan sayfa gosterimi';
$txt['limited_views_remaining_plural'] = ' bugun kalan sayfa gosterimleri';
$txt['limited_views'] = 'Gun basina ziyaretcilere x sayfa gosterimleri limiti<div class="smalltext">0 to disable</div>';
$txt['limited_views_message'] = 'Butun ziyaretciler gun basina %s sayfa gosterimiyle limitlendi.<br /> Simdi Seni Davet Ediyoruz <a href="' . $scripturl . '?action=login">giris</a> or <a href="' . $scripturl . '?action=register">kayit</a> forumdan faydalanmak icin devam et.';
$txt['limited_views_title'] = 'Lutfen Giris Yapin ya da Uye Degilseniz Kayit Olun';

./Themes/default/languages/Modifications.turkish-uft8.php

Kod [Seç]
$txt['limited_views_remaining_singular'] = ' bugun kalan sayfa gosterimi';
$txt['limited_views_remaining_plural'] = ' bugun kalan sayfa gosterimleri';
$txt['limited_views'] = 'Gun basina ziyaretcilere x sayfa gosterimleri limiti<div class="smalltext">0 to disable</div>';
$txt['limited_views_message'] = 'Butun ziyaretciler gun basina %s sayfa gosterimiyle limitlendi.<br /> Simdi Seni Davet Ediyoruz <a href="' . $scripturl . '?action=login">giris</a> or <a href="' . $scripturl . '?action=register">kayit</a> forumdan faydalanmak icin devam et.';
$txt['limited_views_title'] = 'Lutfen Giris Yapin ya da Uye Degilseniz Kayit Olun';

avlak

Eyvallah hocam Allah razı olsun Spider Board & Topic Access i kurdum bakalım işe yarayacak mı  :)  Localde sizin verdiğinizde deneyeceğim.