Yii Framework Forum: How to use usercounter? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How to use usercounter? Rate Topic: -----

#1 User is offline   fouss 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 366
  • Joined: 05-October 10
  • Location:Bamako Mali

Posted 24 May 2011 - 04:51 AM

How to use usercounter?
Do I need to ceate a database so that it works?
if yes, is it pcounter_save ( user_ip, save_name, save_value, day_time)?

I followed the instructions but allways getting -1 as online users

Quote

Documentation
Requirements

Yii 1.0 or above

Installation

Extract the release file under protected/extensions
Insert this code in the config/main.php:

// application components
'components'=>array(

// ...

// UserCounter
'counter' => array(
'class' => 'UserCounter',
),
),

Initialization

// Execute the counter before you use the getter-funtions!
Yii::app()->counter->refresh();

Usage

See the following code example:

online: <?php echo Yii::app()->counter->getOnline(); ?><br />
today: <?php echo Yii::app()->counter->getToday(); ?><br />
yesterday: <?php echo Yii::app()->counter->getYesterday(); ?><br />
total: <?php echo Yii::app()->counter->getTotal(); ?><br />
maximum: <?php echo Yii::app()->counter->getMaximal(); ?><br />
date for maximum: <?php echo date('d.m.Y', Yii::app()->counter->getMaximalTime()); ?>

Posted Image
0

#2 User is offline   Maurizio Domba 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,230
  • Joined: 12-October 09
  • Location:Croatia

Posted 24 May 2011 - 05:10 AM

check the comments on the extension page... there is the table schemas in the comments


Quote

CREATE TABLE pcounter_users ( user_ip VARCHAR(39) NOT NULL, user_time INT(10) UNSIGNED NOT NULL, UNIQUE KEY user_ip (user_ip)) ENGINE = myisam;

CREATE TABLE pcounter_save ( save_name VARCHAR(10) NOT NULL, save_value INT(10) UNSIGNED NOT NULL) ENGINE = myisam;

Find more about me.... btw. Do you know your WAN IP?
0

#3 User is offline   fouss 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 366
  • Joined: 05-October 10
  • Location:Bamako Mali

Posted 24 May 2011 - 05:13 AM

View Postmdomba, on 24 May 2011 - 05:10 AM, said:

check the comments on the extension page... there is the table schemas in the comments


Thanks! I saw it:

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

CREATE TABLE IF NOT EXISTS pcounter_save ( save_name varchar(10) NOT NULL, save_value int(10) unsigned NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8;

INSERT INTO pcounter_save (save_name, save_value) VALUES ('day_time', 2455527), ('max_count', 0), ('counter', 0), ('yesterday', 0);

CREATE TABLE IF NOT EXISTS pcounter_users ( user_ip varchar(39) NOT NULL, user_time int(10) unsigned NOT NULL, UNIQUE KEY user_ip (user_ip) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;

INSERT INTO pcounter_users (user_ip, user_time) VALUES ('''127.0.0.1''', 1290821670);


Posted Image
0

#4 User is offline   fouss 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 366
  • Joined: 05-October 10
  • Location:Bamako Mali

Posted 24 May 2011 - 05:27 AM

Seems working but still having -1 as online users
Posted Image
0

#5 User is offline   fouss 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 366
  • Joined: 05-October 10
  • Location:Bamako Mali

Posted 24 May 2011 - 05:40 AM

View Postfouss, on 24 May 2011 - 05:27 AM, said:

Seems working but still having -1 as online users


Working now.............. !
Posted Image
0

#6 User is offline   itsallaboutnomy 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 06-February 12

Posted 20 June 2012 - 02:12 AM

View Postfouss, on 24 May 2011 - 05:40 AM, said:

Working now.............. !


How it is working i still getting one user online. I have hosted my application on my local machine.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users