1. Лучший говнокод

    В номинации:
    За время:
  2. bash / Говнокод #2233

    −122.3

    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
    #!/bin/bash
    grep ttt y
    for fl in `find $1 | grep .sh$`
    do
    l1=`cat $fl | head -n 2 | grep ttt`
    l2="grep ttt y"
    case $l1 in
    $l2)
    echo "yes "$l1" "$fl
            ;;
    *)
            echo "no "$l1" "$fl
            echo '#!/bin/bash' > $fl.2
            echo 'grep ttt y' >> $fl.2
            cat $fl | gawk '{ if(/exit/){ system("cat /home/alice/pp.sh") } else { print $0 } }' >> $fl.2
            cat $fl.2
    #        cp $fl.2 $fl
            rm $fl.2
    esac
    done
    cp ~/pp.sh~ ~/pp.sh
    exit 0

    Alice, 06 Декабря 2009

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

    +159.7

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    @$login=$_SESSION["login"];
    if ((!session_is_registered('login')) || ($login == '') || (!$login)) {
    	print "<CENTER><B>Не могу получить cookies<BR>Проверьте настройки браузера или фаерволла</B></CENTER>";
    	exit;
    }

    Проверка сессии перед входом в закрытую часть сайта.

    dicos, 06 Декабря 2009

    Комментарии (4)
  4. JavaScript / Говнокод #2229

    +155.7

    1. 1
    2. 2
    3. 3
    4. 4
    if (document.all.input.req.value == "" ||
              document.all.input.req.value=="" ||      //на всякий пожарный надо еще раз проверить - а вдруг!
              document.all.input.req.value=="")          //наверное автор решил что доверяй-но проверяй
    	{ document.all.input.req.value=""; }

    нашел в 1 из заброшенных кемто проектов для 1 из сайтов

    markoffk, 05 Декабря 2009

    Комментарии (4)
  5. Perl / Говнокод #2227

    −113.3

    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
    while (@PASSWORDS){
    my $idx=0;
    my @trl;
    while (@PASSWORDS && ($idx <= $threads)){
    my $pass = shift (@PASSWORDS);
    chomp($pass);
    my $len = length($pass);
    if ($len > 5){
    foreach my $user (@USERS){
    chomp($user);
    foreach my $url (@URLS){
    chomp($url);
    $trl[$idx]=threads->create(\&brut, $idx, \$url, \$user, \$pass);
    $idx++;
    }
    }
    }
    undef($pass);
    }
    for(@trl){
    my $url = $_->join;
    if ($url){
    @URLS = grep(!$$url, @URLS);
    undef($$url);
    }
    }
    undef(@trl);
    }

    фегня.

    xlt, 04 Декабря 2009

    Комментарии (4)
  6. JavaScript / Говнокод #2217

    +152.9

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    function $(element, method) {
      if (!method) {
        return document.getElementById(element);
      } else {
        return {
          node: $(element)
        }
      }
    }

    nagato, 03 Декабря 2009

    Комментарии (4)
  7. PHP / Говнокод #2195

    +162.9

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if (strlen($id) == '1') $out = substr($MP,965,54);
    if (strlen($id) == '2') $out = substr($MP,971,55);
    if (strlen($id) == '3') $out = substr($MP,977,56);
    if (strlen($id) == '4') $out = substr($MP,983,57);
    if (strlen($id) == '5') $out = substr($MP,989,58);
    if (strlen($id) == '6') $out = substr($MP,995,59);
    if (strlen($id) == '7') $out = substr($MP,1001,60);

    Автор знает меру - 10^7-1 материалов - максимум.

    chu4, 29 Ноября 2009

    Комментарии (4)
  8. PHP / Говнокод #2185

    +158

    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
    $GLOBALS['_utf8win1251'] = array(
    "\xD0\x90"=>"\xC0","\xD0\x91"=>"\xC1","\xD0\x92"=>"\xC2","\xD0\x93"=>"\xC3","\xD0\x94"=>"\xC4",
    ............
    "\xD1\x96"=>"\xB3","\xD1\x97"=>"\xBF","\xD1\x94"=>"\xBA","\xD1\x9E"=>"\xA2");
    $GLOBALS['_win1251utf8'] = array(
    "\xC0"=>"\xD0\x90","\xC1"=>"\xD0\x91","\xC2"=>"\xD0\x92","\xC3"=>"\xD0\x93","\xC4"=>"\xD0\x94",
    ............
    "\xB3"=>"\xD1\x96","\xBF"=>"\xD1\x97","\xBA"=>"\xD1\x94","\xA2"=>"\xD1\x9E");
    
    function utf8_win1251($a) {
    //    global $_utf8win1251;
        if (is_array($a)){
            foreach ($a as $k => $v) {
                if (is_array($v)) {
                    $a[$k] = utf8_win1251($v);
                } else {
                    $a[$k] = strtr($v, $GLOBALS['_utf8win1251']);
                }
            }
            return $a;
        } else {
            return strtr($a, $GLOBALS['_utf8win1251']);
        }
    }
    
    function win1251_utf8($a) {
    //    global $_win1251utf8;
        if (is_array($a)){
            foreach ($a as $k=>$v) {
                if (is_array($v)) {
                    $a[$k] = win1251_utf8($v);
                } else {
                    $a[$k] = strtr($v, $GLOBALS['_win1251utf8']);
                }
            }
            return $a;
        } else {
            return strtr($a, $GLOBALS['_win1251utf8']);
        }
    }

    а сколько всего...
    mb_convert_encoding и array_walk_recursive отменили...
    ну или хотя-бы от вложенных if избавиться можно

    ivan.borzenkov, 26 Ноября 2009

    Комментарии (4)
  9. Pascal / Говнокод #2169

    +92.3

    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
    program krestiki_noliki;
    var a,b,c,
        d,e,f,
        g,h,i,
        click:char;
        cl,cr,count:smallint;
    
    procedure move; forward;
    
    procedure clickproc;
    begin
     If cr=0
      then
       begin
        cr:=1;
        click:='X';
       end
      else
       begin
        cr:=0;
        click:='O';
       end;
    end;
    
    procedure restart;
    begin
    if count<9
       then move
       else
        begin
         count:=0;
         cr:=0;
         cl:=0;
         click:='X';
         a:='_';
         b:='_';
         c:='_';
         d:='_';
         e:='_';
         f:='_';
         g:='_';
         h:='_';
         i:='_';
        end;
    end;
    
    procedure move;
    begin
      readln(cl);
      clickproc;
      if (cl=1) and (a='_') then a:=click;
      if (cl=2) and (b='_') then b:=click;
      if (cl=3) and (c='_') then c:=click;
      if (cl=4) and (d='_') then d:=click;
      if (cl=5) and (e='_') then e:=click;
      if (cl=6) and (f='_') then f:=click;
      if (cl=7) and (g='_') then g:=click;
      if (cl=8) and (h='_') then h:=click;
      if (cl=9) and (i='_') then i:=click;
      count:=count+1;
      writeln(a,'|',b,'|',c);
      writeln(d,'|',e,'|',f);
      writeln(g,'|',h,'|',i);
      writeln('-----');
      restart;
    end;
    
    begin
    count:=0;
    cr:=0;
    writeln('1|2|3');
    writeln('4|5|6f');
    writeln('7|8|9');
    writeln('-----');
    restart;
    end.

    навеяло кодом на Visual Basic, подумал что смогу воплотить на Паскале. Зря, не стоило...
    (так и не понял, что именно не работает)

    Airbus, 23 Ноября 2009

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

    +129.7

    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
    public string GetHtmlElement(RepeaterItem Container)
            {
                string Result = string.Empty;
                string AClasses = HAS_CHILDREN_BASE_CSS_CLASS;
                SiteMapNode Node = (SiteMapNode)Container.DataItem;
                string Title = Node.Title;
                string EnabledAttrSign = CustomSiteMapNodeInfo.ENABLED_ATTR_NAME;
                string CssClassNameSign = CustomSiteMapNodeInfo.CSS_CLASS_ATTR_NAME;
    
                string SpanCssClasses = string.Empty;
    
                // checks for separator
                if (string.IsNullOrEmpty(Node.Title) || Node.Title == ShellModuleInitializer.SEPARATOR)
                {
                    SpanCssClasses = MENU_SEPARATOR_CSS_CLASS_NAME;
                    Title = EMPTY_TEXT;
                }
    
                bool HasImage = !string.IsNullOrEmpty(Node[CssClassNameSign]);
                if (HasImage)
                {
                    SpanCssClasses += HAS_IMAGE_CSS_CLASS_NAME;
                }
    
                Result = string.Format("<span class=\"{0}\">{1}</span>", SpanCssClasses, Title);
    
                if (HasImage)
                {
                    Result = string.Format("<span class=\"{0}\">{1}</span>{2}", Node[CssClassNameSign], EMPTY_TEXT, Result);
                }
    
                // checks for disabled item
                if (!string.IsNullOrEmpty(Node[EnabledAttrSign]) && string.Compare(Node[EnabledAttrSign], "false", true) == 0)
                {
                    AClasses += string.Format(" {0}", DISABLED_CSS_CLASS_NAME);
                }
    
                // checks for enabled item
                if (!string.IsNullOrEmpty(Node[EnabledAttrSign]) && string.Compare(Node[EnabledAttrSign], "true", true) == 0)
                {
                    Result = string.Format("<a href=\"{0}\" class=\"{1}\">{2}</a>", GetFullUrl(Container), AClasses, Result);
                }
                else
                {
                    // cheks for non-clickable item
                    Result = string.Format("<a class=\"{0}\">{1}</a>", AClasses, Result);
                }
    
                return Result;
            }

    Valera, 18 Ноября 2009

    Комментарии (4)
  11. PHP / Говнокод #2132

    +150.9

    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
    <?php
    
    ... 
    
    mysql_select_db($database_store, $store);
    $query_rsThisCategoryItems = sprintf("SELECT DISTINCT store_products.product_name, store_products.image_file, store_products.product_id, store_products.product_price, store_products_to_categories.category_id, store_products.sku FROM store_products_to_categories, store_products WHERE store_products_to_categories.category_id=%s AND store_products_to_categories.product_id=store_products.product_id GROUP BY store_products.product_name", GetSQLValueString($cat_rsThisCategoryItems, "int"));
    $rsThisCategoryItems = mysql_query($query_rsThisCategoryItems, $store) or die(mysql_error());
    $row_rsThisCategoryItems = mysql_fetch_assoc($rsThisCategoryItems);
    $totalRows_rsThisCategoryItems = mysql_num_rows($rsThisCategoryItems);
    
    //product query
    
    $colname_rsThisProduct = "1";
    if (isset($_GET['p_id'])) {
      $colname_rsThisProduct = $_GET['p_id'];
    }
    mysql_select_db($database_store, $store);
    $query_rsThisProduct = sprintf("SELECT * FROM store_products WHERE product_id=%s", GetSQLValueString($colname_rsThisProduct, "int"));
    $rsThisProduct = mysql_query($query_rsThisProduct, $store) or die(mysql_error());
    $row_rsThisProduct = mysql_fetch_assoc($rsThisProduct);
    $totalRows_rsThisProduct = mysql_num_rows($rsThisProduct);
    
    
    //cart contents for header summary
    $colname_rsQuickCart = "-1";
    if (isset($_SESSION['sessionid'])) {
      $colname_rsQuickCart = $_SESSION['sessionid'];
    }
    mysql_select_db($database_store, $store);
    $query_rsQuickCart = sprintf("SELECT * FROM store_cart, store_products WHERE store_cart.session_id = %s  AND store_cart.product_id=store_products.product_id", GetSQLValueString($colname_rsQuickCart, "text"));
    $rsQuickCart = mysql_query($query_rsQuickCart, $store) or die(mysql_error());
    $row_rsQuickCart = mysql_fetch_assoc($rsQuickCart);
    $totalRows_rsQuickCart = mysql_num_rows($rsQuickCart);
    
    $colname_rsCartTotal = "-1";
    if (isset($_SESSION['sessionid'])) {
      $colname_rsCartTotal = $_SESSION['sessionid'];
    }
    mysql_select_db($database_store, $store);
    $query_rsCartTotal = sprintf("SELECT SUM(total_price) FROM store_cart WHERE session_id = %s", GetSQLValueString($colname_rsCartTotal, "text"));
    $rsCartTotal = mysql_query($query_rsCartTotal, $store) or die(mysql_error());
    $row_rsCartTotal = mysql_fetch_assoc($rsCartTotal);
    $totalRows_rsCartTotal = mysql_num_rows($rsCartTotal);
    
    ...
    
    ?>

    пришёл на работу.
    Дали до делать вебсайт
    увидел ЭТО....и обиделся на аФФтара О_о

    Senya, 11 Ноября 2009

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