- 1
- 2
- 3
- 4
- 5
foreach ($params as $param) {
$param_type = (isset($param['type']) ? $param['type'] : 's');
$param_value = (isset($param['value']) ? $param['value'] : $param);
// <...>
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+154
foreach ($params as $param) {
$param_type = (isset($param['type']) ? $param['type'] : 's');
$param_value = (isset($param['value']) ? $param['value'] : $param);
// <...>
}
Угадайте, что произошло, когда значение параметра оказалось равным 'type'?
−102
def booleanize(value):
"""Return value as a boolean."""
true_values = ("yes", "true", "1")
false_values = ("no", "false", "0")
if isinstance(value, bool):
return value
if value.lower() in true_values:
return True
elif value.lower() in false_values:
return False
В комментариях не нуждается.
+153
if(!empty($this->aActions))
$sMenuItems = htmlspecialcharsbx(CAdminPopup::PhpToJavaScript($this->aActions));
?>
<tr class="adm-list-table-row<?=(isset($this->aFeatures["footer"]) && $this->aFeatures["footer"] == true? ' footer':'')?><?=$this->bEditMode?' adm-table-row-active' : ''?>"<?=($sMenuItems <> ""? ' oncontextmenu="return '.$sMenuItems.';"':'');?><?=($sDefAction <> ""? ' ondblclick="'.$sDefAction.'"'.(!empty($sDefTitle)? ' title="'.GetMessage("admin_lib_list_double_click").' '.$sDefTitle.'"':''):'')?>>
<?
if(count($this->pList->arActions)>0 || $this->pList->bCanBeEdited):
$check_id = RandString(5);
?>
<td class="adm-list-table-cell adm-list-table-checkbox adm-list-table-checkbox-hover<?=$this->bReadOnly? ' adm-list-table-checkbox-disabled':''?>"><input type="checkbox" class="adm-checkbox adm-designed-checkbox" name="ID[]" id="<?=$this->table_id."_".$this->id."_".$check_id;?>" value="<?=$this->id?>" autocomplete="off" title="<?=GetMessage("admin_lib_list_check")?>"<?=$this->bReadOnly? ' disabled="disabled"':''?><?=$this->bEditMode ? ' checked="checked" disabled="disabled"' : ''?> /><label class="adm-designed-checkbox-label adm-checkbox" for="<?=$this->table_id."_".$this->id."_".$check_id;?>"></label></td>
<?
endif;
if($this->pList->bShowActions):
if(!empty($this->aActions)):
?>
<td class="adm-list-table-cell adm-list-table-popup-block" onclick="BX.adminList.ShowMenu(this.firstChild, this.parentNode.oncontextmenu(), this.parentNode);"><div class="adm-list-table-popup" title="<?=GetMessage("admin_lib_list_actions_title")?>"></div></td>
<?
else:
?>
<td class="adm-list-table-cell"></td>
<?
endif;
endif;
bitrix
Лапша PHP кода, с подливкой из HTML. Присутствуют специи из альтернативного синтаксиса оператора if для шаблонов
+157
for ($j=1; $j<8; $j++) {
$up = "";
$down = "";
for ($i=1; $i<7; $i++) {
if (($i==4)&&($j==4)) {
$up = $up.'<td class="simp" colspan="2" rowspan="4">Военная<br>Подготовка</td>';
continue;
}
if (($i==4)&&($j>3)&&($j<6)) {
continue;
}
$x = $i*2-1;
$y = $j*2-1;
if (($table[$x][$y]==$table[$x][$y+1])&&($table[$x+1][$y+1]==$table[$x+1][$y])&&($table[$x+1][$y+1]==$table[$x][$y])) {
$up = $up.str_replace("<br><br>","","<td title='".$table[$x][$y]['description']."' class='simp' colspan='2' rowspan='2'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>");
}
else {
$cnt = 0;
if ($table[$x][$y]==$s) $cnt++;
if ($table[$x][$y+1]==$s) $cnt++;
if ($table[$x+1][$y]==$s) $cnt++;
if ($table[$x+1][$y+1]==$s) $cnt++;
if ($cnt==3) {
$up = $up."<td title='".$table[$x][$y]['description']."' class='insm'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>";
$up = $up."<td title='".$table[$x+1][$y]['description']."' class='insm'>".$table[$x+1][$y]['subject']."<br>".$table[$x+1][$y]['auditory']."<br>".$table[$x+1][$y]['lecturer']."</td>";
$down = $down."<td title='".$table[$x][$y+1]['description']."' class='insm'>".$table[$x][$y+1]['subject']."<br>".$table[$x][$y+1]['auditory']."<br>".$table[$x][$y+1]['lecturer']."</td>";
$down = $down."<td title='".$table[$x+1][$y+1]['description']."' class='insm'>".$table[$x+1][$y+1]['subject']."<br>".$table[$x+1][$y+1]['auditory']."<br>".$table[$x+1][$y+1]['lecturer']."</td>";
}
else {
if ($table[$x][$y]==$table[$x][$y+1]) { // Левые совпадают
$up = $up."<td title='".$table[$x][$y]['description']."' class='insm' rowspan='2'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>";
if ($table[$x+1][$y]==$table[$x+1][$y+1]) {
$up = $up."<td title='".$table[$x+1][$y]['description']."' class='insm' rowspan='2'>".$table[$x+1][$y]['subject']."<br>".$table[$x+1][$y]['auditory']."<br>".$table[$x+1][$y]['lecturer']."</td>";
}
else {
$up = $up."<td title='".$table[$x+1][$y]['description']."' class='insm'>".$table[$x+1][$y]['subject']."<br>".$table[$x+1][$y]['auditory']."<br>".$table[$x+1][$y]['lecturer']."</td>";
$down = $down."<td title='".$table[$x+1][$y+1]['description']."' class='insm'>".$table[$x+1][$y+1]['subject']."<br>".$table[$x+1][$y+1]['auditory']."<br>".$table[$x+1][$y+1]['lecturer']."</td>";
}
} else {
if ($table[$x+1][$y]==$table[$x+1][$y+1]) { // Правые совпадают
$up = $up."<td title='".$table[$x][$y]['description']."' class='insm'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>";
$down = $down."<td title='".$table[$x][$y+1]['description']."' class='insm'>".$table[$x][$y+1]['subject']."<br>".$table[$x][$y+1]['auditory']."<br>".$table[$x][$y+1]['lecturer']."</td>";
$up = $up."<td title='".$table[$x+1][$y]['description']."' class='insm' rowspan='2'>".$table[$x+1][$y]['subject']."<br>".$table[$x+1][$y]['auditory']."<br>".$table[$x+1][$y]['lecturer']."</td>";
}
else {
if ($table[$x][$y]==$table[$x+1][$y]) { // Верхние совпадают
$up = $up."<td title='".$table[$x][$y]['description']."' class='insm' colspan='2'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>";
if ($table[$x][$y+1]==$table[$x+1][$y+1]) {
$down = $down."<td title='".$table[$x][$y+1]['description']."' class='insm' colspan='2'>".$table[$x][$y+1]['subject']."<br>".$table[$x][$y+1]['auditory']."<br>".$table[$x][$y+1]['lecturer']."</td>";
}
else {
$down = $down."<td title='".$table[$x][$y+1]['description']."' class='insm'>".$table[$x][$y+1]['subject']."<br>".$table[$x][$y+1]['auditory']."<br>".$table[$x][$y+1]['lecturer']."</td>";
$down = $down."<td title='".$table[$x+1][$y+1]['description']."' class='insm'>".$table[$x+1][$y+1]['subject']."<br>".$table[$x+1][$y+1]['auditory']."<br>".$table[$x+1][$y+1]['lecturer']."</td>";
}
}
else {
if ($table[$x][$y+1]==$table[$x+1][$y+1]) { // Нижние совпадают
$up = $up."<td title='".$table[$x][$y]['description']."' class='insm'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>";
$up = $up."<td title='".$table[$x+1][$y]['description']."' class='insm'>".$table[$x+1][$y]['subject']."<br>".$table[$x+1][$y]['auditory']."<br>".$table[$x+1][$y]['lecturer']."</td>";
$down = $down."<td title='".$table[$x][$y+1]['description']."' class='insm' colspan='2'>".$table[$x][$y+1]['subject']."<br>".$table[$x][$y+1]['auditory']."<br>".$table[$x][$y+1]['lecturer']."</td>";
}
else {
$up = $up."<td title='".$table[$x][$y]['description']."' class='insm'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>";
...
Рендер расписания занятий из базы данных в табличку на HTML
+133
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
if(ofd.ShowDialog() == DialogResult.OK)
{
gs_path = ofd.FileName;
BinaryReader br = new BinaryReader(new FileStream(gs_path, FileMode.Open, FileAccess.Read));
int sys = 0;
do {
ofset++;
br.BaseStream.Seek(ofset, SeekOrigin.Begin);
if (br.ReadInt64() == 6875716118506401907)
{
if (br.ReadInt64() == 521392779117)
{
sys = 1;
}
}
} while (sys == 0);
br.BaseStream.Seek(ofset + 20, SeekOrigin.Begin);
textBox1.Text = br.ReadSingle().ToString();
br.BaseStream.Seek(ofset + 24, SeekOrigin.Begin);
textBox2.Text = br.ReadSingle().ToString();
br.BaseStream.Seek(ofset + 28, SeekOrigin.Begin);
textBox3.Text = br.ReadSingle().ToString();
br.BaseStream.Seek(ofset + 32, SeekOrigin.Begin);
textBox4.Text = br.ReadSingle().ToString();
br.BaseStream.Seek(ofset + 36, SeekOrigin.Begin);
textBox5.Text = br.ReadSingle().ToString();
br.BaseStream.Seek(ofset + 40, SeekOrigin.Begin);
textBox6.Text = br.ReadSingle().ToString();
br.BaseStream.Seek(ofset + 44, SeekOrigin.Begin);
textBox7.Text = br.ReadSingle().ToString();
br.Close();
}
}
...
string gs_path;
int ofset = 0;
public Form1()
{
InitializeComponent();
}
...
private void button2_Click(object sender, EventArgs e)
{
BinaryWriter bw = new BinaryWriter(new FileStream(gs_path, FileMode.Open, FileAccess.Write));
bw.BaseStream.Seek(ofset + 20, SeekOrigin.Begin);
bw.Write(Convert.ToSingle(textBox1.Text));
bw.BaseStream.Seek(ofset + 24, SeekOrigin.Begin);
bw.Write(Convert.ToSingle(textBox2.Text));
bw.BaseStream.Seek(ofset + 28, SeekOrigin.Begin);
bw.Write(Convert.ToSingle(textBox3.Text));
bw.BaseStream.Seek(ofset + 32, SeekOrigin.Begin);
bw.Write(Convert.ToSingle(textBox4.Text));
bw.BaseStream.Seek(ofset + 36, SeekOrigin.Begin);
bw.Write(Convert.ToSingle(textBox5.Text));
bw.BaseStream.Seek(ofset + 40, SeekOrigin.Begin);
bw.Write(Convert.ToSingle(textBox6.Text));
bw.BaseStream.Seek(ofset + 44, SeekOrigin.Begin);
bw.Write(Convert.ToSingle(textBox7.Text));
bw.Close();
}
http://kn1fe-zone.ru/index.php?threads/%D0%9F%D1%80%D0%B8%D0%BC%D0%B5%D1%80-%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0% BC%D0%BC%D1%8B-%D1%81-%D0%B0%D0%B2%D1%82%D0%BE%D0%BF%D0%BE%D0% B8%D1%81%D0%BA%D0%BE%D0%BC-%D0%B7%D0%BD%D0%B0%D1%87%D0%B5%D0%BD%D0% B8%D0%B9.381/
ХОСПАДИ ДЕСЯТЬ ИЗ ДЕСЯТИ!!!!1111 Принесите мачете и спирт!
+155
global $strError, $MESS, $HTTP_GET_VARS, $arrFORM_FILTER;
global $find_date_create_1, $find_date_create_2, $lAdmin;
$str = "";
CheckFilterDates($find_date_create_1, $find_date_create_2, $date1_wrong, $date2_wrong, $date2_less);
if ($date1_wrong=="Y") $str.= GetMessage("FORM_WRONG_DATE_CREATE_FROM")."<br>";
if ($date2_wrong=="Y") $str.= GetMessage("FORM_WRONG_DATE_CREATE_TO")."<br>";
if ($date2_less=="Y") $str.= GetMessage("FORM_FROM_TILL_DATE_CREATE")."<br>";
bitrix
- использование HTTP_GET_VARS уже давно deprecated
- магические переменные find_date_create_1, find_date_create_2, да и lAdmin тоже не понятно что
- зачем-то используются символы Y и N вместо true и false или 1 и 0
+134
if ((err = SSLHashSHA1.update(&hashCtx, &serverRandom)) != 0)
goto fail;
if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0)
goto fail;
goto fail;
if ((err = SSLHashSHA1.final(&hashCtx, &hashOut)) != 0)
goto fail;
https://www.imperialviolet.org/2014/02/22/applebug.html
Понятно, что третий if не выполнится. Кстати, это был баг в Apple SSL/TLS, привёдший к уязвимости.
Кстати, GCC с -Wall это не ловит. Ловит только Clang, и то только с -Wunreachable-code. Мораль: заключайте все тела ифов в блоки!
+1
for (conn_vector::iterator i = m_connections.begin(); i != m_connections.end(); ++i) {
if (*i == conn) {
m_connections.erase(i);
toDelete = *i;
break;
}
}
Да, С++98. Да, в std::find не умеем. Да, сегфолт. Да, моё.
+144
for (conn_vector::iterator i = m_connections.begin(); i != m_connections.end(); ++i) {
if (*i == conn) {
toDelete = *i;
m_connections.erase(i);
break;
}
}
Да, С++98. Да, в std::find не умеем. Да, сегфолт. Да, моё.
−167
Функция НайтиСтатусРемонта(ВыбСтатус) Экспорт
Возврат Ремонт.Найти(ВыбСтатус, "СтатусРемонта");
КонецФункции
Процедура УстановитьДанныеСтрокиРемонта(СтатусРемонта, ДатаСтатуса, ДатаВх) Экспорт
СТЧ = НайтиСтатусРемонта(СтатусРемонта);
Попытка
Если СТЧ.Дата = Дата(1,1,1) Тогда
Попытка СТЧ.Дата = ДатаВх; Исключение КонецПопытки;
ИначеЕсли СТЧ.Дата <> ДатаВх Тогда
обСообщить(""+Ссылка+" "+СтатусРемонта+" Дата уже установлена",СтатусСообщения.Важное);
КонецЕсли;
Исключение
КонецПопытки;
КонецПроцедуры
На фоне всей базы это всего лишь цветочки ...
Есть еще отчет, для формирования которого создается 36 (!!!) запросов )))
Хотел отчет выложить, но ограничение из 100 строк меня остановило :(