PageRenderTime 41ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/plugins/wp-statistics/includes/settings/tabs/wps-exclusions.php

https://gitlab.com/hop23typhu/faci-times
PHP | 234 lines | 195 code | 39 blank | 0 comment | 14 complexity | 7226d549c376013b34589f88caaae56d MD5 | raw file
  1. <?php
  2. global $wp_roles;
  3. $role_list = $wp_roles->get_names();
  4. if( $wps_nonce_valid ) {
  5. foreach( $role_list as $role ) {
  6. $role_post = 'wps_exclude_' . str_replace(" ", "_", strtolower($role) );
  7. if( array_key_exists( $role_post, $_POST ) ) { $value = $_POST[$role_post]; } else { $value = ''; }
  8. $new_option = str_replace( "wps_", "", $role_post );
  9. $WP_Statistics->store_option($new_option, $value);
  10. }
  11. if( array_key_exists( 'wps_create_honeypot', $_POST ) ) {
  12. $my_post = array(
  13. 'post_type' => 'page',
  14. 'post_title' => __('WP Statistics Honey Pot Page', 'wp_statistics' ) . ' [' . $WP_Statistics->Current_Date() . ']',
  15. 'post_content' => __('This is the honey pot for WP Statistics to use, do not delete.', 'wp_statistics' ),
  16. 'post_status' => 'publish',
  17. 'post_author' => 1,
  18. );
  19. $_POST['wps_honeypot_postid'] = wp_insert_post( $my_post );
  20. }
  21. $wps_option_list = array_merge( $wps_option_list, array('wps_record_exclusions','wps_robotlist','wps_exclude_ip','wps_exclude_loginpage','wps_exclude_adminpage','wps_force_robot_update','wps_excluded_countries','wps_included_countries','wps_excluded_hosts','wps_robot_threshold','wps_use_honeypot','wps_honeypot_postid','wps_exclude_feeds','wps_excluded_urls','wps_exclude_404s', 'wps_corrupt_browser_info' ) );
  22. foreach( $wps_option_list as $option ) {
  23. $new_option = str_replace( "wps_", "", $option );
  24. if( array_key_exists( $option, $_POST ) ) { $value = $_POST[$option]; } else { $value = ''; }
  25. $WP_Statistics->store_option($new_option, $value);
  26. }
  27. }
  28. ?>
  29. <table class="form-table">
  30. <tbody>
  31. <tr valign="top">
  32. <th scope="row" colspan="2"><h3><?php _e('Exclusions', 'wp_statistics'); ?></h3></th>
  33. </tr>
  34. <tr valign="top">
  35. <th scope="row"><label for="wps-exclusions"><?php _e('Record exclusions', 'wp_statistics'); ?></label>:</th>
  36. <td>
  37. <input id="wps-exclusions" type="checkbox" value="1" name="wps_record_exclusions" <?php echo $WP_Statistics->get_option('record_exclusions')==true? "checked='checked'":'';?>><label for="wps-exclusions"><?php _e('Enable', 'wp_statistics'); ?></label>
  38. <p class="description"><?php _e('This will record all the excluded hits in a separate table with the reasons why it was excluded but no other information. This will generate a lot of data but is useful if you want to see the total number of hits your site gets, not just actual user visits.', 'wp_statistics'); ?></p>
  39. </td>
  40. </tr>
  41. <tr valign="top">
  42. <th scope="row" colspan="2"><h3><?php _e('Exclude User Roles', 'wp_statistics'); ?></h3></th>
  43. </tr>
  44. <?php
  45. $role_option_list = '';
  46. foreach( $role_list as $role ) {
  47. $store_name = 'exclude_' . str_replace(" ", "_", strtolower($role) );
  48. $option_name = 'wps_' . $store_name;
  49. $role_option_list .= $option_name . ',';
  50. $translated_role_name = translate_user_role($role);
  51. ?>
  52. <tr valign="top">
  53. <th scope="row"><label for="<?php echo $option_name;?>"><?php echo $translated_role_name; ?>:</label></th>
  54. <td>
  55. <input id="<?php echo $option_name;?>" type="checkbox" value="1" name="<?php echo $option_name;?>" <?php echo $WP_Statistics->get_option($store_name)==true? "checked='checked'":'';?>><label for="<?php echo $option_name;?>"><?php _e('Exclude', 'wp_statistics'); ?></label>
  56. <p class="description"><?php echo sprintf(__('Exclude %s role from data collection.', 'wp_statistics'), $translated_role_name); ?></p>
  57. </td>
  58. </tr>
  59. <?php } ?>
  60. <tr valign="top">
  61. <th scope="row" colspan="2"><h3><?php _e('IP/Robot Exclusions', 'wp_statistics'); ?></h3></th>
  62. </tr>
  63. <tr valign="top">
  64. <th scope="row"><?php _e('Robot list', 'wp_statistics'); ?>:</th>
  65. <td>
  66. <textarea name="wps_robotlist" class="code" dir="ltr" rows="10" cols="60" id="wps_robotlist"><?php
  67. $robotlist = $WP_Statistics->get_option('robotlist');
  68. include_once(dirname( __FILE__ ) . '/../../../robotslist.php');
  69. if( $robotlist == '' ) {
  70. $robotlist = $wps_robotlist;
  71. update_option( 'wps_robotlist', $robotlist );
  72. }
  73. echo htmlentities( $robotlist, ENT_QUOTES );?></textarea>
  74. <p class="description"><?php echo __('A list of words (one per line) to match against to detect robots. Entries must be at least 4 characters long or they will be ignored.', 'wp_statistics'); ?></p>
  75. <a onclick="var wps_robotlist = getElementById('wps_robotlist'); wps_robotlist.value = '<?php echo implode('\n', $wps_robotarray);?>';" class="button"><?php _e('Reset to Default', 'wp_statistics');?></a>
  76. </td>
  77. </tr>
  78. <tr valign="top">
  79. <th scope="row"><label for="force_robot_update"><?php _e('Force robot list update after upgrades', 'wp_statistics'); ?>:</label></th>
  80. <td>
  81. <input id="force_robot_update" type="checkbox" value="1" name="wps_force_robot_update" <?php echo $WP_Statistics->get_option('force_robot_update')==true? "checked='checked'":'';?>><label for="force_robot_update"><?php _e('Enable', 'wp_statistics'); ?></label>
  82. <p class="description"><?php echo sprintf(__('Force the robot list to be reset to the default after an update to WP Statistics takes place. Note if this option is enabled any custom robots you have added to the list will be lost.', 'wp_statistics'), $role); ?></p>
  83. </td>
  84. </tr>
  85. <tr valign="top">
  86. <th scope="row"><label for="wps_robot_threshold"><?php _e('Robot visit threshold', 'wp_statistics'); ?>:</label></th>
  87. <td>
  88. <input id="wps_robot_threshold" type="text" size="5" name="wps_robot_threshold" value="<?php echo $WP_Statistics->get_option('robot_threshold');?>">
  89. <p class="description"><?php echo __('Treat visitors with more than this number of visits per day as robots. 0 = disabled.', 'wp_statistics'); ?></p>
  90. </td>
  91. </tr>
  92. <tr valign="top">
  93. <th scope="row"><?php _e('Excluded IP address list', 'wp_statistics'); ?>:</th>
  94. <td>
  95. <textarea id="wps_exclude_ip" name="wps_exclude_ip" rows="5" cols="60" class="code" dir="ltr"><?php echo htmlentities( $WP_Statistics->get_option('exclude_ip'), ENT_QUOTES );?></textarea>
  96. <p class="description"><?php echo __('A list of IP addresses and subnet masks (one per line) to exclude from statistics collection (both 192.168.0.0/24 and 192.168.0.0/255.255.255.0 formats are accepted). To specify an IP address only, use a subnet value of 32 or 255.255.255.255.', 'wp_statistics'); ?></p>
  97. <a onclick="var wps_exclude_ip = getElementById('wps_exclude_ip'); if( wps_exclude_ip != null ) { wps_exclude_ip.value = jQuery.trim( wps_exclude_ip.value + '\n10.0.0.0/8' ); }" class="button"><?php _e('Add 10.0.0.0', 'wp_statistics');?></a>
  98. <a onclick="var wps_exclude_ip = getElementById('wps_exclude_ip'); if( wps_exclude_ip != null ) { wps_exclude_ip.value = jQuery.trim( wps_exclude_ip.value + '\n172.16.0.0/12' ); }" class="button"><?php _e('Add 172.16.0.0', 'wp_statistics');?></a>
  99. <a onclick="var wps_exclude_ip = getElementById('wps_exclude_ip'); if( wps_exclude_ip != null ) { wps_exclude_ip.value = jQuery.trim( wps_exclude_ip.value + '\n192.168.0.0/16' ); }" class="button"><?php _e('Add 192.168.0.0', 'wp_statistics');?></a>
  100. </td>
  101. </tr>
  102. <tr valign="top">
  103. <th scope="row"><?php _e('Use honey pot', 'wp_statistics'); ?>:</th>
  104. <td>
  105. <input id="use_honeypot" type="checkbox" value="1" name="wps_use_honeypot" <?php echo $WP_Statistics->get_option('use_honeypot')==true? "checked='checked'":'';?>><label for="wps_use_honeypot"><?php _e('Enable', 'wp_statistics'); ?></label>
  106. <p class="description"><?php echo __('Use a honey pot page to identify robots.', 'wp_statistics'); ?></p>
  107. </td>
  108. </tr>
  109. <tr valign="top">
  110. <th scope="row"><label for="honeypot_postid"><?php _e('Honey pot post id', 'wp_statistics'); ?>:</label></th>
  111. <td>
  112. <input id="honeypot_postid" type="text" value="<?php echo htmlentities( $WP_Statistics->get_option('honeypot_postid'), ENT_QUOTES );?>" size="5" name="wps_honeypot_postid">
  113. <p class="description"><?php echo __('The post id to use for the honeypot page.', 'wp_statistics'); ?></p>
  114. <input id="wps_create_honeypot" type="checkbox" value="1" name="wps_create_honeypot"><label for="wps_create_honeypot"><?php _e('Create a new honey pot page', 'wp_statistics'); ?></label>
  115. </td>
  116. </tr>
  117. <tr valign="top">
  118. <th scope="row"><label for="corrupt_browser_info"><?php _e('Treat corrupt browser info as a bot', 'wp_statistics'); ?>:</label></th>
  119. <td>
  120. <input id="corrupt_browser_info" type="checkbox" value="1" name="wps_corrupt_browser_info" <?php echo $WP_Statistics->get_option('corrupt_browser_info')==true? "checked='checked'":'';?>><label for="wps_corrupt_browser_info"><?php _e('Enable', 'wp_statistics'); ?></label>
  121. <p class="description"><?php echo __('Treat any visitor with corrupt browser info (missing IP address or empty user agent string) as a robot.', 'wp_statistics'); ?></p>
  122. </td>
  123. </tr>
  124. <tr valign="top">
  125. <th scope="row" colspan="2"><h3><?php _e('GeoIP Exclusions', 'wp_statistics'); ?></h3></th>
  126. </tr>
  127. <tr valign="top">
  128. <th scope="row"><?php _e('Excluded countries list', 'wp_statistics'); ?>:</th>
  129. <td>
  130. <textarea id="wps_excluded_countries" name="wps_excluded_countries" rows="5" cols="10" class="code" dir="ltr"><?php echo htmlentities( $WP_Statistics->get_option('excluded_countries'), ENT_QUOTES );?></textarea>
  131. <p class="description"><?php echo __('A list of country codes (one per line, two letters each) to exclude from statistics collection. Use "000" (three zeros) to exclude unknown countries.', 'wp_statistics'); ?></p>
  132. </td>
  133. </tr>
  134. <tr valign="top">
  135. <th scope="row"><?php _e('Included countries list', 'wp_statistics'); ?>:</th>
  136. <td>
  137. <textarea id="wps_included_countries" name="wps_included_countries" rows="5" cols="10" class="code" dir="ltr"><?php echo htmlentities( $WP_Statistics->get_option('included_countries'), ENT_QUOTES );?></textarea>
  138. <p class="description"><?php echo __('A list of country codes (one per line, two letters each) to include in statistics collection, if this list is not empty, only visitors from the included countries will be recorded. Use "000" (three zeros) to exclude unknown countries.', 'wp_statistics'); ?></p>
  139. </td>
  140. </tr>
  141. <tr valign="top">
  142. <th scope="row" colspan="2"><h3><?php _e('Host Exclusions', 'wp_statistics'); ?></h3></th>
  143. </tr>
  144. <tr valign="top">
  145. <th scope="row"><?php _e('Excluded hosts list', 'wp_statistics'); ?>:</th>
  146. <td>
  147. <textarea id="wps_excluded_hosts" name="wps_excluded_hosts" rows="5" cols="80" class="code" dir="ltr"><?php echo htmlentities( $WP_Statistics->get_option('excluded_hosts'), ENT_QUOTES );?></textarea>
  148. <p class="description"><?php echo __('A list of fully qualified host names (ie. server.example.com, one per line) to exclude from statistics collection.', 'wp_statistics'); ?></p>
  149. <br>
  150. <p class="description"><?php echo __('Note: this option will NOT perform a reverse DNS lookup on each page load but instead cache the IP address for the provided hostnames for one hour. If you are excluding dynamically assigned hosts you may find some degree of overlap when the host changes it\'s IP address and when the cache is updated resulting in some hits recorded.', 'wp_statistics'); ?></p>
  151. </td>
  152. </tr>
  153. <tr valign="top">
  154. <th scope="row" colspan="2"><h3><?php _e('Site URL Exclusions', 'wp_statistics'); ?></h3></th>
  155. </tr>
  156. <tr valign="top">
  157. <th scope="row"><?php _e('Excluded login page', 'wp_statistics'); ?>:</th>
  158. <td>
  159. <input id="wps-exclude-loginpage" type="checkbox" value="1" name="wps_exclude_loginpage" <?php echo $WP_Statistics->get_option('exclude_loginpage')==true? "checked='checked'":'';?>><label for="wps-exclude-loginpage"><?php _e('Exclude', 'wp_statistics'); ?></label>
  160. <p class="description"><?php _e('Exclude the login page for registering as a hit.', 'wp_statistics'); ?></p>
  161. </td>
  162. </tr>
  163. <tr valign="top">
  164. <th scope="row"><?php _e('Excluded admin pages', 'wp_statistics'); ?>:</th>
  165. <td>
  166. <input id="wps-exclude-adminpage" type="checkbox" value="1" name="wps_exclude_adminpage" <?php echo $WP_Statistics->get_option('exclude_adminpage')==true? "checked='checked'":'';?>><label for="wps-exclude-adminpage"><?php _e('Exclude', 'wp_statistics'); ?></label>
  167. <p class="description"><?php _e('Exclude the admin pages for registering as a hit.', 'wp_statistics'); ?></p>
  168. </td>
  169. </tr>
  170. <tr valign="top">
  171. <th scope="row"><?php _e('Excluded RSS feeds', 'wp_statistics'); ?>:</th>
  172. <td>
  173. <input id="wps-exclude-feeds" type="checkbox" value="1" name="wps_exclude_feeds" <?php echo $WP_Statistics->get_option('exclude_feeds')==true? "checked='checked'":'';?>><label for="wps-exclude-feeds"><?php _e('Exclude', 'wp_statistics'); ?></label>
  174. <p class="description"><?php _e('Exclude the RSS feeds for registering as a hit.', 'wp_statistics'); ?></p>
  175. </td>
  176. </tr>
  177. <tr valign="top">
  178. <th scope="row"><?php _e('Excluded 404 pages', 'wp_statistics'); ?>:</th>
  179. <td>
  180. <input id="wps-exclude-404s" type="checkbox" value="1" name="wps_exclude_404s" <?php echo $WP_Statistics->get_option('exclude_404s')==true? "checked='checked'":'';?>><label for="wps-exclude-404s"><?php _e('Exclude', 'wp_statistics'); ?></label>
  181. <p class="description"><?php _e('Exclude any URL that returns a "404 - Not Found" message.', 'wp_statistics'); ?></p>
  182. </td>
  183. </tr>
  184. <tr valign="top">
  185. <th scope="row"><?php _e('Excluded URLs list', 'wp_statistics'); ?>:</th>
  186. <td>
  187. <textarea id="wps_excluded_urls" name="wps_excluded_urls" rows="5" cols="80" class="code" dir="ltr"><?php echo htmlentities( $WP_Statistics->get_option('excluded_urls'), ENT_QUOTES );?></textarea>
  188. <p class="description"><?php echo __('A list of local urls (ie. /wordpress/about, one per line) to exclude from statistics collection.', 'wp_statistics'); ?></p>
  189. <br>
  190. <p class="description"><?php echo __('Note: this option will NOT handle url parameters (anything after the ?), only to the script name. Entries less than two characters will be ignored.', 'wp_statistics'); ?></p>
  191. </td>
  192. </tr>
  193. </tbody>
  194. </table>
  195. <?php submit_button(__('Update', 'wp_statistics'), 'primary', 'submit'); ?>