Skip to content

Instantly share code, notes, and snippets.

View BAHC's full-sized avatar

BAHC

View GitHub Profile
@BAHC
BAHC / mysqli.php
Created May 31, 2019 02:26
MySQL Improved
<?php
$db_user = 'root';
$db_pass = 'toor';
$db_host = 'localhost';
$db_port = 3306;
$db_name = 'my_db';
$db_encoding = 'utf8';
//mysqli_connect(host, username, password, dbname, port, socket);
@BAHC
BAHC / functions.php
Created May 31, 2019 02:15
Custom routes in WP theme
<?php
//file /wp-content/themes/current-theme/functions.php
function custom_addRoutes() {
add_rewrite_rule('^([A-Za-z]+)/([A-Za-z\+]+)/([0-9]+)/?$', 'tour/?id=$matches[3]&city=$matches[2]&country=$matches[1]', 'top');
add_rewrite_rule('^([A-Za-z]+)/([A-Za-z\+]+)/?$', 'city/?city_name_en=$matches[2]&country=$matches[1]', 'top');
add_rewrite_rule('^([A-Za-z^index]+)/?$', 'country/?country_name_en=$matches[1]', 'top');
}
add_action('init', 'custom_addRoutes');
@BAHC
BAHC / .htaccess
Last active May 31, 2019 01:55
Redirect using mod_rewrite
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^([A-Za-z]+)/([A-Za-z\+]+)/([0-9]+)/?$ tour/?id=$3&city=$2&country=$1 [NC]
RewriteRule ^([A-Za-z]+)/([A-Za-z\+]+)/?$ city/?city=$2&country=$1 [NC]
RewriteRule ^([A-Za-z^index]+)/?$ country/?country=$1 [NC]
public function __construct()
{
$this->clients = new \SplObjectStorage;
$this->connectedUsers = [];
$this->connectedIDs = [];
$this->IDs = 0;
}
public function onOpen(ConnectionInterface $conn)
{
@BAHC
BAHC / mailer.php
Last active May 1, 2019 10:45
Mailer for Yesbol
<?php
//....
$pass = 'qwertyqwerty';
//$row['user_mail'] = 'wans@localhost';
//$row['id_user'] = 1;
$link = 'http://elink.kz/respass/reset/code/'.md5($pass).'/'.$row['id_user'];
@BAHC
BAHC / erp_category.php
Last active May 1, 2019 01:33
ERP Category
<?php
$xml = file_get_contents("erp_category.xml");
$xml = str_replace(PHP_EOL, '', $xml);
$xml = str_replace( "\t", '', $xml);
$xml = str_replace(' ', ' ', $xml);
$xml = str_replace('<Категория_1', "\n\n".'<Категория_1', $xml);
$xml = str_replace('</Категория_1>', '</Категория_1>'."\n\n", $xml);
<script>
var Slides = {};
Slides.tDuration = 1.75 * 1000;
Slides.bgLg = "https://yachtering.eu/img/slides_20min_big.png?201903031805";
Slides.bgSm = "https://yachtering.eu/img/slides_20min.png?201903031805";
Slides.imgHSm = 75;
Slides.imgWSm = 75;
@BAHC
BAHC / Stars 19
Last active December 22, 2018 08:35
<?php
/**
* Привет в 2019 из книги 2008 года
* Андрей Богатырев. Руководство полного идиота
* по программированию (на языке Си)
* http://lib.ru/CTOTOR/starterkit.txt
*/
define("LINES", 19);
@BAHC
BAHC / cmsif_primer.php
Last active July 3, 2018 02:10
CMSIF Primer
<?php
require __DIR__.'/cmsif.php';
init();
/**/
//Simple route to include module file
router('get', '/about', CMSIF_MODULES.'/about.php');
//Simple HTML page
@BAHC
BAHC / get_exchange_rate_for_one_pair.php
Last active June 28, 2018 20:09
Get Exchange Rate For One Pair In One Direction
<?php
require 'exchange_rate.php';
function get_exr($_from=null, $_to=null)
{
$_res = null;
$_pair = $_from.'_'.$_to;
$_pairs = exchange_rate([ $_from => $_to ]);
if(is_array($_pairs) && isset($_pairs[$_pair]))
{