<?php

    
function ClearText($Text)
    {
        
        if(
get_magic_quotes_gpc())
        {
        
            
$Text stripslashes($Text);
            
        }
        
        
$Text trim($Text);
        
$Text htmlspecialchars($Text);
        
$Text htmlentities($Text);
        
$Text strip_tags($Text);
        
        return 
$Text;
        
    }

    function 
CheckFile()
    {
        
        
$BAD 0;
    
        if(
$_FILES['FILE']['error'] == || $_FILES['FILE']['error'] == 2)
        {
            
            echo 
'The file is too big!';
            
            
$BAD++;
            
        }
        
        else if(
$_FILES['FILE']['error'] > 0)
        {
            
            echo 
'An error occurred while adding file';
            
            
$BAD++;
            
        }
        
        
$AllowedExtension = array('pdf''doc''docx');
        
$AllowedType = array('application/msword''text/pdf');    
        
        
$Extension end(explode("."$_FILES["FILE"]["name"]));
        
        if(!
in_array($_FILES['FILE']['type'], $AllowedType) && !in_array($Extension$AllowedExtension))
        {
            
            
$BAD++;
            
        }
        
        if(
$BAD == 0)
        {
            
            
$File $_FILES['FILE']['tmp_name'];
            
$Name $_FILES['FILE']['name']; 
            
            if(
is_uploaded_file($File))
            {
                
                
$Number rand(99999999);
                
                
move_uploaded_file($File"./upload/".$Number."_".$Name."");
                
                return 
"".$Number."_".$Name."";
                
            }
            
        }
        
        return 
0;
    
    }
    
    if(
$_POST['SEND'])
    {
        
        
//W $Info spreparuj sobie tekst jaki tam chcesz w HTML ;)
        
        
$Mail $Core->ClearText($_POST['mail']);
        
$Name $Core->ClearText($_POST['name']);
        
        
$CheckFile CheckFile();
        
        if(
$CheckFile != 0)
        {
            
            
$Info .= 'ATTACHMENT: http://buildersaz.co.uk/upload/'.$CheckFile.'';
            
        }
        
        
$Header "Reply-to: ".$Name." <".$Mail.">" PHP_EOL;
        
$Header .= "From: BUILDERSAZ [CONTACT] <sloenthran@buildersaz.co.uk>" PHP_EOL;
        
$Header .= "MIME-Version: 1.0" PHP_EOL;
        
$Header .= "Content-type: text/html; charset=UTF-8"  .PHP_EOL;
    
        
$Message '<html> 

            <head> 
            
                <title>BUILDERSAZ [CONTACT]</title>
        
            </head>
        
            <body>
        
                '
.$Info.'
        
            </body>
    
        </html>'
;
    
        
mail('buildersaz.ltd@gmail.com''BUILDERSAZ [CONTACT]'$Message$Header);
        
    }
    
    else
    {
        
        
//TU SOBIE WKLEJ FORMULARZ || UKRYTY HIDDEN O WARTOSCI TRUE I NAZWIE SEND
        
    
}



?>