2012-05-23 15:18:49 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
abstract class AbstractAction
|
|
|
|
{
|
|
|
|
protected $value;
|
|
|
|
|
|
|
|
protected $container;
|
|
|
|
|
|
|
|
protected $formatter;
|
|
|
|
|
|
|
|
public function __construct( $value )
|
|
|
|
{
|
|
|
|
$this->value = $value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setContainer( ContainerInterface $container )
|
|
|
|
{
|
|
|
|
$this->container = $container;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setFormatter( FormatterInterface $formatter )
|
|
|
|
{
|
|
|
|
$this->formatter = $formatter;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function esc_raw()
|
|
|
|
{
|
2012-05-30 20:03:20 +00:00
|
|
|
return htmlentities( $this->value );
|
2012-05-23 15:18:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
abstract public function decode();
|
|
|
|
|
|
|
|
public function __toString()
|
|
|
|
{
|
|
|
|
$value = $this->decode();
|
|
|
|
$formatted = $this->formatter->format( $value );
|
|
|
|
return $this->container->wrap( $formatted );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class ActionQuotedPrintableDecode extends AbstractAction
|
|
|
|
{
|
|
|
|
public function __construct( $value )
|
|
|
|
{
|
|
|
|
parent::__construct( $value );
|
|
|
|
$this->setContainer( new TextareaContainer );
|
|
|
|
$this->setFormatter( new EchoFormatter );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function decode()
|
|
|
|
{
|
|
|
|
return quoted_printable_decode( $this->value );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-17 18:18:32 +00:00
|
|
|
class ActionQuotedPrintableEncode extends AbstractAction
|
|
|
|
{
|
|
|
|
public function __construct( $value )
|
|
|
|
{
|
|
|
|
parent::__construct( $value );
|
|
|
|
$this->setContainer( new TextareaContainer );
|
|
|
|
$this->setFormatter( new EchoFormatter );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function decode()
|
|
|
|
{
|
|
|
|
return quoted_printable_encode( $this->value );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-10 14:25:18 +00:00
|
|
|
class ActionBase64Encode extends AbstractAction
|
|
|
|
{
|
|
|
|
public function __construct( $value )
|
|
|
|
{
|
|
|
|
parent::__construct( $value );
|
|
|
|
$this->setContainer( new TextareaContainer );
|
|
|
|
$this->setFormatter( new EchoFormatter );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function decode()
|
|
|
|
{
|
|
|
|
return base64_encode( $this->value );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class ActionBase64Decode extends AbstractAction
|
|
|
|
{
|
|
|
|
public function __construct( $value )
|
|
|
|
{
|
|
|
|
parent::__construct( $value );
|
|
|
|
$this->setContainer( new TextareaContainer );
|
|
|
|
$this->setFormatter( new EchoFormatter );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function decode()
|
|
|
|
{
|
|
|
|
return base64_decode( $this->value );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-23 15:18:49 +00:00
|
|
|
class ActionUrldecode extends AbstractAction
|
|
|
|
{
|
|
|
|
public function __construct( $value )
|
|
|
|
{
|
|
|
|
parent::__construct( $value );
|
|
|
|
$this->setContainer( new TextareaContainer );
|
|
|
|
$this->setFormatter( new EchoFormatter );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function decode()
|
|
|
|
{
|
|
|
|
return urldecode( $this->value );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class ActionUrlencode extends AbstractAction
|
|
|
|
{
|
|
|
|
public function __construct( $value )
|
|
|
|
{
|
|
|
|
parent::__construct( $value );
|
|
|
|
$this->setContainer( new TextareaContainer );
|
|
|
|
$this->setFormatter( new EchoFormatter );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function decode()
|
|
|
|
{
|
|
|
|
return urlencode( $this->value );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class ActionUnserialize extends AbstractAction
|
|
|
|
{
|
|
|
|
public function __construct( $value )
|
|
|
|
{
|
|
|
|
parent::__construct( $value );
|
|
|
|
$this->setContainer( new DivContainer );
|
|
|
|
$this->setFormatter( new DbugFormatter );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function decode()
|
|
|
|
{
|
|
|
|
return unserialize( $this->value );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
interface ContainerInterface
|
|
|
|
{
|
|
|
|
public function wrap( $contents );
|
|
|
|
}
|
|
|
|
|
|
|
|
class DivContainer implements ContainerInterface
|
|
|
|
{
|
|
|
|
public function wrap( $contents )
|
|
|
|
{
|
|
|
|
return '<div class="col">' . $contents . '</div>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class TextareaContainer extends DivContainer
|
|
|
|
{
|
|
|
|
public function wrap( $contents )
|
|
|
|
{
|
2012-08-22 01:37:36 +00:00
|
|
|
return parent::wrap( '<textarea>' . htmlentities($contents) . '</textarea>' );
|
2012-05-23 15:18:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
interface FormatterInterface
|
|
|
|
{
|
|
|
|
public function format( $value );
|
|
|
|
}
|
|
|
|
|
|
|
|
class DbugFormatter implements FormatterInterface
|
|
|
|
{
|
|
|
|
public function format( $value )
|
|
|
|
{
|
|
|
|
ob_start();
|
|
|
|
new dBug( $value );
|
|
|
|
return ob_get_clean();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class VardumpFormatter implements FormatterInterface
|
|
|
|
{
|
|
|
|
public function format( $value )
|
|
|
|
{
|
|
|
|
ob_start();
|
|
|
|
var_dump( $value );
|
|
|
|
return ob_get_clean();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class EchoFormatter implements FormatterInterface
|
|
|
|
{
|
|
|
|
public function format( $value )
|
|
|
|
{
|
|
|
|
return $value;
|
|
|
|
}
|
|
|
|
}
|