<?php
require_once('../../config.php');
global $USER, $CFG, $DB;

$logouturl = new moodle_url('/login/logout.php', array('sesskey' => sesskey()));
                    $userobj = new stdClass();
                    $userobj->id = $USER->id;
                    $userobj->suspended = 1;
                    $return = $DB->update_record('user', $userobj);
                if ($return) {
                        //send_account_suspend_email_to_user();
                        $to = $USER->email;
                        $fname = $USER->firstname;
                        $lname = $USER->lastname;
                        $sitename = $DB->get_field('course', 'fullname', array('id' => 1));
			$subject = "79 Dollar Ohio Driver: Your account has been blocked.";
			$txt = "Oh dear...your account was blocked because you did not answer your security questions correctly. Please confirm the following information, and we will get you back on track!";
			$txt .= "";
		    $txt .= " - Your name";
		    $txt .= " - Your date of birth";
		    $txt .= " - Your favorite color";
		    $txt .= " - Your natural hair color";
		    $txt .= " - Your month of birth";
		    $txt .= " - Your middle initial";
		    $txt .= " - Your eye color";
		    $txt .= "";
		    $txt .= "We will respond to your email to let you know your account is reopened.";
			$headers = "From: CustomerCare@79DollarOhioDriver.com";
			mail($to,$subject,$txt,$headers);
                    }
                    echo "<script type='text/javascript'>alert('Oh dear...your account has been blocked because you did not answer your security questions correctly within the time frame. You will be logged out of the site after clicking the OK button below. Please go to your email account and respond to the email we just sent you, and get you back on track!')</script>";
                    
?>