<?php  
include_once "../../conexao/functions.php";

if (isset($_POST['submit'])) {
	$titulo     	  = trim($_POST['titulo']);
	$icone 			  = trim($_POST['icone']);
	$logo 			  = trim($_POST['logo']);
	$background 	  = trim($_POST['background']);
	$email 			  = trim($_POST['email']);
	$crypted_password = cryptPassword(trim($_POST['senha']), "i9team");
	// var_dump($crypted_password); die();
	$senha 			  = $crypted_password;

	if (empty($_POST['senha'])) {
		if(atualizarConfigSemSenha($titulo, $icone, $logo, $background, $email)){
			header("Location: ../configuracoes?r=atualizado");
		}else{
			header("Location: ../configuracoes?r=erro");
		}
	}else{
		if(atualizarConfigComSenha($titulo, $icone, $logo, $background, $email, $senha)){
			header("Location: ../configuracoes?r=atualizado");
		}else{
			header("Location: ../configuracoes?r=erro");
		}
	}
}
?>