1. C++ / Говнокод #7444

    +152

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    if (getMaterialDom().ztest_)
     {
      device.SetRenderState(D3DRS_ZENABLE, TRUE);
      device.SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL);
     }
     else
      device.SetRenderState(D3DRS_ZENABLE, FALSE);
    
    if (getMaterialDom().zwrite_)
    	device.SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
    else
    	device.SetRenderState(D3DRS_ZWRITEENABLE, FALSE);

    Реализация параметров материала z-test и z-write в 3D-движке.

    Kirinyale, 04 Августа 2011

    Комментарии (30)
  2. Куча / Говнокод #7443

    +144

    1. 1
    Чтобы удалить или заблокировать пользователя, наведите курсор на его фотографию.

    из одноглазников

    jQuery, 04 Августа 2011

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

    +174

    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
    var reps = 2
    var speed = 500
    
    var message = '0';
    var p='15';
    var T="";
    var C=0;
    var mC=0;
    var s=0;
    var sT=null;
    if(reps<1)reps=1;
    function doTheThing(){
    T=message[mC];
    A();}
    function A()
    {
    s++
    if(s>15){s=1}
    
    if(s==1){document.title='W'}
    if(s==2){document.title='WE'}
    if(s==3){document.title='WEL'}
    if(s==4){document.title='WELC'}
    if(s==5){document.title='WELCO'}
    if(s==6){document.title='WELCOM'}
    if(s==7){document.title='WELCOME'}
    if(s==8){document.title='WELCOME T'}
    if(s==9){document.title='WELCOME TO'}
    if(s==10){document.title='WELCOME TO M'}
    if(s==11){document.title='WELCOME TO MY'}
    if(s==12){document.title='WELCOME TO MY S'}
    if(s==13){document.title='WELCOME TO MY SI'}
    if(s==14){document.title='WELCOME TO MY SIT'}
    if(s==15){document.title='WELCOME TO MY SITE'}
    
    if(C<(8*reps)){
    sT=setTimeout("A()",speed);
    C++
    }else{
    C=0;
    s=0;
    mC++
    if(mC>p-1)mC=0;
    sT=null;
    doTheThing();}}
    doTheThing();

    Накопал на древнем сайте по веб-дизайну, какого то самоучки )
    ощущение что делалось чтобы показать как не надо делать , но лежало без подписей вообще

    nazymko, 04 Августа 2011

    Комментарии (20)
  4. Java / Говнокод #7441

    +72

    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
    package com.uva.concurrent;
    
    import com.uva.log.Log;
    import com.uva.log.Message;
    
    public class ThreadExecutor implements Executor {
    	private final String name;
    
    	public ThreadExecutor(String name) {
    		this.name = name;
    	}
    
    	public void execute(Runnable target) {
    		new Thread(target, name).start();
    	}
    	
    	/** Execute given runnable in separate thread. All exceptions will be caught.
    	 * @param runnable - runnable to execute. */
    	public void executeSilent(final Runnable runnable) {
    		new Thread() {	
    			public void run() {
    				try {
    					runnable.run();
    				} 
    				catch (RuntimeException e) {
    					Log.exception(name, Message.CRITICAL_ERROR, e);
    					throw e;
    				}
    			}
    		}.start();
    	}
    }

    Junior пишет весьма ThreadPoolExecutor для BlackBerry.

    enikey, 04 Августа 2011

    Комментарии (8)
  5. Си / Говнокод #7440

    +147

    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
    92. 92
    {
        //-----------------------------------------
        // Declare and initialize variables
        WSADATA wsaData;
        int iResult = 0;
    
        int iError = 0;
        INT iNuminfo = 0;
    
        int i;
    
        // Allocate a 16K buffer to retrieve all the protocol providers
        DWORD dwBufferLen = 16384;
    
        LPWSAPROTOCOL_INFO lpProtocolInfo = NULL;
    
        // variables needed for converting provider GUID to a string
        int iRet = 0;
        WCHAR GuidString[40] = { 0 };
    
        // Initialize Winsock
        iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
        if (iResult != 0) {
            wprintf(L"WSAStartup failed: %d\n", iResult);
            return 1;
        }
    
        lpProtocolInfo = (LPWSAPROTOCOL_INFO) MALLOC(dwBufferLen);
        if (lpProtocolInfo == NULL) {
            wprintf(L"Memory allocation for providers buffer failed\n");
            WSACleanup();
            return 1;
        }
    
        iNuminfo = WSAEnumProtocols(NULL, lpProtocolInfo, &dwBufferLen);
        if (iNuminfo == SOCKET_ERROR) {
            iError = WSAGetLastError();
            if (iError != WSAENOBUFS) {
                wprintf(L"WSAEnumProtocols failed with error: %d\n", iError);
                if (lpProtocolInfo) {
                    FREE(lpProtocolInfo);
                    lpProtocolInfo = NULL;
                }
                WSACleanup();
                return 1;
            } else {
                wprintf(L"WSAEnumProtocols failed with error: WSAENOBUFS (%d)\n",
                        iError);
                wprintf(L"  Increasing buffer size to %d\n\n", dwBufferLen);
                if (lpProtocolInfo) {
                    FREE(lpProtocolInfo);
                    lpProtocolInfo = NULL;
                }
                lpProtocolInfo = (LPWSAPROTOCOL_INFO) MALLOC(dwBufferLen);
                if (lpProtocolInfo == NULL) {
                    wprintf(L"Memory allocation increase for buffer failed\n");
                    WSACleanup();
                    return 1;
                }
                iNuminfo = WSAEnumProtocols(NULL, lpProtocolInfo, &dwBufferLen);
                if (iNuminfo == SOCKET_ERROR) {
                    iError = WSAGetLastError();
                    wprintf(L"WSAEnumProtocols failed with error: %d\n", iError);
                    if (lpProtocolInfo) {
                        FREE(lpProtocolInfo);
                        lpProtocolInfo = NULL;
                    }
                    WSACleanup();
                    return 1;
                }
    
            }
        }
    
        wprintf(L"WSAEnumProtocols succeeded with protocol count = %d\n\n",
                iNuminfo);
        for (i = 0; i < iNuminfo; i++) {
            wprintf(L"Winsock Catalog Provider Entry #%d\n", i);
    
    --- skipped ---
    
            wprintf(L"\n");
        }
    
        if (lpProtocolInfo) {
            FREE(lpProtocolInfo);
            lpProtocolInfo = NULL;
        }
        WSACleanup();
    
        return 0;
    }

    http://msdn.microsoft.com/en-us/library/ms741574(v=VS.85).aspx

    Я считаю это говнокодом, т.к. автор данного примера страдает сильнейшие паранойей. Всем переменным он присваивает нолики, например перед return строки 87, 52 и т.д. ... Даже iResult, lpProtocolInfo и т.д. в начале...

    fddpro, 04 Августа 2011

    Комментарии (17)
  6. PHP / Говнокод #7439

    +160

    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
    // File: /controllers/register.php
    
    //......
    $sql = 'INSERT INTO `users` SET `ID`=NULL, `login`="'.mysql_real_escape_string(substr($_POST['login'], 0, 12)).'", `pass`= blah blah blah....';
    //......
    
    
    
    // File: /templates/default/index.tpl
    /*
    //... 
    <td><div>Hello, <b>{LOGIN}</b></div><!---- blah blah blah ---><div>Server time: <?php echo getCurrentTime();?></div>
    //
    */
    
    
    //File: /index.php
    
    //......
    $sql = 'SELECT * FROM `users` WHERE `id`=........';
    $data = SYS::$db->getDataRow($sql);
    if(sizeof($data)>0) {
          showTeplate(TEMPLATE_NAME, 'index', $data);
    }
    //......
    
    //Function showTeplate();
    
    function showTeplate($tpl_name, $file_name, $data) {
           $template_code = file_get_contents(TPL_PATH.'/'.$tpl_name.'/'.$file_name.'.'.TPL_EXT);
           foreach($data as $name=>$value) {
                  $template_code = str_replace('{'.strtoupper($name).'}', $value, $template_code);
           }
           
          //......
           eval($template_code);
          //......
    
    }

    Внимание, загадка! Найти уязвимость.

    jokz, 04 Августа 2011

    Комментарии (24)
  7. JavaScript / Говнокод #7438

    +164

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    function withoutCyr(inрut) {
      var value = inрut.value;
      var re = /а|б|в|г|д|е|ё|ж|з|и|й|ё|к|л|м|н|о|п|р|с|т|у|ф|х|ц|ч|ш|щ|ъ|ы|ь|э|ю|я/gi;
        if (re.test(value)) {
             value = value.replace(re, '');
             inрut.value = value;
       }
    }

    jQuery, 03 Августа 2011

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

    +146

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    $urt = 'uArts'; 
    $urt1 = 'искуств'; 
    $urt2 = 'сайт'; 
    alert($urt.$urt2.$urt1)//Соединим две переменные используем . 
    
    $us = 2; 
    $us2 = 9; 
    alert($us + $us2);// Сложение получим 11

    Автор писал первую статью для начинающих: http://uarts.ucoz.ru/load/veb_masteru_lt/php/php_rabota_s_peremennymi/17-1-0-25
    Но зачем alert из DS? :D

    Как вывести переменную?!

    есть много способов для создания сайтов используют echo или print и alert
    в Ds нужно с("elem")->caption

    и код выше =)

    TRANE73, 03 Августа 2011

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

    +170

    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
    $q = mysql_query("SELECT * FROM ".$prefix."_users WHERE id='$user_id'");
    
    $org = mysql_result($q,0,"org");
    $orginfo = mysql_result($q,0,"orginfo");
    $orgsite = mysql_result($q,0,"orgsite");
    $orgaddr = mysql_result($q,0,"orgaddr");
    $orgcity = mysql_result($q,0,"orgcity");
    $orgname = mysql_result($q,0,"orgname");
    $sendme = mysql_result($q,0,"sendme");
    $news_sendme = mysql_result($q,0,"news_sendme");
    $arend = mysql_result($q,0,"arend");
    $seller = mysql_result($q,0,"seller");
    $manufacter = mysql_result($q,0,"manufacter");
    $bank = mysql_result($q,0,"bank");
    $leasing = mysql_result($q,0,"leasing");
    $a_bus = mysql_result($q,0,"a_bus");
    $a_gruz = mysql_result($q,0,"a_gruz");
    $a_prec = mysql_result($q,0,"a_prec");
    $a_po_prec = mysql_result($q,0,"a_po_prec");
    $a_sr_tg = mysql_result($q,0,"a_sr_tg");
    ...

    В бесконечность и далее!!!

    invision70, 03 Августа 2011

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

    +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
    public function executeQuery($sql, $return_format = 0) {
            $query = mysql_query($sql, $this->link) OR die(mysql_error());
    
            switch ($return_format) {
                case 1:
                    $query = mysql_fetch_assoc($query);
                    break;
                case 2:
                    $query = mysql_fetch_array($query);
                    break;
                case 3:
                    $query = mysql_fetch_row($query);
                    return $query[0];
                default:
                    return $query;
            }
    
            return $query;
        }

    Практично б*дь.... Советую весь класс посмотреть...потом на их сайт перейти, компания ведь крутая ;D...
    http://www.phpclasses.org/browse/file/35772.html

    AlexanderC, 03 Августа 2011

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