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

Ok!
Ok!
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Путь до файла без слеша на конце
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26