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

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

    +162

    1. 1
    2. 2
    if (suspended())
      resume();

    http://www.gamedev.ru/code/forum/?id=152077

    CPPGovno, 07 Сентября 2011

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

    +78

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    getText( 
    							
    							
    		wifiStates[ 
    		           Settings.getLocationService( ) == null || !Settings.isCellConfigEnabled( ) ? LED_OFF
    							: Settings.isNetworkLocationEnabled( ) ? LED_ON
    									: LED_ERROR 
    				  ] ), Toast.LENGTH_SHORT )
    					.show( );

    Кусочек кода из приложения для андроида, которое придется поддерживать.... 0_0

    exeed, 02 Сентября 2011

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

    −119

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    private function onEnterFrame(e:Event):void { 
       if (success)
        {
        }
       else
       {
        }
    }

    24 раза в секунду: "У вас всё хорошо? Вот и славно. Всё плохо? Да и чёрт с ним."

    robin, 02 Сентября 2011

    Комментарии (6)
  5. ActionScript / Говнокод #7710

    −109

    1. 1
    for (var i:int = 0; i < _levelingScores[i]; i++)

    Три дня багу искал :D Подумываю сходить к доктору.

    crazy_horse, 31 Августа 2011

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

    +156

    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
    /**
     * форматирование даты - преобразует дату в формат ДД-ММ-ГГГГ
     *
     * @param unknown_type $inDate - дата
     * @return unknown
     */
    public static function getDateFormatted($inDate, $forView = false, $inTime = '') {
    	//2011-05-03 20:27:26
    	
    	$a_tmp = explode(' ', $inDate);
    	if ($forView) {
    		$time = substr($a_tmp[1], 0, 5);
    		if ($a_tmp[0] == date('Y-m-d')) {
    			if ($time == '') {
    				$time = substr($inTime, 11, 5);
    				if ($time == '') {
    					$time = $inTime;
    				}
    			}
    			if ($time != '') {
    				return 'Сегодня, ' . $time;
    			}
    		}
    
    		$a_tmp = explode('-', $a_tmp[0]);
    
    		return $a_tmp[2] . '-' . $a_tmp[1] . '-' . $a_tmp[0];
    	}
    
    	$inDate = substr($inDate, 0 , 10);
    	$inDate = str_replace(' ', '', $inDate);
    	$inDate = str_replace('.', '-', $inDate);
    
    	$a_tmp = explode('-', $inDate);
    	if (strlen($a_tmp[0]) == 4) {
    		$inDate = str_pad($a_tmp[2], 2, '0', STR_PAD_LEFT) . '-' . $a_tmp[1] . '-' . $a_tmp[0];
    	}
    	return $inDate;
    }

    Sers, 30 Августа 2011

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

    +165

    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
    function show_price_list() {
    		$period_1 = $period_2 = $period_3 = $period_4 = $period_5 = $period_6 = "";
    		$query = "
    				SELECT id, price, type
    				FROM price 
    				ORDER BY type, start
    			";
    		$this->registry['sql']->query($query);
    		if ($this->registry['sql']->getNumberRows()>0) {
    			foreach ($this->registry['sql']->getFetchObject() as $oRow) {
    				switch($oRow->type) {
    					case 0: $period_1 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
    					break;
    					case 1: $period_2 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
    					break;
    					case 2: $period_3 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
    					break;
    					case 3: $period_4 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
    					break;
    					case 4: $period_5 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
    					break;
    					case 5: $period_6 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
    					break;
    				}
    			}
    		}
    		@$this->registry['template']->set('period_1', $period_1);
    		@$this->registry['template']->set('period_2', $period_2);
    		@$this->registry['template']->set('period_3', $period_3);
    		@$this->registry['template']->set('period_4', $period_4);
    		@$this->registry['template']->set('period_5', $period_5);
    		@$this->registry['template']->set('period_6', $period_6);
    	}

    Модель в шаблоне MVC

    vkontakte, 30 Августа 2011

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

    +159

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    if (strlen($_POST["NEW_PASSWORD"]) <= 0)
    					$arResult["ERROR"][] = GetMessage("STOF_ERROR_REG_FLAG1");
    
    				if (strlen($_POST["NEW_PASSWORD"]) > 0 && strlen($_POST["NEW_PASSWORD_CONFIRM"]) <= 0)
    					$arResult["ERROR"][] = GetMessage("STOF_ERROR_REG_FLAG1");
    
    				if (strlen($_POST["NEW_PASSWORD"]) > 0
    					&& strlen($_POST["NEW_PASSWORD_CONFIRM"]) > 0
    					&& $_POST["NEW_PASSWORD"] != $_POST["NEW_PASSWORD_CONFIRM"])
    					$arResult["ERROR"][] = GetMessage("STOF_ERROR_REG_PASS");

    Взято из Битрикса /bitrix/components/bitrix/sale.order.ajax/component.php

    Потрясающие идентификаторы мессаджей. Ну а то, что прочитать код без слома глаз нельзя отдельная песня.
    В целом там такого внутри много.

    zima, 29 Августа 2011

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

    +174

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    function get_field_by_id($tbl,$field,$id){ //получить field по id
    	$res=mysql_query($v="SELECT * FROM $tbl where `id`=$id");
    	$rez=mysql_fetch_array($res);
    	return $rez["$field"];
    }

    De-Luxis, 29 Августа 2011

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

    +164

    1. 1
    2. 2
    3. 3
    4. 4
    function prepare_graph_query($query, $date_column, $date_format="%b %d") {
    	$date_format = empty($date_format) ? "%Y %b" : $date_format;
    	//...
    }

    Lowezar, 26 Августа 2011

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

    +157

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    function utf8win1251($s){
      $out=""; $c1=""; $byte2=false;
      for ($c=0;$c<strlen($s);$c++){
        $i=ord($s[$c]); if ($i<=127) $out.=$s[$c];
        if ($byte2) { $new_c2=($c1&3)*64+($i&63); $new_c1=($c1>>2)&5;
          $new_i=$new_c1*256+$new_c2;
          if ($new_i==1025) $out_i=168; else
          if ($new_i==1105) $out_i=184; else $out_i=$new_i-848;
          $out.=chr($out_i); $byte2=false; }
        if (($i>>5)==6) {$c1=$i;$byte2=true; } }
     return $out; }

    Я ничо не понял, но это круто.

    http://letopisi.ru/index.php/Знаете-ли-что%3F_скрипт

    7ion, 25 Августа 2011

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