- 1
- 2
- 3
- 4
- 5
if($record->getTitle()) {
$request->setAttribute('title', $record->getTitle());
}else{
$request->setAttribute('title', $record->getName());
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+145.5
if($record->getTitle()) {
$request->setAttribute('title', $record->getTitle());
}else{
$request->setAttribute('title', $record->getName());
}
определение существования метода у объекта $record
+156.1
function CompletesGetTableOld($clist, $mid =0)
{
if(strlen($clist) or $mid > 0)
{
$com = CatalogComplsCostsGet(0, 0, $clist, $mid);
$csz = sizeof($com['id']);
if($csz > 0)
{
$param = CatalogComplParamsGet();
$psz = sizeof($param);
$tds = '';
$cVals = CatalogComplParamValsGet(implode(",", $com['cid']));
echo '
<table cellpadding="4" cellspacing="0" border="0" width="700" class="table-comp">
<tr><td width="50%" class="first"></td>
';
for($i = 0; $i < $csz; $i++)
{
echo '<td align="center">'.$com['name'][$i].'</td>';
$tds .= '<td> </td>';
}
echo '</tr>';
$prgrnm = '';
for($i = 0; $i < $psz; $i++)
{
$data = false;
$html = '';
if($i==0||$param[$i]['gr_name']!=$prgrnm)
{
$html='
<tr>
<td class="first"><br><b>'.$param[$i]['gr_name'].'</b></td>';for($ii = 0; $ii < $csz; $ii++)$html.='<td class="second" > </td>';
$html.= $tds.'
</tr>';
}
$html.= '
<tr>
<td class="first">'.$param[$i]['name'].'</td>';
for($ii = 0; $ii < $csz; $ii++)
{
@$val = $cVals[$com['cid'][$ii]][$param[$i]['id']];
if(isset($val) and strlen($val))
{
if($param[$i]['type'] == 'CH')
{
if($val == 1)
{
$html.= '<td class="second" align="center"><img src="/images/tochka.gif" ></td>';
$data = true;
}
else $html.= '<td class="second"> </td>';
}
else
{
$html.= '<td class="second" align="center">'.$val.'</td>';
$data = true;
}
}
else $html.= '<td class="second"> </td>';
}
$html.= '</tr>';
if($data)
{
$prgrnm = $param[$i]['gr_name'];
echo $html;
}
}
echo '
<tr><td width="50%" class="first"><b>????</b></td>';
for($i = 0; $i < $csz; $i++)
{
$cost = intval($com['cost'][$i]);
if($cost > 1000000) $cost = '<nobr>'.substr($cost, 0, -6)." ".substr($cost, 1, -3).". ".substr($cost, 4).'</nobr> ???';
elseif($cost > 100) $cost = '<nobr>'.substr($cost, 0, -3)." ".substr($cost, strlen($cost)-3).'</nobr> ???';
else $cost = '';
echo '<td class="second" align="center" height="30">'.$cost.'</td>';
}
echo '</tr>
</table>';
return true;
}
}
return false;
}
обратите внимание на переменную $data. долго и упорно собираем из кусочков $html, и только если $data истинно тогда выводим $html (примерно 5-10% случаев)
+160.6
$query=mysql_query("SELECT * FROM `PS_card_list` WHERE `id_categ`='".$_GET['point']."';");
while ($row=mysql_fetch_array($query)) $card_on_plan++;
Наследие военных разработчиков
+147.7
$this->view->isAdmin = ($auth->getIdentity()->role_id == 1) ? true : false;
Называется: "заработался".
Написал и только потом дошло.
+185.3
echo "Время генерации: 0.0".rand(10,99)." сек.";
Без комментариев))) Я под столом))
+164.7
$db = new mysqli(MYSQL_HOST,MYSQL_USER,MYSQL_PASSWORD,MYSQL_DATABASE);
$query = 'UPDATE registration SET choose_style="'.$_POST['style'].'" WHERE registration_id='.$profile_id;
$result = $db->query($query);
if ($result && $db->affected_rows > 0) {
echo 'Стиль успешно изменен. Закройте браузер и зайдите снова.';
} else {
echo 'Стиль не изменен';
echo $db->error;
}
"Закройте браузер и зайдите снова" )))
+156.2
// from views_bonus: grid.inc
function theme_og_picture_grid($result, $column_count = 5) {
$content = '<table class="og-picture-grid">';
$count = 0;
$total = db_num_rows($result);
while ($user = db_fetch_object($result)) {
$classes = 'og-picture-grid-item';
if ($count < $column_count) {
$classes .= ' first';
}
$item = '';
if ($count % $column_count == 0) {
$content .= '<tr>';
}
$picture = theme('user_picture', $user);
$name = theme('username', $user);
$group_role = $user->is_admin ? t('admin') : ' ';
$content .= "<td class=\"$classes\">$picture<div class=\"og-name\">$name</div>";
if ($user->is_admin) {
$txt = t('admin');
$content .= "<div class=\"group-role\">$txt</div>";
}
$content .= "</td>\n";
$count++;
if ($count % $column_count == 0 || $count == $total) {
$content .= '</tr>';
}
}
$content .= '</table>';
if ($total) {
return $content;
}
}
Меня ДУРЬпаловские финты просто бесят.
типа тема
+158
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ru" xml:lang="ru">
<head>
...
<?php
if( !isset($page['header']['links']) || empty($page['header']['links']) )
{
?>
<link rel="shortcut icon" href="/sites/all/themes/deco/favicon.ico" type="image/x-icon" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/node/node.css?t" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/poll/poll.css?t" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/system/defaults.css?t" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/system/system.css?t" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/system/system-menus.css?t" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/user/user.css?t" />
<link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/cck/theme/content-module.css?t" />
<link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/filefield/filefield.css?t" />
<link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/geshifilter/geshifilter.css?t" />
<link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/quote/quote.css?t" />
<link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/tagadelic/tagadelic.css?t" />
<link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/vote_up_down/vote_up_down.css?t" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/comment/comment.css?t" />
<link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/pr_cy/pr_cy.css?t" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/openid/openid.css?t" />
<link type="text/css" rel="stylesheet" media="all" href="/sites/all/themes/deco/style.css?t" />
<link type="text/css" rel="stylesheet" media="all" href="/examples/tagnetic/tags.css?t" />
<link type="text/css" rel="stylesheet" media="print" href="/sites/all/themes/deco/print.css?t" />
<script type="text/javascript" src="/misc/jquery.js?t"></script>
<script type="text/javascript" src="/misc/drupal.js?t"></script>
<script type="text/javascript" src="/files/languages/ru_5530db2a4478b35f94b4da1e2062c5fb.js?t"></script>
<script type="text/javascript" src="/sites/all/modules/vote_up_down/ajax_vote_up_down.js?t"></script>
<script type="text/javascript" src="/sites/all/themes/deco/jquery.tagnetic.js?t"></script>
<script type="text/javascript" src="/sites/all/themes/deco/jquery.tagnetic.settings.js?t"></script>
<script type="text/javascript" src="/modules/comment/comment.js?t"></script>
<script type="text/javascript" src="/misc/textarea.js?t"></script>
<script type="text/javascript" src="/sites/all/modules/pr_cy/pr_cy.js?t"></script>
<script type="text/javascript" src="/modules/openid/openid.js?t"></script>
<?php
}
else
{
echo $page['header']['links'];
}
?>
Я, конечно, понимаю, что это необходимо, но такие хеды у меня всегда вызывают улыбку)
+157.4
....
$str = str_replace(',', ' ', $this->searchString);
$str = str_replace(';', ' ', $str);
$str = str_replace('.', ' ', $str);
$str = str_replace(':', ' ', $str);
$str = str_replace('+', ' ', $str);
$str = str_replace('-', ' ', $str);
$str = str_replace('"', ' ', $str);
$str = str_replace("'", ' ', $str);
$str = trim(preg_replace('!\s{2,}!', ' ', $str));
.....
вот что я наклал как-то
+156.1
$_REQUEST['trigger']['event_params']['duration'] = $_REQUEST['trigger']['event_params']['duration']['hour']*60*60 + $_REQUEST['trigger']['event_params']['duration']['minute']*60 + $_REQUEST['trigger']['event_params']['duration']['seconds'];
if (empty($_REQUEST['trigger']['event_params']['frequency_period'])) {
$_REQUEST['trigger']['event_params']['frequency_count'] = '';
}
if (empty($_REQUEST['trigger']['event_params']['frequency_count'])) {
$_REQUEST['trigger']['event_params']['frequency_period'] = '';
}