Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> błąd przy tworzeniu listy md5
siurek22
post
Post #1





Grupa: Zarejestrowani
Postów: 62
Pomógł: 2
Dołączył: 24.02.2008

Ostrzeżenie: (0%)
-----


Napisałem oto taki skrypt:
  1. <?php
  2.     $alphabet = array(
  3.                 1=>'a',
  4.                 2=>'b',
  5.                 3=>'c',
  6.                 4=>'d',
  7.                 5=>'e',
  8.                 6=>'f',
  9.                 7=>'g',
  10.                 8=>'h',
  11.                 9=>'i',
  12.                 10=>'j',
  13.                 11=>'k',
  14.                 12=>'l',
  15.                 13=>'m',
  16.                 14=>'n',
  17.                 15=>'o',
  18.                 16=>'p',
  19.                 17=>'q',
  20.                 18=>'r',
  21.                 19=>'s',
  22.                 20=>'t',
  23.                 21=>'u',
  24.                 22=>'v',
  25.                 23=>'w',
  26.                 24=>'x',
  27.                 25=>'y',
  28.                 26=>'z',
  29.                 27=>'0',
  30.                 28=>'1',
  31.                 29=>'2',
  32.                 30=>'3',
  33.                 31=>'4',
  34.                 32=>'5',
  35.                 33=>'6',
  36.                 34=>'7',
  37.                 35=>'8',
  38.                 36=>'9',
  39.                 37=>'-',
  40.                 38=>'_'
  41.                 );
  42.         $num=1000;
  43. $z=0;
  44. $i=0;
  45.     while ($i < $num) {
  46.     $los=@mysql_query("SELECT * FROM ile");
  47.                 $logs=@mysql_result($los,$z,"ile");
  48.                 $logs2=@mysql_result($los,$z,"ile2");
  49.                 $logs3=@mysql_result($los,$z,"ile3");
  50.                 $logs4=@mysql_result($los,$z,"ile4");
  51.                 $logs5=@mysql_result($los,$z,"ile5");
  52.                 $logs6=@mysql_result($los,$z,"ile6");
  53.                 $logs7=@mysql_result($los,$z,"ile7");
  54.                 $logs8=@mysql_result($los,$z,"ile8");
  55.                 $logs9=@mysql_result($los,$z,"ile9");
  56.         $aza='1';
  57.         $aba='39';    
  58.                     if($logs9=='38')
  59.                 {
  60.                 mysql_query("UPDATE ile SET ile9=0, ile8=ile8+1 WHERE id=1");
  61.                 }    
  62.                 if($logs8==$aba)
  63.                 {
  64.                 mysql_query("UPDATE ile SET ile8='$aza', ile7=ile7+1 WHERE id=1");    
  65.                             }    
  66.                     if($logs7==$aba)
  67.                 {
  68.                 mysql_query("UPDATE ile SET ile7='$aza', ile6=ile6+1 WHERE id=1");
  69.                 }    
  70.                 if($logs6==$aba)
  71.                 {
  72.                 mysql_query("UPDATE ile SET ile6='$aza', ile5=ile5+1 WHERE id=1");
  73.                 }    
  74.                 if($logs5==$aba)
  75.                 {
  76.                 mysql_query("UPDATE ile SET ile5='$aza', ile4=ile4+1 WHERE id=1");
  77.                 }    
  78.                                 if($logs4==$aba)
  79.                 {
  80.                 mysql_query("UPDATE ile SET ile4='$aza', ile3=ile3+1 WHERE id=1");
  81.                 }    
  82.                                 if($logs3==$aba)
  83.                 {
  84.                 mysql_query("UPDATE ile SET ile3='$aza', ile2=ile2+1 WHERE id=1");
  85.                 }    
  86.                                 if($logs2==$aba)
  87.                 {
  88.                 mysql_query("UPDATE ile SET ile2='$aza', ile1=ile1+1 WHERE id=1");
  89.                 }    
  90.                                                 if($logs==0)
  91.                 {$logs='';}
  92.                 if($logs2==0)
  93.                 {$logs2='';}
  94.                 if($logs3==0)
  95.                 {$logs3='';}
  96.                 if($logs4==0)
  97.                 {$logs4='';}    
  98.                 if($logs5==0)
  99.                 {$logs5='';}
  100.                 if($logs6==0)
  101.                 {$logs6='';}
  102.                 if($logs7==0)
  103.                 {$logs7='';}    
  104.                             if($logs8==0)
  105.                 {$logs8='';}    
  106.                             if($logs9==0)
  107.                 {$logs9='';}
  108.                                     $litera=$alphabet[$logs];
  109.     $litera2=$alphabet[$logs2];
  110.     $litera3=$alphabet[$logs3];
  111.     $litera4=$alphabet[$logs4];
  112.     $litera5=$alphabet[$logs5];
  113.     $litera6=$alphabet[$logs6];
  114.     $litera7=$alphabet[$logs7];
  115.     $litera8=$alphabet[$logs8];
  116.     $litera9=$alphabet[$logs9];
  117.     $haslo=$litera.$litera2.$litera3.$litera4.$litera5.$litera6.$litera7.$litera8.$litera9;
  118.     $md5=md5($haslo);
  119.                 
  120.     @mysql_query("INSERT INTO md5 VALUES ('','$haslo','$md5')");    
  121.     @mysql_query("UPDATE ile SET ile9=ile9+1");
  122.         
  123.     $i++;
  124.     }
  125. ?>


ktory kozysta z tabel

  1. <?php
  2. $query1= "CREATE TABLE md5
  3. (id int(60) NOT NULL auto_increment,
  4. haslo varchar(15) NOT NULL, 
  5. pass varchar(34) NOT NULL, 
  6.  
  7. PRIMARY KEY (id))";
  8. mysql_query($query1);
  9.  
  10. $query2= "CREATE TABLE ile
  11. (id int(60) NOT NULL auto_increment,
  12. ile int(2) NOT NULL, 
  13. ile2 int(2) NOT NULL, 
  14. ile3 int(2) NOT NULL, 
  15. ile4 int(2) NOT NULL, 
  16. ile5 int(2) NOT NULL, 
  17. ile6 int(2) NOT NULL, 
  18. ile7 int(2) NOT NULL, 
  19. ile8 int(2) NOT NULL, 
  20. ile9 int(2) NOT NULL, 
  21.  
  22. PRIMARY KEY (id))";
  23. mysql_query($query2);
  24. ?>


skrypt niby działa poprawnie ale do czasu gdy zajrzy się zawartości tabeli md5
(IMG:http://www.vpx.pl/up/20080503/22000223849928de6fa6d2d7d5936879989838103889.png)
jak widać na obrazku przy rekordzie 1483 który powinien zawierać "aaa" mamy tylko "a" sytuacja powtarza się przy każdym wyrażeniu 3 znakowym i wyżej

siedzę nad tym już 3 dzień i nie mogę dojść dlaczego tak się dzieje (IMG:http://forum.php.pl/style_emoticons/default/sad.gif)

Ten post edytował siurek22 3.05.2008, 22:24:31
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
phpion
post
Post #2





Grupa: Moderatorzy
Postów: 6 072
Pomógł: 861
Dołączył: 10.12.2003
Skąd: Dąbrowa Górnicza




Skoro bawicie się w generowanie tabeli z hasłami md5 może przyda wam się moja funkcja, której zadaniem jest tworzenie różnych kombinacji na podstawie dostarczonej tablicy.
  1. <?php
  2. function array_combination(&$array, &$chars, $length, $startWith = '', $currentLength = 0) {
  3. if ($currentLength < $length) {
  4. foreach ($chars as $char) {
  5. array_push($array, $startWith.$char);
  6.  
  7. array_combination($array, $chars, $length, $startWith.$char, $currentLength+1);
  8. }
  9. }
  10. }
  11.  
  12. $array = array();
  13. $chars = array_merge(range('a', 'z'), range('A', 'Z'), range('0', '9'), array('-', '_'));
  14.  
  15. array_combination($array, $chars, 3);
  16.  
  17. print_r($array);
  18. ?>

Przyjemnej zabawy (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif)
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 7.10.2025 - 11:46