- 1
- 2
- 3
- 4
- 5
- 6
try {
throw new Exception("TRANSACTION IS OPENED");
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−89
try {
throw new Exception("TRANSACTION IS OPENED");
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
реальный проект
+160
<?
function dbQuery($query)
{
$arg = func_get_args();
unset($arg[0]);
for ($i=1; $i<sizeof($arg); $i++) {
$arg[$i] = mysql_real_escape_string($arg[$i]);
}
$sql = vsprintf($query, $arg);
return mysql_query($sql) or die (mysql_error());
}
+161
<?php
if(empty($mw))
{
header ("Location: ..");
exit;
}
?>
<center><h4>АККАУНТ</H4><hr>
<...>
<script type="text/javascript">//<![CDATA[
function isAlphaNumeric(value)
{
if (value.match(/^[a-zA-Z0-9]+$/))
return true;
else
return false;
}
function checkform(f)
{
if (f.account.value=="")
{
alert("Заполните все поля формы");
return false;
}
if (!isAlphaNumeric(f.account.value))
{
alert("Заполните все поля формы");
return false;
}
if (f.password.value=="")
{
alert("Не введен пароль");
return false;
}
if (!isAlphaNumeric(f.password.value))
{
alert("444444");
return false;
}
if (f.password2.value=="")
{
alert("Не введен повтор пароля");
return false;
}
if (f.password.value!=f.password2.value)
{
alert("Не совпадает пароль");
return false;
}
return true;
}
//]]></script>
<form method="post" action="index.php?id=reg_false" onsubmit="return checkform(this)">
<table>
<tr>
<td>Логин</td>
<td><input type="text" name="account" maxlength="15" /></td>
</tr>
<tr>
<td>Пароль</td>
<td><input type="password" name="password" maxlength="15" /></td>
</tr>
<tr>
<td>Повторить пароль</td>
<td><input type="password" name="password2" maxlength="15" /></td>
</tr>
<tr>
<td colspan="2" style="text-align: center;"><br />
<input type="submit" name="submit" value="Регистрация" /></td>
</tr>
</table>
</form>
<?php
if(ereg("^([a-zA-Z0-9_-])*$", $_POST['account']) && ereg("^([a-zA-Z0-9_-])*$", $_POST['password']) && ereg("^([a-zA-Z0-9_-])*$", $_POST['password2']))
{
if ($page="index.php" && $_POST['account'] && strlen($_POST['account'])<16 && strlen($_POST['account'])>3 && $_POST['password'] && $_POST['password2'] && $_POST['password']==$_POST['password2'])
{
$check=mysql_query("select * from accounts where login='".$_POST['account']."'");
$check1=mysql_num_rows($check);
if($check1>0)
echo "<p clss='error'><b>Ошибка при регистрации: такой аккаунт уже сущетвует.</b></p>";
else
{
mysql_query("INSERT INTO accounts (login, password, access_level) VALUES ('" .
$_POST['account']."', '".base64_encode(pack('H*', sha1($_POST['password'])))."', 0)", $link);
mysql_close($link);
print '<p class="error"><b>Регистрация прошла успешно</b></p>';
}
}
else
print '<p class="error"><b> </b></p>'.mysql_error();
}
else
echo "Введенные вами данные не прошли проверку на безопасность. Пожалуйста, попробуйте зарегистрироваться с другим логином и паролем.";
+172
//уничтожение буфера
void delbuf(void* &bf, char ntype)
{
if (ntype=='C')
{
if (bf!=(char*) NULL)
{
delete[] bf;
bf=NULL;
}
return;
}
if (ntype=='B')
{
if (bf!=(BYTE*) NULL)
{
delete[] bf;
bf=NULL;
}
return;
}
if (ntype=='I')
{
if (bf!=(int*) NULL)
{
delete[] bf;
bf=NULL;
}
return;
}
if (ntype=='F')
{
if (bf!=(double*) NULL)
{
delete[] bf;
bf=NULL;
}
return;
}
if (ntype=='D')
{
if (bf!=(double*) NULL)
{
delete[] bf;
bf=NULL;
}
return;
}
if (ntype=='W')
{
if (bf!=(WORD*) NULL)
{
delete[] bf;
bf=NULL;
}
return;
}
if (ntype=='L')
{
if (bf!=(long*) NULL)
{
delete[] bf;
bf=NULL;
}
return;
}
if (ntype=='S')
{
if (bf!=(short*) NULL)
{
delete[] bf;
bf=NULL;
}
return;
}
if (ntype=='R')
{
if (bf!=(DWORD*) NULL)
{
delete[] bf;
bf=NULL;
}
return;
}
return;
}
86 строк вместо простого delete [] bf
+136
while (f != null && !string.IsNullOrEmpty(f.FileName) && f.ContentLength != 0)
{
if (f != null && !string.IsNullOrEmpty(f.FileName) && f.ContentLength != 0)
{
// ...
}
}
Проверка на всякий случай
+161
<style type="text/css" media="all">
@import url(http://static.lanzone.info/templates/Default/css/style.css);
</style>
<style type="text/css" media="all">
@import url(http://static.lanzone.info/templates/Default/css/engine.css);
</style>
Bitches dunno 'bout mah <link rel="stylesheet"
+158
// TEMPLATE FUNCTION rotate
template<class _FI> inline
void rotate(_FI _F, _FI _M, _FI _L)
{if (_F != _M && _M != _L)
_Rotate(_F, _M, _L, _Iter_cat(_F)); }
template<class _FI> inline
void _Rotate(_FI _F, _FI _M, _FI _L,
forward_iterator_tag)
{for (_FI _X = _M; ; )
{iter_swap(_F, _X);
if (++_F == _M)
if (++_X == _L)
break;
else
_M = _X;
else if (++_X == _L)
_X = _M; }}
template<class _BI> inline
void _Rotate(_BI _F, _BI _M, _BI _L,
bidirectional_iterator_tag)
{reverse(_F, _M);
reverse(_M, _L);
reverse(_F, _L); }
template<class _RI> inline
void _Rotate(_RI _F, _RI _M, _RI _L,
random_access_iterator_tag)
{_Rotate(_F, _M, _L, _Dist_type(_F), _Val_type(_F)); }
template<class _RI, class _Pd, class _Ty> inline
void _Rotate(_RI _F, _RI _M, _RI _L, _Pd *, _Ty *)
{_Pd _D = _M - _F;
_Pd _N = _L - _F;
for (_Pd _I = _D; _I != 0; )
{_Pd _J = _N % _I;
_N = _I, _I = _J; }
if (_N < _L - _F)
for (; 0 < _N; --_N)
{_RI _X = _F + _N;
_RI _Y = _X;
_Ty _V = *_X;
_RI _Z = _Y + _D == _L ? _F : _Y + _D;
while (_Z != _X)
{*_Y = *_Z;
_Y = _Z;
_Z = _D < _L - _Z ? _Z + _D
: _F + (_D - (_L - _Z)); }
*_Y = _V; }}
Header из Microshit Visual C++ 6.0.
+155
#if __STDC_WANT_SECURE_LIB__
_Check_return_wat_ _CRTIMP_ALTERNATIVE errno_t __cdecl wcscat_s(_Inout_z_cap_(_SizeInWords) wchar_t * _Dst, _In_ rsize_t _SizeInWords, _In_z_ const wchar_t * _Src);
#endif
__DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_1(errno_t, wcscat_s, _Deref_prepost_z_ wchar_t, _Dest, _In_z_ const wchar_t *, _Source)
__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_1(wchar_t *, __RETURN_POLICY_DST, _CRTIMP, wcscat, _Pre_cap_for_(_Source) _Prepost_z_, wchar_t, _Dest, _In_z_ const wchar_t *, _Source)
_Check_return_ _CRTIMP _CONST_RETURN wchar_t * __cdecl wcschr(_In_z_ const wchar_t * _Str, wchar_t _Ch);
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t * _Str1, _In_z_ const wchar_t * _Str2);
#if __STDC_WANT_SECURE_LIB__
_Check_return_wat_ _CRTIMP_ALTERNATIVE errno_t __cdecl wcscpy_s(_Out_z_cap_(_SizeInWords) wchar_t * _Dst, _In_ rsize_t _SizeInWords, _In_z_ const wchar_t * _Src);
#endif
Хедеры из Microshit Visual Studio. Там так почти везде...
+99
procedure TForm1.Timer1Timer(Sender: TObject);
var Ras, MinRas, MinC, Comp: Integer;
begin
Ras:=0;
MinC:=0;
MinRas:=0; // всё по нулям
for Comp:=0 to ComponentCount-1 do // цикл по всем компонентам
begin
IF (Components[Comp] is TPanel) and (Components[Comp] <> Panel1) and (Panel1.Left>TPanel(Components[Comp]).Left) then
Ras:=Panel1.Left-TPanel(Components[Comp]).Left
else
IF (Components[Comp] is TPanel) and (Components[Comp] <> Panel1) and (Panel1.Left<TPanel(Components[Comp]).Left) then
Ras:=TPanel(Components[Comp]).Left-Panel1.Left;
If Ras < MinRas
then begin
MinRas:= Ras; //устанавливаем переменные этой панельки за основные
MinC:= Comp;
end;
end;
if Panel1.top<(TPanel(Components[MinC]).Top-TPanel(Components[MinC]).Height) then
Panel1.Top:=Panel1.Top+3; //если панель ниже то допрыгиваем
PROBEL:=Panel1.Top=TPanel(Components[MinC]).Top-TPanel(Components[MinC]).Height
end;
какое-то панельное безумие
+75
public static String join(String delimiter, String... str) {
StringBuilder buffer = new StringBuilder();
for (String s : str) {
if (!"".equals(s)) {
if (buffer.length() != 0) {
buffer.append(delimiter);
}
buffer.append(s);
}
}
return buffer.toString();
}
String str = (H.join(" на ", category, H.join(" ", super.getMark().toUpperCase(), super.getModel().toUpperCase())) + " " + super.getFrame().toUpperCase() + " " + super.getEngine().toUpperCase()).trim();
чувак явно знает толк в извращениях