Changeset 418231
- Timestamp:
- 08/02/2011 01:30:45 PM (15 years ago)
- Location:
- traffic-counter-widget/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (4 diffs)
-
wp-traffic-counter-widget.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
traffic-counter-widget/trunk/readme.txt
r417136 r418231 1 1 === Plugin Name === 2 2 Plugin Name: Traffic Counter Widget Plugin 3 Version: 1. 0.23 Version: 1.1.0 4 4 Donate link: http://www.pixme.org/wp-content/uploads/widget-traffic-counter/ 5 5 URI: http://www.pixme.org/wp-content/uploads/widget-traffic-counter/ … … 22 22 It shows the number of visitors in the past 24 hours, 7 days and 30 days. It also shows the number of users currently online. 23 23 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 alsooffers language support on your widget24 It provides a robots filter, so the automatic traffic could also considered. Traffic Counter offers language support on your widget 25 25 26 26 For help or reporting bugs please refer to: http://www.pixme.org/tehnologie-internet/wordpress-traffic-counter-widget/4228 … … 45 45 == Changelog == 46 46 47 = 1.1.0 48 * Configurable robots filter 49 * Automated log deletion 50 47 51 = 1.0.2 48 52 * Monthly visitors bug fix … … 54 58 * Plugin created 55 59 56 == Upgrade Notice ==57 58 = 1.1.0 =59 * delete old logs from DB60 * uninstall61 * work on the number formatting62 63 = 2.0.0 =64 * configurable robots filter65 * more statistic data to be shown66 67 60 == Other == 68 61 -
traffic-counter-widget/trunk/wp-traffic-counter-widget.php
r417136 r418231 5 5 Description: Counts the number of visitors of your blog and shows the traffic information on a widget 6 6 Author: Bogdan Nicolaescu 7 Version: 1. 0.27 Version: 1.1.0 8 8 Author URI: http://www.pixme.org/ 9 9 */ … … 11 11 function traffic_counter_control() { 12 12 13 $options = get_ option("widget_traffic_counter");13 $options = get_wtc_options(); 14 14 15 15 if ($_POST['wp_wtc_Submit']){ … … 21 21 $options['wp_wtc_WidgetText_LastMonth'] = htmlspecialchars($_POST['wp_wtc_WidgetText_LastMonth']); 22 22 $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']); 23 25 24 26 update_option("widget_traffic_counter", $options); … … 28 30 <p><strong>Use options below to translate english labels</strong></p> 29 31 <p> 30 <label for="w idget_traffic_counter">Text Title: </label>32 <label for="wp_wtc_WidgetTitle">Text Title: </label> 31 33 <input type="text" id="wp_wtc_WidgetTitle" name="wp_wtc_WidgetTitle" value="<?php echo ($options['wp_wtc_WidgetTitle'] =="" ? "Blog Traffic" : $options['wp_wtc_WidgetTitle']); ?>" /> 32 34 </p> 33 35 <p> 34 <label for="w idget_traffic_counter">Text Visitors: </label>36 <label for="wp_wtc_WidgetText_Visitors">Text Visitors: </label> 35 37 <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']); ?>" /> 36 38 </p> 37 39 <p> 38 <label for="w idget_traffic_counter">Text Last 24 Hours: </label>:40 <label for="wp_wtc_WidgetText_LastDay">Text Last 24 Hours: </label>: 39 41 <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']); ?>" /> 40 42 </p> 41 43 <p> 42 <label for="w idget_traffic_counter">Text Last 7 Days: </label>:44 <label for="wp_wtc_WidgetText_LastWeek">Text Last 7 Days: </label>: 43 45 <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']); ?>" /> 44 46 </p> 45 47 <p> 46 <label for="w idget_traffic_counter">Text Last 30 Days: </label>:48 <label for="wp_wtc_WidgetText_LastMonth">Text Last 30 Days: </label>: 47 49 <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']); ?>" /> 48 50 </p> 49 51 <p> 50 <label for="w idget_traffic_counter">Text Online Now: </label>:52 <label for="wp_wtc_WidgetText_Online">Text Online Now: </label>: 51 53 <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> 52 69 <input type="hidden" id="wp_wtc_Submit" name="wp_wtc_Submit" value="1" /> 53 70 </p> 71 54 72 <?php 55 73 } … … 65 83 'wp_wtc_WidgetText_LastWeek' => 'Last 7 days', 66 84 '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' 68 88 ); 69 89 } … … 75 95 global $wpdb; 76 96 $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)); 78 104 } 79 105 … … 83 109 global $wpdb; 84 110 $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; 85 117 86 118 if ($_SERVER['HTTP_X_FORWARD_FOR']) … … 95 127 $data = array ( 96 128 'IP' => $ip, 97 'Time' => time() 129 'Time' => time(), 130 'IS_BOT'=> is_bot() 98 131 ); 99 $format = array ('%s','%d' );132 $format = array ('%s','%d', '%b'); 100 133 $wpdb->insert( $table_name, $data, $format ); 101 134 } 102 103 135 ?> 104 136 … … 127 159 } 128 160 161 function 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 129 174 function wp_wtc_install_db () { 130 175 global $wpdb; 131 176 132 177 $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) { 134 182 135 183 $sql = "CREATE TABLE " . $table_name . " ( 136 184 IP VARCHAR( 17 ) NOT NULL , 137 185 Time INT( 11 ) NOT NULL , 186 IS_BOT BOOLEAN NOT NULL, 138 187 PRIMARY KEY ( IP , Time ) 139 188 );"; … … 141 190 require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 142 191 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 145 200 146 201 … … 157 212 $table_name = $wpdb->prefix . "wtc_log"; 158 213 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 159 223 $wpdb->query("DROP TABLE IF EXISTS $table_name"); 160 224
Note: See TracChangeset
for help on using the changeset viewer.