Skip to content

Instantly share code, notes, and snippets.

@ammarfaizi2
Created March 25, 2018 14:18
Show Gist options
  • Save ammarfaizi2/384ea3bb82ecf1ae15b4e91fb0fdf427 to your computer and use it in GitHub Desktop.
Save ammarfaizi2/384ea3bb82ecf1ae15b4e91fb0fdf427 to your computer and use it in GitHub Desktop.
PRGC 2 Solution
<?php
class x implements PrgcContract, ArrayAccess, JsonSerializable
{
const a_list = [1, 2, 3, FX, FY, FZ, 1];
const b_list = [1, 0, "bcd"];
const c_list = ["\x70", '\x70', '{$_POST[x]->e}'];
const z_list = [123, 456, 789];
private $aOffset = 0;
private $bOffset = 0;
private $cOffset = 0;
private $dOffset = 0;
private $eOffset = 0;
private $zOffset = 0;
private $invoke = 0;
private $container = [];
private $invoke2 = "";
private $e;
private $z = 0;
public function __get($k)
{
if ($k == "a")
return self::a_list[$this->aOffset++];
if ($k == "b")
return self::b_list[$this->bOffset++];
if ($k == "c")
return self::c_list[$this->cOffset++];
if ($k == "d")
return self::a_list[$this->dOffset++];
}
public function go()
{
throw new PrgcException;
}
public function __call($f, $x)
{
if ($f == "abc123" || $f == $_POST["z"])
return $this;
if ($f == $_POST["z"].FX.FY.FZ)
return 123;
}
public function __invoke($x=null)
{
if ($this->z===2) return self::z_list[$this->zOffset++];
if ($this->z) {
$this->z++;
return $this;
}
if ($x === null)
return substr($this->invoke2, 0, 65535 - $this->invoke++);
$this->invoke2 = $x;
return true;
}
public function &offsetGet($k)
{
if ($k == "?") return $this;
return $this->container[$k];
}
public function amp($e)
{
$this->z++;
$this->container["y"]["z"] = $e;
}
public function offsetSet($k,$v)
{
}
public function offsetExists($k)
{
}
public function offsetUnset($k)
{
}
public function jsonSerialize()
{
return [1, 2, 3];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment