openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 661f1138cc0eda87ce210e3fdb31dd46ddea331e
parent f6511d6e13ea968ae157430ceae06afa2dec65f4
Author: dankert <devnull@localhost>
Date:   Wed,  5 Jan 2011 23:21:20 +0100

Automatische Erweiterung der Sitzung über AJAX-Request.

Diffstat:
action/TitleAction.class.php | 10++++++++--
action/TitleAction.ini.php | 7+++++--
themes/default/pages/view.php | 23+++++++++++++++++++++++
3 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/action/TitleAction.class.php b/action/TitleAction.class.php @@ -86,10 +86,16 @@ class TitleAction extends Action if ( config('interface','session','auto_extend') ) { - $this->setTemplateVar('refresh_url' ,Html::url('title','show') ); - $this->setTemplateVar('refresh_timeout',ini_get('session.gc_maxlifetime')-60 ); + $this->setTemplateVar('ping_url' ,Html::url('title','ping') ); + $this->setTemplateVar('ping_timeout',ini_get('session.gc_maxlifetime')-60 ); } } + + + public function ping() + { + echo "1"; + } } ?> \ No newline at end of file diff --git a/action/TitleAction.ini.php b/action/TitleAction.ini.php @@ -2,4 +2,7 @@ [default] goto=show -[show]- \ No newline at end of file +[show] + +[ping] +direct=true+ \ No newline at end of file diff --git a/themes/default/pages/view.php b/themes/default/pages/view.php @@ -29,6 +29,29 @@ <link rel="stylesheet" type="text/css" href="<?php echo $user_stylesheet ?>" > <?php } ?> </head> + +<?php +$ping_url = @$viewCache['header']['ping_url' ]; +$ping_timeout = @$viewCache['header']['ping_timeout']; + ?> +<?php if (!empty($ping_url)) { ?> +<script type="text/javascript"> + <!-- + function ping() { + + var xmlHttpObject = new XMLHttpRequest(); + + xmlHttpObject.open('GET', '<?php echo $ping_url ?>'); + xmlHttpObject.send(null); + window.setTimeout("ping()", <?php echo $ping_timeout*1000 ?>); + } + + //window.setTimeout("ping()", <?php echo $ping_timeout*1000 ?>); + window.setTimeout("ping()", 5000); + + // –> + </script> +<?php } ?> <body>