function compose($o) { if ($this->debug || $this->get->src) { $o = parent::compose($o); $o->cookie_path = $CONFIG['session.cookie_path']; $o->cookie_domain = $CONFIG['session.cookie_domain']; $o->document_domain = $CONFIG['document.domain']; $o->maxage = $CONFIG['maxage']; } else { ++self::$recursion; $src = Patchwork\Superloader::class2file(substr(get_class($this), 6)); $src = Patchwork\Serverside::returnAgent($src, (array) $this->get); --self::$recursion; $parser = new JSqueeze(); if ('/*!' != substr(ltrim(substr($src, 0, 512)), 0, 3)) { $o->DATA = Patchwork::__URI__(); $o->DATA .= (false === strpos($o->DATA, '?') ? '?' : '&') . 'src=1'; $o->DATA = "// Copyright & source: {$o->DATA}\n"; foreach (count_chars($o->DATA, 1) as $k => $w) { $parser->charFreq[$k] += $w; } $o->DATA .= $parser->squeeze($src); } else { $o->DATA = $parser->squeeze($src); } } return $o; }
protected function prepare() { if (PATCHWORK_I18N) { $this->lang = Patchwork::__LANG__(); if (!isset($this->alt)) { $a = array(); $base = preg_quote($_SERVER['PATCHWORK_BASE'], "'"); $base = explode('__', $base, 2); $base[1] = '/' === $base[1] ? '[^?/]+(/?)' : ".+?({$base[1]})"; $base = "'^({$base[0]}){$base[1]}(.*)\$'D"; if (preg_match($base, Patchwork::__URI__(), $base)) { unset($base[0]); foreach ($GLOBALS['CONFIG']['i18n.lang_list'] as $k => $v) { if ('' === $k) { continue; } $v = $base[1] . $v . $base[2] . ($this->lang === $k ? $base[3] : Patchwork::translateRequest($base[3], $k)); $a[] = (object) array('lang' => $k, 'title' => isset(self::$nativeLang[$k]) ? self::$nativeLang[$k] : $k, 'href' => $v); } } else { user_error('Something is wrong between Patchwork::__URI__() and PATCHWORK_BASE'); } $this->alt =& $a; } return count($this->alt); } else { return 0; } }
protected function composeEditor($o) { if (!$this->get->sql) { $f = new pForm($o); $f->setPrefix(''); $f->add('hidden', 'low'); $f->add('hidden', 'high'); $sql = $f->add('textarea', 'sql'); if ($sql->isOn()) { $sql = trim($sql->getValue()); $sql || Patchwork::redirect(); if (!($db = $this->getDb($o))) { return $o; } if (self::isReadOnlyQuery($db, $sql, $o->error_msg)) { $sql = urlencode($sql); $uri = Patchwork::__URI__(); $uri = $uri !== strtr($uri, '?&', '--') ? preg_replace("'([?&]sql=)[^&]*'", '$1' . $sql, $uri) : $uri . '?sql=' . $sql; Patchwork::redirect($uri); } try { $db->exec($sql); } catch (Exception $e) { $o->error_msg = $e->getMessage(); } $o->write_sql = pStudio_highlighter::highlight($sql, 'sql', false); } } return $this->composeReader($o); }
static function loadAgent($agent) { p::setMaxage(-1); p::setPrivate(); p::setExpires('onmaxage'); $a = p::agentArgs($agent); $a = implode(',', array_map('jsquote', $a)); $agent = jsquote('agent_index' === $agent ? '' : p\Superloader::class2file(substr($agent, 6))); $lang = p::__LANG__(); $appId = p::$appId; $base = p::__BASE__(); if (PATCHWORK_I18N) { ob_start(); self::writeAgent(new \loop_altLang()); $b = substr(ob_get_clean(), 4, -1); } else { $b = '0'; } $lang = $lang ? " lang=\"{$lang}\"" : ''; $uri = p::__URI__(); $uri .= (false === strpos($uri, '?') ? '?' : '&') . 'p:=serverside'; false !== strpos($uri, '<') && ($uri = str_replace('<', '%3C', $uri)); false !== strpos($uri, '>') && ($uri = str_replace('>', '%3E', $uri)); echo $a = <<<EOHTML <!doctype html> <!--[if lt IE 7]><html{$lang} class="lt-ie9 lt-ie8 lt-ie7 ie6"><![endif]--> <!--[if IE 7]><html{$lang} class="lt-ie9 lt-ie8 ie7"><![endif]--> <!--[if IE 8]><html{$lang} class="lt-ie9 ie8"><![endif]--> <!--[if gt IE 8]><!--><html{$lang}><!--<![endif]--> <meta charset="utf-8"> <noscript><meta http-equiv="refresh" content="0; url={$uri}"></noscript> <script name="w\$">a=[{$agent},[{$a}],{$appId},{$b}]</script> <!--[if !IE]><!--><script name="w\$" src="data:text/javascript,a[4]=1"></script><!--<![endif]--> <script src="{$base}js/w?{$appId}"></script> EOHTML; }