21 октября 2021 Нет комментариев

При:

$cities_get=file_get_contents(LOS_URL.'ajax.php?type=cities');

Ошибка:

<br />
<b>Warning</b>:  file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in <b>/var/www/site.ru/index.php</b> on line <b>241</b><br />
<br />
<b>Warning</b>:  file_get_contents(): Failed to enable crypto in <b>/var/www/site.ru/index.php</b> on line <b>241</b><br />
<br />
<b>Warning</b>:  file_get_contents(https://site.su/ajax.php?type=cities): failed to open stream: operation failed in <b>/var/www/site.ru/index.php</b> on line <b>241</b><br />

Решение:

$arrContextOptions=array(
	"ssl"=>array(
		"verify_peer"=>false,
		"verify_peer_name"=>false,
	),
);
$cities_get=file_get_contents(LOS_URL.'ajax.php?type=cities',false,stream_context_create($arrContextOptions));
Categories: PHP Tags:
28 сентября 2021 Нет комментариев
new Date(1632822057*1000).toLocaleDateString("ru-RU")
Categories: Javascript Tags:
16 сентября 2021 Нет комментариев

Без циклической прокрутки:

var owl_catalog_item=$('.owl_catalog_item');
owl_catalog_item.owlCarousel({
	items:1,
	loop:false,
	margin:0,
	autoplay:true,
	autoplayTimeout:1000,
	autoplayHoverPause:false,
	dots:false,
	nav:false,
	navText:['<i class="fa fa-angle-left"></i>','<i class="fa fa-angle-right"></i>'],
	responsive:{
		0:{
		},
		480:{
		},
		768:{
		}
	}
});
owl_catalog_item.trigger('stop.owl.autoplay');
$('.catalog .item').on('mouseenter',function(){
	if($(this).find('.owl_catalog_item a').length>1){
		$(this).find('.owl_catalog_item').trigger('play.owl.autoplay',[1000]);
	}
});
$('.catalog .item').on('mouseleave',function(){
	$(this).find('.owl_catalog_item').trigger('stop.owl.autoplay');
	$(this).find('.owl_catalog_item').trigger('to.owl.carousel',0);
});

С циклической прокруткой:

var owl_catalog_item=$('.owl_catalog_item');
owl_catalog_item.owlCarousel({
	items:1,
	loop:true,
	margin:0,
	autoplay:true,
	autoplayTimeout:1000,
	autoplayHoverPause:false,
	dots:false,
	nav:false,
	navText:['<i class="fa fa-angle-left"></i>','<i class="fa fa-angle-right"></i>'],
	responsive:{
		0:{
		},
		480:{
		},
		768:{
		}
	}
});
owl_catalog_item.trigger('stop.owl.autoplay');
$('.catalog .item').on('mouseenter',function(){
	$(this).find('.owl_catalog_item').trigger('play.owl.autoplay',[1000]);
})
$('.catalog .item').on('mouseleave',function(){
	$(this).find('.owl_catalog_item').trigger('stop.owl.autoplay');
});
Categories: Javascript Tags:
1 сентября 2021 Нет комментариев

less:

.pricedesc{
	width:100%;
	margin-bottom:20px;
	&>div{
		display:flex;
		justify-content:space-between;
		&>div{
			text-align:left;
			font-size:14px;
			line-height:20px;
			font-weight:700;
			padding:2px 0;
			&:nth-child(2){
				flex:1 0;
				border-bottom:1px dotted #d2d2d2;
				height:1em;
				margin:0 .4em;
			}
		}
	}
}

html:

<div class="pricedesc">
	<div>
		<div>Взнос в КФ ВВ</div>
		<div></div>
		<div>0 ₽</div>
	</div>
	<div>
		<div>Взнос в КФ ОДО</div>
		<div></div>
		<div>0 ₽</div>
	</div>
	<div>
		<div>Страхование</div>
		<div></div>
		<div>0 ₽</div>
	</div>
	<div>
		<div>Вступительный взнос</div>
		<div></div>
		<div>0 ₽</div>
	</div>
	<div>
		<div>Членские взносы</div>
		<div></div>
		<div>0 ₽</div>
	</div>
</div>
Categories: CSS Tags:
6 августа 2021 Нет комментариев

При ошибке

Access to XMLHttpRequest at 'https://site1.ru/api.php' from origin 'https://site2.ru' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

добавить на отдающий данные сайт (в примере site1.ru) заголовок

header('Access-Control-Allow-Origin: *');
Categories: PHP Tags: ,
5 августа 2021 Нет комментариев

В примере по клику на i в блоке .link скопировать ссылку внутри этого блока

function copyToClipboard(textToCopy){
	if(navigator.clipboard&&window.isSecureContext){
		return navigator.clipboard.writeText(textToCopy);
	}
	else{
		let textArea=document.createElement("textarea");
		textArea.value=textToCopy;
		textArea.style.position="fixed";
		textArea.style.left="-999999px";
		textArea.style.top="-999999px";
		document.body.appendChild(textArea);
		textArea.focus();
		textArea.select();
		return new Promise((res,rej)=>{
			document.execCommand('copy')?res():rej();
			textArea.remove();
		});
	}
}
$(document).ready(function(){
	$('.link i').on('click',function(){
		var link=$(this).closest('.link').find('a').attr('href');
		copyToClipboard(link).then(()=>console.log('copied')).catch(()=>console.log('not copied'));
	});
});
Categories: Javascript Tags:
3 августа 2021 Нет комментариев

Массив:

print_r($result_price);
Array
(
    [econom_mag] => 1800
    [econom] => 510
    [def] => 870
)

Ищем ключ минимального значения массива:

$min_key=array_keys($result_price,min($result_price));
print_r($min_key);
Array
(
    [0] => econom
)
Categories: PHP Tags: