- 1
- 2
Результат работы нашего бывшего верстальщика.
http://pastebin.com/sDndiz9Q
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+5
Результат работы нашего бывшего верстальщика.
http://pastebin.com/sDndiz9Q
Результат работы нашего бывшего верстальщика.
http://pastebin.com/sDndiz9Q
+1
<ul id="top_menu" alias="{$alias}" parentAlias="{$parentAlias}">
{foreach $items as $i}
{*{$i->parentId == null} :)*}
{if $i->parentId == null}
<li class="{if $alias === $i->alias || $parentAlias === $i->alias}active{/if}"><a href="{Yii::app()->params->languageUrl}/{$i->alias}" onclick="return false;">{$i->lang->name}</a>
<ul class="sub" style="display: none;">
{foreach $items as $ii}
{if $ii->parentId == $i->id}
<li class="{if $alias === $ii->alias || $parentAlias === $ii->alias}active{/if}">
{if $ii->hasAction > 0}
<a href="{if $ii->alias!==''}{Yii::app()->params->languageUrl}/{$ii->alias}{/if}">{$ii->lang->name}</a>
{else}
<a href="{Yii::app()->params->languageUrl}/{$i->alias}{if $ii->alias!==''}/{$ii->alias}{/if}">{$ii->lang->name}</a>
{/if}
</li>
{/if}
{/foreach}
</ul>
</li>
{/if}
{/foreach}
</ul>
Типичное меню на фреймворках.
В данном случае Yii
+1
<script type="text/javascript" src="{$assetsUrl}/js/controllers/news.js"></script>
<div class="breadcrumbs">
<span typeof="v:Breadcrumb" ><a href="/" style="color: #000000;">{Y::t('MainMenu', 'Главная')}</a></span> /
<span typeof="v:Breadcrumb" style="color: red;">{$this->title}</span>
</div>
<div class="news_sections">
<ul>
{assign comment ''}
{foreach from=Trololo::model()->newsTypes() key=k item=n}
{if Yii::app()->request->getParam('rubric')==$k}
{assign comment $n['comment']}
<li class="active"><span>{$n['label']}</span></li>
{else}
<li class=""><span><a href="{Yii::app()->params->languageUrl}/news/rubric/{$k}">{$n['label']}</a></span></li>
{/if}
{/foreach}
</ul>
</div>
<h1 class="page_title">{$comment}</h1>
Типичный шаблон на фреймворке.
В данном случае - Yii.
+1
<?
namespace components\max;
class articles_element
{
static function run($_arParams)
{
$arParams = &$_arParams['PARAMS'];
$tm = &$_arParams['tm'];
$user = &$tm->user;
$code = $arParams['CODE'];
$arCache = array(
'prefix' => 'show',
'sufix' => $code,
'time' => -1,
'lang' => LANGUAGE_ID,
);
$tm->loadLang('show');
$arSelect = array(
'E.id',
'E.active',
'rel',
'time',
'code',
'date_active_from',
'title_'.LANGUAGE_ID.' AS title' => $tm->conf['LANG_FALLBACKS'][LANGUAGE_ID],
'content_'.LANGUAGE_ID.' AS content' => $tm->conf['LANG_FALLBACKS'][LANGUAGE_ID],
'author_id',
'only_for_auth_users',
'source_url',
'source_author',
'source_date',
);
$arJoin = [];
if($tm->conf['show']['show_additional'])
{
$arSelect[] = 'GROUP_CONCAT(show2category.category_id) AS categories';
$arJoin[\CShow2Category::$table.' show2category ON E.id = show2category.show_id'] = 'LEFT';
}
$arFilter = array('E.code' => $code, 'E.site_id' => $tm->conf['site_id']);
$dbShow = \CShow::GetList(false, $arFilter, ['E.id'], array('nTopCount' => 1), $arSelect, $arJoin);
while($arShow = mysql_fetch_assoc($dbShow))
{
$arShow['title'] = htmlspecialchars($arShow['title']);
if(!empty($arShow['categories']))
{
$arShow['categories'] = explode(',', $arShow['categories']);
}
$arShow['time_write'] = date("d.m.Y", $arShow['date_active_from']);
$arShow['only_for_auth_users'] = $arResult['only_for_auth_users'] && empty($tm->user['id']);
$arResult = $arShow;
if($arResult['only_for_auth_users'])
{
$arResult['title'] = GetMessage('ERROR_ONLY_AUTH');
}
$tm->setLastModifiedTime($arShow['date_active_from']);
$tm->setBuffered('title', $arResult['title'].' | '.GetMessage('sitename'));
$tm->setBuffered('h1', $arResult['title']);
}
if(empty($arResult))
{
// Проверяем редиректы
$arParamsRedirects = array(
'code' => $arFilter['code'],
'module' => 'show',
);
$tm->redirects_modules($arParamsRedirects);
$tm->pagenotfound();
}
$arResult['user_status'] = $user['sts'];
if($tm->conf['show']['show_additional'] && !empty($arResult['categories']))
{
$arFilter = [
'active' => 1,
'show2category.category_id' => $arResult['categories'],
'!E.id' => $arResult['id'],
];
$arSelect = [
'E.id',
'code',
'title_'.LANGUAGE_ID.' AS title' => $tm->conf['LANG_FALLBACKS'][LANGUAGE_ID],
Код от противника фреймворков (это контроллер). Цитата виновника торжества:
"У меня роутинга нету За роутинг отвечает nginx (ранее отвечал .htaccess)"
+2
<select tabindex="8" id="inputBirthMonth" class="input-small form-control" name="month">
<option value="0">--</option>
<option
value="1" <?php $month = 0;
if (isset($specificdata['month'])) {
$month = @$specificdata['month'];
}
if (1 == $month) {
echo "selected";
}
?»<?php echo lang('Main:january'); ?></option>
<option
value="2" <?php if (2 == @$month) {
echo "selected";
}
?»<?php echo lang('Main:february'); ?></option>
<option
value="3" <?php if (3 == @$month) {
echo "selected";
}
?»<?php echo lang('Main:march'); ?></option>
<option
value="4" <?php if (4 == @$month) {
echo "selected";
}
?»<?php echo lang('Main:april'); ?></option>
<option
value="5" <?php if (5 == @$month) {
echo "selected";
}
?»<?php echo lang('Main:may'); ?></option>
<option
value="6" <?php if (6 == @$month) {
echo "selected";
}
?»<?php echo lang('Main:june'); ?></option>
<option
value="7" <?php if (7 == @$month) {
echo "selected";
}
?»<?php echo lang('Main:july'); ?></option>
<option
value="8" <?php if (8 == @$month) {
echo "selected";
}
?»<?php echo lang('Main:august'); ?></option>
<option
value="9" <?php if (9 == @$month) {
echo "selected";
}
?»<?php echo lang('Main:september'); ?></option>
<option
value="10" <?php if (10 == @$month) {
echo "selected";
}
?»<?php echo lang('Main:october'); ?></option>
<option
value="11" <?php if (11 == @$month) {
echo "selected";
}
?»<?php echo lang('Main:november'); ?></option>
<option
value="12" <?php if (12 == @$month) {
echo "selected";
}
?»<?php echo lang('Main:december'); ?></option>
</select>
Month dropdown select in registration form
+1
<p class="name">
{% if (file.url) { %}
<a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" {%=file.thumbnailUrl?'data-gallery':''%}>{%=file.name%}</a>
{% } else { %}
<span>{%=file.name%}</span>
{% } %}
</p>
{% if (file.error!="SyntaxError: Unexpected token <") { %}
<div><span class="label label-danger">Error</span> {%=file.error%}</div>
{% } %}
Шедевральный человек! Оригинал http://www.yiiframework.ru/forum/viewtopic.php?t=15956#p119944
+2
public function get($userId = null, $advense = false) {
if ($userId === null) $userId = $this->currentId;
$user = DB::table('users')
->select(
'*',
DB::raw('IF(email IS NOT NULL AND email_confirm IS NULL, 1, 0) AS email_confirm'),
DB::raw('IF(phone IS NOT NULL AND phone_confirm IS NULL, 1, 0) AS phone_confirm'),
DB::raw('IF(birthday IS NOT NULL, TIMESTAMPDIFF(YEAR,birthday,CURDATE()), NULL) AS age'),
DB::raw('IF(phone IS NOT NULL AND phone_confirm IS NULL AND email IS NOT NULL AND email_confirm IS NULL AND (new_first_name IS NOT NULL OR new_last_name IS NOT NULL OR new_status_text IS NOT NULL OR new_image_url IS NOT NULL), 1, 0) AS on_moderate'))
->where('id', $userId)->first();
if ($user === null) throw new Exception ('User is not found', 404);
unset($user->password);
$user->locality = Geo::get($user->locality_id);
$rating = $this->rating($userId);
$user->rating = (float)$rating->avg;
$user->rating_counter = (int)$rating->cnt;
$user->counters = $this->getCounters($userId);
$contact = $this->contacts->isMyContact($userId);
if ($userId != $this->currentId) {
$user->created = null;
$user->updated = null;
$user->birthday = null;
$user->email_confirm = null;
$user->phone_confirm = null;
$user->subscribed = null;
$user->organizations = null;
$contact = $this->contacts->isMyContact($userId);
// Если пользователь не контакт авторизованного, сотрем контактную информацию
if ( $contact === null || $contact === 'declined') {
$user->phone = null;
$user->email = null;
$user->last_name = mb_substr($user->last_name, 0, 1, 'UTF-8');
}
} else {
if($user->new_first_name !== null) {
$user->first_name = $user->new_first_name;
}
if($user->new_last_name !== null) {
$user->last_name = $user->new_last_name;
}
if($user->new_image_url !== null) {
$user->image_url = $user->new_image_url;
}
if($user->new_status_text !== null) {
$user->status_text = $user->new_status_text;
}
$user->organizations = Organizations\Organizations::getByUserId($userId);
$user->is_followed = null;
$user->is_my_contact = null;
$user->has_my_contact = null;
$user->has_my_opinion = null;
}
unset($user->new_status_text);
unset($user->new_image_url);
unset($user->new_last_name);
unset($user->new_first_name);
unset($user->reset_code);
$user->is_followed = $this->followers->isFollowed($userId);
$user->is_my_contact = $this->contacts->isMyContact($userId);
$user->has_my_contact = $this->contacts->hasMyContact($userId);
return $user;
}
Тыдыдыдыдыыыц, laravel code О_О
Что же тут вообще происходит?
+4
// Авторизация
$app->post('/action/login', function(Request $request, Response $response)
{
global $connection, $hash;
$data = $request->getParsedBody('login');
$login = $data['login'];
$password = md5($data['password']);
$result = mysqli_query($connection, "SELECT `password` FROM `users` WHERE `login` = '$login'");
$row = $result->fetch_assoc();
if(!empty($login) and !empty($password))
{
if($password === $row['password'])
{
$_SESSION['auth'] = $hash;
echo "<script>location.href='/log';</script>";
}
else
{
redirect();
}
}
});
+8
<?
function __echo($str){
return "$str\n";
}
function _echo ($str){
echo __echo($str);
}
function _echo_utf8($str){
_echo (iconv('windows-1251', 'UTF-8//IGNORE', $str));
}
_echo("<div id='class_edit_add' style='display:none;margin-left:30px;'>");
_echo("<div style='margin-bottom:30px;'><center>");
_echo_utf8("Добавить ");
_echo("<select id='chose_class_edit_add_something'>");
_echo("<option selected value='0'></option>");
_echo_utf8("<option value='1'>предмет</option>");
_echo_utf8("<option value='2'>учителя</option>");
_echo_utf8("<option value='3'>ученика</option>");
_echo_utf8("<option value='4'>подгруппу</option>");
_echo("</select>");
_echo("<input type='button' class='button' value='ok' onclick=\"class_edit_add_something();\">");
_echo("</сenter></div>");
_echo("<div id='div_class_edit_add_something_out' style='display:none'></div>");
_echo("</div>");
_echo_utf8
+4
<?if(false){?>
<ul class="top_nav_lang">
<?if($lang != 'en'){?><li><a href="en"><span>EN</span></a></li><?}?>
<?if($lang != 'bg'){?><li><a href="bg"><span>BG</span></a></li><?}?>
</ul>
<?}?>
выбор языка...