protected final function next() { if ($this->firstCall) { $this->firstCall = false; if (!isset($this->data)) { $data = $this->get(); $data->{'a$'} = $this->agent; if ($this->autoResolve) { if (!isset($this->keys) || preg_match("'^(/|https?://)'", $this->agent)) { list($appId, $base, $data->{'a$'}, $keys, $a) = Patchwork\AgentTrace::resolve($this->agent); foreach ($a as $k => &$v) { $data->{$k} =& $v; } $data->{'k$'} = implode(',', $keys); if (false !== $base) { $data->{'v$'} = $appId; $data->{'r$'} = $base; } } else { $data->{'k$'} = $this->keys; } } $this->data = $data; } return clone $this->data; } else { $this->firstCall = true; return false; } }
protected function addAGENT($limit, $inc, &$args, $is_exo) { if ($limit) { return false; } $this->pushCode(''); $keys = false; $meta = $is_exo ? 3 : 2; if (preg_match('/^\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'$/s', $inc)) { eval("\$inc={$inc};"); list($appId, $base, $inc, $keys, $a) = Patchwork\AgentTrace::resolve($inc); $args = array_map('jsquote', $a) + $args; if (false !== $base) { if (!$is_exo) { user_error("Template Security Restriction Error: an EXOAGENT ({$base}{$inc}) is called with AGENT on line " . $this->getLine()); exit; } $meta = "[{$appId}," . jsquote($base) . ']'; } else { if ($is_exo) { user_error("Template Security Restriction Error: an AGENT ({$inc}) is called with EXOAGENT on line " . $this->getLine()); exit; } else { $meta = 1; } } $keys = implode(',', array_map('jsquote', $keys)); $inc = jsquote($inc); } $a = ''; $comma = ''; foreach ($args as $k => $v) { $a .= in_array($k, $this->jsreserved) ? "{$comma}'{$k}':{$v}" : "{$comma}{$k}:{$v}"; $comma = ','; } $a = '{' . $a . '}'; array_push($this->jscode, self::OP_AGENT, 3 === $meta || 2 === $meta ? "function(a,d,v,g,z,r){return {$inc}}" : $inc, "function(a,d,v,g,z,r){return {$a}}", false === $keys ? 0 : "[{$keys}]", $meta); return true; }
protected function addAGENT($limit, $inc, &$args, $is_exo) { if ($limit) { return false; } if (preg_match('/^\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'$/s', $inc)) { eval("\$base={$inc};"); list(, $base, $limit) = Patchwork\AgentTrace::resolve($base); if (false !== $base) { if (!$is_exo) { user_error("Template Security Restriction Error: an EXOAGENT ({$base}{$limit}) is called with AGENT on line " . $this->getLine()); exit; } } else { if ($is_exo) { user_error("Template Security Restriction Error: an AGENT ({$limit}) is called with EXOAGENT on line " . $this->getLine()); exit; } } } $a = ''; $comma = ''; foreach ($args as $k => &$v) { $a .= "{$comma}'{$k}'=>" . $v; $comma = ','; } /**/ if (DEBUG) { if (!strncmp($inc, '(isset(', 7)) { $k = substr($inc, 7, strpos($inc, ')', 7) - 7); $this->pushCode("isset({$k})?Patchwork_Serverside::loadAgent({$inc},array({$a})," . ($is_exo ? 1 : 0) . "):user_error('{$k} is undefined in AGENT name');"); return true; } /**/ } $this->pushCode("Patchwork_Serverside::loadAgent({$inc},array({$a})," . ($is_exo ? 1 : 0) . ");"); return true; }