X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fajax.inc;h=f71aaf47c987b2773af02ce0dd0e9ff506e39974;hb=1ea749c4abfe081bd7f1b4b11c65a61b311a189e;hp=ce8c965519e3ab62f0429649e8f0d50fe4ca4808;hpb=f513bee88bb7c734dd65486e230cc497c2fc8894;p=fa-stable.git diff --git a/includes/ajax.inc b/includes/ajax.inc index ce8c9655..f71aaf47 100644 --- a/includes/ajax.inc +++ b/includes/ajax.inc @@ -1,4 +1,14 @@ . +***********************************************************************/ require_once($path_to_root. "/includes/JsHttpRequest.php"); class Ajax extends JsHttpRequest { @@ -8,7 +18,7 @@ class Ajax extends JsHttpRequest { function Ajax() { - $this->JsHttpRequest($_SESSION['language']->encoding); + $this->JsHttpRequest(@$_SESSION['language']->encoding); } // // This function is used in ctrl routines to activate @@ -25,15 +35,15 @@ class Ajax extends JsHttpRequest { // function redirect($url) { if(in_ajax()) { - $this->_addCommand(true, array('n'=>'rd'),$url); - $this->run(); + $this->_addCommand(true, array('n'=>'rd'), absolute_url($url)); + $this->run(); } } // // Popup window (target=_blank) // function popup($url) { - $this->_addCommand(true, array('n'=>'pu'),$url); + $this->_addCommand(true, array('n'=>'pu'), absolute_url($url)); } // // Adds an executable Javascript code. @@ -122,8 +132,8 @@ class Ajax extends JsHttpRequest { if($com['n'] == 'up' && $com['t'] == '_page_body') { $cmds = array($com); foreach( $this->aCommands as $k=> $cmd) { - if ($cmd['n'] == 'fc') { // save focus - $cmds[] = $cmd; break; + if ($cmd['n'] == 'fc' || $cmd['n'] == 'js') { // save focus + $cmds[] = $cmd; //break; } } $this->aCommands = $cmds; @@ -142,4 +152,10 @@ function in_ajax() { return $Ajax->isActive(); } -?> +// Returns absolute path of relative $url. To be used in ajax calls +// for proper redirection from any referer page. +// +function absolute_url($url) +{ + return strpos($url, '..')===0 ? dirname($_SERVER['PHP_SELF']).'/'.$url : $url; +}