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

    +162

    1. 1
    2. 2
    $id = $this->db->fetchCol('SELECT id FROM data;');
    $names = $this->db->fetchCol('SELECT name FROM points INNER JOIN data ON points.id = data.point_id_from;');

    Zend Db usage

    jf4ever, 18 Ноября 2011

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

    +160

    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
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    function &GetObject($cls, $p=null, $flags=0)
    {	//HIDE($objects,$i,$ext,$n,$v)
    	static $objects;
    	if (is_array($cls)) {
    		$i = null;
    		foreach($cls as $n=>$v) $i->$n = $v;
    		$result = &$i;
    		return $result;
    	}
    	if (!($flags&O_NEW) && isset($objects[$cls])) return $objects[$cls];
    
    	$ext = new WExtern($cls, 'c');
    	if (!($flags&O_NEW) && isset($objects[$i=$ext->Id()])) return $objects[$i];
        if ($flags&O_INSTANCE) {$x = null; $result = &$x; return $result;}
    
    	if (!$ext->Exists()) $ext->Prepare();
    	if (($flags&O_NOERROR) && !class_exists($ext->c)) {
    		$co = $ext->c;
    		$cc = $co{0}.'B'.substr($co,1);
    		if (($flags&O_NOERROR) && !class_exists($cc)) {
    			$i = false;
    			return $i;
    		} else {
    			$ext->c = $cc;
    		}
    	}
    	
    	if (!class_exists($ext->c)) {
    		$co = $ext->c;
    		$cc = $co{0}.'B'.substr($co,1);
    		if (!class_exists($cc)) {
    			$i = false;
    			return $i;
    		} else {
    			$ext->c = $cc;
    		}
    	}
    	$c = $ext->c;
    	$i = new $c;
    
    	if (isset($ext->I) && $ext->I) $i->_I = reset($ext->I);	// Instance ID
    	if (isset($ext->A) && $ext->A) $i->_A = $ext->A;		// Alias ID
    
    	if (!($flags&O_NEW)) {
    		$objects[$ext->Id()] = &$i;
    		if ($ext->Id()!=$cls) $objects[$cls] = &$i;
    	}
    	$options = &WConfig::Get('OPTIONS');
    	if (/*is_a($i, 'wobject')*/ $i instanceof wobject && $options) {
    		$o = $options;
    		$c = get_class($i);
    		do{
    			$c = strtolower($c);
    			if (isset($o[$c])) {
        			$i->o = array_merge($o[$c], isset($i->o) ?$i->o :array());
    			}
    		}while($c=get_parent_class($c));
    		if (isset($ext->A) && isset($o[$ext->A])) 	$i->o = array_merge(isset($i->o) ?$i->o :array(), $o[$ext->A]);
    		if ($ext->I && isset($o[$ext->Id()])) 		$i->o = array_merge(isset($i->o) ?$i->o :array(), $o[$o[$ext->Id()]]);
    	}
    
    	if (is_object($p)) {
    		if (isset($p->o)) $i->o = array_merge(isset($i->o) ?$i->o :array(), $p->o);
    		$p = isset($p->c) ? $p->c : null;
    	}
    	if (method_exists($i,'Create')  && $p!==false) {
    		call_user_func_array(array(&$i,'Create'), is_array($p) ?$p : (isset($p) ? array($p) : array()));
    	}
    
    	return $i;
    }

    Одна из базовых функций фремворка.

    Orion189, 18 Ноября 2011

    Комментарии (14)
  3. C# / Говнокод #8564

    +124

    1. 1
    _videoNum = (byte) (videoNum==0?videoNum:0);

    попалось сегодня в исходниках рабочего проекта

    _vinka, 18 Ноября 2011

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

    +80

    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
    m_scrabblerProperties = Utils.loadPropertiesFile(m_args[1]);
    if (null != m_scrabblerProperties)
    {
    	System.out.println("Executing DBScrubber with properties file " + m_args[1] + " loaded from the classpath");
    }
    else
    {
    	try
    	{
    		m_scrabblerProperties.load(new FileInputStream(m_args[1]));
    		System.out.println("Executing DBScrubber with properties file " + m_args[1] + " loaded from the file system");
    	}
    	catch (IOException e)
    	{
    		System.err.println("Failed to load " + m_args[1] + " from the classpath or the file system");
    	}
    }

    Utils.loadPropertiesFile - какая то хитрая поделуха которая ищет файл в кэше. Если он не найден в кэше, то автор видимо хотел попробовать считать файл с диска, но судя по всему оказался оказался дебилом.

    askell, 18 Ноября 2011

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

    +166

    1. 1
    foreach ($_GET as $xxx => $rvar) { $$xxx = $rvar; }

    может боян конешн

    pusinsky, 18 Ноября 2011

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

    −362

    1. 1
    // Если FlowerItem, то ложим продукт в подарки, иначе ложим на склад

    Блядь, ну ведь не ложим, а кладем!

    grin, 17 Ноября 2011

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

    +163

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if (isset($_GET['last_user']) && (int)$_GET['last_user']){
        $last_user = 0;
    }else{
        $last_user = (int)$_GET['last_user'];
    }

    no comments.. )

    Igogo, 17 Ноября 2011

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

    +162

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    $tmp_arr=array();
    $id1_str='';
    $root_str='';
    foreach($id1 as $id){
    	$id1_str.=$id['id'].' , ';
    	if(!isset($tmp_arr[$id['root']])){
    		$root_str.=$id['root'].' , ';
    		$tmp_arr[$id['root']]=true;
    	}
    }

    это типа такой способ собрать distinct root ids в строку!
    не забыть потом откусить хвост ' , '
    нормальные герои не ищут легких путей

    shitcoder, 17 Ноября 2011

    Комментарии (1)
  9. C++ / Говнокод #8549

    +996

    1. 1
    abstractObject=abstractObject;

    Когда я это обнаружила в коде, то упала со стула.

    Говногость, 17 Ноября 2011

    Комментарии (137)
  10. Pascal / Говнокод #8547

    +100

    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
    function Encrypt(jstr: String): String;
    var
      I: Integer;
      A: Real;
    begin
      if Length(jstr) = 0 Then begin
        Result := '';
        Exit;
      end;
      A := 0;
        for I := 0 To Length(jstr) do
          A := A + (Ord(jstr[I]) * Pos(jstr[I],jstr)) / 33;
      Result := FormatFloat('0000000000.0000000000',A);
      if Pos(',',Result) > 0 then begin
        Insert('.',Result,Pos(',',Result));
        Delete(Result,Pos(',',Result),1);
      end;
    end;

    bugmenot, 17 Ноября 2011

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