1. Pascal / Говнокод #9752

    +81

    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
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    99. 99
    type
      TString=string[20];
      TInputRec=record      //Inputable record type - тип вводимой информации
              FCol: TString;  //первый, второй, третий столбец
              SCol: TString;
              TCol: TString;
                end;
      TInputRecArray=array [1..127]of TInputRec;
    <...>
    procedure InFile (var n0,k0:byte);       //процедура формирования файлов
    Var
        InRec0   :TInputRec;
        BufChar  :char;
        BufString:TString;
        C,CharCheck,DigitCheck,DelBool,IncorBool:Boolean;
      begin
        n0:=0;
        repeat
          InRec0.FCol:='';
          InRec0.SCol:='';
          InRec0.TCol:='';
          BufString:='';
          IncorBool:=true;
          DelBool:=false;
          Inc(n0);
          Writeln(n0:20);
          while IncorBool do
          begin
          repeat
            BufChar:=readkey;
            StringDel(DelBool);
            ExitCond(k0,C,CharCheck,DigitCheck,BufChar);
            If C then Break;
            If CharCheck then
              begin
                write(bufchar);
                BufString:=BufString+BufChar;
              end;
            if DelBool then BufString:='';
            DelBool:=false;
          until BufChar=' ';
          If C then Break;
          InRec0.FCol:=Trim(BufString);
          BreakProc(n0,IncorBool,InRec0.FCol);
          end;
          Writeln;
          BufString:='';
          IncorBool:=true;
          if (k0=1) or (k0=2) then Break;
          while IncorBool do
          begin
          repeat
            BufChar:=readkey;
            StringDel(DelBool);
            ExitCond(k0,C,CharCheck,DigitCheck,BufChar);
            If C then Break;
            If DigitCheck or (BufChar='-') or (BufChar='/') or (BufChar='.') then
              begin
                Write(bufchar);
                BufString:=BufString+BufChar;
              end;
          if DelBool then BufString:='';
          DelBool:=false;
          until BufChar=' ';
          If C then Break;
          InRec0.SCol:=Trim(BufString);
          BreakProc(n0,IncorBool,InRec0.SCol);
          end;
          Writeln;
          BufString:='';
          DelBool:=false;
          IncorBool:=true;
          while IncorBool do
          begin
          repeat
            BufChar:=readkey;
            StringDel(DelBool);
            ExitCond(k0,C,CharCheck,DigitCheck,BufChar);
            If C then Break;
            If DigitCheck or (BufChar='-') or (BufChar='/') or (BufChar='.') then
              begin
                Write(bufchar);
                BufString:=BufString+BufChar;
              end;
          if DelBool then BufString:='';
          DelBool:=false;
          until BufChar=' ';
          If C then Break;
          InRec0.TCol:=Trim(BufString);
          BreakProc(n0,IncorBool,InRec0.TCol);
          end;
          Writeln;
          BufString:='';
          DelBool:=false;
          IncorBool:=true;
          InputRecArray[n0]:=InRec0;
        until False;
        ClrScr;
      end;

    Одна из ужасных моих программ (сдал и забыл как страшный сон (задача на первом курсе была сформировать 2 файла)). Тогда даже не знал про оператор continue...

    Psilon, 23 Марта 2012

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

    +114

    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
    private int GetInsertion(byte[] firstArr, byte[] secondArr)
            {
                int result = -1;
                int counter = 0;
                if (firstArr.Count() >= secondArr.Count())
                {
                    for (int i = 0; i < firstArr.Count(); i++)
                    {
                        if (firstArr[i] == secondArr[counter])
                        {
                            counter++;
                            if (counter == secondArr.Count())
                            {
                                result = i - counter + 1;
                                break;
                            }
                        }
                        else
                        {
                            counter = 0;
                        }
                    }
                }
                return result;
            }

    находит индекс вхождения одного массива в другой

    razzil, 23 Марта 2012

    Комментарии (1)
  3. ActionScript / Говнокод #9750

    −124

    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
    if (param.visible == 'cache')
    {
    	while (parseCacheResult.indexOf('$data') != -1) parseCacheResult = parseCacheResult.replace('$data', '_dataCache');
    	while (parseCacheResult.indexOf('$name') != -1) parseCacheResult = parseCacheResult.replace('$name', param.nameParam);
    	while (parseCacheResult.indexOf('$type') != -1) parseCacheResult = parseCacheResult.replace('$type', param.type);
    } else if (param.visible == 'static')
    {
    	while (parseStaticResult.indexOf('$data') != -1) parseStaticResult = parseStaticResult.replace('$data', '_dataStatic');
    	while (parseStaticResult.indexOf('$name') != -1) parseStaticResult = parseStaticResult.replace('$name', param.nameParam);
    	while (parseStaticResult.indexOf('$type') != -1) parseStaticResult = parseStaticResult.replace('$type', param.type);
    }
    else
    {
    	while (parseDynamicResult.indexOf('$data') != -1) parseDynamicResult = parseDynamicResult.replace('$data', '_dataDynamic');
    	while (parseDynamicResult.indexOf('$name') != -1) parseDynamicResult = parseDynamicResult.replace('$name', param.nameParam);
    	while (parseDynamicResult.indexOf('$type') != -1) parseDynamicResult = parseDynamicResult.replace('$type', param.type);
    }
    
    while (setResult.indexOf('$name') != -1) setResult = setResult.replace('$name', param.nameParam);
    while (setResult.indexOf('$type') != -1) setResult = setResult.replace('$type', param.type);
    while (setResult.indexOf('$className') != -1) setResult = setResult.replace('$className', className);
    
    while (getResult.indexOf('$name') != -1) getResult = getResult.replace('$name', param.nameParam);
    while (getResult.indexOf('$type') != -1) getResult = getResult.replace('$type', param.type);
    
    while (varResult.indexOf('$name') != -1) varResult = varResult.replace('$name', param.nameParam);
    while (varResult.indexOf('$type') != -1) varResult = varResult.replace('$type', param.type);
    while (varResult.indexOf('$comment') != -1) varResult = varResult.replace('$comment', param.comment);
    while (varResult.indexOf('$default') != -1) varResult = varResult.replace('$default', param.defaultValue);
    
    }
    
    var result : String = baseTemplate;
    while (result.indexOf('$className') != -1) result = result.replace('$className', className);
    while (result.indexOf('$comment') != -1) result = result.replace('$comment', comment);
    while (result.indexOf('$baseClass') != -1) result = result.replace('$baseClass', baseClass);
    while (result.indexOf('$singleton_1') != -1) result = result.replace('$singleton_1', singl_1);
    while (result.indexOf('$singleton_2') != -1) result = result.replace('$singleton_2', singl_2);
    
    result = result.replace('$var', varResult);
    result = result.replace('$set', setResult);
    result = result.replace('$get', getResult);
    result = result.replace('$parseDynamic', parseDynamicResult);
    result = result.replace('$parseStatic', parseStaticResult);
    result = result.replace('$parseCache', parseCacheResult);
    result = result.replace('$values', valuesList);
    result = result.replace('$dynamic', data.dynamicClass == 1 ? 'dynamic' : '');

    Как то родилось в процессе допилок кодогена )

    kyzi007, 23 Марта 2012

    Комментарии (1)
  4. Java / Говнокод #9749

    +142

    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
    public abstract class MySqlDataBase extends AbstractDataBase {
    
        public MySqlDataBase() throws Exception {
        }
    
        public void connection) {
            // Тут наш говнокод...
        }
    
        public abstract void createDB() {
            // Тут наш говнокод...
        }   
        
        public abstract void executeQuery() {
            // Тут наш говнокод...
        }
    
        public abstract void shutdown() {
            // Тут наш говнокод
        }
    
        public abstract DBObject getObject(String q);
        
        public abstract Vector getObjectVector(String q);
        
        public abstract void insertObject(DBObject o);
        
        public abstract void updateObject(DBObject o);
    }

    JavaCoder, 23 Марта 2012

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

    +62

    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
    package ru.jimbot.db;
    
    public abstract void AbstractDataBase {
    
        public AbstractDataBase {
        }
    
        public abstract void connection();
    
        public abstract void createDB();   
        
        public abstract void executeQuery();
    
        public abstract void shutdown();
    
    }

    JavaCoder, 23 Марта 2012

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

    +158

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    $version = (int)$_GET['version'];
    	
    	if (!empty($version))
    	{
    		$version = '1.4.6.2';
    	}
    	else
    	{
    		$version = '1.4.6.2';
    	}

    Ну и на кой?

    ibnLoky, 23 Марта 2012

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

    +79

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    if ("5".equals(pid)) {
    
    } else {
    	if ("1".equals(pid) || "4".equals(pid)) {
    		type = "fl";
    	} else if ("6".equals(pid)){
    		type = "nw";
    	}else {
    		type = "ul";
    	}
    }

    Из базы формируется дерево элементов для меню. Там же есть какая-то сортировка. Меняем в базе сортировку, а все работает по-старому. Лезем копать и находим.

    akkuch, 23 Марта 2012

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

    +157

    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
    if ($this->_hasParam('error')) {
                    if (intval(htmlentities($this->getRequest()->getParam('error'))) == -1100) {
                        $this->payment_messages->addMess($this->translate->translate('please.remember.fill'));
                    } elseif (intval(htmlentities($this->getRequest()->getParam('error'))) == -1300) {
                        $this->payment_messages->addMess($this->translate->translate('credit.card.not.accepted'));
                    } elseif (intval(htmlentities($this->getRequest()->getParam('error'))) == -1022) {
                        $this->payment_messages->addMess($this->translate->translate('transaction.declined.card.number'));
                    } elseif (intval(htmlentities($this->getRequest()->getParam('error'))) == -1018) {
                        $this->payment_messages->addMess($this->translate->translate('transaction.declined.card.number'));
                    } else {
                        $this->payment_messages->addMess($this->translate->translate('payment.system.error'));
                    }
                    $this->view->payment_messages = $this->payment_messages->getMess();
                }

    В продолжение #9742
    Это Team leader!!!

    Quetzalcoatl, 23 Марта 2012

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

    +158

    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
    public function delete_post($id_op){
            $ret = 'false';
            if((!empty($id_op))){
                    try{
                                        $ret1 = $this->getAdapter()->delete($this->users_posts_table,  'op_id = '.intval($id_op));
                                        $ret2 = $this->getAdapter()->delete($this->offer_posts_table,  'id_op = '.intval($id_op));
                                        if($ret1>0 && $ret2>0){
                                            $ret = 'true';
                                        }
                                        }catch(Exception $e){
                            $this->logger->log('module: deleting in  users_posts, offer_posts tables '.$e->getMessage(), Zend_Log::ERR);
                     }
            }
            else{
                            $ret = 'false';
                            $this->logger->log('function: delete_post : id_op is null', Zend_Log::ERR);
            }
            return $ret;
        }

    Код тим лидера.
    форматирование автора

    Quetzalcoatl, 23 Марта 2012

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

    +155

    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
    function sql_ommetr($q,&$dbt,$line)
    {
    	$result = mysql_query($q, $dbt);
    	if (!$result)
    	{
    		if (!mysql_ping($dbt))
    		{
    			$dbt = reinit_master_connection();
    			if (!mysql_ping($dbt))
    			{
    				trigger_error(__FILE__.":$line\t".mysql_errno($dbt)."\t".mysql_error($dbt)."\t| 2dieWhen executing: ".preg_replace("/\n+/"," ",$q)."\n",E_USER_WARNING);
    				die();
    			}else{
    				$result = mysql_query($q, $dbt);
    				if (!$result){
    					trigger_error(__FILE__.":$line\t".mysql_errno($dbt)."\t".mysql_error($dbt)."\t| 3dieWhen executing: ".preg_replace("/\n+/"," ",$q)."\n",E_USER_WARNING);
    					die();
    				}
    			}
    		}else{
    			$result = mysql_query($q, $dbt);
    			if (!$result){
    				trigger_error(__FILE__.":$line\t".mysql_errno($dbt)."\t".mysql_error($dbt)."\t| 3dieWhen executing: ".preg_replace("/\n+/"," ",$q)."\n",E_USER_WARNING);
    				die();
    			}
    		}
    	}
    	return $result;
    }

    Странно, я представлял себе Омметр немного иначе...

    roman-kashitsyn, 23 Марта 2012

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