cagartner
7/10/2014 - 4:28 PM

upload

upload

<?php
if(function_exists(securiteuser)){
	if(!securiteuser($_SESSION['autuser']['id'],'1')){
		echo "Infelizmente você não possui Permissão!";
	}else{
?>

<?php

if(isset($_POST['cadastro'])){
  $cadastro['nome']  = mysql_real_escape_string($_POST['nome']);
  $cadastro['email']  = mysql_real_escape_string($_POST['email']);
  $cadastro['code']  = mysql_real_escape_string($_POST['code']);
  $cadastro['senha']  = md5($cadastro['code']);
  $cadastro['nivel']  = mysql_real_escape_string($_POST['nivel']);
  $cadastro['status']  = mysql_real_escape_string($_POST['status']);

  if(in_array('', $cadastro)){
    echo '<div class="alert alert-warning" role="alert">Preencha todos os campos!</div>';
  }elseif(email($cadastro['email'])){
    echo '<div class="alert alert-warning" role="alert">Formato de email Inválido!</div>';
  }elseif (strlen($cadastro['code']) <5 || strlen($cadastro['code']) > 10) {
    echo '<div class="alert alert-danger" role="alert">Senha deve conter entre 5 a 10 digitos!</div>'; 
  }else{
    $emailcompara = read('php_users', "WHERE email = '$cadastro[email]'");
    if($emailcompara){
       echo '<div class="alert alert-danger" role="alert">Email já existente!</div>'; 
    }else{
        if(empty($_FILES["fotoperfil"])){
            $imagem = $_FILES["fotoperfil"];
            $pasta = '../uploads/usuarios/';
            $tmp = $imagem['tmp_name'];
            $ext = substr($arquivo, -3);
            $nome = md5(time()).'.'.$ext;           

            $cadastro['fotoperfil'] = $nome;           

            WideImage::loadFromUpload('fotoperfil')->resize(600)->saveToFile($pasta.$nome);
        }
        create('php_users',$cadastro);
        $idlast = mysql_insert_id();
        $_SESSION['cadastro'] = '<div class="alert alert-success" role="alert">Cadastrado com Sucesso!</div>';
        header("Location: painel.php?execute=usuarios/create");
        unset($cadastro);
    }
  }
}elseif(!empty($_SESSION['cadastro'])){
    echo $_SESSION['cadastro'];
    unset($_SESSION['cadastro']);
  }

?>
<div class="row">
                <div class="col-lg-12">
                    <section class="panel">
                        <header class="panel-heading">
                            Criar Usuário
                            <span class="tools pull-right">
                                <a class="fa fa-chevron-down" href="javascript:;"></a>
                                <a class="fa fa-cog" href="javascript:;"></a>
                                <a class="fa fa-times" href="javascript:;"></a>
                             </span>
                        </header>
                        <div class="panel-body">
                            <div class="form">
                                <form class="cmxform form-horizontal " method="post" action="" novalidate="novalidate" enctype="multipart/form-data">
                                    <div class="form-group">
                                        <label for="img" class="control-label col-lg-3">Foto Perfil</label>
                                        <div class="col-lg-6">
                                            <input type="file" name="fotoperfil" id="uploadFile">
                                        </div>   
                                    </div>  
                                    <div class="form-group ">
                                        <label for="firstname" class="control-label col-lg-3">Nome</label>
                                        <div class="col-lg-6">
                                            <input class=" form-control" id="firstname" name="nome" type="text">
                                        </div>
                                    </div>
                                    <div class="form-group ">
                                        <label for="email" class="control-label col-lg-3">Email</label>
                                        <div class="col-lg-6">
                                            <input class="form-control " id="email" name="email" type="email">
                                        </div>
                                    </div>
                                    <div class="form-group ">
                                        <label for="password" class="control-label col-lg-3">Senha</label>
                                        <div class="col-lg-6">
                                            <input class="form-control valid" id="password" name="code" type="password">
                                        </div>
                                    </div>
                                    <div class="form-group ">
                                        <label for="confirm_password" class="control-label col-lg-3">Nível</label>
                                        <div class="col-lg-6">
                                        <select class="form-control" style="width: 100%" name="nivel">
                                        <option value='1'>Administrador</option>
                                        <option value='2'>Criador de Conteúdo</option>   
                                        </select>
                                        </div>
                                    </div>
                                    <div class="form-group ">
                                        <label for="confirm_password" class="control-label col-lg-3">Ativo</label>
                                        <div class="col-lg-6">
                                        <select class="form-control" style="width: 100%" name="status">
                                        <option value='1'>Ativo</option>
                                        <option value='0'>Inativo</option>   
                                        </select>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="col-lg-offset-3 col-lg-6">
                                            <button class="btn btn-primary" type="submit" name="cadastro">Cadastrar</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </section>
                </div>
            </div>
            <script src="js/advanced-form.js"></script>
<?php
}}else{
	header("Location: painel.php");
}
?>