'admin');
$buffer = array_merge($buffer1, $buffer2);
} else {
$buffer = array(0 => 'admin');
}
if((($aqontrol_config['allow'] == 'registered' AND $user_ID == '') OR $aqontrol_config['allow'] == 'nobody') AND !in_array($userdata->user_login, $buffer)) {
aqontrol_login_template();
exit;
}
}
/* -------------------------------------------------------------
Name: aqontrol_login_template
Purpose: Shows to people when site is restricted.
Receive: -None-
Return: -None-
------------------------------------------------------------- */
function aqontrol_login_template() {
global $aqontrol_template;
get_header();
$template_title = stripslashes(html_entity_decode($aqontrol_template['title'], ENT_QUOTES));
$template_content = stripslashes(html_entity_decode($aqontrol_template['content'], ENT_QUOTES));
$template_content = str_replace('%login_link%', 'Login form', $template_content);
?>
pulled from function args
// User choose anonymous?
if($aqontrol_tracker['anonymous'] == 'Y') {
$ident = 'Anonymous';
$blogname = 'Anonymous';
$blogurl = 'Anonymous';
$email = 'Anonymous';
} else {
$ident = md5(get_option('siteurl'));
$blogname = get_option('blogname');
$blogurl = get_option('siteurl');
$email = get_option('admin_email');
}
// Build array of data
$post_data = array (
'headers' => null,
'body' => array(
'ident' => $ident,
'blogname' => base64_encode($blogname),
'blogurl' => base64_encode($blogurl),
'email' => base64_encode($email),
'date' => $date,
'plugin' => $plugin,
'version' => $version,
'action' => $action,
),
);
// Destination
$url = 'http://stats.meandmymac.net/receiver.php';
wp_remote_post($url, $post_data);
}
/*-------------------------------------------------------------
Name: aqontrol_activate
Purpose: Activation script
Receive: -none-
Return: -none-
-------------------------------------------------------------*/
function aqontrol_activate() {
aqontrol_send_data('Activate');
}
/*-------------------------------------------------------------
Name: aqontrol_deactivate
Purpose: Deactivation script
Receive: -none-
Return: -none-
-------------------------------------------------------------*/
function aqontrol_deactivate() {
aqontrol_send_data('Deactivate');
}
/*-------------------------------------------------------------
Name: aqontrol_check_config
Purpose: Create or update the options
Receive: -none-
Return: -none-
-------------------------------------------------------------*/
function aqontrol_check_config() {
// Configuration
if ( !$option = get_option('aqontrol_config') ) {
// Default Options
$option['allow'] = 'everyone';
$option['except'] = '';
update_option('aqontrol_config', $option);
}
// If value not assigned insert default (upgrades)
// "except" may be empty!!
if (strlen($option['allow']) < 1) {
$option['allow'] = 'everyone';
$option['except'] = ''; // may be left empty!!
update_option('aqontrol_config', $option);
}
// Template
if ( !$template = get_option('aqontrol_template') ) {
// Default Options
$template['title'] = 'You need to log in to enter this website
';
$template['content'] = 'If you wish to log in you need an account. Please contact the system administrator if you do not have an account.
';
update_option('aqontrol_template', $template);
}
// If value not assigned insert default (upgrades)
if ( strlen($template['title']) < 1 or strlen($template['content'] ) < 1) {
$template['title'] = 'You need to log in to enter this website
';
$template['content'] = 'If you wish to log in you need an account. Please contact the system administrator if you do not have an account.
';
update_option('aqontrol_template', $template);
}
if ( !$tracker = get_option('aqontrol_tracker') ) {
$tracker['register'] = 'Y';
$tracker['anonymous'] = 'N';
update_option('aqontrol_tracker', $tracker);
}
}
/*-------------------------------------------------------------
Name: aqontrol_options_submit
Purpose: Save options
Receive: $_POST
Return: -none-
-------------------------------------------------------------*/
function aqontrol_options_submit() {
$buffer = get_option('acontrol_tracker');
//options page
$option['allow'] = $_POST['aqontrol_allow'];
$option['except'] = trim($_POST['aqontrol_except'], "\t\n ");
$template['title'] = htmlspecialchars(trim($_POST['aqontrol_title'], "\t\n "), ENT_QUOTES);
$template['content'] = htmlspecialchars(trim($_POST['aqontrol_content'], "\t\n "), ENT_QUOTES);
$tracker['register'] = $_POST['aqontrol_register'];
$tracker['anonymous'] = $_POST['aqontrol_anonymous'];
if($tracker['register'] == 'N' AND $buffer['register'] == 'Y') { aqontrol_send_data('Opt-out'); }
update_option('aqontrol_config', $option);
update_option('aqontrol_template', $template);
update_option('aqontrol_tracker', $tracker);
}
/*-------------------------------------------------------------
Name: aqontrol_uninstall
Purpose: Delete the entire database table and remove the
options on uninstall.
Receive: -none-
Return: -none-
-------------------------------------------------------------*/
function aqontrol_uninstall() {
aqontrol_send_data('Uninstall');
// Delete Option
delete_option('aqontrol_config');
delete_option('aqontrol_template');
delete_option('aqontrol_tracker');
// Deactivate Plugin
$current = get_settings('active_plugins');
array_splice($current, array_search( "accessqontrol.php", $current), 1);
update_option('active_plugins', $current);
do_action('deactivate_' . trim( $_GET['plugin'] ));
die();
}
?>