Skip to content

Instantly share code, notes, and snippets.

View MaxLazar's full-sized avatar
😇

Max Lazar MaxLazar

😇
View GitHub Profile
@MaxLazar
MaxLazar / gist:2e59c100b5e6089eb802cd252287da6c
Created December 24, 2020 05:52
Return Source Back to RTE Again (ExpressionEngine 6 + CKEditor 5)
/*
To inject JS code into CP you can use MX CP CSS & JS addon
https://expressionengine.com/add-ons/mx-cp-css-js
warning - it just a quick workaround, not a solution. You should know what you do. Good luck! :)
*/
let btnRTE = '<div class="mx_extra"><a class="button button--default button--xsmall left show_editor" href="#" style="display:none">Editor</a> <a class="button button--default button--xsmall left show_code" href="#" >Source</a></div>';
$('.rte-textarea').after(btnRTE);
$('.grid-rte').append(btnRTE);
$roleIds = ee('Permission')->rolesThatHave('can_access_cp', $siteId);
return ee('Model')->get('Role', $roleIds)->all()->getDictionary('role_id', 'name');
if (! defined('ENV')) {
$URL = strtolower($_SERVER['HTTP_HOST']);
define('ENV', 'local');
define('ENV_FULL', 'Local');
define('ENV_DEBUG', false);
define('ENV_DOMAIN', $URL);
}
$protocol = ( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ) ? 'https://' : 'http://';
@MaxLazar
MaxLazar / install.sh
Last active January 21, 2020 01:57
install.sh
#!env bash
# Nginx-Craft virtual host configuration file
# @author MaxLazar
# @copyright Copyright (c) 2018
# @link https://maxlazar.com/
# @package server-install-lemp
# @since 1.0.0
# @license MIT
# sudo sh install_server.sh
# https://linuxize.com/post/how-to-add-swap-space-on-centos-7/
Apache
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/system [NC]
RewriteCond %{QUERY_STRING} !ACT|URL [NC]
RewriteCond %{REQUEST_METHOD} !=POST [NC]
RewriteCond $1 !\.(css|js|gif|jpe?g|png) [NC]
RewriteCond %{DOCUMENT_ROOT}/static/default_site/static%{REQUEST_URI}/index\.php -f
RewriteRule ^ /static/default_site/static%{REQUEST_URI}/index\.php [L,QSA]
Apache
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/system [NC]
RewriteCond %{QUERY_STRING} !ACT|URL [NC]
RewriteCond %{REQUEST_METHOD} !=POST [NC]
RewriteCond $1 !\.(css|js|gif|jpe?g|png) [NC]
RewriteCond %{DOCUMENT_ROOT}/static/default_site/static%{REQUEST_URI}/index\.php -f
RewriteRule ^ /static/default_site/static%{REQUEST_URI}/index\.php [L,QSA]
Apache
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/system [NC]
RewriteCond %{QUERY_STRING} !ACT|URL [NC]
RewriteCond %{REQUEST_METHOD} !=POST [NC]
RewriteCond $1 !\.(css|js|gif|jpe?g|png) [NC]
RewriteCond %{DOCUMENT_ROOT}/static/default_site/static%{REQUEST_URI}/index\.php -f
RewriteRule ^ /static/default_site/static%{REQUEST_URI}/index\.php [L,QSA]
$member = ee('Model')->make('Member');
$member->group_id = 5;
$member->screen_name = 'DUMMY' . ee()->localize->now;
$member->username = 'dummy' . ee()->localize->now;
$member->ip_address = ee()->input->ip_address();
$member->join_date = ee()->localize->now;
$member->language = ee()->config->item('deft_lang');
$member->password = 'HD9GD23sxL';
$member->hashAndUpdatePassword( $member->password );
$member->save();
@MaxLazar
MaxLazar / nginx.conf
Created September 10, 2019 15:31
Nginx Rules to Harden WordPress Security
location ~* /xmlrpc.php$ {
allow 172.0.1.1;
deny all;
}
if ($request_method !~ ^(GET|POST)$ ) {
return 444;
}
location ~* /(?:uploads|files|wp-content|wp-includes|akismet)/.*.php$ {
#!/bin/bash
# Find location of this script.
# This ensures that only files in the directory in
# which this script exists (recursively) are modified.
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Set what the name of your expressionengine folders are.
SYSTEM="system"
IMAGES_DIR="public_html/images"