Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/03/2010, 17:01
Avatar de Ranya
Ranya
 
Fecha de Ingreso: marzo-2010
Mensajes: 10
Antigüedad: 14 años, 2 meses
Puntos: 0
Ahi quien me ayuda

Hola a todos!

Tengo un problema con este script es que miren y me ayudan


Código PHP:
Ver original
  1. <?php
  2. include('conexion.php');
  3. include('autor.php');
  4. $accdir="D:\\cuentas\\primero\\2010";
  5. $title = 'Sistema 1';
  6. if ($_POST['action'] == 'submitted')
  7. {
  8.     $Email = $_POST['txtEmail'];
  9.     $UserID = $_POST['userid'];
  10.     $Password = $_POST['password'];
  11.     $CPassword = $_POST['password2'];
  12.     $UserKey = $_POST['txtKey'];
  13.     $SecretQuestion = $_POST['txtQuest'];
  14.     $Answer = $_POST['txtAnswer'];
  15.     $FirstName = $_POST['txtName'];
  16.     $MI = substr($UserID,0,1);
  17.     $LastName = $_POST['txtLastName'];
  18.     $Month = $_POST['txtMonth'];
  19.     $Day = $_POST['txtDay'];
  20.     $Year = $_POST['txtYear'];
  21.     $Sex = $_POST['txtSex'];
  22.     $Country = $_POST['txtCountry'];
  23.  
  24.     function is_email($email){
  25.        $x = '\d\w!\#\$%&\'*+\-/=?\^_`{|}~';    
  26.    
  27.        return count($email = explode('@', $email, 3)) == 2
  28.            && strlen($email[0]) < 65
  29.            && strlen($email[1]) < 256
  30.            && preg_match("#^[$x]+(\.?([$x]+\.)*[$x]+)?$#", $email[0])
  31.            && preg_match('#^(([a-z0-9]+-*)?[a-z0-9]+\.)+[a-z]{2,6}.?$#', $email[1]);
  32.     }
  33.  
  34.     $error = "";
  35.     function AllOK()
  36.     {
  37.         global $error,$Email,$UserID,$Password,$CPassword,$UserKey,$SecretQuestion,$Answer,$FirstName,$MI,$LastName,$Month,$Day,$Year,$Sex,$Address,$Country;
  38.  
  39.         if (strlen($UserID) < 6 || strlen($UserID) > 50 || !preg_match("/^[a-zA-Z0-9_-]+$/", $UserID)) {
  40.             $error .= "'$UserID', Nombre de usuario no valido. Solo letras, se permiten números en este campo (longitud 6 ~ 50).<br/>";
  41.             return 0;
  42.         }
  43.        
  44.         if (strlen($Password) < 6 || strlen($Password) > 30 || !preg_match("/^[a-zA-Z0-9_-]+$/", $Password)) {
  45.             $error .= "Contraseña no valida. Solo letras, se permiten números en este campo (longitud 6 ~ 30).<br/>";
  46.             return 0;
  47.         }
  48.  
  49.         if (strlen($UserKey) != 7 || !preg_match("/^[0-9]/", $UserKey)) {
  50.             $error .= "Llave secreta no valida. Debe ser un numero de 7 digitos.<br/>";
  51.             return 0;
  52.         }
  53.  
  54.         if ($Password != $CPassword) {
  55.             $error .= "Las contraseñas no coinciden...<br/>";
  56.             return 0;
  57.         }
  58.  
  59.         $SecretQuestion = str_replace("'", "''", $SecretQuestion);
  60.  
  61.         if (!is_email($Email)) {
  62.             $error .= "Correo electronico no valido.<br/>";
  63.             return 0;
  64.         }
  65.  
  66.         if (!preg_match("/^[a-zA-Z 0-9_-]+$/", $Answer) || strlen($Answer) == "0") {
  67.             $error .= "Respuesta no valida.. Solo letras y numeros estan permitidos.<br/>";
  68.             return 0;
  69.         }
  70.  
  71.         if (!preg_match("/^[a-zA-Z_-]+$/", $FirstName) || strlen($FirstName) == "0") {
  72.             $error .= "Nombre no valido.. Solo letras estan permitidas.<br/>";
  73.             return 0;
  74.         }
  75.  
  76.         if (!preg_match("/^[a-zA-Z_-]+$/", $LastName) || strlen($LastName) == "0") {
  77.             $error .= "Apellido no valido.. Solo letras estan permitidas.<br/>";
  78.             return 0;
  79.         }
  80.  
  81.         if (strlen($MI) != 1 || !preg_match("/^[a-zA-Z_-]+$/", $MI)) {
  82.             $error .= "Inicial no valido. Solo letras estan permitidas.<br/>";
  83.             return 0;
  84.         }
  85.  
  86.         if ($Month > 12 || $Month < 1 || !preg_match("/^[0-9]/", $Month) || strlen($Month) == "0") {
  87.             $error .= "Mes de fecha de nacimiento no valido.<br/>";
  88.             return 0;
  89.         }
  90.  
  91.         if ($Day > 31 || $Day < 1 || !preg_match("/^[0-9]/", $Day) || strlen($Day) == "0") {
  92.             $error .= "Dia de fecha de nacimiento no valido.<br/>";
  93.             return 0;
  94.         }
  95.  
  96.         if ($Year > 2007 || $Year < 1950 || !preg_match("/^[0-9]/", $Year) || strlen($Year) == "0") {
  97.             $error .= "Año de fecha de nacimiento no valido.<br/>";
  98.             return 0;
  99.         }
  100.  
  101.         if ($Sex != 1 && $Sex != 2) {
  102.             $error .= "Genero no valido.<br/>";
  103.             return 0;
  104.         }
  105.  
  106.  
  107.         if (!preg_match("/^[a-zA-Z 0-9_-]+$/", $Country)) {
  108.             $error .= "País no valido.<br/>";
  109.             return 0;
  110.         }
  111.  
  112.  
  113.         if(file_exists($accdir."\\".$initial."\\".$userid.".tad"))
  114.         {
  115.             $error .= "Account already exist.";
  116.             return 0;
  117.         }
  118.        
  119.        
  120.         $wea = mssql_query("SELECT UserID FROM Account where UserID='$UserID'");
  121.         $row = mssql_fetch_row($wea);
  122.        
  123.         if ($row[0] != "") {
  124.             $error .= "Nombre de usuario en uso, Porfavor elije otro.<br/>";
  125.             return 0;
  126.         }
  127.  
  128.         $wea2 = mssql_query("SELECT Email FROM Account where Email='$Email'");
  129.         $row2 = mssql_fetch_row($wea2);
  130.        
  131.         if ($row2[0] != "") {
  132.             $error .= "Email en uso, Porfavor selecciona otro.<br/>";
  133.             return 0;
  134.         }
  135.        
  136.     return 1;
  137.     }
  138.    
  139.    
  140.  
  141.     if (!AllOK())
  142.     {
  143.         $result = $error;
  144.     }
  145.     else   //BUENO EN ESTA PARTE QUIERO METER EL USER Y EL PASS EN UN ARCHIVO .TD QUE ES BINARIO
  146.     {
  147.         $result = "¡Cuenta registrada con exito!";
  148.         $initial="etc";
  149.         $passwordmd5=strtoupper(md5($password));
  150.         $f=@fopen("./inc/sample.tad",r) or die("Error"); // esta parte esta fatal
  151.             $acc = @fread($f,7124);
  152.             $demoid=substr($acc,0,$userlenght);
  153.             $demopass=substr($acc,52,32);
  154.             $acc = str_replace($demoid,$userid,$acc);
  155.             $acc = str_replace($demopass,$passwordmd5,$acc);
  156.             $f2=@fopen($accdir."\\".$initial."\\".$userid.".tad",a);
  157.             @fwrite($f2,$acc) or die("Error");
  158.             @fclose($f);
  159.            
  160.            
  161.  
  162.         mssql_query("INSERT INTO Account VALUES ('$Email', '$UserID', '$Password' , '$UserKey', '0', NULL, NULL, NULL, '$SecretQuestion', '$Answer', '$FirstName', '$MI', '$LastName', '$Month/$Day/$Year 00:00:00', '$Sex', '$Address', NULL, NULL, '$Country', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '$_SERVER[REMOTE_ADDR]', newid(), GETDATE(), 1, NULL, 0, 0, 0, NULL, 0, 1, NULL, 0, 0, NULL, NULL, 0)");
  163.         mssql_query("DECLARE    @return_value int,
  164.         @NCashResult int,
  165.         @NCashMsg nvarchar(100)
  166.  
  167. EXEC    @return_value = [dbo].[AccountInsertUserInBilling]
  168.         @Email = N'".$Email."',
  169.         @NCashResult = @NCashResult OUTPUT,
  170.         @NCashMsg = @NCashMsg OUTPUT");
  171.  
  172.     }
  173.  
  174.  
  175.  
  176.  
  177.  
  178.     include('plantilla/registrocompleto.php');
  179.  
  180. }
  181. else
  182. {
  183.     include('plantilla/registro.php');
  184. }
  185.  
  186. ?>

Pues el asunto es que aparte de que haga la modificación y lo genere también guarde los datos en mi tabla pues el ya hace el INSERT pero lo del archivo nop ayúdenme plix no soy muy experta en esto.... (Perdonen si el código es un desastre).