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

Ok!
Ok!
120
В файле bitrix/php_interface/dbconn.php нужно добавить строчку ini_set ("SMTP", "XXX.XXX.XXX.XXX"),
где XXX.XXX.XXX.XXX - IP почтовика 
smtp1670smtp
22
// Create an iframe:
const iframe = document.createElement('iframe');

// Put it in the document (but hidden):
iframe.style.display = 'none';
document.body.appendChild(iframe);

// Wait for the iframe to be ready:
iframe.onload = () => {
  // Ignore further load events:
  iframe.onload = null;

  // Write a dummy tag:
  iframe.contentDocument.write('<streaming-element>');

  // Get a reference to that element:
  const streamingElement = iframe.contentDocument.querySelector('streaming-element');

  // Pull it out of the iframe & into the parent document:
  document.body.appendChild(streamingElement);

  // Write some more content - this should be done async:
  iframe.contentDocument.write('<p>Hello!</p>');

  // Keep writing content like above, and then when we're done:
  iframe.contentDocument.write('</streaming-element>');
  iframe.contentDocument.close();
};

// Initialise the iframe
iframe.src = '';
iframe vs link1755Возможный способ ускорения загрузки через Javascript
26
        <!--script src="http://maps.api.2gis.ru/2.0/loader.js?pkg=full"></script-->
        <!--script type="text/javascript">
    var map;

    DG.then(function () {
        map = DG.map('map', {
            center: [55.753276, 37.783386],
            zoom: 15
        });

        myIcon = DG.icon({
                    iconUrl: '/wp-content/uploads/2016/12/berkana-marker.png',
                    iconSize: [43, 50]
                });

        DG.marker([55.754244, 37.778933], {icon: myIcon}).addTo(map)
    });
</script-->
карта, 2gis, скрипт1800Карта 2Gis
34
UPDATE wp_posts SET post_content = REPLACE(post_content, 'http://rosmid.ru/', '/') WHERE post_content LIKE '%http://rosmid.ru/%'

UPDATE b_iblock_element SET CODE = REPLACE(CODE, '.', '_') WHERE CODE LIKE '%.%'
заменить, mysql1809Заменить конкретные фразы в солонке таблицы mysql
217
$len = 10;   // total number of numbers
$min = 100;  // minimum
$max = 999;  // maximum
$range = []; // initialize array
foreach (range(0, $len - 1) as $i) {
    while(in_array($num = mt_rand($min, $max), $range));
    $range[] = $num;
}
print_r($range);
exclusive random, эксклюзивный2040Эксклюзивный выбор рандомных чисел
139
<div class="itogo">Итого: <?=$pos?> <?=(in_array($pos % 10, array(2, 3, 4)) && $pos < 10 ) ? "позиции" : ($pos == 1 ? "позиция" : "позиций")?></div>
10 позиций2090Множественное по-русски позиций
250
<?php
$dbh = new PDO('mysql:host=localhost;dbname=test', $user, $pass, array(
    PDO::ATTR_PERSISTENT => true
));
?>
pdo, php, mysql, постоянное соединение2200Настройка постоянного соединения с MySQL
44
@supports (-webkit-overflow-scrolling: touch) {}
iPhone, стили для Apple, стили для iPhone2300Добавить стили ТОЛЬКО для iPhone, так как он единственный поддерживает owerflow-scrolling
79
<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
$widthPreview = 300;
$heightPreview = 200;
$widthPreviewBig = 300*2;
$heightPreviewBig = 200*2;
foreach($arResult['ITEMS'] as $i => $arItem) {

        $file = CFile::ResizeImageGet($arItem['FIELDS']["DETAIL_PICTURE"]['ID'], array('width' => $widthPreviewBig, 'height' => $heightPreviewBig), BX_RESIZE_IMAGE_EXACT, true);
        $arResult['ITEMS'][$i]["FIELDS"]["DETAIL_PICTURE"]["SRC"] = $file["src"];
        $arResult['ITEMS'][$i]["FIELDS"]["DETAIL_PICTURE"]["WIDTH"] = $file["width"];
        $arResult['ITEMS'][$i]["FIELDS"]["DETAIL_PICTURE"]["HEIGHT"] = $file["height"];

        $file = CFile::ResizeImageGet($arItem["PREVIEW_PICTURE"]['ID'], array('width' => $widthPreview, 'height' => $heightPreview), BX_RESIZE_IMAGE_EXACT, true);
        $arResult['ITEMS'][$i]["PREVIEW_PICTURE"]["SRC"] = $file["src"];
        $arResult['ITEMS'][$i]["PREVIEW_PICTURE"]["WIDTH"] = $file["width"];
        $arResult['ITEMS'][$i]["PREVIEW_PICTURE"]["HEIGHT"] = $file["height"];
}
resizeImageGet, resize, bitrix2300Ресайз
130
$fr = fopen("log_site_users.txt", "w+");
fwrite($fr, $result . "
");
fclose($fr);
fwrite, запись в файл2300Запись лога в файл php
29
@media all and (min-width: 1001px) {
  #sidebar ul li a:after {
    content: " (" attr(data-email) ")";
    font-size: 11px;
    font-style: italic;
    color: #666;
  }
}
media, content2360Текст тега из атрибуте data-*
127
if (strlen($hip) > 120) {
        $pos = 160;
        $crop = $hip;
        if (strlen($crop) > 160) {
            $pos = strpos($hip, ".", 120) + 1;
        }
        $lip = substr($hip, 0, $pos);
}
обрезать, по точке, crop name2360Обрезать описание до точки если оно длиннее 120 знаков
62
count(preg_grep('~^[0-9]$~', str_split($str)))
считать сколько цифр, php цифр, count digits2390Посчитать число цифр в строке php
99
DELETE t1 FROM contacts t1
        INNER JOIN
    contacts t2 
WHERE
    t1.id < t2.id AND t1.email = t2.email;
удалить, mysql, дупликаты2900Удалить дублирующиеся строки базы
247
function loadImages(block) {
  Array.from(block.querySelectorAll('img[data-src]')).forEach(function (img, i) {
    let _img = new Image,
        _src = img.getAttribute('data-src');
    let wrap = img.closest('.is-loader');
    _img.onload = function () {
      img.src = _src;
      img.classList.add('is-loaded');
      if (wrap.length > 0) wrap.classList.remove('is-loader');
    }
    if (img.src !== _src) _img.src = _src;
  });
}
изображения, загрузка, load, js3000Загрузка картинок с атрибутом data-src
45
<?
$str = "1234567890";
echo TruncateText($str, 7);
// результатом будет строка "1234567..."
?>
bitrix, truncate, text, truncate text3100Обрезка текста в Битрикс
93
<?=($this->GetFolder().'/images/ .... ?>
картинка шаблона инфоблока3200Путь картинки из папки images размещенной в шаблоне компонента
150
function find_wrap($string, $search){
    $out = "";
    $pos = 0;
    if(strpos(" " . $string, $search) > 0){
        $in = str_replace($search, "<b>".$search."</b>", strip_tags($string));
        $wordToFind = $search;
        $numWordsBefore = 3;
        $numWordsAfter = 10;


        $words = preg_split('/s+/', $in);
        $found_words    =   preg_grep("/^".$wordToFind.".*/", $words);
        $found_pos      =   array_keys($found_words);
        if(count($found_pos))
        {
            $pos = $found_pos[0];
        }
        if (isset($pos)) {
            $start = ($pos - $numWordsBefore > 0) ? $pos - $numWordsBefore : 0;
            $length = (($pos + ($numWordsAfter + 1) < count($words)) ? $pos + ($numWordsAfter + 1) : count($words) - 1) - $start;
            $slice = array_slice($words, $start, $length);
            $pre_start  =   ($start > 0) ? "...":"";
            $post_end   =   ($pos + ($numWordsAfter + 1) < count($words)) ? "...":"";
            $out = $pre_start.implode(' ', $slice).$post_end;
        }
    }
    return $out;
}
wrap, фраза текста, поиск3400Возвращает искомое слово из текста плюс 3 слова до и 10 слов после
168
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );

function custom_override_checkout_fields( $fields ) {
    //unset($fields['billing']['billing_first_name']);// имя
    unset($fields['billing']['billing_last_name']);// фамилия
    unset($fields['billing']['billing_company']); // компания
    unset($fields['billing']['billing_address_1']);//
    unset($fields['billing']['billing_address_2']);//
    unset($fields['billing']['billing_city']);
    unset($fields['billing']['billing_postcode']);
    unset($fields['billing']['billing_country']);
    unset($fields['billing']['billing_state']);
    //unset($fields['billing']['billing_phone']);
    //unset($fields['order']['order_comments']);
    //unset($fields['billing']['billing_email']);
    //unset($fields['account']['account_username']);
    //unset($fields['account']['account_password']);
    //unset($fields['account']['account_password-2']);


    unset($fields['billing']['billing_company']);// компания
    unset($fields['billing']['billing_postcode']);// индекс
    return $fields;
}
woocommerce, лишние поля3400Удалить лишние поля для оформления заказа на woocommerce
106
window.i = 1;
setInterval(function( ){
$.ajax({
            type: 'get',
            url: 'https://shop.lamaree.ru/agree/letter.php?iter=' + window.i + '&pass=q12345Q&test=1',
            data: '',
            dataType: "html",
            success: function (data) {
                console.log(window.i);
            }
        });
++window.i;
},1000)
рассылка, скрипт, ajax3450Скрипт рассылки раз в секунду для консоли
1 2 3 4 5 6 7 8 9 10 11 12 13 14