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 | |
/** | |
* Это стандартный заголовок для какого-либо обработчика AJAX вызова | |
* или обращения к API на Битриксе: всё то, где не выполняется обычная страница сайта. | |
* Коллекция "магических" констант Битрикса, меняя которые под требования скрипта, - | |
* можно существенно снизить нагрузку сервера (меньше исполнения PHP-кода, меньше запросов к БД). | |
* ВНИМАНИЕ! Константы с комментариями - нужно менять их значения или вообще удалять, - | |
* в каждом конкретном применении надо действовать индивидуально | |
*/ |
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 | |
class Utils | |
{ | |
/** | |
* Метод шифрует обратимым методом данные массива. | |
* Получившаяся строка пригодна для отправки в GET запросе. | |
* | |
* @param array $arData Массив данных, который нужно зашифровать | |
* @param string $encKey Секретный ключ (строка со случайными символами). |
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
#!/usr/bin/env bash | |
# For PhpStorm | |
REGEX="^xdebug://(.*):(.*)$" | |
if [[ $1 =~ $REGEX ]]; then | |
/snap/bin/phpstorm --line "${BASH_REMATCH[2]}" "${BASH_REMATCH[1]}" | |
exit 0 | |
fi | |
exit 1 |
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 (isset($_GET['prof']) && 'Y' === $_GET['prof']) { | |
if (function_exists('tideways_xhprof_enable')) { | |
// Профилировщик для PHP7 - https://github.com/tideways/php-xhprof-extension | |
tideways_xhprof_enable(TIDEWAYS_XHPROF_FLAGS_MEMORY | TIDEWAYS_XHPROF_FLAGS_CPU); | |
} elseif (function_exists('xhprof_enable')) { | |
// XHprof заброшен и работает только на PHP5 | |
xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY); | |
} | |
} |
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
server { | |
listen 80; | |
server_name xhprof.local; | |
charset utf-8; | |
# You can download archive with source from: | |
# https://pecl.php.net/package/xhprof | |
root /mnt/projects/sites/xhprof/www/xhprof_html; |
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
# Исходный образ | |
FROM php:7.2-fpm | |
# RUN выполняет идущую за ней команду в контексте нашего образа. | |
# В данном случае мы установим некоторые зависимости и модули PHP. | |
# Для установки модулей используем команду docker-php-ext-install. | |
# На каждый RUN создается новый слой в образе, поэтому рекомендуется объединять команды. | |
RUN apt-get update && apt-get install -y \ | |
curl \ | |
wget \ |
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 | |
// Подключим зависимые библиотеки (API RetailCRM) | |
require_once __DIR__ . '/vendor/autoload.php'; | |
$site = 'https://site'; | |
$apiKey = 'key'; | |
$siteCode = 'TestCompany'; | |
$arBy = ['id', 'externalId']; | |
$arTestPaymentData = [ | |
'externalId' => '38', | |
'amount' => 19800.00, |
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 | |
// Подключим зависимые библиотеки (API RetailCRM) | |
require_once __DIR__ . '/vendor/autoload.php'; | |
$arVersions = [ | |
\RetailCrm\ApiClient::V4, | |
\RetailCrm\ApiClient::V5 | |
]; | |
$site = 'https://sitename'; |
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 | |
/* | |
Функция SQL (подготовленные выражения через PDO) взята с https://www.owasp.org/index.php/PHP_Security_Cheat_Sheet | |
*/ | |
$Host = ''; | |
$Username = ''; | |
$Password = ''; | |
$DatabaseName = ''; | |
$Driver = 'mysql'; | |
/* |
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 | |
session_start(); | |
/** | |
* client_id приложения | |
*/ | |
define('CLIENT_ID', 'local.somecode1.somecode2'); | |
/** | |
* client_secret приложения | |
*/ |