- 1
- 2
- 3
- 4
- 5
$razn = mktime(0,0,0,$m,$d,$y);
$vozrast = (time() - $razn) / 31536000;
return explode(".",$vozrast);
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+161
$razn = mktime(0,0,0,$m,$d,$y);
$vozrast = (time() - $razn) / 31536000;
return explode(".",$vozrast);
из кода одного крупного сайта, сделанного на заказ
+157
$wpdb->query($wpdb->prepare("INSERT INTO `".WPSC_TABLE_CART_CONTENTS."` (`prodid`, `name`, `purchaseid`, `price`, `pnp`,`tax_charged`, `gst`, `quantity`, `donation`, `no_shipping`, `custom_message`, `files`, `meta`) VALUES ('%d', '%s', '%d', '%s', '%s', '%s', '%s', '%s', '%d', '0', '%s', '%s', NULL)", $this->product_id, $this->product_name, $purchase_log_id, $this->unit_price, (float)$shipping, (float)$tax, (float)$tax_rate, $this->quantity, $this->is_donation, $this->custom_message, serialize($this->custom_file)));
$cart_id = $wpdb->get_var("SELECT LAST_INSERT_ID() AS `id` FROM `".WPSC_TABLE_CART_CONTENTS."` LIMIT 1");
Это код WP-Ecommerce. Ахтунг!
+163
<?php
// Создание массива из строки
if($_POST['add_array']=="Получит массив")
{
// новый массив для заполнения значениями
$new_arr = array();
$text = explode(",", htmlspecialchars($_POST['text']));
for($i=0; $i<count($text); $i++)
{
$vol = "<".$text[$i].">";
array_push($new_arr,$vol);
}
print_r($new_arr);
}
?>
<form method="post" action="">
Введите текст:<br>
<textarea name="text" cols="70" rows="5"></textarea>
<br>
<br>
<input name="add_array" type="submit" value="Получит массив">
</form>
Нашел на одном сайте с уроками по PHP.
+75
float lan = getLan();
float lon = getLan();
if(lan == lan || lon == lon)
{
throw new RuntimeException("Bad value");
}
Из моего реалного проекта. Этот код реально делает полезную вещь
+158
switch(filter)
{
case FILTER_SPECIAL:
{
if ( ( u8Direction >= 0xF0 ) || ( u8Direction <= 0x0F ) )
{
return 0x0;
}
else if ( ( u8Direction >= 0x10 ) && ( u8Direction <= 0x2F ) )
{
return 0x2;
}
else if ( ( u8Direction >= 0x30 ) && ( u8Direction <= 0x4F ) )
{
return 0x4;
}
else if ( ( u8Direction >= 0x50 ) && ( u8Direction <= 0x7F ) )
{
return 0x6;
}
else if ( u8Direction == 0x80 )
{
return 0x8;
}
else if ( ( u8Direction >= 0x81 ) && ( u8Direction <= 0xAF ) )
{
return 0xA;
}
else if ( ( u8Direction >= 0xB0 ) && ( u8Direction <= 0xCF ) )
{
return 0xC;
}
else if ( ( u8Direction >= 0xD0 ) && ( u8Direction <= 0xEF ) )
{
return 0xE;
}
break;
}
case FILTER_NORMAL:
--//--
break;
case FILTER_BACKWARD_DIRECTION:
--//--
break;
}
Сферический индокод в вакууме
+117
if (str_45_ik.ToString() == "".ToString())
Вот такое неоптимальное говно осталось от предков. Нужно было использовать string.IsNullOrEmpty.
+109
if (embededDatasourceItem.Text.Localized(language) == string.Empty)
Это вместо string.IsNullOrEmpty
+114
<?php
function initiate()
{
$logged_in = false;
if(isset($_SESSION['user_name']))
{
$logged_in = true;
}
// Check that cookie is set
if(isset($_COOKIE['auth_key']))
{
$auth_key = safe_var($_COOKIE['auth_key']);
if($logged_in === false)
{
// Select user from database where auth key matches (auth keys are unique)
$auth_key_query = mysql_query("SELECT username, password FROM users WHERE auth_key = '" . $auth_key . "' LIMIT 1");
if($auth_key_query === false)
{
// If auth key does not belong to a user delete the cookie
setcookie("auth_key", "", time() - 3600);
}
else
{
while($u = mysql_fetch_array($auth_key_query))
{
// Go ahead and log in
login($u['username'], $u['password'], true);
}
}
}
else
{
setcookie("auth_key", "", time() - 3600);
}
}
}
?>
Там целый сайт такого кода полный http://www.ruseller.com/lessons.php?rub=28&id=427
+176
function NDS($poisk)
{
preg_match('#БЕЗ НДС#', $poisk, $matches);
if(empty($matches[0]))
{
preg_match('#без НДС#', $poisk, $matches);
if(empty($matches[0]))
{
preg_match('#НДС НЕТ#', $poisk, $matches);
if(empty($matches[0]))
{
preg_match('#НДС нет#', $poisk, $matches);
if(empty($matches[0]))
{
preg_match('#НДС не облагается#', $poisk, $matches);
if(empty($matches[0]))
{
preg_match('#НДС НЕ ОБЛАГАЕТСЯ#', $poisk, $matches);
if(empty($matches[0]))
{
preg_match('#НДС НЕ ПРЕДУСМОТРЕН#', $poisk, $matches);
if(empty($matches[0]))
{
preg_match('#Без налога (НДС)#', $poisk, $matches);
if(empty($matches[0]))
{
preg_match('#НДС: БЕЗ НАЛОГА#', $poisk, $matches);
if(empty($matches[0]))
{
preg_match('#Без НДС#', $poisk, $matches);
if(empty($matches[0]))
{
preg_match('#без налога (НДС)#', $poisk, $matches);
if(empty($matches[0]))
{}
else return true;
}
else return true;
}
else return true;
}
else return true;
}
else return true;
}
else return true;
}
else return true;
}
else return true;
}
else return true;
}
else return true;
}
else return true;
}
Обнаружено в старом проекте заказчика
+97
{
----------------------8<----------------------
Цей юніт призначений лише для використання
разом із пакетом програм ███████
будь-якої версії.
Він не може розповсюджуватися окремо, так
як являється частиною пакету, який може
розповсюджуватися на платній основі.
(С) Copyright ███████████████
----------------------8<----------------------
}
(* ~15 строк поскипано за унылостью *)
procedure TranslateForm(var form:TObject; const LNGFile:String);
var
ini:TIniW;
c1,c2,p1,p2,i:Integer;
Sct,par,val:string;
keys:TStringList;
cobg:TObject;
comp:TComponent;
begin
initini(ini,LNGFile);
keys:=TStringList.Create;
sct:=Trim((form as TForm).Name);
c1:=ini.KeyCount(Sct);
ini.ReadSection(Sct,keys);
cobg:=(form as TObject);
for I := 0 to c1-1 do
begin
par:=keys[I];
p1:=Pos('=',par);
par:=Trim(Copy(par,0,p1-1));
val:=ini.ReadString(Sct,par,'read error');
typinfo.SetStrProp(cobg,par,val);
end;
c2:=(form as TForm).ComponentCount;
for p2 := 0 to c2 - 1 do
begin
comp:=(form as TForm).Components[p2];
cobg:=(comp as TObject);
sct:=typinfo.GetStrProp(cobg,'Name');
c1:=ini.KeyCount(Sct);
if c1>0 then
ini.ReadSection(Sct,keys);
for I := 0 to c1-1 do
begin
par:=keys[I];
p1:=Pos('=',par);
par:=Trim(Copy(par,0,p1-1));
val:=ini.ReadString(Sct,par,'read error');
try
typinfo.SetStrProp(cobg,par,val);
except
end;
end;
end;
end;
end.
Сверху - жадность, снизу - отсутствие скиллов.