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

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

    +147

    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
    void
    syslog(int pri, const char *fmt, ...)
    {
    	va_list ap;
    
    	va_start(ap, fmt);
    	vsyslog(pri, fmt, ap);
    	va_end(ap);
    }
    ......................................
    void
    vsyslog(int pri, const char *fmt, va_list ap)
    {
    	vsyslog_r(pri, &sdata, fmt, ap);
    }
    ....................................
    void
    vsyslog_r(int pri, struct syslog_data *data, const char *fmt, va_list ap)
    {
    	int cnt;
    	char ch, *p, *t;
    	time_t now;
    	int fd, saved_errno, error;
    #define	TBUF_LEN	2048
    #define	FMT_LEN		1024
    	char *stdp = NULL, tbuf[TBUF_LEN], fmt_cpy[FMT_LEN];
    	int tbuf_left, fmt_left, prlen;
    
    #define	INTERNALLOG	LOG_ERR|LOG_CONS|LOG_PERROR|LOG_PID
    	/* Check for invalid bits. */
    	if (pri & ~(LOG_PRIMASK|LOG_FACMASK)) {
    		if (data == &sdata) {
    			syslog(INTERNALLOG,
    			    "syslog: unknown facility/priority: %x", pri);
    		} else {
    			syslog_r(INTERNALLOG, data,
    			    "syslog_r: unknown facility/priority: %x", pri);
    		}
    		pri &= LOG_PRIMASK|LOG_FACMASK;
    	}
    .......................
    }
    ......................

    Из исходников Bioninc - Android libc.
    В реализации сислога, в случае ошибки, вызывается syslog

    elenbert, 14 Апреля 2011

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

    +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
    <?
    $url = file_get_contents("url страницы");
    $js = "<script";
    $endjs = "</script>";
    $test = 0;
    $i = 1;
     
    while($test == 0)
    {
      $q = strpos($url, $js);
      $q++;
      $y = strpos($url,$endjs);
      $y++;
      $url = substr($url, $q, $y);
      if($url == false)
      {
      $test = 1;
      }else{
      $i++;
      }
     }
     
    echo"<br>Удалено скриптов: " .$i. "<br>";
    $url = htmlspecialchars("$url", ENT_QUOTES);
    echo $url;
    ?>

    программа удаляющую полностью все javascript

    BlackMonolit, 13 Апреля 2011

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

    +165

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    function writeln($str) {
        echo $str."\n";
    }
    
    function readln() {
        $handle = fopen ("php://stdin","r");
        $line = fgets($handle);
        fclose($handle);
        return $line;
    }

    Функции для реализации ввода и вывода PHP-CGI в режиме консоли

    Мартин, 12 Апреля 2011

    Комментарии (5)
  5. Python / Говнокод #6321

    −181

    1. 1
    2. 2
    3. 3
    4. 4
    if str(type(code_text)) == "<type 'str'>":
        code = self.errors[code_text]
    else:
        code = code_text

    Случайно найдено на просторах гуглокода

    winter, 12 Апреля 2011

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

    −130

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

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

    AliceGoth, 12 Апреля 2011

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

    +137

    1. 1
    <a id="top_home_link" class="top_home_link fl_l" href="/" onclick="return nav.go(this, event)" class="fl_l" style=""></a>

    Duplicate attribute class.
    Простите за контактик, не удержался.

    nsauk, 10 Апреля 2011

    Комментарии (5)
  8. 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)
  9. 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)
  10. 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)
  11. Pascal / Говнокод #6278

    +146

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

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

    megaruliz, 07 Апреля 2011

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