Plugin Directory

Changeset 418231


Ignore:
Timestamp:
08/02/2011 01:30:45 PM (15 years ago)
Author:
aviaxis
Message:

version 1.1.0

Location:
traffic-counter-widget/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • traffic-counter-widget/trunk/readme.txt

    r417136 r418231  
    11=== Plugin Name ===
    22Plugin Name: Traffic Counter Widget Plugin
    3 Version: 1.0.2
     3Version: 1.1.0
    44Donate link: http://www.pixme.org/wp-content/uploads/widget-traffic-counter/
    55URI: http://www.pixme.org/wp-content/uploads/widget-traffic-counter/
     
    2222It shows the number of visitors in the past 24 hours, 7 days and 30 days. It also shows the number of users currently online.
    2323
    24 It does not have (yet) a robots filter, so the automatic traffic is also considered (however this should be in your benefit). Traffic Counter Widget also offers language support on your widget 
     24It provides a robots filter, so the automatic traffic could also considered. Traffic Counter offers language support on your widget 
    2525
    2626For help or reporting bugs please refer to: http://www.pixme.org/tehnologie-internet/wordpress-traffic-counter-widget/4228
     
    4545== Changelog ==
    4646
     47= 1.1.0
     48* Configurable robots filter
     49* Automated log deletion
     50
    4751= 1.0.2
    4852* Monthly visitors bug fix
     
    5458* Plugin created
    5559
    56 == Upgrade Notice ==
    57 
    58 = 1.1.0 =
    59 * delete old logs from DB
    60 * uninstall
    61 * work on the number formatting
    62 
    63 = 2.0.0 =
    64 * configurable robots filter
    65 * more statistic data to be shown
    66 
    6760== Other ==
    6861
  • traffic-counter-widget/trunk/wp-traffic-counter-widget.php

    r417136 r418231  
    55Description: Counts the number of visitors of your blog and shows the traffic information on a widget
    66Author: Bogdan Nicolaescu
    7 Version: 1.0.2
     7Version: 1.1.0
    88Author URI: http://www.pixme.org/
    99*/
     
    1111function traffic_counter_control() {
    1212
    13   $options = get_option("widget_traffic_counter");
     13  $options = get_wtc_options();
    1414
    1515  if ($_POST['wp_wtc_Submit']){
     
    2121    $options['wp_wtc_WidgetText_LastMonth'] = htmlspecialchars($_POST['wp_wtc_WidgetText_LastMonth']);
    2222    $options['wp_wtc_WidgetText_Online'] = htmlspecialchars($_POST['wp_wtc_WidgetText_Online']);
     23    $options['wp_wtc_WidgetText_log_opt'] = htmlspecialchars($_POST['wp_wtc_WidgetText_log_opt']);
     24    $options['wp_wtc_WidgetText_bots_filter'] = htmlspecialchars($_POST['wp_wtc_WidgetText_bots_filter']);
    2325
    2426    update_option("widget_traffic_counter", $options);
     
    2830  <p><strong>Use options below to translate english labels</strong></p>
    2931  <p>
    30     <label for="widget_traffic_counter">Text Title: </label>
     32    <label for="wp_wtc_WidgetTitle">Text Title: </label>
    3133    <input type="text" id="wp_wtc_WidgetTitle" name="wp_wtc_WidgetTitle" value="<?php echo ($options['wp_wtc_WidgetTitle'] =="" ? "Blog Traffic" : $options['wp_wtc_WidgetTitle']); ?>" />
    3234  </p>
    3335  <p>
    34     <label for="widget_traffic_counter">Text Visitors: </label>
     36    <label for="wp_wtc_WidgetText_Visitors">Text Visitors: </label>
    3537    <input type="text" id="wp_wtc_WidgetText_Visitors" name="wp_wtc_WidgetText_Visitors" value="<?php echo ($options['wp_wtc_WidgetText_Visitors'] =="" ? "Visitors" : $options['wp_wtc_WidgetText_Visitors']); ?>" />
    3638  </p>
    3739  <p>
    38     <label for="widget_traffic_counter">Text Last 24 Hours: </label>:
     40    <label for="wp_wtc_WidgetText_LastDay">Text Last 24 Hours: </label>:
    3941    <input type="text" id="wp_wtc_WidgetText_LastDay" name="wp_wtc_WidgetText_LastDay" value="<?php echo ($options['wp_wtc_WidgetText_LastDay'] =="" ? "Last 24 hours" : $options['wp_wtc_WidgetText_LastDay']); ?>" />
    4042  </p>
    4143  <p>
    42     <label for="widget_traffic_counter">Text Last 7 Days: </label>:
     44    <label for="wp_wtc_WidgetText_LastWeek">Text Last 7 Days: </label>:
    4345    <input type="text" id="wp_wtc_WidgetText_LastWeek" name="wp_wtc_WidgetText_LastWeek" value="<?php echo ($options['wp_wtc_WidgetText_LastWeek'] =="" ? "Last 7 days" : $options['wp_wtc_WidgetText_LastWeek']); ?>" />
    4446  </p>
    4547  <p>
    46     <label for="widget_traffic_counter">Text Last 30 Days: </label>:
     48    <label for="wp_wtc_WidgetText_LastMonth">Text Last 30 Days: </label>:
    4749    <input type="text" id="wp_wtc_WidgetText_LastMonth" name="wp_wtc_WidgetText_LastMonth" value="<?php echo ($options['wp_wtc_WidgetText_LastMonth'] =="" ? "Last 30 days" : $options['wp_wtc_WidgetText_LastMonth']); ?>" />
    4850  </p>
    4951  <p>
    50     <label for="widget_traffic_counter">Text Online Now: </label>:
     52    <label for="wp_wtc_WidgetText_Online">Text Online Now: </label>:
    5153    <input type="text" id="wp_wtc_WidgetText_Online" name="wp_wtc_WidgetText_Online" value="<?php echo ($options['wp_wtc_WidgetText_Online'] =="" ? "Online now" : $options['wp_wtc_WidgetText_Online']); ?>" />
     54  </p>
     55  <p>
     56    <label for="wp_wtc_WidgetText_bots_filter">Automatic Traffic</label>:
     57    <select id="wp_wtc_WidgetText_bots_filter" name="wp_wtc_WidgetText_bots_filter">
     58      <option value="1" <?php echo ($options['wp_wtc_WidgetText_bots_filter'] == "1" ? "selected" : "" ); ?> >Log and show</option>
     59      <option value="2" <?php echo ($options['wp_wtc_WidgetText_bots_filter'] == "2" ? "selected" : "" ); ?> >Log do not show</option>
     60      <option value="3" <?php echo ($options['wp_wtc_WidgetText_bots_filter'] == "3" ? "selected" : "" ); ?> >Do not log</option>
     61    </select>
     62  </p>
     63  <p>
     64    <label for="wp_wtc_WidgetText_log_opt">Automatically delete old logs:*</label>
     65    <input type="checkbox" id="wp_wtc_WidgetText_log_opt" name="wp_wtc_WidgetText_log_opt" <?php echo ($options['wp_wtc_WidgetText_log_opt'] == "on" ? "checked" : "" ); ?> />
     66  </p>
     67<p>*Caution! By unchecking this you will have to manually delete old logs from time to time! Checking this would only keep logs for the past 1-2 months</p>
     68  <p>
    5269    <input type="hidden" id="wp_wtc_Submit" name="wp_wtc_Submit" value="1" />
    5370  </p>
     71
    5472<?php
    5573}
     
    6583                     'wp_wtc_WidgetText_LastWeek' => 'Last 7 days',
    6684                     'wp_wtc_WidgetText_LastMonth' => 'Last 30 days',
    67                      'wp_wtc_WidgetText_Online' => 'Online now'
     85                     'wp_wtc_WidgetText_Online' => 'Online now',
     86                     'wp_wtc_WidgetText_log_opt' => 'on',
     87                     'wp_wtc_WidgetText_bots_filter' => '1'
    6888                    );
    6989  }
     
    7595  global $wpdb;
    7696  $table_name = $wpdb->prefix . "wtc_log";
    77   return $wpdb->get_var($wpdb->prepare("SELECT COUNT(".($unique ? "DISTINCT IP" : "*").") FROM $table_name where Time > ".(time()-$sex) ) );
     97  $options = get_wtc_options();
     98
     99  $sql = "SELECT COUNT(".($unique ? "DISTINCT IP" : "*").") FROM $table_name where Time > ".(time()-$sex);
     100  if ($options['wp_wtc_WidgetText_bots_filter'] > 1)
     101    $sql .= ' AND IS_BOT <> 1';
     102
     103  return $wpdb->get_var($wpdb->prepare($sql));
    78104}
    79105
     
    83109  global $wpdb;
    84110  $options = get_wtc_options();
     111
     112  if ($options['wp_wtc_WidgetText_log_opt'] == 'on' && date('j') == 1 && date('G') == 23)
     113     $wpdb->query('DELETE FROM '.$table_name.' WHERE Time < '.time()-2592000);
     114
     115  if (is_bot() && ($options ['wp_wtc_WidgetText_bots_filter'] == 3 ))
     116     return;
    85117
    86118  if ($_SERVER['HTTP_X_FORWARD_FOR'])
     
    95127    $data = array (
    96128                 'IP' => $ip,
    97                  'Time' => time()
     129                 'Time' => time(),
     130                 'IS_BOT'=> is_bot()
    98131                );
    99     $format  = array ('%s','%d');
     132    $format  = array ('%s','%d', '%b');
    100133    $wpdb->insert( $table_name, $data, $format );
    101134  }
    102 
    103135?>
    104136
     
    127159}
    128160
     161function is_bot(){
     162
     163    $user_agent = $_SERVER['HTTP_USER_AGENT'];
     164    $bots = array( 'Google Bot' => 'googlebot', 'Google Bot' => 'google', 'MSN' => 'msnbot', 'Alex' => 'ia_archiver', 'Lycos' => 'lycos', 'Ask Jeeves' => 'jeeves', 'Altavista' => 'scooter', 'AllTheWeb' => 'fast-webcrawler', 'Inktomi' => 'slurp@inktomi', 'Turnitin.com' => 'turnitinbot', 'Technorati' => 'technorati', 'Yahoo' => 'yahoo', 'Findexa' => 'findexa', 'NextLinks' => 'findlinks', 'Gais' => 'gaisbo', 'WiseNut' => 'zyborg', 'WhoisSource' => 'surveybot', 'Bloglines' => 'bloglines', 'BlogSearch' => 'blogsearch', 'PubSub' => 'pubsub', 'Syndic8' => 'syndic8', 'RadioUserland' => 'userland', 'Gigabot' => 'gigabot', 'Become.com' => 'become.com', 'Baidu' => 'baidu', 'Yandex' => 'yandex', 'Amazon' => 'amazonaws.com' );
     165
     166    foreach ( $bots as $name => $lookfor )
     167        if ( stristr( $user_agent, $lookfor ) !== false )
     168            return true;
     169
     170        return false;
     171}
     172
     173
    129174function wp_wtc_install_db () {
    130175   global $wpdb;
    131176
    132177   $table_name = $wpdb->prefix . "wtc_log";
    133    if($wpdb->get_var("show tables like '$table_name'") != $table_name) {
     178   $gTable = $wpdb->get_var("show tables like '$table_name'");
     179   $gColumn = $wpdb->get_results("SHOW COLUMNS FROM ".$table_name." LIKE 'IS_BOT'");
     180
     181   if($gTable != $table_name) {
    134182
    135183      $sql = "CREATE TABLE " . $table_name . " (
    136184           IP VARCHAR( 17 ) NOT NULL ,
    137185           Time INT( 11 ) NOT NULL ,
     186           IS_BOT BOOLEAN NOT NULL,
    138187           PRIMARY KEY ( IP , Time )
    139188           );";
     
    141190      require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    142191      dbDelta($sql);
    143    }
    144 }
     192
     193   } else if (empty($gColumn)) {  //old table version update
     194
     195     $sql = "ALTER TABLE ".$table_name." ADD IS_BOT BOOLEAN NOT NULL";
     196     $wpdb->query($sql);
     197  }
     198}
     199
    145200
    146201
     
    157212  $table_name = $wpdb->prefix . "wtc_log";
    158213  delete_option("widget_traffic_counter");
     214  delete_option("wp_wtc_WidgetTitle");
     215  delete_option("wp_wtc_WidgetText_Visitors");
     216  delete_option("wp_wtc_WidgetText_LastDay");
     217  delete_option("wp_wtc_WidgetText_LastWeek");
     218  delete_option("wp_wtc_WidgetText_LastMonth");
     219  delete_option("wp_wtc_WidgetText_Online");
     220  delete_option("wp_wtc_WidgetText_log_opt");
     221  delete_option("wp_wtc_WidgetText_bots_filter");
     222
    159223  $wpdb->query("DROP TABLE IF EXISTS $table_name");
    160224
Note: See TracChangeset for help on using the changeset viewer.