run(); include("captcha/simple-php-captcha.php"); $last_capture = @XXXXXXXXX['captcha']['code']; XXXXXXXXX['captcha'] = simple_php_captcha(); if(($_SERVER['REQUEST_METHOD'] == "POST") && isset(XXXXXX["login"])){ //catch the POSTED data $username = filter_input(INPUT_POST,'username'); $password = filter_input(INPUT_POST,'password'); //check if fields are empty if( validate($username) && validate($password) ){ //set log in credentials //dump(XXXXXX); $parameters= array("username"=>$username,"password"=> $password); $loguser = execService('/authUser?wsdl','accountAuthenticate',$parameters); //dump( $loguser ); if(isset($loguser->errMessage)) { log_error ('ORACLE PL/SQL', $loguser->errMessage); header("Location: login-register.php?err=4"); } //dump($loguser); //Check if agent has been authenticated $turnquestmsg = @$loguser->message; if(strlen(@$turnquestmsg)>0){ $turnquestmsg = str_ireplace('[HERE]','here',$turnquestmsg); } $accountType = @$loguser->accountType; if (stripos($turnquestmsg,'Login Successfull') !== false && $loguser->result=="S") { //Check if err Message has been set for trying to Login /****************************************************** A->agent C->Client SP->service provider *********************************************************/ if(strcmp(@$accountType, 'A')==0){ $session->run(); $session->set('username',$username); $session->set('name',$loguser->accountName); $session->set('loggedIn',true); $session->set('agentCode',$loguser->accountCode); $session->set('userCode',$loguser->userCode); if(strlen($session->get('currency'))==0){ $session->set('currency',@$loguser->currSysmbol); $session->set('currSymbol',@$loguser->currSysmbol); $session->set('currCode',@$loguser->currCode); } //$session->set('currCode',$loguser->currCode); $session->set('shtDesc',$loguser->accountShtDesc); $session->set('sysBranchCode',$loguser->sysBranchCode); $session->set('mobileno' ,$loguser->mobileNo); $session->set('telphoneno' ,$loguser->telphoneNo); $session->set('accountType','A'); $agentCode = $session->get("agentCode"); $parameters = array("accountCode"=>$agentCode,"accountType"=>'A'); $parameterz = array("brnCode"=>$loguser->sysBranchCode); $notificationcount=execService('/portals/servReq?wsdl','getAccountPendingRequestsCount',$parameters); //dump($notificationcount); $branchdetails=execService('/portals/base?wsdl','getBranchDetails',$parameterz); $session->set('brnShtDesc',$branchdetails->brnShtDesc); $session->set('notificationcount',$notificationcount); $quoteParameters= array( "username"=>$loguser->username, "quoteCode"=>XXXXX['qqtnCode'], "clientCode"=>'0', "prpCode"=>'0', "user"=>$loguser->username, "ipuPrpCode"=>'0', "quoteNo"=>'0' ); //dump($quoteParameters); //end get count of Notification +++++++++++++++++++++++++++++++++++++++++++++++ $url='Location: intermediary/home.php'; if(strcmp($session->get('buyquote'),'true')==0){ $url='Location: intermediary/selectclient.php?q=&sprod='.$session->get('sprod').'&bcode='.$session->get('bcode').'&scode='.$session->get('scode'); //dump($ScreenCode); if(strcmp($session->get('ScreenCode'),'MAR_U')==0){ $url='Location: intermediary/marineExtraDtls.php'; } } $session->delete('buyquote'); header($url); }else if(strcmp($accountType, 'C')==0){ //dump($loguser); $session->run(); $session->set('username',$username); $session->set('userCode' , $loguser->userCode); $session->set('clientCode' , $loguser->accountCode); $session->set('name' ,$loguser->accountName); $session->set('loggedIn',true); $session->set('country' ,$loguser->country); $session->set('mobileno' ,$loguser->mobileNo); $session->set('clientType',"I");// I for Normal User X For inderwriter $session->set('clienttype',"I"); ////////////////////////////////////////// $session->set('selectedclientcode', $loguser->accountCode); $session->set('clname' ,$loguser->accountName); ////////////////////////////////////////// if(strlen($session->get('currency'))==0){ $session->set('currency',@$loguser->currSysmbol); $session->set('currSymbol',@$loguser->currSysmbol); $session->set('currCode',@$loguser->currCode); } //$session->set('currCode',@$loguser->currCode); $session->set('shtDesc',@$loguser->accountShtDesc); $session->set('sysBranchCode',@$loguser->defaultBranch); $session->set('accountType','C'); $session->set('agentCode','0'); $session->set("agentShtDesc",'DIRECT'); //$session->dump(); $quoteParameters= array( "username"=>$loguser->name, "quoteCode"=>XXXXX['qqtnCode'], "clientCode"=>$loguser->accountCode, "prpCode"=>$loguser->accountCode, "user"=>$loguser->name, "ipuPrpCode"=>$loguser->accountCode, "quoteNo"=>'0' ); //dump($quoteParameters); //$quoteCode = execService('/portals/quotation?wsdl','convertQuickQuotation',$quoteParameters); //$session->dump(); //get count of Notification +++++++++++++++++++++++++++++++++++++++++++++++ //initialize variables for WSDL Call declared at Start $arguments = array( "username"=>XXXXXXXXX['username'], "usercode"=>XXXXXXXXX['userCode'], "clientCode"=>XXXXXXXXX['clientCode'] ); $notificationcount = execService('/portals/servReq?wsdl','getClientPendingRequestsCount',$quoteParameters); $session->set('nofitification',$notificationcount); //end get count of Notification +++++++++++++++++++++++++++++++++++++++++++++++ $url='Location: client/policys.php'; if(strcmp($session->get('buyquote'),'true')==0){ $url='Location: client/selectclient.php?q=&sprod='.$session->get('sprod').'&bcode='.$session->get('bcode').'&scode='.$session->get('scode'); //dump($ScreenCode); if(strcmp($session->get('ScreenCode'),'MAR_U')==0){ $url='Location: client/marineExtraDtls.php'; } } $session->delete('buyquote'); //dump($url); header($url); }else{ //empty error header('location: login-register.php?err=1'); } } } } if(($_SERVER['REQUEST_METHOD'] == "POST") && isset(XXXXXX["register"])){ //catch the POSTED data $surname = filter_input(INPUT_POST,'surname'); $fname = filter_input(INPUT_POST,'fname'); $email = filter_input(INPUT_POST,'email'); $pin = filter_input(INPUT_POST,'pin'); $idno = filter_input(INPUT_POST,'idno'); $boxaddress = filter_input(INPUT_POST,'boxaddress'); $mobileno = filter_input(INPUT_POST,'mobileno'); $passport = filter_input(INPUT_POST,'passport'); $capture = filter_input(INPUT_POST,'capture'); $question1 = filter_input(INPUT_POST,'question1'); $answer1 = filter_input(INPUT_POST,'answer1'); $question2 = filter_input(INPUT_POST,'question2'); $answer2 = filter_input(INPUT_POST,'answer2'); $password = filter_input(INPUT_POST,'password'); $confirm_password = filter_input(INPUT_POST,'confirm_password'); $error = NULL; $regexcheckdigits = '/\d/'; //validate First Name if(strlen($surname) == 0 ) { $error[] = 'Please fill in your Surname Name !'; } elseif (preg_match($regexcheckdigits, $surname)) { $error[] = 'Surname Name cannot include digits!'; } //validate LastName if(strlen($fname) == 0 ) { $error[] = 'Please fill in your First Name!'; } elseif (preg_match($regexcheckdigits, $fname)) { $error[] = 'First Name cannot include digits!'; } //validate Useremail if(strlen($email) == 0 ) { $error[] = 'Please fill in your email!'; } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $error[] = 'Please enter a Valid Email!'; } //validate pin if(strlen($pin) == 0 ) { $error[] = 'Please fill in your PIN!'; } //validate capture if(strlen($capture) == 0 ) { $error[] = 'Please fill in your Capture Code!'; } //dump($_SESSION['captcha']['code']); if(strcmp( $capture , $last_capture ) !=0 ) { $error[] = "You've entered the wrong Capture Code!"; } //validate mobile if(strlen($mobileno) == 0 ) { $error[] = 'Please fill in your Mobile No!'; } //validate ID Number if(strlen($idno) == 0 && strlen($passport) == 0) { $error[] = 'Please fill in your ID Number or Passport Number!'; } //validate boxaddress if(strlen($boxaddress) == 0 ) { $error[] = 'Please fill in your Box Address!'; } //validate ID Number if(strlen($question1) == 0 ) { $error[] = 'Please select question 1!'; } //validate ID Number if(strlen($answer1) == 0 ) { $error[] = 'Please provide answer 1!'; } //validate ID Number if(strlen($question2) == 0 ) { $error[] = 'Please select question 2!'; } if(strcmp($question1,$question2) == 0 ) { $error[] = 'Please select different questions!'; } //validate ID Number if(strlen($answer2) == 0 ) { $error[] = 'Please provide answer 2!'; } //validate ID Number if(strcmp($question1,$question2) == 0 ) { $error[] = 'Please select different questions!'; } //validate Confirm Password if(strlen($confirm_password) == 0 ) { $error[] = 'Please Confirm your Password!'; } //validate Password if(strlen($password) == 0 ) { $error[] = 'Please fill in your Password!'; } elseif (preg_match("/^.*(?=.{6,})(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).*$/", $password ) === 0) { $error[] = 'Password should have Minimum 6 characters, 1 UPPERCASE, 1 lowercase & at least 1 Digit !'; } elseif ($password !== $confirm_password) { $error[] = 'Passwords DO NOT Match..!'; } if(empty($error)) { //Validation token for Login $random = mt_rand(0, 99999); $salt = "Qz[]!@#$^2*&"; $combi = $random.$salt; $token = hash('sha256',$combi); $parameters = array( "username"=>$email, "password"=>$password, "confirmPass"=>$confirm_password, "fullname"=>$surname.' '.$fname, "mobile"=>'000', "resetPassword"=>$password, "token"=>$token, "country"=>'KE', "regNo"=>$idno, "postalAddress"=>$boxaddress, "pin"=>$pin, "mobile"=>$mobileno, "passport"=>$passport, "question1"=>$question1, "answer1"=>$answer1, "question2"=>$question2, "answer2"=>$answer2 ); //dump($parameters); $activated = execService('/authUser?wsdl','captureWebClient',$parameters); //dump($activated); $clientCode=$activated->clientCode; if(!empty($clientCode)&&$activated->access==1&&$activated->message=='Successfull') { //Create a new PHPMailer instance $mail = new PHPMailer; //Tell PHPMailer to use SMTP $mail->isSMTP(); //Enable SMTP debugging // 0 = off (for production use) // 1 = client messages // 2 = client and server messages $mail->SMTPDebug = 0; //Ask for HTML-friendly debug output //$mail->Debugoutput = 'html'; //Set the hostname of the mail server $mail->Host = $mailhost; //Set the SMTP port number - likely to be 25, 465 or 587 $mail->Port = $mailport; //Whether to use SMTP authentication $mail->SMTPAuth = true; //Username to use for SMTP authentication $mail->Username = $mailusername; //Password to use for SMTP authentication $mail->Password = $mailpassword; //Set who the message is to be sent from $mail->setFrom($mailFromEmail, $mailFromName); //Set an alternative reply-to address $mail->addReplyTo($replytoemail, $replytoname); //Set who the message is to be sent to $mail->addAddress($email, $surname.' '.$fname); //Set the subject line $mail->Subject = 'Account Activation'; //Read an HTML message body from an external file, convert referenced images to embedded, //convert HTML into a basic plain-text alternative body $mail->Body = ""; $mail->Body.= '
'; $mail->Body.= '
The Heritage Insurance Company Client Portal
'; $mail->Body.= '
'; $mail->Body.= '

Dear '.$fname.'

'; $mail->Body.= '

Thank you for Registering your account on our Client Portal.

'; $mail->Body.= '

Please : Click here to Activate your Account Now

'; $mail->Body.= '

Note that your email address will be your Username for Login.

'; $mail->Body.= '

Regards

'.$companyFooter.'

'; $mail->Body.= '
'; $mail->Body.= '
Terms and Conditions Apply.
'; $mail->Body.= '
'; //mail as HTML $mail->IsHTML(true); //send Mail if($mail->send()){ header('location:login-register.php?err=15'); die(); } else { $error[] = 'An error occurred while sending email, please try again!'.$mail->ErrorInfo; } } else { $error[] = 'An error occurred while processing registration, please try again!'.$activated->message; } } } $view_path = 'login-register-view.php'; include 'views/layout.php'; ?>