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

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

    +2

    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
    <?
    $lasturl = ($_GET[url]) ? $_GET[url] : $CONFIG[site_url]; // последний урл
    
    $expire = ($_GET[expire] == 1) ? time() + 365*24*60*60 : 0;
    
    $domain = str_replace('www.', '', $_SERVER['HTTP_HOST']);
    
    if (preg_match('/^[\d\.]*$/', $domain)) $cookie_domain = $domain; // ip-домен
    else {$temp = explode('.', $domain); $temp = array('', $temp[count($temp)-2], $temp[count($temp)-1]); $cookie_domain = implode('.', $temp);}
    
    setcookie($CONFIG[cookie_name], serialize(array($_GET[user_id],$_GET[password])), $expire, $CONFIG[cookie_path], $cookie_domain,
    	$CONFIG[cookie_secure], true);
    if($_GET['iframe'])
    {
        setcookie('iframe', '1', $expire, $CONFIG[cookie_path], $cookie_domain,
            $CONFIG[cookie_secure], true);
    }
    
    $i = array_search('www.'.$domain, $CONFIG[domains]);
    
    
    if ($i && $CONFIG[domains][$i] && $i == count($CONFIG[domains]) - 1) $url = $lasturl;
    else
    	$url = 'http://'.$CONFIG[domains][$i+1].'/domain_login/?user_id='.$_GET[user_id]
    	.'&password='.$_GET[password].'&expire='.$_GET[expire].'&url='.rawurlencode($lasturl).'&iframe='.($_GET['iframe']?'1':'0');
    
    header("Location: $url");
    
    ScriptEnd();
    
    
    ?>

    ... когда хочется бросить все и уехать в деревню. Наслаждаться утренней свежестью, слушать пение птиц. День за днем восстанавливая психику так беспощадно порушенную жестокими людьми-самозванцами, порочащими нашу профессию богов!

    © "PHP. Немного боли и страдания"

    3371, 17 Мая 2016

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

    −96

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    Процедура Таймаут(ЧислоСекунд)
    	НачВремя = ТекущаяДата();
    	Пока 1 = 1 Цикл
    		Если ТекущаяДата() - НачВремя > ЧислоСекунд Тогда
    			Прервать;
    		КонецЕсли;
    	КонецЦикла; 
    КонецПроцедуры

    Вот это я понимаю!!! Таймаут...
    Это из той же конфигурации, что и прошлые мои кладки.
    По прежнему коплю на патроны.
    Открыт для любых конструктивных идей.

    ivan_0110, 05 Мая 2016

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

    +4

    1. 1
    2. 2
    IEnumerable<SmartCurrencyPriceRule> rules = _smartRuleService.GetCurrencyPriceRules(id).OrderBy(r => r.Title).ThenBy(r => r.Updated).ThenBy(r => r.Created);
    var oldPriceRule = rules.SingleOrDefault(r => r.RuleId == postData.RuleId) ?? new SmartCurrencyPriceRule();

    Давайте три раза отсортируем, а то мало ли что, а потом возьмём тот, у которого id совпадает.
    Вот что значит - любит человек порядок.

    kerman, 23 Апреля 2016

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

    +1

    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
    [DllImport("quickusb.dll", CharSet = CharSet.Ansi)]
    static extern int QuickUsbWriteData(IntPtr Handle, byte[] outData, int length);
    
    // ...
    
     public bool Write(byte[] data)
        {
        // ...
            int result = QuickUsbWriteData(handle, data, data.Length);
    
            if (result != 0)
                return true;
            else if (result == 0)
            {
                LastError =  "QUSB returned 0";
                return false;
            }
            else
            {
                LastError = "Unknown error inside WriteData";
                return false;
            }
        // ...
      }

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

    yamamoto, 25 Марта 2016

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

    +2

    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
    <div class="form-group">
    	<label for="inputName" class="col-sm-2 control-label">День рождения:</label>
    	<div class="col-sm-3">
    		<select class="form-control" id="day">
    			<option <?php if($explode[2] == 01) Echo "selected"; ?> value="01">01</option>
    			<option <?php if($explode[2] == 02) Echo "selected"; ?> value="02">02</option>
    			<option <?php if($explode[2] == 03) Echo "selected"; ?> value="03">03</option>
    			<option <?php if($explode[2] == 04) Echo "selected"; ?> value="04">04</option>
    			<option <?php if($explode[2] == 05) Echo "selected"; ?> value="05">05</option>
    			<option <?php if($explode[2] == 06) Echo "selected"; ?> value="06">06</option>
    			<option <?php if($explode[2] == 07) Echo "selected"; ?> value="07">07</option>
    			<option <?php if($explode[2] == 08) Echo "selected"; ?> value="08">08</option>
    			<option <?php if($explode[2] == 09) Echo "selected"; ?> value="09">09</option>
    			<option <?php if($explode[2] == 10) Echo "selected"; ?> value="10">10</option>
    			<option <?php if($explode[2] == 11) Echo "selected"; ?> value="11">11</option>
    			<option <?php if($explode[2] == 12) Echo "selected"; ?> value="12">12</option>
    			<option <?php if($explode[2] == 13) Echo "selected"; ?> value="13">13</option>
    			<option <?php if($explode[2] == 14) Echo "selected"; ?> value="14">14</option>
    			<option <?php if($explode[2] == 15) Echo "selected"; ?> value="15">15</option>
    			<option <?php if($explode[2] == 16) Echo "selected"; ?> value="16">16</option>
    			<option <?php if($explode[2] == 17) Echo "selected"; ?> value="17">17</option>
    			<option <?php if($explode[2] == 18) Echo "selected"; ?> value="18">18</option>
    			<option <?php if($explode[2] == 19) Echo "selected"; ?> value="19">19</option>
    			<option <?php if($explode[2] == 20) Echo "selected"; ?> value="20">20</option>
    			<option <?php if($explode[2] == 21) Echo "selected"; ?> value="21">21</option>
    			<option <?php if($explode[2] == 22) Echo "selected"; ?> value="22">22</option>
    			<option <?php if($explode[2] == 23) Echo "selected"; ?> value="23">23</option>
    			<option <?php if($explode[2] == 24) Echo "selected"; ?> value="24">24</option>
    			<option <?php if($explode[2] == 25) Echo "selected"; ?> value="25">25</option>
    			<option <?php if($explode[2] == 26) Echo "selected"; ?> value="26">26</option>
    			<option <?php if($explode[2] == 27) Echo "selected"; ?> value="27">27</option>
    			<option <?php if($explode[2] == 28) Echo "selected"; ?> value="28">28</option>
    			<option <?php if($explode[2] == 29) Echo "selected"; ?> value="29">29</option>
    			<option <?php if($explode[2] == 30) Echo "selected"; ?> value="30">30</option>
    			<option <?php if($explode[2] == 31) Echo "selected"; ?> value="31">31</option>
    		</select>
    	</div>
    	<div class="col-sm-4">
    		<select class="form-control" id="month">
    			<option <?php if($explode[3] == 01) Echo "selected"; ?> value="01">Января</option>
    			<option <?php if($explode[3] == 02) Echo "selected"; ?> value="02">Февраля</option>
    			<option <?php if($explode[3] == 03) Echo "selected"; ?> value="03">Марта</option>
    			<option <?php if($explode[3] == 04) Echo "selected"; ?> value="04">Апреля</option>
    			<option <?php if($explode[3] == 05) Echo "selected"; ?> value="05">Мая</option>
    			<option <?php if($explode[3] == 06) Echo "selected"; ?> value="06">Июня</option>
    			<option <?php if($explode[3] == 07) Echo "selected"; ?> value="07">Июля</option>
    			<option <?php if($explode[3] == 08) Echo "selected"; ?> value="08">Августа</option>
    			<option <?php if($explode[3] == 09) Echo "selected"; ?> value="09">Сентября</option>
    			<option <?php if($explode[3] == 10) Echo "selected"; ?> value="10">Октября</option>
    			<option <?php if($explode[3] == 11) Echo "selected"; ?> value="11">Ноября</option>
    			<option <?php if($explode[3] == 12) Echo "selected"; ?> value="12">Декабря</option>
    		</select>
    	</div>
    </div>

    Суровые челябинские программисты :)

    by133312, 13 Марта 2016

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

    −1

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    #ifndef H112
    #define H112 201004L
    
    #include<iostream>
    #include<fstream>
    #include<sstream>
    #include<cmath>
    #include<cstdlib>
    #include<string>
    #include<list>
    #include<vector>
    #include<algorithm>
    #include<stdexcept>
    
    //------------------------------------------------------------------------------
    
    #ifdef _MSC_VER
    #include <hash_map>
    using stdext::hash_map;
    #else
    #include <ext/hash_map>
    using __gnu_cxx::hash_map;
    
    namespace __gnu_cxx {
    
        template<> struct hash<std::string>
        {
            size_t operator()(const std::string& s) const
            {
                return hash<char*>()(s.c_str());
            }
        };
    
    } // of namespace __gnu_cxx
    #endif
    
    //------------------------------------------------------------------------------
    
    #define unordered_map hash_map
    
    //------------------------------------------------------------------------------
    
    typedef long Unicode;
    
    //------------------------------------------------------------------------------
    
    using namespace std;
    
    template<class T> string to_string(const T& t)
    {
      ostringstream os;
      os << t;
      return os.str();
    }
    
    struct Range_error : out_of_range {  // enhanced vector range error reporting
      int index;
      Range_error(int i) :out_of_range("Range error: "+to_string(i)), index(i) { }
    };
    
    
    // trivially range-checked vector (no iterator checking):
    template< class T> struct Vector : public std::vector<T> {
      typedef typename std::vector<T>::size_type size_type;
    
      Vector() { }
      explicit Vector(size_type n) :std::vector<T>(n) {}
      Vector(size_type n, const T& v) :std::vector<T>(n,v) {}
      template <class I>
      Vector(I first, I last) :std::vector<T>(first,last) {}
    
      T& operator[](unsigned int i) // rather than return at(i);
      {
        if (i<0||this->size()<=i) throw Range_error(i);
        return std::vector<T>::operator[](i);
      }
      const T& operator[](unsigned int i) const
      {
        if (i<0||this->size()<=i) throw Range_error(i);
        return std::vector<T>::operator[](i);
      }
    };
    
    // disgusting macro hack to get a range checked vector:
    #define vector Vector
    
    // trivially range-checked string (no iterator checking):
    struct String : std::string {
      
      String() { }
      String(const char* p) :std::string(p) {}
      String(const string& s) :std::string(s) {}
      template<class S> String(S s) :std::string(s) {}
      String(int sz, char val) :std::string(sz,val) {}
      template<class Iter> String(Iter p1, Iter p2) : std::string(p1,p2) { }
    
      char& operator[](unsigned int i) // rather than return at(i);
      {
        if (i<0||size()<=i) throw Range_error(i);
        return std::string::operator[](i);

    LispGovno, 10 Марта 2016

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

    −2

    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
    [HttpPost]
            [Route("api/Pateikimai/SaveList")]
            public OperacijosRezultatas SaveList(List<PateikimasEditItem> models)
            {
                var atsakymas = new OperacijosRezultatas();
                int failCounter = 0;
                foreach (var model in models) {
                    try {
                        PateikimaiBll.SaveOrUpdate(model);
                    }
                    catch (Exception ex) {
                        failCounter++;
                    }
                }
                if (failCounter > 0)
                {
                    atsakymas.SekmingaOperacija = false;
                    atsakymas.PridetiKlaida("Ne visi įrašai buvo išsaugoti");
                }
                else {
                    atsakymas.PridetiSekme("Pateikimų įrašas sėkmingai išsaugotas");
                }
                
    
                return atsakymas;
            }

    Смесь литовского с английским. Try/catch, который не записывает в лог и юзается для того, чтобы в front-end'e не запариватся с масивами (повторяющееся элементы). Уже не говорю об отсутсвии транзакций и foreach'e в контроллере.

    kontora, 02 Марта 2016

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

    −1

    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
    if(Checksquare()){
    if(Checksquare()){
    if(Checksquare()){
    if(Checksquare()){
    if(Checksquare()){
    if(Checksquare()){
    if(Checksquare()){
    if(Checksquare()){
    if(Checksquare()){
    if(Checksquare()){
    if(Checksquare()){
    if(Checksquare()){
    if(Checksquare()){
    if(Checksquare()){
    if(Checksquare()){
    if(Checksquare()){
    if(Checksquare()){
    if(Checksquare()){
    if(Checksquare()){
    if(Checksquare()){
    if(Checksquare()){
    if(Checksquare()){
    if(Checksquare()){
    if(Checksquare()){
    if(Checksquare()){
    if(Checksquare()){
    if(Checksquare()){
    if(Checksquare()){
    if(Checksquare()){
    if(Checksquare()){
    if(Checksquare()){
                  Cut(_point(x, y), true);
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }

    Здесь уместно вспомнить пословицу "Семь раз отмерь,(в данном случае 32 раза) один раз отрежь"

    sliper, 01 Марта 2016

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

    +1

    1. 1
    define('OKVED_TRY_BUILD_CHUNK_IF_IT_NOT_FOUND_IN_CHUNKCACHE', TRUE);

    Написал строчку и думаю - то ли я наговнокодил с названием, то ли соломки подстелил, так, что через месяц я ТОЧНО вспомню, зачем оно нужно...

    Arris, 24 Февраля 2016

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

    0

    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
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    class Program
        {
            static void Main(string[] args)
            {
                Cell[] cells = new Cell[15];
                cells[1] = new Cell(); //и ещё 14 подобных строк
                cells[1].AddAdjacentCell(cells[2], 1);
                cells[1].AddAdjacentCell(cells[5], 2); //и так для всех 15 ячеек
                Spore spore01 = new Spore(true, false, true, true, false, true);
                Spore spore02 = new Spore(true, true, true, true, true, true);
                for(Int16 i = 1; i <= 14; i++)
                    for (Int16 k = 1; k <= 14; k++)
                    {
                        if (i != k)
                        {
                            Console.Write("Trying " + i + " " + k + "... ");
                            cells[i].AddSpore(spore01);
                            cells[k].AddSpore(spore02);
                            bool badAttempt = false;
                            for(Int16 c = 1; c <= 14; c++)
                            {
                                if (cells[c].state == CellState.Empty)
                                {
                                    badAttempt = true;
                                    break;
                                }
                            }
                            Console.WriteLine(badAttempt.ToString());
                        }
                    }
    Console.ReadLine();
            }
        }
        class Cell
        {
            public CellState state;
            private Cell[] adjacentCells = new Cell[6];
            private Spore currentSpore = null;
            public Cell()
            {
                this.state = CellState.Empty;
                for (Int16 i = 0; i <= 5; i++)
                {
                    this.adjacentCells[i] = null;
                }
            }
            public void AddAdjacentCell(Cell cell, Int16 direction)
            {
                if (direction >= 6)
                    return;
    
                this.adjacentCells[direction] = cell;
            }
            public void Ray(Int16 direction)
            {
                if (this.adjacentCells[direction] == null)
                    return;
                if (this.adjacentCells[direction].state == CellState.Spore)
                    return;
                this.state = CellState.Light;
                this.adjacentCells[direction].Ray(direction);
            }
            public void AddSpore(Spore spore)
            {
                this.state = CellState.Spore;
                this.currentSpore = spore;
                for (Int16 i = 0; i <= 5; i++)
                {
                    if (this.currentSpore.directions[i] == true)
                        this.Ray(i);
                }
            }
            public void Reset()
            {
                this.state = CellState.Empty;
                this.currentSpore = null;
                for (Int16 i = 0; i <= 5; i++)
                {
                    this.adjacentCells[i] = null;
                }
            }
        }
        enum CellState
        {
            Empty,
            Light,
            Spore
        }
        class Spore
        {
            public bool[] directions = new bool[6];
            public Spore(params bool[] rays)
            {
                for (Int16 i = 0; i <= 5; i++)
                    this.directions[i] = rays[i];
            }
        }
    }

    (обсуждение программы для поиска решений для одной головоломки под Андроид)
    - Да щас напишем, хуль там делать то?
    (через 5 минут)
    - Ой, переполнение стека...
    - ...

    A1mighty, 11 Февраля 2016

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