1. PHP / Говнокод #4888

    +165

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    <?php 
    header("Content-Type: text/html; charset=windows-1251");
    defined('_JEXEC') or die('<html>
    <head><title>404 Not Found</title></head>
    <body bgcolor="white">
    <center><h1>404 Not Found</h1></center>
    <hr><center>nginx/0.7.59</center>
    </body>
    </html>');
    $url = $_SERVER['HTTP_HOST'];
    $host = $_SERVER['DOCUMENT_ROOT'];
    
    if(!file_exists($host."/data/conf.php")) die("Система не установленна!");
    
    include $host.'/data/conf.php';
    
     function generate_password($a)  
      {  
        if($a==1){
    	return rand(111111,99999999); }
        else if($a==2){
        $arr = array('a','b','c','d','e','f',  
                     'g','h','i','j','k','l',  
                     'm','n','o','p','r','s',  
                     't','u','v','x','y','z', 
    				 );      $pass = "";  
    	$n = rand(6,10);
        for($i = 0; $i < $n; $i++)  
        {  
          $index = rand(0, count($arr) - 1);  
          $pass .= $arr[$index];  
        }  
        return $pass; }
    	else if($a==3){
        $arr = array('a','b','c','d','e','f',  
                     'g','h','i','j','k','l',  
                     'm','n','o','p','r','s',  
                     't','u','v','x','y','z',  
                     'A','B','C','D','E','F',  
                     'G','H','I','J','K','L',  
                     'M','N','O','P','R','S',  
                     'T','U','V','X','Y','Z', 
    				 );      $pass = "";  
    	$n = rand(6,10);
        for($i = 0; $i < $n; $i++)  
        {        
          $index = rand(0, count($arr) - 1);  
          $pass .= $arr[$index];  
        }  
        return $pass; }
    	else if($a==4){
        $arr = array('a','b','c','d','e','f',  
                     'g','h','i','j','k','l',  
                     'm','n','o','p','r','s',  
                     't','u','v','x','y','z',  
                     'A','B','C','D','E','F',  
                     'G','H','I','J','K','L',  
                     'M','N','O','P','R','S',  
                     'T','U','V','X','Y','Z',  
                     '1','2','3','4','5','6',  
                     '7','8','9','0', 
    				 );     $pass = "";  
    	$n = rand(10,16);
        for($i = 0; $i < $n; $i++)  
        {  
          $index = rand(0, count($arr) - 1);  
          $pass .= $arr[$index];  
        }  
        return $pass;  }
    	else if($a==5){
      $arr = array('a','b','c','d','e','f',  
                     'g','h','i','j','k','l',  
                     'm','n','o','p','r','s',  
                     't','u','v','x','y','z',  
                     'A','B','C','D','E','F',  
                     'G','H','I','J','K','L',  
                     'M','N','O','P','R','S',  
                     'T','U','V','X','Y','Z',  
                     '1','2','3','4','5','6',  
                     '7','8','9','0','.',',',  
                     '(',')','[',']','!','?',  
                     );      $pass = "";  
    	$n = rand(10,16);
        for($i = 0; $i < $n; $i++)  
        {  
          $index = rand(0, count($arr) - 1);  
          $pass .= $arr[$index];  
        }  
        return $pass; }
     
      }   // генератор паролей

    qbasic, 10 Декабря 2010

    Комментарии (23)
  2. Pascal / Говнокод #4887

    +102

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    function FileIsBusy(AFileName: string): Boolean;
    var
      F: Integer;
    begin
      F := FileOpen(AFileName, fmShareExclusive);
      Result := F = -1;
      FileClose(F);
    end;
    
    function WaitFile(AFileName: string; ASpeepDelay: integer): Boolean;
    begin
      while FileIsBusy(AFileName) do
        Sleep(ASpeepDelay);
      Result := True;
    end;

    пока юзверь ковыряется в Ворде, другой процесс мечтает овладеть файлом
    "It is necessary to wait of end of editing Microsoft Office files.I use next conventional approach: file is editing While file is busy" (ингриш - питерского разлива)

    это stackoverflow такими сниппетами переполнено

    bugmenot, 10 Декабря 2010

    Комментарии (24)
  3. PHP / Говнокод #4886

    +168

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    <?php
    ...
    $string = array();
    ...
    ?>

    hidespb, 10 Декабря 2010

    Комментарии (36)
  4. C++ / Говнокод #4885

    +163

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    //
    				if (delay == 0)
    				{
    					Uint8 *keys = SDL_GetKeyState(NULL);
    					// Checking for letters
    					for (c = 97; c < 123; c++)
    						if (cpos < 9)
    							if (keys[c] && !delay)
    							{
    								mapname[cpos] = c;
    								mapname[++cpos] = '\0';
    								delay = 5;
    								
    								bg.show(400, 240, 0);
    								text.print(mapname, 200, 180);
    								render.backend();
    								
    								break;
    							}
    					// Checking for numbers
    					for (c = 48; c < 58; c++)
    						if (cpos < 9)
    							if (keys[c] && !delay)
    							{
    								mapname[cpos] = c;
    								mapname[++cpos] = '\0';
    								delay = 5;
    								
    								bg.show(400, 240, 0);
    								text.print(mapname, 200, 180);
    								render.backend();
    								
    								break;
    							}
    					// On pressing ENTER
    					if (keys[13] && !delay && strlen(mapname) > 2)
    						break;
    					// On pressing BACKSPACE
    					if (keys[SDLK_BACKSPACE] && cpos > 0 && !delay)
    					{
    						mapname[--cpos] = '\0';
    						delay = 5;
    						
    						bg.show(400, 240, 0);
    						if (cpos > 0) text.print(mapname, 200, 180);
    						render.backend();
    					}
    				}
    				
    				if (delay > 0)
    					delay--;

    Уверен, можно было сделать намного проще =)

    wh_, 10 Декабря 2010

    Комментарии (17)
  5. C++ / Говнокод #4884

    +159

    1. 1
    int** ppi = new int*;

    bot225, 09 Декабря 2010

    Комментарии (56)
  6. Си / Говнокод #4883

    +146

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    #include <fcntl.h>
    #include <stdio.h>
    #include <unistd.h>
    #include <string.h>
    
    // man sendfile
    
    int main (int argc, char **argv, char **envp) {
      while(
    	  (
    	    argc < 0 // true if all ok, false on first iter
    	    ||  
    	    (
    	      argc != 2 // true if error
    	      && 
    	      (printf("usage %s filename\n", argv[0]) && 0 == (argc = 0))// show error (true)
    	    ) // true if error, and argc == 0
    	    ||
    	    (
    	      ((argc = open(argv[1], O_RDONLY) * -1) < 0) // false if error
    	      ||
    	      (printf("cannot open %m\n") && 0 == (argc = 0))// show error (true)
    	    ) 
    	  ) // true if all ok, also argc != 0
    	  && 
    	  (
    	    argc < 0 // if open success this is true
    	    &&
    	    (read(argc * -1, memset(envp[1], 0, 1025), 1024) > 0 && printf("%s", envp[1])) || (close(argc * -1))
    	  )
           ) ;
    }

    работает и под linux и под cygwin (gcc какие были под рукой)

    затрудняюсь определить парадигму :)

    Anonimous, 09 Декабря 2010

    Комментарии (31)
  7. Куча / Говнокод #4882

    +144

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    <html>
    <head>
    <TITLE>Бесплатные форумы. Дизайн phpBB, возможности vbulletin, скорость FastBB</TITLE>
    <STYLE>
    body {font: Verdana; }
    </STYLE>
    </head>
    <BODY bgColor=#ffffff leftMargin=50 topMargin=5 marginheight="5" marginwidth="50" style="margin:50px;margin-top:5px;margin-bottom:5px;">
    <center><br><br> <br> <br> <br> <br> <br> <br> <br>  
    <h1>На сервере ведутся работы. Пожалуйста, зайдите позже.</h1>
    
    </body>
    </html>

    html код аварийной странички сервиса borda.ru

    espr, 09 Декабря 2010

    Комментарии (33)
  8. C# / Говнокод #4881

    +121

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    private static long generateUniqueSetID(DataContext context)
            {
                long id;
                do
                {
                    id = BitConverter.ToInt64(Guid.NewGuid().ToByteArray(), 0) - DateTime.UtcNow.Ticks;
                } while (s_sets.Contains(id));
    
                if (!context.Sets.Where(s => s.SetID == id).Any())
                {
                    s_sets.Add(id);
                    return id;
                }
    
                return generateUniqueSetID(context);
            }

    это как можно хоть с трудом и догадаться генерация уникального Id для вставки в таблицу. Таблицу чел делал сам и создавать ключик как int его никто не заставлял.

    eval_2009, 09 Декабря 2010

    Комментарии (3)
  9. JavaScript / Говнокод #4880

    +157

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    function processGetPost() {
      var myajax=ajaxpack.ajaxobj;
      var myfiletype=ajaxpack.filetype;
      if (myajax.readyState == 4) {
        if (myajax.status==200 || window.location.href.indexOf("http")==-1) {
          if (myfiletype=="txt") {}
          else {
            var resp = myajax.responseXML;
    	var xmlRoot = resp.documentElement;
    	dateArray = xmlRoot.getElementsByTagName("putdate");
    	userArray = xmlRoot.getElementsByTagName("name");
    	var html = "<table border='1'><tr><th>Время входа</th>";
    	html += "<th>Имя пользователя</th></tr>";
    	var conlines = dateArray.length;
    	if (conlines) {
    	  for (var i=0; i<conlines; i++) {
    	    html += "<tr>";
    	    html += "<td>"+dateArray.item(i).firstChild.data+"</td>";
    	    html += "<td>"+userArray.item(i).firstChild.data+"</td>";
    	    html += "</tr>";
    	  }
    	}
    	html += "</table>";
    	myDiv = document.getElementById("onlines");
    	myDiv.innerHTML = html;
         }
         timerID = setTimeout("ajaxpack.getAjaxRequest('active_users.php','',processGetPost,'xml');", 5000);
       }
     }
    }

    Мой говнокод 4-х летней давности, но воняет до сих пор. 6-ая строчка особенно убивает.

    dwinner, 09 Декабря 2010

    Комментарии (0)
  10. PHP / Говнокод #4879

    +163

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    if ($_GET)
    {
    if (!empty($_GET['kol'])) {$k=$_GET['kol'];}
    else $k=1;
    if (!empty($_GET['diametr'])) {$d=$_GET['diametr'];}
    else $d=1;
    if (!empty($_GET['zaves'])) {$z=$_GET['zaves'];}
    else $z=1;
    if($z!=1)
    	{
    	if (!empty($_GET['rasst'])) {$r=$_GET['rasst']; }
    		else $r=1;
    	if (!empty($_GET['terra'])) {$t=$_GET['terra']; }
    	else $t=1; }
    else {$r=1;$t=1;}
    $sum=1;
    
    $sum=$k*$z*$t*$r;
    echo "<b><center>";
    switch ($d):
     case "10": $sum*=500;echo "примерная стоимость".$sum."рублей"; break;
     case "20": $sum*=1000;echo "примерная стоимость".$sum."рублей"; break;
     case "30": $sum*=2000;echo "примерная стоимость".$sum."рублей"; break;
     case "40": $sum*=3000;echo "примерная стоимость".$sum."рублей"; break;
     case "50": $sum*=3500;echo "примерная стоимость".$sum."рублей"; break;
     case "60": $sum*=4000;echo "примерная стоимость".$sum."рублей"; break;
     case "70": $sum*=4500;echo "примерная стоимость".$sum."рублей"; break;
     default: echo 'требуется консультация по телефону :)';
     endswitch;
     echo "</b></center>";
    }

    Shiz89, 09 Декабря 2010

    Комментарии (23)