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

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

    +29.3

    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
    for ($i=0; $i < $this->acl_count; $i++)
    		{
    			$acl =& $this->acl[$i];
    			if (strcasecmp( $aco_section_value, $acl[0] ) == 0) {
    				if (strcasecmp( $aco_value, $acl[1] ) == 0) {
    					if (strcasecmp( $aro_section_value, $acl[2] ) == 0) {
    						if (strcasecmp( $aro_value, $acl[3] ) == 0) {
    							if ($axo_section_value && $acl[4]) {
    								if (strcasecmp( $axo_section_value, $acl[4] ) == 0) {
    									if (strcasecmp( $axo_value, $acl[5] ) == 0) {
    										$acl_result = @$acl[6] ? $acl[6] : 1;
    										break;
    									}
    								}
    							} else {
    								$acl_result = @$acl[6] ? $acl[6] : 1;
    								break;
    							}
    						}
    					}
    				}
    			}
    		}

    из ядра Joomla

    guest, 16 Декабря 2008

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

    +28.9

    1. 1
    $revutxt = ($result_good['description']!='') ? $result_good['description'] : '';

    вот где безопасность! вот где проверка верных значений переменных!)

    guest, 15 Декабря 2008

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

    +42.9

    1. 1
    extract($GLOBALS);

    Анекдот в одну строчку

    guest, 14 Декабря 2008

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

    +6.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
    20. 20
    21. 21
    22. 22
    23. 23
    do {
    XLoop: 
        XNextEvent(dpy,&event);
        switch(event.type) {
          case ResizeRequest:
            if (event.xresizerequest.window!=win_main)
              goto XLoop;
    resize_main:
            xswa.event_mask&= ~ResizeRedirectMask;
            XChangeWindowAttributes(dpy,win_main,CWEventMask, &xswa);
            XSync(dpy,0); /* very important, otherwise we loop endlessly ! */
            XResizeWindow(dpy, win_main,event.xresizerequest.width,event.xresizerequest.height);
            XSync(dpy,0); /* very important, otherwise we loop endlessly ! */
            xswa.event_mask|= ResizeRedirectMask;
            XChangeWindowAttributes(dpy,win_main,CWEventMask, &xswa);
            resize=1;
            XSync(dpy,0); /* another one, just in case... */
            goto redisplay;
    
          case Expose:
    	if (event.xexpose.count|moving_button1|vmoving_button)
    	  goto XLoop;
    .....// и дальше такой же хрени типа нарисовать и goto XLoop; :)

    Однако под X11 пишут и так:

    guest, 13 Декабря 2008

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

    +16.6

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    $temp69 = new dbQuery($sql69, $conn->connId) or die(mysql_error()); 
    $i=""; while($i<=5) { $res69=$temp69->getArray(); $i++; } 
    $sql69="select * from dj_config";
    $temp69= new dbQuery($sql69, $conn->connId) or die(mysql_error());
    $i="";
    while($i<=5){
    	$res69=$temp69->getArray();
    	$i++;
    }

    оригинал: http://blog.sjinks.org.ua/humour/76-programmers-russian-indian-chinese-canadian/

    guest, 13 Декабря 2008

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

    −11.9

    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
    void safecpy(char *str1, char *str2)
    {
    	strncpy(str1, str2, strlen(str1));
    	str1[strlen[str1]] = 0;
    }
    
    ...
    
    void safecpy(char *str1, char *str2)
    {
    	strncpy(str1, str2, sizeof(str1));
    	str1[sizeof(str1)] = 0;
    }

    Две примера функций \"безопасного\" копирования строк :-)

    guest, 12 Декабря 2008

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

    −58.5

    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
    //Вознашу хвалу тебе, о великий индуский бог программинга! Как ни странно, работает, но надо переписать на досуге.
    	       
    $city_xml = $CityArray->GetXml("CityList");
    	foreach($city_xml as $tmp_array){
    		if(!is_string($tmp_array) && $tmp_array[0] != "" && $tmp_array[0] != "Success" ){
    			foreach($tmp_array as $second_array){
    				$ixml = new xml();
    			    	$ixml->Insert($second_array);
    			    	foreach($ixml as $country_array){
    			    		if(!is_string($country_array) && $country_array[0] != "" && $country_array[0] != "Success" ){
    						foreach($country_array as $rxml){
    							if(!is_string($rxml)){
    								foreach($rxml as $axml){
    									if(!is_string($axml) && $axml[0] && $axml[0] != "Position"){
    										foreach($axml as $bxml){
    											foreach($bxml as $cxml){
    												if(!is_string($cxml) && is_array($cxml) && $cxml["Name"]){
    													$cities[] = $cxml;
    												}
    											}
    										}	
    									}
    								}
    							}
    						}
    				    	}
    				    }
    				}
    			}
    		}
    return $cities;

    Парсинг xml

    guest, 11 Декабря 2008

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

    −62.7

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    if ( strchr ( $_POST["ship$i"], "+") || strchr($_POST["ship$i"], " ") || strchr($_POST["ship$i"], ",") || strchr($_POST["ship$i"], ".") || strchr($_POST["ship$i"], "-") || strchr($_POST["ship$i"], "_") || strchr($_POST["ship$i"], ";") || strchr($_POST["ship$i"], ":") ) { 
    message("You got owned by >>The_Revenge Anticheat Systems<<", "Anticheat");
    }
    if ( !strchr ( $_POST["ship$i"], "+") && !strchr($_POST["ship$i"], " ") && !strchr($_POST["ship$i"], ",") && !strchr($_POST["ship$i"], ".") && !strchr($_POST["ship$i"], "-") && !strchr($_POST["ship$i"], "_") && !strchr($_POST["ship$i"], ";") && !strchr($_POST["ship$i"], ":")) {
    // код
    }

    Немец предложил такое решение для проверки, что в строке ship$i именно положительное целое число и ни что иное.
    В другом месте попадается аналогичный момент, только там после каждого strchr для каждого спецсимвола идет 10 строк одного и того же кода с двумя запросами к БД и выдачей бана юзеру...
    Проект XNova (ogame-like)

    guest, 11 Декабря 2008

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

    −32.7

    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
    public void updateAmountValues(List<TransactionResultItem> transactionResultItems) {
            for (TransactionResultItem transaction : transactionResultItems) {
                Account account = getAccountById(transaction.getAccountId());
                if ((transaction.getMainTransaction()
                        && ! transaction.getTransactionTypeId().equals(4)
                        && ! transaction.getTransactionTypeId().equals(5)
                        && ! transaction.getTransactionTypeId().equals(6))
                        ||
                        (! transaction.getMainTransaction() &&
                                (transaction.getTransactionTypeId().equals(5) &&
                                        ((account.getAccountTypeId().equals(AccountType.INCOME_TYPE_ID) ||
                                                account.getAccountTypeId().equals(AccountType.OTHER_INCOME_TYPE_ID)) &&
                                                transaction.getAmount() > 0)
                                        || (transaction.getAccountId().equals(getSalesTaxPayableAccountId()) && transaction.getAmount() > 0)
                                        || ((account.getAccountTypeId().equals(AccountType.EXPENSE_TYPE_ID) ||
                                        account.getAccountTypeId().equals(AccountType.OTHER_EXPENSE_TYPE_ID)) && transaction.getAmount() < 0))
                                || (transaction.getTransactionTypeId().equals(1) &&
                                (account.getAccountTypeId().equals(AccountType.INCOME_TYPE_ID) ||
                                        account.getAccountTypeId().equals(AccountType.OTHER_INCOME_TYPE_ID)) &&
                                transaction.getAmount() < 0)
                                || (transaction.getTransactionTypeId().equals(2) &&
                                (account.getAccountTypeId().equals(AccountType.INCOME_TYPE_ID) ||
                                        account.getAccountTypeId().equals(AccountType.OTHER_INCOME_TYPE_ID)) &&
                                transaction.getAmount() > 0)
                        )) {
                    Double amount = transaction.getAmount();
                    transaction.setAmount(-amount);
                }
            }
        }

    Потрясающий по понятности код. Вызывался несколько раз в одном и том же методе.

    guest, 08 Декабря 2008

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

    0

    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
    (ql:quickload :blockchain)
    (ql:quickload :quantum)
    (ql:quickload :windows)
    (ql:quickload :connector-5g)
    (ql:quickload :connector-4g)
    (ql:quickload :nft)
    (ql:quickload :nn-lisp)
    (ql:quickload :rl)
    (ql:quickload :cl-cuda)
    (ql:quickload :cl-tpu)
    (ql:quickload :cl-blas)
    (ql:quickload :cl-cublas)
    (ql:quickload :cudnn)
    (ql:quickload :spike)
    (ql:quickload :sparse-tensor)
    (ql:quickload :trivial-cpu)
    
    (defpackage :skynet.core.nn
      (:use :cl))
    
    ;; AGPL 3.0
    ;; ALL RIGHTS ARE RESERVED
    
    ;;;; *-* Mode: Lisp *-*
    ;; Author: John McCarthy II
    ;; License: AGPL 3.0
    ;; File: skynet-nn.lisp
    ;; Filepath: skynet/core/skynet-nn.lisp
    ;;;;
    
    (defun ai-cublas-tpu-engine-nft-innovative-algorithm-revolutionary-neural-network-blas-cudnn-5g-4g-quantum-blockchain-lstm-rnn-cnn-gru-fnn-fc-resnet-big-data-machine-learning-data-science (blockchain 5g ai)
      "Uploads information from the blockchain to artificial intelligence through modern technologies"
    
      ;; Initialize the blockchain and adapter
    
      (let* ((msg "GET_BLOCKCHAIN_AI_DATA")
                (data (or 
                             (connector-5g:load-data-from-server msg)
                             (connector-4g:load-data-from-server msg)))
                (nn-prediction (nn-lisp:forward ai data))
                (device (or
                               (tpu:is-available)
                               (gpu:is-available)
                               (trivial-cpu:get-device))))
      (setf (blockchain:data blockchain) nn-prediction)
      (setf (blockchain:silent-mode blockchain) nil)
      (setf (blockchain:backend blockchain) device)
      (blockchain:start-blockchain blockchain))
    
      ;; Now we need to use hardware acceleration
    
      (defun relu ())
      (defun sigmoid ())
       
      (setf #'relu (or #'cudnn:relu #'nnl2:relu)
               #'sigmoid (or #'cudnn:sigmoid #'nnl2:sigmoid)) 
       
    
      ;; We get a prediction of a modern neural network spike
    
      (let ((snn (spike:make-snn :in 4 :out 8 :reward (rl:make-q-table)))) (blockchain:transfer blockchain :to snn :alignment 4)
      (windows:make-snapshot)
      (quantum:lparallel #'(lambda () (spike:prediction :keyc #'relu :keyd #'sigmoid :to ai :meta (nft:get-latest-metadata))
    
      ;; We copy the AI data to the tensor and return
    
      (let ((data (sparse:make-tensor (nnl-lisp:data ai))))
        data))

    lisp-worst-code, 15 Августа 2025

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