- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
std::string s1;
std::string s2;
int ret = strcmp(s1.c_str(), s2.c_str()); //А здесь мы сравниваем строки
if (ret == 0)
{
....
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+7
std::string s1;
std::string s2;
int ret = strcmp(s1.c_str(), s2.c_str()); //А здесь мы сравниваем строки
if (ret == 0)
{
....
}
+7
if(isMoving)
{
std::map<int, unsigned char> dirToFrame = boost::assign::map_list_of(1, 10)(2, 5)(3, 6)(4, 7)(5, 8)(6, 9)(7, 12)(8, 11);
if(dir >= 1 && dir <= 10)
return dirToFrame[dir];
throw std::string("Something very wrong1.");
}
else //if(isMoving)
{
std::map<int, unsigned char> dirToFrame = boost::assign::map_list_of(1, 13)(2, 0)(3, 1)(4, 2)(5, 3)(6, 4)(7, 15)(8, 14);
if(dir >= 1 && dir <= 10)
return dirToFrame[dir];
throw std::string("Something very wrong1.");
}
Кусок кода из open source игры. Выбирает кадр спрайта, в зависимости от направления героя. В ревизии, предшествующей этой, использовался switch.
+166.4
<?
$query="SELECT * FROM Communicators WHERE phoneID=$phoneID";
$dba->query($query);
list($phoneID, $brandID, $phoneModel, $phoneDate, $phonePriceRetail, $phonePriceWS,$phonePriceWS1, $phoneDescrShort, $phoneDescrFull, $phonePicShort, $phonePicFull,
$phonePriceWSComment, $groupDefaultprice1, $groupDefaultprice2, $groupGroup2price1, $groupGroup2price2, $grouptempprice1, $grouptempprice2, $groupGorodprice1, $groupGorodprice2, $groupClientsprice1, $groupClientsprice2,
$standards, $height, $width, $thickness, $weight, $batteryType, $batteryMAH, $standbyTime, $talkTime, $phoneBookSize, $video, $processor, $calendar, $wap, $OS, $GPRS, $EDGE, $java, $FMradio, $memcard, $bluetooth, $modem, $irda, $EMS, $MMS, $USB, $dictaphone, $camera, $colorDisplay, $twoDisplays, $outlookSynchro, $otherDescription, $games, $ringFileFormat, $innerMemory, $mp3player, $corpus, $WiFi, $videoCall, $GPS, $xtraDescr, $id_article)=$dba->get_row();
?>
<h2>Описание <?=$brandName?> <?=$phoneModel?></h2>
<b>Основные характеристики</b><br>
<?if( $standards != "" ){?>Стандарт: <?=$standards?><br><?}?>
<?if( $corpus != "" ){?>Тип корпуса: <?=$corpus?><br><?}?>
Размеры, мм (Ш×В×Г): <?=$width?>×<?=$height?>×<?=$thickness?><br>
<?if( $weight != "" ){?>Вес: <?=$weight?> г<br><?}?>
Аккумулятор: <?if( $batteryType != "" ){?><?=$batteryType?>, <?}?><?if( $batteryMAH != "" ){?><?=$batteryMAH?> мА·ч<br><?}?>
<?if( $processor != "" ){?>Процессор: <?=$processor?><br><?}?>
<?if( ($innerMemory != "0") && ($innerMemory != 0) && ($innerMemory != "") ){?>Память RAM/ROM: <?=$innerMemory?><br><?}?>
<?if( $memcard != "" ){?>Слоты расширения: <?=str_replace("+","есть",str_replace("-","нет",$memcard))?><br><?}?>
<?if( $OS != "" ){?>Операционная система: <?=$OS?><br><?}?>
<?if( $calendar != "" ){?>Органайзер: <?=str_replace("+","есть",str_replace("-","нет",$calendar))?><br><?}?>
<br>
<b>Связь</b><br>
<?if( $USB != "" ){?>USB: <?=str_replace("+","есть",str_replace("-","нет",$USB))?><br><?}?>
<?if( $irda != "" ){?>Инфракрасный порт: <?=str_replace("+","есть",str_replace("-","нет",$irda))?><br><?}?>
<?if( $GPRS != "" ){?>GPRS: <?=str_replace("+","есть",str_replace("-","нет",$GPRS))?><br><?}?>
<?if( $EDGE != "" ){?>EDGE: <?=str_replace("+","есть",str_replace("-","нет",$EDGE))?><br><?}?>
<?if( $bluetooth != "" ){?>Bluetooth: <?=str_replace("+","есть",str_replace("-","нет",$bluetooth))?><br><?}?>
<?if( $WiFi != "" ){?>Wi-Fi: <?=str_replace("+","есть",str_replace("-","нет",$WiFi))?><br><?}?>
<?if( $GPS != "" ){?>GPS: <?=str_replace("+","есть",str_replace("-","нет",$GPS))?><br><?}?>
<br>
<b>Экран</b><br>
<?if( $colorDisplay != "" ){?>Экран: <?=str_replace("+","есть",str_replace("-","нет",$colorDisplay))?><br><?}?>
<?if( $twoDisplays != "" ){?>Сенсорный дисплей: <?=str_replace("+","есть",str_replace("-","нет",$twoDisplays))?><br><?}?>
<br>
<b>Мультимедийные возможности</b><br>
<?if( $mp3player != "" ){?>MP3-плеер: <?=str_replace("+","есть",str_replace("-","нет",$mp3player))?><br><?}?>
<?if( $ringFileFormat != "" ){?>Аудио форматы: <?=$ringFileFormat?><br><?}?>
<?if( $FMradio != "" ){?>FM радио: <?=str_replace("+","есть",str_replace("-","нет",$FMradio))?><br><?}?>
<?if( $dictaphone != "" ){?>Диктофон: <?=str_replace("+","есть",str_replace("-","нет",$dictaphone))?><br><?}?>
<?if( $camera != "" ){?>Камера: <?=str_replace("+","есть",str_replace("-","нет",$camera))?><br><?}?>
<?if( $video != "" ){?>Съемка видео: <?=str_replace("+","есть",str_replace("-","нет",$video))?><br><?}?>
<?if( $videoCall != "" ){?>Видеозвонок: <?=str_replace("+","есть",str_replace("-","нет",$videoCall))?><br><?}?>
<?if( $games != "" ){?>Игры: <?=str_replace("+","есть",str_replace("-","нет",$games))?><br><?}?>
<?if( $otherDescription != "" ){?>
<br>
<b>Прочее</b><br>
<?=nl2br($otherDescription)?>
<?}?>
Разгребаю это говно... Тот кто так пишет - недостоин жить :(
+148
if(mysql_num_rows($records_sql)<1){
$_SESSION['site_msg']='no_user_found';
header('Location: customer_listing.php');
echo '<script type="text/javascript">';
echo 'window.location.href="customer_listing.php";';
echo '</script>';
echo '<noscript>';
echo '<meta http-equiv="refresh" content="0;url=customer_listing.php" />';
echo '</noscript>';
exit();
}
чтоб наверняка
+14.1
bool IsTranslucent() const
{
return !!Translucent;
}
Зачем двойное отрицание?
Наверное потому, что Translucent имеет тип BOOL из windows.h и приведение ее к bool даст нежелательный warning.
+162.2
$r_fam = str_replace(',',"",$r_fam);
$r_fam = str_replace('$',"",$r_fam);
$r_fam = str_replace('\"',"",$r_fam);
$r_fam = str_replace('<',"",$r_fam);
$r_fam = str_replace('>',"",$r_fam);
$r_fam = str_replace('*',"",$r_fam);
$r_fam = str_replace('=',"",$r_fam);
$r_name = str_replace(',',"",$r_name);
$r_name = str_replace('$',"",$r_name);
$r_name = str_replace('\"',"",$r_name);
$r_name = str_replace('<',"",$r_name);
$r_name = str_replace('>',"",$r_name);
$r_name = str_replace('*',"",$r_name);
$r_name = str_replace('=',"",$r_name);
$sqlr="INSERT INTO users VALUES(NULL,'$r_login','$r_pass','0.00','0.00','0.00','$r_email','$r_name','$r_fam','$date','0.00')";
mysql_query($sqlr);
Защита в лоб.
register_globals = on
+154
var ratingid=where+id+"rating";
document.getElementById(ratingid).innerHTML="Представьте, что курсор мышки превратился в часики";
xmlhttp.open("GET", "/"+where+"/"+act+"/"+id+"?reqt=update", true);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4) {
if(xmlhttp.status == 200) {
if(xmlhttp.responseText.substring(0,2) == "OK") {
s=xmlhttp.responseText.search(/!RATING!/i)+8;
e=xmlhttp.responseText.search(/!ERATING!/i);
document.getElementById(ratingid).innerHTML=xmlhttp.responseText.substring(s,e);
}
}
}
};
"Представьте, что вы - Властелин Вселенной, а курсор мышки - часики"
+147.8
if ($i++%2==0)
$bgc='#eeeeee';
else
$bgc='#cccccc';
Самое интересное, что инкремент производится после прохождения проверки
−109.3
$in{item_name}=CGI::unescape($in{item_name});
$in{item_number}=CGI::unescape($in{item_number});
#убиваем пробелы сначала, с конца и двойные
###
if($in{item_name}=~/^[\s]+([\s\S]+)/) {
$in{item_name}=$1;
}
if($in{item_name}=~/([\s\S]+)[\s]+$/) {
$in{item_name}=$1;
}
$in{item_name}=~s/[\s]{2,}/ /g;
if($in{item_number}=~/^[\s]+([\s\S]+)/) {
$in{item_number}=$1;
}
if($in{item_number}=~/([\s\S]+)[\s]+$/) {
$in{item_number}=$1;
}
$in{item_number}=~s/[\s]{2,}/ /g;
####
my @select_parent=db_select_list ['title','id'],"catalog_section","parent_id=0";
###########
my $only_this_category_text;
my $checked_only;
if($in{action} eq 'filter' and !$in{only_this_cat}) { $checked_only=''; } else {$checked_only="checked"; }
#############################
my $selected_list_item;
my $only_this_cat_string;
my @selected_only;
my $selected_parent;
#die $in{only_this_cat_s};
for(@select_parent)
{my $name="index_sel_$$_{id}";
if($in{action} eq 'filter' and ($in{only_this_cat_s} eq $$_{id})) {$selected_only[$$_{id}]='selected'; } else { $selected_only[$$_{id}]=''; }
if(!$in{only_this_cat_s})
{ if(!$in{action} and ($in{s} eq $$_{id})) {$selected_only[$$_{id}]='selected'; } else { $selected_only[$$_{id}]=''; }
}else{ if($in{only_this_cat_s} eq $$_{id}){ $selected_only[$$_{id}]='selected';}}
}
############################
if($in{s}) {
#максимальная вложенность =3 - сформируем строку для чекбокса по-простому
my %ha=db_select_row ['id','title','parent_id'],"catalog_section","id=$in{s}";
if(%ha){$selected_only[$ha{parent_id}]='selected';}
my %parent=db_select_row ['title','parent_id'],"catalog_section","id=$ha{parent_id}";
my %parent2=db_select_row ['title','parent_id'],"catalog_section","id=$parent{parent_id}";
my $only_title=$ha{title};
$only_title= "$parent{title} — $only_title" if %parent;
$only_title= "$parent2{title} — $only_title" if %parent2;
$only_this_cat_string="";
if(%parent || %parent2) {#%ha
$only_this_category_text=qq~
<span>
<input type="checkbox" name="only_this_cat" id="only_this_cat" $checked_only onchange="checkSelect();">
<label for="only_this_cat">Искать только в разделе «$only_title»</label>
</span>~;
}
}
$selected_list_item=qq~<select name="only_this_cat_s" id="only_this_cat_s"> <OPTION VALUE='none'>Все разделы</OPTION>~;
for(@select_parent)
{
$selected_list_item.=qq~<OPTION VALUE='$$_{id}' $selected_only[$$_{id}]~;
$selected_list_item.=qq~><label for="only_this_cat_s">$$_{title}</label>
</OPTION>~;
}
$selected_list_item.=qq~</select></td>~;
$only_this_cat_string="Раздел каталога";
Оригинальное форматирование сохранено
+135.2
Continue = (Continue) ? true : false;