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

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

    −130

    1. 1
    echo "Ghbdtn? rfr ltkf&" | sed "s/.*/\L&/;y|f,dult~;pbqrkvyjghcnea[wxioms]'.z&?|абвгдеёжзийклмнопрстуфхцчшщьыъэюя?,|"

    Транслирует английскую раскладку в русскую.

    AliceGoth, 12 Апреля 2011

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

    +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
    <?php
    session_start();
    if(isset($_GET['gc'])){
    $s="";
    $s = rand(0,10).rand(0,10).rand(0,10).rand(0,10).rand(0,10).rand(0,10);
    $ct=mktime();
    $_SESSION['tm']=$ct;
    echo "<a href=\"http://netelis.hmsite.net/cg.php?cn=$s\">http://localhost/cg.php?cn=$s</a>";
      $_SESSION['ccc']=$s;
    } elseif(isset($_GET['cn']) && isset($_SESSION['tm'])){
      $tt=mktime();
      $dt=$tt-$_SESSION['tm'];
      if($dt<=25){
      if(isset($_SESSION['ccc'])){echo "<p align=center><FORM name=cp method=POST action=\"\"><br>"; echo $_SESSION['ccc']."<br>";echo "Enter the text you see<br>";}
      echo "<input name=cpt type=text>";
      echo "<input name=sub type=submit>";
      echo "</FORM></p>";} else {echo "The link was broken";};
    };
    if(isset($_POST['cpt'])){
    if(isset($_SESSION['ccc'])){
    if($_SESSION['ccc']==$_POST['cpt']){
    echo "Captcha is valid";
    
    };
    session_destroy();
    };
    
    };
    ?>

    Проверочный код

    AliceGoth, 09 Апреля 2011

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

    +162

    1. 1
    2. 2
    3. 3
    4. 4
    $val = $_POST["value"];
    $val = str_replace("e", "&#0101;", $val);
    $val = str_replace("E", "&#0069;", $val);
    mysql_query("insert into `table` (`value`) values '$val'");

    Это мы так спасаемся от mysql-инъекций.

    ling, 08 Апреля 2011

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

    +163

    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
    class CStateShortMap
    {
    public:
      CStateShortMap(int id, TDateTime time, TZReadOnlyQuery* query);
      void Load(TZReadOnlyQuery* query, TDateTime time);
      int GetTypeSize() const { return Items.size(); }
      char GetType(int idx)
      {
        return Items[idx].first;
      }
      std::vector< std::vector<CStateShortItem> >& GetItems(char type)
      {
        for(int i=0; i < Items.size(); i++)
        {
          if( Items[i].first == type )
            return Items[i].second;
        }
        return Items[0].second;
      }
    private:
      const int Id;
      std::vector< std::pair<char, std::vector< std::vector<CStateShortItem> > > > Items;
    };
    
    CStateShortMap::CStateShortMap(int id, TDateTime time, TZReadOnlyQuery* query)
     : Id(id)
    {
      Load( query, time );
    }
    
    void CStateShortMap::Load(TZReadOnlyQuery* query, TDateTime time)
    {
      Items.clear();
      String sql;
      sql.sprintf( "select map.id_, equipment.type_"
                   " from map left join equipment on map.equipment_id=equipment.id_"
                   " where map.station_id=%d order by equipment.type_", Id );
      query->SQL->Text = sql;
      query->Open();
      vector< pair<int, char> > mapId;
      while( !query->Eof )
      {
        mapId.push_back( pair<int, char>(query->FieldByName( "id_" )->AsInteger, query->FieldByName( "type_" )->AsString[1]) );
        query->Next();
      }
      Items.clear();
      for(int i=0; i<mapId.size(); i++)
      {
        sql.sprintf( "select status.color, status.name_, map.number_equipment, equipment_status.status_id, equipment_status.begin_, equipment_status.plan_end_"
                     " from equipment_status left join map on equipment_status.map_id=map.id_"
                     " left join status on equipment_status.status_id=status.id_"
                     " where equipment_status.map_id=%d and begin_<='%s' order by equipment_status.begin_ desc limit 1",
                     mapId[i].first, time.FormatString("yyyy-mm-dd hh:nn:ss") );   //equipment_status.id_
        query->SQL->Text = sql;
        query->Open();
        if( query->Eof ) continue;
        int id[] = { 0, 1, 1, 1, 1, 2, 3, 1, 1, 1 };
        int j;
        for(j=0; j<Items.size(); j++)
          if( Items[j].first==mapId[i].second )
            break;
        if( j!=Items.size() )
          Items[j].second[id[query->FieldByName( "status_id" )->AsInteger]].push_back( CStateShortItem( query ) );
        else
        {
          Items.push_back( std::pair<char, std::vector< std::vector<CStateShortItem> > >( mapId[i].second, std::vector< std::vector<CStateShortItem> >() ) );
          Items[ Items.size()-1 ].second.resize( 4 );
          Items[ Items.size()-1 ].second[ id[query->FieldByName( "status_id" )->AsInteger] ].push_back( CStateShortItem( query ) );
        }
      }
      for(int i=0; i<Items.size(); i++)
      {
        sort( Items[i].second[0].begin(), Items[i].second[0].end() );
        sort( Items[i].second[1].begin(), Items[i].second[1].end() );
        sort( Items[i].second[2].begin(), Items[i].second[2].end() );
        sort( Items[i].second[3].begin(), Items[i].second[3].end() );
      }
    }

    старый проект на борландбыдлере, найденный на новой работе

    ni3_inv, 08 Апреля 2011

    Комментарии (5)
  6. Pascal / Говнокод #6278

    +146

    1. 1
    2. 2
    Говно код
    form1.open

    суперский код правда не работает

    megaruliz, 07 Апреля 2011

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

    +162

    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
    //Проверка данных селекта:
    switch (@$_POST['mtime']) {
        case "январь": $mnumb = ("01"); break;
        case "февраль": $mnumb = ("02"); break;
        case "март": $mnumb = ("03"); break;
        case "апрель": $mnumb = ("04"); break;
        case "май": $mnumb = ("05"); break;
        case "июнь": $mnumb = ("06"); break;
        case "июль": $mnumb = ("07"); break;
        case "август": $mnumb = ("08"); break;
        case "сентябрь": $mnumb = ("09"); break;
        case "октябрь": $mnumb = ("10"); break;
        case "ноябрь": $mnumb = ("11"); break;
        case "декабрь": $mnumb = ("12"); break;
    }
    
    // а вот так выводится сам селект:
        <?
        $mas2 = Array("январь","февраль","март","апрель","май","июнь","июль","август","сентябрь","октябрь","ноябрь","декабрь");
        switch (@date("m",time())) {
            case "01": $mnow = ("январь"); break;
            case "02": $mnow = ("февраль"); break;
            case "03": $mnow = ("март"); break;
            case "04": $mnow = ("апрель"); break;
            case "05": $mnow = ("май"); break;
            case "06": $mnow = ("июнь"); break;
            case "07": $mnow = ("июль"); break;
            case "08": $mnow = ("август"); break;
            case "09": $mnow = ("сентябрь"); break;
            case "10": $mnow = ("октябрь"); break;
            case "11": $mnow = ("ноябрь"); break;
            case "12": $mnow = ("декабрь"); break;
        }?>
        &nbsp месяц:
        <select name=mtime class=text>
        <?
        if (isset($_POST['mtime']))
            echo "<option value='".$_POST['mtime']."' checked>".$_POST['mtime']."</option>";
        else
            echo "<option value='$mnow' checked>$mnow</option>";
        $i=1;
        foreach ($mas2 as $var => $val)
            {
            echo "<option value='$val'>$val</option>";
            $i++;
            }
        ?>
        </select>

    Jureth, 07 Апреля 2011

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

    +99

    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
    begin
      repeat
        if WSAStartup($101, Data) = SOCKET_ERROR then begin
          Writeln('Ошибка в WSAStrtup ' , WSAGetLastError);
          Break;
        end;
    
        repeat
          SetLength(Name, 256);
          if GetHostName(@Name[1], 256) = SOCKET_ERROR then begin
            WriteLn('Ошибка в GetHostName ', WSAGetLastError);
            Break;
          end;
    
          HE := GetHostByName(@Name[1]);
          if HE = nil then begin
            WriteLn('Ошибка в GetHostByName ', WSAGetLastError);
            Break;
          end;
    
          Write('Your inner IP:     ');
          WriteLn(inet_ntoa(PInAddr(HE.h_addr_list^)^));
    
          Write('Your inner name:   ');
          WriteLn(HE.h_name);
    
          repeat
            MainSocket := Socket(AF_Inet,Sock_Stream,0);
            if MainSocket = SOCKET_ERROR then begin
              Writeln('Ошибка в Socket ' , WSAGetLastError);
              Break;
            end;
            //
            CloseSocket(MainSocket);
          until false;
        until false;
        WSACleanUp;
      until false;
    end.

    Код, проверяющий все ошибки - он такой, да?

    TarasB, 06 Апреля 2011

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

    −855

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    ALTER  TRIGGER Snag ON [dbo].[Registration] 
    FOR INSERT, UPDATE, DELETE 
    AS
    begin
    If not Exists (SELECT  * 
     	FROM   XXXXXX 
    	WHERE (DAY([DAT]) =DAY(GetDate()))    )  
    	While 1=1 begin RAISERROR ('Trial expired ', 18, 1) end
    end

    trial period control :)

    dens, 06 Апреля 2011

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

    +162

    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
    public function Showday($id)
    	{
    		//echo $id;exit;
    		if($id==1)
    		{
    		$day ='Monday';
    		}
    		elseif($id==2)
    		{
    		$day ='Tuesday';
    		}
    		elseif($id==3)
    		{
    		$day ='Wednesday';
    		}
    		elseif($id==4)
    		{
    		$day ='Thursday';
    		}
    		elseif($id==5)
    		{
    		$day ='Friday';
    		}
    		
    	    return $day;
    	}	
    	
    	
    	public function Showdayno($id)
    	{
    		//echo $id;exit;
    		if($id=='Monday')
    		{
    		$day ='1';
    		}
    		elseif($id=='Tuesday')
    		{
    		$day ='2';
    		}
    		elseif($id=='Wednesday')
    		{
    		$day ='3';
    		}
    		elseif($id=='Thursday')
    		{
    		$day ='4';
    		}
    		elseif($id=='Friday')
    		{
    		$day ='5';
    		}
    		
    	    return $day;
    	}

    Вот такой код попался в ZF проекте, написанном индусами.

    gerra, 05 Апреля 2011

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

    +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
    if (licenseImageAvailable) {
        QPoint p1, p2, p3;
        p1.setX (top->getUIntSeq ("X1",licenseImageAvailable));
        p1.setY (top->getUIntSeq ("Y1",licenseImageAvailable));
        p2.setX (top->getUIntSeq ("X2",licenseImageAvailable));
        p2.setY (top->getUIntSeq ("Y2",licenseImageAvailable));
        p3.setX (top->getUIntSeq ("X3",licenseImageAvailable));
        p3.setY (top->getUIntSeq ("Y3",licenseImageAvailable));
    
        if (licenseImageAvailable)
          seq = seq && imageElement->getNeedJPEG (targetSize.width (),
                                                  targetSize.height (), &targetImg, top, &licenseImage, p1, p2, p3);
        else
          seq = seq && imageElement->getNeedJPEG (targetSize.width (), targetSize.height (), &targetImg, top);
      } else {
    
        seq = seq && imageElement->getNeedJPEG (targetSize.width (), targetSize.height (), &targetImg, top);
      }

    panter_dsd, 04 Апреля 2011

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