Skip to content

Instantly share code, notes, and snippets.

View AlexMcowkin's full-sized avatar

Alexandr Macovchin AlexMcowkin

View GitHub Profile
/* ВОДНЫЕ ЗНАКИ */
http://brianium.github.io/watermarkjs/
/*ПРИКОЛЬНЫЙ ЗУММЕР ИЗОБРАЖЕНИЙ*/
http://fat.github.io/zoom.js/
/*PHP XML parcer*/
http://sabre.io/xml/
@AlexMcowkin
AlexMcowkin / cql_copy_table
Created May 21, 2015 09:37
SQL: create copy of table
CREATE TABLE table_new LIKE databasename.table_old;
INSERT table_new SELECT * FROM databasename.table_old;
@AlexMcowkin
AlexMcowkin / cut_title.php
Created June 23, 2015 10:23
php: обрезка заголовка по целым словам!
<?php
function cut_title($string)
{
$desired_width = 70;
$string = substr($string, 0, $desired_width+1);
if (strlen($string) > $desired_width)
{
$string = wordwrap($string, $desired_width);
$i = strpos($string, "\n");
@AlexMcowkin
AlexMcowkin / form.html
Created June 23, 2015 14:58
JS: random password generator
<input id="usersmodel-pwd" name="UsersModel[pwd]" value="" type="text">
<a href="#generatepassword" id="generatepassword"><span>сгенерировать пароль</span></a>
@AlexMcowkin
AlexMcowkin / randomstring.php
Created July 13, 2015 15:42
PHP: генерация строки случайными символами
<?php
private function generateRandomPwd($length = 8)
{
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
<?php
try
{
switch (__DIR__) {
case 'D:\open-server500\OpenServer\domains\sitename.loc':
$dbh = new PDO("mysql:host=127.0.0.1; dbname=sitename_db", 'root', '');
break;
default:
$dbh = new PDO("mysql:host=localhost; dbname=dbname", 'dbusr', 'dbpwd');
break;
<?php
include_once('simple_html_dom.php');
// %progdir%\modules\wget\bin\wget.exe -q --no-cache http://forexfactory.loc/forexfactory.php
define ("PATH_TO_FOLDER", "C:/Users/Vadim/AppData/Roaming/MetaQuotes/Terminal/D0E8209F77C8CF37AD8BF550E51FF075/MQL5/Files/");
// define ("PATH_TO_FOLDER", "E:/openserver522/openserver/domains/forexfactory.loc/");
define ("CSV_FILE_NAME", "forexfactoryparce.csv");
if(!file_exists(PATH_TO_FOLDER.CSV_FILE_NAME))
@AlexMcowkin
AlexMcowkin / foreffactory.php
Created August 10, 2015 17:59
forexfactory parce
<?php
include_once('simple_html_dom.php');
// %progdir%\modules\wget\bin\wget.exe -q --no-cache http://forexfactory.loc/forexfactory.php
define ("PATH_TO_FOLDER", "C:/Users/Vadim/AppData/Roaming/MetaQuotes/Terminal/D0E8209F77C8CF37AD8BF550E51FF075/MQL5/Files/");
// define ("PATH_TO_FOLDER", "E:/openserver522/openserver/domains/forexfactory.loc/");
define ("CSV_FILE_NAME", "forexfactoryparce.csv");
if(!file_exists(PATH_TO_FOLDER.CSV_FILE_NAME))
@AlexMcowkin
AlexMcowkin / php_decrypt_encrypt.php
Created August 20, 2015 07:58
способ зашифровать/дешифровать данные БЕЗ md5
$key = 'password to (en/de)crypt';
$string = ' string to be encrypted '; // данные для шифровки/дешифровки
/////////////// Шифрование //////////////////
$iv = mcrypt_create_iv(
mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC),
MCRYPT_DEV_URANDOM
);
$encrypted = base64_encode(
public function actionSearch()
{
// ---------SphinxSearch----------
if($_SERVER['REQUEST_METHOD'] == 'GET')
{
$searchText = HtmlPurifier::process(Yii::$app->request->get('search'));
$searchText = trim($searchText);
$sphinxQuery = new Query();
$sphinxResult = $sphinxQuery->from('post_index')->match($searchText)->all();