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

    +101

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    procedure TForm1.ShowPaletteButtonClick(Sender: TObject);
    begin
    if Form2.Visible = False then Form2.Visible := True;
    Form2.BringToFront;
    end;

    кстати о документации
    подлинное говно от багланд интернейшнл
    пруф - http://docwiki.embarcadero.com/CodeExamples/en/BringToFront_(Delphi)

    bugmenot, 24 Сентября 2011

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

    +151

    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
    <?php include ("blocks/bd.php");
    
    if (isset($_POST['author']))
    {
    $author = $_POST['author'];
    }
    
    if (isset($_POST['tetx']))
    {
    $text = $_POST['text'];
    }
    
    if (isset($_POST['pr']))
    {
    $pr = $_POST['pr'];
    }
    
    if (isset($_POST['sub_com']))
    {
    $sub_com = $_POST['sub_com'];
    }
    
    if (isset($_POST['id']))
    {
    $id = $_POST['id'];
    }
    
    if (isset($sub_com))
    {
    if (isset($author)) {trim($author);  }
    else {$author = "";}
    
    if (isset($text)) {trim($text);  }
    else {$text = "";}
    
    if (empty($author) or empty($text))
    {
    exit ("<p>Вы ввели не всю информацию ,вернитесь назад и заполните все поля. <br> <input name='back' type='button' value='Вернитесь назад'onclick='javascript:self.back();'>");
    }
    
    $author = stripslashes($author);
    $text = stripslashes($text);
    $author = htmlspecialchars($author);
    $text = htmlspecialchars($text);
    
    $result =  mysql_query ("SELECT sum FROM com_settings",$db);
    $myrow = mysql_fetch_array($result);
    
    if ($pr == $myrow["sum"])
    {
    $date = date("Y-m-d");
    
    $result2 = mysql_query ("INSERT INTO comments (post,author,text,date) VALUES ('$id','$author','$text','$date')",$db);
    
    }
    else 
    {
    exit ("<p>Вы ввели не вернуюсумму цыфр с картинки на пебедущей странице. <br> <input name='back' type='button' value='Вернитесь назад'onclick='javascript:self.back();'>");
    }
    }
    ?>

    мне тут надо post прировнть к id чтобы коментарий добивился в то место где надо
    в 54 строке мне выдет вот такую ошибку:
    Notice: Undefined variable: id in z:\home\localhost\www\phpblog\comment.ph p on line 54
    скажипо пож что тут справить

    cooler97, 24 Сентября 2011

    Комментарии (38)
  3. Pascal / Говнокод #7961

    +107

    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
    for i:=1 to 8 do
     begin
     case i of
     1 : begin
         xx := 0;
         yy := -LUCH_LEN;
         end;
     2 : begin
         xx := round(LUCH_LEN/sqrt(2));;
         yy := -round(LUCH_LEN/sqrt(2));;
         end;
     3 : begin
         xx := LUCH_LEN;
         yy := 0;
         end;
     4 : begin
         xx := round(LUCH_LEN/sqrt(2));;
         yy := round(LUCH_LEN/sqrt(2));;
         end;
     5 : begin
         xx := 0;
         yy := LUCH_LEN;
         end;
     6 : begin
         xx := -round(LUCH_LEN/sqrt(2));;
         yy := round(LUCH_LEN/sqrt(2));;
         end;
     7 : begin
         xx := -LUCH_LEN;
         yy := 0;
         end;
     8 : begin
         xx := -round(LUCH_LEN/sqrt(2));
         yy := -round(LUCH_LEN/sqrt(2));
         end;
     end;

    вот такое странное сочетание...

    dvdking, 23 Сентября 2011

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

    +162

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    # Если ошибка при авторизации
    begin_page("Вход");
    
    echo("<font color='red'>Ошибка при наборе логина или пароля</font>\n");
    
    }
    
    # Форма авторизации
    if (!headers_sent())
    begin_page("Вход");

    Поручили мне отрефакторить систему "Компьютерный класс" и баги в ней пофиксить.
    В login.php сразу же гениальнейшая конструкция.

    7ion, 23 Сентября 2011

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

    +161

    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
    if (!GetCurrentCurrency()) { print $_lang[ErrorGetCurrentCurrency]; mclose(); exit; }
    
    @set_time_limit(0);
    
    $company_name=GetSetting('company_name');
    $company_url=GetSetting('company_url');
    $billing_url=GetSetting('billing_url');
    $support_url=GetSetting('support_url');
    $manager_email=GetSetting('manager_email');
    
    $cronAutoSuspend = GetSetting('cronAutoSuspend');
    $cronSendAdminEndOrder = GetSetting('cronSendAdminEndOrder');
    $cronSendClientBillRemind = GetSetting('cronSendClientBillRemind');
    $cronSendClientBillRemindDays = GetSetting('cronSendClientBillRemindDays');
    $cronSendClientEndOrderRemind = GetSetting('cronSendClientEndOrderRemind');
    $cronSendClientEndOrderRemindDays = GetSetting('cronSendClientEndOrderRemindDays');
    $cronSendClientEndOrderDomainRemind = GetSetting('cronSendClientEndOrderDomainRemind');
    $cronSendClientEndOrderDomainRemindDays = GetSetting('cronSendClientEndOrderDomainRemindDays');
    $cronDeleteBill = GetSetting('cronDeleteBill');
    $cronDeleteBillDay = GetSetting('cronDeleteBillDay');
    $cronDeleteNeobrabOrdersWithoutBills = GetSetting('cronDeleteNeobrabOrdersWithoutBills');
    $cronDeleteNeobrabOrdersDomainsWithoutBills = GetSetting('cronDeleteNeobrabOrdersDomainsWithoutBills');
    $cronDeleteOrder = GetSetting('cronDeleteOrder');
    $cronDeleteOrderDay = GetSetting('cronDeleteOrderDay');
    $cronAutoDelete = GetSetting('cronAutoDelete');
    $cronDeleteOrderDomain = GetSetting('cronDeleteOrderDomain');
    $cronDeleteOrderDomainDay = GetSetting('cronDeleteOrderDomainDay');
    $cronCloseTickets = GetSetting('cronCloseTickets');
    $cronCloseTicketsDay = GetSetting('cronCloseTicketsDay');
    $cronDeleteTickets = GetSetting('cronDeleteTickets');
    $cronDeleteTicketsDay = GetSetting('cronDeleteTicketsDay');
    $cronDeleteUserLogs = GetSetting('cronDeleteUserLogs');
    $cronDeleteUserLogsDay = GetSetting('cronDeleteUserLogsDay');
    $cronDeleteAdminLogs = GetSetting('cronDeleteAdminLogs');
    $cronDeleteAdminLogsDay = GetSetting('cronDeleteAdminLogsDay');
    $cronSendClientEndOrderShopRemind = GetSetting('cronSendClientEndOrderShopRemind');
    $cronSendClientEndOrderShopRemindDays = GetSetting('cronSendClientEndOrderShopRemindDays');
    $cronDeleteNeobrabOrdersShopWithoutBills = GetSetting('cronDeleteNeobrabOrdersShopWithoutBills');
    $cronDeleteOrderShop = GetSetting('cronDeleteOrderShop');
    $cronDeleteOrderShopDay = GetSetting('cronDeleteOrderShopDay');
    $cronSendClientEndTestRemind = GetSetting('cronSendClientEndTestRemind');
    $cronSendClientEndTestRemindDays = GetSetting('cronSendClientEndTestRemindDays');
    
    $autoRenewEnable=GetSetting("autoRenewEnable");
    $autoRenewClientChange=GetSetting("autoRenewClientChange");
    $autoRenewDay=GetSetting("autoRenewDay");
    $autoRenewDomainDay=GetSetting("autoRenewDomainDay");
    $autoRenewShopDay=GetSetting("autoRenewShopDay");
    
    $attachPDFtoBill = GetSetting("attachPDFtoBill");
    
    $cronSendClientEndTestRemind = GetSetting('cronSendClientEndTestRemind');
    $cronSendClientEndTestRemindDays = GetSetting('cronSendClientEndTestRemindDays');
    $cronAutoDeleteTest = GetSetting('cronAutoDeleteTest');
    
    
    
    if ($cronCloseTickets and intval($cronCloseTicketsDay) > 0) {
    
    и так дальше с каждой переменной ~ 1500 строк кода

    Равшан,где сериализация?
    Где сериализация кодя я тебя спашиваю?!

    - Где сериализация, насяльника, где?

    tertychniy, 23 Сентября 2011

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

    +159

    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
    <?
    session_set_cookie_params(86400);
    session_start();
    
    $full_home_path = dirname(__FILE__);
    require_once($full_home_path.'/_rootload.php');
    
    if ($do == "logout" and !$pass) {
            userLogOut();
            Header("Location: billing.php");
            exit;
    }
    
    if ($dh = opendir($full_home_path)) {
    	while (($my->xcsd31s = readdir($dh)) !== false) {
    		if (preg_match("/_rootconfig/ui",$my->xcsd31s) and $my->xcsd31s != "_rootconfig.php") {
    			$my->azazqwe2a = $my->xcsd31s;
    			break;
    		}
    	}
    	closedir($dh);

    Индусский быдлокод по русски.
    Таким мастерски написаным говнокодом пестрит все 8 мегабайт уйобища с гордым названием биллинг.

    tertychniy, 23 Сентября 2011

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

    +159

    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
    AddEventHandler("iblock", "OnAfterIBlockElementUpdate", Array("MyClass", "OnAfterIBlockElementUpdateHandler"));
    class MyClass
    {
        // создаем обработчик события "OnAfterIBlockElementUpdate"
        function OnAfterIBlockElementUpdateHandler(&$arFields)
        {
    //привязка элементов (формирование комплектов)
    if(CModule::IncludeModule('iblock')){
    $id=$arFields['ID'];
    $i=0;
    $komplekt=array();
    $elements=array();
    $db_props = CIBlockElement::GetProperty(24, $id, "sort", "asc", Array("CODE"=>"KOMPLEKT"));
    while($ar_props = $db_props->Fetch()){
    $i++;
    $komplekt[$i]=$ar_props["VALUE"];
    }
    for($j=1; $j<=$i; $j++){
    $elements[$komplekt[$j]][0]=$id;
    for($k=1; $k<=$i; $k++){
    if($komplekt[$j]!=$komplekt[$k]){
    $elements[$komplekt[$j]][$k]=$komplekt[$k];
    }
    }
    }
    for($z=1; $z<=$i; $z++){
    CIBlockElement::SetPropertyValueCode($komplekt[$z], "KOMPLEKT", $elements[$komplekt[$z]]);
    }
    }
    //автоматически добавляем скидку в торговом каталоге
    if(CModule::IncludeModule('iblock')&& CModule::IncludeModule('catalog')){
    $discount10=array();
    $discount15=array();
    $discount20=array();
    $dbProductDiscounts = CCatalogDiscount::GetDiscountProductsList(
    array(),
    array(),
    false,
    false,
    array()
    );
    while ($arProductDiscounts = $dbProductDiscounts->Fetch())
    {
    if($arProductDiscounts['DISCOUNT_ID']==5){
    $discount10[]=$arProductDiscounts['PRODUCT_ID'];
    }
    if($arProductDiscounts['DISCOUNT_ID']==6){
    $discount15[]=$arProductDiscounts['PRODUCT_ID'];
    }
    if($arProductDiscounts['DISCOUNT_ID']==7){
    $discount20[]=$arProductDiscounts['PRODUCT_ID'];
    }
    }
    $db_props2 = CIBlockElement::GetProperty(24, $id, "sort", "asc", Array("CODE"=>"SALE"));
    while($ar_props2 = $db_props2->Fetch()){
    
    if(!in_array($id, $discount10) && $ar_props2['VALUE']==66){
    $discount10[]=$id;
    }
    if(in_array($id, $discount10) && $ar_props2['VALUE']==""){
    $num=count($discount10);
    for($i=0; $i<$num; $i++){
    if($discount10[$i]==$id){
    unset($discount10[$i]);
    }
    }
    }
    if(!in_array($id, $discount15) && $ar_props2['VALUE']==67){
    $discount15[]=$id;
    }
    if(in_array($id, $discount15) && $ar_props2['VALUE']==""){
    $num=count($discount15);
    for($i=0; $i<$num; $i++){
    if($discount15[$i]==$id){
    unset($discount15[$i]);
    }
    }
    }
    if(!in_array($id, $discount20) && $ar_props2['VALUE']==68){
    $discount20[]=$id;
    }
    if(in_array($id, $discount20) && $ar_props2['VALUE']==""){
    $num=count($discount20);
    for($i=0; $i<$num; $i++){
    if($discount20[$i]==$id){
    unset($discount20[$i]);
    }
    }
    }
    }
    if($discount10){
    CCatalogDiscount::Update(5, array("ACTIVE"=>"Y", "PRODUCT_IDS"=>$discount10));
    }
    else{
    CCatalogDiscount::Update(5, array("ACTIVE"=>"N"));
    }
    if($discount15){
    CCatalogDiscount::Update(6, array("ACTIVE"=>"Y", "PRODUCT_IDS"=>$discount15));
    }
    else{

    Оригинальное форматирование кода сохранено. Код до 7-ой строчки - копипаста из документации. Жаль все не влезло, шедевр

    inside, 23 Сентября 2011

    Комментарии (15)
  8. Python / Говнокод #7956

    −181

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    def main():
        iface = "eth0:"
        f = open("/proc/net/dev","r")
        lines = f.readlines()
        f.close()
        x = 0
        r = '\s+'+iface+'\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+'
        while x < len(lines):
            result = re.match(r, lines[x])
            print result
            x +=1

    Мсье знает толк в регулярках

    cutwater, 23 Сентября 2011

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

    +148

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    public List<OrderEntity> getOrders() {
        if (orders == null) {
            orders = new ArrayList<OrderEntity>();
        }
        return orders;
    }

    Потокобезопасность? Не, не слышал.

    roman-kashitsyn, 23 Сентября 2011

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

    +85

    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
    nLen = m_aRealTexts[index].m_txtString.length();
    for (int iyhx = 0; iyhx < nLen; iyhx++) {
    	cLetter = m_aRealTexts[index].m_txtString.charAt(iyhx);
    	CTxtCharStyle pCharNode = new CTxtCharStyle(cLetter);
    	pCharNode.SetTxtFontFace(m_nFontFace);
    	m_aRealTexts[index].m_txtChars.add(pCharNode);
    }
    
    ...
    
    
    public void SetTxtFontFace(byte nType)
    {
    	String sLine, sTemp;
    	int nMark;
    	float xValue, yValue;		//笔画点位的临时坐标
    	byte bIsBigChar = 0;		//1表示ANSI字体UserArial_ansi.uft,2表示Unicode字体UserArial_unicode.uft,3表示宋体hztxt1.shx
    	m_cStroke.clear();			//清空笔画路径链表
    	
    	if(nType == 1)
    	{
    		if((int)m_cChar<0x7F || ((int)m_cChar>=0x2160&&(int)m_cChar<=0x2169))
    		{
    			//按Unicode编码顺序处理字符查找指定字库文件,避免读取不必要的字库文件
    			InputStream fInFile = this.getClass().getResourceAsStream("/TagResources/UserArial_ansi.uft");
    			
    			...
    			
    			fInFile.close();
    		}
    		else if((int)m_cChar>=0x007F && (int)m_cChar<0x2FFF)
    		{
    			//字符在UserArial_ansi.uft中未找到,看是否在UserArial_unicode.uft中
    			int nGetByte;
    			sLine = new String("");
    			sTemp = new String("");
    			//float xValue, yValue;
    			byte[] CharUnicode = new byte[2];			//一次读取两个字节,为一个字符
    			byte[] cBytes = new byte[2];
    			InputStream fInFile = this.getClass().getResourceAsStream("/TagResources/UserArial_unicode.uft");
    			while((nGetByte = fInFile.read(cBytes, 0, 2)) > 0)
    			{
    				...
    			}
    			fInFile.close();
    		}
    		else if((int)m_cChar>=0x3000)
    		{
    			//字符在西文字库UserArial.uft中未找到,是大字体,则在宋体文件hztxt1.shx中查找
    			m_cWidth = 112.0f;	//对于宋体,左下角点为坐标原点,包围盒长宽皆为127,调整量为(127-112)/2=5
    			m_cHeight = 112.0f;
    			byte nMoveDown = 5;
    			InputStream fInFile = this.getClass().getResourceAsStream("/TagResources/hztxt1.shx");
    			
    			...
    			
    			fInFile.close();
    		}
    		else if(bIsBigChar == 0)
    		{
    			//仍然没有找到字符字体,则按空格处理
    			m_cWidth = 12.0f;
    			m_cHeight = 16.0f;
    			m_cStroke.clear();
    		}
    	}
    	else if(nType == 2)
    	{
    		try
    		{
    			
    			InputStream fInFile = this.getClass().getResourceAsStream("/TagResources/hztxt1.shx");
    			
    			...
    			
    			fInFile.close();
    			
    		}
    		catch(IOException e)
    		{
    			//异常处理
    			e.printStackTrace();
    		}
    	}
    }

    Ещё один отжиг господ китайцев.

    Магические числа вместо энумов и закрытие файлов вне finally - это ещё полбеды. Больше всего умиляет, что при каждой отрисовке отдельно для каждой буквы файл шрифта открывается и сканируется по новой. Неудивительно, что отрисовка так тормозит. Буду переписывать это дело - загружать глифы из файла один раз и затем дёргать их из кэша.

    lucidfox, 23 Сентября 2011

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