Skip to content

Instantly share code, notes, and snippets.

View webnitros's full-sized avatar

Андрей webnitros

View GitHub Profile
<?php
/** @var modX $modx */
switch ($modx->event->name) {
case 'OnHandleRequest':
$isAjax = !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest';
if (empty($_REQUEST['action']) || (!$isAjax && $modx->event->name != 'OnHandleRequest')) {return;}
$action = trim($_REQUEST['action']);
@webnitros
webnitros / api.php
Created January 14, 2018 05:43
api file modx revolution
<?php
ini_set('display_errors', 1);
ini_set("max_execution_time", 50);
define('MODX_API_MODE', true);
require 'index.php';
$modx->getService('error', 'error.modError');
$modx->getRequest();
$modx->setLogLevel(modX::LOG_LEVEL_INFO);
$modx->setLogTarget('ERROR');
$modx->error->message = null;
@webnitros
webnitros / setup_selenium.sh
Created April 10, 2018 02:22 — forked from curtismcmullan/setup_selenium.sh
Setup Selenium Server on Ubuntu 14.04
#!/bin/bash
# Following the guide found at this page
# http://programmingarehard.com/2014/03/17/behat-and-selenium-in-vagrant.html
echo "\r\nUpdating system ...\r\n"
sudo apt-get update
# Create folder to place selenium in
@webnitros
webnitros / index.php
Last active June 27, 2018 07:08
Test task Mirafox
<?php
/**
* @param array $c
* @return array
*/
function averageNumberOfGoals($c)
{
$games = $c['games'];
$scored = $c['goals']['scored'];
$skiped = $c['goals']['skiped'];
@webnitros
webnitros / sample_json_import.php
Created July 27, 2018 11:44 — forked from sepiariver/sample_json_import.php
Imports a JSON file as output from the sample_json_export.php script.
<?php
// Only run via SSH
if (PHP_SAPI !== 'cli') exit();
// Instantiate MODX
@include(dirname(__FILE__) . '/config.core.php');
if (!defined('MODX_CORE_PATH')) define('MODX_CORE_PATH', dirname(__FILE__) . '/core/');
include_once (MODX_CORE_PATH . "model/modx/modx.class.php");
$modx= new modX();
$modx->initialize('web');
@webnitros
webnitros / checkApiKey.php
Created February 4, 2019 22:28
Проверка сайта на доступ для приложения
<?php
/**
* Created by Andrey Stepanenko.
* User: webnitros
* Date: 24.01.2019
* Time: 1:00
*/
ini_set('display_errors', 1);
ini_set("max_execution_time", 50);
define('MODX_API_MODE', true);
@webnitros
webnitros / generatevter.php
Created February 6, 2019 11:40
События для управления превью изображений для minishop2 MODX
<?php
/**
* Created by Andrey Stepanenko.
* User: webnitros
* Date: 06.02.2019
* Time: 18:38
*/
switch ($event->name) {
case 'OnMediaSourceGetProperties':
<?php
//ini_set('display_errors', 1);
//ini_set("max_execution_time", 20);
// Boot up MODX
require_once dirname(dirname(__FILE__)) . '/config.core.php';
require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx = new modX();
$modx->initialize('web');
$modx->getService('error','error.modError', '', '');
// Boot up any service classes or packages (models) you will need
<?php
class MyControllerPayment extends modRestController {
public $classKey = 'msPayment';
public $defaultSortField = 'rank';
public $defaultLimit = 20;
public $headers = array(
'Access-Control-Allow-Methods' => 'GET',
);
public $fields = 'id,name,description,price,logo,active';
/**
* Connect to a POP3 server.
* @access public
* @param string $host
* @param integer|boolean $port
* @param integer $tval
* @return boolean
*/
public function connect($host, $port = false, $tval = 30)