Хакер писал(а):А ты думаешь по изложенному можно подсказать, в чём дело? Какой ключ имеет элемент в массиве $_SESSION?
burik писал(а):Скорее, я на это надеюсь
ini_set('session.use_trans_sid', 0);
ini_set('session.use_only_cookies',1);
session_cache_limiter(false);
header('P3P: CP="NOI NID ADMa OUR IND UNI COM NAV"');
header('Cache-Control: private, must-revalidate');
session_name(self::GetSetting('session.name'));
session_start();
self::$session_started = true;
<?php
/**
*
* @author Буров Александр (burikella@mail.ru)
*/
define(PARSER_CLASS, true);
class WxParser {
private $code;
private $passes;
private $position;
private $vars = array();
private $logic_indent = 0;
private $debug = false;
function __construct($debug = false) {
$this->debug = $debug;
}
function Execute($code, $maxpasses = 0) {
$this->code = $code;
$maxpasses = intval($maxpasses);
$this->passes = ($maxpasses == 0) ? intval(Core::GetSetting('parser.maxpasses')) : $maxpasses;
return $this->parse();
}
private function parse() {
$out = '';
$this->position = 0;
$out .= $this->get_out();
$out .= $this->get_in();
return $out;
}
private function to_output($str) {
if(($this->passes <= 1) || (strpos($str, '<?') === false)) {
$__T = 1;
$r = $str;
} else {
$_p = $this->position;
$_c = $this->code;
$this->passes--;
$__T = 2;
$this->code = $str;
$r = $this->parse();
$this->code = $_c;
$this->position = $_p;
$this->passes++;
}
if($this->debug) Core::Log("call to_output for code:\n" . $str . "\n\nReturn:\n" . ($__T == 1 ? 'AS IS' : $r), 0, __file__, __line__);
return $r;
}
private function char($ps = 0) {
return $this->code[$this->position + $ps];
}
private function get_name() {
if(preg_match('/^\s*([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)/', substr($this->code, $this->position), $m)) {
$this->position += strlen($m[0]);
return $m[1];
} else {
return '';
}
}
private function get_value() {
if(preg_match('/^\s*([a-zA-Z0-9_\x7f-\xff]+)/', substr($this->code, $this->position), $m)) {
$this->position += strlen($m[0]);
return $m[1];
} else {
return '';
}
}
private function get_brackets_content() {
$esc = false;
$buf = "";
$close = $this->char();
$this->position++;
while($this->position < strlen($this->code)) {
$char = $this->char();
if($esc) {
if($char != $close && $char != '\\') $buf .= '\\';
$buf .= $char;
$esc = false;
} else {
switch($char) {
case '\\':
$esc = true;
break;
case $close:
$this->position++;
return $buf;
default:
$buf .= $char;
}
}
$this->position++;
}
if($this->debug) Core::Log('Expected end of brackets', 0, __file__, __line__);
return '';
}
private function get_out() {
$p = strpos($this->code, '<?', $this->position);
if($p === false) {
$out = substr($this->code, $this->position);
$this->position = strlen($this->code);
return $out;
}
$out = substr($this->code, $this->position, $p - $this->position);
$this->position = $p;
return $out;
}
private function get_in() {
$out = '';
$this->white_space();
if($this->char() == '<' && $this->char(1) == '?') $this->position += 2;
while($this->position < strlen($this->code)) {
$this->white_space();
if($this->char() == '@') {
$out .= $this->to_output($this->get_script());
} elseif($this->char() == '$') {
$out .= $this->to_output($this->get_variable());
} elseif($this->char() == '?' && $this->char(1) == '>') {
$this->position += 2;
$out .= $this->get_out();
$this->position += 2;
} elseif(preg_match('/^(if|else|endif|elseif)/', substr($this->code, $this->position), $m)) {
if($m[1] == 'if') {
$out .= $this->to_output($this->get_condition());
if($this->char() == ';') $this->position++;
} else {
return $out;
}
} else {
if($this->debug) Core::Log("Unexpected character '" . $this->char() . "' at the beginning of expression.", 0, __file__, __line__);
$p = strpos($this->code, '?>', $this->position);
if($p === false) {
$this->position = strlen($this->code);
} else {
$this->position = $p + 2;
}
return "";
}
}
return $out;
}
private function get_var_value($var) {
$v = & Core::$vars;
foreach($var as &$k) {
if(!is_array($v)) return '';
$v = &$v[$k];
}
return strval($v);
}
private function set_var_value($var, $value) {
$v = & Core::$vars;
foreach($var as &$k) {
if(!is_array($v)) $v = array();
$v = &$v[$k];
}
$v = $value;
}
private function get_variable() {
$this->position++;
$name = $this->get_name();
$var = array($name);
while($this->position < strlen($this->code)) {
$this->white_space();
if($this->char() == '[') {
$this->position++;
$this->white_space();
$buf = $this->get_expression();
if(empty($buf)) {
if($this->debug) Core::Log("Unexpected character '" . $this->char() . "'. Expected array key expression", 0, __file__, __line__);
return '';
}
$this->white_space();
if($this->char() != ']') {
if($this->debug) Core::Log("Unexpected character '" . $this->char() . "'. Expected ']'", 0, __file__, __line__);
return '';
}
$this->position++;
$var[] = $buf;
} else break;
}
$value = $this->get_var_value($var);
if($this->debug) Core::Log("Take variable:\n" . print_r($var, true) . "\nVALUE: '" . $value . "'", 0, __file__, __line__);
$this->white_space();
if($this->char() == '=') {
$this->position++;
$this->white_space();
$buf = $this->get_expression();
$this->set_var_value($var, $buf);
if($this->char() != '?' || $this->char(1) != '>') $this->position++;
if($this->debug) Core::Log("Set new value '" . $buf . "'", 0, __file__, __line__);
return '';
}
while($this->position < strlen($this->code)) {
$this->white_space();
if($this->char() == ':') {
$this->get_modifier($value);
} else {
if($this->char() == ';') $this->position++;
return $value;
}
}
return $value;
}
private function get_modifier(&$value) {
$this->position++;
$name = $this->get_name();
$func = "wx_modifier_" . $name;
while(in_array($this->char(), array(" ", "\t", "\r", "\n", "\0"))) $this->position();
if($this->char() != '(') {
if($this->debug) Core::Log("Unexpected character '" . $this->char() . "'. Expected '('.", 0, __file__, __line__);
return;
}
$this->position++;
$params = array();
$state = 0;
while($this->position < strlen($this->code)) {
$this->white_space();
if($state == 0) {
$buf = $this->get_expression();
if($buf == '') {
if($this->debug) Core::Log("Unexpected character '" . $this->char() . "'. Expected param value", 0, __file__, __line__);
return '';
}
$params[] = $buf;
$state = 1;
} else {
switch($this->char()) {
case ')':
$this->position++;
if(!function_exists($func)) return;
$value = $func($value, $params);
return;
case ',':
$this->position++;
$state = 0;
break;
default:
if($this->debug) Core::Log("Unexpected character '" . $this->char() . "'. Expected ',' or ')'", 0, __file__, __line__);
return;
}
}
}
}
private function get_script() {
$this->position++;
$name = $this->get_name();
if(empty($name)) {
if($this->debug) Core::Log("Unexpected character '" . $this->char() . "'. Expected script name", 0, __file__, __line__);
return '';
}
$func = "wx_script_" . $name;
if(!function_exists($func)) {
if($this->debug) Core::Log("Script '{$name}' not found");
return '';
}
$this->white_space();
if($this->char() != '(') {
if($this->debug) Core::Log("Unexpected character '" . $this->char() . "'. Expected '('", 0, __file__, __line__);
return '';
}
$this->position++;
while($this->position < strlen($this->code)) {
$pname = $this->get_name();
if(empty($pname)) {
if($this->debug) Core::Log("Unexpected character '" . $this->char() . "'. Expected parameter name");
return '';
}
$this->white_space();
if($this->char() != '=') {
if($this->debug) Core::Log("Unexpected character '" . $this->char() . "'. Expected '='");
return '';
}
$this->position++;
$this->white_space();
$pval = $this->get_expression();
if(empty($pval)) {
if($this->debug) Core::Log("Unexpected character '" . $this->char() . "'. Expected param value");
return '';
}
$params[$pname] = $pval;
$this->white_space();
if($this->char() == ')') {
$this->position++;
break;
} elseif($this->char() == ',') {
$this->position++;
} else {
if($this->debug) Core::Log("Unexpected character '" . $this->char() . "'. Expected ',' or ')'", 0, __file__, __line__);
return '';
}
}
if($this->debug) Core::Log("Script call. Name: {$name}\nParams:\n" . print_r($params, true), 0, __file__, __line__);
$value = $func($params);
while($this->position < strlen($this->code)) {
$this->white_space();
if($this->char() == ':') {
$this->get_modifier($value);
} else {
if($this->char() == ';') $this->position++;
return $value;
}
}
return $value;
}
private function get_condition() {
$this->position += 2;
$this->white_space();
if($this->char() != '(') {
if($this->debug) Core::Log("Unexpected character '" . $this->char() . "'. Expected '('", 0, __file__, __line__);
return '';
}
$this->position++;
$cond = $this->get_expression();
$this->white_space();
if($this->char() != ')') {
if($this->debug) Core::Log("Unexpected character '" . $this->char() . "'. Expected ')'", 0, __file__, __line__);
return '';
}
$this->position++;
$out = '';
if($cond) {
if($this->debug) Core::Log("Condition is true. Logic indent", 0, __file__, __line__);
$this->logic_indent++;
$out .= $this->get_in();
$this->skip_login_block('endif');
$this->logic_indent--;
} else {
if($this->debug) Core::Log("Condition is false. Skipping logic block", 0, __file__, __line__);
$out .= $this->skip_login_block();
}
return $out;
}
private function skip_login_block($end = '') {
$in = true; $str = false;
$cli = $li = $this->logic_indent;
while($this->position < strlen($this->code)) {
if($in) {
if($this->char() == '?' && $this->char(1) == '>') {
$in = false;
} elseif(preg_match('/^(if|endif|else|elseif)/', substr($this->code, $this->position), $m)) {
$this->position += strlen($m[1]);
if($m[1] == 'if') {
$cli++;
} elseif($m[1] == 'endif') {
if($cli == $li) return ''; else $cli--;
} elseif($m[1] == 'else' && $end == '') {
$this->logic_indent++;
$out = $this->get_in();
$this->skip_login_block('endif');
$this->logic_indent--;
return $out;
} elseif($m[1] == 'elseif' && $end == '') {
$this->position -= 2;
$out = $this->get_condition();
return $out;
}
}
} else {
if($this->char() == '<' && $this->char(1) == '?') {
$in = true;
}
}
$this->position++;
}
}
private function get_expression() {
$ret = '';
$this->white_space();
switch($this->char()) {
case '@':
$ret = $this->get_script();
break;
case '$':
$ret = $this->get_variable();
break;
case '"': case "'": case "`": case "~":
$ret = $this->get_brackets_content();
break;
default:
$ret = $this->get_value();
}
return $ret;
}
private function white_space() {
while(in_array($this->char(), array(" ", "\t", "\r", "\n", "\0"))) $this->position++;
}
}
?>
Хакер писал(а):Тебя, что, учить методике отладки?
Хакер писал(а):Что там пишется?
Что должно писаться?
FireFenix писал(а):Что весит в конфиге пхп.ини в переменной variables_order?
variables_order = "EGPCS"
burik писал(а):FireFenix писал(а):Что весит в конфиге пхп.ини в переменной variables_order?
- Код: Выделить всё
variables_order = "EGPCS"
Хакер писал(а):Приведи разницу между phpinfo() с сервера, на котором работает как надо, и сервера, на котором не так.
cscript /nologo configure.js "--enable-snapshot-build" "--with-gd=shared"
'./configure' '--disable-pdo' '--enable-bcmath' '--enable-calendar' '--enable-dbase' '--enable-exif' '--enable-force-cgi-redirect' '--enable-ftp' '--enable-gd-native-ttf' '--enable-libxml' '--enable-magic-quotes' '--enable-mbstring' '--enable-safe-mode' '--enable-soap' '--enable-sockets' '--enable-wddx' '--enable-zend-multibyte' '--enable-zip' '--prefix=/usr/local' '--with-apxs=/usr/local/apache/bin/apxs' '--with-bz2' '--with-curl=/opt/curlssl/' '--with-curlwrappers' '--with-freetype-dir=/usr' '--with-gd' '--with-gettext' '--with-imap=/opt/php_with_imap_client/' '--with-imap-ssl=/usr' '--with-jpeg-dir=/usr' '--with-kerberos' '--with-libdir=lib64' '--with-libexpat-dir=/usr' '--with-libxml-dir=/opt/xml2' '--with-libxml-dir=/opt/xml2/' '--with-mcrypt=/opt/libmcrypt/' '--with-mhash=/opt/mhash/' '--with-mime-magic' '--with-mm=/opt/mm/' '--with-mysql=/usr' '--with-mysql-sock=/var/lib/mysql/mysql.sock' '--with-mysqli=/usr/bin/mysql_config' '--with-pic' '--with-png-dir=/usr' '--with-pspell' '--with-tidy=/opt/tidy/' '--with-ttf' '--with-xmlrpc' '--with-xpm-dir=/usr' '--with-xsl=/opt/xslt/' '--with-zlib' '--with-zlib-dir=/usr'
FireFenix писал(а):Если пхп под виндой, то смотри php.ini вначале в C:\Windows
Ты ведь не там смотрел?
burik писал(а):Хакер писал(а):Приведи разницу между phpinfo() с сервера, на котором работает как надо, и сервера, на котором не так.
FireFenix писал(а):burik писал(а):Хакер писал(а):Приведи разницу между phpinfo() с сервера, на котором работает как надо, и сервера, на котором не так.
upload_tmp_dir C:/Program Files/bacs/tmp
папка такая имеется?
Joo писал(а):Если у тебя другой код работает с сессиями нормально, но не работает твой то ищи проблему в коде.
Joo писал(а):Что-то мне подсказывает, что бага где-то в коде, я не представляю таких настроек PHP чтобы по завершении работы скрипта в сессии подменялось значение.
burik писал(а):Следуя такой же логике, можно заключить, что раз один и тот же код работает на одном сервере, но не работает на другом, то проблема в сервере.
работает одинаково хорошо, как на удаленном сервер так и на локальном. Так?burik писал(а):MediaWiki, phpBB3, MODx, Mantis
burik писал(а):но после всех манипуляций направленных на выявление ошибки я в тупике
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 36