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

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

    +162

    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
    if (prepopulate_transfer_preset_enabled > 0)
    									{
    if (prepopulate_transfer_preset == 'PRESET_1')
    										{document.vicidial_form.xfernumber.value = CalL_XC_a_NuMber;}
    if (prepopulate_transfer_preset == 'PRESET_2')
    										{document.vicidial_form.xfernumber.value = CalL_XC_b_NuMber;}
    if (prepopulate_transfer_preset == 'PRESET_3')
    										{document.vicidial_form.xfernumber.value = CalL_XC_c_NuMber;}
    if (prepopulate_transfer_preset == 'PRESET_4')
    										{document.vicidial_form.xfernumber.value = CalL_XC_d_NuMber;}
    if (prepopulate_transfer_preset == 'PRESET_5')
    										{document.vicidial_form.xfernumber.value = CalL_XC_e_NuMber;}
    									}
    if ( (quick_transfer_button == 'PRESET_1') || (quick_transfer_button == 'PRESET_2') || (quick_transfer_button == 'PRESET_3') || (quick_transfer_button == 'PRESET_4') || (quick_transfer_button == 'PRESET_5') )
    									{
    									document.getElementById("QuickXfer").innerHTML = "<a href=\"#\" onclick=\"mainxfer_send_redirect('XfeRBLIND','" + lastcustchannel + "','" + lastcustserverip + "');return false;\"><IMG SRC=\"./images/vdc_LB_quickxfer.gif\" border=0 alt=\"QUICK TRANSFER\"></a>";
    
    									if (quick_transfer_button == 'PRESET_1')
    										{document.vicidial_form.xfernumber.value = CalL_XC_a_NuMber;}
    									if (quick_transfer_button == 'PRESET_2')
    										{document.vicidial_form.xfernumber.value = CalL_XC_b_NuMber;}
    									if (quick_transfer_button == 'PRESET_3')
    										{document.vicidial_form.xfernumber.value = CalL_XC_c_NuMber;}
    									if (quick_transfer_button == 'PRESET_4')
    										{document.vicidial_form.xfernumber.value = CalL_XC_d_NuMber;}
    									if (quick_transfer_button == 'PRESET_5')
    										{document.vicidial_form.xfernumber.value = CalL_XC_e_NuMber;}
    									}

    7ion, 20 Марта 2011

    Комментарии (2)
  3. Си / Говнокод #6025

    +126

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    format MS COFF
    
    public fuckHighLevel as '_fuckHighLevel@4'
    
    fuckHighLevel:
            pop ebx
    
                pop eax
                add eax, 1
    
            jmp ebx

    Вызываем ассемблерную процедуру из Си.
    Вместо retn используем безусловыный переход на адрес возврата.
    Но работает же!

    danilissimus, 19 Марта 2011

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

    +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
    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
    elseif( $action == "pingationmod" ) { 
    echoheader( "options", "pingationMod" ); 
    echo <<<HTML 
    <form action="{$PHP_SELF}" method="post"> 
    <div style="padding-top:5px;padding-bottom:2px;"> 
    <table width="100%"> 
    <tr> 
    <td width="4"><img src="engine/skins/images/tl_lo.gif" width="4" height="4" border="0"></td> 
    <td background="engine/skins/images/tl_oo.gif"><img src="engine/skins/images/tl_oo.gif" width="1" height="4" border="0"></td> 
    <td width="6"><img src="engine/skins/images/tl_ro.gif" width="6" height="4" border="0"></td> 
    </tr> 
    <tr> 
    <td background="engine/skins/images/tl_lb.gif"><img src="engine/skins/images/tl_lb.gif" width="4" height="1" border="0"></td> 
    <td style="padding:5px;" bgcolor="#FFFFFF"> 
    <table width="100%"> 
    <tr> 
    <td bgcolor="#EFEFEF" height="29" style="padding-left:10px;"><div class="navigation">Отправка уведомлений в пинг сервисы</div></td> 
    </tr> 
    </table> 
    <div class="unterline"></div> 
    <table width="100%"> 
    <tr> 
    <td style="padding:2px;" height="100" align="center"> 
    HTML; 
         
    echo "Вы действительно хотите отправить уведомления в пинг сервисы, на (<b>" . count( $selected_news ). "</b>) $lang[mass_confirm_1]<br><br> 
    <input class=bbcodes type=submit value=\"   $lang[mass_yes]   \"> &nbsp; <input type=button class=bbcodes value=\"  $lang[mass_no]  \" onclick=\"javascript:document.location='$PHP_SELF?mod=editnews&action=list'\"> 
    <input type=hidden name=action value=\"do_mass_ping\"> 
    <input type=hidden name=user_hash value=\"{$dle_login_hash}\"> 
    <input type=hidden name=mod value=\"massactions\">"; 
    foreach ( $selected_news as $newsid ) { 
    $newsid = intval($newsid); 
    echo "<input type=hidden name=selected_news[] value=\"$newsid\">"; 
    } 
    echo <<<HTML 
    </tr> 
    </table> 
    </td> 
    <td background="engine/skins/images/tl_rb.gif"><img src="engine/skins/images/tl_rb.gif" width="6" height="1" border="0"></td> 
    </tr> 
    <tr> 
    <td><img src="engine/skins/images/tl_lu.gif" width="4" height="6" border="0"></td> 
    <td background="engine/skins/images/tl_ub.gif"><img src="engine/skins/images/tl_ub.gif" width="1" height="6" border="0"></td> 
    <td><img src="engine/skins/images/tl_ru.gif" width="6" height="6" border="0"></td> 
    </tr> 
    </table> 
    </div></form> 
    HTML; 
    echofooter(); 
    exit(); 
    }elseif( $action == "do_mass_ping" ) { 
    include ENGINE_DIR .'/inc/include/pingfunction.php'; 
    include ENGINE_DIR .'/data/pingdata.php'; 
    foreach ( $selected_news as $newsid ) { 
    $newsid = intval($newsid); 
    $sql_select = "SELECT id, title, date, category, alt_name, flag FROM ".PREFIX ."_post WHERE id=".$newsid; 
    $sql_result = $db->query( $sql_select ); 
    while ( $row = $db->get_row( $sql_result ) ) { 
    $row['date'] = strtotime( $row['date'] ); 
    $title = $row['title']; 
    if( $config['allow_alt_url'] == "yes") { 
    if( $row['flag'] and $config['seo_type'] ) { 
    if( $row['category'] and $config['seo_type'] == 2 ) { 
    $full_link = $config['http_home_url'] .get_url( $row['category'] ) ."/".$row['id'] ."-".$row['alt_name'] .".html"; 
    }else { 
    $full_link = $config['http_home_url'] .$row['id'] ."-".$row['alt_name'] .".html"; 
    } 
    }else { 
    $full_link = $config['http_home_url'] .date( 'Y/m/d/',$row['date'] ) .$row['alt_name'] .".html"; 
    } 
    }else { 
    $full_link = $config['http_home_url'] ."index.php?newsid=".$row['id']; 
    } 
    } 
    pingationMod($title, $full_link, 0, $pingdata['service'], $pingdata['zaderjka']); 
    } 
    if($pingdata['allow_log']){ 
     
    saveLog("Массовая отправка уведомлений в пинг сервисы"); 
    } 
     
    clear_cache(); 
    msg( "info", "Уведомления успешно отправлены", "Уведомления успешно отправлены в пинг сервисы", $_SESSION['admin_referrer'] ); 
    }

    qbasic, 16 Марта 2011

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

    +169

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    foreach ( $all_fields as $k => $one_field )
            {
                if ( $one_field['id'] == $field_id )
                {
                }
                else
                {
                    break;
                }
            }

    дзен-foreach

    govnozmey, 12 Марта 2011

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

    +154

    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
    public function getCurrentDomain()
        {
            $host = 'http://' . $_SERVER['HTTP_HOST'];
            $folder = strstr($_SERVER['SCRIPT_NAME'], 'index.php', true);
            if ($folder)
            {
                if ($folder[1] != '/')
                    $folder = '/' . $folder;
                $host.=$folder;
            }
            if ($host[strlen($host)] != '/')
                $host.='/';
            return $host
    }

    Решил определить домен+папку(если она есть) из откуда работает скрипт. Спать пора, да?
    Как-то оно не так должно быть.

    vitaly, 12 Марта 2011

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

    +161

    1. 1
    var CURRENCY = {$company_info|@json_encode}.currency;

    Вот такой код встретился в проекте в одном из Smarty шаблонов
    $company_info - некий ассоциативный массив.

    x86demon, 09 Марта 2011

    Комментарии (2)
  8. SQL / Говнокод #5930

    −860

    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
    SELECT i.id AS i__id, i.title AS i__title, i.description AS i__description, i.meta_title AS i__meta_title, i.meta_keywords AS i__meta_keywords, i.meta_description AS i__meta_description, i.lang AS i__lang FROM item_translation i WHERE (i.id IN ('8845'))
    0.00s, "doctrine" connection
    #
    
    SELECT t.id AS t__id, t.source AS t__source, t.target AS t__target, t.lang AS t__lang FROM translation t WHERE (t.source = 'Акция' AND t.lang = 'ru') LIMIT 1
    0.00s, "doctrine" connection
    #
    
    SELECT t.id AS t__id, t.source AS t__source, t.target AS t__target, t.lang AS t__lang FROM translation t WHERE (t.source = 'Акция' AND t.lang = 'ru') LIMIT 1
    0.00s, "doctrine" connection
    #
    
    SELECT t.id AS t__id, t.source AS t__source, t.target AS t__target, t.lang AS t__lang FROM translation t WHERE (t.source = 'Розница' AND t.lang = 'ru') LIMIT 1
    0.00s, "doctrine" connection
    #
    
    SELECT t.id AS t__id, t.source AS t__source, t.target AS t__target, t.lang AS t__lang FROM translation t WHERE (t.source = 'Оптом' AND t.lang = 'ru') LIMIT 1
    0.00s, "doctrine" connection
    #
    
    SELECT t.id AS t__id, t.source AS t__source, t.target AS t__target, t.lang AS t__lang FROM translation t WHERE (t.source = 'Безнал' AND t.lang = 'ru') LIMIT 1
    0.00s, "doctrine" connection
    #
    
    SELECT t.id AS t__id, t.source AS t__source, t.target AS t__target, t.lang AS t__lang FROM translation t WHERE (t.source = 'Дилер' AND t.lang = 'ru') LIMIT 1
    0.00s, "doctrine" connection
    #
    
    SELECT t.id AS t__id, t.source AS t__source, t.target AS t__target, t.lang AS t__lang FROM translation t WHERE (t.source = 'Кредит' AND t.lang = 'ru') LIMIT 1
    0.00s, "doctrine" connection
    #
    
    SELECT p.id AS p__id, p.item_id AS p__item_id, p.type AS p__type, p.currency AS p__currency, p.value AS p__value, p.date AS p__date FROM price p WHERE (p.item_id = '8845' AND p.type = 'A') ORDER BY p.date DESC LIMIT 1
    0.00s, "doctrine" connection
    #
    
    SELECT t.id AS t__id, t.source AS t__source, t.target AS t__target, t.lang AS t__lang FROM translation t WHERE (t.source = 'В корзину' AND t.lang = 'ru') LIMIT 1
    0.00s, "doctrine" connection
    #
    
    SELECT t.id AS t__id, t.source AS t__source, t.target AS t__target, t.lang AS t__lang FROM translation t WHERE (t.source = 'В корзину' AND t.lang = 'ru') LIMIT 1
    0.00s, "doctrine" connection

    Это часть запросов которые выполняются для генерации главной страницы для одного интернет магазина. И таких запросов: 360 :-)

    aleksey, 09 Марта 2011

    Комментарии (2)
  9. C++ / Говнокод #5920

    +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
    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
    #include <iostream.h>
    #include <stdlib.h>
    #define make(a,b) new a[b];
    #define init(a,b) for(int i=0; i<b; i++) a[i]=random(10);
    #define MyType int
    template<class type>
    void sort(type *m,int  n)
     {
     type *m1 = m;
       for(int i=0; i<n-1; i++)
      		{
            for(int j=0; j<n-i-1; j++)
               {
               if (*m1>*(m1+1))
            	    {
                                              MyType temp;
       		      temp=*m1;
      	    	       *m1=*(m1+1);
    		       *(m1+1)=temp;
             	  }
               m1++;
               }
           m1=m;
          }
     }
    
     template<class type>
     void input(type *m,int num)
     {
     type *m1=m;
     for(int i=0;i<num; i++)
      		{
             cin>>*m1;
              m1++;
          }
      m1=m;
      cout << endl;
     }
    
     template<class type>
     void output(type  *m, int n)
     {
     for(int i=0;i<n; i++)
      		{
             cout << *(m+i)<<" ";
          }
     }
    
     main()
     {
     int len;
      cout << "Vvedite razmer massiva" << endl;
      cin >> len;
    
      MyType *mas1 = make(MyType,len);
      input(mas1,len);
      //init(mas1,len);
      output<MyType>(mas1,len);
      sort<MyType>(mas1,len);
      cout<<endl;
      output<MyType>(mas1,len);
      cout<<endl;
      system("pause");;
     }

    Делалось на Borland C++ 5.02 , что прикольно без макроса make , если память выделяется просто в теле, то ревет, что память ниразу не выделена . Делали ее часика в 4 утра к зачету, препод конечно прибалдел от таких раскладов, но покопавшись ничего сам сделать не смог, плюнул на это дело и зачет поставил.

    USERNAME, 08 Марта 2011

    Комментарии (2)
  10. JavaScript / Говнокод #5913

    +159

    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
    <div id='vote' name='vote'></div>
    
    <script src="http://siteheart.com/apps/api.js"></script>
    <script type="text/javascript">
    
        var query = window.location.search.substring('?url=');//находим часть url, что нужно затереть
            query = query.replace('?url=','');
            var url_split = query.split("&");      //разбиваем url на части
    	    var url = url_split[0];                //нас интересует только первая часть
    
    var params = {
    text        : 'Оцените эту страницу',
    appendTo    : 'vote',
    id          : 3055,
    description : 'Приватбанк',
    template    : 'full',
    vid         : encodeURIComponent( url ) //document.location.href
    };
    Siteheart.widget('Vote', params); //описание https://siteheart.com/apps/vote/full.html
    
    </script>

    Вот такой код в privat24.privatbank.ua.
    Комменты убили.

    therion, 06 Марта 2011

    Комментарии (2)
  11. JavaScript / Говнокод #5906

    +162

    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
    function convert(val){
        var TablePrice = document.getElementById("main_price");
        var trList = TablePrice.getElementsByTagName("tr");
        var IdVal = document.getElementById("IndocatorCurHide");
        var IdCur = document.getElementById("IndocatorCur");
        
        var CurUSD = parseFloat(document.getElementById("CurUSD").innerHTML);
        var CurRUR = parseFloat(document.getElementById("CurRUR").innerHTML);
        var CurEUR = parseFloat(document.getElementById("CurEUR").innerHTML);
        
        var Kurce = 1;
        var KurceUAH = 1;
        
        switch (val) {
            case "RUR":
                IdCur.style.backgroundImage = "url('flags/FlagsRussia.jpg')";
                break;
            case "EUR":
                IdCur.style.backgroundImage = "url('flags/FlagsEU.jpg')";
                break;
            case "USD":
                IdCur.style.backgroundImage = "url('flags/FlagsUSA.jpg')";
                break;
            case "UAH":
                IdCur.style.backgroundImage = "url('flags/FlagsUkraine.jpg')";
                break;
        }
        
        for (var i = 0; i < trList.length; i++) {
            var tdList = trList[i].getElementsByTagName('td');
            for (j = 0; j < tdList.length; j++) {
                if (tdList[j].id == "ToConvert") {
                    if ((tdList[j].innerHTML != "") && (tdList[j].innerHTML != "-")) {
                        var TmpPrice = parseFloat(tdList[j].innerHTML);
                        switch (IdVal.innerHTML) {
                            case "RUR":
                                switch (val) {
                                    case "UAH":
    	
                                        TmpPrice *= CurRUR;
                                        break;
                                    case "EUR":
                                        TmpPrice *= CurRUR;
                                        TmpPrice /= CurEUR;
                                        break;
                                    case "USD":
                                        TmpPrice *= CurRUR;
                                        TmpPrice /= CurUSD;
                                        break;
                                }
                                ;                            break;
                            case "USD":
                                switch (val) {
                                    case "UAH":
                                        TmpPrice *= CurUSD;
                                        break;
                                    case "EUR":
                                        TmpPrice *= CurUSD;
                                        TmpPrice /= CurEUR;
                                        break;
                                    case "RUR":
                                        TmpPrice *= CurUSD;
                                        TmpPrice /= CurRUR;
                                        break;
                                }
                                ;                            break;
                                
                            case "EUR":
                                switch (val) {
                                    case "UAH":
                                        TmpPrice *= CurEUR;
                                        break;
                                    case "RUR":
                                        TmpPrice *=  CurEUR;
                                        TmpPrice /=  CurRUR;
                                        break;
                                    case "USD":
                                        TmpPrice *= CurEUR;
                                        TmpPrice /= CurUSD;
                                        break;
                                }
                                ;                            break;
    ...
                        }
                        tdList[j].innerHTML = TmpPrice.toFixed(2);//Math.round(TmpPrice / 0.1) * 0.1;

    Наткнулся на форуме JavaScript, функция для конвертирования валют =).

    vulkan, 06 Марта 2011

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