- 1
- 2
- 3
- 4
- 5
$c = (int)(bool)$_POST['chat'];
// через сто строк
$q = 'UPDATE ....., `chat`='.$c.' WHERE ....';
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+156
$c = (int)(bool)$_POST['chat'];
// через сто строк
$q = 'UPDATE ....., `chat`='.$c.' WHERE ....';
интригующе
−84
$sth = $dbh->prepare("select *,DATE(DTime),DATE(RDTime),MONTH(DTime),DAY(DTime),HOUR(DTime),MINUTE(DTime),UNIX_TIMESTAMP(DTime)
from tt_list where Type!=0 $where order $order");
...
if ($row->{'HOUR(DTime)'}<10) {$row->{'HOUR(DTime)'}="0$row->{'HOUR(DTime)'}"};
if ($row->{'MINUTE(DTime)'}<10) {$row->{'MINUTE(DTime)'}="0$row->{'MINUTE(DTime)'}"};
...
print "...<td width=60 nowrap><img src=../images/icon_clock.gif width=16 height=16 border=0>
$row->{'HOUR(DTime)'}:$row->{'MINUTE(DTime)'}</td>...";
Выводим время...
+160
function addParam(iId)
{
var sData = '';
//Контрольная работа
if (iId==1)
sData = '';
// Реферат
else if (iId==2)
sData = '';
// Курсовая
else if (iId==3)
sData = '';
// Решение задач
else if (iId==4)
sData = '';
else {
$('#addParam').hide().html('');
return false;
}
$('#addParam').html('').append('<td colspan="2">'+sData+'</td>').show();
}
lot's of code, govnocode, govnocode, govnocode...
+138
error LNK2001: unresolved external symbol "private: static class std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class
std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class
std::map<__int64,class k3bufferblock,struct std::less<__int64>,class std::allocator<struct
std::pair<__int64 const ,class k3bufferblock> > >,struct std::less<class std::basic_string<char,struct
std::char_traits<char>,class std::allocator<char> > >,class std::allocator<struct std::pair<class
std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class
std::map<__int64,class k3bufferblock,struct std::less<__int64>,class std::allocator<struct
std::pair<__int64 const ,class k3bufferblock> > > > > >,struct std::less<class
std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class
std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> > const ,class std::map<class std::basic_string<char,struct
std::char_traits<char>,class std::allocator<char> >,class std::map<__int64,class k3bufferblock,struct
std::less<__int64>,class std::allocator<struct std::pair<__int64 const ,class k3bufferblock> > >,struct
std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >
>,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> > const ,class std::map<__int64,class k3bufferblock,struct
std::less<__int64>,class std::allocator<struct std::pair<__int64 const ,class k3bufferblock> > > > > >
> > > k3entity_cache::buffercache" (?buffercache@k3entity_cache@@0V?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$map@V?$basic_string@DU?
$char_traits@D@std@@V?$allocator@D@2@@std@@V?$map@_JVk3bufferblock@@U?$less@_J@std@@V?$allocator@U?$pair@$$CB_JVk3bufferblock@@@std@@@3@@2@U?$less@V?
$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?
$map@_JVk3bufferblock@@U?$less@_J@std@@V?$allocator@U?$pair@$$CB_JVk3bufferblock@@@std@@@3@@2@@std@@@2@@2@U?$less@V?$basic_string@DU?
$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$map@V?$basic_string@DU?
$char_traits@D@std@@V?$allocator@D@2@@std@@V?$map@_JVk3bufferblock@@U?$less@_J@std@@V?$allocator@U?$pair@$$CB_JVk3bufferblock@@@std@@@3@@2@U?$less@V?
$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?
$map@_JVk3bufferblock@@U?$less@_J@std@@V?$allocator@U?$pair@$$CB_JVk3bufferblock@@@std@@@3@@2@@std@@@2@@2@@std@@@2@@std@@A)
+163
function addNewUpload()
{
$('#button_'+i).remove();
i++;
$('<div id="field_'+i+'"><input id="file_'+i+'" name="file_'+i+'" type="file"><input type="button" value="+" id="button_'+i+'" onClick="addNewUpload()"></div>').appendTo("#loadmore_files");
$('#hidden_count').attr('value', i);
}
Учись, студент.
−92
def clean_node(node, debug=False):
"""
Этот пример скопипащен из книги
"Как не должен выглядеть код"
"""
if node['sub']:
sub = []
num = 1
for item in node['sub']:
i = clean_node(item, debug)
if i:
sub.append(i)
num += i['num']
node['sub'] = sub
node['num'] = num
else:
node['num'] = 1
if node['deleted']:
if node['sub']:
return node
else:
return node
return None
Мне достался в наследство большой проект, в котором порой встречается вот такое. Единственное, что радует это подобные комментарии )
−175
if request.path == '/':
thread_list = ThreadBlock.objects.all()
else:
thread_nomer = re.search( r'/\d*/', request.path ).group()[1:-1]
thread_list = ThreadBlock.objects.filter(id=int(thread_nomer))
Бидон, джанга, уеб.
+147
$offset = intval($_POST['offset']);
$sql = mysql_query("SELECT * FROM `test` ORDER BY id DESC LIMIT $offset, 5");
if(mysql_num_rows($sql)>0) {
while($post = mysql_fetch_assoc($sql)){
foreach($post AS $n=>$m){
$post[$n] = utf8_encode($m);
}
$json['more'][] = $post; # чтобы было легче до
}
if(count($json['more'])) {
$json['ok'] = '1';
} else {
$json['ok'] = '0';
}
} else {
$json['ok']='3';
}
mysql_close($db);
echo json_encode($json);
Индусский метод выборки записей из таблицы.
+161
class Session {
function sess_write() {
/*запись данных сессии в бд ($this->userdata)*/
}
function set_userdata($newdata = array(), $newval = '') {
if (count($newdata) > 0) {
foreach ($newdata as $key => $val) {
$this->userdata[$key] = $val;
}
}
$this->sess_write();
}
function unset_userdata($newdata = array()) {
if (count($newdata) > 0) {
foreach ($newdata as $key => $val) {
unset($this->userdata[$key]);
}
}
$this->sess_write();
}
function userdata($item) {
return (!isset($this->userdata[$item])) ? false : $this->userdata[$item];
}
}
говнокод изысканный.
ЗЫДН: в таком случае $this->sess_write() правильней делать в деструкторе
+125
for(int i = 0; i<et.Days.Count; i++)
{
if (et.Days[i].WorkDay.Day == colno - 1)
{
EmplTabelDays etd = et.Days[i];
switch (colno)
{
case 0:
break;
case 1:
break;
default:
{
//pinc.TypeIncome = (IncomeItem)
//((TreeNodeHelper)(income_grid.Rows[e.RowIndex].Cells[e.ColumnIndex]).Value).Value;
//etd.WorkStatus = (WorkStatus)((DataGridViewCell)(WorkDaysGrid.Rows[recno].Cells[colno]).Value).Value;
DataGridViewCell cell = WorkDaysGrid.Rows[recno].Cells[colno];
if (SpecialButton.Checked == false)
{
etd.TypeWorkHours = 8;
//еще 100500 строк гавнокода...
if (cell.Value == "8")
etd.WorkStatus.Id = 1;
if (cell.Value == "-")
etd.WorkStatus.Id = 2;
if (cell.Value == "О")
etd.WorkStatus.Id = 3;
if (cell.Value == "Б")
etd.WorkStatus.Id = 4;
if (cell.Value == "Р")
etd.WorkStatus.Id = 5;
if (cell.Value == "П")
etd.WorkStatus.Id = 6;
if (cell.Value == "А")
etd.WorkStatus.Id = 7;
if (cell.Value == "Г")
etd.WorkStatus.Id = 8;
if (cell.Value == "С")
etd.WorkStatus.Id = 9;
}
Найдено в коде программы табель для бухгалтерии.
Заполнение справочника с типами дней на основе ячеек грида.
KeyboardInheritance в чистом виде.