- 1
if ($invitationType == '1' || '2') {}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+10
if ($invitationType == '1' || '2') {}
Indian validation. WHYYYYY?
+3
Point3D& operator /= (const float f) { x/=f; y/=f; z/=f; return *this; }
ебать я лох
0
public static GridElementForm SetConnectionState(GridElement[][] _map, int x, int y)
{
int right;
int left;
int up;
int down;
try { right = (int)_map[x - 1][y].elementType; }
catch { right = 0; }
try { left = (int)_map[x + 1][y].elementType; }
catch { left = 0; }
try { up = (int)_map[x][y - 1].elementType; } catch { up = 0; }
try { down = (int)_map[x][y + 1].elementType; } catch { down = 0; }
//**** I
if (right >= 1 && left >= 1 && up == 0 && down == 0)
{
return GridElementForm.Ihorizontal;
}
else if (right == 0 && left == 0 && up > 0 && down > 0)
{
return GridElementForm.Ivertical;
}
///*********
/// ***** T
else if (right > 0 && left == 0 && up > 0 && down > 0)
{
return GridElementForm.T1;
}
else if (right == 0 && left > 0 && up > 0 && down > 0)
{
return GridElementForm.T2;
}
else if (right > 0 && left > 0 && up == 0 && down > 0)
{
return GridElementForm.T3;
}
else if (right > 0 && left > 0 && up > 0 && down == 0)
{
return GridElementForm.T4;
}
/// *******
/// ******* L
else if (right > 0 && left == 0 && up > 0 && down == 0)
{
return GridElementForm.L2;
}
else if (right == 0 && left > 0 && up > 0 && down == 0)
{
return GridElementForm.L1;
}
else if (right == 0 && left > 0 && up == 0 && down > 0)
{
return GridElementForm.L4;
}
else if (right > 0 && left == 0 && up == 0 && down > 0)
{
return GridElementForm.L3;
}
/// *******
else if (right > 0 && left > 0 && up > 0 && down > 0)
{
return GridElementForm.X;
}
else
{
return 0;
}
}
}
Без комментариев
+8
//как создать сильный пароль в php
$hp = md5(md5(md5(strong($_POST['hp'])))); // типо наш пароль
//а что же такое strong??
###############################
######## Фильтрация ###########
###############################
function strong($msg){
$msg = trim($msg);
$msg = htmlspecialchars($msg);
$msg = mysql_escape_string($msg);
return $msg;
}
Мануал по шифрованию паролей.
+3
###############################
##### Проверяем сылку гет #####
###############################
foreach ($_GET as $links) {
if (!is_string($links) || !preg_match('#^(?:[a-z0-9_\-/]+|\.+(?!/))*$#i', $links)) {
header ('Location: '.$HOME.'');
exit;
}
}
unset($links);
Защита с strongcms v.1.1 . Офф сайт strongcms.ru
---
P.s. продам такую же защиту на $_POST данные ))
+2
//-----Если жмут submit(кнопку)-----//
if(isset($_REQUEST['reg']))
Really ? :D
+5
$sql = mysql_query("SELECT * FROM `news` ORDER BY `id` DESC LIMIT 1");
while($sql1 = mysql_fetch_assoc($sql))
{
echo ''.smile(bb($sql1['text'])).'<br />
Добавил: '.nick($sql1['avtor']).'<br />
<a href="/news/comment'.$sql1['id'].'">Комментарии:</a> ('.mysql_result(mysql_query('select count(`id`) from `news_com` where `news` = "'.$sql1['id'].'"'),0).')';
if($user['id']) {
echo '<br /><a href="?news='.$sql1['id'].'">Скрыть новость</a>';}
if(isset($_GET['news']))
{
$news= trim(intval($_GET['news']));
mysql_query("UPDATE `users` SET `news` = '".$news."' WHERE `id` = '".$user['id']."'");
header('Location: '.$HOME.'');
}
}
Исходники супер сильной cms 2016 ! Встречайте StrongCMS! Версия движка 1.1. Скачать можно на strongcms.ru :)
+3
template<class... Bases>
struct MaminVisitor: public boost::static_visitor<>, public Bases... {
MaminVisitor(Bases&&... bases) : Bases(std::move(bases))... { }
};
template<class Variant, class... F>
void match(Variant &&v, F &&... functors) {
typedef MaminVisitor<typename std::decay<F>::type...> visitor_t;
boost::apply_visitor(visitor_t(std::move(functors)...), std::forward<Variant>(v));
}
int main() {
boost::variant<int, double, std::string> v = "ololo";
match(v,
[&](auto x) {
std::cout << "auto branch " << x << std::endl;
},
[&](double x) {
std::cout << "double branch " << x << std::endl;
}
);
return 0;
}
Сделал няшный матч, а на гцц не конпелируется.
http://ideone.com/J9ulsr
+3
if (Expires != 0 && Expires.ToString() != "9223372036854775807")
{
...
}
Expires типа long
+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С-Битрикс