ae_visitor_counter(); } function ae_visitor_counter() { } function getData() { $values = array( 'title' => $title , 'startDay' => get_option('ae_visitor_day') , 'startYest' => get_option('ae_visitor_yesterday') , 'startWeek' => get_option('ae_visitor_week') , 'startMonth' => get_option('ae_visitor_month') , 'startAll' => get_option('ae_visitor_all') , 'DayUpdate' => get_option('ae_visitor_day_update') , 'WeekUpdate' => get_option('ae_visitor_week_update') , 'MonthUpdate' => get_option('ae_visitor_month_update') , ); return $values; } function counter() { if( trim($_SERVER['HTTP_USER_AGENT'])=='' || preg_match('/(bot.((x)?htm(l)?|php)|[\w\W]+bot[\W]+|feedfetcher|slurp|Baiduspider|WOW64)/i', $_SERVER['HTTP_USER_AGENT']) ) return false; $values = $this->getData(); $ae_visitor_update = ( isset( $_COOKIE[ 'ae_visitor_update' ] ) ) ? $_COOKIE[ 'ae_visitor_update' ] : 0 ; if( $ae_visitor_update != '1' ) { setcookie('ae_visitor_update', '1', time()+(60*15), COOKIEPATH, COOKIE_DOMAIN, false); if( $values['DayUpdate']!=(date("N")) ) { // for reset to day update_option('ae_visitor_day_update', (date("N")) ); update_option('ae_visitor_day', 0 ); $values['startYest'] = $values['startDay']; $values['startDay'] = 0; } if( $values['WeekUpdate']!=(date("W")) ) { // for reset this week update_option('ae_visitor_week_update', (date("W")) ); update_option('ae_visitor_week', 0 ); $values['startWeek'] = 0; } if( $values['MonthUpdate']!=(date("n")) ) { // for reset this month update_option('ae_visitor_month_update', (date("n")) ); update_option('ae_visitor_month', 0 ); $values['startMonth'] = 0; } $values['startDay']++; //$values['startYest']++; $values['startWeek']++; $values['startMonth']++; $values['startAll']++; update_option('ae_visitor_day', $values['startDay']); update_option('ae_visitor_yesterday', $values['startYest']); update_option('ae_visitor_week', $values['startWeek']); update_option('ae_visitor_month', $values['startMonth']); update_option('ae_visitor_all', $values['startAll']); } } } class ae_visitor extends WP_Widget { function __construct() { $this->ae_visitor(); } function ae_visitor() { $widget_ops = array( 'classname' => 'Widget_ae_visitor', 'description' => __('Display guest visitor of your web in day, week, month, and all.', 'ae-visitor') ); //Create widget $this->WP_Widget('aevisitor', __('AE Visitor', 'ae-visitor'), $widget_ops); } function widget($args, $instance) { extract($args, EXTR_SKIP); echo $before_widget; $title = empty($instance['title']) ? __('AE Visitor', 'ae-visitor') : apply_filters('widget_title', $instance['title']) ; $aeVC = new ae_visitor_counter(); $values = $aeVC->getData(); if ( !empty( $title ) ) { echo $before_title . $title . $after_title; }; echo $ae_visitor_update; ?>
Today Today
Yesterday Yesterday
This Week This Week
This Month This Month
All Days All Days
  __('AE Visitor','ae-visitor') ) ); $title = esc_attr($instance['title']); ?>