- 1
- 2
- 3
foreach ($properties->xml->ЗначенияСвойства as $property) {
//......
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
foreach ($properties->xml->ЗначенияСвойства as $property) {
//......
}
$properties->xml->ЗначенияСвойства
+3
# Alternative mysql_real_escape_string without mysql connection
function escape_string($param) {
if(is_array($param))
return array_map(__METHOD__, $param);
if(!empty($param) && is_string($param)) {
return str_replace(array('\\', "\0", "\n", "\r", "'", '"', "\x1a"), array('\\\\', '\\0', '\\n', '\\r', "\\'", '\\"', '\\Z'), $param);
}
return $param;
}
#Using example
$name = @trim(escape_string(stripslashes($_POST['name'])));
https://gist.github.com/wilnaweb/ca37459bdf92aa74bd2dd7994fa5b0df
+1
$DI_WName = Array('ѕн','¬т','—р','„т','ѕт','—б','¬с');
$DI_MName = Array('январь','‘евраль','ћарт','јпрель','ћай','»юнь','»юль','јвгуст','—ент¤брь','ќкт¤брь','Ќо¤брь','ƒекабрь');
$today = TodayDate();
$today = explode(".",$today);
$today = $today[2]*10000+$today[1]*100+$today[0];
$DI_Date = TodayDate();
if (isset($_GET["p0"])) $DI_Date = $_GET["p0"];
$DI_Date = explode(".",$DI_Date);
$DI_YY = $DI_Date[2];
$DI_LYY = $DI_YY;
$DI_NYY = $DI_YY;
$DI_MM = $DI_Date[1]-1;
$DI_LMM = $DI_MM-1;
if ($DI_LMM<0) $DI_LMM = 11;
$DI_NMM = $DI_MM+1;
if ($DI_NMM>11) $DI_NMM = 0;
if ($DI_MM==0) $DI_LYY = $DI_YY-1;
if ($DI_MM==11) $DI_NYY = $DI_YY+1;
$DI_DD = $DI_Date[0];
$lastM = $DI_MM-2;
$yy = $DI_YY;
if ($lastM<1) {
$lastM = 12+$lastM;
$yy = $yy - 1;
}
$lastM = $DI_DD.".".$lastM.".".$yy;
$nextM = $DI_MM+4;
$yy = $DI_YY;
if ($nextM>12) {
$nextM = $nextM-12;
$yy = $yy + 1;
}
$nextM = $DI_DD.".".$nextM.".".$yy;
$lastY = $DI_DD.".".($DI_MM+1).".".($DI_YY-1);
$nextY = $DI_DD.".".($DI_MM+1).".".($DI_YY+1);
+1
function DI_MNum($Mon, $Year) {
$nn = Array(31,28,31,30,31,30,31,31,30,31,30,31);
$x = 28;
$y = (Round($Year/4))*4;
if ($y==$Year) $x = 29;
$ret = $nn[$Mon];
if ($Mon==1) $ret = $x;
return $ret;
}
function DI_FirstDay($Mon,$Year) {
$x0 = 365;
$Y = $Year-1;
$days = $Y*$x0+floor($Y/4)+6;
for ($j=0; $j<$Mon; $j=$j+1) {
$days = $days+DI_MNum($j,$Year);
}
$week = $days-(7*Round(($days/7)-0.5));
return $week;
}
function even_week($Day,$Mon,$Year) {
$x0 = 365;
$Y = $Year-1;
$days = $Y*$x0+floor($Y/4)+6;
for ($j=0; $j<$Mon; $j=$j+1) {
$days = $days+DI_MNum($j,$Year);
}
$days = $days + $Day;
$weeks = ceil($days/7);
$res = false;
if (2*ceil($weeks/2) == $weeks) $res = true;
return $res;
}
−1
public function index()
{
$items = CartManager::getAllItems();
$couponCode = Coupon::getFromSession()->implode('code', ', ');
$address = auth()->user()->address;
$user = auth()->user();
$userDetails = auth()->user() ? auth()->user()->fields : null;
$fields = [
'promo_code' => $couponCode,
'email' => $user->email,
'first_name' => $userDetails->firstname,
'last_name' => $userDetails->lastname,
'phone' => $userDetails->phone,
];
if ($address) {
$field = [
'value' => $address->city->title
];
if ($address->city->type === \App\Address::TYPE_CITY) {
$field ['data']['city_fias_id'] = $address->city->id;
$field ['data']['city'] = $address->city->title;
} elseif ($address->city->type === \App\Address::TYPE_SETTLEMENT) {
$field ['data']['settlement_fias_id'] = $address->city->id;
$field ['data']['settlement'] = $address->city->title;
}
$fields ['delivery_city'] = $field;
}
if ($address->street) {
$fields ['delivery_street'] = [
'value' => $address->street->title,
'data' => [
'street_fias_id' => $address->street->id,
]
];
}
if ($address->street_number) {
$fields ['delivery_house_number'] = [
'value' => $address->street_number,
];
}
if ($address->flat) {
$fields ['delivery_flat_number'] = $address->flat;
}
$fields = (object)$fields;
$actions = [
'remove' => route('shop.cart.remove'),
'remove_gift_card' => route('shop.cart.gift-cards.remove'),
'change' => route('shop.cart.update'),
'promo' => route('shop.coupon.apply'),
'checkout' => route('orders.store'),
'get_pickups' => route('delivery_points.index'),
'check_email' => route('check_email'),
];
return view('shop.cart.index', compact(
'items',
'address',
'couponCode',
'fields',
'actions'
));
}
this is MVC, baby !
0
if (SCRIPT_DEBUG || filemtime(get_theme_file_path('/assets/js/global.min.js')) < filemtime(get_theme_file_path('/assets/js/global.js'))) {
wp_enqueue_script('gk-global', get_theme_file_uri('/assets/js/global.js'), array('jquery'), $ver, true);
} else {
wp_enqueue_script('gk-global', get_theme_file_uri('/assets/js/global.min.js'), array('jquery'), $ver, true);
}
Обосрался.
Сделал, чтобы после правок скрипта не использовался min файл. В какой-то момент время сравнялось, а версии разошлись.
Хрю.
−1
private function changePlans(Coupon $coupon): Coupon
{
$coupon->paypal_plan_yearly_rub_id = $this->getPaypalId($coupon->billingPlanYearlyRub, $coupon);
$coupon->paypal_plan_yearly_usd_id = $this->getPaypalId($coupon->billingPlanYearlyUsd, $coupon);
$coupon->paypal_plan_monthly_rub_id = $this->getPaypalId($coupon->billingPlanMonthlyRub, $coupon);
$coupon->paypal_plan_monthly_usd_id = $this->getPaypalId($coupon->billingPlanMonthlyUsd, $coupon);
return $coupon;
}
Вот это забавно $this->getPaypalId($coupon->billingPlanMonthlyUsd, $coupon); (getPaypalId приватный)
0
https://ru.wikihow.com/%D0%B8%D0%B7%D1%83%D1%87%D0%B8%D1%82%D1%8C-PHP-%D0%B8-MySQL
+1
private function _postPhotoWidth($post) {
$raw_code = rtrim(str_replace("\r", '', $post->post_content));
$lines = explode("\n", $raw_code);
if (count($lines) <= 1) {
return -1;
}
$text_width = 0;
foreach ($lines as $line) {
$text_width = max($text_width, mb_strlen($line) + substr_count($line, "\t") * 7);
}
return (int)(max(20 + $text_width, 60) * 18.5);
}
Код для вычисления длины данного гамнакода.
+2
В боте @GovnokodBot обновление:
Теперь говнокоды отправляются скриншотами.
Также создан канал "Говнокода" в "Telegram": https://t.me/GovnokodChannel
Баги и пожелания можно писать сюда.
Зеркала Говнокода и полезные ресурсы:
* https://govnokod.xyz/
* https://gcode.space/
* индекс оффтопов: https://index.gcode.space/
* https://t.me/GovnokodBot
* https://pethu.ru