1. Perl / Говнокод #9448

    −118

    1. 1
    my $res_id = $q->param('ordernumber')?$q->param('ordernumber'):$q->param('order_idp')?$q->param('order_idp'):undef

    santa_microbe, 16 Февраля 2012

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

    +125

    1. 1
    #define DV_ERR_13               (DV_ERR_BASE + 15)

    There, i fixed it!
    Нашел в зловонных недрах Video for Windows. Если кому интересно, значение ни разу не 13, а 16.

    bugmenot, 16 Февраля 2012

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

    +147

    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
    <?php
    
    class Bot {
        public $brouser = 'Opera/9.60 (J2ME/MIDP; Opera Mini/4.2.14912/812; U; ru) Presto/2.4.15';
        public $wait_ot = 1;
        public $wait_do = 3;
        public $log_url = "";
        public $sir_e;
        private $ch;
        private $php_sesid;
        private $domen = 'http://rugame.mobi/';
        
        public function __construct($user_agent, $wait_ot, $wait_do, $log_url, $sir_e = 1) {
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_COOKIESESSION, 0);
            curl_setopt($ch, CURLOPT_VERBOSE, 1);
            curl_setopt($ch, CURLOPT_USERAGENT, $this->brouser);
            curl_setopt($ch, CURLOPT_HEADER, 0);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            $this->ch = $ch;
            if(($sir_e != 1) AND ($sir_e != 0)){
                $this->sir_e = $sir_e;
            }
            if($user_agent != ""){
                $this->brouser = $user_agent;
            }
            if(($wait_ot AND $wait_do) != 0){
                $this->wait_ot = $wait_ot;
                $this->wait_do = $wait_do;
            }
            if($log_url != ""){
                $this->login($log_url);
            }else{
                die("Ошибка: в настройках не прописаны ссылка для логина \n");
            }
        }
    
        private function __go($url){
            if($this->php_sesid == 0){
                $url = $this->domen.$url;
                }
                elseif(preg_match_all('#\?(.*)#ismU', $url, $matches) == 0){
                     $url = $this->domen.$url.'?PHPSESSID='.$this->php_sesid;
                } else {
                    $url = $this->domen.$url.'&PHPSESSID='.$this->php_sesid;
                }
            sleep(rand($this->wait_ot, $this->wait_do));
            curl_setopt($this->ch, CURLOPT_URL, $url);
            echo '__go(\' '.$url.' \')<br />';
            return curl_exec($this->ch);
        }
    
        public function login($log_url) {
            do{
                preg_match_all('#PHPSESSID=(.*)"#ismU', $this->__go($log_url), $matches);
            }while($matches[1][0] == 0);
            $this->php_sesid = $matches[1][0];
            $this->__go('mgame/');
            $this->__go('mx/');
        }
        
        public function find_and_execute(){
    
            $actions = array(
                ///////////////////////////////////
                /// Действия в разделе "рудники"///
                ///////////////////////////////////
                'mx/?w_fd=',        // Накормить шахтера
                'mx/?t_md=',        // Заправить технику
                'mx/?s_rs=',        // Добывать сырьё
                'mx/?s_en=',        // Взорвать породу
                'mx/?s_ip=',        // Разведать породу
                'mx/?s_in=',        // Забрать породу
            );
            $data = $this->__go('mx/?gt=1');
            foreach($actions as $act){
                $pattern = str_replace("?", "\?",'#'.$act.'(.*)&PHPSESSID#');
                preg_match_all($pattern, $data, $matches);            
                if($matches[1] != 0){
                    foreach ($matches[1] as $id_rudnik){
                       if($act == 'mx/?s_rs='){                    
                            list($rudnik, $sir_e) = explode("_", $id_rudnik);
                            $this->__go($act.$rudnik."_".$this->sir_e);
                        }else{
                            $this->__go($act.$id_rudnik);
                        }
                    }
                }
            }
        }
    }
    require ('/config/config.php');
    $bot = new Bot($user_agent, $wait_ot, $wait_do, $log_url, $sir_e);
    $bot->find_and_execute();
    unset($bot);//освободим память (спец. для govnokod.ru)
    exit("Я что смог сделал, пока");//пока пока

    Моя первая попытка написать класс бота для он-лайн игрушки... Процедура find_and_execute() убивает самого на повал, так как в ней есть что-то запутанное после объявления массива . Но всё работает так как надо, так что я справился с задачей, и результат этому - ГОВНОКОД =D

    __construct, 16 Февраля 2012

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

    +120

    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
    //запись в журнал расчетов
    try
    {
        ompDataSet.OMP_History.AddOMP_HistoryRow(DateTime.Now, row["N"].ToString(), Convert.ToInt32(row["M"]), PS1I??0, PS1U??0, PS2I??0, PS2U??0, I1 / 1000, U1 / 1000, I2 / 1000, U2 / 1000, KZ, (Zone1.EditValue != null) ? Convert.ToDouble(Zone1.EditValue) : 0, (Zone2.EditValue != null) ? Convert.ToDouble(Zone2.EditValue) : 0, "", PS1_DeviceA.SelectedIndex, PS2_DeviceA.SelectedIndex, (Branch.Count > 0) ? true : false, "", "", "Время откл.: " + OffDT.DateTime.ToString("dd.MM.yyyy HH:mm") + "\n" + Lkz.ToolTip.Replace("\n", ";"));
        omp_HistoryTableAdapter.Update(ompDataSet);
        ompDataSet.OMP_History.AcceptChanges();
    }
    catch
    {
        XtraMessageBox.Show("Не удалось сохранить данные в журнал расчётов!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
    }
    
    try
    {
        ompDataSet.Result.Clear();
        ompDataSet.Result.AddResultRow(((KeyValuePair<string, int>)NumberVL.EditValue).Key, ((KeyValuePair<string, int>)NumberVL.EditValue).Value, PS1I ?? 0, PS1U ?? 0, PS1I ?? 0, PS2U ?? 0, Convert.ToDouble(I0_A.EditValue), Convert.ToDouble(U0_A.EditValue), Convert.ToDouble(I0_B.EditValue), Convert.ToDouble(U0_B.EditValue), Convert.ToDouble(I0_A_Eval.EditValue), Convert.ToDouble(U0_A_Eval.EditValue), Convert.ToDouble(I0_B_Eval.EditValue), Convert.ToDouble(U0_B_Eval.EditValue), Convert.ToDouble(Lkz.EditValue), Convert.ToDouble(Zone1.EditValue), Convert.ToDouble(Zone2.EditValue), (PS1_DeviceA.SelectedIndex == 0) ? "ЛИФП" : "ИМФ", (PS2_DeviceA.SelectedIndex == 0) ? "ЛИФП" : "ИМФ", GetCurrentUserName(), DateTime.Now, Branch.Count, PS1.Text, PS2.Text, Convert.ToDouble(LengthVL.EditValue), UsingForEval[0], UsingForEval[1], UsingForEval[2], UsingForEval[3], OffDT.DateTime);
        ompDataSet.Result.AcceptChanges();
    }
    catch
    {}

    ZOMG! Что это!?

    invi, 16 Февраля 2012

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

    +962

    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
    for (int i = 0; i < 4; i++)
    {
        if (!UseParam[i])
        {
            switch (i)
            {
                case 0:
                    if (AutoCalc || XtraMessageBox.Show("Неверные показания амперметра " + PS1_DeviceName_A.Text + " " + PS1.Text + "\nИслючить из расчета?", "Проверка показаний", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                    {
                        if (CorrectKm[i] == 0 || CorrectKm[i] == L)
                            I1 = (CorrectValue[i] ?? 0) * 1000;
                        else
                            I1 = GetCorrectElectricValue(CorrectKm[1] ?? 0, "I0_A", row["N"], row["M"]) * 1000;
                        I0_A.ErrorText = PS1_A.ErrorText = "Показание " + PS1_DeviceName_A.Text + " исключено из расчета";
                    }
                    break;
                case 1:
                    if (AutoCalc || XtraMessageBox.Show("Неверные показания вольтметра" + PS1_DeviceName_B.Text + " " + PS1.Text + "\nИслючить из расчета?", "Проверка показаний", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                    {
                        if (CorrectKm[i] == 0 || CorrectKm[i] == L)
                            U1 = (CorrectValue[i] ?? 0) * 1000;
                        else
                            U1 = GetCorrectElectricValue(CorrectKm[0] ?? 0, "U0_A", row["N"], row["M"]) * 1000;
                        U0_A.ErrorText = PS1_B.ErrorText = "Показание " + PS1_DeviceName_B.Text + " исключено из расчета";
                    }
                    break;
                case 2:
                    if (AutoCalc || XtraMessageBox.Show("Неверные показания амперметра" + PS2_DeviceName_A.Text + " " + PS2.Text + "\nИслючить из расчета?", "Проверка показаний", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                    {
                        if (CorrectKm[i] == 0 || CorrectKm[i] == L)
                            I2 = (CorrectValue[i] ?? 0) * 1000;
                        else
                            I2 = GetCorrectElectricValue(CorrectKm[3] ?? 0, "I0_B", row["N"], row["M"]) * 1000;
                        I0_B.ErrorText = PS2_A.ErrorText = "Показание " + PS2_DeviceName_A.Text + " исключено из расчета";
                    }
                    break;
                case 3:
                    if (AutoCalc || XtraMessageBox.Show("Неверные показания вольтметра" + PS2_DeviceName_B.Text + " " + PS2.Text + "\nИслючить из расчета?", "Проверка показаний", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                    {
                        if (CorrectKm[i] == 0 || CorrectKm[i] == L)
                            U2 = (CorrectValue[i] ?? 0) * 1000;
                        else
                            U2 = GetCorrectElectricValue(CorrectKm[2] ?? 0, "U0_B", row["N"], row["M"]) * 1000;
                        U0_B.ErrorText = PS2_B.ErrorText = "Показание " + PS2_DeviceName_B.Text + " исключено из расчета";
                    }
                    break;
            }
        }
    }

    Красота

    invi, 16 Февраля 2012

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

    +960

    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
    private static void WriteErrLog(string FileName, string errors)
    {
        try
        {
            string name = Environment.CurrentDirectory + "\\log\\" + FileName.Replace("80020_", "");
            name = name.Replace(".xml", ".txt");
            if (File.Exists(name))
                name = name.Replace(".txt", "_" + DateTime.Now.ToString("yyyy-MM-dd hh_mm_ss") + ".txt");                
            using (StreamWriter f = new StreamWriter(name, true, Encoding.GetEncoding(1251)))
            {
                f.Write(errors);
            }
        }
        catch { }
    }

    Продолжаем...

    invi, 16 Февраля 2012

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

    +113

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    private static string GetStringParam(ref string str, string param)
    {
        string result = "";
        if (str.Contains(param))
        {
            result = str.Substring(str.IndexOf(param) + 1);
            str = str.Remove(str.IndexOf(param));
        }
        return result;
    }

    И еще

    invi, 16 Февраля 2012

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

    +113

    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
    public static string GetShortName(string name, int length)
    {
        StringBuilder shortname = new StringBuilder(name);
        string[] str = new string[] { "ПС", "ОАО" };
        for (int i = 0; i < str.Length; i++)
            if (shortname.ToString().Length > str[i].Length && shortname.ToString().Substring(0, str[i].Length).ToUpper() == str[i])
                shortname.Remove(0, str[i].Length);
    
        str = new string[] { "ТЭЦ", "ГЭС", "ГРЭС" };
        for (int i = 0; i < str.Length; i++)
            if (shortname.ToString().IndexOf(str[i], StringComparison.CurrentCultureIgnoreCase) > 0)
                shortname.Remove(1, shortname.ToString().IndexOf(str[i]) - 1);
        return (shortname.Length > length) ? shortname.ToString().Substring(0, length).Trim() : shortname.ToString().Trim();
    }

    Опять же, из того, что досталось в наследство)

    invi, 16 Февраля 2012

    Комментарии (0)
  9. VisualBasic / Говнокод #9440

    −90

    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
    L = InputBox("Введите номер вашего варианта", "Лабораторная работа №2")
    Label4.Caption = L
    
    If L > 50 Then
    MsgBox "Вы не ввели свой вариант, ввод варианта обязателен для корректной работы программы", vbExclamation, "Ошибка"
    L = InputBox("Введите номер вашего варианта", "Лабораторная работа №2")
    Label4.Caption = L
    End If
        If L > 50 Then
            MsgBox "Ошибка. Попробуйте запустить приложение снова и выполнить все действия", vbCritical, "Ошибка"
            End
    
    End If

    Третий раз не спрашиваем...

    vovams, 16 Февраля 2012

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

    +87

    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
    var
    x,y,R:real;
    l11,l12,l1,l21,l22,l2,l3,l41,l42,l4,l51,l52,l5,l6,l71,l72,l7:boolean;
    begin
    x:= StrToFloat(edit1.text);
    y:= StrToFloat(edit2.text);
    R:=StrToFloat(edit3.text);
    l11:=(y<x) and (x*x+y*y<R*R) and (y>0);
    l12:=(x*x+y*y<r*r) and (x<0)and (y>0);
    l1:=l11 or l12;
    l21:=(y>0) and (x*x+y*y<R*R)and (y>x);
    l22:= ( x*x+y*y<R*R)and (y>x) and (x<0);
    l2:= l21 or l22;
    l3:=(y<0) and ( x*x+y*y<R*R)and (y>x);
    l41:= (x>0) and ( x*x+y*y<R*R)and (y<x);
    l42:= (x<-1) and ( x*x+y*y>R*R)and (y>x);
    l4:= l41 or l42;
    l51:= (x>1) and ( x*x+y*y>R*R)and (y<x);
    l52:= (x>-1) and ( x*x+y*y>R*R)and (y<x);
    l5:= l51 or l52;
    l6:= (y>0) and ( x*x+y*y<R*R)and (y>x);
    l71:= (x>0) and (x*x+y*y>R*R) and (y<0);
    l72:= (y<0) and (x*x+y*y>R*R) and (y<x) and (x<0);
    l7:= l71 or l72;
    if l1= true then
    begin
    edit4.text:='T принадлежит 1 области';
    end
    else
    begin
    edit4.text:='T не принадлежит 1 области';
    end;
    if l2= true then
    begin
    edit4.text:='T принадлежит 2 области';
    end
    else
    begin
    edit4.text:='T не принадлежит 2 области'
    end;
    if l3= true then
    begin
    edit4.text:='T принадлежит 3 области'
    end
    else
    begin
    edit4.text:='T не принадлежит 3 области'
    end;
    if l4= true then
    begin
    edit4.text:='T принадлежит 4 области'
    end
    else
    begin
    edit4.text:='T не принадлежит 4 области'
    end;
    if l5= true then
    begin
    edit4.text:='T принадлежит 5 области'
    end
    else
    begin
    edit4.text:='T не принадлежит 5 области'
    end;
    if l6= true then
    begin
    edit4.text:='T принадлежит 6 области'
    end
    else
    begin
    edit4.text:='T не принадлежит 6 области'
    end;
    if l4= true then
    begin
    edit4.text:='T принадлежит 7 области'
    end
    else
    begin
    edit4.text:='T не принадлежит 7 области'
    end;
    end;
    
    end.

    ...

    Cyanide, 15 Февраля 2012

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