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

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

    +50

    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
    <?php
    
    //    ...
    
    if(!empty($_GET['hit']))
    {
    $tovar2 = mysql_query("select * from `product` where `hit`='1' ORDER BY `weight` DESC, `id` asc ");
    }else{
    if(!empty($_POST['cena']) && !empty($_POST['meh']) && !empty($_POST['razmer']))
    {
    $tovar2 = mysql_query("select * from `product` where `new`<'".$_POST['cena']."' and `kat`='".$_POST['meh']."' and `razmer` like '%".$_POST['razmer']."%' ORDER BY `weight` DESC, `id` asc limit  $start, $num;");
    }
    elseif(!empty($_POST['cena']) && !empty($_POST['meh']) && empty($_POST['razmer']))
    {
    $tovar2 = mysql_query("select * from `product` where `new`<'".$_POST['cena']."' and `kat`='".$_POST['meh']."' ORDER BY `weight` DESC, `id` asc limit  $start, $num;");
    }
    elseif(!empty($_POST['cena']) && empty($_POST['meh']) && !empty($_POST['razmer']))
    {
    $tovar2 = mysql_query("select * from `product` where `new`<'".$_POST['cena']."' and `razmer` like '%".$_POST['razmer']."%' ORDER BY `weight` DESC, `id` asc limit  $start, $num;");
    }
    elseif(empty($_POST['cena']) && !empty($_POST['meh']) && !empty($_POST['razmer']))
    {
    $tovar2 = mysql_query("select * from `product` where `kat`='".$_POST['meh']."' and `razmer` like '%".$_POST['razmer']."%' ORDER BY `weight` DESC, `id` asc limit  $start, $num;");
    }
    elseif(!empty($_POST['cena']) && empty($_POST['meh']) && empty($_POST['razmer']))
    {
    $tovar2 = mysql_query("select * from `product` where `new`<'".$_POST['cena']."' ORDER BY `weight` DESC, `id` asc limit  $start, $num;");
    }
    elseif(empty($_POST['cena']) && !empty($_POST['meh']) && empty($_POST['razmer']))
    {
    $tovar2 = mysql_query("select * from `product` where `kat`='".$_POST['meh']."' ORDER BY `weight` DESC, `id` asc limit  $start, $num;");
    }
    elseif(empty($_POST['cena']) && empty($_POST['meh']) && !empty($_POST['razmer']))
    {
    $tovar2 = mysql_query("select * from `product` where `razmer` like '%".$_POST['razmer']."%' ORDER BY `weight` DESC, `id` asc limit  $start, $num;");
    }
    
    //    ...
    
    ?>

    Make me unsee it!

    Sarkian, 30 Января 2013

    Комментарии (8)
  3. Java / Говнокод #12497

    +79

    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
    public static void loadSWT() {
    		try {
    			File file = null;
    			if (PlatformUtils.IS_WINDOWS) {
    				file = new File("lib/swtwin32.jar"); // x86
    				if (PlatformUtils.JVM_ARCH.equals("64")) {
    					file = new File("lib/swtwin64.jar"); // x64
    				}
    			} else if (PlatformUtils.IS_OSX) {
    				file = new File("lib/swtmac32.jar"); // x86
    				if (PlatformUtils.JVM_ARCH.equals("64")) {
    					file = new File("lib/swtmac64.jar"); // x64
    				} else if (PlatformUtils.OS_ARCH.startsWith("ppc")) {
    					file = new File("lib/swtmaccb.jar"); // carbon
    				}
    			} else if (PlatformUtils.IS_LINUX) {
    				file = new File("lib/swtlin32.jar"); // x86
    				if (PlatformUtils.JVM_ARCH.equals("64")) {
    					file = new File("lib/swtlin64.jar"); // x64
    				}
    			}
    			if ((file == null) || !FileUtils.isExistingFile(file)) {
    				file = new File("lib/swt.jar"); // old system
    			}
    			final Method method = URLClassLoader.class.getDeclaredMethod(
    					"addURL", new Class[] { URL.class });
    			method.setAccessible(true);
    			method.invoke(ClassLoader.getSystemClassLoader(), file.toURI()
    					.toURL());
    		} catch (final Exception e) {
    			e.printStackTrace();
    		}
    	}

    вот так приколачиваем SWT в систему.
    особенное веселье в строках 25-28.

    Lure Of Chaos, 29 Января 2013

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

    +64

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    public class ClientSourceTranslator implements ITranslator
    {
      public Object map(Object input)
      {
        return String.valueOf(12);
      }
    }

    askell, 29 Января 2013

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

    +71

    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
    private String getSecondsToTimeFormat(long startTime, long finishTime) {
    
            int secs = Math.round((finishTime - startTime) / 1000);
    
            int hours = secs / 3600,
                    remainder = secs % 3600,
                    minutes = remainder / 60,
                    seconds = remainder % 60;
    
            StringBuilder result = new StringBuilder();
    
            if (hours > 0) {
                result.append((hours < 10 ? "0" : "") + hours).append(":");
            }
    
            if (minutes > 0 || hours > 0) {
                result.append((minutes < 10 ? "0" : "") + minutes).append(":");
            }
    
            if (seconds > 0 || hours > 0 || minutes > 0) {
                result.append((seconds < 10 ? "0" : "") + seconds);
            }
    
            if (hours == 0 && minutes == 0) {
                if (seconds == 1) {
                    result.append(" second");
                } else {
                    result.append(" seconds");
                }
            }
    
            return result.toString();
        }

    Задача - перевести из секунд в человеческий формат

    nafania217518, 29 Января 2013

    Комментарии (8)
  6. Куча / Говнокод #12489

    +133

    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
    .wrapper#container {
        background-color: #ffffff;
        border-style: hidden;
        -webkit-border-radius: 5px;
        -moz-border-radius: 5px;
        border-radius: 5px;
        -webkit-border-radius: 5px;
        -moz-border-radius: 5px;
        border-radius: 5px;
        -webkit-border-radius: 5px;
        -moz-border-radius: 5px;
        border-radius: 5px;
        -webkit-border-radius: 5px;
        -moz-border-radius: 5px;
        border-radius: 5px;
        margin: 0 auto 0;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        width: 672px;
        -webkit-box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        -moz-box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        -webkit-box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        -moz-box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        -webkit-box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        -moz-box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        -webkit-box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        -moz-box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
        padding: 15px 20px 20px 30px;
    }

    Из сорса страницы Evernote, вообще там порядка 8к строк для 4 дивов....

    nonamez, 28 Января 2013

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

    +48

    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
    $title = get_the_title();
    if ( $title == "Portfolio")  $data['sl_portfolio_style'] = "2 Columns Portfolio";
    if ( $title == "3 Columns Portfolio")  $data['sl_portfolio_style'] = "3 Columns Portfolio";
    if ( $title == "4 Columns Portfolio")  $data['sl_portfolio_style'] = "4 Columns Portfolio";
    if ( $title == "6 Columns Portfolio")  $data['sl_portfolio_style'] = "6 Columns Portfolio";
    if ( $title == "Portfolio")  query_posts( '&post_type=portfolio-type&posts_per_page=4&paged=' . $paged );
    if ( $title == "4 Columns Portfolio")  query_posts( '&post_type=portfolio-type&posts_per_page=8&paged=' . $paged );
    if ( $title == "6 Columns Portfolio")  query_posts( '&post_type=portfolio-type&posts_per_page=12&paged=' . $paged );
    if ( $title == "3 Columns Portfolio")  query_posts( '&post_type=portfolio-type&posts_per_page=6&paged=' . $paged );
    if ( $title == "Portfolio Right Sidebar")  $data['sl_portfolio_style'] = "Portfolio with Sidebar";
    if ( $title == "Portfolio Right Sidebar")  $data['portfolio_sidebar_position'] = "Right Sidebar";
    if ( $title == "Portfolio Left Sidebar")  $data['sl_portfolio_style'] = "Portfolio with Sidebar";
    if ( $title == "Portfolio Left Sidebar")  $data['portfolio_sidebar_position'] = "Left Sidebar";
    
    if ( $title == "Portfolio Left Sidebar")  query_posts( '&post_type=portfolio-type&posts_per_page=12&paged=' . $paged );
    if ( $title == "Portfolio Right Sidebar")  query_posts( '&post_type=portfolio-type&posts_per_page=12&paged=' . $paged );

    "switch - case" - Не не слышал!
    И это в покупной теме для wordpress на тимфоресте.
    Стоимость темы - 45 уе...

    tsybulskyserg, 22 Января 2013

    Комментарии (8)
  8. bash / Говнокод #12440

    −113

    1. 1
    http://lab.madscience.nl/oo.sh.txt

    ООП-фаги, набигайте!

    byss, 17 Января 2013

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

    +52

    1. 1
    2. 2
    3. 3
    4. 4
    $new_addresses = $_POST['friendE1']."\n".$_POST['friendE2']."\n".$_POST['friendE3']."\n".$_POST['friendE4']."\n".$_POST['friendE5']
        ."\n".$_POST['friendE6']."\n".$_POST['friendE7']."\n".$_POST['friendE8']."\n".$_POST['friendE9']."\n".$_POST['friendE10'];
    
    $list = explode( "\n", $new_addresses);

    Отакое счастье в очередном проекте :-)

    tsybulskyserg, 11 Января 2013

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

    +137

    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
    GePolygon newPoly;
    int c_ai = 0, n_pi = 0;
    int fac[GE_MAX_POLY_VERTEX];
    newPoly.n = 0;
        
    Pt diff = ccpSub(end, bgn);
        
    int f = 0;
    do
       newPoly.p[newPoly.n] = ai[c_ai] == (n_pi - 1) ? (f = 1, a[c_ai++]) : (f = 0, inp->p[n_pi++]),
       fac[newPoly.n++] = f ? 0 : (ccpCross(ccpSub(newPoly.p[newPoly.n - 1], newPoly.p[newPoly.n - 2]), diff) > 0 ? 1 : -1 );
    while(n_pi < inp->n);
    if(c_ai < ac)
       newPoly.p[newPoly.n] = a[c_ai], fac[newPoly.n++] = 0;

    Из личной коллекции. Не помню, что конкретно делает, что-то вроде классификации точек полигона относительно линии...

    tirinox, 02 Января 2013

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

    +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
    var fmCategoryClass = function(fmCategory) {
                    switch (parseInt(fmCategory))
                    {
                        case 0: return 'important';
                        case 1: return 'sell';
                        case 2: return 'buy';
                        case 3: return 'exchange';
                        case 4: return 'service';
                        case 5: return 'rent';
                        case 6: return 'close';
                        default: return '';
                    }
                }

    http://onliner.by - один из самых посещаемых сайтов в Беларуси - содержит прям в вёрстке

    daemon_master, 28 Декабря 2012

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