Skip to content

Instantly share code, notes, and snippets.

<?php
// Callback function to format numbers with &nbsp;
function format_numbers_with_nbsp($content) {
// Regular expression pattern to match numbers
$pattern = '/\b(\d{1,3}(?:\d{3})*)\b/';
// Replace matched numbers with formatted version
$formatted_content = preg_replace_callback($pattern, 'add_nbsp_to_number', $content);
@Dimasmagadan
Dimasmagadan / wp-secure.conf
Last active December 4, 2020 11:18 — forked from ethanpil/wp-secure.conf
Wordpress Security for NginX
# wp-secure.conf
#
#
# This file includes common security considerations for wordpress using nginx.
#
# The goal is to block actions which are usually dangerous to wordpress.
# Additionally, we block direct access to PHP files and folders which should not
# be accessed directly from a browser.
#
# Also have included exceptions for plugins that are known to require this access.
function _edaeda(){
curl -v --cookie "p=aaa" https://dobripovar.ru/login/ ;
curl -v --cookie "PHPSESSID=xxx" https://dobripovar.ru/ ;
curl 'https://dobripovar.ru/index.php?route=checkout/cart/add' -H 'Host: dobripovar.ru' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:55.0) Gecko/20100101 Firefox/55.0' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3' --compressed -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'X-Requested-With: XMLHttpRequest' -H 'Referer: https://dobripovar.ru/pervie-bluda/' -H 'Cookie: PHPSESSID=xxx; language=ru; currency=RUB' -H 'Connection: keep-alive' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' --data 'product_id=74&quantity=1';
curl 'https://dobripovar.ru/index.php?route=checkout/cart/add' -H 'Host: dobripovar.ru' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:55.0) Gecko/20100101 Firefox/55.0' -H 'Accept: application/json, text/javascript, */*; q=
@Dimasmagadan
Dimasmagadan / pagespeed.conf
Last active December 31, 2020 11:49
Fix for mod_pagespeed and WordPress
ModPagespeedDisallow */admin/*
ModPagespeedDisallow */wp-admin/*
ModPagespeedDisallow */tinymce/*
ModPagespeedDisallow */mysql/*
ModPagespeedDisallow */tubepress/*
@Dimasmagadan
Dimasmagadan / admin.sql
Last active December 31, 2017 12:01
Create new admin user in #WordPress
INSERT INTO `databasename`.`wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES ('5', 'demo', MD5('demo'), 'Your Name', '[email protected]', 'http://www.test.com/', '2011-06-07 00:00:00', '', '0', 'Your Name');
INSERT INTO `databasename`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '5', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
INSERT INTO `databasename`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '5', 'wp_user_level', '10');
@Dimasmagadan
Dimasmagadan / database encoding fix.sql
Last active December 31, 2017 12:01 — forked from ericrasch/database encoding fix.sql
Fix #WordPress database encoding issues with these #MySQL queries...source #1: http://tanyanam.com/technology/fixing-encoding-issues-on-wordpress-comments-display-as-question-markssource #2: http://stackoverflow.com/a/3568144/284091The 3 groups of repeated queries include the post content, post title, and the post slug.
ALTER DATABASE 'my_wp_database' CHARACTER SET utf8;
ALTER TABLE 'wp_comments' CHARACTER SET utf8;
alter table 'wp_comments' change comment_content comment_content LONGTEXT CHARACTER SET utf8;
alter table 'wp_comments' change comment_author comment_author LONGTEXT CHARACTER SET utf8;
update `wp_posts` set `post_content` = replace(`post_content` ,'á','á');
update `wp_posts` set `post_content` = replace(`post_content` ,'é','é');
update `wp_posts` set `post_content` = replace(`post_content` ,'í©','é');
update `wp_posts` set `post_content` = replace(`post_content` ,'ó','ó');
<?php
/*
Plugin Name: MaxSite Russian Date & Russify Comments Number
Plugin URI: http://maxsite.org/
Description: Русские даты
Version: 1.0
Author: MAX & Alexander Ulizko
*/
function maxsite_the_russian_time($tdate = '') {
<?php
/**
Plugin Name: qTranslate-X Yandex Auto Translator Addon
Description: Over 900 lines of code? Rly?
Version: 1.0
Author: [email protected]
*/
/**
* undocumented function
@Dimasmagadan
Dimasmagadan / wp-config.php
Last active December 31, 2017 13:01
Отключение встроенного редактора кода и возможности установки новых плагинов #WordPress
define( 'DISALLOW_FILE_EDIT', true );
define( 'DISALLOW_FILE_MODS', true );