1. Python / Говнокод #6866

    −318

    1. 1
    self._DEBUG=Debug.Debug(debug)

    В библиотеке xmpppy. Дебаг на дебаге.

    diok, 05 Июня 2011

    Комментарии (7)
  2. Pascal / Говнокод #6865

    +96

    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
    Assign(F, FileName);
      IOResult;
      Reset(F);
      if IOResult = 0 then begin
        for i := 0 to MaxModelNamesCount-1 do ModelKind[i] := mkVagon;
        Result := True;
        BlockRead(F, W, 2);
        if W = OldWDim then begin // старый формат
          // 20 строк пропущено
        end else if W = WDim then begin // новый формат
          BlockRead(F, FormatVersion, 4); // версия нового формата
          if FormatVersion <= 4 then begin
            BlockRead(F, EditorDate, 4);
            BlockRead(F, C, 4);
            LCount := C;
            for i := 0 to LCount - 1 do begin
              BlockReadLine(F, Lines[i], 16);
              if (FormatVersion <= 2) and (Lines[i].Attr[3] and $0F = 5) then Lines[i].Attr[0] := 0
              else if (Lines[i].Attr[3] and $0F = k3DObject) then ModelKind[Lines[i].IntAttr[1]] := mkStatic;
            end;
            if FormatVersion <= 1 then begin
              ModelNamesCount := 8;  // для 1й версии список жёстко задан
              ModelNames[0] := 'ГЗРВ-10';
              ModelNames[1] := 'ГЗРВ-10М';
              ModelNames[2] := 'КТМ-5М3';
              ModelNames[3] := 'ЛМ-68';
              ModelNames[4] := 'ЛМ-68М';
              ModelNames[5] := 'ЛМ-68ММ';
              ModelNames[6] := 'ЛВС-86';
              ModelNames[7] := 'ЛВС-97';
              for i := 8 to MaxModelNamesCount-1 do ModelNames[i] := '';
            end else if FormatVersion <= 3 then begin
              ModelNamesCount := 0;
              for i := 0 to 255 do begin
                j := 0;
                BlockRead(F, j, 1);
                SetLength(ModelNames[i], j);
                for j := 1 to Length(ModelNames[i]) do Read(F, byte(ModelNames[i, j]));
                if ModelNames[i] <> '' then Inc(ModelNamesCount);
              end;
            end else begin
              BlockRead(F, ModelNamesCount, 4); // кол-во моделей
              for i := 0 to MaxModelNamesCount - 1 do ModelNames[i] := '';
              for i := 0 to ModelNamesCount-1 do begin
                BlockRead(F, k, 4); // номер считываемой модели
                j := 0;
                BlockRead(F, j, 1); // длина имени, не более 255
                SetLength(ModelNames[k], j);
                for j := 1 to Length(ModelNames[k]) do Read(F, byte(ModelNames[k, j]));
              end;
            end;
    
            for i := 0 to 8 do
              for j := 0 to 12 + Byte(FormatVersion >= 2) do with Routes[i, j] do begin
                BlockRead(F, PCount, 2);
                SetAllowedModels(Routes[i,j], 0, -1);
                if FormatVersion <= 1 then begin      
                  BS := [];
                  BlockRead(F, BS, 4);
                  AllowedModelsCount := 0;
                  for k := 0 to 255 do if k in BS then begin
                    Inc(AllowedModelsCount);
                    AllowedModels[k] := True;
                  end;
                end else if FormatVersion <= 3 then begin
                  BlockRead(F, BS, 32);
                  AllowedModelsCount := 0;
                  for k := 0 to 255 do if k in BS then begin
                    Inc(AllowedModelsCount);
                    AllowedModels[k] := True;
                  end;
                end else begin
                  BlockRead(F, AllowedModelsCount, 4);
                  for k := 0 to AllowedModelsCount-1 do begin
                    BlockRead(F, n, 4);           // номер модели
                    AllowedModels[n] := True;
                  end;
                end;
    
                for k := 0 to PCount - 1 do begin
                  if FormatVersion >= 3 then BlockRead(F, c, 4)
                  else begin
                    c := 0;
                    BlockRead(F, c, 2);
                  end;
                  Points[k] := c;
                end;
                BlockRead(F, DefVagons, 1);
                SpeedRoute := boolean(DefVagons shr 4);
                DefVagons := DefVagons and $0F;
                BlockRead(F, Interval, 1);
              end;
          end else Result := False;
        end else Result := False;
        Close(F);

    Короче, лапша из if FormatVesion такой-то...
    Обратная совместимость формата файла.
    Формату уже 4 года.

    TarasB, 05 Июня 2011

    Комментарии (52)
  3. Ruby / Говнокод #6864

    −99

    1. 1
    2. 2
    <%= @album.playlist.gsub('
    ','<br />') %>

    Тогда, видимо, не догадался написать "\n" :)

    Actine, 05 Июня 2011

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

    +138

    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
    auto ret;
    ulong[] generateMobs() {
    
        ushort counter = 0;
    
        for(ulong id = 0; id < NUMBER_OF_MOBS; ++id) {
    
            Mob bufferMob = get(id);
    
            if ( bufferMob.habitat == hero.hero.heroLocalityType() && ((bufferMob.rating() <= hero.hero.rating())) ) {
                suitable ~= id;
                counter++;
            }
        }
        ret = suitable;
    
        suitable.length = 0;   /// Im
        suitable = null;        /// FUCKIN'
        delete suitable;      /// DESTROY YOU!!!
    
        return ret;
    }

    Вообще это язык Ди(D(digitalmars.com <-- разрабы языка). Зае... Достала всякая НЕ статичная хрень)
    Вообще в Ди есть гарбадж коллектор...

    Hackeridze, 05 Июня 2011

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

    +167

    1. 1
    <a title="Главная" href="http://<?php echo $_SERVER['HTTP_HOST'].str_replace('\\', '', dirname($_SERVER['PHP_SELF'])); ?>">Главная</a>

    нашел в одном проекте, я бы и не смог до такого додуматься

    alextg, 04 Июня 2011

    Комментарии (5)
  6. VisualBasic / Говнокод #6861

    −99

    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
    Dim byteOut(64) As Byte
            Dim i As Integer
            Try
                byteOut(0) = Len(outCName) + 5 'number bytes in output message
                byteOut(1) = &H0 'should be 0 for NXT
                byteOut(2) = &H80 '&H0 = reply expected &H80 = no reply expected
                byteOut(3) = &H9 'Send Bluetooth
                byteOut(4) = &H0 'Box Number - 1
                byteOut(5) = Len(outCName) + 1 'message size with null terminator
                For i = 1 To Len(outCName) 'copy bytes into output array
                    byteOut(i + 5) = Asc(Mid(outCName, i, 1))
                Next
                byteOut(Len(outCName) + 6) = &H0 'add null terminator
                SerialPort1.Write(byteOut, 0, Len(outCName) + 7) 'send message
    
            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try
            '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            Try
                byteOut(0) = Len(outWState) + 5 'number bytes in output message
                byteOut(1) = &H0 'should be 0 for NXT
                byteOut(2) = &H80 '&H0 = reply expected &H80 = no reply expected
                byteOut(3) = &H9 'Send Bluetooth
                byteOut(4) = &H1 'Box Number - 1
                byteOut(5) = Len(outWState) + 1 'message size with null terminator
                For i = 1 To Len(outWState) 'copy bytes into output array
                    byteOut(i + 5) = Asc(Mid(outWState, i, 1))
                Next
                byteOut(Len(outWState) + 6) = &H0 'add null terminator
                SerialPort1.Write(byteOut, 0, Len(outWState) + 7) 'send message
    
            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try
    
    <..ещё один раз..>
    
       '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            Try
                byteOut(0) = Len(outWindC) + 5 'number bytes in output message
                byteOut(1) = &H0 'should be 0 for NXT
                byteOut(2) = &H80 '&H0 = reply expected &H80 = no reply expected
                byteOut(3) = &H9 'Send Bluetooth
                byteOut(4) = &H3 'Box Number - 1
                byteOut(5) = Len(outWindC) + 1 'message size with null terminator
                For i = 1 To Len(outWindC) 'copy bytes into output array
                    byteOut(i + 5) = Asc(Mid(outWindC, i, 1))
                Next
                byteOut(Len(outWindC) + 6) = &H0 'add null terminator
                SerialPort1.Write(byteOut, 0, Len(outWindC) + 7) 'send message
    
            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try
    
            '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            Try
                byteOut(0) = Len(outHum) + 5 'number bytes in output message
                byteOut(1) = &H0 'should be 0 for NXT
                byteOut(2) = &H80 '&H0 = reply expected &H80 = no reply expected
                byteOut(3) = &H9 'Send Bluetooth
                byteOut(4) = &H4 'Box Number - 1
                byteOut(5) = Len(outHum) + 1 'message size with null terminator
                For i = 1 To Len(outHum) 'copy bytes into output array
                    byteOut(i + 5) = Asc(Mid(outHum, i, 1))
                Next
                byteOut(Len(outHum) + 6) = &H0 'add null terminator
                SerialPort1.Write(byteOut, 0, Len(outHum) + 7) 'send message
    
            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try

    Говнокод почти трёхлетней давности. Понадобилось мне посмотреть, как я реализовывал "общение" по блютусу с Mindstorms NXT, и напоролся на вот это...

    RaZeR, 04 Июня 2011

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

    +163

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    <?php echo '<?xml version="1.0" encoding="utf-8"?>';?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="ru">
    <head>
    <title>День Победы! 66 лет со дня победы! 9 Мая!</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style type="text/css">body{background:#000;}h1{color:#ff5500;}</style>
    </head>
    <body>
    <div style="text-align:center">
    <div style="padding-top:28%"><h1><?php
    class Main
    {
    var $timex;
    var $month;
    var $day;
    var $year;
    function win2uni($s)
    {
    $s = convert_cyr_string($s,'w','i');
    for ($result='', $i=0; $i<strlen ($s); $i++) {
    $charcode = ord($s[$i]);
    $result .= ($charcode>175)?"&#".(1040+($charcode-176)).";":$s[$i];
    }
    return $result;
    }
    function Main()
    {
    if ($this->GetDate())
    $this->TimeTo();
    return true;
    }
    function GetDate()
    {
    $this->month = '05';
    $this->day = '09';
    $this->year = '2011';
    return true;
    }
    function TimeTo()
    {
    $m = $this->month;
    $d = $this->day;
    $y = $this->year;
    $mn = date("m");
    $dn = date("d");
    $yn = date("y");
    $hh = date("H");
    $mm = date("i");
    $ss = date("s");
    $diff = mktime(23,59,59,$m,$d,$y)-mktime($hh,$mm,$ss,$mn,$dn,$yn);
    $days = $diff/60/60/24;
    $hours = $diff/60/60 - intval($days)*24;
    $minutes = $diff/60 - intval(intval($days*24)*60);
    $seconds = $diff - intval(intval(intval($days*24*60))*60);
    $text = "До Дня Победы (9 мая) осталось<br/>\n";
    $text.= round($days);
    $mins = round($days)."";
    if ($mins == "11" or $mins == "12" or $mins == "13" or $mins == "14") $text.= " дней "; else
    if (
    $mins[strlen($mins)-1] == "2"
    or $mins[strlen($mins)-1] == "3"
    or $mins[strlen($mins)-1] == "4")
    $text.= " дня "; else
    if($mins[strlen($mins)-1] == "1")
    $text.= " день "; else
    $text.= " дней ";
    $text.= round($hours);
    if (round($hours) == 1 or round($hours == 21)) $text.= " час "; else
    if (round($hours) == 2 or round($hours) == 3 or round($hours) == 4 or round($hours) == 22 or round($hours) == 23) $text.= " часа ";
    else $text.= " часов ";
    $text.= round($minutes);
    $mins = round($minutes)."";
    if ($mins == "11" or $mins == "12" or $mins == "13" or $mins == "14") $text.= " минут "; else
    if (
    $mins[strlen($mins)-1] == "2"
    or $mins[strlen($mins)-1] == "3"
    or $mins[strlen($mins)-1] == "4")
    $text.= " минуты "; else
    if($mins[strlen($mins)-1] == "1")
    $text.= " минута "; else
    $text.= " минут ";
    $text.= round($seconds);
    $mins = round($seconds)."";
    if ($mins == "11" or $mins == "12" or $mins == "13" or $mins == "14") $text.= " секунд "; else
    if (
    $mins[strlen($mins)-1] == "2"
    or $mins[strlen($mins)-1] == "3"
    or $mins[strlen($mins)-1] == "4")
    $text.= " секунды "; else
    if($mins[strlen($mins)-1] == "1")
    $text.= " секунда "; else
    $text.= " секунд ";
    echo $text;
    return true;
    }
    }
    $X = new Main();
    ?></h1></div>

    Заранее извиняюсь за "опять даты, опять php":)

    Отсчет времени до 9 мая
    http://dumpz.org/23155/

    rO_ot, 04 Июня 2011

    Комментарии (14)
  8. JavaScript / Говнокод #6859

    +144

    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
    if (navigator.appName != "Microsoft Internet Explorer") {
    document.write(
    "<img src=\"blank.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img0\">\n"+
    "<img src=\"blank.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img1\">\n"+
    "<a href=\"#\" onClick=\"window.move(2);return false\" onMouseOver=\"window.status='';\n"+
    "return true\"><img src=\"peg.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img2\"></A>\n"+
    "<a href=\"#\" onClick=\"window.move(3);return false\" onMouseOver=\"window.status='';\n"+
    "return true\"><img src=\"peg.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img3\"></A>\n"+
    "<a href=\"#\" onClick=\"window.move(4);return false\" onMouseOver=\"window.status='';\n"+
    "return true\"><img src=\"peg.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img4\"></A>\n"+
    "<img src=\"blank.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img5\">\n"+
    "<img src=\"blank.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img6\"><BR>\n"+
    "
    "<a href=\"#\" onClick=\"window.move(26);return false\" onMouseOver=\"window.status='';\n"+
    "return true\"><img src=\"peg.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img26\"></A>\n"+
    "<a href=\"#\" onClick=\"window.move(27);return false\" onMouseOver=\"window.status='';\n"+
    "return true\"><img src=\"peg.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img27\"></A><BR>\n"+
    "<a href=\"#\" onClick=\"window.move(28);return false\" onMouseOver=\"window.status='';\n"+
    "return true\"><img src=\"peg.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img28\"></A>\n"+
    "<a href=\"#\" onClick=\"window.move(29);return false\" onMouseOver=\"window.status='';\n"+
    "return true\"><img src=\"peg.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img29\"></A>\n"+
    "<a href=\"#\" onClick=\"window.move(30);return false\" onMouseOver=\"window.status='';\n"+
    "return true\"><img src=\"peg.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img30\"></A>\n"+
    "<a href=\"#\" onClick=\"window.move(31);return false\" onMouseOver=\"window.status='';\n"+
    "return true\"><img src=\"peg.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img31\"></A>\n"+
    "<a href=\"#\" onClick=\"window.move(32);return false\" onMouseOver=\"window.status='';\n"+
    "return true\"><img src=\"peg.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img32\"></A>\n"+
    "<a href=\"#\" onClick=\"window.move(33);return false\" onMouseOver=\"window.status='';\n"+
    "<img src=\"blank.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img47\">\n"+
    "<img src=\"blank.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img48\"><BR>")
    
    ... До хуя таких строк
    }
    else {
    document.write(
    "<img src=\"blank.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img0\">\n"+
    "<img src=\"blank.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img1\">\n"+
    "<img src=\"peg.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img2\" \n"+
    "onClick=\"window.move(2);return false\">\n"+
    "<img src=\"peg.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img3\" \n"+
    "onClick=\"window.move(3);return false\">\n"+
    "<img src=\"peg.gif\" border=\"0\" width=\"19\" height=\"19\" name=\"img4\" \n"+
    "
    ... аналогично

    Из каталога готовых скриптов EsayScript

    Vasiliy, 04 Июня 2011

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

    +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
    <?php
    $this->phptal->id=$id;
    $this->phptal->returnid=$returnid;
    
    if(isset($params['catalogue']))
    {
    	if(isset($params['category']))
    	{
    		if(isset($params['news']))
    		{
    			$nid=(int)$params['news'];
    			require_once(cms_join_path($this->GetModulePath(), 'classes','dao', 'EventNewsDAO.php'));
    			$nldao=new EventNewsDAO($this);
    			$this->phptal->newsline=$nldao->get($nid);
    			echo $this->ProcessTalTemplate('admin/admin_newsline.tal.tpl');
    		}
    		else
    		{
    			$cid=(int)$params['catalogue'];
    			require_once(cms_join_path($this->GetModulePath(), 'classes','dao', 'EventCatalogueDAO.php'));
    			$cdao=new EventCatalogueDAO($this);
    			$this->phptal->catalogue=$cdao->get($cid);
    			require_once(cms_join_path($this->GetModulePath(), 'classes','dao', 'EventCategoryDAO.php'));
    			$ccdao=new EventCategoryDAO($this);
    			$this->phptal->categories=$ccdao->all($cid);
    
    			$ccid=(int)$params['category'];
    			$this->phptal->category=$ccdao->get($ccid);
    			require_once(cms_join_path($this->GetModulePath(), 'classes','dao', 'EventNewsDAO.php'));
    			$ndao=new EventNewsDAO($this);
    			$this->phptal->news=$ndao->all($ccid);
    			echo $this->ProcessTalTemplate('admin/admin_news.tal.tpl');
    		}
    	}
    	else
    	{
    		$cid=(int)$params['catalogue'];
    		require_once(cms_join_path($this->GetModulePath(), 'classes','dao', 'EventCatalogueDAO.php'));
    		$cdao=new EventCatalogueDAO($this);
    		$this->phptal->catalogue=$cdao->get($cid);
    		require_once(cms_join_path($this->GetModulePath(), 'classes','dao', 'EventCategoryDAO.php'));
    		$ccdao=new EventCategoryDAO($this);
    		$this->phptal->categories=$ccdao->all($cid);
    		echo $this->ProcessTalTemplate('admin/admin_categories.tal.tpl');
    	}
    }
    else
    {
    	require_once(cms_join_path($this->GetModulePath(), 'classes','dao', 'EventCatalogueDAO.php'));
    	$cdao=new EventCatalogueDAO($this);
    	$this->phptal->catalogues=$cdao->all();
    	echo $this->ProcessTalTemplate('admin/admin_catalogues.tal.tpl');
    }

    я молодец. наговнокодил как школьник.
    ветвистое ветвление + жуткая копипаста.
    буду это рефакторить, когда в целом закончу базовую функциональность.

    Lure Of Chaos, 04 Июня 2011

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

    +157

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    $opdirbase=opendir(H.'sys/fnc');
    while ($filebase=readdir($opdirbase))
    {
    if (eregi('\.php$',$filebase))
    {
    include_once(H.'sys/fnc/'.$filebase);
    }
    }

    Вот так вот инклюдится код в одной в вап cms.В дериктории файлы по 200-300кб.

    jQuery, 03 Июня 2011

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