Skip to content

Instantly share code, notes, and snippets.

View metalagman's full-sized avatar

Alexey Samoylov metalagman

View GitHub Profile
@metalagman
metalagman / bad_referer.conf
Last active September 12, 2016 01:12
HTTP referer spam blocking for nginx
map $http_referer $bad_referer {
hostnames;
default 0;
.semalt.com 1;
.kambasoft.com 1;
.savetubevideo.com 1;
.descargar-musica-gratis.net 1;
.7makemoneyonline.com 1;
.baixar-musicas-gratis.com 1;
.iloveitaly.com 1;
# Cloudflare
set_real_ip_from 103.21.244.0/22;
set_real_ip_from 103.22.200.0/22;
set_real_ip_from 103.31.4.0/22;
set_real_ip_from 104.16.0.0/12;
set_real_ip_from 108.162.192.0/18;
set_real_ip_from 131.0.72.0/22;
set_real_ip_from 141.101.64.0/18;
set_real_ip_from 162.158.0.0/15;
set_real_ip_from 172.64.0.0/13;
server {
listen 80;
error_log /var/log/nginx/yiisite.log;
server_name yiisite.loc;
charset utf-8;
root /var/www/yiisite/web;
server {
listen 80;
server_name yiidreamteam.com;
charset utf-8;
root /var/www/yiidreamteam/frontend/web;
location / {
index index.php;
$js = <<<JS
// Change hash for page-reload
$('.nav-tabs a').on('shown.bs.tab', function (e) {
window.location.hash = e.target.hash;
})
// Javascript to enable link to tab
var url = document.location.toString();
if (url.match('#')) {
$('.nav-tabs a[href=#'+url.split('#')[1]+']').tab('show') ;
<?php
namespace common\traits;
use yii\base\InvalidConfigException;
use yii\helpers\ArrayHelper;
/**
* Trait for default status column
*
* Class StatusTrait
<?php
/**
* @author Alexey Samoylov <alexey.samoylov@gmail.com>
*/
use yii\web\JsExpression;
use yii\helpers\Url;
use yii\helpers\Html;
Url::remember();
$this->title = 'Иерархия';
<?php
namespace common\components;
/**
* Class ActiveRecord
* @package common\components
*/
class ActiveRecord extends \yii\db\ActiveRecord
{
/**
public static function getAssetUrl($url)
{
return \Yii::$app->assetManager->getBundle('frontend\assets\AppAsset')->baseUrl . $url;
}
ymaps.ready(init);
var myMap, myPlaceMark;
function init() {
myMap = new ymaps.Map("map", {
center: [<?=$model->latitude?>, <?=$model->longitude?>],
zoom: <?=$city->defaultZoom?>,
minZoom: <?=$city->minZoom?>,
maxZoom: <?=$city->maxZoom?>,
controls: ['searchControl', 'typeSelector', 'zoomControl', 'geolocationControl']
});