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

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

    +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
    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
    if (isset($_GET['page'])) {
    	include "pages/index.php";
    }
    if (isset($_GET['accounts'])) {
    	include "pages/allacc.php";
    }
    if (isset($_GET['gold'])) {
    	include "pages/gold.php";
    }
    if (isset($_GET['send'])) {
    	include "pages/send.php";
    }
    if (isset($_GET['gm'])) {
    	include "pages/gm.php";
    }
    if (isset($_GET['ban'])) {
    	include "pages/ban.php";
    }
    if (isset($_GET['chat'])) {
    	include "pages/chat.php";
    }
    if (isset($_GET['tw'])) {
    	include "pages/tw.php";
    }
    if (isset($_GET['server'])) {
    	include "pages/server.php";
    }
    if (isset($_GET['logs'])) {
    	include "pages/logs.php";
    }
    if (isset($_GET['live_chat'])) {
    	include "pages/live_chat.php";
    }
    if (isset($_GET['chars'])) {
    	include "pages/chars.php";
    }
    
    
    //Functions
    if (isset($_GET['Acc_Change'])) {
    	
    	if (isset($_POST['SaveChange'])) {
    		$iwp->SaveUserToMysql(strtolower($_POST['name']), strtolower($_POST['pass']), strtolower($_POST['email']), $_POST['PassType']);
    	}
    	if (isset($_POST['DeleteAcc'])) {
    		echo "<script>alert('Вы точно хотите удалить этот аккаунт?');location.href='index.php?Acc_Change&DeleteYes=$_POST[AccID]';</script>";
    	}
    	if (isset($_GET['DeleteYes'])) {
    		mysql_query("DELETE FROM users WHERE ID=$_GET[DeleteYes]");
    		echo "<script>alert('Аккаунт успешно удален');location.href='index.php?accounts';</script>";
    	}
    	include "pages/acc_change.php";
    }
    
    if (isset($_GET['Give_Gold'])) {
    	if(isset($_POST['GiveGold'])) {
    		$iwp->GiveGold($_POST['GoldID'], $_POST['GoldNum'], "user");
    	}
    	if(isset($_POST['GoldWhoOnline'])) {
    		$iwp->GiveGold(null, $_POST['AllGold'], "online");
    	}
    	if(isset($_POST['GoldAll'])) {
    		$iwp->GiveGold(null, $_POST['AllGolds'], "all");
    	}
    }

    http://kn1fe-zone.ru/index.php?threads/iwp-veb-panel-upravlenija-serverom.10/#post-1554
    Автор называет это ООП.
    Полный архив — https://www.dropbox.com/s/gpdge94t0jv9hl9/IWP%2806.08.2014%29pre.rar?dl=0
    Можно просматривать для успокоения души своей перед сном.

    DesmondHume, 07 Ноября 2014

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

    +154

    1. 1
    2. 2
    3. 3
    4. 4
    $this->template_model = BaseCommunicationType::model()->findByAttributes(array('template' => $this->template));
    if(!$this->template_model === NULL) {
    		throw new Exception("Template name is wrong", 1);	
    }

    Угадайте, что будет из исключением?

    boddicheg, 06 Ноября 2014

    Комментарии (10)
  4. Си / Говнокод #17061

    +135

    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
    void *list_find_data(struct node *llist, void *data, int (*cmp_func)(void *, void *))
    {
    	struct node* it_node = NULL;
    
    	if (NULL != cmp_func)
    	{
    		for(it_node = llist; (NULL != it_node); it_node = it_node->next)
    	    {
                if (NULL != it_node->data)
                {
                    if (0 == cmp_func(data, it_node->data))
                    {
                        break;
                    }
                }
            }
    	}
    	return ((NULL != it_node) && (NULL != it_node->data)) ? it_node->data : NULL;
    }

    Велосипедисты жгут. О glibопараше не наслышаны.

    codemonkey, 04 Ноября 2014

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

    +158

    1. 1
    2. 2
    3. 3
    4. 4
    for($i = 0; $i < $db->max; $i++) {
    	if($i==1) continue;
    	.....
    }

    Почему бы и нет

    UncaughtException, 28 Октября 2014

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

    +52

    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
    #include <iostream>
    using namespace std;
    
    void foo()
    {
        int i = 0xffffffff;
        cout << i << endl;
    }
    
    void bar()
    {
        bool b;
    	if(b)
    	{
    		cout << "true" << endl;
    	}
    	if(!b)
    	{
    		cout << "false" << endl;
    	}
    }
    
    int main()
    {
        foo();
        bar();
    	return 0;
    }

    http://rextester.com/HJRO12041

    DlangGovno, 26 Октября 2014

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

    −133

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    Public m_Values As Hashtable    
    
    Public Function GetSensorType(p_SensorType As SensorType) As SensorValue
            For Each de As DictionaryEntry In m_Values
                If CType(de.Key, SensorType) = p_SensorType Then
                    Return de.Value
                End If
            Next
            Return Nothing
     End Function

    Отличный пример работы с Hashtable!

    IlyaS, 24 Октября 2014

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

    +142

    1. 1
    2. 2
    3. 3
    // string errorMessage;
    if (result == false)
       result = true; //because model is not changed

    because

    sharpman, 24 Октября 2014

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

    +53

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    /* set _god=true temporarily, safely */
    class GodScope {
        bool _prev;
    public:
        GodScope();
        ~GodScope();
    };

    mongo/db/client.h
    Почувствуй простор божий

    roman-kashitsyn, 23 Октября 2014

    Комментарии (10)
  10. Pascal / Говнокод #16846

    +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
    program lab2;
    
     const n = 5;
     var i:integer;
     var A, x1, dx:single;
     var arrayX : array[1..n] of single;
     var arrayY : array[1..n] of single;
    
    begin
      readln(A);
      x1:= -1 * 2.2 * A;
      dx:= A/5;
      arrayX[1]:= x1;
      for i:=2 to n do
       arrayX[i]:= arrayX[i - 1] + dx;
      for i:=1 to n do
      begin
       if (arrayX[i] < 0) then
        arrayY[i]:= -1 * sqrt(sqrt(16 * sqr(sqr(A)) + 4 * sqr(A) * sqr(arrayX[i] + A)) - sqr(arrayX[i] + A) - sqr(A))
       else
        arrayY[i]:= sqrt(sqr(A) - sqr(arrayX[i] + A)) - 2 * A;
       writeln(arrayX[i], ' ; ', arrayY[i]);
      end;
      readln;
    end.

    govno, govno, govnyanoe

    GOVNOgovnyanoe, 13 Октября 2014

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

    +119

    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
    static void writeInternal(byte type, Object object, ObjectOutput out) throws IOException {
        out.writeByte(type);
        switch (type) {
            case DURATION_TYPE:
                ((Duration) object).writeExternal(out);
                break;
            case INSTANT_TYPE:
                ((Instant) object).writeExternal(out);
                break;
            ...
            <snip>
            ...
            case PERIOD_TYPE:
                ((Period) object).writeExternal(out);
                break;
            default:
                throw new InvalidClassException("Unknown serialized type");
        }
    }

    JDK 8. java.time.Ser.

    Вот что происходит, когда в языке есть только public-наследование. Без рефлексии короче написать нельзя.

    someone, 12 Октября 2014

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