Skip to content

Instantly share code, notes, and snippets.

View 0test's full-sized avatar

Andrey 0test

View GitHub Profile
<?php
function getUserGeo() {
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = explode(",",$_SERVER['HTTP_X_FORWARDED_FOR'])[0];
} elseif (!empty($_SERVER['REMOTE_ADDR'])){
$ip = $_SERVER['REMOTE_ADDR'];
}
else{
@0test
0test / myconfig.js
Created May 24, 2021 07:56
Ex. config Tiny 5
let myconfig = {
selector: selector_myconfig,
document_base_url: modx_site_url,
language: lang,
language_url: modx_site_url + 'assets/plugins/tinymce5/langs/' + lang + '.js',
plugins: 'print preview importcss searchreplace autolink directionality visualblocks visualchars fullscreen image link media template table charmap hr paste pagebreak nonbreaking anchor toc insertdatetime advlist save lists wordcount imagetools textpattern noneditable charmap emoticons code',
toolbar1: 'undo | bold italic | alignleft aligncenter alignright | bullist numlist blockquote table | link unlink image insertfile formatselect | visualblocks removeformat code ',
mobile:{
theme: "mobile"
<?php
date_default_timezone_set('Europe/Moscow');
$host ='http://ursite.ru/manager/';
$auth_fields = [
'username' => 'administrator',
'password' => '******',
];
$header = [
'Accept: */*',
'Accept-Encoding: gzip, deflate',
public static function prepare(array $data = array(), DocumentParser $modx, $_DocLister, prepare_DL_Extender $_extDocLister){
return $data;
}
//FormLister preare нельзять анонимно только название функции или метода
function setSubject(DocumentParser $modx,array $data,\FormLister\Form $Fl,string $name)
{
}
/**
* categoryUpdate
*
* При сохранении и перемещении товаров обновляет их категорию
*
* @category plugins
* @internal @events onAfterMoveDocument,OnDocFormSave
*/
$e = $modx->Event;
switch ($modx->event->name) {
case 'OnManagerBeforeOrdersListRender': {
// добавляем столбец в таблицу заказов
$params['columns']['name'] = [
'title' => 'Имя',
'content' => function($data, $DL, $eDL) {
return !empty($data['fields']['fullname']) ? $data['fields']['fullname'] : '';
},
'sort' => 20,
params:
&chunk=Redirect Map Chunk;text;redirectMap
OnPageNotFound
global $modx;
$map = $modx->getChunk($chunk);
$lines = explode("\r\n",$map);
$redirectArray = array();
foreach($lines as $line) {
list($link,$redirectId) = explode('||',$line);
@0test
0test / TVid.php
Created March 10, 2021 09:30
tabs
<?php
return [
'settings' => [],
'templates' => [
'region_block' => [
'value' => true,
'type' => 'row',
'title' => 'Один таб',
'label' => 'Один таб',
@0test
0test / TVid.php
Last active March 10, 2021 09:28
<?php
return [
'settings' => [],
'templates' => [
'newsimage' => [
'type' => 'row',
'value' => false,
'label' => 'Фото',
'items.class' => 'd-block',
@0test
0test / order_body_tpl
Last active February 2, 2021 10:58
Commerce - view one order
<tr class="orders_history_one">
<td>[+position+]</td>
<td></span><a href="[~[+product_id+]~]" target="_blank">[+title+]</a></td>
<td style="text-align:center;"><span class="showmobile">Опции</span>[+options+]</td>
<td style="text-align:center;"><span class="showmobile">Количество</span>[+count+]</td>
<td style="text-align:center;"><span class="showmobile">Цена</span>[[PriceFormat? &price=`[+price+]` &convert=`1`]]</td>
<td style="text-align: right; white-space: nowrap;"><span class="showmobile">Стоимость</span>[[PriceFormat? &price=`[+total+]` &convert=`1`]]</td>
</tr>