'admin'); $buffer = array_merge($buffer1, $buffer2); } else { $buffer = array(0 => 'admin'); } if ($aqontrol_access['allow'] == 'nobanned' AND aqontrol_check_bans() == true AND !in_array($userdata->user_login, $buffer)) { aqontrol_redirect_template(); exit; } else if ($aqontrol_access['allow'] == 'registered' AND ($user_ID == '' OR aqontrol_check_bans() == true)) { aqontrol_redirect_template(); exit; } else if ($aqontrol_access['allow'] == 'nobody' AND !in_array($userdata->user_login, $buffer)) { aqontrol_redirect_template(); exit; } } /* ------------------------------------------------------------- Name: aqontrol_check_bans Purpose: Sees if you are banned Receive: -None- Return: Boolean ------------------------------------------------------------- */ function aqontrol_check_bans() { global $wpdb, $aqontrol_remote_ip; $remote_ip_long = sprintf("%u", ip2long($aqontrol_remote_ip)); $remote_addr = gethostbyaddr($aqontrol_remote_ip); $banned = $wpdb->get_results("SELECT * FROM `".$wpdb->prefix."accessqontrol` ORDER BY `id` ASC"); foreach ($banned AS $ban) { if (strlen($ban->reason) > 0) { $banned_reason = $ban->reason; } else { $banned_reason = "Not given"; } if ($ban->timespan > 0) { $banned_until = date("l, j F Y", $ban->timespan); } else { $banned_until = "indefinite"; } if ($remote_ip_long >= $ban->address AND $remote_ip_long <= $ban->range) { return true; } else { return false; } } } /* ------------------------------------------------------------- Name: aqontrol_redirect_template Purpose: Shows to people when site is restricted. Receive: $type, $banned_until, $banned_reason Return: -None- ------------------------------------------------------------- */ function aqontrol_redirect_template($type = 'everyone', $banned_until = null, $banned_reason = null) { global $aqontrol_template; $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); if ($type == "nobanned") { $template_content = str_replace('%reason%', $banned_reason, $template_content); $template_content = str_replace('%until%', $banned_until, $template_content); } else { $template_content = str_replace('%reason%', '', $template_content); $template_content = str_replace('%until%', '', $template_content); } ?>