This extension is a simple user counter. It's a port of the pCounter from Andreas Droesch.
protected/extensions// application components 'components'=>array( // ... // UserCounter 'counter' => array( 'class' => 'UserCounter', ), ),
// Execute the counter before you use the getter-funtions! Yii::app()->counter->refresh();
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()); ?>
online: 9
today: 17
yesterday: 28
total: 1203
maximum: 32
date for maximum: 17.10.2009
Total 7 comments
Greate extention............. working!
I Add to this powerful class the ability to draw image for each digit, instead of return the number as text only. change the following functions to
public function getTotal(); public function getOnline(); public function getToday(); public function getYesterday(); public function getMaximal();
you can call the function as the following: <?php echo Yii::app()->counter->getOnline(true,'style name','digit image extension'); ?> or as usual, return the number as text: <?php echo Yii::app()->counter->getOnline(); ?>
you can download style for digit images from here. extract the zipped file to images folder on you project root, so "your_project/images/counterstyles"
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
CREATE TABLE IF NOT EXISTS
pcounter_save(save_namevarchar(10) NOT NULL,save_valueint(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_ipvarchar(39) NOT NULL,user_timeint(10) unsigned NOT NULL, UNIQUE KEYuser_ip(user_ip) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;INSERT INTO
pcounter_users(user_ip,user_time) VALUES ('''127.0.0.1''', 1290821670);This extension can be used for licence control.
You can check at the login the number of user logged in and forbid the login if there are more user logged in respect the user allowed by licence.
Nice job, indeed
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;
table: pcounter_users
table: pcounter_save
can you supply above table schema example?
simple but powerful :)
Leave a comment
Please login to leave your comment.