This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- function pDate() { | |
- return new Date().getTime(); | |
- } | |
doctype html | |
html(lang="ru") | |
head | |
meta(charset="utf-8") | |
title TITLE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user - имя пользователя | |
server.timeweb.ru - сервер | |
1. На машине ssh-keygen -t rsa | |
2. Копируем, можно по FTP или одной из команд | |
2.1. ssh-copy-id -i ~/.ssh/id_rsa [email protected] | |
2.2. scp ~/.ssh/id_rsa.pub [email protected]:~ | |
3. На сервере | |
[ -d ~/.ssh ] || (mkdir ~/.ssh; chmod 711 ~/.ssh) # создание директории и изменение прав | |
cat ~/id_rsa.pub >> ~/.ssh/authorized_keys # добавление открытого ключа |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php"); | |
global $USER; | |
use Bitrix\Main, | |
Bitrix\Main\Loader, | |
Bitrix\Main\Config\Option, | |
Bitrix\Sale, | |
Bitrix\Sale\Order, | |
Bitrix\Sale\DiscountCouponsManager; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Bitrix\Main\Application; | |
$connection = Application::getConnection(); | |
$sqlHelper = $connection->getSqlHelper(); | |
$sql = "SELECT ID FROM b_user WHERE LOGIN = '".$sqlHelper->forSql($login, 50)."'"; | |
//$connection->query($sql, $limit); | |
//$connection->query($sql, $offset, $limit); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(defined('BX_COMP_MANAGED_CACHE')) | |
$GLOBALS['CACHE_MANAGER']->ClearByTag('iblock_id_4'); //clear cache for iblock with ID = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function plural_form($n, $forms) { | |
return $n%10==1&&$n%100!=11?$forms[0]:($n%10>=2&&$n%10<=4&&($n%100<10||$n%100>=20)?$forms[1]:$forms[2]); | |
} | |
//usage | |
$ends = [ | |
"банан", | |
"банана", | |
"бананов" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function isPhone($val){ | |
if (!preg_match('/^((8|\+7)[\- ]?)?(\(?\d{3}\)?[\- ]?)?[\d\- ]{7,10}$/iu', $val)) | |
return false; | |
return true; | |
} | |
//allow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Bitrix\Main\Diag\Debug; | |
use Bitrix\Main\Diag\Helper; | |
/*Write in file*/ | |
//Debug::writeToFile($variable, $varName, $file); | |
Debug::writeToFile(['ID' => $ID, 'fields' => $arResult ], null, "log.log"); | |
Debug::dumpToFile(['ID' => $ID, 'fields' => $arResult ], null, "log.log"); | |
/*Time label*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$adress = urlencode("Москва, Тверская улица, дом 7"); | |
$url = "http://geocode-maps.yandex.ru/1.x/?geocode={$adress}"; | |
$content = file_get_contents($url); | |
preg_match("/<pos>(.*?)<\/pos>/", $content, $point); | |
$coords = str_replace(' ', ', ', trim(strip_tags($point[1]))); | |
echo $coords; | |
// результат: 38.241803, 56.300984 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getNumEnding(number, titles) { | |
var cases = [2, 0, 1, 1, 1, 2]; | |
return titles[ (number%100>4 && number%100<20)? 2 : cases[(number%10<5)?number%10:5] ]; | |
} | |
use: | |
getNumEnding(count, ["товар", "товара", "товаров"]); |
NewerOlder