Invalid API Key '.$apikey1on1secure.''; $count = 0; } else { //they have entered their api key - now verify it $apiurl = 'https://api.1on1secure.com/?action=register&apitoken='.$apikey1on1secure.'&domain='.$homeurl; $response = wp_remote_get($apiurl, array('timeout' => 2)); $body = wp_remote_retrieve_body( $response ); $apianswers = json_decode($body, true); //used to debug communication errors // $myipurl = 'http://checkip.dyndns.org/'; // $myipresponse = wp_remote_get($myipurl, array('timeout' => 5)); // $myipbody = wp_remote_retrieve_body($myipresponse); // $myipanswer = json_decode($myipbody, true); if ($apianswers) { if ($apianswers['response'] == 'success') { if (!add_option('APIKey1on1Secure', $apikey1on1secure)) { update_option('APIKey1on1Secure', $apikey1on1secure); } $count = 1; } else { $message = '
API Error: '.$apianswers['errmsg'].'
'; $count = 0; } } else { $message = '
Unable to contact registration server.
'; $count = 0; } } if (!add_option('OnlyUSAVisitor1on1Secure', $visitorvalue1on1secure)) { update_option('OnlyUSAVisitor1on1Secure', $visitorvalue1on1secure); } if (!add_option('TorUser1on1Secure', $toruser1on1secure)) { update_option('TorUser1on1Secure', $toruser1on1secure); } if (!add_option('DataAnalysis1on1Secure', $dataanalysis1on1secure)) { update_option('DataAnalysis1on1Secure', $dataanalysis1on1secure); } if (!add_option('ActionForBadIPs1on1Secure', $actionforbadips1on1secure)) { update_option('ActionForBadIPs1on1Secure', $actionforbadips1on1secure); } if (!add_option('ErrorPageForBadIPs1on1Secure', $errorpageforbadips1on1secure)) { update_option('ErrorPageForBadIPs1on1Secure', $errorpageforbadips1on1secure); } if($count > 0) { $message = '
Congratulations You Are Ready To Go!
'; } } DisplayAdminSettingPanelsOneOn1Secure($message); } } if (! function_exists('DisplayAdminSettingPanelsOneOn1Secure')) { function DisplayAdminSettingPanelsOneOn1Secure($message) { $apikey = sanitize_text_field(get_option("APIKey1on1Secure")); //sanitize the input to check the API key if (strlen($apikey) < 16) { //if the api key is not added of first time install the plugin DisplayAPISettingPageOneOn1Secure($message); //show the setting page with the register link } else { DisplayDashboardPanelOneOn1Secure($message); //display the Graph, Last 5 bad IP, Hit Log Report and Settings boxes. } } } if (! function_exists('DisplayAPISettingPageOneOn1Secure')) { function DisplayAPISettingPageOneOn1Secure($message) { DisplayAdminSettingHeaderOneOn1Secure($message); ?>

Settings

Get API Key



  1on1 Secure API Settings


'.wp_kses_post($errorpage['name']).''; } return $thereturn_clean; } } if (! function_exists('Display1on1SecureAdmin')) { function Display1on1SecureAdmin($message) { // wp_enqueue_script('1on1secure-wp-admin-js', plugins_url('../js/1on1secure-wp-admin.js?a=2', __FILE__), array('jquery'), null, true); // wp_enqueue_style('1on1secure-wp-admin-css', plugins_url('../css/1on1secure-wp-admin.css', __FILE__)); $dataanalysis = absint(get_option("DataAnalysis1on1Secure")); //sanitize the input $actionforbadips = absint(get_option("ActionForBadIPs1on1Secure")); //sanitize the input $errorpageipsdropdowndefault = absint(get_option("ErrorPageForBadIPs1on1Secure")); //sanitize the input $onlyusavisitor = absint(get_option("OnlyUSAVisitor1on1Secure")); //sanitize the input $toruser = absint(get_option("TorUser1on1Secure")); //sanitize the input $apikey = sanitize_text_field(get_option("APIKey1on1Secure")); //sanitize the input ?>

Settings

API Key
Get API Key'; } ?>
0) { print 'checked'; } ?>> Only allow USA visitors
0) { print 'checked'; } ?>> Block Tor Users
0) { print 'checked'; } ?> onclick="popupOneOn1Secure()"> opt-out of data analysis
Action for bad ips:

'; } else { print '

Protected:

Protected Site:

Last 7 Days

Graph is Not Available. Please reload the page.
'; return; //exit the function } $totalhits = $userdata['graph'][0]['thecount'] + $userdata['graph'][1]['thecount']; //calculate the total hits $chartdata[] = array('name', 'Hits'); //set the chart data Header foreach ($userdata['graph'] as $piechartdatalist => $piechartarray) { $chartdata[] = array($piechartarray['name'], (int)$piechartarray['thecount']); //add the value to the array } $piechartdataarray = array('piechartvalue' => $chartdata); //set the format before sending to the JS wp_localize_script('1on1secure-admin', 'piechartdataarray', $piechartdataarray); //send the data to JS with WP function print '

'.'Blocked IPs: '.'  '.number_format($userdata['graph'][0]['thecount']).'
'.'Clean IPs: '.'  '.number_format($userdata['graph'][1]['thecount']).'
'.'Total Hits: '.'  '.number_format($totalhits).'
'; //} } } if (! function_exists('DisplayLastFiveBadIPTableOneOn1Secure')) { function DisplayLastFiveBadIPTableOneOn1Secure($userdata) { ?>

Blocked IPs

See more
Blocked IP report is Not Available. Please reload the page.
'; return; //exit the function } if (empty($userdata['fivebadip'][0])) { //if there is no data // print ' //
//
Blocked IP report contains no data at this time.
//
'; ?>
IP Date  Classification URL
- - - -
format('F j, Y')."
".$date->format('h:i a'); //change the data and time format } // Create the table print '
'; foreach ($userdata['fivebadip'] as $row) { print ' '; } print '
IP Date  Classification URL
'.$row['ip'].' '.$row['stamp'].' '.$row['description'].' '.$row['urlhit'].'
'; } } } if (! function_exists('DisplayHitLogReportOneOn1Secure')) { function DisplayHitLogReportOneOn1Secure($userdata) { ?>

Website Hits Report

Website Hits Report is Not Available. Please reload the page.
'; return; //exit the function } $hitlogchartdata[] = array('Date', 'Hits'); //set the chart data Header foreach ($userdata['hitlogreport'] as $hitlogname => $hitloglists) { $hitlognames[] = $hitlogname; foreach ($hitloglists as $hitlogdate => $hitloglist) { $date = date('M d', strtotime($hitloglist['date'] ?? '')); //set the date format if (isset($hitloglist['count'])) { $hitlogchartdata[$hitlogname][] = array($date, (int)$hitloglist['count']); //add the data into the chart } else { $hitlogchartdata[$hitlogname][] = array($date, 0); //fix the undefined array error } } } //set the format before sending to the JS $hitlogchartdataarray = array( 'hitlogchartvalue' => $hitlogchartdata, 'hitlognames' => $hitlognames ); wp_localize_script('1on1secure-admin', 'hitlogchartdataarray', $hitlogchartdataarray); //send the data to JS with WP function //dropdown classification print ' '; //display the chart foreach ($userdata['hitlogreport'] as $hitlogname => $hitloglist) { print '
'; } //} } } if (! function_exists('GetDashboardDataAPIOneOn1Secure')) { function GetDashboardDataAPIOneOn1Secure() { $apikey = sanitize_text_field(get_option("APIKey1on1Secure")); //get the API key $homeurl = sanitize_url(get_site_url()); //sanitize the site URL //get the data from the API $apiurl = 'https://api.1on1secure.com/myaccount.php?action=allstatssummary&apitoken='.$apikey.'&domain='.$homeurl; $response = wp_remote_get($apiurl, array('timeout' => 9)); if (is_wp_error($response)) { //if there is an error, show it $apidata['error'] = '1on1secure Error {DMK-441} : '.$response->get_error_message(); } else if (wp_remote_retrieve_response_code($response) != 200 ) { $apidata['error'] = '1on1secure Error {DMK-441} : '.wp_remote_retrieve_response_code($response); } else { $body = wp_remote_retrieve_body($response); //if there is no error, get the data $apidata = json_decode($body, true); } return $apidata; } } ?>