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

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

    +151

    1. 1
    #define xxx 1 ? 2 : 3

    guest, 10 Февраля 2009

    Комментарии (0)
  3. C++ / Говнокод #509

    +151

    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 "stdafx.h"
    
    class CTest
    {
    private:
      virtual void Print()
      {
        _tprintf( _T("He he ;)\n"));
      }
    };
    
    class CX
    {
    public:
      virtual void BlaBla();
    };
    
    int _tmain(int argc, _TCHAR* argv[])
    {
      CTest t;
    
      //error C2248: 'CTest::Print' : cannot access private member declared in class 'test'
      //t.Print();
    
      //It works
      ((void (*)(void))((int*)(*(int*)&t))[0])();
    
      //It works, too
      ((CX*)&t)->BlaBla();
    
      return 0;
    }

    guest, 07 Февраля 2009

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

    +151

    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
    <...>
    switch($action) {
    case 'postAjouterDocument' :
    	$titre = read_post_str('text1');
    	$files['fichier'] = isset($_FILES['text2'])?$_FILES['text2']:'';
    	$codeRet = $ClsDocument->Add(GUSERID, $files, $titre, GROUPE );
    	location(PAGE_DOC_DEFAUT."&codeRet=".$codeRet);
    	exit();
    	break;
    case 'postAjouterCommentaire' :
    	<...>
    	exit();
    	break;
    case 'postModifierCommentaire' :
    	<...>
    	exit();
    	break;
    }

    зачем break; после exit(); ?

    guest, 27 Января 2009

    Комментарии (5)
  5. PHP / Говнокод #2265

    +150.9

    1. 1
    2. 2
    3. 3
    function get_pseudo_uniqid() {
        return 'abcdef';
    }

    While looking trought some code,
    I've found this snippet. Imagine what happens if this is a hash generator? :-)

    mr.groove, 11 Декабря 2009

    Комментарии (0)
  6. 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)
  7. PHP / Говнокод #1799

    +150.9

    1. 1
    2. 2
    3. 3
    4. 4
    function get_current_time() //get current date and time as a string
    {
    	return strftime("%Y-%m-%d %H:%M:%S", time());
    }

    апстену... про функцию date() люди не знали...
    старая версия WebAsyst Shop-Script

    gorky, 09 Сентября 2009

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

    +150.9

    1. 1
    $date = mktime(0,0,0, date("m",time()), date("d",time()), date("Y",time()));

    gorvic, 28 Августа 2009

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

    +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
    //$arr - array with arbitrary keys
    
    end($arr);
    do {
           if( <some condition> ) {
                <something of no importance>
                unset($arr[key($arr)]);
            }
            else {
                <something of no importance>
            } 
    } while( prev($arr) !== false );

    Предполагалось, что на входе будет непустой массив. Потом он будет пролистан с конца (это необходимо) и из него по некоторому условию исключаются элементы. При этом после первого исключения итератор оказывается вне массива и prev() возвращает false (в самом массиве false не размещён заведомо).

    interested, 25 Августа 2009

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

    +150.9

    1. 1
    if (FALSE !== strpos($this->lin{$i},$this->o)) {

    я б до такого сравнения даже в кошмарном сне бы не додумался.

    guest, 15 Февраля 2009

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

    +150.8

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    $tttr = rand( 1, 2 );
    if ( $tttr == 1 )
    {
        $bonusik = "&dd=10|";
    }
    if ( $tttr == 2 )
    {
        $bonusik = "&dd=5|dd=5|";
    }

    Random and naming fails.

    Bobby, 16 Апреля 2010

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