active_tab = sanitize_text_field($_GET[ 'tab' ]); } else { $this->active_tab = ADS_ID_PAGE1; } } // Add options page public function add_plugin_page() { // This page will be under "Settings" add_menu_page( "Site Counter", "Site Counter", "manage_options", ADS_ID_SETTINGS, array( $this, 'create_admin_page'), ADS_IMAGE_URL.'icon16.png' ); //add_options_page(__('Settings', ADS_TEXT_DOMAIN),__('Settings', ADS_TEXT_DOMAIN),'manage_options', ADS_ID_SETTINGS, array( $this, 'create_admin_page' )); } // Options page callback public function create_admin_page() { // Set class property $this->mGeneral = adswsc_GetOptions( ADS_OPTIONS_GENERAL ); if( isset( $_GET[ 'tab' ] ) ) { $this->active_tab = sanitize_text_field($_GET[ 'tab' ]); } else { $this->active_tab = ADS_ID_PAGE1; } ?>

icon

active_tab == ADS_ID_PAGE1 ) { settings_fields( ADS_ID_GROUP ); do_settings_sections( ADS_ID_PAGE1 ); submit_button(); } else if( $this->active_tab == ADS_ID_PAGE2 ) { settings_fields( ADS_ID_GROUP ); do_settings_sections( ADS_ID_PAGE2 ); submit_button(); } else if( $this->active_tab == ADS_ID_PAGE3) { settings_fields( ADS_ID_GROUP ); do_settings_sections( ADS_ID_PAGE3 ); submit_button(); } else if( $this->active_tab == ADS_ID_PAGE4) { settings_fields( ADS_ID_GROUP ); do_settings_sections( ADS_ID_PAGE4 ); } else if( $this->active_tab == ADS_ID_PAGE5) { settings_fields( ADS_ID_GROUP ); do_settings_sections( ADS_ID_PAGE5 ); } else if( $this->active_tab == ADS_ID_PAGE6) { settings_fields( ADS_ID_GROUP ); do_settings_sections( ADS_ID_PAGE6 ); } print '
'; print __('Translated by: ad-software', ADS_TEXT_DOMAIN); print '
'; ?>
'Counter' ) ); add_settings_field( 'Reset', // ID __('Set Counter to Default Value', ADS_TEXT_DOMAIN), // Title array( $this, 'callback_reset' ), // Callback ADS_ID_PAGE1, // Page ADS_ID_SEC1, // Section array( 'label_for' => 'Reset' ) ); add_settings_field( 'CycleTime', // ID __('Visitor-hit cooldown', ADS_TEXT_DOMAIN), // Title array( $this, 'callback_Cycletime' ), // Callback ADS_ID_PAGE1, // Page ADS_ID_SEC1, // Section array( 'label_for' => 'CycleTime' ) ); //PAGE 2 #================================================= add_settings_section( ADS_ID_SEC1, // ID __('Cleanup Settings', ADS_TEXT_DOMAIN), // Title array( $this, 'print_info_nix' ), // Callback ADS_ID_PAGE2 // Page ); add_settings_field( 'Cleanup', // ID __('Cleanup intervall', ADS_TEXT_DOMAIN), // Title array( $this, 'callback_Cleanup' ), // Callback ADS_ID_PAGE2, // Page ADS_ID_SEC1, // Section array( 'label_for' => 'Cleanup' ) ); add_settings_field( 'DeleteTime', // ID __('Max age of the IP to remove', ADS_TEXT_DOMAIN), // Title array( $this, 'callback_Deletetime' ), // Callback ADS_ID_PAGE2, // Page ADS_ID_SEC1, // Section array( 'label_for' => 'DeleteTime' ) ); add_settings_field( 'Bots', // ID __('Defines a comma-separated list of Robots, which prevents a count', ADS_TEXT_DOMAIN), // Title array( $this, 'callback_bots' ), // Callback ADS_ID_PAGE2, // Page ADS_ID_SEC1, // Section array( 'label_for' => 'Bots' ) ); //PAGE 3 #================================================= add_settings_section( ADS_ID_SEC1, // ID __('Short dashboard statistics', ADS_TEXT_DOMAIN), // Title array( $this, 'print_info_nix' ), // Callback ADS_ID_PAGE3 // Page ); add_settings_field( 'PageTime', // ID __('Page-hit cooldown', ADS_TEXT_DOMAIN), // Title array( $this, 'callback_Pagetime' ), // Callback ADS_ID_PAGE3, // Page ADS_ID_SEC1, // Section array( 'label_for' => 'PageTime' ) ); add_settings_section( ADS_ID_SEC1, // ID '', // Title array( $this, 'print_info_help' ), // Callback ADS_ID_PAGE4 // Page ); add_settings_section( ADS_ID_SEC1, // ID '', // Title array( $this, 'print_info_help2' ), // Callback ADS_ID_PAGE5 // Page ); add_settings_section( ADS_ID_SEC1, // ID '', // Title array( $this, 'print_info_help3' ), // Callback ADS_ID_PAGE6 // Page ); } // Sanitize each setting field as needed // @param array $input Contains all settings fields as array keys public function validate_general( $input ) { $DoReset = ''; $temp = adswsc_GetOptions( ADS_OPTIONS_GENERAL ); //PAGE 1 //counter if ( isset( $input['Counter'] ) ) $temp['Counter'] = absint( $input['Counter'] ); //reset counter if ( isset( $input['Reset'] ) ) $DoReset = ($input['Reset'] == 'on' ? 'on' : '' ); //cycle if ( isset( $input['CycleSec'] ) || isset( $input['CycleMin'] ) || isset( $input['CycleHou'] )) { $t = 0; if ( isset( $input['CycleSec'] ) ) $t += (absintminmax($input['CycleSec'],0,59)); if ( isset( $input['CycleMin'] ) ) $t += (absintminmax($input['CycleMin'], 0, 59) * 60 ); if ( isset( $input['CycleHou'] ) ) $t += (absintminmax($input['CycleHou'], 0, 24) * 3600); if ($t >= 30 && $t <= (24*3600)) $temp['CycleTime'] = $t; else add_settings_error('validate_general', esc_attr( '' ), __('only 30 sec. to 24 hour supported on cyle time', ADS_TEXT_DOMAIN), 'error'); } //PAGE 2 //cleanup $DoCleanup = ''; if ( isset( $input['CleanupNow'] ) ) $DoCleanup = ($input['CleanupNow'] == 'on' ? 'on' : '' ); //cleanup time if ( isset( $input['CleanupD'] ) || isset( $input['CleanupM'] ) ) { $t = 0; if( isset( $input['CleanupD'] ) ) $t += absint($input['CleanupD'])*24*3600; if( isset( $input['CleanupM'] ) ) $t += absint($input['CleanupM'])*30*24*3600; if ($t >= (24*3600) && $t <= (6*30*24*3600) ) $temp['CleanupTime'] = $t; else add_settings_error('main', ' ' , sprintf(__('( Enter cleanup interval from 1 days to 6 months )', ADS_TEXT_DOMAIN).'
' )); } //delete IP if ( isset( $input['DeleteDay'] ) || isset( $input['DeleteMon'] ) ) { $t = 0; if( isset( $input['DeleteDay'] ) ) $t += absint($input['DeleteDay'])*24*3600; if( isset( $input['DeleteMon'] ) ) $t += absint($input['DeleteMon'])*30*24*3600; if ($t >= (6*24*3600) && $t <= (9*30*24*3600) ) $temp['DeleteTime'] = $t; else add_settings_error('validate_general', esc_attr( '' ), __('only 6 day to 9 months supported on cleanup', ADS_TEXT_DOMAIN), 'error'); } // bots if( isset( $input['Bots'] ) ) $temp['Bots'] = htmlspecialchars($input['Bots']); //PAGE 3 if ( isset( $input['PageOn'] ) ) $temp['PageOn'] = ($input['PageOn'] == 'on' ? 'on' : ''); if ( isset( $input['PageSec'] ) || isset( $input['PageMin'] ) ) { $t = 0; if ( isset( $input['PageSec'] ) ) $t += (absintminmax($input['PageSec'],0,59)); if ( isset( $input['PageMin'] ) ) $t += (absintminmax($input['PageMin'], 0, 60)*60); if ($t >= 30 && $t <= (3600)) $temp['PageTime'] = $t; else add_settings_error('validate_general', esc_attr( '' ), __('only 30 sec. to 1 hour supported on cyle time', ADS_TEXT_DOMAIN), 'error'); } //reset counter if ( $DoReset == 'on' ) { adswsc_ResetCounter($temp['Counter']); $temp['LastReset'] = current_time('timestamp'); add_settings_error('main', ' ' , sprintf(__('( Counter reseted to %s )', ADS_TEXT_DOMAIN).'
', $temp['Counter']), 'updated'); } //Cleanup if ( $DoCleanup == 'on' ) { adswsc_CleanUp($temp['DeleteTime']); $temp['Cleanup'] = current_time('timestamp') + $temp['CleanupTime']; add_settings_error('main', ' ' , __('( outdated hits were cleaned )', ADS_TEXT_DOMAIN).'
', 'updated'); } if ($temp['CleanupTime'] > $temp['DeleteTime']) add_settings_error('main', ' ' , __('WARNING: Cleanup time should be less than IP age', ADS_TEXT_DOMAIN).'
', 'updated'); return $temp; } // Print the Section text #================================================= public function print_info_nix() { //printf } #================================================= public function print_info_help(){ ?>



"; for($x = 0; $x < sizeof($FILES); $x++) { echo "".basename($FILES[$x]).""; echo "".do_shortcode("[ads-wpsitecount image=".basename($FILES[$x])." imgmaxw='100' width=120 whunit='px' height=0 block='' count=1234 ]").""; if ((($x+1) % 4) == 0) echo ""; } echo ""; ?>

%s', ADS_OPTIONS_GENERAL, isset( $this->mGeneral['Bots'] ) ? esc_attr( $this->mGeneral['Bots']) : ''); printf('
'.__('Example (copy & paste), white-space are removed on search:',ADS_TEXT_DOMAIN).'
'. 'Google, msnbot, Rambler, Yahoo, AbachoBOT, Accoona, AcoiRobot, ASPSeek, Bing, CrocCrawler,'. ' Dumbot, FAST-WebCrawler, GeonaBot, Gigabot, Lycos, MSRBOT, Scooter, Altavista, IDBot,'. ' eStyle, Scrubby, facebookexternalhit, bot, robot'); } public function callback_counter() { printf('', ADS_OPTIONS_GENERAL, isset( $this->mGeneral['Counter'] ) ? esc_attr( $this->mGeneral['Counter']) : '0'); global $wpdb; $table_name = $wpdb->prefix.ADS_PAGEFILE; $count = $wpdb->get_var("SELECT Count FROM $table_name where IP='0'"); printf(" ".__('( actual count: %s )', ADS_TEXT_DOMAIN), $count); } public function callback_reset() { printf('', ADS_OPTIONS_GENERAL); printf(" ".__('( Last Reset on: %s )', ADS_TEXT_DOMAIN), date('Y.m.d H:i:s', $this->mGeneral['LastReset'])); print '
'.__('The counter is reset when saving with the above default counter value', ADS_TEXT_DOMAIN); } public function callback_Cycletime() { $t = absint( $this->mGeneral['CycleTime'] ); $h = absint($t / 3600); $m = absint(($t - ($h*3600)) / 60); $s = absint(($t - ($h*3600) - ($m*60))); printf(':', ADS_OPTIONS_GENERAL, $h); printf(':', ADS_OPTIONS_GENERAL, $m); printf(' '.__('( Time, H:M:S )', ADS_TEXT_DOMAIN), ADS_OPTIONS_GENERAL, $s); printf("
".__('supports 30 sec. to 24 hours on ip cycle', ADS_TEXT_DOMAIN)); } public function callback_Pagetime() { $t = absint( $this->mGeneral['PageTime'] ); $m = absint($t / 60); $s = absint($t % 60); printf('', ADS_OPTIONS_GENERAL ); printf('%s
', ADS_OPTIONS_GENERAL, $this->mGeneral['PageOn'] == 'on' ? 'checked' : '', __('Statistic ON',ADS_TEXT_DOMAIN)); printf(':', ADS_OPTIONS_GENERAL, $m); printf(' '.__('( Time, M:S )', ADS_TEXT_DOMAIN), ADS_OPTIONS_GENERAL, $s); printf('
'. __('supports 30 sec. to 1 Hour on page cycle', ADS_TEXT_DOMAIN)); } public function callback_Deletetime() { $t = absint( $this->mGeneral['DeleteTime'] ); $m = absint($t / (30*24*3600)); $d = absint(($t - ($m*30*24*3600)) / (24*3600) ); printf(':', ADS_OPTIONS_GENERAL, $m); printf(' '.__('( Month / Day )',ADS_TEXT_DOMAIN), ADS_OPTIONS_GENERAL, $d); printf('
'. __('supports 6 day to 9 months to start cleanup', ADS_TEXT_DOMAIN)); } public function callback_Cleanup() { $t = absint( $this->mGeneral['CleanupTime'] ); $m = absint($t / (30*24*3600)); $d = absint(($t - ($m*30*24*3600)) / (24*3600) ); printf(':', ADS_OPTIONS_GENERAL, $m); printf(' '.__('( Month / Day )',ADS_TEXT_DOMAIN), ADS_OPTIONS_GENERAL, $d); printf('   '.__('cleanup !now! ( next at %s )', ADS_TEXT_DOMAIN), ADS_OPTIONS_GENERAL, date_i18n( get_option( 'date_format' ), $this->mGeneral['Cleanup'])); printf('
'. __('supports 1 day to 6 months on cleanup', ADS_TEXT_DOMAIN)); printf('
'. __('cleanup time should be less than IP age', ADS_TEXT_DOMAIN)); } } if( is_admin() ) $ads_SettingsPage = new adswsc_clsSettingsPage(); ?>