Changeset 539498
- Timestamp:
- 05/03/2012 03:58:36 PM (14 years ago)
- Location:
- wordpress-file-monitor-plus
- Files:
-
- 10 added
- 2 edited
-
.idea (added)
-
.idea/.name (added)
-
.idea/encodings.xml (added)
-
.idea/misc.xml (added)
-
.idea/modules.xml (added)
-
.idea/scopes (added)
-
.idea/scopes/scope_settings.xml (added)
-
.idea/vcs.xml (added)
-
.idea/wordpress-file-monitor-plus.iml (added)
-
.idea/workspace.xml (added)
-
branches/2.0/classes/wpfmp.class.php (modified) (2 diffs)
-
branches/2.0/classes/wpfmp.settings.class.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wordpress-file-monitor-plus/branches/2.0/classes/wpfmp.class.php
r539401 r539498 553 553 * @return array $data if getting data this should contain array of old scan data 554 554 */ 555 static p rotectedfunction getPutScanData( $getorput, $data = NULL )555 static public function getPutScanData( $getorput, $data = NULL ) 556 556 { 557 557 $options = get_option( self::$settings_option_field ); // Get settings … … 588 588 * @return string $data if getting data this should contain alert data 589 589 */ 590 static p rotectedfunction getPutAlertContent( $getorput, $data = "" )590 static public function getPutAlertContent( $getorput, $data = "" ) 591 591 { 592 592 $options = get_option( self::$settings_option_field ); // Get settings -
wordpress-file-monitor-plus/branches/2.0/classes/wpfmp.settings.class.php
r539401 r539498 30 30 add_action( 'admin_init', array( __CLASS__, 'admin_register_scripts_styles' ) ); 31 31 add_action( 'admin_menu', array( __CLASS__, 'add_settings_page' ) ); 32 /* 33 add_action( 'admin_init', array( __CLASS__, 'admin_settings_init' ) ); // Add admin init functions 34 */ 35 add_filter( 'plugin_action_links', array( __CLASS__, 'plugin_action_links' ), 10, 2 ); // Add settings link to plugin in plugin list 32 add_action( 'admin_init', array( __CLASS__, 'admin_plugin_actions' ) ); 33 add_action( 'admin_init', array( __CLASS__, 'admin_settings_init' ) ); 34 add_filter( 'plugin_action_links', array( __CLASS__, 'plugin_action_links' ), 10, 2 ); 36 35 } 37 36 … … 185 184 186 185 186 static public function admin_plugin_actions() 187 { 188 $options = get_option( sc_WordPressFileMonitorPlus::$settings_option_field ); // get settings 189 190 // No action to preform if all variables are not set. 191 if( ! isset( $_GET['sc_wpfmp_action'] ) || ! isset( $_GET['page'] ) || ! current_user_can( SC_WPFMP_ADMIN_ALERT_PERMISSION ) || "wordpress-file-monitor-plus" != $_GET['page'] ) 192 return; 193 194 // Switch through actions 195 switch( $_GET['sc_wpfmp_action'] ) 196 { 197 // Manual scan? 198 case "sc_wpfmp_scan": 199 do_action( sc_WordPressFileMonitorPlus::$cron_name ); 200 add_settings_error( "sc_wpfmp_settings_main", "sc_wpfmp_settings_main_error", __( "Manual scan completed", "wordpress-file-monitor-plus" ), "updated" ); 201 break; 202 203 // Reset settings? 204 case "sc_wpfmp_reset_settings": 205 delete_option( sc_WordPressFileMonitorPlus::$settings_option_field ); 206 delete_option( sc_WordPressFileMonitorPlus::$settings_option_field_ver ); 207 self::settingsUpToDate(); 208 add_settings_error( "sc_wpfmp_settings_main", "sc_wpfmp_settings_main_error", __( "Settings reset", "wordpress-file-monitor-plus" ), "updated" ); 209 break; 210 211 // Clear admin alert 212 case "sc_wpfmp_clear_admin_alert": 213 $options['is_admin_alert'] = 0; 214 update_option( sc_WordPressFileMonitorPlus::$settings_option_field, $options ); 215 add_settings_error( "sc_wpfmp_settings_main", "sc_wpfmp_settings_main_error", __( "Admin alert cleared", "wordpress-file-monitor-plus" ), "updated" ); 216 break; 217 218 // View admin alert? 219 case "sc_wpfmp_view_alert": 220 $alert_content = sc_WordPressFileMonitorPlus::getPutAlertContent( "get" ); 221 die( $alert_content ); 222 break; 223 224 // Wrong action... 225 default: 226 add_settings_error( "sc_wpfmp_settings_main", "sc_wpfmp_settings_main_error", __( "Invalid action encountered", "wordpress-file-monitor-plus" ), "error" ); 227 break; 228 } 229 } 230 231 187 232 /** 188 233 * Adds settings/manual scan link on plugin list … … 217 262 * much straight forward use of the WordPress Settings API. 218 263 */ 219 static public function admin_settings_menu() {220 $options = get_option(sc_WordPressFileMonitorPlus::$settings_option_field); // get settings221 if( isset($_GET['sc_wpfmp_action'])222 && isset($_GET['page'])223 && current_user_can(SC_WPFMP_ADMIN_ALERT_PERMISSION)224 && "wordpress-file-monitor-plus" == $_GET['page'] )225 {226 switch($_GET['sc_wpfmp_action']) {227 case "sc_wpfmp_scan" :228 do_action(sc_WordPressFileMonitorPlus::$cron_name);229 add_settings_error("sc_wpfmp_settings_main", "sc_wpfmp_settings_main_error", __("Manual scan completed", "wordpress-file-monitor-plus"), "updated");230 break;231 case "sc_wpfmp_reset_settings" :232 delete_option(sc_WordPressFileMonitorPlus::$settings_option_field);233 delete_option(sc_WordPressFileMonitorPlus::$settings_option_field_ver);234 self::settingsUpToDate();235 add_settings_error("sc_wpfmp_settings_main", "sc_wpfmp_settings_main_error", __("Settings reset", "wordpress-file-monitor-plus"), "updated");236 break;237 case "sc_wpfmp_clear_admin_alert" :238 $options['is_admin_alert'] = 0;239 update_option(sc_WordPressFileMonitorPlus::$settings_option_field, $options);240 add_settings_error("sc_wpfmp_settings_main", "sc_wpfmp_settings_main_error", __("Admin alert cleared", "wordpress-file-monitor-plus"), "updated");241 break;242 case "sc_wpfmp_view_alert" :243 $alert_content = sc_WordPressFileMonitorPlus::getPutAlertContent("get");244 echo $alert_content;245 exit;246 break;247 default:248 add_settings_error("sc_wpfmp_settings_main", "sc_wpfmp_settings_main_error", __("Invalid action encountered", "wordpress-file-monitor-plus"), "error");249 break;250 }251 }252 }253 254 264 static public function settings_page() 255 265 { … … 277 287 static public function admin_settings_init() 278 288 { 279 register_setting(sc_WordPressFileMonitorPlus::$settings_option_field, sc_WordPressFileMonitorPlus::$settings_option_field, array(__CLASS__, "sc_wpfmp_settings_validate")); // Register Main Settings 280 add_settings_section("sc_wpfmp_settings_main", __("Settings", "wordpress-file-monitor-plus"), array(__CLASS__, "sc_wpfmp_settings_main_text"), "wordpress-file-monitor-plus"); // Make settings main section 281 add_settings_field("sc_wpfmp_settings_main_cron_method", __("Cron Method", "wordpress-file-monitor-plus"), array(__CLASS__, "sc_wpfmp_settings_main_field_cron_method"), "wordpress-file-monitor-plus", "sc_wpfmp_settings_main"); 282 add_settings_field("sc_wpfmp_settings_main_file_check_interval", __("File Check Interval", "wordpress-file-monitor-plus"), array(__CLASS__, "sc_wpfmp_settings_main_field_file_check_interval"), "wordpress-file-monitor-plus", "sc_wpfmp_settings_main"); 283 add_settings_field("sc_wpfmp_settings_main_data_save", __("Data Save Method", "wordpress-file-monitor-plus"), array(__CLASS__, "sc_wpfmp_settings_main_field_data_save"), "wordpress-file-monitor-plus", "sc_wpfmp_settings_main"); 284 add_settings_field("sc_wpfmp_settings_main_notify_by_email", __("Notify By Email", "wordpress-file-monitor-plus"), array(__CLASS__, "sc_wpfmp_settings_main_field_notify_by_email"), "wordpress-file-monitor-plus", "sc_wpfmp_settings_main"); 285 add_settings_field("sc_wpfmp_settings_main_from_address", __("From Email Address", "wordpress-file-monitor-plus"), array(__CLASS__, "sc_wpfmp_settings_main_field_from_address"), "wordpress-file-monitor-plus", "sc_wpfmp_settings_main"); 286 add_settings_field("sc_wpfmp_settings_main_notify_address", __("Notify Email Address", "wordpress-file-monitor-plus"), array(__CLASS__, "sc_wpfmp_settings_main_field_notify_address"), "wordpress-file-monitor-plus", "sc_wpfmp_settings_main"); 287 add_settings_field("sc_wpfmp_settings_main_display_admin_alert", __("Admin Alert", "wordpress-file-monitor-plus"), array(__CLASS__, "sc_wpfmp_settings_main_field_display_admin_alert"), "wordpress-file-monitor-plus", "sc_wpfmp_settings_main"); 288 add_settings_field("sc_wpfmp_settings_main_file_check_method", __("File Check Method", "wordpress-file-monitor-plus"), array(__CLASS__, "sc_wpfmp_settings_main_field_file_check_method"), "wordpress-file-monitor-plus", "sc_wpfmp_settings_main"); 289 add_settings_field("sc_wpfmp_settings_main_site_root", __("File Check Root", "wordpress-file-monitor-plus"), array(__CLASS__, "sc_wpfmp_settings_main_field_site_root"), "wordpress-file-monitor-plus", "sc_wpfmp_settings_main"); 290 add_settings_field("sc_wpfmp_settings_main_exclude_paths_files", __("Dirs/Files To Ignore", "wordpress-file-monitor-plus"), array(__CLASS__, "sc_wpfmp_settings_main_exclude_paths_files"), "wordpress-file-monitor-plus", "sc_wpfmp_settings_main"); 291 add_settings_field("sc_wpfmp_settings_main_file_extension_mode", __("File Extensions Scan", "wordpress-file-monitor-plus"), array(__CLASS__, "sc_wpfmp_settings_main_field_file_extension_mode"), "wordpress-file-monitor-plus", "sc_wpfmp_settings_main"); 292 add_settings_field("sc_wpfmp_settings_main_file_extensions", __("File Extensions", "wordpress-file-monitor-plus"), array(__CLASS__, "sc_wpfmp_settings_main_field_file_extensions"), "wordpress-file-monitor-plus", "sc_wpfmp_settings_main"); 293 } 294 static public function sc_wpfmp_settings_validate($input) { 295 $valid = get_option(sc_WordPressFileMonitorPlus::$settings_option_field); 296 if(in_array($input['cron_method'], array("wordpress", "other"))) { 289 register_setting( sc_WordPressFileMonitorPlus::$settings_option_field, sc_WordPressFileMonitorPlus::$settings_option_field, array( __CLASS__, "sc_wpfmp_settings_validate" ) ); 290 add_settings_section( "sc_wpfmp_settings_main", __( "Settings", "wordpress-file-monitor-plus" ), array( __CLASS__, "sc_wpfmp_settings_main_text" ), "wordpress-file-monitor-plus" ); 291 add_settings_field( "sc_wpfmp_settings_main_cron_method", __( "Cron Method", "wordpress-file-monitor-plus" ), array( __CLASS__, "sc_wpfmp_settings_main_field_cron_method" ), "wordpress-file-monitor-plus", "sc_wpfmp_settings_main" ); 292 add_settings_field( "sc_wpfmp_settings_main_file_check_interval", __( "File Check Interval", "wordpress-file-monitor-plus" ), array( __CLASS__, "sc_wpfmp_settings_main_field_file_check_interval" ), "wordpress-file-monitor-plus", "sc_wpfmp_settings_main" ); 293 add_settings_field( "sc_wpfmp_settings_main_data_save", __( "Data Save Method", "wordpress-file-monitor-plus" ), array( __CLASS__, "sc_wpfmp_settings_main_field_data_save" ), "wordpress-file-monitor-plus", "sc_wpfmp_settings_main" ); 294 add_settings_field( "sc_wpfmp_settings_main_notify_by_email", __( "Notify By Email", "wordpress-file-monitor-plus" ), array( __CLASS__, "sc_wpfmp_settings_main_field_notify_by_email" ), "wordpress-file-monitor-plus", "sc_wpfmp_settings_main" ); 295 add_settings_field( "sc_wpfmp_settings_main_from_address", __( "From Email Address", "wordpress-file-monitor-plus" ), array( __CLASS__, "sc_wpfmp_settings_main_field_from_address" ), "wordpress-file-monitor-plus", "sc_wpfmp_settings_main" ); 296 add_settings_field( "sc_wpfmp_settings_main_notify_address", __( "Notify Email Address", "wordpress-file-monitor-plus" ), array( __CLASS__, "sc_wpfmp_settings_main_field_notify_address" ), "wordpress-file-monitor-plus", "sc_wpfmp_settings_main" ); 297 add_settings_field( "sc_wpfmp_settings_main_display_admin_alert", __( "Admin Alert", "wordpress-file-monitor-plus" ), array( __CLASS__, "sc_wpfmp_settings_main_field_display_admin_alert" ), "wordpress-file-monitor-plus", "sc_wpfmp_settings_main" ); 298 add_settings_field( "sc_wpfmp_settings_main_file_check_method", __( "File Check Method", "wordpress-file-monitor-plus" ), array( __CLASS__, "sc_wpfmp_settings_main_field_file_check_method" ), "wordpress-file-monitor-plus", "sc_wpfmp_settings_main" ); 299 add_settings_field( "sc_wpfmp_settings_main_site_root", __( "File Check Root", "wordpress-file-monitor-plus" ), array( __CLASS__, "sc_wpfmp_settings_main_field_site_root" ), "wordpress-file-monitor-plus", "sc_wpfmp_settings_main" ); 300 add_settings_field( "sc_wpfmp_settings_main_exclude_paths_files", __( "Dirs/Files To Ignore", "wordpress-file-monitor-plus" ), array( __CLASS__, "sc_wpfmp_settings_main_exclude_paths_files" ), "wordpress-file-monitor-plus", "sc_wpfmp_settings_main" ); 301 add_settings_field( "sc_wpfmp_settings_main_file_extension_mode", __( "File Extensions Scan", "wordpress-file-monitor-plus" ), array( __CLASS__, "sc_wpfmp_settings_main_field_file_extension_mode" ), "wordpress-file-monitor-plus", "sc_wpfmp_settings_main" ); 302 add_settings_field( "sc_wpfmp_settings_main_file_extensions", __( "File Extensions", "wordpress-file-monitor-plus" ), array( __CLASS__, "sc_wpfmp_settings_main_field_file_extensions" ), "wordpress-file-monitor-plus", "sc_wpfmp_settings_main" ); 303 } 304 305 306 static public function sc_wpfmp_settings_validate( $input ) 307 { 308 $valid = get_option( sc_WordPressFileMonitorPlus::$settings_option_field ); 309 310 if( in_array( $input['cron_method'], array( "wordpress", "other" ) ) ) 297 311 $valid['cron_method'] = $input['cron_method']; 298 } else { 299 add_settings_error("sc_wpfmp_settings_main_cron_method", "sc_wpfmp_settings_main_cron_method_error", __("Invalid cron method selected", "wordpress-file-monitor-plus"), "error"); 300 } 301 if("other" == $valid['cron_method']) { // If cron method is other 302 $input['file_check_interval'] = "manual"; // then force scan interval to manual 303 } 304 if(in_array($input['file_check_interval'], self::$frequency_intervals)) { 312 else 313 add_settings_error( "sc_wpfmp_settings_main_cron_method", "sc_wpfmp_settings_main_cron_method_error", __( "Invalid cron method selected", "wordpress-file-monitor-plus" ), "error" ); 314 315 316 if("other" == $valid['cron_method']) 317 $input['file_check_interval'] = "manual"; 318 319 320 if( in_array( $input['file_check_interval'], sc_WordPressFileMonitorPlus::$frequency_intervals ) ) 321 { 305 322 $valid['file_check_interval'] = $input['file_check_interval']; 306 sc_WordPressFileMonitorPlus::enable_cron($input['file_check_interval']); 307 } else { 308 add_settings_error("sc_wpfmp_settings_main_file_check_interval", "sc_wpfmp_settings_main_file_check_interval_error", __("Invalid file check interval selected", "wordpress-file-monitor-plus"), "error"); 309 } 310 if(in_array($input['data_save'], array("database", "file"))) { 323 sc_WordPressFileMonitorPlus::enable_cron( $input['file_check_interval'] ); 324 } else 325 { 326 add_settings_error( "sc_wpfmp_settings_main_file_check_interval", "sc_wpfmp_settings_main_file_check_interval_error", __( "Invalid file check interval selected", "wordpress-file-monitor-plus" ), "error" ); 327 } 328 329 if( in_array( $input['data_save'], array( "database", "file" ) ) ) 311 330 $valid['data_save'] = $input['data_save']; 312 } else {313 add_settings_error( "sc_wpfmp_settings_main_data_save", "sc_wpfmp_settings_main_data_save_error", __("Invalid data save method selected", "wordpress-file-monitor-plus"), "error");314 }331 else 332 add_settings_error( "sc_wpfmp_settings_main_data_save", "sc_wpfmp_settings_main_data_save_error", __( "Invalid data save method selected", "wordpress-file-monitor-plus" ), "error" ); 333 315 334 $sanitized_notify_by_email = absint($input['notify_by_email']); 316 if(1 === $sanitized_notify_by_email || 0 === $sanitized_notify_by_email) { 335 336 if( 1 === $sanitized_notify_by_email || 0 === $sanitized_notify_by_email ) 317 337 $valid['notify_by_email'] = $sanitized_notify_by_email; 318 } else {319 add_settings_error( "sc_wpfmp_settings_main_notify_by_email", "sc_wpfmp_settings_main_notify_by_email_error", __("Invalid notify by email selected", "wordpress-file-monitor-plus"), "error");320 }338 else 339 add_settings_error( "sc_wpfmp_settings_main_notify_by_email", "sc_wpfmp_settings_main_notify_by_email_error", __( "Invalid notify by email selected", "wordpress-file-monitor-plus" ), "error" ); 340 321 341 $sanitized_email_from = sanitize_email($input['from_address']); 322 if(is_email($sanitized_email_from)) { 342 343 if( is_email( $sanitized_email_from ) ) 323 344 $valid['from_address'] = $sanitized_email_from; 324 } else {325 add_settings_error( "sc_wpfmp_settings_main_from_address", "sc_wpfmp_settings_main_from_address_error", __("Invalid from email address entered", "wordpress-file-monitor-plus"), "error");326 }345 else 346 add_settings_error( "sc_wpfmp_settings_main_from_address", "sc_wpfmp_settings_main_from_address_error", __( "Invalid from email address entered", "wordpress-file-monitor-plus" ), "error" ); 347 327 348 $sanitized_email_to = sanitize_email($input['notify_address']); 328 if(is_email($sanitized_email_to)) { 349 350 if( is_email( $sanitized_email_to ) ) 329 351 $valid['notify_address'] = $sanitized_email_to; 330 } else {331 add_settings_error( "sc_wpfmp_settings_main_notify_address", "sc_wpfmp_settings_main_notify_address_error", __("Invalid notify email address entered", "wordpress-file-monitor-plus"), "error");332 }352 else 353 add_settings_error( "sc_wpfmp_settings_main_notify_address", "sc_wpfmp_settings_main_notify_address_error", __( "Invalid notify email address entered", "wordpress-file-monitor-plus" ), "error" ); 354 333 355 $sanitized_display_admin_alert = absint($input['display_admin_alert']); 334 if(1 === $sanitized_display_admin_alert || 0 === $sanitized_display_admin_alert) { 356 357 if( 1 === $sanitized_display_admin_alert || 0 === $sanitized_display_admin_alert ) 335 358 $valid['display_admin_alert'] = $sanitized_display_admin_alert; 336 } else { 337 add_settings_error("sc_wpfmp_settings_main_display_admin_alert", "sc_wpfmp_settings_main_display_admin_alert_error", __("Invalid display admin alert selected", "wordpress-file-monitor-plus"), "error"); 338 } 339 $valid['file_check_method'] = array_map(array(__CLASS__, 'file_check_method_func'), $input['file_check_method']); 340 $sanitized_site_root = realpath($input['site_root']); 341 if(is_dir($sanitized_site_root) && is_readable($sanitized_site_root)) { 359 else 360 add_settings_error( "sc_wpfmp_settings_main_display_admin_alert", "sc_wpfmp_settings_main_display_admin_alert_error", __( "Invalid display admin alert selected", "wordpress-file-monitor-plus" ), "error" ); 361 362 $valid['file_check_method'] = array_map( array( __CLASS__, 'file_check_method_func' ), $input['file_check_method'] ); 363 364 $sanitized_site_root = realpath( $input['site_root'] ); 365 366 if( is_dir( $sanitized_site_root ) && is_readable( $sanitized_site_root ) ) 342 367 $valid['site_root'] = $sanitized_site_root; 343 } else { 344 add_settings_error("sc_wpfmp_settings_main_site_root", "sc_wpfmp_settings_main_site_root_error", __("File check root is not valid. Make sure that PHP has read permissions of the entered file check root", "wordpress-file-monitor-plus"), "error"); 345 } 346 $valid['exclude_paths_files'] = self::textarea_newlines_to_array($input['exclude_paths_files']); 347 $sanitized_file_extension_mode = absint($input['file_extension_mode']); 348 if(2 === $sanitized_file_extension_mode || 1 === $sanitized_file_extension_mode || 0 === $sanitized_file_extension_mode) { 368 else 369 add_settings_error( "sc_wpfmp_settings_main_site_root", "sc_wpfmp_settings_main_site_root_error", __( "File check root is not valid. Make sure that PHP has read permissions of the entered file check root", "wordpress-file-monitor-plus" ), "error" ); 370 371 $valid['exclude_paths_files'] = self::textarea_newlines_to_array( $input['exclude_paths_files'] ); 372 373 $sanitized_file_extension_mode = absint( $input['file_extension_mode'] ); 374 375 if( 2 === $sanitized_file_extension_mode || 1 === $sanitized_file_extension_mode || 0 === $sanitized_file_extension_mode ) 349 376 $valid['file_extension_mode'] = $sanitized_file_extension_mode; 350 } else { 351 add_settings_error("sc_wpfmp_settings_main_file_extension_mode", "sc_wpfmp_settings_main_file_extension_mode_error", __("Invalid file extension mode selected", "wordpress-file-monitor-plus"), "error"); 352 } 353 $valid['file_extensions'] = self::file_extensions_to_array($input['file_extensions']); 377 else 378 add_settings_error( "sc_wpfmp_settings_main_file_extension_mode", "sc_wpfmp_settings_main_file_extension_mode_error", __( "Invalid file extension mode selected", "wordpress-file-monitor-plus" ), "error" ); 379 380 $valid['file_extensions'] = self::file_extensions_to_array( $input['file_extensions'] ); 381 354 382 return $valid; 355 383 } 356 static public function sc_wpfmp_settings_main_text() {} 357 static public function sc_wpfmp_settings_main_field_cron_method() { 358 $options = get_option(sc_WordPressFileMonitorPlus::$settings_option_field); 384 385 386 static public function sc_wpfmp_settings_main_text() 387 { 388 return; 389 } 390 391 392 static public function sc_wpfmp_settings_main_field_cron_method() 393 { 394 $options = get_option( sc_WordPressFileMonitorPlus::$settings_option_field ); 359 395 ?> 360 396 <select name="<?php echo sc_WordPressFileMonitorPlus::$settings_option_field ?>[cron_method]"> 361 <option value="wordpress" <?php selected( $options['cron_method'], "wordpress" ); ?>><?php _e( "WordPress Cron", "wordpress-file-monitor-plus"); ?></option>362 <option value="other" <?php selected( $options['cron_method'], "other" ); ?>><?php _e( "Other Cron", "wordpress-file-monitor-plus"); ?></option>397 <option value="wordpress" <?php selected( $options['cron_method'], "wordpress" ); ?>><?php _e( "WordPress Cron", "wordpress-file-monitor-plus" ); ?></option> 398 <option value="other" <?php selected( $options['cron_method'], "other" ); ?>><?php _e( "Other Cron", "wordpress-file-monitor-plus" ); ?></option> 363 399 </select> 364 400 <div> 365 401 <br /> 366 <span class="description"><?php _e( "Cron Command: ", "wordpress-file-monitor-plus"); ?></span>402 <span class="description"><?php _e( "Cron Command: ", "wordpress-file-monitor-plus" ); ?></span> 367 403 <pre>wget -q "<?php echo site_url(); ?>/index.php?sc_wpfmp_scan=1&sc_wpfmp_key=<?php echo $options['security_key']; ?>" -O /dev/null >/dev/null 2>&1</pre> 368 404 </div> 369 405 <?php 370 406 } 371 static public function sc_wpfmp_settings_main_field_file_check_interval() { 372 $options = get_option(sc_WordPressFileMonitorPlus::$settings_option_field); 407 408 409 static public function sc_wpfmp_settings_main_field_file_check_interval() 410 { 411 $options = get_option( sc_WordPressFileMonitorPlus::$settings_option_field ); 373 412 ?> 374 413 <select name="<?php echo sc_WordPressFileMonitorPlus::$settings_option_field ?>[file_check_interval]"> 375 <option value="<?php echo s elf::$frequency_intervals[0]; ?>" <?php selected( $options['file_check_interval'], self::$frequency_intervals[0] ); ?>><?php _e("Hourly", "wordpress-file-monitor-plus"); ?></option>376 <option value="<?php echo s elf::$frequency_intervals[1]; ?>" <?php selected( $options['file_check_interval'], self::$frequency_intervals[1] ); ?>><?php _e("Twice Daily", "wordpress-file-monitor-plus"); ?></option>377 <option value="<?php echo s elf::$frequency_intervals[2]; ?>" <?php selected( $options['file_check_interval'], self::$frequency_intervals[2] ); ?>><?php _e("Daily", "wordpress-file-monitor-plus"); ?></option>378 <option value="<?php echo s elf::$frequency_intervals[3]; ?>" <?php selected( $options['file_check_interval'], self::$frequency_intervals[3] ); ?>><?php _e("Manual", "wordpress-file-monitor-plus"); ?></option>414 <option value="<?php echo sc_WordPressFileMonitorPlus::$frequency_intervals[0]; ?>" <?php selected( $options['file_check_interval'], sc_WordPressFileMonitorPlus::$frequency_intervals[0] ); ?>><?php _e( "Hourly", "wordpress-file-monitor-plus" ); ?></option> 415 <option value="<?php echo sc_WordPressFileMonitorPlus::$frequency_intervals[1]; ?>" <?php selected( $options['file_check_interval'], sc_WordPressFileMonitorPlus::$frequency_intervals[1] ); ?>><?php _e( "Twice Daily", "wordpress-file-monitor-plus" ); ?></option> 416 <option value="<?php echo sc_WordPressFileMonitorPlus::$frequency_intervals[2]; ?>" <?php selected( $options['file_check_interval'], sc_WordPressFileMonitorPlus::$frequency_intervals[2] ); ?>><?php _e( "Daily", "wordpress-file-monitor-plus" ); ?></option> 417 <option value="<?php echo sc_WordPressFileMonitorPlus::$frequency_intervals[3]; ?>" <?php selected( $options['file_check_interval'], sc_WordPressFileMonitorPlus::$frequency_intervals[3] ); ?>><?php _e( "Manual", "wordpress-file-monitor-plus" ); ?></option> 379 418 </select> 380 419 <?php 381 420 } 382 static public function sc_wpfmp_settings_main_field_data_save() { 383 $options = get_option(sc_WordPressFileMonitorPlus::$settings_option_field); 421 422 423 static public function sc_wpfmp_settings_main_field_data_save() 424 { 425 $options = get_option( sc_WordPressFileMonitorPlus::$settings_option_field ); 384 426 ?> 385 427 <select name="<?php echo sc_WordPressFileMonitorPlus::$settings_option_field ?>[data_save]"> 386 <option value="database" <?php selected( $options['data_save'], "database" ); ?>><?php _e( "Database", "wordpress-file-monitor-plus"); ?></option>387 <option value="file" <?php selected( $options['data_save'], "file" ); ?>><?php _e( "File", "wordpress-file-monitor-plus"); ?></option>428 <option value="database" <?php selected( $options['data_save'], "database" ); ?>><?php _e( "Database", "wordpress-file-monitor-plus" ); ?></option> 429 <option value="file" <?php selected( $options['data_save'], "file" ); ?>><?php _e( "File", "wordpress-file-monitor-plus" ); ?></option> 388 430 </select> 389 431 <?php 390 432 } 391 static public function sc_wpfmp_settings_main_field_notify_by_email() { 392 $options = get_option(sc_WordPressFileMonitorPlus::$settings_option_field); 433 434 435 static public function sc_wpfmp_settings_main_field_notify_by_email() 436 { 437 $options = get_option( sc_WordPressFileMonitorPlus::$settings_option_field ); 393 438 ?> 394 439 <select name="<?php echo sc_WordPressFileMonitorPlus::$settings_option_field ?>[notify_by_email]"> 395 <option value="1" <?php selected( $options['notify_by_email'], 1 ); ?>><?php _e( "Yes", "wordpress-file-monitor-plus"); ?></option>396 <option value="0" <?php selected( $options['notify_by_email'], 0 ); ?>><?php _e( "No", "wordpress-file-monitor-plus"); ?></option>440 <option value="1" <?php selected( $options['notify_by_email'], 1 ); ?>><?php _e( "Yes", "wordpress-file-monitor-plus" ); ?></option> 441 <option value="0" <?php selected( $options['notify_by_email'], 0 ); ?>><?php _e( "No", "wordpress-file-monitor-plus" ); ?></option> 397 442 </select> 398 443 <?php 399 444 } 400 static public function sc_wpfmp_settings_main_field_from_address() { 401 $options = get_option(sc_WordPressFileMonitorPlus::$settings_option_field); 445 446 447 static public function sc_wpfmp_settings_main_field_from_address() 448 { 449 $options = get_option( sc_WordPressFileMonitorPlus::$settings_option_field ); 402 450 ?><input class="regular-text" name="<?php echo sc_WordPressFileMonitorPlus::$settings_option_field ?>[from_address]" value="<?php echo $options['from_address']; ?>" /><?php 403 451 } 404 static public function sc_wpfmp_settings_main_field_notify_address() { 405 $options = get_option(sc_WordPressFileMonitorPlus::$settings_option_field); 452 453 454 static public function sc_wpfmp_settings_main_field_notify_address() 455 { 456 $options = get_option( sc_WordPressFileMonitorPlus::$settings_option_field ); 406 457 ?><input class="regular-text" name="<?php echo sc_WordPressFileMonitorPlus::$settings_option_field ?>[notify_address]" value="<?php echo $options['notify_address']; ?>" /><?php 407 458 } 408 static public function sc_wpfmp_settings_main_field_display_admin_alert() { 409 $options = get_option(sc_WordPressFileMonitorPlus::$settings_option_field); 459 460 461 static public function sc_wpfmp_settings_main_field_display_admin_alert() 462 { 463 $options = get_option( sc_WordPressFileMonitorPlus::$settings_option_field ); 410 464 ?> 411 465 <select name="<?php echo sc_WordPressFileMonitorPlus::$settings_option_field ?>[display_admin_alert]"> 412 <option value="1" <?php selected( $options['display_admin_alert'], 1 ); ?>><?php _e( "Yes", "wordpress-file-monitor-plus"); ?></option>413 <option value="0" <?php selected( $options['display_admin_alert'], 0 ); ?>><?php _e( "No", "wordpress-file-monitor-plus"); ?></option>466 <option value="1" <?php selected( $options['display_admin_alert'], 1 ); ?>><?php _e( "Yes", "wordpress-file-monitor-plus" ); ?></option> 467 <option value="0" <?php selected( $options['display_admin_alert'], 0 ); ?>><?php _e( "No", "wordpress-file-monitor-plus" ); ?></option> 414 468 </select> 415 469 <?php 416 470 } 417 static public function sc_wpfmp_settings_main_field_file_check_method() { 418 $options = get_option(sc_WordPressFileMonitorPlus::$settings_option_field); 419 ?> 420 <input name="<?php echo sc_WordPressFileMonitorPlus::$settings_option_field ?>[file_check_method][size]" type="checkbox" value="1" <?php checked( $options['file_check_method']['size'], 1 ); ?> /><?php _e(" File Size", "wordpress-file-monitor-plus"); ?><br /> 421 <input name="<?php echo sc_WordPressFileMonitorPlus::$settings_option_field ?>[file_check_method][modified]" type="checkbox" value="1" <?php checked( $options['file_check_method']['modified'], 1 ); ?> /><?php _e(" Date Modified", "wordpress-file-monitor-plus"); ?><br /> 422 <input name="<?php echo sc_WordPressFileMonitorPlus::$settings_option_field ?>[file_check_method][md5]" type="checkbox" value="1" <?php checked( $options['file_check_method']['md5'], 1 ); ?> /><?php _e(" File Hash", "wordpress-file-monitor-plus"); ?> 423 <?php 424 } 425 static public function sc_wpfmp_settings_main_field_site_root() { 426 $options = get_option(sc_WordPressFileMonitorPlus::$settings_option_field); 427 ?><input name="<?php echo sc_WordPressFileMonitorPlus::$settings_option_field ?>[site_root]" value="<?php echo $options['site_root']; ?>" /> <span class="description"><?php printf(__("Default: %s", "wordpress-file-monitor-plus"), realpath(ABSPATH)); ?></span><?php 428 } 429 static public function sc_wpfmp_settings_main_exclude_paths_files() { 430 $options = get_option(sc_WordPressFileMonitorPlus::$settings_option_field); 471 472 473 static public function sc_wpfmp_settings_main_field_file_check_method() 474 { 475 $options = get_option( sc_WordPressFileMonitorPlus::$settings_option_field ); 476 ?> 477 <input name="<?php echo sc_WordPressFileMonitorPlus::$settings_option_field ?>[file_check_method][size]" type="checkbox" value="1" <?php checked( $options['file_check_method']['size'], 1 ); ?> /><?php _e( " File Size", "wordpress-file-monitor-plus" ); ?><br /> 478 <input name="<?php echo sc_WordPressFileMonitorPlus::$settings_option_field ?>[file_check_method][modified]" type="checkbox" value="1" <?php checked( $options['file_check_method']['modified'], 1 ); ?> /><?php _e( " Date Modified", "wordpress-file-monitor-plus" ); ?><br /> 479 <input name="<?php echo sc_WordPressFileMonitorPlus::$settings_option_field ?>[file_check_method][md5]" type="checkbox" value="1" <?php checked( $options['file_check_method']['md5'], 1 ); ?> /><?php _e( " File Hash", "wordpress-file-monitor-plus" ); ?> 480 <?php 481 } 482 483 484 static public function sc_wpfmp_settings_main_field_site_root() 485 { 486 $options = get_option( sc_WordPressFileMonitorPlus::$settings_option_field ); 487 ?><input name="<?php echo sc_WordPressFileMonitorPlus::$settings_option_field ?>[site_root]" value="<?php echo $options['site_root']; ?>" /> <span class="description"><?php printf(__( "Default: %s", "wordpress-file-monitor-plus" ), realpath(ABSPATH)); ?></span><?php 488 } 489 490 491 static public function sc_wpfmp_settings_main_exclude_paths_files() 492 { 493 $options = get_option( sc_WordPressFileMonitorPlus::$settings_option_field ); 431 494 ?><textarea name="<?php echo sc_WordPressFileMonitorPlus::$settings_option_field ?>[exclude_paths_files]" cols="60" rows="8"><?php echo implode("\n", $options['exclude_paths_files']); ?></textarea><?php 432 495 } 433 static public function sc_wpfmp_settings_main_field_file_extension_mode() { 434 $options = get_option(sc_WordPressFileMonitorPlus::$settings_option_field); 496 497 498 static public function sc_wpfmp_settings_main_field_file_extension_mode() 499 { 500 $options = get_option( sc_WordPressFileMonitorPlus::$settings_option_field ); 435 501 ?> 436 502 <select name="<?php echo sc_WordPressFileMonitorPlus::$settings_option_field ?>[file_extension_mode]"> 437 <option value="0" <?php selected( $options['file_extension_mode'], 0 ); ?>><?php _e( "Disabled", "wordpress-file-monitor-plus"); ?></option>438 <option value="1" <?php selected( $options['file_extension_mode'], 1 ); ?>><?php _e( "Exclude files that have an extension listed below", "wordpress-file-monitor-plus"); ?></option>439 <option value="2" <?php selected( $options['file_extension_mode'], 2 ); ?>><?php _e( "Only scan files that have an extension listed below", "wordpress-file-monitor-plus"); ?></option>503 <option value="0" <?php selected( $options['file_extension_mode'], 0 ); ?>><?php _e( "Disabled", "wordpress-file-monitor-plus" ); ?></option> 504 <option value="1" <?php selected( $options['file_extension_mode'], 1 ); ?>><?php _e( "Exclude files that have an extension listed below", "wordpress-file-monitor-plus" ); ?></option> 505 <option value="2" <?php selected( $options['file_extension_mode'], 2 ); ?>><?php _e( "Only scan files that have an extension listed below", "wordpress-file-monitor-plus" ); ?></option> 440 506 </select> 441 507 <?php 442 508 } 443 static public function sc_wpfmp_settings_main_field_file_extensions() { 444 $options = get_option(sc_WordPressFileMonitorPlus::$settings_option_field); 445 ?><input class="regular-text" name="<?php echo sc_WordPressFileMonitorPlus::$settings_option_field ?>[file_extensions]" value="<?php echo implode($options['file_extensions'], "|"); ?>" /> <span class="description"><?php _e("Separate extensions with | character.", "wordpress-file-monitor-plus"); ?></span><?php 446 } 447 448 static protected function file_check_method_func($n) { 449 $n = absint($n); 450 if(1 !== $n) { $n = 0; } 509 510 511 static public function sc_wpfmp_settings_main_field_file_extensions() 512 { 513 $options = get_option( sc_WordPressFileMonitorPlus::$settings_option_field ); 514 ?><input class="regular-text" name="<?php echo sc_WordPressFileMonitorPlus::$settings_option_field ?>[file_extensions]" value="<?php echo implode($options['file_extensions'], "|" ); ?>" /> <span class="description"><?php _e( "Separate extensions with | character.", "wordpress-file-monitor-plus" ); ?></span><?php 515 } 516 517 518 /** 519 * Anything not a 1 is made 0 520 * 521 * @param int $n value to check 522 * @return int $n value as 1 or 0 523 */ 524 static protected function file_check_method_func( $n ) 525 { 526 $n = absint( $n ); 527 528 if( 1 !== $n ) 529 $n = 0; 530 451 531 return $n; 452 532 } … … 459 539 * @return array $output 460 540 */ 461 static protected function textarea_newlines_to_array($input) { 462 $output = (array) explode("\n", $input); // Split textarea input by new lines 463 $output = array_map('trim', $output); // trim whitespace off end of line. 464 $output = array_filter($output); // remove empty lines from array 465 return $output; // return array. 541 static protected function textarea_newlines_to_array( $input ) 542 { 543 $output = (array) explode( "\n", $input ); // Split textarea input by new lines 544 $output = array_map( 'trim', $output ); // trim whitespace off end of line. 545 $output = array_filter( $output ); // remove empty lines from array 546 return $output; 466 547 } 467 548 … … 473 554 * @return array $output 474 555 */ 475 static protected function file_extensions_to_array($input) { 476 $output = strtolower($input); // set all to lower case 477 $output = preg_replace("/[^a-z0-9|]+/", "", $output); // strip characters that cannot make up valid extension 478 $output = (array) explode("|", $output); // Split into array 479 $output = array_filter($output); // remove empty entries from array 556 static protected function file_extensions_to_array( $input ) 557 { 558 $output = strtolower( $input ); // set all to lower case 559 $output = preg_replace( "/[^a-z0-9|]+/", "", $output ); // strip characters that cannot make up valid extension 560 $output = (array) explode( "|", $output ); // Split into array 561 $output = array_filter( $output ); // remove empty entries from array 480 562 return $output; 481 563 }
Note: See TracChangeset
for help on using the changeset viewer.