- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
$i=10000;
while(true)
{
$i--;
if ($i==0) break;
// Какойто код с $i
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+134
$i=10000;
while(true)
{
$i--;
if ($i==0) break;
// Какойто код с $i
}
Выкопал в одном серьезном проекте. Так там что не цикл так while(true) c точками выхода по телу цикла..
+166
<?php
if (!isset($_REQUEST['page'])&&!isset($_REQUEST['story']))
{
header('Location: index.php');
exit;
}
$page = $_REQUEST['page'];
$story = intval($_REQUEST['story']);
include_once('db_fns.php');
include_once('header.php');
$handle = db_connect();
if($story)
{
$query = "select * from stories
where id = '$story' and
published is not null";
}
else
{
$query = "select * from stories
where page = '$page' and
published is not null
order by published desc";
}
$result = $handle->query($query);
while ($story = $result->fetch_assoc())
{
// headline
echo "<h2>{$story['headline']}</h2>";
//picture
if ($story['picture'])
{
echo '<div style="float:right; margin:0px 0px 6px 6px;">';
echo '<img src="resize_image.php?image=';
echo urlencode($story[picture]);
echo '&max_width=200&max_height=120" align = right/></div>';
}
// byline
$w = get_writer_record($story['writer']);
echo '<br /><p class="byline">';
echo $w[full_name].', ';
echo date('M d, H:i', $story['modified']);
echo '</p>';
// main text
echo $story['story_text'];
}
include_once('footer.php');
?>
Там еще много такого говнеца
http://www.ibm.com/developerworks/ru/library/l-php_mysql_10/index.html?S_TACT=105AGX99&S_CMP=GR01
На ЛОРе обсуждают http://www.linux.org.ru/news/doc/6002642
−94
mCharInfoContent.x += ( hexTile.x + hexTile.parent.x + hexTile.parent.parent.x + hexTile.parent.parent.parent.x );
mCharInfoContent.y += ( hexTile.y + hexTile.parent.y + hexTile.parent.parent.y + hexTile.parent.parent.parent.y );
Красота неописуемая, метод научного тыка в действии
+161
<?
$result = mysql_query("SELECT date, article, post_text FROM posts");
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
echo "<div class=\"block\">\n\t<span class=\"da_ar\" id=\"left\">\n\t\t".$row[0]."\n\t</span>\n\t<span class=\"da_ar\" id=\"right\">\n\t\t".$row[1]."\n\t</span>\n\t<div class=\"block_text\"><pre>\n".$row[2]."</pre>\n\t</div>\n</div>";
}
mysql_free_result($result);
?>
Да - да - да, все это в одну строчку...
Не совсем, конечно, говно, но все же:)
+175
// "Dedicated to the near-memory of Nev. Let's start remembering people while they're still alive."
// Nev's great contribution to dc++
while(1) break;
Вот такое можно увидеть в исходниках ядра DC++
https://github.com/negativ/eiskaltdcpp/blob/master/dcpp/DCPlusPlus.cpp#L60
+165
function ChangePhoto(num, photo)
{
if (photo.className != 'photo_selected')
{
var image1 = document.getElementById("ctl00_MainContent_ProductInfo1_ctl00_AlternativePictures_Image1");
var image2 = document.getElementById("ctl00_MainContent_ProductInfo1_ctl00_AlternativePictures_Image2");
var image3 = document.getElementById("ctl00_MainContent_ProductInfo1_ctl00_AlternativePictures_Image3");
var image4 = document.getElementById("ctl00_MainContent_ProductInfo1_ctl00_AlternativePictures_Image4");
var image5 = document.getElementById("ctl00_MainContent_ProductInfo1_ctl00_AlternativePictures_Image5");
var image6 = document.getElementById("ctl00_MainContent_ProductInfo1_ctl00_AlternativePictures_Image6");
if (image1 != null) image1.className = 'photo_notselected';
if (image2 != null) image2.className = 'photo_notselected';
if (image3 != null) image3.className = 'photo_notselected';
if (image4 != null) image4.className = 'photo_notselected';
if (image5 != null) image5.className = 'photo_notselected';
if (image6 != null) image6.className = 'photo_notselected';
photo.className = 'photo_selected';
Hide(0);
setTimeout("ChangeSrc("+num+")", 300);
setTimeout("ShowPhoto()", 400);
}
}
Чо мне ща сказал? Цыклы мне ща сказал? Какие тенна цыклы, ыдисюданна!
Строчки 22, 23 активируют какое-то хитрожопое многопоточное отображение фоток со взаимными блокировками и ожиданием друг друга по таймеру с интервалами в 10 мс.
+76
//skipped
b1 = new JButton("Disable middle button", leftButtonIcon);
b1.setVerticalTextPosition(AbstractButton.CENTER);
b1.setHorizontalTextPosition(AbstractButton.LEADING); //aka LEFT, for left-to-right locales
b1.setMnemonic(KeyEvent.VK_D);
b1.setActionCommand("disable");
b1.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
if ("disable".equals(e.getActionCommand())) {
b2.setEnabled(false);
b1.setEnabled(false);
b3.setEnabled(true);
} else {
b2.setEnabled(true);
b1.setEnabled(true);
b3.setEnabled(false);
}
из мануала на oracle.com. Что действительно так нужно обрабатывать события?
+154
if (request->status().is_success() &&
(request->GetResponseCode() / 100) == 2) {
/* блаблабла */
}
Было случайно откопано в исходниках хромиума (http://src.chromium.org/svn/trunk/src/webkit/appcache/appcache_update_job.cc). И первый вопрос который возникает это "Ну вот нахера???".
+169
global $_GET, $m_db;
паццтолом
+163
$tmp = mysql_query("SELECT DISTINCT (author),(poluchatel) FROM messages WHERE author='$login' OR poluchatel='$login' ORDER BY poluchatel,author ",$db);
$messages = mysql_fetch_array($tmp);//извлекаем автора
if (!empty($messages['author']))
{
$mass[]=''; // сюда хуячим все имена контактов, всё шо есть в базе
$security; // ключ 0,1
$i=0; //счетчик
$white='ffffff';
$blue='e3ebf8';
$c=0;
do //выводим всех авторов
{
$security=1; //первоначально положительно("1") в каждом цикле на каждый контакт
if($messages['author']==$login) //если поле автор = тому чья стр
{
$author = $messages['poluchatel']; //то в пер автор сохраняем имя получателя
$mass[$i]=$author; //кидаем копию имя в массив
$i++; //счетчик ++
}
else{ //если поле автор не тот чья стр
$author = $messages['author']; //то в пер летит имя отправителя из базы
$mass[$i]=$author; //ебошим всё в массив
$i++;
}
for($j=0; $j<=$i; $j++) //перебераем массив
{
if($mass[$j]==$messages['poluchatel']) //если в массиве уже есть такой автор
{$security=0; break;} //то присваеваем ключ "0"
}
if($security==1) //усли ключ = 1, то выводим контакт
{
$result4 = mysql_query("SELECT avatar,id FROM users WHERE login='$author'",$db); //извлекаем аватар автора
$myrow4 = mysql_fetch_array($result4);
if (!empty($myrow4['avatar'])) {//если такового нет, то выводим стандартный (может этого пользователя уже давно удалили)
$avatar = $myrow4['avatar'];
}
else {$avatar = "avatars/net-avatara.jpg";}
$auth = $messages['author']; //запоминаем имя этого автора
$count = mysql_query("SELECT * FROM messages WHERE author='$auth' AND poluchatel='$login' AND stat='0' " ); //выбираем строки с непрочит соо
$new_msg=mysql_num_rows($count); //считаем строки
//выставляем цвет фона смс
//////
if($c%2==0)
{
$color=$blue;
}
else
{
$color=$white;
}
//считаем сообщений от контакта
$result5=mysql_query("SELECT * FROM messages WHERE author='$author' AND poluchatel='$login' ");
$result6=mysql_query("SELECT * FROM messages WHERE author='$login' AND poluchatel='$author' ");
$msg_count1=mysql_num_rows($result5);
$msg_count2=mysql_num_rows($result6);
$msg_count=$msg_count1+$msg_count2;
if($new_msg>0)
{
printf("
<table width='450' bgcolor='f4cf90' >
<tr>
<td style='border-bottom:1px solid black'>
<a href='page.php?id=%s'><img alt='аватар' width='20px' height='30px' src='%s'></a>
<a href='my_messages_view.php?author=%s'><font color='0c50a5' style='font-size:17px;font-weight:bold;'>%s</font></a>
<font color=red style='font-size:17px;font-weight:bold'>(+%s)</font>
</td>
</tr>
</table>
",$myrow4['id'],$avatar,$author,$author,$new_msg);
}
else
{
printf("
<table width='450' bgcolor='".$color."' >
<tr>
<td style='border-bottom:1px solid black'>
<a href='page.php?id=%s'><img alt='аватар' width='20px' height='30px' src='%s'></a>
<a href='my_messages_view.php?author=%s'><font style='font-size:17px; font-weight:bold;' color='0c50a5'>%s</a></font>
<font color='6b6b6b' style='font-size:17px; text-align: right; font-weight:bold;'>(%s)</font>
</td>
</tr>
</table>
",$myrow4['id'],$avatar,$author,$author,$msg_count);
}
}
$c++;
}
while($messages = mysql_fetch_array($tmp));
}