1. Pascal / Говнокод #5454

    +103

    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
    Const MAX32 : DWord = $FFFFFFFF;
     
    Var
        State : Array[0..15] of DWord;
        Count : Array[0..1] of DWord;
        Len : Byte;
        Buffer : Array[0..31] of Byte;
     
    Procedure SHIFT12(var U : Array of DWord; var M : Array of DWord; var S : Array of DWord);
    Begin
            U[0] := M[0] xor S[6];
            U[1] := M[1] xor S[7];
            U[2] := M[2] xor (S[0] shl 16) xor (S[0] shr 16) xor (S[0] and $FFFF) xor
                    (S[1] and $FFFF) xor (S[1] shr 16) xor (S[2] shl 16) xor S[6] xor (S[6] shl 16) xor
                    (S[7] and $FFFF0000) xor (S[7] shr 16);
            U[3] := M[3] xor (S[0] and $FFFF) xor (S[0] shl 16) xor (S[1] and $FFFF) xor
                    (S[1] shl 16) xor (S[1] shr 16) xor (S[2] shl 16) xor (S[2] shr 16) xor
                    (S[3] shl 16) xor S[6] xor (S[6] shl 16) xor (S[6] shr 16) xor (S[7] and $FFFF) xor
                    (S[7] shl 16) xor (S[7] shr 16);
            U[4] := M[4] xor
                    (S[0] and $FFFF0000) xor (S[0] shl 16) xor (S[0] shr 16) xor
                    (S[1] and $FFFF0000) xor (S[1] shr 16) xor (S[2] shl 16) xor (S[2] shr 16) xor
                    (S[3] shl 16) xor (S[3] shr 16) xor (S[4] shl 16) xor (S[6] shl 16) xor
                    (S[6] shr 16) xor(S[7] and $FFFF) xor (S[7] shl 16) xor (S[7] shr 16);
            U[5] := M[5] xor (S[0] shl 16) xor (S[0] shr 16) xor (S[0] and $FFFF0000) xor
                    (S[1] and $FFFF) xor S[2] xor (S[2] shr 16) xor (S[3] shl 16) xor (S[3] shr 16) xor
                    (S[4] shl 16) xor (S[4] shr 16) xor (S[5] shl 16) xor  (S[6] shl 16) xor
                    (S[6] shr 16) xor (S[7] and $FFFF0000) xor (S[7] shl 16) xor (S[7] shr 16);
            U[6] := M[6] xor S[0] xor (S[1] shr 16) xor (S[2] shl 16) xor S[3] xor (S[3] shr 16) xor
                    (S[4] shl 16) xor (S[4] shr 16) xor (S[5] shl 16) xor (S[5] shr 16) xor S[6] xor
                    (S[6] shl 16) xor (S[6] shr 16) xor (S[7] shl 16);
            U[7] := M[7] xor (S[0] and $FFFF0000) xor (S[0] shl 16) xor (S[1] and $FFFF) xor
                    (S[1] shl 16) xor (S[2] shr 16) xor (S[3] shl 16) xor S[4] xor (S[4] shr 16) xor
                    (S[5] shl 16) xor (S[5] shr 16) xor (S[6] shr 16) xor (S[7] and $FFFF) xor
                    (S[7] shl 16) xor (S[7] shr 16);
    End;
     
    Procedure SHIFT16(var H : Array of DWord; var V : Array of DWord; var U : Array of DWord);
    Begin
            V[0] := H[0] xor (U[1] shl 16) xor (U[0] shr 16);
            V[1] := H[1] xor (U[2] shl 16) xor (U[1] shr 16);
            V[2] := H[2] xor (U[3] shl 16) xor (U[2] shr 16);
            V[3] := H[3] xor (U[4] shl 16) xor (U[3] shr 16);
            V[4] := H[4] xor (U[5] shl 16) xor (U[4] shr 16);
            V[5] := H[5] xor (U[6] shl 16) xor (U[5] shr 16);
            V[6] := H[6] xor (U[7] shl 16) xor (U[6] shr 16);
            V[7] := H[7] xor (U[0] and $FFFF0000) xor (U[0] shl 16) xor (U[7] shr 16) xor
                    (U[1] and $FFFF0000) xor (U[1] shl 16) xor (U[6] shl 16) xor (U[7] and $FFFF0000);
    End;

    qbasic, 31 Января 2011

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

    +159

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    <?
    exec('dir "'.str_replace('/','\\',$fname).'"',$r);
    $r = implode("\r\n",$r);
    $r = str_replace("\xFF",' ',$r);
    preg_match('/[\d]{2,2}\.[\d]{2,2}\.[\d]{2,4}[\s]+[\d]{2,2}\:[\d]{2,2}[\s]+([\d\s]+)/im',$r,$m);
    if (!isset($m[1])) return false;
    $size = str_replace(' ','',$m[1]);

    qbasic, 31 Января 2011

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

    +164

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    <?
    ...
    function toUpper($content){
        $trans_eng = array('q' => 'Q', 'w' => 'W', 'e' => 'E', 'r' => 'R', 't' => 'T', 'y' => 'Y', 'u' => 'U', 'i' => 'I', 'o' => 'O', 'p' => 'P', 'a' => 'A', 's' => 'S', 'd' => 'D', 'f' => 'F', 'g' => 'G', 'h' => 'H', 'j' => 'J', 'k' => 'K', 'l' => 'L', 'z' => 'Z', 'x' => 'X', 'c' => 'C', 'v' => 'V', 'b' => 'B', 'n' => 'N', 'm' => 'M');
        $trans_rus = array('а' => 'А', 'б' => 'Б', 'в' => 'В', 'г' => 'Г', 'д' => 'Д', 'е' => 'Е', 'ё' => 'Ё', 'ж' => 'Ж', 'з' => 'З', 'и' => 'И', 'й' => 'Й', 'к' => 'К', 'л' => 'Л', 'м' => 'М', 'н' => 'H', 'о' => 'О', 'р' => 'Р', 'п' => 'П', 'с' => 'С', 'т' => 'Т', 'у' => 'У', 'ф' => 'Ф', 'х' => 'Х', 'ц' => 'Ц', 'ч' => 'Ч', 'ш' => 'Ш', 'щ' => 'Щ', 'ъ' => 'Ъ', 'ь' => 'Ь', 'ы' => 'Ы', 'э' => 'Э', 'ю' => 'Ю', 'я' => 'Я');
        $content = strtr($content, $trans_eng);
        $content = strtr($content, $trans_rus);
        return $content;
    }
    ...
    ?>

    1_and_0, 31 Января 2011

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

    +83

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    if ( file.isDirectory())
        {
          try
          {
            throw new Exception("Cannot backup directories recently.");
          }
          catch ( Exception e ) { ExceptionHandler.handle( e ); }
        }

    Belorus, 31 Января 2011

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

    +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
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    public SqlTransaction GetSqlTransaction(string pMd5)
    {
    	if (_connection.State == ConnectionState.Closed)
    	{
    		try
    		{
    			_connection.Open();
    		}
    		catch (SqlException ex)
    		{
    			throw new ApplicationException("Unable to connect to database (" + _connection.DataSource + "/" + _connection.Database + "). Please contact your local IT administrator.", ex);
    		}
    	}
    	else
    	{
    		try
    		{
    			throw new ApplicationException("COUCOU");
    		}
    		catch (ApplicationException ex)
    		{
    			System.Diagnostics.Trace.WriteLine(ex.StackTrace);
    		}
    		sqlTransaction = _connection.BeginTransaction();
    	}
    	return sqlTransaction;
    }

    Код из очередного проекта. А надежда то на коннект все-равно остается! :)

    _Ru55_, 31 Января 2011

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

    +166

    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
    <?
    ...
    <a href="<?php echo $this->_tpl_vars['sBaseBackend']; ?>
    /page/<?php echo $this->_tpl_vars['aMapMenuItem']['list']->id; ?>
    /"><?php if ($this->_tpl_vars['aMapMenuItem']['list']->header != ''): ?><?php echo $this->_tpl_vars['aMapMenuItem']['list']->header; ?>
    <?php else: ?><?php echo $this->_tpl_vars['aMapMenuItem']['list']->uri; ?>
    <?php endif; ?></a> <?php if ($this->_tpl_vars['aMapMenuItem']['list']->type == 'photo'): ?><sub><a href="<?php echo $this->_tpl_vars['sBaseBackend']; ?>
    /albums/index/<?php echo $this->_tpl_vars['aMapMenuItem']['list']->id; ?>
    /">альбомы</a></sub><?php endif; ?>
    			<?php if ($this->_tpl_vars['aMapMenuItem']['list']->id_parent >= 0): ?>
    				<?php if ($this->_tpl_vars['aMapMenuItem']['list']->position > 1): ?>
    ...
    ?>

    1_and_0, 31 Января 2011

    Комментарии (9)
  7. Си / Говнокод #5448

    +126

    1. 1
    2. 2
    3. 3
    4. 4
    int main() {
        long long A = 44903392596LL;
        printf((char *)&A);
    }

    Выводим текст.

    danilissimus, 31 Января 2011

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

    +146

    1. 1
    2. 2
    3. 3
    public function loadClass($class) {
    		return class_exists($class)||interface_exists($class)||($this->load($this->findClass($class))&&(class_exists($class)||interface_exists($class)));		
    	}

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

    Lure Of Chaos, 30 Января 2011

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

    +144

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    public function __destruct() {
    		parent::__destruct();
    		if(!self::$_c--) {
    			session_write_close();
    		}
    	}

    прямичком из IDE

    Lure Of Chaos, 30 Января 2011

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

    +146

    1. 1
    Notice: unserialize(): Error at offset 8180 of 8192 bytes in /home/***/govnokod/mzz/system/cache/cacheFile.php on line 81

    -10

    %govnouser%, 30 Января 2011

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