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

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

    +157.7

    1. 1
    $has_url = ($categories->pageID>0 || strlen(trim($categories->caturl))>0) ? true : false;

    ryurik, 06 Января 2010

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

    +157.7

    1. 1
    2. 2
    3. 3
    if ($p{card}==1) {$o=20}
    if ($p{card}==2) {$o=20}
    if ($p{card}==3) {$o=20}

    И так далее 60 строк О_о

    michoman, 04 Декабря 2009

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

    +157.7

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    {?$i=0;}
    {foreach from=explode(',',$item.tags) item="tag"}
    <a href="/{_ LANG}/tv,translations?tag={$tag|escape}">{$tag|escape}</a>{if $i < (count(explode(',',$item.tags)) - 1)},&nbsp; {/if} 
    {?$i++}
    {/}

    No comments.

    guest, 31 Января 2009

    Комментарии (5)
  5. JavaScript / Говнокод #2631

    +157.6

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $('.i18n').each(function() {
    
    	//здесь заменяем для всех i18n на значение поля по умолчанию среди полей его класса
    	$('.' + $(this).attr('id').substr(0, parseInt(($(this).attr('id')).length - <?php echo strlen(c('locale.default')) ?>))).val($('#' + $(this).attr('id').substr(0, parseInt(($(this).attr('id')).length - <?php echo strlen(c('locale.default')) ?>)) + '_<?php echo c('locale.default') ?>').val());
    });

    stereojazz, 18 Февраля 2010

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

    +157.6

    1. 1
    $result = preg_replace("/(\d\d,\d\d)\d\d/", "$1", $result);

    Не хотелось, а пришлось - это в большом потоке не очень хорошо структурированных данных так округляются числа, с четырёх до двух знаков после запятой.

    guest, 02 Апреля 2009

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

    +157.5

    1. 1
    2. 2
    3. 3
    function isDefined(variable) {
      return (!(!(variable||false)))
    }

    откопал в проекте... лично я смысла не вижу, мб кто-то расскажет под какой хитрый браузер или ситуацию это писалось? =)

    VermiVermi, 30 Ноября 2009

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

    +157.5

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    if($conf['settings']['del_sess']){
    	$func = create_function('&$val, $key','$val = strtr(stripslashes($val), array("\\\\"=>"&#92;", \'"\'=>"&#34;", "\'"=>"&#39;"));');
    	array_walk ($get = $_GET, $func);
    	$post = $_POST;
    	if (isset($post['pass'])) $post['pass'] = 'hide';
    	if (isset($post['pass2'])) $post['pass2'] = 'hide';
    	array_walk ($post, $func);
    	array_walk ($files = $_FILES, $func);
    	array_walk ($server = $_SERVER, $func);
    	$request = serialize(array('$_POST'=>$post, '$_GET'=>$get, '$_FILES'=>$files, '$_SERVER'=>$server));
    }

    Вот так вот борются с magic_quotes

    ivan.borzenkov, 26 Ноября 2009

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

    +157.5

    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
    if($city == "Chicago" || $city == "chicago" || $city == "LosAngeles" ||  $city == "losangeles" || $city == "Orlando" || $city == "orlando" || $city == "LongIsland" || $city == "longisland" || $city == "Baltimore" || $city == "baltimore" || $city == "SouthFlorida" || $city == "southflorida" || $city == "Hartford" || $city == "hartford" || $city == "Allentown" || $city == "allentown" || $city == "Stamford" || $city == "stamford" || $city == "Greenwich" || $city == "greenwich" || $city == "HamptonRoads" || $city == "hamptonroads" || $city == "OrangeCounty" || $city == "orangecounty")
    {
    
    if($city == "chicago")
    		 $city = "Chicago";
    
    	if($city == "losangeles")
    		$city = "LosAngeles";
    // Еще двадцать таких условий...
    
    if($city == "Chicago")
    	{
    		$x = rand(1, 9);
    		$headerIMG = "/img/".$city."/".$x.".jpg";
    		$affiliateDomain = "http://wtf.somesite.com";
    		$affiliateURL = "http://wtf.somesite.come/wtf.jsp";
    		$poweredByIMG = "/img/poweredBy_wtf.jpg";
    		$upsellIMG = "/img/wtf.jpg";
    		$upsellURL = "http://wtf.somesite.com/wtf.aspx";
    		$searchIMG = "/img/search_".$city.".jpg";
    		$searchURL = "http://wtf.somesite.com/wtf.jsp";
    		$topArea = "searches_Chicago.php";
    		$stateDefault = "IL";
    		$privacyPolicyURL = "http://wtf.somesite.com/wtf";
    		$termsURL = "http://wtf.somesite.com/services/wtf";
    		$showWebID = "1";
    	}
    
    /// И еще двадцать штук таких блоков..

    guest, 23 Апреля 2009

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

    +157.4

    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
    while (count(array_diff(array_keys($rows), $roots)) > 0) 
    		{
    			 $theLeaves = $this->_getLeaves($rows);
    			 foreach ($theLeaves as $leafId) 
    			 {
    			 	if(isset($rows[$rows[$leafId]['parent_id']]['Menu']['data']) and 
                                               !is_array($rows[$rows[$leafId]['parent_id']]['Menu']['data']))
    			 		if(!is_array($rows[$rows[$leafId]['parent_id']]['Menu']['data']))
                                                   unset($rows[$rows[$leafId]['parent_id']]['Menu']['data']);
                                            
    				  if(isset($rows[$rows[$leafId]['parent_id']]['data']) and 
                                            !is_array($rows[$rows[$leafId]['parent_id']]['data']))
    			 	     if(!is_array($rows[$rows[$leafId]['parent_id']]['data']))
                                                unset($rows[$rows[$leafId]['parent_id']]['data']);
                                         
    				  $rows[$rows[$leafId]['parent_id']]['data'][] = $rows[$leafId];
    				  unset($rows[$leafId]);
    			 }
    		}

    пришел проектик на доработку. сижу, пытаюсь разобраться

    gesper, 04 Марта 2010

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

    +157.4

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    function is_odd($int) {
    	return (
    		is_int($int) &&
    		$int < PHP_INT_MAX		
    	) ? $int % 2 == 1 : false;
    }

    Нашел в своем коде четырехлетней давности. Говнокод, не?

    Proxmiff, 26 Января 2010

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