<?php
defined('_JEXEC') or die;
function sourcerer_php_a8b71fc76ead414984c90657b7e06a0b($src_variables){
$app = $mainframe = JFactory::getApplication();
$document = $doc = JFactory::getDocument();
$database = $db = JFactory::getDbo();
$user = JFactory::getUser();
$Itemid = $app->input->getInt('Itemid');
if (is_array($src_variables)) {foreach ($src_variables as $src_key => $src_value) {${$src_key} = $src_value;}}
echo $_SERVER['DOCUMENT_ROOT']; 


	<style type="text/css">

	.sppb-btn-custom {

	background-color: #3897d3;

	    padding: 10px 50px;}

	</style>

	 

	
		<div class="custom">
	
		<p>
	
		<button class="sppb-btn sppb-btn-custom sppb-btn-square" data-target="#studModal" data-toggle="modal" id="student-btn"><b>APPLY</b></button></p>
	
		 
	
		<?php
	
		if (isset($_POST['apply-btn'])) {
	
		   defined('_JEXEC') or die;
	
		   $user = JFactory::getUser();
	
		   $status = $user->guest;
	
		
			   if (/*$status = 1*/true) {
		
			     $db=JFactory::getDbo();   
		
			
				     $db->setQuery("SELECT nUserID FROM `cl_hlusers`.`u_emails` WHERE `email`='".$_POST['email']."' LIMIT 1;");
			
				     $exist1=$db->loadObject();
			
				 
			
				     if (empty($exist1)) {
			
				
					        $db->setQuery("SELECT * FROM `cl_hlusers`.`users` WHERE `strEmail`='".$_POST['email']."' LIMIT 1;");
				
					        $exist2=$db->loadObject();
			
			
				        if (empty($exist2)) {
			
				            $db->setQuery("INSERT INTO `cl_hlusers`.`users` (`strEmail`,`strName`, `nCtrID`, `old_db`) 
			
				               VALUES ('".$_POST['email']."','".$_POST['fname'].' '.$_POST['lname']."', '".$_POST['country']."', 'clusers_eng');");
			
				            $db->execute();
			
				            $nUserID = $db->insertid();
			
				
					            $db->setQuery("INSERT INTO `cl_hlusers`.`u_emails` (`email`,`nUserID`, `default`, `active`, `deleted`, `newsletter`) 
				
					               VALUES ('".$_POST['email']."','".$nUserID."', '1', '1', '0', '1');");
				
					            $db->execute();
			
			
				        } else {
			
				           $nUserID = $exist2->nUserID;
			
				        }
			
				     } else {
			
				        $nUserID = $exist1->nUserID;
			
				     }
		
		
			   } else {
		
			     $nUserID = $user->nUserID;
		
			   }
		
			   $education = $_POST['education'];
		
			
				   $db->setQuery("UPDATE `cl_hlusers`.`users` SET `strEducation`='".$education."' WHERE nUserID=".$nUserID." LIMIT 1;");
			
				   $db->execute();
			
				 
			
				
					   $db->setQuery("INSERT INTO `cl_hlusers`.`u_history` (`nUserID`,`nTopicID`, `dateEvent`, `strPlace`, `old_db`, `nManagerID`)
				
					      VALUES ('".$nUserID."', '386', '".date('Y-m-d')."', 'web', 'clusers_eng', '36');");
				
					   $db->execute();
			
		
		
			 
		
			
				   if (!file_exists("/var/www/hosting/archline.hu/sub/attachements/{$nUserID}"))
			
				      mkdir("/var/www/hosting/archline.hu/sub/attachements/{$nUserID}");
		
		
			 
	
	
		   $countfiles = count($_FILES['files']['name']);
	
		   for ($i = 0; $i < $countfiles; $i++) {
	
		        $filename = $_FILES['files']['name'][$i];
	
		        move_uploaded_file($_FILES['files']['tmp_name'][$i], JPATH_BASE.'/attachements/'.$nUserID.'/'.$filename);
	
		
			 
		
			        $path_parts = pathinfo( '/attachements/'.$nUserID.'/'.$filename);
		
			 
		
			
				        $db->setQuery("INSERT INTO `cl_hlusers`.`attachments` (`add_nManagerID`,`nUserID`, `path`, `file_name`, `file_type`, `file_extension`, `strInfo`, `add_DateTime`)
			
				           VALUES ('36','".$nUserID."', 'not-public/".$nUserID."/', '".$path_parts['filename']."', 'image/png', '.".$path_parts['extension']."', 'Academic Proof', '".date('Y-m-d H:i:s')."');");
			
				        $db->execute();
			
				 
			
				 

					$mailer = JFactory::getMailer(); 

				 

					$config = JFactory::getConfig(); 

				
					$sender = array( 
				
					    $config->get( 'info@archlinexp.com' ),
				
					    $config->get( 'info@archlinexp.com' ) 
				
					);
				
					 
				
					$mailer->setSender($sender);
				
					$mailer->addRecipient($_POST['email']);
				
					$body = 'Dear <b>'.$_POST['fname'].' '.$_POST['lname'].'</b><br/><br/>We have received your request for (PRODUCT NAME), and we are currently evaluating it. You will hear back from us within 2 working days.<br/><br/>Should your application be approved, you will receive a link to our online store, where you can pay for your subscription, and get the necessary info on how to download and activate your ARCHLine.XP copy.<br/><br/>Best wishes,<br/>The ARCHLine.XP Team';
				
					
						$mailer->isHtml(true);
					
						$mailer->Encoding = 'base64';
				
				
					
						$mailer->setSubject('Your subject string');
					
						$mailer->setBody($body);
					
						$send = $mailer->Send();
				
			
			
				 
		
	
	
		   } ; ?>
	
		 
	
		<script>
	
		jQuery('#system-message-container').html('<div id="system-message"><div class="alert alert-message"><a class="close" data-dismiss="alert">×</a><h4 class="alert-heading">Thank You</h4><div><p>We have received your request, please check your inbox (also your SPAM folder) for our confirmation.<br/> We are currently evaluating your application. You will hear back from us within 2 working days.<br/>Should your application be approved, you will receive a link to our online store, where you can pay for your subscription. </p></div></div></div>');
	
		 
	
		</script>
	
		<?php };;
return get_defined_vars();
;}