Changeset 399351
- Timestamp:
- 06/20/2011 07:35:35 PM (15 years ago)
- Location:
- piwikcounter/trunk
- Files:
-
- 3 edited
-
class.PiwikCounterAdministration.php (modified) (3 diffs)
-
class.Visitors.php (modified) (1 diff)
-
piwikcounter.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
piwikcounter/trunk/class.PiwikCounterAdministration.php
r386209 r399351 31 31 update_option( 'piwikcounter_start_date', $_POST[ 'start_date' ] ); 32 32 update_option( 'piwikcounter_unique_visitors', $_POST[ 'unique_visitors' ] ); 33 34 if ( $this->validateInt( $_POST[ 'update_interval' ], 0, 60 ) == $_POST[ 'update_interval' ] ) 35 { 36 update_option( 'piwikcounter_update_every', $_POST[ 'update_interval' ] ); 37 } 33 38 34 39 if (isset($_POST[ 'visits_today_visible' ]) && ($_POST[ 'visits_today_visible' ] == 1)) { … … 95 100 </td> 96 101 </tr> 102 103 <tr valign="top"> 104 <th scope="row"><?php _e("Update interval", 'piwikcounter'); ?></th> 105 <td> 106 <input type="text" size="4" name="update_interval" value="<?php echo get_option('piwikcounter_update_every') ?>" /> (time in minutes between 0 and 60) 107 </td> 108 </tr> 97 109 98 110 <tr valign="top"> … … 113 125 <?php 114 126 } 127 128 private function validateInt($value, $min_range = null, $max_range = null) { 129 130 if ($min_range != null AND $max_range != null) { 131 $int_options = array("options"=>array("min_range"=>$min_range, "max_range"=>$max_range)); 132 } 133 else if ($min_range == null AND $max_range != null) { 134 $int_options = array("options"=>array("max_range"=>$max_range)); 135 } 136 else if ($min_range != null AND $max_range == null) { 137 $int_options = array("options"=>array("min_range"=>$min_range)); 138 } 139 140 return filter_var($value, FILTER_VALIDATE_INT, $int_options); 141 } 115 142 116 143 } -
piwikcounter/trunk/class.Visitors.php
r386209 r399351 58 58 59 59 // Update 60 update_option( 'piwikcounter_visitors_yesterday', $visitors_yesterday ); 61 update_option( 'piwikcounter_visitors_last_change', date("Y-m-d", mktime(0, 0, 0, date("m"), date("d"), date("Y"))) ); 62 60 if ( get_option( 'piwikcounter_visitors_yesterday' ) < $visitors_yesterday ) 61 { 62 update_option( 'piwikcounter_visitors_yesterday', $visitors_yesterday ); 63 update_option( 'piwikcounter_visitors_last_change', date("Y-m-d", mktime(0, 0, 0, date("m"), date("d"), date("Y"))) ); 64 } 63 65 } 64 66 65 67 public function getTodaysVisitors() { 66 68 67 return $this->getVisitors( null, get_option('piwikcounter_piwik_url'), get_option('piwikcounter_site_id'), get_option('piwikcounter_auth_key'), get_option('piwikcounter_unique_visitors') ); 69 if ( ($this->minTimeDiffReached( get_option('piwikcounter_todays_visitors_last_change'), get_option('piwikcounter_update_every')) ) ) 70 { 71 update_option( 'piwikcounter_todays_visitors_last_change', time() ); 72 update_option( 'piwikcounter_todays_visitors', $this->getVisitors( null, get_option('piwikcounter_piwik_url'), get_option('piwikcounter_site_id'), get_option('piwikcounter_auth_key'), get_option('piwikcounter_unique_visitors')) ); 73 } 74 75 return (int) get_option('piwikcounter_todays_visitors'); 68 76 69 77 } 70 78 79 // check the minimum time between two timestamps 80 private function minTimeDiffReached($timestamp, $timedifference) 81 { 82 if ( time()-((int) $timedifference * 60) > (int) $timestamp ) 83 { 84 return true; 85 } 86 return false; 87 } 88 71 89 } 72 90 -
piwikcounter/trunk/piwikcounter.php
r386217 r399351 9 9 Plugin URI: http://piwikcounter.rontu.de 10 10 Description: PiwikCounter allows you to show the summary of (unique) visitors as a widget on your blog. 11 Version: 0. 2.011 Version: 0.3.0 12 12 Author: Tobias Etzold 13 13 Email: tobias.etzold@googlemail.com … … 33 33 add_option( 'piwikcounter_visitors_last_change', '2000-01-01', '', 'yes' ); // last modification date of piwikcounter_visitors_yesterday (date YYYY-MM-DD) 34 34 add_option( 'piwikcounter_visits_today_visible', '1', '', 'yes' ); // enables visability of visits for today 35 add_option( 'piwikcounter_todays_visitors', '', '', 'yes' ); // cached amount of visitors for today 36 add_option( 'piwikcounter_todays_visitors_last_change', '0000000001', '', 'yes' ); // last modification of piwikcounter_todays_visitors (timestamp) 37 add_option( 'piwikcounter_update_every', '5', '', 'yes' ); // time in minutes between updates of todays visitors 35 38 36 39 $pca = new PiwikCounterAdministration();
Note: See TracChangeset
for help on using the changeset viewer.