- 1
- 2
- 3
<td class="td_caption" style="width: 40%"><label for="pohuy">Запомнить</label></td>
<td class="td_value"><input type="checkbox" name="pohuy" checked="checked" id="pohuy"/></td>
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+172
<td class="td_caption" style="width: 40%"><label for="pohuy">Запомнить</label></td>
<td class="td_value"><input type="checkbox" name="pohuy" checked="checked" id="pohuy"/></td>
"Я ХАЧУ ГАЛОЧКУ ЗАПОМНИТЬ ПОД ПАРОЛЕМ БИЛЯТЬ", - как скажешь начальник.
*параметр "pohuy" как вы поняли нигде и никак не обрабатывается.
+163
if ($linksCount == 0) $linksCount = -1; // for no error
$percent = round(($linksOkIndex/$linksCount)*100, 0);
if ($linksCount == -1) $linksCount = 0; // for no error
Я так избегаю деления на ноль -)
+167
if (!$xhr)
{
//...
}
else
{
echo $goodUpload ? 'ok' : 'ne ok';
}
Ответ формы на AJAX-запрос
+157
function &_static($name = null, $value = null, $unsetVal = false) {
static $data = array();
$null = null;
if (is_array($name)) {
$data = $name;
return $null;
}
$state = 0;
$args = array($name, $value, $unsetVal);
while (count($args)) {
$arg = array_shift($args);
switch ($state) {
case 0:
if ($arg === null) {
$state = 8;
}
elseif ($arg !== null) {
$state = 1;
}
else {
throw new \InvalidArgumentException();
}
break;
case 1:
if ($arg === null) {
$state = 5;
}
elseif ($arg !== null) {
$state = 2;
}
else {
throw new \InvalidArgumentException();
}
break;
case 2:
if ($arg === true) {
$data[$name] = $value; // $name, $value, true - overwrite saved value and return reference on it.
return $data[$name];
}
elseif ($arg === false) {
if (!array_key_exists($name, $data)) {
$data[$name] = $value;
}
return $data[$name]; // $name, $value, false - save value if not exist, return reference on stored value.
}
else {
throw new \InvalidArgumentException();
}
case 5:
if ($arg === false) {
if (!array_key_exists($name, $data)) {
$data[$name] = $value; // $name, null, false, - initialize var if not exist, return reference on stored value.
}
return $data[$name];
}
elseif ($arg === true) {
$data[$name] = $value; // $name, $value, true - overwrite saved value and return reference on it.
return $data[$name]; // $name, null, true - overwrite saved value and return reference on it.
}
else {
throw new \InvalidArgumentException();
}
break;
case 8:
if ($arg === null) {
continue;
}
if ($arg === true) {
$data = array(); // null, null, true - unset all
break 2;
}
elseif ($arg === false) {
return $data; // null, null, false - return all
}
else {
throw new \InvalidArgumentException();
}
default:
throw new \RuntimeException('Unknown state.');
}
}
return $null;
}
Как сделать глобальные переменные своими руками?
Как сделать ветвление когда под рукой не оказалось if, зато есть while и switch?
+177
"
<td><span>\".setDiskont2(\$data[price]*{$as_Quantity}, $current_site[Skidka], \$data[Discount]).\"</span></td>
<th></th>
</tr>
")."
".as_if($totalsum+=as_query("SELECT price FROM Data".$as_ObjectID." WHERE Data_ID=$as_ItemID","\$data[price]")*$as_Quantity*$as_Discount,"")."
")."
Оцените.
Этот кусок кода хранится в поле таблицы бд, в котором хранится кусок шаблона формы корзины интернет-магазина.
Функция на шестой строке выводит общую сумму заказа при eval.
У меня ушло более двух часов, чтобы розыскать логику внутри семикратной (! я не шучу) вложенности include_once, чтобы в итоге понять, что запрос который я искал хранится в самой бд, причем не просто храниться, а хранится внутри бд, внутри php который хранится внутри html... Сам Доминик Кобб позавидовал бы степени вложенности моих кошмаров %)
+159
$t2 = db_query("SELECT
COUNT(*)
FROM
order_delivery_offers AS odf,
uc_orders AS uo
WHERE
odf.order_id = uo.order_id AND
uo.uid = $uid AND
uo.order_status = 'accepted' AND
odf.status = 'accepted' AND
odf.visible = 1 AND
odf.active = 1
GROUP BY odf.order_id");
$count_rows2 = 0;
while ($r2 = db_fetch_array($t2)){
$count_rows2++;
}
Подсчет количества записей в запросе.
+160
const ORDER_FUNC_ARGS = '$a, $b';
const ORDER_FUNC_LOGIC = '$a=strlen($a);$b=strlen($b);return$a==$b?0:($a<$b?1:-1);';
// а дальше в одном из методов
$this->_userAgents = array_keys($browsers);
usort(
$this->_userAgents,
create_function(self::ORDER_FUNC_ARGS, self::ORDER_FUNC_LOGIC)
);
Для меня это странно выглядит
+159
protected $_never_allowed_regex = array(
"javascript\s*:" => '[removed]',
"expression\s*(\(|&\#40;)" => '[removed]', // CSS and IE
"vbscript\s*:" => '[removed]', // IE, surprise!
"Redirect\s+302" => '[removed]'
);
Это не разу не ковнокод, но строкой с // IE, surprise! не поделится, не смог)
ЗЫ. это CodeIgniter 2.0.3 класс Security, строка 52
+159
private function isBonusAddOK($code,$ffStr)
{
switch($code)
{
case 1:if(
($this->isBFFOK($ffStr,40) || $this->isBFFOK($ffStr,38) || $this->isBFFOK($ffStr,37)) &&
$this->isBFFOK($ffStr,24) && $this->isBFFOK($ffStr,19) &&
($this->isBFFOK($ffStr,42) || $this->isBFFOK($ffStr,43) || $this->isBFFOK($ffStr,44))
)return true;return false;
case 6:if(
($this->isBFFOK($ffStr,40) || $this->isBFFOK($ffStr,38) || $this->isBFFOK($ffStr,37)) &&
$this->isBFFOK($ffStr,24) && $this->isBFFOK($ffStr,20) &&
($this->isBFFOK($ffStr,42) || $this->isBFFOK($ffStr,43) || $this->isBFFOK($ffStr,44))
)return true;return false;
case 11:if(
$this->isBFFOK($ffStr,24) &&
($this->isBFFOK($ffStr,16) || $this->isBFFOK($ffStr,358) || $this->isBFFOK($ffStr,360) || $this->isBFFOK($ffStr,361)) &&
$this->isBFFOK($ffStr,62) &&
($this->isBFFOK($ffStr,64) || $this->isBFFOK($ffStr,352) || $this->isBFFOK($ffStr,356) || $this->isBFFOK($ffStr,363)) &&
($this->isBFFOK($ffStr,3) || $this->isBFFOK($ffStr,4) || $this->isBFFOK($ffStr,5))
)return true;return false;
case 14:if(
$this->isBFFOK($ffStr,24) &&
($this->isBFFOK($ffStr,16) || $this->isBFFOK($ffStr,358) || $this->isBFFOK($ffStr,360) || $this->isBFFOK($ffStr,361)) &&
$this->isBFFOK($ffStr,61) &&
($this->isBFFOK($ffStr,64) || $this->isBFFOK($ffStr,352) || $this->isBFFOK($ffStr,356) || $this->isBFFOK($ffStr,363)) &&
($this->isBFFOK($ffStr,3) || $this->isBFFOK($ffStr,4) || $this->isBFFOK($ffStr,5))
)return true;return false;
case 17:if(
($this->isBFFOK($ffStr,16) || $this->isBFFOK($ffStr,358) || $this->isBFFOK($ffStr,360) || $this->isBFFOK($ffStr,361)) &&
($this->isBFFOK($ffStr,64) || $this->isBFFOK($ffStr,352) || $this->isBFFOK($ffStr,356) || $this->isBFFOK($ffStr,363)) &&
($this->isBFFOK($ffStr,3) || $this->isBFFOK($ffStr,4) || $this->isBFFOK($ffStr,5)) &&
$this->isBFFOK($ffStr,17)
)return true;return false;
case 20:if(
($this->isBFFOK($ffStr,16) || $this->isBFFOK($ffStr,358) || $this->isBFFOK($ffStr,360) || $this->isBFFOK($ffStr,361)) &&
($this->isBFFOK($ffStr,64) || $this->isBFFOK($ffStr,352) || $this->isBFFOK($ffStr,356) || $this->isBFFOK($ffStr,363)) &&
($this->isBFFOK($ffStr,3) || $this->isBFFOK($ffStr,4) || $this->isBFFOK($ffStr,5)) &&
$this->isBFFOK($ffStr,25) && $this->isBFFOK($ffStr,21)
)return true;return false;
case 23:if(
($this->isBFFOK($ffStr,16) || $this->isBFFOK($ffStr,358) || $this->isBFFOK($ffStr,360) || $this->isBFFOK($ffStr,361)) &&
($this->isBFFOK($ffStr,64) || $this->isBFFOK($ffStr,352) || $this->isBFFOK($ffStr,356) || $this->isBFFOK($ffStr,363)) &&
($this->isBFFOK($ffStr,3) || $this->isBFFOK($ffStr,4) || $this->isBFFOK($ffStr,5)) &&
$this->isBFFOK($ffStr,21)
)return true;return false;
.... еще куча строк до значения 88
default: return true;
}
}
private function isBFFOK($ffStr,$pos)
{
$val = substr($ffStr,$pos,1);//echo $pos.':'.$val;var_dump(($val != '0'));echo ' ';
return ($val != '0');
/*if($val == 0)return false;
ИфЗебок
+167
( $resultat == 1 AND $resultat != '' AND $resultat != 0 ) ? true : false;
Что-бы наверняка.