- 1
- 2
- 3
- 4
- 5
if (isset($response['initialize'])) {
$initialize = $response['initialize'];
unset($response['initialize']);
$response['initialize'] = $initialize;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+5
if (isset($response['initialize'])) {
$initialize = $response['initialize'];
unset($response['initialize']);
$response['initialize'] = $initialize;
}
cometchat
(Как говорится, шаг вперед и два назад)
−1
if (COption::GetOptionString("vote", "VOTE_COMPATIBLE_OLD_TEMPLATE", "Y") == "N")
{
unset($arDisplayOptions[2]);
unset($arDisplayOptions[3]);
unset($arDisplayOptions[4]);
unset($arDisplayOptions[5]);
unset($arDisplayOptions[6]);
}
elseif ($old_module_version=="Y")
{
unset($arDisplayOptions[6]);
}
else
{
unset($arDisplayOptions[2]);
unset($arDisplayOptions[3]);
unset($arDisplayOptions[4]);
unset($arDisplayOptions[5]);
}
bitrix/modules/vote/options.php:44
−3
<?php
abstract class Upload {//Клас загрузка файлов на сервер //Класс, который не имеет реализации.
private $dir;//директория для загрузки
private $mime_type;//Некий mime_type
public function __construct($dir, $mime_type) {
$this->dir = $dir;
$this->mime_type = $mime_type;
}
public function UploadFile($file) {
if (!$this->isSequrity($file)) return false;
$dirupload = $_SERVER['DOCUMENT_ROOT']."/".$this->dir."/".$file['name'];
return move_uploaded_file($file['tmp_name'], $dirupload);
}
protected function isSequrity($file) {
$blacklist = array (".php", ".php3", ".php4", ".html", ".htm", ".exe", ".js", ".css");//Запрещено
foreach ($blacklist as $item) {
if (preg_match("/$item\$/i", $file["name"])) return false;
}
$type = $file["type"];//тип файла
$mime_types = $this->mime_type;
$i = 0;
foreach ($mime_types as $k => $v) {
if ($type == $v) break;//Если тип файла найден(равняется типу, что файл какого типа, то выходим из цикла.
if ($i + 1 === count($this->mime_type)) return false;
$i++;
}
$size = $file["size"];
if ($size > 2048000) return false;
return true;
}
}
?>
Код мне прислал адепт пРуссакова. С вопросом, "че не раблотает?". Собственно орфография, пунктуация и стили сохранены. Если кто-то будет спрашивать "чем плохи видеокурсы?", просто скиньте линку на данный код.
+102
string sql = "select " + (sender == sbFind_Phone ? "distinct " : "") +
"orders.id, orders.dat_add, users.family, orders.status, " +
"clients.name, clients.phone, " +
"orders.adress, orders.note_adress, orders.dat, orders.time_, orders.\"SUM\", orders.skidka, " +
"factories.name, " +
"drivers.family || ' ' || drivers.name, orders.actions, " +
"orders.pay, orders.enter, clients.note, orders.website " + // website: 0 - сайт 1, 1 - сайт 2
(
bPrimeCost || bRolly ? ", orders.subitems || ';' || orders.actions || ';' " : ""
) +
"from orders " +
"left outer join users on users.id = orders.id_user_in " +
"left outer join clients on clients.id = orders.id_client " +
"left outer join factories on factories.id = orders.factory " +
"left outer join drivers on drivers.id = orders.driver " +
(
bFrom_Site ? //---- поиск заказов с сайта ---------
"where factory = " + Factorys[cbFactories.SelectedIndex - 1].id.ToString()
: sender == sbMobil ? //---- поиск заказов, поступивших с моб./устройств
"where '" + (bDataDelivery
? dataFrom.ToShortDateString() + "'<= dat and dat < '" + dtTo.AddDays(1).ToShortDateString() + "'"
: // дата доставки попадает в интервал или
dataFrom.ToShortDateString() + "'<= dat_add and dat_add < '" + dtTo.AddDays(1).ToShortDateString() +
"'" // дата приема заказа попадает в интервал
) +
" and (orders.note_adress containing 'Android' or orders.note_adress containing 'IOS')"
: sender == sbFind_Phone ? //---- поиск по номеру телефона ------
"where orders.id_client = " + ((id_client_Phone as int?)?.ToString() ?? "0")
: sender == sbFind_Order // так быстрее
? //---- поиск заказов по номеру -------
"where orders.id in (" + sOrders + ")"
: "where '" + //---- поиск заказов по фильтрам ----
(bDataDelivery
? dataFrom.ToShortDateString() + "'<= dat and dat < '" + dtTo.AddDays(1).ToShortDateString() +
"'"
: // дата доставки попадает в интервал или
dataFrom.ToShortDateString() + "'<= dat_add and dat_add < '" + dtTo.AddDays(1).ToShortDateString() +
"'" // дата приема заказа попадает в интервал
)
+ //---- вид оплаты --------------------
(!chPayNal.Checked ? " and orders.pay != 0 " : "") + // 0 - нал.
(!chPayOnl.Checked ? " and orders.pay != 1 " : "") + // 1 - онлайн
(!chPayMt.Checked ? " and orders.pay != 3 " : "") + // 3 - моб/терминал
(!chPayNull.Checked ? " and orders.pay != 2 " : "") // 2 - б/о
+ //---- откуда поступил ---------------
(!chFromPhone.Checked ? " and orders.enter != 0 " : "") + // 0 - телефон
(!chFromSite.Checked ? " and orders.enter != 1 " : "") + // 1 - сайт
(!chFromClub.Checked ? " and orders.enter != 2 " : "") // 2 - delivery club
+
(rbTake.Checked
? " and orders.status = 0"
: // принят
rbKitchen.Checked
? " and orders.status = 1"
: // на кухне
// rbReady.Checked ? " and orders.status = 2": // готов - убрал, не хватает места
rbShip.Checked
? " and orders.status = 3"
: // в пути
// rbDelive.Checked ? " and orders.status = 4": // доставлен - убрал, не хватает места
rbPay.Checked
? " and orders.status = 5"
: // оплачен
rbCancel.Checked ? " and orders.status = 6" : "" // отменен
)
+ // производство
(cbFactories.SelectedIndex <= 0
? ""
: " and factory = " + Factorys[cbFactories.SelectedIndex - 1].id.ToString()
)
+ // акция
(cbActions.SelectedIndex <= 0
? ""
: " and substring(actions from 1 for " +
Actions[cbActions.SelectedIndex - 1].id.ToString().Length.ToString() + ") = '"
+ Actions[cbActions.SelectedIndex - 1].id.ToString() + "'"
)
+ // манагеры
(cbManagers.SelectedIndex <= 0
? ""
: " and orders.id_user_in = " + Managers[cbManagers.SelectedIndex - 1].id.ToString()
)
+ // водители
(cbDrivers.SelectedIndex <= 0
? ""
: " and orders.driver = " + Drivers[cbDrivers.SelectedIndex - 1].id.ToString()
)
+ // сайт заказа: первый(0) или второй(1)
(rbSiteAll.Checked
? ""
: " and orders.website = " +
(rbSitePirogu.Checked ? FLogo.LOGO_1 : FLogo.LOGO_2).ToString()
)
);
Абсолютно коричневый код одного пожилого разработчика с 20-летним стажем и кандидатской степенью (прямо в классе формы).
0
const int DD_GOOD = 1;
const int DD_BAD = 2;
const int DD_BAD_VERT = 3;
auto segStatus = [&DD_GOOD, &DD_BAD, &DD_BAD_VERT](SomeClass* seg, EXTR ext, coord pickPt, double pickElev) -> int
{
Pt& pt = seg->ExtremePt(ext);
Line& line = seg->ExtremeLn(ext);
coord btPt = seg->GetExtremeWallPos(ext);
if (pt.GetCoord() != pickPt && btPt != pickPt)
{
return DD_BAD;
}
if (pt.pairGuid == GUID_NULL && EQ(pt.GetHeight(), pickElev))
{
return DD_GOOD;
}
if (!line.IsNonVert())
{
return DD_BAD;
}
double e1 = line.m_startPt.GetHeight();
double e2 = line.m_endPt.GetHeight();
if (e1 < e2 && e1 < pickElev && pickElev < e2)
{
return DD_GOOD;
}
if (e2 < e1 && e2 < pickElev && pickElev < e1)
{
return DD_GOOD;
}
return DD_BAD_VERT;
};
Когда не умеешь пользоваться энумами.
+506
if(isset($db_array["reference"]) && is_array($db_array["reference"]))
$ref = $db_array["reference"];
elseif(isset($db_array["REFERENCE"]) && is_array($db_array["REFERENCE"]))
$ref = $db_array["REFERENCE"];
else
$ref = array();
if(isset($db_array["reference_id"]) && is_array($db_array["reference_id"]))
$ref_id = $db_array["reference_id"];
elseif(isset($db_array["REFERENCE_ID"]) && is_array($db_array["REFERENCE_ID"]))
$ref_id = $db_array["REFERENCE_ID"];
else
$ref_id = array();
bitrix/modules/main/tools.php:182
+916
if(!empty($_REQUEST['action_button']))
$_REQUEST['action'] = $_REQUEST['action_button'];
bitrix/modules/main/interface/admin_lib.php:3320
+840
Options -Indexes
ErrorDocument 404 /404.php
<IfModule mod_php5.c>
php_flag allow_call_time_pass_reference 1
php_flag session.use_trans_sid off
php_value display_errors 1
php_value display_startup_errors 1
php_value error_reporting E_ALL
php_value auto_prepend_file "/home/bitrix/www/bitrix/pagen.php"
#php_value mbstring.internal_encoding UTF-8
</IfModule>
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(.*)/page([\d]+)/ /$1/?PAGEN_2=$2 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !/bitrix/urlrewrite.php$
RewriteRule ^(.*)$ /bitrix/urlrewrite.php [L]
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
</IfModule>
<IfModule mod_dir.c>
DirectoryIndex index.php index.html
</IfModule>
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType image/jpeg "access plus 3 day"
ExpiresByType image/gif "access plus 3 day"
</IfModule>
RewriteCond %{HTTP_HOST} ^www\.sitename\.ru [NC]
RewriteRule ^(.*)$ http://sitename.ru/$1 [L,R=301]
# Чиним изменения в названии корневых разделов
RedirectMatch 301 /catalog/oborudovanie-dlya-katerov-i-lodok/(.*) /catalog/oborud/$1
RedirectMatch 301 /catalog/vse-dlya-orujiya/(.*) /catalog/guns/$1
RedirectMatch 301 /catalog/ohota/(.*) /catalog/hunt/$1
RedirectMatch 301 /catalog/ribalka/(.*) /catalog/fish/$1
RedirectMatch 301 /catalog/noji/(.*) /catalog/knifes/$1
RedirectMatch 301 /catalog/lodochnie-motory/(.*) /catalog/motors/$1
RedirectMatch 301 /catalog/zapchasti/(.*) /catalog/spares/$1
RedirectMatch 301 /catalog/navigatsiya/(.*) /catalog/navi/$1
RedirectMatch 301 /catalog/masla-i-gsm/(.*) /catalog/oil/$1
RedirectMatch 301 /catalog/accumulyatori/(.*) /catalog/accum/$1
RedirectMatch 301 /catalog/turizm-i-kemping/(.*) /catalog/camp/$1
RedirectMatch 301 /catalog/pnevmaticheskoe-orujie/(.*) /catalog/pneumo/$1
RedirectMatch 301 /catalog/suveniri-i-podarki/(.*) /catalog/gifts/$1
Помогите пожалуйста сделать так, чтобы все ссылки вида /catalog/oborud редиректили 301 на / catalog/oborud/
+967
if (!ch.election) {
exec('date -R', function(error, stdout, stderr) {
if (stdout.search('Wed') > -1) {
ch.startElection();
}
});
} else {
exec('date -R', function(error, stdout, stderr) {
if (stdout.search('Wed') < 0) {
ch.stopElection();
}
});
}
В ноде видимо нет функций для работы с календарём...
https://github.com/birdlab/trigger/blob/master/src/node/trigger/channel.js#L783
+1004
// shit.h :
#if END_SHIT == 0
bagor++;
#if BIT0 == 0
#undef BIT0
#define BIT0 1
#else
#undef BIT0
#define BIT0 0
#if BIT1 == 0
#undef BIT1
#define BIT1 1
#else
#undef BIT1
#define BIT1 0
#if BIT2 == 0
#undef BIT2
#define BIT2 1
#else
#undef BIT0
#undef BIT1
#undef BIT2
#define END_SHIT 1
#endif
#endif
#endif
#include "shit.h"
#endif
//shit.c
#include <stdio.h>
int main(void) {
int bagor = 0;
#define BIT0 0
#define BIT1 0
#define BIT2 0
#include "shit.h"
printf("bagor = %i\n", bagor);
return 0;
}
http://govnokod.ru/20947#comment348047
CHayT 3 часа назад # 0
> нет ни циклов, ни рекурсий
Можно, думаю, файлы сами в себя инклудить, чем не рекурсия. Не очень понятно, что с этим делать, правда.
-----
Но ведь совершенно очевидно, что с этим можно делать. Очередной шедевр макроговна