- 1
- 2
- 3
- 4
- 5
- 6
$send = mysql_query("INSERT INTO comments VALUES(NULL,'$postid','$text','$name','$email','$date')");
if ($send == 'true')
{
....
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+162
$send = mysql_query("INSERT INTO comments VALUES(NULL,'$postid','$text','$name','$email','$date')");
if ($send == 'true')
{
....
}
Еще кусок из Light CMS
+156
$postid = htmlspecialchars($_POST['postid']);
mysql_query("UPDATE posts SET comments = comments + 1 WHERE id = $postid");
Кусок из Light CMS :)
−106
public function Rotate():void
{
switch(type)
{
case 'line':
if (figure[0][1])
{
figure = [[1], [1], [1], [1]];
position.y += 1;
position.x -= 1;
}
else
{
figure = [[1, 1, 1, 1]];
position.y -= 1;
position.x += 1;
}
break;
case 'square':
return;
break;
case 'pyramide':
if (!figure[0][0] && figure[1][0] && figure.length == 2)
{
figure = [[0, 1], [1, 1], [0, 1]];
}
else if (!figure[0][0] && figure[0][1] && figure.length == 3)
{
figure = [[1, 1, 1], [0, 1, 0]];
}
else if (figure[0][0] && figure[0][1] && figure.length == 2)
{
figure = [[1, 0], [1, 1], [1, 0]];
}
else if (figure[0][0] && !figure[0][1] && figure.length == 3)
{
figure = [[0, 1, 0], [1, 1, 1]];
}
break;
case 'lL':
if (figure[0][0] && !figure[0][1])
figure = [[0, 0, 1], [1, 1, 1]];
else if (!figure[0][0] && !figure[0][1])
figure = [[1, 1], [0, 1], [0, 1]];
else if (figure[0][0] && figure[0][1] && figure.length == 3)
figure = [[1, 1, 1], [1, 0, 0]];
else if (figure[0][0] && figure[0][1] && figure.length == 2)
figure = [[1, 0], [1, 0], [1, 1]];
break;
case 'rL':
{
if (!figure[0][0] && figure[0][1])
figure = [[1, 0, 0], [1, 1, 1]];
else if (figure[0][0] && !figure[0][1])
figure = [[1, 1], [1, 0], [1, 0]];
else if (figure[0][0] && figure[0][1] && figure.length == 3)
figure = [[1, 1, 1], [0, 0, 1]];
else if (figure[0][0] && figure[0][1] && figure.length == 2)
figure = [[0, 1], [0, 1], [1, 1]];
}
break;
case 'lZ':
if (figure[0][0] && !figure[0][1])
figure = [[0, 1, 1], [1, 1, 0]];
else if (!figure[0][0] && figure[0][1])
figure = [[1, 0], [1, 1], [0, 1]];
break;
case 'rZ':
if (!figure[0][0] && figure[0][1])
figure = [[1, 1, 0], [0, 1, 1]];
else if (figure[0][0] && figure[0][1])
figure = [[0, 1], [1, 1], [1, 0]];
break;
}
}
"Поворот" фигур в тетрисе
+98
function Prime (N: longword): boolean;
var
i : longword;
Max : single;
begin
if N = 2
then Prime := true
else if (N <= 1) or (N mod 2 = 0)
then Prime := false
else begin
Prime := true;
i := 3; Max := sqrt(N);
while i <= Max do begin
if N mod i = 0 then begin
Prime := false;
exit
end;
i := i + 2
end
end
end;
var
a, i : longword;
begin
read(a);
for i := 2 to a do
if Prime(i)
then writeln(i, ' is a prime number');
end.
Нахождение простых чисел.
+79
/**
* @return
* true - если все строчки выделены,
* false - если все строчки не выделены,
* null - если есть как выделенные, так и не выделенные строчки
*/
private Boolean lookRowsDownwards(ColumnHolder rowHolder, boolean isPreviousRowsSelected) {
это реализация переключателя с 3-мя состояниями
+163
WCHAR *qStringToWideChar(const QString &str) {
if (str.isNull())
return 0;
WCHAR *result = new WCHAR[str.length() + 1];
for (unsigned int i = 0; i < str.length(); ++i)
result[i] = str[i].unicode();
result[str.length()] = 0;
return result;
}
Опять неосиляторы ассистента издеваются над Qt.
+158
$pos = strpos($pp_req, '&FIRSTNAME=');
if ($pos === false) {
$pos = strpos($pp_req, '&SHIPTONAME=');
}
return $res;
−352
#!/bin/bash
function f() {
sleep "$1"
echo "$1"
}
while [ -n "$1" ]
do
f "$1" &
shift
done
wait
example usage:
./sleepsort.bash 5 3 6 3 6 3 1 4 7
Метод сортировки :)
Взято с:
http://dis.4chan.org/read/prog/1295544154
+174
// привет помоги почему скрипт не работает? он делает лоадер загрузки страницы а потом когда уже все загружено то скрипты подключает
if($(document).ready(function(){return "true";})) {
$(document).ready(function(){//
$('div:eq(32)').addClass('LOADED'"+);
$('body').removeClass('LOADIING');
$("head").html(+$("head").html()+"+<script type=text/javascript src=../jquery.1.6.min.js></script>"+");
$(function(){
if(typeof jquery===function && typeof $===typeof jquery){$.get('/load/0-0-0-0-17',function(DATA){
if(data){
if(data!=undefined){
$("div:contains('Друзья')").html($("[id*=entry]", DATA).append("true"))}}
})}
})
})
} else {alert("ОШИБКА ЗАГРУЗКИ СТРАНИЦЫ!"+\n")}
Йобаннаврот!
+93
Label 1, 2;
var
M,n:integer;
B:real;
Begin
Read(m,n);
2:
B:=m mod n;
If b=0 then goto 1 else
Begin
M:=n; n:=b;
Goto 2;
End;
1:
Write(n);
End.
Кaк бэ прогрaммноe рeaлизaциё aлгоритмa Евклидa, нaхождeниe мaксимaльного дeлитeля двух чисeл, кaк-то тaк.