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

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

    +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
    f (isset(self::$_namespaceLocks[$this->_namespace])) {
                /*
                  @see Zend_Session_Exception
                 /
                require_once 'Zend/Session/Exception.php';
                throw new Zend_Session_Exception('This session/namespace has been marked as read-only.');
            }
    
            if ($name === '') {
                /*
                 * @see Zend_Session_Exception
                 /
                require_once 'Zend/Session/Exception.php';
                throw new Zend_Session_Exception("The '$name' key must be a non-empty string");
            }
    
            if (parent::$_writable === false) {
                /*
                 * @see Zend_Session_Exception
                 */
                require_once 'Zend/Session/Exception.php';
                throw new Zend_Session_Exception(parent::_THROW_NOT_WRITABLE_MSG);
            }

    asfalanaft, 15 Ноября 2011

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

    +153

    1. 1
    2. 2
    3. 3
    w = 640;
    h = 480;
    w+=2; h+=2;

    Tairesh, 09 Ноября 2011

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

    +167

    1. 1
    2. 2
    3. 3
    $query1234 = "select ....";
    $result1234 = mysql_query($query1234);
    $rs1234 = mysql_fetch_assoc($result1234);

    Это до такой степени не было фантазии придумать осмысленное название переменным. И бедные боялись, что перепишет где-то другие $query, $result, $rs. Не говоря уже о том, что никакой модели, сплошные фетчи, вместо того, чтобы вытянуть всё сразу

    Sash, 03 Ноября 2011

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

    +167

    1. 1
    2. 2
    3. 3
    >govnokod.ru - По колено в говнокоде
    Предлагаю переименовать в
    >govnokod.ru - Поколение говнокодеров

    alexoy, 30 Октября 2011

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

    +1009

    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
    #pragma once
    
    #include <vector>
    #include <algorithm>
    #include <exception>
    
    using namespace std;
    
    template<typename nodeT>
    class Tree
    {
    	Tree* root;
    	Tree(Tree* _root, nodeT value)
    		: root(_root)
    		, Node(value)
    	{
    	}
    	vector<Tree> children;
    public:
    	nodeT Node;
    	Tree(void) : root(nullptr) { }
    	Tree(const Tree& value)
    		: children(value.children)
    		, Node(value.Node)
    		, root(value.root)
    	{
    	}
    	virtual ~Tree(void) { }
    	const Tree& operator=(const Tree& value)
    	{
    		if(&value != this)
    		{
    			children = value.children;
    			for_each(children.begin(), children.end(), [this](Tree& tree)
    			{
    				tree.root = this;
    			});
    			Node = value.Node;
    			root = value.root;
    		}
    		return *this;
    	}
    	Tree& Root()
    	{
    		if(root == nullptr)
    		{
    			throw exception("already root");
    		}
    		return *root;
    	}
    	bool IsRoot() const
    	{
    		return root == nullptr;
    	}
    	Tree* Push(nodeT node)
    	{
    		children.push_back(Tree(this, node));
    		return &children.back();
    	}
    	Tree& operator[](typename vector<Tree>::size_type index)
    	{
    		return children[index];
    	}
    	vector<Tree*> Children()
    	{
    		vector<Tree*> result;
    		for(vector<Tree>::iterator i = children.begin(); i!=children.end(); i++)
    		{
    			result.push_back(&(*i));
    		}
    		return result;
    	}
    	typename vector<Tree>::iterator begin()
    	{
    		return children.begin();
    	}
    	typename vector<Tree>::iterator end()
    	{
    		return children.end();
    	}
    };

    Шаблон из http://govnokod.ru/6415.

    Xom94ok, 29 Октября 2011

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

    +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
    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
    char *zamena(int m)
     {
       char *s;
       int a,b,c;
       a = m / 100;
       b=(m / 10)% 10;
       c=m % 10;
       if (a>0)
       switch (a)   
       {
        case 1: s=s+"сто ";
        case 2: s=s+"двести ";
        case 3: s=s+"триста ";
        case 4: s=s+"четыреста ";
        case 5: s=s+"пятьсот ";
        case 6: s=s+"шестьсот ";
        case 7: s=s+"семьсот ";
        case 8: s=s+"восемьсот ";
        case 9: s=s+"девятьсот ";
       }
       if (b==1) 
        switch (c)
       {
        case 1: s=s+"одиннадцать ";
        case 2: s=s+"двенадцать ";
        case 3: s=s+"тринадцать ";
        case 4: s=s+"четырнадцать ";
        case 5: s=s+"пятнадцать ";
        case 6: s=s+"шестнадцать ";
        case 7: s=s+"семнадцать ";
        case 8: s=s+"восемнадцать ";
        case 9: s=s+"девятнадцать ";
       }
       else
        switch (b)
       {
        case 2: s=s+"двадцать ";
        case 3: s=s+"тридцать ";
        case 4: s=s+"сорок ";
        case 5: s=s+"пятьдесят ";
        case 6: s=s+"шестьдесят ";
        case 7: s=s+"семьдесят ";
        case 8: s=s+"восемьдесят ";
        case 9: s=s+"девяносто ";
       }
       if (b!=1 && c>0) 
        switch (c)
       {
        case 1: s=s+"один ";
        case 2: s=s+"два ";
        case 3: s=s+"три ";
        case 4: s=s+"четыре ";
        case 5: s=s+"пять ";
        case 6: s=s+"шесть ";
        case 7: s=s+"семь ";
        case 8: s=s+"восемь ";
        case 9: s=s+"девять ";
       }
       return s;
     }

    Перевод целого числа в строку.

    Proger, 22 Октября 2011

    Комментарии (11)
  8. Java / Говнокод #8238

    +82

    1. 1
    2. 2
    3. 3
    if (getAgentAgrees() && (firstOrdered || secondOrdered) && !(getDisclaimer().getDisplayed())) {
        getDisclaimer().setDisplayed(false);
    }

    Минут пять вникал в условия, в итоге выяснил, что код только тратит время (моё и процессора).

    roman-kashitsyn, 19 Октября 2011

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

    +149

    1. 1
    2. 2
    3. 3
    4. 4
    ...
    $access = array();  
    $access = file("access.php");  
    ...

    http://forum.php.su/topic.php?forum=33&topic=732

    x34e, 18 Октября 2011

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

    +161

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    <?php
    class Plugins_Comments implements Plugins_interface{
       function Run(){
    	  $args=func_get_args();
    
          return Formcacher::ProccessByAllRequest(APP_PluginBOX::tplOnce("comments",array("comments_list"=>APP_Models_Comments::GetCommentsTree($args[0]['post_id']),"post_id"=>$args[0]['post_id'],"com_name"=>htmlspecialchars($_COOKIE['com_name'],ENT_QUOTES))),FormCacher::LoadVars());
       }
    }
    ?>

    Не то чтобы говнокод, скорее бугога-код...

    Zho, 12 Октября 2011

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

    +166

    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
    void sort(student x[], perech *&py)
         { int l;
           perech t;
           //perech *y;
           py=new perech[n];
           l=1; k=0;
           for(i=0; i<n; i++)
    	  { fl=0;
    	    for(j=0; j<l; j++)
    	       { if((strcmp(x[i].fam,py[j].fam)==0)&&((strcmp(x[i].im,py[j].im)!=0)||(strcmp(x[i].gr,py[j].gr)!=0)))
    		   { fl=1;
    	    py[j].ng++; break;
    		   }
    		 if(fl==0) { strcmp(py[l-1].fam,x[i].fam);
    			     py[l].ng=1; l++;
    			   }
    	       }
    	  }
           for(i=0; i<(l-1); i++)
    	  for(j=i+1; j<l; j++)
    	     if(py[i].ng<py[j].ng)
    	       { t=py[i];
    		 py[i]=py[j];
    		 py[j]=py[i];
    	       }
           for(i=1; i<l; i++)
    	  if(py[0].ng=py[i].ng)
    	    k++;
           k++;
           py=new perech[k];
           if(py==NULL) {
    		      cout<<"Net pamyati"; getch();
    		      k=0; delete []py; return;
    		    }
           for(i=0; i<l; i++)
    	  py[i]=py[i];
           delete []py;
           cout<<"Perechen' sformirovan:\n";
           getch();
           for(i=0; i<l; i++)
    	  cout<<py[i].fam<<" "<<py[i].ng<<endl;
           getch();
         }
    void outputFileStudent(perech x[])
         { int l;
           ofstream fout;
           char file[L];
           cout<<"Vvedite imya faila:\n"; cin>>file;
           fout.open(file);
           if(fout.fail()) { cout<<"Error... Press any key for exit";
    			 getch(); return;
    		       }
           for(i=0; i<l; i++)
    	  fout<<x[i].fam<<" "<<x[i].ng<<endl;
           cout<<"File save\n";
           getch();
         }
    void outputFileStudentBin(perech y[])
         { ofstream fout;
           char file[L];
           cout<<"Vvedite imya save fila:\n"; cin>>file;
           fout.open(file, ios::binary);
           if(fout.fail()) { cout<<file<<"ne sozdan\n"; getch(); return; }
           fout.write((char *) y, k*sizeof(perech()));
           if(fout.fail()) { cout<<"Oshibka zapisi\n"; getch(); return; }
           cout<<"Perechen save\n";
           getch();
           fout.close();
         }
    void inputFileStudentBin(perech *&px)
         { ifstream fin;
           char file[20];
           int l;
           perech t;
           cout<<"Vvedite imya save faila:\n"; cin>>file;
           fin.open(file);
           if(fin.fail()) { cout<<"Error\n"; getch(); return();}
           for(i=0; i<l; i++)
    	   fin>>t.fam>>t.ng;
           fin.close();
    
           if(px!=NULL) delete []px;
           fin.open(file);
           if(fin.fail()) { cout<<"Povtornaya oshibka\n"; getch();
    			delete []px; k=0; return; }
           for(i=0; i<k; i++)
    	  fin>>px[i].fam>>px[i].ng;
           cout<<"file vveden\n"; getch();
           for(i=0; i<l; i++)
    	  cout<<px[i].fam<<" "<<px[i].ng<<endl;
           getch();
           fin.close();
         }

    Новый стажер решил задачу про студентов, вызывая их в компилированном виде из модуля 1С.
    Не знал в какой раздел запостить, поэтому пощу в 1С
    Вообще-то в 1С своя база.

    alexoy, 10 Октября 2011

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