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!
';
}
}
DisplayDashboardPanelOneOn1Secure($message); //display the Graph, Last 5 bad IP, Hit Log Report and Settings boxes.
}
}
if (! function_exists('DisplayDashboardPanelOneOn1Secure')) {
function DisplayDashboardPanelOneOn1Secure($message) {
$oneononesecurelogo = plugins_url( '../images/1on1securelogo70.png', __FILE__ ); //add the image url
?>
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
?>
';
return; //exit the function
}
$totalhits = $piechartdata['graph'][0]['thecount'] + $piechartdata['graph'][1]['thecount']; //calculate the total hits
$chartdata[] = array('name', 'Hits'); //set the chart data Header
foreach ($piechartdata['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 IP report is Not Available. Please reload the page.
';
return; //exit the function
}
foreach ($fivebadIPdata['fivebadip'] as &$record) { //get the value in the array
$date = new DateTime($record['stamp']); //create a new DateTime object
$record['stamp'] = $date->format('F j, Y')." ".$date->format('h:i a'); //change the data and time format
}
// Create the table
print '
IP
Date
Classification
URL
';
foreach ($fivebadIPdata['fivebadip'] as $row) {
print '
'.$row['ip'].'
'.$row['stamp'].'
'.$row['description'].'
'.$row['urlhit'].'
';
}
print '
';
}
}
if (! function_exists('DisplayHitLogReportOneOn1Secure')) {
function DisplayHitLogReportOneOn1Secure() {
?>
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 ($hitlogdata['hitlogreport'] as $hitlogname => $hitloglists) {
$hitlognames[] = $hitlogname;
foreach ($hitloglists as $hitlogdate => $hitloglist) {
$date = date('M d', strtotime($hitloglist['date'])); //set the date format
$hitlogchartdata[$hitlogname][] = array($date, (int)$hitloglist['count']); //add the data into the chart
}
}
//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 ($hitlogdata['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=getdata&apitoken='.$apikey.'&domain='.$homeurl;
$response = wp_remote_get($apiurl, array('timeout' => 3));
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;
}
}
?>