Ir para conteúdo
Fórum Script Brasil

Lucas AG

Membros
  • Total de itens

    1
  • Registro em

  • Última visita

Posts postados por Lucas AG

  1. Eu tenho um sistema em meu site que a pessoas insere o nome e e-mail para ser registrado no sistema, eu queria bloquear um domininio de e-mail que no caso é esse: @boxtemp.com.br

    mas não tenho a minima ideia de como fazer isso. Agradeço a ajuda

     

    <?php require_once('Connections/config.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
    {
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      }
    
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
    
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;    
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      }
      return $theValue;
    }
    }
        
    	function Gerador($LARGURA = 5, $SO_NUMEROS=true, $MAIUSCULAS = false, $NUMERICA = true, $SIMBOLO = false)
    	{
    	
    		// Caracteres de cada tipo para geração
    		$l_minuscula = 'abcdefghijklmnopqrstuvwxyz';
    		$l_maiuscul  = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
    		$numeros     = '1234567890';
    		$simbol      = '!@#$%*-';
    		
    		// Variáveis internas da função
    		$retorno = '';
    		$caracteres = '';
    		
    		// Agrupamos todos os caracteres que poderão ser utilizados
    		$caracteres .= ($SO_NUMEROS) ? $numeros : $l_minuscula;
    		
    		$caracteres .= ($MAIUSCULAS) ? $l_maiuscula : false;
    		$caracteres .= ($NUMERICA)   ? $numeros : false;
    		$caracteres .= ($SIMBOLO)    ? $simbol : false;
    		
    		// Contamos o tamanho da definição escolhida
    		$tamanho = strlen($caracteres);
    		
    			for ($d = 1; $d <= $LARGURA; $d++) {
    				// Criamos um número aleatório de 1 até $len para pegar um dos caracteres
    				
    				$rand = mt_rand(1, $tamanho);
    				
    				// Concatenamos um dos caracteres na variável $retorno
    				$retorno .= $caracteres[$rand-1];
    			}
    			
    		return $retorno;
    	
    	}
    	
    
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
    	
      $MM_dupKeyRedirect="ERRO-ao-gerar-o-teste";
      $loginUsername = isset($_POST['email']) ? $_POST['email'] : NULL;
      $LoginRS__query = sprintf("SELECT email FROM `clientes-teste` WHERE email=%s", GetSQLValueString($loginUsername, "text"));
     
      $LoginRS=mysql_query($LoginRS__query, $config) or die(mysql_error());
      $loginFoundUser = mysql_num_rows($LoginRS);
    
      //if there is a row in the database, the username was found - can not add the requested username
      if($loginFoundUser >0){
        $MM_qsChar = "?";
        //append the username to the redirect page
        if (substr_count($MM_dupKeyRedirect,"?") >=1) $MM_qsChar = "&";
        $MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar ."requsername=".$loginUsername;
        header ("Location: $MM_dupKeyRedirect");
    
      }else{
      	
      
    	
      $insertSQL = sprintf("INSERT INTO `clientes-teste` (nome, email) VALUES (%s, %s)",
                           GetSQLValueString($_POST['nome'], "text"),
                           GetSQLValueString($_POST['email'], "text"));
     
      $Result1 = mysql_query($insertSQL, $config) or die(mysql_error());
      
      if($Result1 == true){
      	
    	$idFinal = mysql_insert_id();
    	
    	$duplicado = mysql_query("SELECT * FROM dados WHERE id_utilizador='$idFinal' AND status=1")or die(mysql_error());
    	
    	if(mysql_num_rows($duplicado) > 0)
    	{
    		header('Location: ERRO-ao-gerar-o-teste.php?requesername='.$loginUsername);
    		exit();
    	}
    	  
    	//Gerando as senhas
    	$pass1 = 'az'.Gerador(5);
    	$pass2 = Gerador(5);
    	
    	//Vamos verificar se 
    	$verificar = mysql_query("SELECT user,senha FROM dados WHERE user='$pass1' AND status=1")or die(mysql_error());
    	
    	//Verificamos se existem registros na base de dados
    	if(mysql_num_rows($verificar) > 0)
    	{
    		$ver = mysql_fetch_object($verificar);
    		
    		$passNovo = 'az'.Gerador(5);
    			
    		if($ver->user != $passNovo)	
    		{
    			//Verifico se algum dos registros é igual à chave gerada, se for, ele gera outra e insere.
    			$inserir = mysql_query("INSERT INTO dados (id_utilizador,user,senha) VALUES('$idFinal','$passNovo','$pass2')")or die(mysql_error());
    		}elseif($ver->user == $passNovo)
    		{
    			
    			$passNovo2 = 'az'.Gerador(5);
    			//Verifico se algum dos registros é igual à chave gerada, se for, ele gera outra e insere.
    			$inserir = mysql_query("INSERT INTO dados (id_utilizador,user,senha) VALUES('$idFinal','$passNovo2','$pass2')")or die(mysql_error());
    		}		
    		
    	}else{
    		//Se não tiver nenhum registros no db, ele insere o primeiro.
    		$inserir = mysql_query("INSERT INTO dados (id_utilizador,user,senha) VALUES('$idFinal','$pass1','$pass2')")or die(mysql_error());
    		
    	}
    	
    	if($inserir)
    	{
    		header('Location: teste-gerado-?id='.base64_encode($idFinal));
    	}
    	  
      }
      
      }
      
    }
    
    ?>

     

×
×
  • Criar Novo...