Skip to content

Instantly share code, notes, and snippets.

@s2ar
s2ar / bitrix.change.user.pass.php
Last active April 23, 2016 08:17
bitrix change user pass
<?php
// Оригинал http://pai-bx.com/wiki/1c-bitrix/2913-perform-actions-only-when-a-confirm-password/
$arUser["PASSWORD"] = $USER->GetParam("PASSWORD_HASH");
$arParams["PASSWORD"] = $_POST['PASSWORD'];
$arParams["NEW_PASSWORD"] = $_POST['NEW_PASSWORD'];
$arParams["NEW_PASSWORD_CONFIRM"] = $_POST['CONFIRM_NEW_PASSWORD'];
if (strlen($arUser["PASSWORD"]) > 32) {
$salt = substr($arUser["PASSWORD"], 0, strlen($arUser["PASSWORD"]) - 32);
@s2ar
s2ar / Bitrix. Сохранить свойство типа Файл.php
Last active April 23, 2016 08:18
Bitrix. Сохранить свойство типа Файл
<?php
$_FILES['appl_file_input']["MODULE_ID"] = "docsapplications";
CIBlockElement::SetPropertyValueCode($id, 'APDOCS_FILE', $_FILES['appl_file_input']);
@s2ar
s2ar / Bitrix. Очистить свойство типа Файл.php
Last active November 20, 2021 18:54
Bitrix. Очистить свойство типа Файл.
<?php
$bx_photo = CIBlockElement::GetProperty(
$IBID,
$id,
'sort',
'asc',
array('CODE' => 'PHOTO')
);
$ar_photo = $bx_photo->Fetch();
@s2ar
s2ar / Bitrix. Получить свойство элемента.php
Last active April 19, 2017 10:46
Bitrix.Получить.свойство.элемента
<?php
// Получить свойство элемента
$rProp = CIBlockElement::GetProperty($iblock_id, $element_id, "sort", "asc", array("CODE" => "badge"));
$badge = ($aProp = $rProp->GetNext())? $aProp['VALUE'] :'';
@s2ar
s2ar / bitrix highloadblock all items.php
Last active November 11, 2016 07:11
bitrix highloadblock all items
<?php
// Взято с http://thisis-blog.ru/elementi-highload-bloka/#compl
// подключаем пространство имен класса HighloadBlockTable и даём ему псевдоним HLBT для удобной работы
use Bitrix\Highloadblock\HighloadBlockTable as HLBT;
//подключаем модуль highloadblock
CModule::IncludeModule('highloadblock');
//Напишем функцию получения экземпляра класса:
@s2ar
s2ar / array to xml.php
Last active April 23, 2016 08:21
array to xml
<?php
//function defination to convert array to xml
function array_to_xml($array, &$xml_user_info) {
foreach($array as $key => $value) {
if(is_array($value)) {
if(!is_numeric($key)){
$subnode = $xml_user_info->addChild("$key");
array_to_xml($value, $subnode);
}else{
$subnode = $xml_user_info->addChild("item$key");
@s2ar
s2ar / bitrix запись в журнал событий.php
Last active April 23, 2016 08:22
bitrix запись в журнал событий
<?php
AddEventHandler('main', 'OnEventLogGetAuditTypes', 'ASD_OnEventLogGetAuditTypes');
function ASD_OnEventLogGetAuditTypes()
{
return array('MY_OWN_TYPE' => '[MY_OWN_TYPE] Мой собственный тип');
}
CEventLog::Add(array(
"SEVERITY" => "SECURITY",
@s2ar
s2ar / JS.checked.number.js
Last active April 19, 2016 05:55
JS. checked number
/*
-9007199254740990 to 9007199254740990
*/
function isInt(n) {
return +n === n && !(n % 1);
}
/*
-128 to 127
@s2ar
s2ar / bitrix.highload iblock element.php
Last active April 23, 2016 08:23
bitrix.highload iblock element
<?php
use Bitrix\Main\Application;
use Bitrix\Highloadblock\HighloadBlockTable;
use Bitrix\Main\Loader;
Loader::includeModule('highloadblock');
Loader::includeModule('iblock');
$hlBlockId = 2;
@s2ar
s2ar / urlrewrite.php
Last active April 23, 2016 08:23
Bitrix.urlrewrite
<?php
array(
"CONDITION" => "#^/weather/([^/]+)/([^/]+)/($|index\\.php|\\?.*)#",
"RULE" => "COUNTRY_CODE=$1&CITY_CODE=$2",
"ID" => "",
"PATH" => "/weather/city.php",
),
/*
/weather/russia/moscow/ => /weather/city.php?COUNTRY_CODE=russia&CITY_CODE=moscow