(☞ຈل͜ຈ)☞ Главная  Статьи  Загрузчик Домой

Ok!
Ok!
103
$data = preg_replace('!s:(\d+):"(.*?)";!e', "'s:'.strlen('$2').':\"$2\";'", $data);
var_dump(unserialize($data));
replace, serialized510recalculating the length of the elements in serialized array
102
"ELEMENT_SORT_FIELD" => "catalog_PRICE_1",
"ELEMENT_SORT_ORDER" => "asc"
сортировка, цена, битрикс230Сортировка каталога по цене в Битрикс
101
/bitrix/modules/main/include.php replace OLDSITEEXPIREDATE by (exmpl) time() + 86400 * 3
bitrix100replace old site expire date
100
<?if($_REQUEST) {
	if ( htmlspecialchars( $_REQUEST['mail'], 3 ) != ''
	     && strpos( htmlspecialchars( $_REQUEST['mail'], 3 ), '@' ) != false
	) {
		$to = '[email protected]'; 
		$to2 .= htmlspecialchars( $_REQUEST['mail'] );
		$subject  = 'Сообщение с сайта' . $_SERVER['HTTP_HOST'];
		$subject2 = 'Ваше сообщение на сайт ' . $_SERVER['HTTP_HOST'];
		$message = '
<html>
<head>
  <title>Сообщение с сайта ' . $_SERVER['HTTP_HOST'] . '</title>
</head>
<body>
  <p>С сайта отправлено соощение:</p>
  <table cellpadding=10>
    <tr>
      <th style="background-color:#ccc; color:white">Имя</th><th style="background-color:#ccc; color:white">Почта</th><th style="background-color:#ccc; color:white">Дата</th><th style="background-color:#ccc; color:white">Время</th>
    </tr>
    <tr>
      <td>' . htmlspecialchars( $_REQUEST['name'],3 ) . '</td><td>' . htmlspecialchars( $_REQUEST['mail'],3 ) . '</td><td>' .
		           date( 'd-m-Y' ) . '</td><td>' . date( 'H:s' ) . '</td>
    </tr>
    <tr>
      <td colspan=4>' . htmlspecialchars( $_REQUEST['text'],3 ) . '</td>
    </tr>
  </table>
</body>
</html>
';
$message2 = '
<html>
<head>
  <title>Сообщение с сайта' . $_SERVER['HTTP_HOST'] . '</title>
</head>
<body>
  <p>Вы отправили сообщение на сайт ' . $_SERVER['HTTP_HOST'] . '. С вами свяжутся в ближайшее время, спасибо.</p>
  
</body>
</html>
';


		$headers = 'MIME-Version: 1.0' . "
";
		$headers .= 'Content-type: text/html; charset=utf-8' . "
";
		$headers .= 'To: Admin <' . $to . '>' . "
";
		$headers .= 'From: Reglass <' . $to . '>' . "
";
		$headers2 = 'MIME-Version: 1.0' . "
";
		$headers2 .= 'Content-type: text/html; charset=utf-8' . "
";
		$headers2 .= 'To: ' . htmlspecialchars( $_REQUEST['name'] ) . ' <' . htmlspecialchars( $_REQUEST['mail'] ) . '>' . "
";
		$headers2 .= 'From: Reglass <' . $to . '>' . "
";


		if($y = mail( $to, $subject, $message, $headers )
		&& $y2 = mail( $to2, $subject2, $message2, $headers2 )) {
			echo '<script>alert(Спасибо. Сообщение отправлено.); document.location="/"</script>';
		}
	}
}
?>
php, mail230Отправка письма php
99
DELETE t1 FROM contacts t1
        INNER JOIN
    contacts t2 
WHERE
    t1.id < t2.id AND t1.email = t2.email;
удалить, mysql, дупликаты2900Удалить дублирующиеся строки базы
98
onerror="this.src='/bitrix/templates/persona/images/<?=strtolower(str_replace(' ', '-', $arItem['PROPERTY_BRAND_VALUE']))?>-pale.jpg'; this.setAttribute('data-err', 'true')"
дефолт, картинка, img220В случае, если картинки нет, то прописать свойство (здесь название бренда) в качестве дефолтной картинки
97
<link rel="stylesheet" href="/animate.min.css" media="none" onload="if(media!='all')media='all'"><noscript><link rel="stylesheet" href="/animate.min.css"></noscript>
link, ускорение загрузки130Ускорение загрузки сайта уменьшением загрузки css
96
function resizeAndConvertImageWebP(
    $width,
    $height,
    $density,
    $originalFilepath,
    $resizedFilepath) {
  $newWidth = $width * $density;
  $newHeight = $height * $density;

  $image = new Imagick($originalFilepath);
  $origImageDimens = $image->getImageGeometry();
  $origImgWidth = $origImageDimens['width'];
  $origImgHeight = $origImageDimens['height'];

  if($newWidth == 0) {
    $ratioOfHeight = $newHeight / $origImgHeight;
    $newWidth = $origImgWidth * $ratioOfHeight;
  }

  if($newHeight == 0) {
    $ratioOfWidth = $newWidth / $origImgWidth;
    $newHeight = $origImgHeight * $ratioOfWidth;
  }

  $widthRatios = $origImgWidth / $newWidth;
  $heightRatios = $origImgHeight / $newHeight;

  if($widthRatios <= $heightRatios) {
    $cropWidth = $origImgWidth;
    $cropHeight = $newWidth * $widthRatios;
  } else {
    $cropWidth = $newHeight * $heightRatios;
    $cropHeight = $origImgHeight;
  }

  $cropX = ($origImgWidth - $cropWidth) / 2;
  $cropY = ($origImgHeight - $cropHeight) / 2;

  $image->stripImage();
  $image->cropImage($cropWidth, $cropHeight, $cropX, $cropY);
  $image->resizeImage($newWidth, $newHeight, imagick::FILTER_LANCZOS, 0.9);
  $image->setImageFormat('webp');
  $image->setImageAlphaChannel(imagick::ALPHACHANNEL_ACTIVATE);
  $image->setBackgroundColor(new ImagickPixel('transparent'));
  $image->writeImage($resizedFilepath);
}
webp,support,imagemagic140Конвертация картинки в webp в случае, если imageMagic поддрживает
95
<?=(webps() && is_file($_SERVER['DOCUMENT_ROOT'] . str_replace('.jpg', '.webp', $arItem["DETAIL_PICTURE"]["SRC"])))?'style="background-image: url('.str_replace('.jpg', '.webp', $arItem["DETAIL_PICTURE"]["SRC"]).')':'style="background-image: url('.$arItem["DETAIL_PICTURE"]["SRC"].')'?>"
webp,support120Бэкграунд если готов файл webp
94
$webpsupport = (strpos($_SERVER['HTTP_ACCEPT'], 'image/webp') >= 0);
if($webpsupport) {
  $this->attemptToServeWebP($pathinfo, $matches, $width, $height, $density);
} else {
  $this->attemptToServeNormal($pathinfo, $matches, $width, $height, $density);
}
webp,support100Определить, поддерживает ли браузер webp картинки
93
<?=($this->GetFolder().'/images/ .... ?>
картинка шаблона инфоблока3200Путь картинки из папки images размещенной в шаблоне компонента
92
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
$path = $protocol . $_SERVER['HTTP_HOST'] . SITE_TEMPLATE_PATH;
битрикс, путь1450Путь до файла без слеша на конце
91
При ошибке 502 в импорте инфоблоков Битрикс
Заменить в файле
/bitrix/modules/iblock/admin/iblock_xml_import.php

if($obXMLFile->ReadXMLToDatabase($fp, $NS, $INTERVAL))
на
if($obXMLFile->ReadXMLToDatabase($fp, $NS, 10, $INTERVAL))
502, битрикс, инфоблок, ошибка импорта140Ошибка импорта инфоблока Битрикс 502
90
center iframe {
    width: 100%;
    height: calc(100vw * 9 / 16 );
}
iframe, youtube, height120Установить размер iframe видео с Youtube, подогнать его под мобильный размер. При условии, что видео 100% ширны.
89
$post = get_post();
$t = strtotime($post->post_modified_gmt);
$str = 'Last-Modified: '.gmdate('D, d M Y H:i:s', $t).' GMT';
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $t).' GMT');
daremodified, wp, php1200WP date modified php file
88
document.addEventListener("DOMContentLoaded", function(event) {
    var cl = document.getElementById('#all_otz');
    cl.onclick = function(ev) {
        var post = {};
        post['num_otz'] = 20;
        post['ajax'] = 'y';
        node = BX('video_feed_block');
        if (!!node) {
            BX.ajax.post(
                'https://www.brtclinic.ru/index.php',
                post,
                function (data) {
                    var el = data.getElementById('video_feed_block');
                    node.innerHTML = el.innerHTML();
                }
            );

        }
    }
});
битрикс, битрикс аякс1090Битрикс функция вместо jQuery ajax
87
var setResponsive = function () {
  if ($(window).height() > $("#adminmenuwrap").height() + 50) {
     $('#adminmenuwrap').css('position', 'fixed'); 
  } else {
     $('#adminmenuwrap').css('position', 'relative'); 
  }
}
$(window).resize(setResponsive);
setResponsive();
wp, overflow, height500Функция WP для отображения кнопок левого меню админки пр низком экране
86
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
https, www8700Любой редирект на https + www
85
document.addEventListener("DOMContentLoaded", function(event) {
    console.log("DOM fully loaded and parsed");
  });
domcontentloaded200По окончании загрузки страницы без jQuery
84
INSERT INTO table (id, name, age) VALUES(1, "A", 19) ON DUPLICATE KEY UPDATE    
name="A", age=19
update, duplicate100Если есть уже такой ключ в базе, то обновить значение
1 2 3 4 5 6 7 8 9 10 11 12 13 14