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

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

    +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
    public function toArray()
            {
                    $that = $this;
                    $profile = $this->getProfile();
                    return [
                            'sex' => $profile->getSex(),
                            'distance' => (int) $profile->get($profile::FIELD_DISTANCE),
                            'balance' => new Object_Response_Model_User_Balance($profile->get($profile::FIELD_BALANCE)),
     
                            'payments' => call_user_func(function() use ($that) {
                                    $return = [];
                                    $checkoutTypes = $that->getRelationCheckoutTypes()->find_all()->as_array();
                                    foreach($checkoutTypes as $checkoutType) {
                                            if (json_decode($checkoutType->data)[0]->value) {
                                                    $return[] = $checkoutType;
                                            }
                                    }
                                    return $return;
                            }),
                            'vk' => $this->getRelationSocial()->getProfileUrl(),
                            'validate' => $this->getValidate()
                    ];
            };

    limitium, 09 Сентября 2014

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

    +151

    1. 1
    2. 2
    3. 3
    4. 4
    // /vendor/composer/autoload_real.php
    // Строка 18
    if (NULL !== self::$loader) {
    // ...

    Composer видимо такой же мудрый как и Йода...
    ( http://en.wikipedia.org/wiki/Yoda_conditions )

    volter9, 16 Августа 2014

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

    +151

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $mas=split("/",$_FILES["filename"]["type"]);
    if ((count($mas)==2) and ($mas[0]=="audio"))
    {
      ...
    }

    А то вдруг там в MIME-типе двадцать слешей.

    vocal_hydra, 21 Июля 2014

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

    +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
    for($page = 0 ; $page <= $maxPage; $page ++) {
    	$result = LoadPage($page);
    	if(!$result) {
    		if($try < 5) {
    			$page --;
    			$try ++;
    		} else
    			$try = 0;
    	} else {
    		$try = 0;
    		ProcessPage($page, $result);
    	}
    }

    два цикла по цене одного

    clauclauclau, 26 Мая 2014

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

    +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
    <?
    						$arPrimary = array();
    						if(!empty($item['IB_ELEMENT']['PROPERTIES']['MANUFACTURER']['VALUE'])){
    							$arPrimary['ПРОИЗВОДИТЕЛЬ'] = $item['IB_ELEMENT']['PROPERTIES']['MANUFACTURER']['VALUE'];
    						}
    						if(!empty($item['IB_ELEMENT']['PROPERTIES']['MATERIAL']['VALUE'])){
    							$arPrimary['ПРОИЗВОДИТЕЛЬ'] = $item['IB_ELEMENT']['PROPERTIES']['MATERIAL']['VALUE'];
    						}
    						
    						if(!empty($arPrimary)):
    							$c = count($arPrimary); $i = 1;
    						?>
    							<ul class="primary">
    								<?foreach($arPrimary as $k => $v):
    									$last = false;
    									if($i == $c){
    										$last = true;
    									}
    								?>
    									<li<?if($last):?> class="last"<?endif;?>>
    										<span class="label"><?=$k?>:</span>
    										<?=$v?>
    									</li>
    								<?
    								$i++;
    								endforeach;?>
    							</ul>
    						<?endif;?>

    Bitrix же!

    TBoolean, 13 Мая 2014

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

    +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
    if (!empty($_POST["favoriteColor"])) {
        switch($_POST["favoriteColor"]) {
            case "Lightred":
                $strBackgroundColor = "#FFDAB9";
                break;
            case "Lightgreen":
                $strBackgroundColor = "Lightgreen";
                break;
            case "Lightblue":
                $strBackgroundColor = "Lightblue";
                break;
            case "Lightgray":
                $strBackgroundColor = "Lightgray";
                break;
            default:
                $strBackgroundColor = "Gray";
                break;
        }
    } else {
        $strBackgroundColor = "Gray";
    }

    arif, 05 Мая 2014

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

    +151

    1. 1
    var $resetBtn = $("<a class=\"filter-reset-btn resetBtn\"/>");

    Это нормально вообще?

    farit_slv, 26 Марта 2014

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

    +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
    $params['monthes'] = array(
    			1 => 'January',
    			2 => 'February',
    			3 => 'March',
    			4 => 'April',
    			5 => 'May',
    			6 => 'June',
    			7 => 'July',
    			8 => 'August',
    			9 => 'September',
    			10 => 'October',
    			11 => 'November',
    			12 => 'December',
    		);

    О существовании date() видимо никто не знает.

    texnikru, 13 Марта 2014

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

    +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
    $s = $this->getAdapter()->select()->from(array('b' => $this->info('name'), array(
       'text',
       'link',
       'image',
                'show_register',
    
    
      )))->joinInner(array('s' => 'banner_size'), 's.id=b.size_id', array('x', 'y'))
       ->where('b.show_it = ?', 1)
       ->where('s.x = ?', $sizeX)
       ->where('s.y = ?', $sizeY)
       ->limit(1)
       ->order('RAND()');
    
    
            if (!empty($uid)){
                $s->where('(b.show_register= ?, 1)' OR '(b.show_register= ?, 0)');
            } else {
                $s->where('(b.show_register= ?, -1)' OR '(b.show_register= ?, 0)');
    
            }
          echo $s-> __toString();
          //  var_dump(!empty($uid));
      return $this->getAdapter()->fetchRow($s);

    мега крутое условие
    $s->where('(b.show_register= ?, 1)' OR '(b.show_register= ?, 0)');

    kolyabres, 25 Февраля 2014

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

    +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
    33. 33
    34. 34
    35. 35
    36. 36
    var el = jQuery(this);
    	if(el.html().length<1){		
    		el.prev().find('div').addClass('over');
    		var url = jQuery(jQuery(el.prev().children()[0]).children()[1]).attr('href');
    		url = url.replace('index.php', '')+'?ajax=1';
    		//url = url.replace(/&task=[^&]+/, '&task=subcatalogs');
    
    		el.html(jQuery.ajax({
    			url: url,
    			async: false			
    		}).responseText);
    		var list = jQuery(el.children()[0]);
    		list.find('.parent').each(function(i,item){
    			jQuery(item).bind('click', catalogs_click);	
    			jQuery(item).bind('mouseover', catalogs_mouseover);
    			jQuery(item).bind('mouseout', catalogs_mouseout);
    			jQuery(item).prev().bind('mouseover', catalogs_mouseover2);
    			jQuery(item).prev().find('div').bind('mouseover', catalogs_mouseover3);
    			jQuery(item).prev().find('div a').bind('mouseover', catalogs_mouseover4);
    			jQuery(item).prev().find('div img').bind('mouseover', catalogs_mouseover5);
    		});
    		list.find('.final').each(function(i,item){
    			jQuery(item).bind('mouseover', catalogs_mouseover6).bind('mouseout', catalogs_mouseout6);
    			jQuery(item).find('div').bind('mouseover', catalogs_mouseover7).bind('mouseout', catalogs_mouseout7);
    			jQuery(item).find('div a').bind('mouseover', catalogs_mouseover8).bind('mouseout', catalogs_mouseout8);
    			jQuery(item).find('div img').bind('mouseover', catalogs_mouseover9).bind('mouseout', catalogs_mouseout9);
    		});
    		list.show();
    		
    	}else{
    		var list = jQuery(el.children()[0]);
    		if(!list.children().find('div').hasClass('over')){
    			el.prev().find('div').addClass('over');
    		}
    		list.show();
    	}

    Взялся за проект на фрилансе...

    LAKnoKAL, 19 Февраля 2014

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