Settings'; //add link to the plugin setting array_unshift($links, $settings_link); return $links; } } if (! function_exists('OneOn1SecureAdminSettingsPage')) { function OneOn1SecureAdminSettingsPage() { //add the plugin on the sidebar $oneononesecureicon = plugins_url( '../images/1on1secureicon18.png', __FILE__ ); //add the image url add_menu_page( '1on1 Secure Plugin', '1on1 Secure', 'manage_options', '1on1-secure-settings', 'oneon1secure_admin_settings_page_content', $oneononesecureicon, 110 ); } add_action('admin_enqueue_scripts', 'OneOn1Secure_enqueue_styles'); //add style in the admin page } if (! function_exists('CheckVisitorWith1On1Secure')) { function CheckVisitorWith1On1Secure() { $apikey = sanitize_key(get_option("APIKey1on1Secure")); //sanitize the input $torboolean = absint(get_option("toruser1on1secure")); //sanitize the input $redirpageid = absint(get_option("errorpageforbadips1on1secure")); //sanitize the input $redirectoption = absint(get_option("actionforbadips1on1secure")); //sanitize the input $homeurl = sanitize_url(get_site_url()); //sanitize the input $visitingip = GetIPAddress1on1Secure(); if (is_admin()) { return; } //they are in the admin, don't do a security lookup if ( (get_queried_object_id() == $redirpageid) && ($redirpageid > 0) ) { return; } //TODO: use this later to only restrict access to specific pages as user defined in settings if (get_transient('1on1secure_'.$visitingip) > 0) { // print "cached approval"; return; //previously approved and cached approval } $apiurl = 'https://api.1on1secure.com/?action=checkip&apitoken='.$apikey.'&tor='.$torboolean.'&domain='.$homeurl.'&ip='.$visitingip; $response = wp_remote_get($apiurl, array('timeout' => 2)); $body = wp_remote_retrieve_body( $response ); $apianswers = json_decode($body, true); if ($apianswers) { if ($apianswers['response'] == 'fail') { $intendedurl = sanitize_text_field($_SERVER['REQUEST_SCHEME']) . '://' . sanitize_text_field($_SERVER['HTTP_HOST']) . sanitize_text_field($_SERVER['REQUEST_URI']); switch ($redirectoption) { case 1: //white screen exit; break; case 3: //custom error page wp_redirect( get_permalink($redirpageid), 302 ); exit; break; case 4: //captcha header ("Location: https://baiter.1on1secure.com/verification.php?target=".$visitingip."&url=".$intendedurl); exit; break; default: //default to honeypot header ("Location: https://baiter.1on1secure.com/contactus.php"); exit; break; } } else { set_transient('1on1secure_'.$visitingip, 1, 3600); //expire in 1 hour // print "allow them to pass"; } } else { // print "no data and allowed to pass"; } } } if (! function_exists('ListWebpages1on1secure')) { function ListWebpages1on1secure() { $pageslist = get_pages(); foreach($pageslist as $thispage) { $pagearray[] = array("name" => $thispage->post_title, "id" => $thispage->ID); } return $pagearray; } } if (! function_exists('GetIPAddress1on1Secure')) { function GetIPAddress1on1Secure() { $ipHeaders = array('HTTP_CF_CONNECTING_IP','HTTP_X_FORWARDED_FOR','HTTP_X_FORWARDED','HTTP_FORWARDED_FOR','HTTP_FORWARDED','HTTP_CLIENT_IP',); foreach ($ipHeaders as $header) { $thisheader = sanitize_text_field($_SERVER[$header] ?? ''); if (filter_var($thisheader, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6)) { return $thisheader; } } return sanitize_text_field($_SERVER['REMOTE_ADDR']); } } if (! function_exists('OneOn1Secure_custom_admin_notice')) { function OneOn1Secure_custom_admin_notice() { //the notification or advertising $oneononesecurelogo = plugins_url( '../images/1on1securelogo40.png', __FILE__ ); //add the image url ?>