- 1
Я упал
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+3
Я упал
+2
<?if( $arResult['PROPERTIES']['NOT_ALLOWED']['VALUE'] == 'да' || $arItem["PROPERTIES"]["NOT_ALLOWED"]["VALUE_XML_ID"] == "Y" ) { ?>
<div class="alert-empty alert--licence">
<?$APPLICATION->IncludeComponent(
"bitrix:main.include",
"",
Array(
"AREA_FILE_SHOW" => "file",
"PATH" => SITE_DIR."/inc/card_not_allowed.php",
"EDIT_TEMPLATE" => ""
)
);?>
Платформа Битрикс, очередное творение Lenal в шаблоне компонента.
Сравнение значения с КИРИЛИЦЕЙ в template.php.
+3
public function favoriteCount($userId) {
$query = $this->db->query("SELECT * FROM ".DB_PREFIX."favorite WHERE customer_id =".$this->db->escape($userId));
$rows = $query->rows;
return count($rows);
}
Opencart.
Потому что агрегатные функции для слабаков!
+2
//-----Если жмут submit(кнопку)-----//
if(isset($_REQUEST['reg']))
Really ? :D
+1
header.php
<?$APPLICATION->IncludeComponent(
"lenal:lenal.menu",
"mobile",
array(
"VIEW_MODE" => "LINE",
"SHOW_PARENT_NAME" => "Y",
"IBLOCK_TYPE" => "catalog",
"IBLOCK_ID" => "39",
"SECTION_ID" => $_REQUEST["SECTION_ID"],
"SECTION_CODE" => "",
"SECTION_URL" => "",
"COUNT_ELEMENTS" => "N",
"TOP_DEPTH" => "1",
"SECTION_FIELDS" => array(
0 => "",
1 => "",
),
"SECTION_USER_FIELDS" => array(
0 => "UF_MOST_POPULAR",
1 => "",
),
"ADD_SECTIONS_CHAIN" => "Y",
"CACHE_TYPE" => "A",
"CACHE_TIME" => "36000000",
"CACHE_GROUPS" => "Y",
"COMPONENT_TEMPLATE" => "ds_main_menu",
"MAX_COUNT" => "12",
"MAX_ACTIONS" => "4",
"MAX_POPULAR" => "5"
),
false
);?>
/**************************************************************/
component.php
if(!isset($arParams["CACHE_TIME"]))
$arParams["CACHE_TIME"] = 36000000;
if($this->StartResultCache(false, ($arParams["CACHE_GROUPS"]==="N"? false: $USER->GetGroups())))
{
if(!\Bitrix\Main\Loader::includeModule("iblock"))
{
$this->AbortResultCache();
ShowError(GetMessage("IBLOCK_MODULE_NOT_INSTALLED"));
return;
}
/**************************************************************/
В параметрах стоит "SECTION_ID" => $_REQUEST["SECTION_ID"] и единственным условием сброса кеша ("CACHE_TIME" => "36000000") является отсутствие одного из основных модулей.
Результат: по 99 460 файлов кеша на каждый сайт. И это - простое МЕНЮ.
Производство компания Lenal, платформа 1С-Битрикс
+6
StringBuilder text = new StringBuilder();
for (char letter : section.getName().toCharArray()){
text.append(Character.toUpperCase(letter));
}
Вот так мы приводим текст к верхнему регистру
+2
$this->a[$this->c[$this->m]] = my_substr($this->t, $prev[2], ($v[0] - $prev[2]));
Кусочек кустарного говношаблонизатора.
Без комментариев. В обоих смыслах.
+6
switch ($m->type) {
case 'photo':
echo sprintf('<div class="fb_photo %s"><a %s href="%s"><div style="background-image: url(\'%s\');"><b>%s</b><br>%s%s<div class="status">%s <img src="%s" /> %s <img src="%s" /></div></div></div>', ($showProfilePic ? 'padding65' : ''), (isset($_GET['nonavbar']) ? 'target="_top"' : 'target="_blank"'), $m->link . (isset($_GET['nonavbar']) ? '&openwithnavigation=1' : ''), str_replace("_s", "_n", $m->picture), $m->from->name, (!empty($m->message) ? $m->message.'<br>' : ''), ago($m->created_time, $timezone), isset($m->likes) && isset($m->likes->count) ? $m->likes->count : '', isset($m->likes) && isset($m->likes->count) ? buildUri('images/icons/like.png') : '', isset($m->comments) && isset($m->comments->count) ? $m->comments->count : '', isset($m->comments) && isset($m->comments->count) ? buildUri('images/icons/comment.png') : '');
break;
case 'video':
case 'link':
echo sprintf('<div class="fb_link %s"><a %s href="%s"><div style="width: 100%%; padding: 30px; box-sizing: border-box;border-bottom:1px solid #ccc;border-top:1px solid #ccc;"><img style="max-width: none; width:100px;" src="%s" /><div style="width: 100%%"><b>%s</b><br>%s</div></div><div style="position:absolute; right: 10px; bottom: 10px;" class="status">%s <img style="display: inline-block" src="%s" /> %s <img style="display: inline-block" src="%s" /></div></a></div>', ($showProfilePic ? 'padding65' : ''), (isset($_GET['nonavbar']) ? 'target="_top"' : 'target="_blank"'), $m->link . (isset($_GET['nonavbar']) ? '&openwithnavigation=1' : ''), $m->picture, $m->name, $m->message, ago($m->created_time, $timezone), isset($m->likes) && isset($m->likes->count) ? $m->likes->count : '', isset($m->likes) && isset($m->likes->count) ? buildUri('images/icons/like.png') : '', isset($m->comments) && isset($m->comments->count) ? $m->comments->count : '', isset($m->comments) && isset($m->comments->count) ? buildUri('images/icons/comment.png') : '');
//echo sprintf('<div class="fb_link"><a href="%s"><div><img src="%s" /><b>%s</b><br>%s<div class="status">%s likes, %s comments</div></div></div></div>', $m->link, str_replace("_s", "_n", $m->picture), $m->from->name, $m->message, $m->likes->count, $m->comments->count);
break;
case 'status':
echo sprintf('<div class="fb_link %s"><a %s href="%s"><div style="width: 100%%; padding: 30px; box-sizing: border-box;border-bottom:1px solid #ccc;border-top:1px solid #ccc;"><img style="max-width: none; width:100px;" src="%s" /><div style="width: 100%%"><b>%s</b><br>%s</div></div><div style="position:absolute; right: 10px; bottom: 10px;" class="status">%s <img style="display: inline-block" src="%s" /> %s <img style="display: inline-block" src="%s" /></div></a></div>', ($showProfilePic ? 'padding65' : ''), '', '', $m->picture, $m->name, $m->message, ago($m->created_time, $timezone), isset($m->likes) && isset($m->likes->count) ? $m->likes->count : '', isset($m->likes) && isset($m->likes->count) ? buildUri('images/icons/like.png') : '', isset($m->comments) && isset($m->comments->count) ? $m->comments->count : '', isset($m->comments) && isset($m->comments->count) ? buildUri('images/icons/comment.png') : '');
break;
default:
//echo 'TODO: ' . $m->type;
//var_dump($m);
break;
}
Верстка.
Уровень - бог.
−1
AnsiString message=IntToStr((int)GetTickCount());
if(message.Length()>=3)
message=message.SubString(message.Length()-3, 3);
else if(message.Length()==2)
message="0"+message;
else if(message.Length()==1)
message="00"+message;
message=dt.FormatString("yy")+dt.FormatString("mm")+dt.FormatString("dd")+" "+
dt.FormatString("hh")+dt.FormatString("nn")+dt.FormatString("ss")+" "+message;
message=message+" "+aMessage;
if(FMemoMes){
FMemoMes->Lines->Add(message);
}
Выводит сообщение aMessage, вставляя в начало сообщения текущие дату и время с миллисекундами.
0
function setLastHandshake ($carID) {
$HsList = json_decode(file_get_contents('carconnection.txt'), 1);
if ($HsList == "null" || $HsList == null) {
$HsList = json_decode("[]");
}
$carCount = count($HsList);
$i = 0;
foreach ($HsList as &$row) {
if ($row['car'] == $carID) {
$row['lastHS'] = (string)time();
break;
}
else {
$i++;
}
if ($i == $carCount) {
$HsList[] = array('car' => (string)$carID, 'lastHS' => (string)time());
}
}
if ($HsList == "null" || $HsList == null) {
return -1;
}
$f = fopen('carconnection.txt', 'w');
fwrite($f, json_encode($HsList));
}