Skip to content

Instantly share code, notes, and snippets.

View r3code's full-sized avatar

Dmitriy S. Sinyavskiy r3code

View GitHub Profile
{ Created it because I found that defining the columns at design time isn't much productive.
Usage:
Consider CustomersBindingScope is a TBindScope and CustomersGrid is a TStringGrid, and
CustomerBindingScope.DataObject points to a TList<TCustomer> and TCustomer is declared as
follow:
type
TCustomer = class
public
property Name: String read FName write FName;
property Age: Integer read FAge write FAge;
@r3code
r3code / hostsms6-robots--noindex-follow-for-paged.php
Created August 27, 2017 19:55
HostCMS 6: запрет индексации станиц с пейджингом начиная со второй для магазина и информационных систем
<?php //r3code::Не допускать индексации страниц 2,3 и т.д. где содержимое группы разделено на несколько страниц (SEO)
$objectPresent = is_object(Core_Page::instance()->object);
$objClassName = get_class(Core_Page::instance()->object);
$isPagedSource = ($objClassName == 'Shop_Controller_Show' || $objClassName == 'Informationsystem_Controller_Show');
$notFirstPage= Core_Page::instance()->object->page > 0; // // Первая страница - 0
if ( $objectPresent && $isPagedSource && $notFirstPage )
{
// Запретить индексацию страниц с url /page-N/, но разрешить обход для сбора ссылок
?> <meta name="robots" content="noindex, follow"><?php
echo PHP_EOL;
@r3code
r3code / htaccess-php-malware-protection.txt
Last active January 22, 2024 20:09
.htaccess правила для предотвращения исполнения вредоносных PHP-скриптов
# Блокировка XSS
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Блокируем выставление переменной PHP GLOBALS через URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Блокируем возможность изменять переменную _REQUEST через URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Блокировка MySQL инъекций, RFI, base64, и др.
RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=http:// [OR]
RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=(\.\.//?)+ [OR]
@r3code
r3code / notify-bad-requests.php
Created August 29, 2017 19:39
Скрипт для уведомления о плохих запросах отловленных правилом в .htaccess
<?php
// report blocked requests
// @ https://perishablepress.com/detect-attacks-php-htaccess/
//
// redirect bad requests with htaccess rule
// RewriteRule (.*) /path/to/notify-bad-requests.php?6g_1=%1&6g_2=%2&6g_3=%3 [R=302,L]
$email = '[email protected]';
$subject = 'Blocked Request Report';
@r3code
r3code / send-zip-bomp.php
Created August 29, 2017 20:51
Скрипт для отсылки zip-бомбы атакующему веб-сайт сканнеру, или источнику пытающемуся вызвать вредоносный код PHP
<?php
/*
See original source at https://habrahabr.ru/post/332580/
Create bomb file in Linux with: dd if=/dev/zero bs=1M count=10240 | gzip > 10G.gzip
Bomb must be GZIP compressed
*/
$bomb_file_path = '10G.gzip'; // path to a HUGE file, same folder as it's script
/* // Uncomment to enable
@r3code
r3code / hostcms5-hotoffers.php
Last active October 31, 2017 20:16
HostCMS 5 - Горячие предложения (блок в макете)
<?php // Горячие предложения / расчет (вставить сверху шаблона)
if (class_exists('shop'))
{
$shop = & singleton('shop');
$shop_id = 1;
$param_offer = array();
// Товары выбираем из всех групп
$param_offer['current_group_id'] = false;
// Выводим по 4 товара в блока
$param_offer['items_on_page'] = 4;
@r3code
r3code / МагазинГорячиеПредложения.xslt
Created October 31, 2017 20:16
HostCMS 5 - Горячие предложения, XSLT-шаблон
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output xmlns="http://www.w3.org/TR/xhtml1/strict" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" encoding="utf-8" indent="yes" method="html" omit-xml-declaration="no" version="1.0" media-type="text/xml"/>
<!-- МагазинКаталогТоваровНаГлавнойСпецПред -->
<xsl:template match="/">
<xsl:apply-templates select="/shop"/>
</xsl:template>
@r3code
r3code / .htaccess
Last active April 6, 2018 12:32
htaccess for password protect based on domain name (for multisite CMS dev)
# Password protect for site.ru while in DEV
SetEnvIf host ^site\.ru$ noauth=1
SetEnvIf host ^www\.site\.ru$ noauth=1
# Put your password auth stuff here
AuthName 'Restricted Area site.ru'
AuthType Basic
AuthUserFile /path/to/.authfile
Require valid-user
@r3code
r3code / js-refartoring-example.js
Created April 6, 2018 07:06
Making our JS code more clear (splitiing the code)
// # Making our JS code more clear
// Based on https://codepen.io/dongguangming/pen/bNjzzw
// --------------------------------------------------------------
//
// ## 1. Initial code. Bad practice.
//
// * Mixed IO and data processing all in one place.
// * It is not self-documenting, as it is not clear at-a-glance what is happening inside it.
// * It can not be easily unit tested as it has side-effects (e.g. API calls) mixed in with its output logic.
//
@r3code
r3code / node-shape-square-draw-image-visjs.html
Last active April 27, 2022 16:04
vis.js draw custom image for node shape square or box
// https://codepen.io/anon/pen/mjJMOy
<div id="graph"></div>
<script>
document.addEventListener('DOMContentLoaded', function() {
document.addEventListener('DOMContentLoaded', function() {
var container = document.querySelector('#graph');
var data = {
nodes: [