From b753fd8a2fec0694a044a788b64d232778846276 Mon Sep 17 00:00:00 2001 From: Guillaume Turri Date: Sun, 20 Jan 2013 11:20:36 +0100 Subject: [PATCH 1/2] Added timeout --- admin.php | 11 +++++++++++ lang/en/lang.php | 1 + 2 files changed, 12 insertions(+) diff --git a/admin.php b/admin.php index a872dc5..21136f9 100644 --- a/admin.php +++ b/admin.php @@ -28,6 +28,12 @@ function admin_plugin_sync(){ function _connect(){ if(!is_null($this->client)) return true; $this->client = new IXR_Client($this->profiles[$this->profno]['server']); + if ( isset($this->profiles[$this->profno]['timeout']) ){ + $timeout = (int) $this->profiles[$this->profno]['timeout']; + } else { + $timeout = 15; //default legacy value + } + $this->client->timeout = $timeout; // do the login if($this->profiles[$this->profno]['user']){ @@ -83,6 +89,7 @@ function handle() { }else{ // add/edit profile if($this->profno === '') $this->profno = count($this->profiles); + $_REQUEST['prf']['timeout'] = (int) $_REQUEST['prf']['timeout']; $this->profiles[$this->profno] = $_REQUEST['prf']; } $this->_profileSave(); @@ -285,6 +292,9 @@ function _profileform($no=''){ echo ' '; echo ''; + echo ''; + echo ''; + echo ''.$this->getLang('type').''; echo '
'; @@ -298,6 +308,7 @@ function _profileform($no=''){ echo ' '; echo '
'; + echo '
'; echo ''; if($no !== '' && $this->profiles[$no]['ltime']){ diff --git a/lang/en/lang.php b/lang/en/lang.php index c58feb2..1dbf6cf 100644 --- a/lang/en/lang.php +++ b/lang/en/lang.php @@ -59,3 +59,4 @@ $lang['keep'] = 'Skip this file and keep both revisions as is.'; $lang['syncdone'] = 'Synchronization finished.'; +$lang['timeout'] = 'Timeout'; From f094ef3cd4a57df0b43c5fb1c68c1c494e506551 Mon Sep 17 00:00:00 2001 From: Guillaume Turri Date: Sun, 20 Jan 2013 11:40:12 +0100 Subject: [PATCH 2/2] deal with default timeout --- admin.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/admin.php b/admin.php index 21136f9..6a724e5 100644 --- a/admin.php +++ b/admin.php @@ -16,6 +16,7 @@ class admin_plugin_sync extends DokuWiki_Admin_Plugin { protected $profno = ''; protected $client = null; protected $apiversion = 0; + protected $defaultTimeout = 15; /** * Constructor. @@ -31,7 +32,7 @@ function _connect(){ if ( isset($this->profiles[$this->profno]['timeout']) ){ $timeout = (int) $this->profiles[$this->profno]['timeout']; } else { - $timeout = 15; //default legacy value + $timeout = $this->defaultTimeout; } $this->client->timeout = $timeout; @@ -89,7 +90,9 @@ function handle() { }else{ // add/edit profile if($this->profno === '') $this->profno = count($this->profiles); - $_REQUEST['prf']['timeout'] = (int) $_REQUEST['prf']['timeout']; + if ( !isset($_REQUEST['prf']['timeout']) || !is_numeric($_REQUEST['prf']['timeout']) ){ + $_REQUEST['prf']['timeout'] = $this->defaultTimeout; + } $this->profiles[$this->profno] = $_REQUEST['prf']; } $this->_profileSave();