=()= / Говнокод #1854 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
sub inet_aton{
  my $n_ip;
  $sth1 = $dbh->prepare("SELECT inet_aton(\"$_[0]\") as inet_aton");
  $sth1->execute();
  while (my $ips = $sth1->fetchrow_hashref()) {
    $n_ip = "$ips->{'inet_aton'}";
  };
  $sth1->finish();
  return $n_ip;
};

вот так в одном коммерческом продукте получают ip-адрес в виде int'а

Mihard Mihard, (Updated )

Комментарии (20, +20)

=()= / Говнокод #1675 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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
if ( $in{s} )
{

#	максимальная вложенность =3 - сформируем строку для чекбокса по-простому 
	my %ha = db_select_row [ 'id', 'title', 'parent_id' ], "catalog_section", "id=$in{s}			AND `object_id`=1";
	if (%ha)    																				          		    ¦
	{           																				          			¦
		$selected_only[ $ha{parent_id} ] = 'selected';    										          			
	}    																						              		¦
	     																						          			¦
	my %parent = db_select_row [ 'title', 'parent_id' ], "catalog_section",  "id=$ha{parent_id}		AND `object_id`=1";
	my %parent2 = db_select_row [ 'title', 'parent_id' ], "catalog_section", "id=$parent{parent_id}	AND `object_id`=1";
	my $only_title = $ha{title};

	$only_title = "$parent{title} — $only_title"  if %parent;
	$only_title = "$parent2{title} — $only_title" if %parent2;
	$only_this_cat_string = "";

	if ( %parent || %parent2 )
	{

		#%ha
		$only_this_category_text = qq~
			<span>
				<input type="checkbox" name="only_this_cat" id="only_this_cat" $checked_only onchange="checkSelect();">
				<label for="only_this_cat">Искать только в разделе «$only_title»</label>
			</span>~;

	}
}

по-простому

nolka4 nolka4, (Updated )

Комментарии (3, +3)

=()= / Говнокод #1644 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
#Пример раз
	my %parse_hash = (
		$sub_dir       => $dir,
		$sub_style_dir => $style_dir,
		$sub_image_dir => $image_dir
	);


#Пример два
...
elsif ($event eq $Event_View_Par){
  print &ViewPar(%Query);
}
elsif ($event eq $Event_View_All){
  print &ViewPar(%Query);
}
elsif ($event eq $Event_View_Asset){
  print &ViewAsset(%Query);
}

Пример 1: В качестве ключей хэша переменные, которые определены в другом файле.
Пример 2: переменные $Event_View* определены в другом, используются только здесь и больше нигде

И так по всему коду
Задалбывает всё время переключаться alt-табом на файл, смотреть на определение переменных

Oleg_quadro Oleg_quadro, (Updated )

Комментарии (4, +4)

=()= / Говнокод #1605 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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
$in{item_name}=CGI::unescape($in{item_name});
$in{item_number}=CGI::unescape($in{item_number});

#убиваем пробелы сначала, с конца и двойные
###
if($in{item_name}=~/^[\s]+([\s\S]+)/) {
  $in{item_name}=$1;
}
if($in{item_name}=~/([\s\S]+)[\s]+$/) {
  $in{item_name}=$1;
}

$in{item_name}=~s/[\s]{2,}/ /g;
  
if($in{item_number}=~/^[\s]+([\s\S]+)/) {
  $in{item_number}=$1;
}
if($in{item_number}=~/([\s\S]+)[\s]+$/) {
  $in{item_number}=$1;
}

$in{item_number}=~s/[\s]{2,}/ /g;
####

my @select_parent=db_select_list ['title','id'],"catalog_section","parent_id=0";



###########
my $only_this_category_text;
my $checked_only;
if($in{action} eq 'filter' and !$in{only_this_cat}) { $checked_only=''; } else {$checked_only="checked"; }

#############################
my $selected_list_item;
my $only_this_cat_string;
my @selected_only;
my $selected_parent;
#die $in{only_this_cat_s};


for(@select_parent)
{my $name="index_sel_$$_{id}";
 if($in{action} eq 'filter' and ($in{only_this_cat_s} eq $$_{id})) {$selected_only[$$_{id}]='selected'; } else { $selected_only[$$_{id}]=''; }
 if(!$in{only_this_cat_s})
 { if(!$in{action} and ($in{s} eq $$_{id})) {$selected_only[$$_{id}]='selected'; } else { $selected_only[$$_{id}]=''; }
 }else{ if($in{only_this_cat_s} eq $$_{id}){ $selected_only[$$_{id}]='selected';}}
}


############################


if($in{s}) {

#максимальная вложенность =3 - сформируем строку для чекбокса по-простому
  my %ha=db_select_row ['id','title','parent_id'],"catalog_section","id=$in{s}";
 if(%ha){$selected_only[$ha{parent_id}]='selected';}
	my %parent=db_select_row ['title','parent_id'],"catalog_section","id=$ha{parent_id}";
  my %parent2=db_select_row ['title','parent_id'],"catalog_section","id=$parent{parent_id}";	
	my $only_title=$ha{title};
	
	$only_title= "$parent{title} — $only_title" if %parent;
	$only_title= "$parent2{title} — $only_title" if %parent2;
  $only_this_cat_string=""; 
	if(%parent || %parent2) {#%ha
      $only_this_category_text=qq~
			<span>
			<input type="checkbox" name="only_this_cat" id="only_this_cat" $checked_only onchange="checkSelect();">
			<label for="only_this_cat">Искать только в разделе «$only_title»</label>
			</span>~;
			    	
	}
	}
	
	
$selected_list_item=qq~<select name="only_this_cat_s" id="only_this_cat_s"> <OPTION VALUE='none'>Все разделы</OPTION>~;
										for(@select_parent)
										{
$selected_list_item.=qq~<OPTION VALUE='$$_{id}' $selected_only[$$_{id}]~;
$selected_list_item.=qq~><label for="only_this_cat_s">$$_{title}</label>
                        </OPTION>~;
										
										}
$selected_list_item.=qq~</select></td>~;
$only_this_cat_string="Раздел каталога";

Оригинальное форматирование сохранено

nolka4 nolka4, (Updated )

Комментарии (4, +4)

=()= / Говнокод #1530 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
my $cache_sql="SELECT `content`, `insertTime` FROM _cache WHERE `confid`='$$conf{confid}'";
...
    $cache_sql.=" AND `location`=".$self->{dbh}->quote($url);
...
    $cache_sql.=" AND `cgiparams`=".$self->{dbh}->quote($cgi_hash);
...
    $cache_sql.=" AND `callparams`=".$self->{dbh}->quote($callp_hash);
...
    $cache_sql.=" AND `userid`=".int($$params{userid});
...
    $cache_sql.=" AND `groupid`=".int($$params{groupid});

   my $replace_sql=$cache_sql;
   $replace_sql=~s/SELECT.*?FROM\s+_cache\s+WHERE/REPLACE INTO _cache SET/s;

perl+sql

poltora poltora, (Updated )

Комментарии (1, +1)

=()= / Говнокод #1529 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
my $iref=$self->{ditems}->_get_item({itemid=>$weather_itemid, set=>'Weather', fields=>['MinT', 'MaxT', 'Precip', 'Cloud', 'twater'], prefix=>$$p{prefix}});
    if ($$iref{$$p{prefix}.'MinT'}<0 && $$iref{$$p{prefix}.'MaxT'}<=0) {
        my $tmp=$$iref{$$p{prefix}.'MaxT'};
        $$iref{$$p{prefix}.'MaxT'}=$$iref{$$p{prefix}.'MinT'};
        $$iref{$$p{prefix}.'MaxT'}=$tmp;
    };
    #warn $$iref{$$p{prefix}.'MinT'} if !$$iref{$$p{prefix}.'MinT'}>0;
    $$iref{$$p{prefix}.'T'}=int( ($$iref{$$p{prefix}.'MinT'}+$$iref{$$p{prefix}.'MaxT'})/2 );
    $$iref{$$p{prefix}.'T'}='+'.$$iref{$$p{prefix}.'T'} if $$iref{$$p{prefix}.'T'}>0;
    #$$iref{$$p{prefix}.'T'}=~s/\-/\&\#150\;/gs;
    $$iref{$$p{prefix}.'MinT'}='+'.$$iref{$$p{prefix}.'MinT'} if ($$iref{$$p{prefix}.'MinT'}>0);
    $$iref{$$p{prefix}.'MaxT'}='+'.$$iref{$$p{prefix}.'MaxT'} if ($$iref{$$p{prefix}.'MaxT'}>0);
    $$iref{$$p{prefix}.'twater'}='+'.$$iref{$$p{prefix}.'twater'} if ($$iref{$$p{prefix}.'twater'}>0);
    
    $$iref{$$p{prefix}.'time'}=$$p{daystart}+$$p{hour}*3600;

poltora poltora, (Updated )

Комментарии (1, +1)

=()= / Говнокод #1519 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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
#!/etc/Tivoli/bin/perl
##############################################################
#  Name: Default.cgi
#
#  Description: Generates translated Default HTML page
#               according to browser's language
#  TMF 4.1
#  Licensed Materials- Property of IBM
#  (C) Copyright IBM Corp. 2000. All Rights Reserved
#
#  US Government Users Restricted Rights- Use, duplication,
#  or disclosure restricted by GSA ADP Schedule Contract with
#  IBM Corp.
##############################################################

# wupddefhtml will bind all messages contained in default page
# accordingly ( LANG is set to the browser's locale )

$defaultPage=`wupddefhtml -out`;

# all links in the default page are absolute or relative to root
# so we need to fix them because we have changed location

$defaultPage =~ s|href=|href=../|g;
$defaultPage =~ s|//|/|g;

print("HTTP/1.0 200 OK
Contents-Type: text/html

");

print "$defaultPage";

строка print("HTTP/1.0 200 OK
явно говорит о глубоких знаниях протокола :))
(C) Copyright IBM Corp. - ИТ лидер - что еще сказать

pdp_dp pdp_dp, (Updated )

Комментарии (10, +10)