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

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

    +154

    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
    <?
    function clearComma($str)
    {
      $str = preg_replace("#(,|\.|-|\/|:|;|\"|'|\?|\(|\)|\\|*)#", '', $str);
      return $str;
    }
    function generate($bold_o, $bold_c)
    {
      $art = file_get_contents('article.txt');
      $voc_str_mass = file('voc.txt');
      $key = file('key.txt');
      foreach ($key as $word)
      {
        $keys[] = trim($word);
      }
      foreach ($voc_str_mass as $voc_str)
      {
        $voc[] = explode("\t", trim($voc_str));
      }
      $words_massive = explode(' ', clearComma($art));
      foreach ($words_massive as $word)
      {
        if (strlen($word) > 3)
        {
          foreach ($voc as $check)
          {
            if (in_array($word, $check) && $word != 'keyword')
            {
              $c = count($check);
              $art = str_replace($word, $check[rand(0, $c - 1)], $art);
            }
          }
        }
      }
      $art_mass = explode(' ', $art);
      foreach ($art_mass as $string)
      {
        $art_out .= str_replace('keyword', $bold_o . $keys[rand(0, count($keys) - 1)] . $bold_c, $string) . ' ';
      }
      return $art_out;
    }
    //echo(generate('<b>', '</b>'));
    //exit();
    $tpl_mass = file("tpl.tpl");
    foreach ($tpl_mass as $tpl_string)
    {
      $template .= str_replace('{GENERATE}', generate('<b>', '</b>'), $tpl_string);
    }
    //$date = date(d).'-'.date(m).'-'.date(Y).'_'.date(H).'-'.date(i).'-'.date(s);
    $handle = fopen($date . '_generated.html', "w");
    fwrite($handle, $template);
    fclose($handle);
    ?>

    ну тут тока матом если...

    пгуые, 20 Августа 2009

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

    +170.5

    1. 1
    2. 2
    $menu=new menu;
    $menu->menu=$menu->menu($menu_arr); // Меню

    Человек знал толк в ООП

    alesha, 19 Августа 2009

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

    +27

    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
    template<class T>
    class TAbstractObject
    {
    private:
    	T Value;
    public:
    	bool operator==(TAbstractObject& Obj);
    };
    
    ...
    
    template<class T>
    bool TAbstractObject<T>::operator==(TAbstractObject<T>& Obj)
    {
    	...
    	Value++;
    	...
    };

    Код в мешке...

    Говногость, 19 Августа 2009

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

    +32.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
    class TString
    {
    public:
    	...
    	char len;
    };
    ...
    int GetWidth(TString& str)
    {
    	if(&str==NULL)
    		return 0;
    	return str.len;
    };

    Мрахахаха(фр)хахаха.

    Говногость, 19 Августа 2009

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

    +164.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
    /**
    function.php
    */
    function result($selected, $sources, $date_from, $date_till, $step)
    {
      $ret = $header = array();
      if (is_array($selected) and count($selected))
      {
        foreach ($selected as $item=>$value)
        {
          if ('on' == $value)
          {
            $header[$item] = $sources[$item]['name'];
            if (isset($sources[$item]['db_host']))
            {
              // external db
              class DB_EXT extends DB
              {
    .......

    объявление класса внутри цикла внутри функции!!
    рыдааййууу

    shitcoder, 18 Августа 2009

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

    +147.8

    1. 1
    2. 2
    3. 3
    4. 4
    if ($i++%2==0)
            $bgc='#eeeeee';
        else
            $bgc='#cccccc';

    Самое интересное, что инкремент производится после прохождения проверки

    p0dl0m, 17 Августа 2009

    Комментарии (7)
  8. Ruby / Говнокод #1603

    −145.5

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    # I really hate Western week system (0 - sunday, 6 - saturday),
          # maybe it is better, but this crap is incompatible with
          # Russian week system (0 - monday, 6 - sunday)
          wday = date.wday - 1
          wday = 6 if wday == -1

    Кусок кода из реализации расписания с календарём в текущем проекте.

    Только что оказалось, что для этого как раз есть метод Date#cwday :)

    eveel, 17 Августа 2009

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

    −132.6

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    public function showNotAvailableAlert(str:String):void
    {
    	var defString:String = str = "Connection with server is lost. Unfortunately you can not continue now. Please try later.";
    	if(str)
    	{
    		Alert.show(str, "Not connected to server");
    	}
    	else
    	{
    		Alert.show(defString, "Not connected to server");
    	}
    }

    Kuros, 13 Августа 2009

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

    +151.9

    1. 1
    $table_name = "$pub_code"."_"."$lg_code";

    funny-chipmunk, 12 Августа 2009

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

    +17

    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
    std::string sError = "";
    try
    {
       fIn = fopen(cszFileName, "rb");
       if (fIn == 0)
       {
         sError = "Can not open file: ";
         sError += cszFileName;
         throw std::string("");
       }
    
       if (!ParseFile(fIn, pLookup))
       {
         sError = "Bad file format. File: ";
         sError += cszFileName;
         throw std::string("");
       }
    
       sError = "";
       throw std::string("");
    }
    catch (std::string& e)
    {
       if (fIn != 0)
       {
          fclose(fIn);
          fIn = NULL;
       }
       if (sError.length() != 0)
       {
          throw std::exception(sError.c_str());
       }
    }

    Там же нашел еще более шикарное продолжение гавнокода http://govnokod.ru/1459

    lugal, 12 Августа 2009

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