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

Ok!
Ok!
205
function flog($fname, $ftext, $write_a_w_state = null){
    if(!$write_a_w_state)
        $write_a_w_state = "a+";
    $fp = fopen("/home/d/dlmlru/posuda/public_html/log/" . $fname, $write_a_w_state);
    fwrite($fp, date("Y-m-d H:i:s ") . $ftext . "

");
    fclose($fp);
}
flog12090функция логирования php
204
var p1 = Promise.resolve(3);
var p2 = 1337;
var p3 = new Promise((resolve, reject) => {
  setTimeout(resolve, 100, "foo");
});

Promise.all([p1, p2, p3]).then(values => {
  console.log(values);
});
Promise, JS10900Промис яваскрипт
203
/^([a-z0-9_.-]+)@([a-z0-9_.-]+).([a-z.]{2,6})$/
regexp, email. JS14800Регулярное выражение для проверки email
202
/^(https?://)?([da-z.-]+).([a-z.]{2,6})([/w .-]*)*/?$/
regexp, url, JS1300Регулярное выражение для проверки URL
201
function send(onError, onSuccess, url, method = 'GET', data = null, headers = [], timeout = 60000) {
  let xhr;

  if (window.XMLHttpRequest) {
      // Chrome, Mozilla, Opera, Safari
      xhr = new XMLHttpRequest();
  }  else if (window.ActiveXObject) { 
      // Internet Explorer
      xhr = new ActiveXObject("Microsoft.XMLHTTP");
  }

  xhr.open(method, url, true);


  headers.forEach((header) => {
      xhr.setRequestHeader(header.key, header.value);
  })
  

  xhr.timeout = timeout;

  xhr.onreadystatechange = function () {
      if (xhr.readyState === 4) {
      if(xhr.status >= 400) {
          onError(xhr.statusText)
      } else {
          onSuccess(xhr.responseText)
      }
      }
  }

  xhr.send(data);
}
xhr, request, XMLHttpRequest, JS12090XMLHttpRequest обернутый в функцию
200
"CUSTOM_FILTER" => "{"CLASS_ID":"CondGroup","DATA":{"All":"AND","True":"True"},"CHILDREN":[{"CLASS_ID":"CondIBSection","DATA":{"logic":"Equal","value":995}}]}",
custom filter^ bitrix100Пример заполнения custom_filter в Битрикс
199
function maskPhone(selector, masked = '+7 (___) ___-__-__') {
        const elems = document.querySelectorAll(selector);

        function mask(event) {
            const keyCode = event.keyCode;
            const template = masked,
                def = template.replace(/D/g, ""),
                val = this.value.replace(/D/g, "");

            let i = 0,
                newValue = template.replace(/[_d]/g, function (a) {
                    return i < val.length ? val.charAt(i++) || def.charAt(i) : a;
                });
            i = newValue.indexOf("_");
            if (i !== -1) {
                newValue = newValue.slice(0, i);
            }
            let reg = template.substr(0, this.value.length).replace(/_+/g,
                function (a) {
                    return "\d{1," + a.length + "}";
                }).replace(/[+()]/g, "\$&");
            reg = new RegExp("^" + reg + "$");
            if (!reg.test(this.value) || this.value.length < 5 || keyCode > 47 && keyCode < 58) {
                this.value = newValue;
            }
            if (event.type === "blur" && this.value.length < 5) {
                this.value = "";
            }

        }

        for (const elem of elems) {
            elem.addEventListener("input", mask);
            elem.addEventListener("focus", mask);
            elem.addEventListener("blur", mask);
        }

    }
    maskPhone('input[type=tel]');
маска телефона12009Скрипт JS маски телефона
198
function setCookie(name,value,days) {
    var expires = "";
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days*24*60*60*1000));
        expires = "; expires=" + date.toUTCString();
    }
    document.cookie = name + "=" + (value || "")  + expires + "; path=/";
}
function getCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}
function eraseCookie(name) {   
    document.cookie = name +'=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}
куки, cookie120Постановка, уаделние кук Яваскрипт
197
let d = new Date(); let m = String(d.getMonth() + 1).padStart(2, '0');
js,javascript,month with 0,month with zero340В яваскрипте получить месяц номер с ведущим нулём
196
SELECT AUTO_INCREMENT FROM  INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'dlmlru_betashop' AND TABLE_NAME = 'sb_plugins_2'
autoincrement, автоинкремент120Получить авоинкремент из таблицы базы данных
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21