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

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

    +164

    1. 1
    min=(pSamplesVector->operator[](i)).x;

    rat4, 04 Февраля 2011

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

    +164

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    $args['section'] = (int)$_POST['section'];
    
    $args['type'] = 0;
    
    if ($args['section'] == 1117){$args['section'] = 7;$args['type'] = 1;}
    if ($args['section'] == 2227){$args['section'] = 7;$args['type'] = 2;}
    if ($args['section'] == 11111){$args['section'] = 11;$args['type'] = 1;}
    if ($args['section'] == 22211){$args['section'] = 11;$args['type'] = 2;}

    Magic numbers в действии

    dew2, 03 Февраля 2011

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

    +164

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    $exist = true;
    
    while ($exist) { 
           $user = 'guest'.rand(1,100000);
     	if (!Customer::customerExists($email = $user.'@ya.ru'))
     	$exist = false;
    }

    Prestashop, хак, убирающий регистрацию. #5476 напомнил.

    dew2, 01 Февраля 2011

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

    +164

    1. 1
    $code = $id_user.rand(0,9).rand(0,12).rand(0,32).rand(0,32).rand(0,32).rand(0,32).rand(0,32).".txt";

    Стопицотый генератор.

    Uchkuma, 01 Февраля 2011

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

    +164

    1. 1
    2. 2
    3. 3
    4. 4
    {php}
        header('Content-type: text/html; charset=utf-8');
        $this->assign('host', $_SERVER['HTTP_HOST']);
    {/php}

    Увидел в проекте доставшемся по наследству и сел на пятую точку. Феерический гк

    wmmorgun, 31 Января 2011

    Комментарии (2)
  7. 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)
  8. PHP / Говнокод #5424

    +164

    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
    $proArray = array();
    while(strlen($result))
    {
    	// name
    	$keypos= strpos($result,'=') ;
    	$keyval = substr($result,0,$keypos);
    	// value
    	$valuepos = strpos($result,'&') ? strpos($result,'&') : strlen($result);
    	$valval = substr($result,$keypos+1,$valuepos-$keypos-1);
    	// decoding the respose
    	$proArray[$keyval] = $valval;
    	$result = substr($result,$valuepos+1,strlen($result));
    }

    Разбор URL-encoded ответа от платёжной системы.
    Знал ли автор про функцию parse_str() ?

    hdkeeper, 28 Января 2011

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

    +164

    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
    WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
    {
            try
            {
                     Application->Initialize();
                     Application->CreateForm(__classid(TForm1), &Form1);
                     Application->Run();
            }
            catch (Exception &exception)
            {
                     Application->ShowException(&exception);
            }
            catch (...)
            {
                     try
                     {
                             throw Exception("");
                     }
                     catch (Exception &exception)
                     {
                             Application->ShowException(&exception);
                     }
            }
            return 0;
    }

    Ну чтобы уж точно обработать все runtime-отбросы.

    dwinner, 18 Января 2011

    Комментарии (45)
  10. C++ / Говнокод #5277

    +164

    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
    // Licensed to Green Energy Corp (www.greenenergycorp.com) under one
    // or more contributor license agreements. See the NOTICE file
    // distributed with this work for additional information
    // regarding copyright ownership. Green Enery Corp licenses this file
    // to you under the Apache License, Version 2.0 (the
    // "License"); you may not use this file except in compliance
    // with the License. You may obtain a copy of the License at
    // http://www.apache.org/licenses/LICENSE-2.0
    // Unless required by applicable law or agreed to in writing,
    // software distributed under the License is distributed on an
    // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    // KIND, either express or implied. See the License for the
    // specific language governing permissions and limitations
    // under the License.
    //
    #include "Objects.h"
    
    #define MACRO_STATIC_INSTANCE(group, var) Group##group##Var##var Group##group##Var##var::mInstance;
    
    namespace apl { namespace dnp {
    
    MACRO_STATIC_INSTANCE(1,0)
    MACRO_STATIC_INSTANCE(1,1)
    MACRO_STATIC_INSTANCE(1,2)
    MACRO_STATIC_INSTANCE(2,0)
    MACRO_STATIC_INSTANCE(2,1)
    MACRO_STATIC_INSTANCE(2,2)
    MACRO_STATIC_INSTANCE(2,3)
    
    <... 100500 строк ...>
    
    MACRO_STATIC_INSTANCE(60,1)
    MACRO_STATIC_INSTANCE(60,2)
    MACRO_STATIC_INSTANCE(60,3)
    MACRO_STATIC_INSTANCE(60,4)
    
    MACRO_STATIC_INSTANCE(80,1)
    
    MACRO_STATIC_INSTANCE(110,0)
    MACRO_STATIC_INSTANCE(111,0)
    MACRO_STATIC_INSTANCE(112,0)
    MACRO_STATIC_INSTANCE(113,0)
    
    //////////////////////////////////////////////
    // Binary Input Types
    //////////////////////////////////////////////
    
    void Group1Var2::Write(apl::byte_t* p, const apl::Binary& v) const { DNPToStream::WriteQ(p, Group1Var2::Inst(), v); }
    void Group2Var1::Write(apl::byte_t* p, const apl::Binary& v) const { DNPToStream::WriteQ(p, Group2Var1::Inst(), v); }
    void Group2Var2::Write(apl::byte_t* p, const apl::Binary& v) const { DNPToStream::WriteQT(p, Group2Var2::Inst(), v); }
    void Group2Var3::Write(apl::byte_t* p, const apl::Binary& v) const { DNPToStream::WriteQT(p, Group2Var3::Inst(), v); }
    
    Binary Group1Var2::Read(const apl::byte_t* p) const { return DNPFromStream::ReadBinaryQV(p, Group1Var2::Inst()); }
    Binary Group2Var1::Read(const apl::byte_t* p) const { return DNPFromStream::ReadBinaryQV(p, Group2Var1::Inst()); }
    Binary Group2Var2::Read(const apl::byte_t* p) const { return DNPFromStream::ReadBinaryQV(p, Group2Var2::Inst()); }
    Binary Group2Var3::Read(const apl::byte_t* p) const { return DNPFromStream::ReadBinaryQVT(p, Group2Var3::Inst()); }

    "We provide world-class engineering services to companies leading the smart energy revolution."
    посредством копипасты. малаца.

    xXx_totalwar, 14 Января 2011

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

    +164

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    if( $check_referer ) {
    	if( $_SERVER['HTTP_REFERER'] == ''and $_REQUEST['subaction'] != 'dologin') $allow_login = true;
    	elseif( clean_url( $_SERVER['HTTP_REFERER'] ) == clean_url( $_SERVER['HTTP_HOST'] ) ) $allow_login = true;
    }else {
    	$allow_login = true;
    }

    dle software

    DanxilLs, 12 Января 2011

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