Skip to content

Instantly share code, notes, and snippets.

View megamosk's full-sized avatar
🎯
Focusing

megamosk

🎯
Focusing
View GitHub Profile
@megamosk
megamosk / dropzone.php
Created March 23, 2021 16:59
Dropzone.js with php multiple files upload
<?php
// define absolute folder path
$storeFolder = 'ABSOLUTE_FOLDER_PATH/'
// if folder doesn't exists, create it
if(!file_exists($storeFolder) && !is_dir($storeFolder)) {
mkdir($storeFolder);
}
// upload files to $storeFolder
@megamosk
megamosk / bitrix_cheat_sheets.txt
Created November 20, 2021 19:20
Bitrix cheat sheets
Шаблон
Пролог/подключение языковых файлов (header.php/footer.php)
<?
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true) die();
IncludeTemplateLangFile(__FILE__);
?>
Язык шаблона
<html lang="<?=LANGUAGE_ID?>">
@megamosk
megamosk / price_provider.php
Created May 27, 2022 10:21
Ставка НДС в зависимости от местоположения 1С-Битрикс
<?php
use Bitrix\Main;
use Bitrix\Main\Loader;
Loader::includeModule("catalog");
\Bitrix\Main\EventManager::getInstance()->addEventHandler(
'sale',
'OnSaleBasketBeforeSaved',
@megamosk
megamosk / add_discount.php
Created July 17, 2023 11:10
1C-Битрикс добавление скидки по внешнему коду продукта
<?php
require $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_before.php';
use Bitrix\Main\Loader;
Loader::includeModule('catalog');
// add discount by product xml id
$uuid = 'f0a73f90-57ec-11ec-8ea2-005056b8434b';
@megamosk
megamosk / reserve.php
Created November 21, 2023 15:21
Битрикс резервирование товара и снятие резерва
<?php
//резервирование товара
$productId = 12;
$a = new \Bitrix\Catalog\Product\CatalogProvider;
$resReserve = $a->reserve(array(
$productId => ["PRODUCT_ID" => $productId, "QUANTITY" => 15]
));
@megamosk
megamosk / gist:1d40a3a0ac9551b456d63972aafc841c
Created May 24, 2024 08:04
Postfix: adding TLS traffic encryption support
#add certificate
openssl req -new -nodes -x509 -out /etc/postfix/smtpd.pem -keyout /etc/postfix/smtpd.pem -days 3650
#/etc/postfix/main.cf
smtp_use_tls = yes
smtpd_use_tls = yes
smtpd_tls_auth_only = yes
smtp_tls_note_starttls_offer = yes
smtpd_tls_key_file = /etc/postfix/smtpd.pem
smtpd_tls_cert_file = /etc/postfix/smtpd.pem