- 1
- 2
- 3
- 4
$arResult = Yii::app()->db->createCommand($sql)->queryRow();
if ($arResult && isset($arResult) && is_array($arResult) && !empty($arResult['pk_report'])) {
...
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+156
$arResult = Yii::app()->db->createCommand($sql)->queryRow();
if ($arResult && isset($arResult) && is_array($arResult) && !empty($arResult['pk_report'])) {
...
}
проверить все, что скрыто
+161
function getGeneralOfficesStats(&$stats_year, &$stats_office_logo, &$stats_quant_client, &$stats_summ_client, &$stats_summ_supplier, &$stats_summ_delivery, &$stats_without_complex_price, &$quant_position, &$top_quant_client, &$top_summ_client, &$top_summ_supplier, &$top_summ_delivery, &$top_stats_without_complex_price, &$top_quant_position, $date_start_time=0, $date_end_time=0, $office_logo="")
{
$sql="SELECT t1.month, t1.year, t1.office_logo, t1.quant_client, t1.summ_client, t1.summ_supplier,
t1.summ_delivery, t1.stats_without_complex_price,
t1.quant_position, t1.top_quant_client, t1.top_summ_client,
t1.top_summ_supplier, t1.top_summ_delivery, t1.top_stats_without_complex_price, t1.top_quant_position
FROM stats_offices AS t1
INNER JOIN offices AS t2 ON t1.office_logo=t2.name AND t1.currency_logo=t2.currency
WHERE 1=1
".(($date_start_time>0 && $date_end_time>0)?" AND STR_TO_DATE(CONCAT(t1.year,'-',IF(LENGTH(t1.month)=1,'0',''),t1.month,'-01 01:01:01'), '%Y-%m-%d %H:%i:%s') BETWEEN STR_TO_DATE('".date("Y-m-01 00:00:00",$date_start_time)."', '%Y-%m-%d %H:%i:%s') AND STR_TO_DATE('".date("Y-m-d 23:59:59",$date_end_time)."', '%Y-%m-%d %H:%i:%s') ":"")."
".((!empty($office_logo))?" AND t1.office_logo='".mysql_escape_string($office_logo)."' ":"")."
ORDER BY t1.office_logo, t1.year DESC, t1.month DESC";
list($stats_month, $stats_year, $stats_office_logo, $stats_quant_client, $stats_summ_client, $stats_summ_supplier, $stats_summ_delivery, $stats_without_complex_price, $quant_position, $top_quant_client, $top_summ_client, $top_summ_supplier, $top_summ_delivery, $top_stats_without_complex_price, $top_quant_position)=$this->query($sql);
return $stats_month;
}
Сменил работу. Стал знакомится с кодом. Тихо охуеваю.
+160
/**
* @param array $input
* @return array
* @throws Exception
*/
protected function makeParams($input)
{
if (!is_array($input))
{
throw new \Exception('argument should be array');
}
$params = array();
foreach ($input as $k=>$v)
{
$params[] = $v;
}
return $params;
}
свой array_values, с блекджеком и экзепшенами
+159
static function beforeIblockElementAddOrUpdateResetResponseAuthor($fields){
...
}
+160
echo 'some string'."\n";
)))
+165
foreach ($user as $field => $value) {
if ($field == 'username') {
$user[$field] = md5($value);
}
}
Обучаю стажера, который целый год кодил на битрикс, частенько у него проскользает такой подход для обновления значений в ассоциативном массиве.
+155
<?php
// Default: http://<host>/<dir>/<filename>.php?iter1=64&width=600&height=400&coef=32
function BN($n, $l, $r) {return $n>$l && $n<=$r;}
function SQR($a) {return $a*$a;}
define("COEF", $_GET["coef"]);
$iter1 = $_GET["iter1"];
$width = $_GET["width"];
$height = $_GET["height"];
header("Content-type: image/png");
$img = imagecreatetruecolor($width, $height);
$iter2 = 0.01/($width/300);
$yy = -1;
for ($y = -1; $y < 1; $y = $y + $iter2) {
$yy++; $xx=-1;
for($x = -2; $x < 1; $x = $x + $iter2) {
$xx++;
$Cx = $x;
$Cy = $y;
$X = $x;
$Y = $y;
$ix = 0;
$iy = 0;
$n = 0;
while ((SQR($ix) + SQR($iy) < 4) and ($n < $iter1)) {
$ix = SQR($X) - SQR($Y) + $Cx;
$iy = 2*$X*$Y + $Cy;
$X = $ix;
$Y = $iy;
$n++;
}
if(BN($n,0,7)) $col = imagecolorallocate($img,COEF*$n,0,0);
elseif(BN($n,7,14)) $col = imagecolorallocate($img,COEF*$n,COEF*$n,0);
elseif(BN($n,14,21))$col = imagecolorallocate($img,COEF*$n,0,COEF*$n);
elseif(BN($n,21,28))$col = imagecolorallocate($img,0,COEF*$n,0);
elseif(BN($n,28,35))$col = imagecolorallocate($img,COEF*$n,COEF*$n,0);
elseif(BN($n,35,42))$col = imagecolorallocate($img,0,COEF*$n,COEF*$n);
elseif(BN($n,42,49))$col = imagecolorallocate($img,0,0,COEF*$n);
elseif(BN($n,49,56))$col = imagecolorallocate($img,COEF*$n,0,COEF*$n);
elseif(BN($n,56,64))$col = imagecolorallocate($img,0,COEF*$n,COEF*$n);
imagesetpixel($img, $xx, $yy, $col);
}
}
imagepng($img);
imagedestroy($img);
?>
https://ru.wikipedia.org/wiki/%D0%9C%D0%BD%D0%BE%D0%B6%D0%B5%D1%81%D1% 82%D0%B2%D0%BE_%D0%9C%D0%B0%D0%BD%D0%B4% D0%B5%D0%BB%D1%8C%D0%B1%D1%80%D0%BE%D1%8 2%D0%B0
+167
function advancedMD5($parol) {
$zashita = 50;
for( $i = 0; $i < $zashita; $i++ ) {
$parol = md5($parol);
}
return $parol;
}
Неповторимый инновационный алгоритм шифрования паролей...
+157
<?
foreach ($_POST as &$post) {
$post = iconv(mb_detect_encoding($post, mb_detect_order(), true), 'windows-1251', $post);
}
setlocale(LC_ALL, 'ru_RU.CP1251');
header("Content-Type: text/html; charset=windows-1251");
$global_index = $_POST['global_index'];
include '../global/global_'.$global_index.'.php';
include 'stat_bibl.php';
$zy = $_POST["y_in"];
$zm = $_POST["m_in"];
$zd = $_POST["d_in"];
$zy1 = $_POST["y1"];
$zm1 = $_POST["m1"];
$zd1 = $_POST["d1"];
$zy2 = $_POST["y2"];
$zm2 = $_POST["m2"];
$zd2 = $_POST["d2"];
$gl_firstday = $zd.".".$zm.".".$zy;
$gl_daz1 = $zd1.".".$zm1.".".$zy1;
$gl_daz2 = $zd2.".".$zm2.".".$zy2;
$gl_ip_n = $_POST["ip"];
$gl_ip_c = Def_Country_IP($gl_ip_n);
$gl_fio1 = $_POST["fio1"]; $gl_fio1 = trim($gl_fio1); $gl_cm1 = $_POST["cm1"];
$gl_fio2 = $_POST["fio2"]; $gl_fio2 = trim($gl_fio2); $gl_cm2 = $_POST["cm2"];
$gl_fio3 = $_POST["fio3"]; $gl_fio3 = trim($gl_fio3); $gl_cm3 = $_POST["cm3"];
$gl_fio4 = $_POST["fio4"]; $gl_fio4 = trim($gl_fio4); $gl_cm4 = $_POST["cm4"];
$gl_fio5 = $_POST["fio5"]; $gl_fio5 = trim($gl_fio5); $gl_cm5 = $_POST["cm5"];
$gl_fio6 = $_POST["fio6"]; $gl_fio6 = trim($gl_fio6); $gl_cm6 = $_POST["cm6"];
$gl_fio7 = $_POST["fio7"]; $gl_fio7 = trim($gl_fio7); $gl_cm7 = $_POST["cm7"];
$gl_fio8 = $_POST["fio8"]; $gl_fio8 = trim($gl_fio8); $gl_cm8 = $_POST["cm8"];
$gl_ksk1=$gl_ksk2=$gl_ksk3=$gl_ksk4=$gl_ksk5=$gl_ksk6=$gl_ksk7=$gl_ksk8=0;
$gl_ps1=$gl_ps2=$gl_ps3=$gl_ps4=$gl_ps5=$gl_ps6=$gl_ps7=$gl_ps8=0;
$gl_p1=$gl_p2=$gl_p3=$gl_p4=$gl_p5=$gl_p6=$gl_p7=$gl_p8="ж";
$gl_person=0;
$gl_ch=0;
if (strlen($gl_fio1) > 1) {$gl_person++; $gl_p1=Def_Pol($gl_fio1); if ($gl_cm1 <= $year_child) {$gl_ch++; $gl_p1="р";}}
if (strlen($gl_fio2) > 1) {$gl_person++; $gl_p2=Def_Pol($gl_fio2); if ($gl_cm2 <= $year_child) {$gl_ch++; $gl_p2="р";}}
if (strlen($gl_fio3) > 1) {$gl_person++; $gl_p3=Def_Pol($gl_fio3); if ($gl_cm3 <= $year_child) {$gl_ch++; $gl_p3="р";}}
if (strlen($gl_fio4) > 1) {$gl_person++; $gl_p4=Def_Pol($gl_fio4); if ($gl_cm4 <= $year_child) {$gl_ch++; $gl_p4="р";}}
if (strlen($gl_fio5) > 1) {$gl_person++; $gl_p5=Def_Pol($gl_fio5); if ($gl_cm5 <= $year_child) {$gl_ch++; $gl_p5="р";}}
if (strlen($gl_fio6) > 1) {$gl_person++; $gl_p6=Def_Pol($gl_fio6); if ($gl_cm6 <= $year_child) {$gl_ch++; $gl_p6="р";}}
if (strlen($gl_fio7) > 1) {$gl_person++; $gl_p7=Def_Pol($gl_fio7); if ($gl_cm7 <= $year_child) {$gl_ch++; $gl_p7="р";}}
if (strlen($gl_fio8) > 1) {$gl_person++; $gl_p8=Def_Pol($gl_fio8); if ($gl_cm8 <= $year_child) {$gl_ch++; $gl_p8="р";}}
$gl_place_ind = $_POST["place_index"];
$gl_place_adr = $_POST["place"];
$w_place = $gl_place_ind.", ".$gl_place_adr;
$w_place=Sep_Delete($w_place);
$gl_tel = $_POST["tel"];
$gl_mail1 = $_POST["mail1"]; $gl_mail1 = trim($gl_mail1);
$gl_mail2 = $_POST["mail2"]; $gl_mail2 = trim($gl_mail2);
$gl_totaldays = $_POST["totaldays"];
$gl_nom1 = $_POST["nomer1"];
$gl_nom2 = $_POST["nomer2"];
$gl_z_comments = $_POST["comments"];
$gl_f_plat = $_POST["f_plat"];
$gl_gor = $_POST["gor"];
$gl_z_comments=Sep_Delete($gl_z_comments);
$gl_fio1=ucwords(strtolower($gl_fio1));
$gl_fio2=ucwords(strtolower($gl_fio2));
$gl_fio3=ucwords(strtolower($gl_fio3));
$gl_fio4=ucwords(strtolower($gl_fio4));
$gl_fio5=ucwords(strtolower($gl_fio5));
$gl_fio6=ucwords(strtolower($gl_fio6));
$gl_fio7=ucwords(strtolower($gl_fio7));
$gl_fio8=ucwords(strtolower($gl_fio8));
list($gl_parol)=explode(" ",$gl_fio1);
$gl_dt_znew=date("d.m.y H:i:s");
$gl_dt_podt=$gl_dt_post=$gl_dt_sogl=$gl_dt_sch1=$gl_dt_sch2=$gl_dt_popl=$gl_dt_napr=$gl_dt_mail=$gl_dt_mest=$gl_dt_ot_p=$gl_dt_plat=$gl_dt_ot_z="";
if ($gl_mail1 === $gl_mail2) $gl_mail2="";
$gl_arch="W";
$gl_status=0;
$gl_san=$global_san;
Отрывочек из файла-обработчика формы создания заявки на размещение в санатории
Форма например тут: http://rb.evet.ru/objects/7/
+156
bool
CIBlockElement::Update(...);
// ......
$el = new CIBlockElement;
// ......
$res = $el->Update($PRODUCT_ID, $arLoadProductArray);
Нынче статический метод вызывается через объект.
( Пример из официальной документации Битрикс https://dev.1c-bitrix.ru/api_help/iblock/classes/ciblockelement/update.php )