- 1
- 2
- 3
- 4
- 5
- 6
- 7
/**
*
* @class admin_members_members_members
* @brief Provides methods to deal with the members management for administrators
*/
class admin_members_members_members extends ipsCommand
{
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
Всего: 17
+65
/**
*
* @class admin_members_members_members
* @brief Provides methods to deal with the members management for administrators
*/
class admin_members_members_members extends ipsCommand
{
Это из форума IPB
+161
function validate() {
var at = document.getElementById("email").value.indexOf("@");
var age = document.getElementById("age").value;
var fname = document.getElementById("fname").value;
submitOK = "true";
if (fname.length > 10) {
alert("Имя не должно содержать более 10 знаков");
submitOK = "false";
}
if (isNaN(age) || age < 1 || age > 100) {
alert("Возраст должен быть от 1 до 100");
submitOK = "false";
}
if (at == -1) {
alert("Неправильный e-mail");
submitOK = "false";
}
if (submitOK == "false") {
return false;
}
}
Джордж Буль в гробу перевернулся.
+106
procedure FirstStep (var Text: string);
// Удаление комментариев <!--...-->, переводов строк, раскрытие тегов <br>, удаление парных пробелов:
var
P: Integer;
State: Integer;
Idx: Integer;
Cnt: Integer;
NL: Boolean;
begin
State := 0;
P := 1;
NL := True;
while P <= Length (Text) do
begin
if Text[P] in [#9,#10,#13] then Text[P] := ' ';
case State of
0: case Text[P] of
'<': State := 1;
' ': begin
Idx := P;
State := 9;
end; { }
else NL := False;
end; {case}
1: case Text[P] of
'!': State := 2;
'b': State := 7;
else
begin
Dec (P);
State := 10;
end; {else}
end; {case}
2: if Text[P] <> '-' then
begin
Dec (P);
State := 10;
end else State := 3;
3: if Text[P] = '-' then
begin
Idx := P - 3;
State := 4;
end else
begin
Dec (P);
State := 10;
end; {if}
4: if Text[P] = '-' then State := 5;
5: if Text[P] = '-' then State := 6 else State := 4;
6: if Text[P] = '>' then
begin
Delete (Text, Idx, P - Idx + 1);
P := Idx - 1;
while (P >= 1) and (Text[P] = ' ') do Dec (P);
State := 0;
end else State := 4;
7: if Text[P] = 'r' then State := 8 else State := 0;
8: begin
if Text[P] = '>' then
begin
Text[P-3] := #13;
Text[P-2] := #10;
Delete (Text, P - 1, 2);
Dec (P, 2);
NL := True;
end; {if}
State := 0;
end; {8}
9: if Text[P] <> ' ' then
begin
Cnt := P - Idx;
if NL then
begin
Delete (Text, Idx, Cnt);
Dec (Idx);
end else if Cnt > 1 then Delete (Text, Idx, Cnt - 1);
P := Idx;
State := 0;
end; {if}
10: if Text[P] = '>' then State := 0;
end; {case}
Inc (P);
end; {while}
end; {proc FirstStep}
Кусок парсера HTML.
−155
$??s:;s:s;;$?::s;;=]=>%-{<-|}<&|`{;;y; -/:-@[-`{-};`-{/" -;;s;;$_;see
+131
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Билайн анкетирование</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="Билайн анкетирование">
<meta name="keywords" content="Билайн анкетирование">
<link href="/stylesheets/main_stl.css" type=text/css rel=stylesheet>
<script src="/javascripts/jquery-1.4.2.min.js" language="javascript"></script>
<script src="/javascripts/jquery.maskedinput-1.2.2.min.js" language="javascript"></script>
<script src="/javascripts/custom/masked.js" language="javascript"></script>
</head>
<body>
<table id=main cellspacing=0 cellpadding=0 border=0>
<!-- HEAD -->
<tr>
<td style="height:128px; text-align:center;" align=center>
<table style="height:128px; width:798px; margin:0px auto;" cellspacing=0 cellpadding=0 border=0><tr>
<td style="padding-top:70px; padding-left:32px; vertical-align:top; width:681px;"><img src="/images/beetitle.png"></td>
<td style="padding-top:33px; vertical-align:top; width:117px;"><img src="/images/beelogo.png"></td>
</tr></table>
</td>
</tr>
<!-- BODY -->
<tr>
<td style="text-align:center;" valign=top align=center>
...
Это от сюда: http://opros-beeline.ru/login
Интересный у них там XHTML
−121
sub captcha {
my $msg = $_[0];
## make colors for validation image into hex again ##
$rgb_foreground =~ s/\#//g;
$rgb_shade =~ s/\#//g;
$rgb_background =~ s/\#//g;
$r_f = substr($rgb_foreground,0,2);
$g_f = substr($rgb_foreground,2,2);
$b_f = substr($rgb_foreground,4,2);
$r_s = substr($rgb_shade,0,2);
$g_s = substr($rgb_shade,2,2);
$b_s = substr($rgb_shade,4,2);
$r_b = substr($rgb_background,0,2);
$g_b = substr($rgb_background,2,2);
$b_b = substr($rgb_background,4,2);
// Тут я вырезал кусок никчемного кода
$ci{' '} = qq~
.......
.......
.......
.......
.......
.......
.......
.......
.......
.......
~;
$ci{'!'} = qq~
.......
...X...
...X...
...X...
...X...
...X...
.......
...X...
.......
.......
~;
$ci{'"'} = qq~
.......
..X.X..
..X.X..
..X.X..
.......
.......
.......
.......
.......
.......
~;
$ci{'#'} = qq~
.......
..X.X..
..X.X..
.XXXXX.
..X.X..
.XXXXX.
..X.X..
..X.X..
.......
.......
~;
$ci{'$'} = qq~
.......
...X...
..XXXX.
.X.X...
..XXX..
...X.X.
.XXXX..
...X...
.......
.......
~;
// Дальше идет вся таблица ASCII
Вот таким вот образом выводили каптчу в далеком 2009 году. Очень надежный метод :)
−122
sub generate_code {
my ($arrey_pos,$code);
my @arrey = ('a'..'q', 'C'..'O', '1'..'9', 'g'..'u', 'l'..'z', '9'..'1', 'H'..'W');
for (my $i = 0; $i < $_[0]; $i++) {
$arrey_pos = int(rand($#arrey));
$code .= $arrey[$arrey_pos];
}
$code;
}
Генерация кода.
−155
sub write_cookie {
my %params = @_;
if ($params{'-expires'} =~ /\+(\d+)m/) {
my ($sec, $min, $hour, $mday, $mon, $year, $wday) = gmtime($date + $1 * 60);
$year += 1900;
my @mos = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
my @dys = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
$mon = $mos[$mon];
$wday = $dys[$wday];
$params{'-expires'} = sprintf("%s, %02i-%s-%04i %02i:%02i:%02i GMT", $wday, $mday, $mon, $year, $hour, $min, $sec);
}
$params{'-path'} = " path=$params{'-path'};" if $params{'-path'};
$params{'-expires'} = " expires=$params{'-expires'};" if $params{'-expires'};
"$params{'-name'}=$params{'-value'};$params{'-path'}$params{'-expires'}";
}
setcookie() Perl-вариант.
−119
sub mainMenu {
if ($action eq "addtab" && $iamadmin) { require "$sourcedir/AdvancedTabs.pl"; &AddNewTab; }
elsif ($action eq "edittab" && $iamadmin) { require "$sourcedir/AdvancedTabs.pl"; &EditTab; }
elsif ($action ne "") {
if ($action eq "search2") {
$tmpaction = "search";
} elsif ($action eq "favorites" || $action eq "shownotify" || $action eq "im" || $action eq "imdraft" || $action eq "imoutbox" || $action eq "imstorage" || $action eq "imsend" || $action eq "imsend2" || $action eq "imshow" || $action eq "profileCheck" || $action eq "myviewprofile" || $action eq "myprofile" || $action eq "myprofileContacts" || $action eq "myprofileOptions" || $action eq "myprofileBuddy" || $action eq "myprofileIM" || $action eq "myprofileAdmin" || $action eq "myusersrecentposts") {
$tmpaction = "mycenter";
} elsif ($action eq "messagepagetext" || $action eq "messagepagedrop" || $action eq "threadpagetext" || $action eq "threadpagedrop" || $action eq "post" || $action eq "notify" || $action eq "boardnotify" || $action eq "sendtopic" || $action eq "modify") {
$tmpaction = "home";
} elsif ($action eq "guestpm2") {
$tmpaction = "guestpm";
} else { $tmpaction = $action; }
} else {
$tmpaction = "home";
}
$tab{'home'} = qq~<span |><a href="$scripturl" title = "$img_txt{'103'}" style="padding: 3px 0 4px 0;">$tabfill$img_txt{'103'}$tabfill</a></span>~;
$tab{'help'} = qq~<span |><a href="$scripturl?action=help" title = "$img_txt{'119'}" style="padding: 3px 0 4px 0; cursor:help;">$tabfill$img_txt{'119'}$tabfill</a></span>~;
if ($maxsearchdisplay > -1) {
$tab{'search'} = qq~<span |><a href="$scripturl?action=search" title = "$img_txt{'182'}" style="padding: 3px 0 4px 0;">$tabfill$img_txt{'182'}$tabfill</a></span>~;
}
if (!$ML_Allowed || ($ML_Allowed == 1 && !$iamguest) || ($ML_Allowed == 2 && $staff) || ($ML_Allowed == 3 && ($iamadmin || $iamgmod))) {
$tab{'ml'} = qq~<span |><a href="$scripturl?action=ml" title = "$img_txt{'331'}" style="padding: 3px 0 4px 0;">$tabfill$img_txt{'331'}$tabfill</a></span>~;
}
if ($iamadmin) {
$tab{'admin'} = qq~<span |><a href="$boardurl/AdminIndex.$yyaext" title = "$img_txt{'2'}" style="padding: 3px 0 4px 0;">$tabfill$img_txt{'2'}$tabfill</a></span>~;
}
if ($iamgmod) {
if (-e "$vardir/gmodsettings.txt") { require "$vardir/gmodsettings.txt"; }
if ($allow_gmod_admin) {
$tab{'admin'} = qq~<span |><a href="$boardurl/AdminIndex.$yyaext" title = "$img_txt{'2'}" style="padding: 3px 0 4px 0;">$tabfill$img_txt{'2'}$tabfill</a></span>~;
}
}
if ($sessionvalid == 0 && !$iamguest) {
my $sesredir;
unless (!$testenv || $action eq "revalidatesession" || $action eq "revalidatesession2") {
$sesredir = $testenv;
$sesredir =~ s/\=/\~/g;
$sesredir =~ s/;/x3B/g;
$sesredir = qq~;sesredir=$sesredir~;
}
$tab{'revalidatesession'} = qq~<span |><a href="$scripturl?action=revalidatesession$sesredir" title = "$img_txt{'34a'}" style="padding: 3px 0 4px 0;">$tabfill$img_txt{'34a'}$tabfill</a></span>~;
}
// далее мало что меняется в стиле...
Формируем меню...
−126
sub Tgetent {
local($TERM) = @_;
local($TERMCAP,$_,$entry,$loop,$field);
# warn "Tgetent: no ospeed set" unless $ospeed;
foreach $key (keys %TC) {
delete $TC{$key};
}
$TERM = $ENV{'TERM'} unless $TERM;
$TERM =~ s/(\W)/\\$1/g;
$TERMCAP = $ENV{'TERMCAP'};
$TERMCAP = '/etc/termcap' unless $TERMCAP;
if ($TERMCAP !~ m:^/:) {
if ($TERMCAP !~ /(^|\|)$TERM[:\|]/) {
$TERMCAP = '/etc/termcap';
}
}
if ($TERMCAP =~ m:^/:) {
$entry = '';
do {
$loop = "
open(TERMCAP,'<$TERMCAP') || die \"Can't open $TERMCAP\";
while (<TERMCAP>) {
next if /^#/;
next if /^\t/;
if (/(^|\\|)${TERM}[:\\|]/) {
chop;
while (chop eq '\\\\') {
\$_ .= <TERMCAP>;
chop;
}
\$_ .= ':';
last;
}
}
close TERMCAP;
\$entry .= \$_;
";
eval $loop;
} while s/:tc=([^:]+):/:/ && ($TERM = $1);
$TERMCAP = $entry;
}
foreach $field (split(/:[\s:\\]*/,$TERMCAP)) {
if ($field =~ /^\w\w$/) {
$TC{$field} = 1;
}
elsif ($field =~ /^(\w\w)#(.*)/) {
$TC{$1} = $2 if $TC{$1} eq '';
}
elsif ($field =~ /^(\w\w)=(.*)/) {
$entry = $1;
$_ = $2;
s/\\E/\033/g;
s/\\(200)/pack('c',0)/eg; # NUL character
s/\\(0\d\d)/pack('c',oct($1))/eg; # octal
s/\\(0x[0-9A-Fa-f][0-9A-Fa-f])/pack('c',hex($1))/eg; # hex
s/\\(\d\d\d)/pack('c',$1 & 0177)/eg;
s/\\n/\n/g;
s/\\r/\r/g;
s/\\t/\t/g;
s/\\b/\b/g;
s/\\f/\f/g;
s/\\\^/\377/g;
s/\^\?/\177/g;
s/\^(.)/pack('c',ord($1) & 31)/eg;
s/\\(.)/$1/g;
s/\377/^/g;
$TC{$entry} = $_ if $TC{$entry} eq '';
}
}
$TC{'pc'} = "\0" if $TC{'pc'} eq '';
$TC{'bc'} = "\b" if $TC{'bc'} eq '';
}
Гениальный код.