Просмотр поста

.
ДоХтор

Если кто-то будет делать, то можете заюзать эту функцию. Ток подредачить её немного надо под конкретные нужды

Скрипт считающий переходы юзеров (+/-)
function cnt() {
    global $rights;
    $cnt = 'count.txt';
    if (!session_id()) session_start();
    if (!file_exists($cnt)) file_put_contents($cnt, 0);
    if (isset($_GET['cnt']) && $_GET['cnt'] == 'del') {
        if ($rights == 9) {
            unset($_SESSION['counter']);
            unlink($cnt);
            header('Location: '. $_SERVER['PHP_SELF']);
        } else {
            return '<h4 class="rmenu">Ошибка! Доступ только для SV!</h4>';
        }
    }
    
    if (!isset($_SESSION['counter'])) {
        $_SESSION['counter'] = 1;
        file_put_contents($cnt, ((int)file_get_contents($cnt) + 1));
    }
 
    if ($rights == 9) {
        return 'Просмотров: (<b>'. file_get_contents($cnt) .'</b>)'.
               ' | <a href="'. $_SERVER['PHP_SELF'] .'?cnt=del">Сброс</a><br />';
    } else {
        return 'Просмотров: (<b>'. file_get_contents($cnt) .'</b>)';
    }
}

echo cnt();