This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//$modx->log(1, print_r($array, 1),'HTML'); | |
//ini_set('display_errors',1); //Sets the value of a configuration option. В данном случае. Посмотреть | |
//дефолтные значения display_errors (и не только данного параметра) можно через echo ini_get('display_errors') | |
//error_reporting(E_ALL); | |
require_once $modx->getOption('base_path')."vendor/autoload.php"; | |
$mpdf = new mPDF(); //создаем PDF файл, задаем формат, отступы и.т.д. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Если после перноса сайта на битрикс идет редирект по не понятному алгоритму то скорее всего виновата проактивная защита. Идем в бд и правим в таблице b_option | |
*security | |
*restriction_hosts_action | |
*redirect | |
=============================================================================================== | |
дев прод и bare на одном сервере | |
создаем папку для пустого репозитория и делаем там git init --bare | |
в проде делаем git init | |
делаем в проде первый коммит |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/.idea/ | |
/bitrix/* | |
/upload/* | |
upload | |
/awstats/* | |
/education_files/* | |
/minify_bx/* | |
/tmp/* | |
/robots.txt | |
/.gitignore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
//пишем данные в файл. полезно при отладке аякс запросов | |
$filename = __DIR__.'/data.php'; // Путь куда записать содержимое файла | |
$string = "<?php\n return ".var_export($_GET, true).';'; | |
file_put_contents($filename, $string); | |
//////////////////////////////////////////////////////// | |
//делаем дамп базы из PHP | |
exec('mysqldump --user=username --password=D#hfgefg --host=localhost username > ' . $_SERVER['DOCUMENT_ROOT'] . '/dump.sql'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$start = microtime(true); | |
for ($i = 0; $i <= 30000000; $i++) | |
{ | |
//ничего не делаем | |
} | |
echo 'Скрипт был выполнен за ' . (microtime(true) - $start) . ' секунд'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// BEGIN | |
$app->get('/', function ($params) use ($data) { | |
if (array_key_exists('sort', $params)) { | |
list($key, $order) = explode(' ', $params['sort']); | |
usort($data, function ($prev, $next) use ($key, $order) { | |
$prevValue = $prev[$key]; | |
$nextValue = $next[$key]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
В моей практике, проблема актуальности цен и наличия товаров на сайте стоит очень остро. Владельцы сайта физически не успевают обновлять каталог и доходило до того, что у одного из моих клиентов было порядка 70% отказов от сделанных заказов по этой причине. | |
В комплекте с miniShop2 идет скрипт для обновления каталога из файла csv, но чаще мне приходилось синхронизировать именно с сайтом поставщика, поэтому я хочу поделиться небольшим скриптом, который это и делает. | |
Для парсинга страницы я использовала библиотеку phpQuery в виду ее простоты: запросы очень похожи на синтаксис css и jQuery. | |
Сам код с комментариями: | |
<?php | |
echo '<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8">'; | |
//Подключаем MODx |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
## Читает CSV файл и возвращает данные в виде массива. | |
## @param string $file_path Путь до csv файла. | |
## string $col_delimiter Разделитель колонки (по умолчанию автоопределине) | |
## string $row_delimiter Разделитель строки (по умолчанию автоопределине) | |
## ver 6 | |
ini_set('display_errors', 1); | |
ini_set('error_reporting', -1); | |
//конфиги |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
$info = new SplFileInfo($step_details[1]); // подставляю путь файла и узнаю его инфу | |
$ext = '.'.pathinfo($info->getFilename(), PATHINFO_EXTENSION); | |
$file = $name.$ext; | |
if( file_exists( DIR.$file ) && !file_exists( DIR.$name.$key.$ext )) // проверки на существующие файлы | |
$file = $name.$key.$ext; | |
else | |
$file = $name.($key+1).$ext; | |
save_img( DIR.$file, $step_details[1]); // сохраняю файл на сервере |