Re: Visit Counter

You use the tag in the template but only in full story ?


but only in full story ? no.
I use and short news.  Or may be only one? full or short?

Re: Visit Counter

full story.

Re: Visit Counter

Hi,

Visit counter plug-in with MySQL works like a charm.

I've said to the support that It would be greatful to have a plug-in that will classify news by visits. I think users would like this fonction.

Regards.

Nodody is interested ?

Re: Visit Counter

hey,

Please donot alter the web counter code of Free internet Counter and paste as html counter as it is to avoid difficulties. This counter can also be used as a PHP counter and ASP counter. Grow Business. Many of fancy counters of different colors are given below to choose from so you have a choice and you put beautiful web counters of your taste on your website.

bobblemaker https://cutephp.com/forum/style_emoticons/default/rolleyes.gif

Re: Visit Counter

Very interesting and useful tips I think.I read step by step this informations and help me so much.Thank you for this great informations

Re: Visit Counter

Hello Support,

Actually, I use :

<?php

/*
  CREATE TABLE `cn_visit_counter` (
  `id` int(11) NOT NULL,
  `ip` varchar(16) NOT NULL,
  `accesstime` int(11) NOT NULL,
  KEY `id` (`id`)
  ) ENGINE=MyISAM DEFAULT CHARSET=utf8
*/

$MYSQL_HOST = '###';
$MYSQL_USER = '###';
$MYSQL_PASS = '###';
$MYSQL_DB = '###';

$cn_connection = mysql_connect($MYSQL_HOST, $MYSQL_USER, $MYSQL_PASS);
mysql_select_db($MYSQL_DB, $cn_connection);
unset($MYSQL_HOST, $MYSQL_USER, $MYSQL_PASS, $MYSQL_DB);

if (!defined('CN_CONNECT'))
    define("CN_CONNECT", $cn_connection);

add_hook('core/entry_make_start', '*visit_counter');

function visit_counter($template, $data, $template_name)
{
    global $_plugin_visit_access;

    $ID = intval($data['id']);
    $online_time = intval(getoption('client_online'));

    if ($online_time == 0 || !empty($_plugin_visit_access))
        return array($template);

    // Part 1: Add
    if ($data['id'] && $template_name == 'full')
    {
        $_ip = mysql_real_escape_string($_SERVER['REMOTE_ADDR'], CN_CONNECT);

        mysql_query("INSERT INTO cn_visit_counter (`id`, `ip`, `accesstime`) VALUES ($ID, '$_ip', UNIX_TIMESTAMP(NOW()))", CN_CONNECT);
        mysql_query("DELETE FROM cn_visit_counter WHERE accesstime < ".(time() - $online_time), CN_CONNECT);
    }

    // Part 2: Calc
    $views = mysql_fetch_assoc( mysql_query("SELECT COUNT(*) as `count` FROM cn_visit_counter WHERE id = $ID", CN_CONNECT) );
    $template = str_replace("{page-views}", $views['count'], $template);

    $_plugin_visit_access = TRUE;
    return array($template);
}

This plugin work fine.

I test it on my private SQL (with port) and the connection is not good. I don't understand why. I've tested too with this code but don't work :

<?php

/*
  CREATE TABLE `cn_visit_counter` (
  `id` int(11) NOT NULL,
  `ip` varchar(16) NOT NULL,
  `accesstime` int(11) NOT NULL,
  KEY `id` (`id`)
  ) ENGINE=MyISAM DEFAULT CHARSET=utf8
*/

$MYSQL_HOST = '###';
$MYSQL_USER = '###';
$MYSQL_PASS = '###';
$MYSQL_DB = '###';
$MYSQL_PORT = '###';

$cn_connection = mysql_connect($MYSQL_HOST, $MYSQL_USER, $MYSQL_PASS, $MYSQL_PORT);
mysql_select_db($MYSQL_DB, $cn_connection);
unset($MYSQL_HOST, $MYSQL_USER, $MYSQL_PASS, $MYSQL_DB, $MYSQL_PORT);

if (!defined('CN_CONNECT'))
    define("CN_CONNECT", $cn_connection);

add_hook('core/entry_make_start', '*visit_counter');

function visit_counter($template, $data, $template_name)
{
    global $_plugin_visit_access;

    $ID = intval($data['id']);
    $online_time = intval(getoption('client_online'));

    if ($online_time == 0 || !empty($_plugin_visit_access))
        return array($template);

    // Part 1: Add
    if ($data['id'] && $template_name == 'full')
    {
        $_ip = mysql_real_escape_string($_SERVER['REMOTE_ADDR'], CN_CONNECT);

        mysql_query("INSERT INTO cn_visit_counter (`id`, `ip`, `accesstime`) VALUES ($ID, '$_ip', UNIX_TIMESTAMP(NOW()))", CN_CONNECT);
        mysql_query("DELETE FROM cn_visit_counter WHERE accesstime < ".(time() - $online_time), CN_CONNECT);
    }

    // Part 2: Calc
    $views = mysql_fetch_assoc( mysql_query("SELECT COUNT(*) as `count` FROM cn_visit_counter WHERE id = $ID", CN_CONNECT) );
    $template = str_replace("{page-views}", $views['count'], $template);

    $_plugin_visit_access = TRUE;
    return array($template);
}



Could you help me to solve this small problem ?

Thanks you!

Re: Visit Counter

Support ?