Skip to content

Instantly share code, notes, and snippets.

@dnikonov
dnikonov / PHP: getDir
Last active December 17, 2015 09:39
PHP: getDir
/**
* берет путь до файла (вложенность директорий)
* @param integer $id идентификатор файла
* @return string путь до файла
*/
function getDir($id)
{
return floor($id / 10000).DS.floor($id % 10000 / 100).DS;
}
@dnikonov
dnikonov / PHP: BOM
Last active August 29, 2015 13:56
Скрипт ищет файлы, сохраненные с BOM.
<?
/**
*
* Скрипт ищет файлы, сохраненные с BOM.
*
* Использование:
* 1. залить на сервер в корневую директорию сайта
* 2. в адресной строке браузера набрать http://ваш.сайт/bom.php
*
@dnikonov
dnikonov / CSS + JS: youtube
Created March 24, 2014 11:25
CSS + JS: youtube
/* CSS */
a[href*=youtube] {display: block; position: relative; width: 260px; height: 195px;}
a[href*=youtube] img {vertical-align: top; width: 260px; height: 195px;}
a[href*=youtube] span {display: block; position: absolute; left: 0; top: 0; background: url('images/play.png') no-repeat center center; width: 260px; height: 195px;}
a[href*=youtube]:hover span {opacity: 0.75;}
/* JS */
// ссылки на видео youtube
$('a[href*=youtube]').each(function(){
@dnikonov
dnikonov / JS: anchor
Created March 27, 2014 05:21
JS: anchor
// прокрутка на все якоря (#) на странице
$('a[href^="#"]').click(function(event){
event.preventDefault();
var h = $(this).attr('href');
var to = $('a[name=' + h.substr(1) + ']');
$('html, body').stop().animate({
'scrollTop': to.offset().top
}, 250);
});
@dnikonov
dnikonov / BITRIX: BREAD (NEWS.DETAIL)
Created April 1, 2014 09:42
BITRIX: BREAD (NEWS.DETAIL)
// create new file
/local/templates/TEMPLATE_NAME/components/bitrix/news/news_list/bitrix/news.detail/.default/component_epilog.php
<?
global $APPLICATION;
$APPLICATION->AddChainItem($arResult["NAME"]);
?>
@dnikonov
dnikonov / TEAMVIEWER: MAC OS CHANGE ID
Created April 11, 2014 15:38
TEAMVIEWER: MAC OS CHANGE ID
defaults delete ~/Library/Preferences/com.teamviewer.teamviewer9.plist
defaults delete ~/Library/Preferences/com.teamviewer.teamviewer9.Machine.plist
sudo defaults delete /Library/Preferences/com.teamviewer.teamviewer9.plist
rm -f ~/Library/Preferences/com.teamviewer.teamviewer9.plist
rm -f ~/Library/Preferences/com.teamviewer.teamviewer9.Machine.plist
sudo rm -f /Library/Preferences/com.teamviewer.teamviewer9.plist
@dnikonov
dnikonov / PHP: geo
Created July 11, 2014 06:06
PHP: geo
$geo = json_decode(file_get_contents('http://api.sypexgeo.net/json/'.$_SERVER["REMOTE_ADDR"]));
@dnikonov
dnikonov / BITRIX: watermark
Created August 28, 2014 05:05
BITRIX: watermark
<?
// Добавление водяного знака на множественное свойство
AddEventHandler("iblock", "OnBeforeIBlockElementAdd", array("SrWatermark", "OnBeforeIBlockElementAdd"));
AddEventHandler("iblock", "OnBeforeIBlockElementUpdate", array("SrWatermark", "OnBeforeIBlockElementUpdate"));
class SrWatermark
{
function OnBeforeIBlockElementAdd (&$arFields)
@dnikonov
dnikonov / PHP: symlink
Created March 23, 2015 07:19
PHP: symlink
@dnikonov
dnikonov / BITRIX: form bootstrap
Last active November 8, 2015 12:07
BITRIX: form bootstrap
// result_modifier.php
$search = array();
$search["text"] = "/class=\"inputtext\"/";
$search["email"] = "/class=\"inputtext\"/";
$search["url"] = "/class=\"inputtext\"/";
$search["date"] = "/\<input /";
$search["textarea"] = "/class=\"inputtextarea\"/";
$search["dropdown"] = "/\<select /";
$search["radio"] = "/\<\/label\>\<label for=\"(\d+)\"\>/";