1. PHP / Говнокод #13119

    +153

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    $currurl = str_replace(" ", '', $this->helper('core/url')->getCurrentUrl());
    if (strpos($currurl, 'index.php/')) {
        $currurl = str_replace('index.php/', '', $currurl);
    } else if (strpos($currurl, '/index.php')) {
        $currurl = str_replace('index.php', '', $currurl);
    }
    $url_suffix = (substr($currurl, strlen(Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB))));
    <?php if (strlen($url_suffix) <= 0) : #not homepage ?>
    ...

    Magento. Увидел в template, код одной английской компании.

    crook, 06 Июня 2013

    Комментарии (14)
  2. Java / Говнокод #13118

    +77

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if (groundsDTO.isChildCome()) {
        ZAGSAffiliation.Grounds.CHILDCONSENT childConsest = grounds.addNewCHILDCONSENT();
        childConsest.setISCHILDCONSENT(groundsDTO.isChildAgreeWithFillation());
        if (!groundsDTO.isChildCome()) {
             tranferConfirmation(childConsest.addNewCONSENTNOTAR(),groundsDTO.getChildAgree());
        }
    }

    А вдруг ребенок все-таки не придет?

    killogramm, 06 Июня 2013

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

    +121

    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
    public int sum(final Type type, final int increment) {
    	switch(type) {
    	case REDOS: 
    		return redos += increment;
    	case ONCE: 
    		return onceRedoneOrders += increment;
    	case TWICE: 
    		return twiceRedoneOrders += increment;
    	case THRICE: 
    		return thriceRedoneOrders += increment;
    	case MORE: 
    		return moreRedoneOrders += increment;
    	default:
    		break;
    	}
    	
    	throw new RuntimeException();
    }

    Осталось в наследство. Даже не знаю, что хотел изобразить предыдущий оратор...

    someone, 06 Июня 2013

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

    +149

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    $startYear = date('Y', $programs[$i][1]);
                    $startMounth = date('m', $programs[$i][1]);
                    $startDay = date('d', $programs[$i][1]);
                    $startHour = date('H', $programs[$i][1]);
                    $startMinute = date('i', $programs[$i][1]);
                    $startSecond = date('s', $programs[$i][1]);
                    $startDate = mktime($startHour + $timeoffset, $startMinute, $startSecond, $startMounth, $startDay, $startYear);

    Поправка на часовой пояс

    stsaranchin, 06 Июня 2013

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

    +135

    1. 1
    #define __click_window_chkarmor (!((inventory==plr->inventory)&&(((slot==5)&&!hasflag(consts.item_flags[plr->holdingitem->type],ITEM_FLAG_ARMOR_HEAD))||((slot==6)&&!hasflag(consts.item_flags[plr->holdingitem->type],ITEM_FLAG_ARMOR_CHEST))||((slot==7)&&!hasflag(consts.item_flags[plr->holdingitem->type],ITEM_FLAG_ARMOR_FEET))||((slot==8)&&!hasflag(consts.item_flags[plr->holdingitem->type],ITEM_FLAG_ARMOR_BOOTS)))))

    Форматирование сохранено

    kostoprav, 05 Июня 2013

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

    +136

    1. 1
    http://pastebin.com/htxgeLCJ

    Трололо!

    deep, 05 Июня 2013

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

    −80

    1. 1
    Если Найти(Строка(ТипЗнч(Ссылка)),"Документ") Тогда

    Проверка, является ли переданная ссылка документом. Сегодня без авторства.

    ilya2184, 05 Июня 2013

    Комментарии (40)
  8. Perl / Говнокод #13112

    −160

    1. 1
    unless( eval{ $p -> role() -> is_company() } or eval{ $p -> channel_status() } or ( $p -> id() eq 11902 ) )

    kainwinterheart, 05 Июня 2013

    Комментарии (49)
  9. Java / Говнокод #13111

    +73

    1. 1
    if (fooTextField.getText().equalsIgnoreCase("")) {

    Не то, чтобы очень говно...
    Просто порадовало :)

    myzone, 04 Июня 2013

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

    +150

    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
    <?php
    class Router {
        private $available_pages = array('index',
                                         'contacts',
                                         'about',
                                         'clients' => array('index',
                                                           'howto',
                                                           'register',
                                                           'faq'),
                                         'experts' => array('index',
                                                              'why',
                                                              'howto',
                                                              'register',
                                                              'faq')
                                         );
        
        function __construct()
        {
            if(!isset($_GET['act'])) $act = "index";
            else $act=$_GET['act'];
            $path = pathinfo($act);
            if($path["filename"] == "experts" || $path["filename"] == "clients")
            {
                $path['dirname'] = $path["filename"];
                $path['filename'] = "index";
            }
            if($this->isAvailablePage($path))
            {
                $controllerPath = FRONT_TPL.$path['dirname'].'/'.$path['filename'].'.php';
                $controllerName = $path['filename'];
                if(file_exists($controllerPath))
                {
                    include(FRONT_TPL."header.php");
                    include($controllerPath);
                    include(FRONT_TPL."footer.php");
                }
                else $this->error404();
            }
            else $this->error404();
        }
        
        function error404()
        {
            include(FRONT_TPL."header.php");
            include(FRONT_TPL."404.php");
            include(FRONT_TPL."footer.php");
        }
        
        function isAvailablePage($path)
        {
            
            if($path["dirname"] == ".")
            {
                reset($this->available_pages);
                if(in_array($path['filename'], $this->available_pages)) return true;
            }
            else if($path["dirname"] == "experts" || $path["dirname"] == "clients")
            {
                reset($this->available_pages);
                if(in_array($path['filename'], $this->available_pages[$path["dirname"]])) return true;
            }
            else return false;
        }
    }

    Небольшой роутинг

    varg242, 04 Июня 2013

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