- fixed silently not working statistic submit with Webkit browsers (Safari, Chrome, ...)

- changed submit url to https://www.egroupware.org/usage-statistic to overcome unsecure submit warnings
This commit is contained in:
Ralf Becker 2011-05-31 09:25:36 +00:00
parent 61c0b251c3
commit e09444e4f6

View File

@ -5,7 +5,7 @@
* @link http://www.egroupware.org * @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de> * @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package admin * @package admin
* @copyright (c) 2009 by Ralf Becker <RalfBecker-AT-outdoor-training.de> * @copyright (c) 2009-11 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$ * @version $Id$
*/ */
@ -23,8 +23,8 @@ class admin_statistics
const CONFIG_USAGE_TYPE = 'usage_type_submit'; const CONFIG_USAGE_TYPE = 'usage_type_submit';
const CONFIG_INSTALL_TYPE = 'install_type_submit'; const CONFIG_INSTALL_TYPE = 'install_type_submit';
const SUBMIT_URL = 'http://www.egroupware-server.org/usage-statistic'; const SUBMIT_URL = 'https://www.egroupware.org/usage-statistic';
const STATISTIC_URL = 'http://www.egroupware-server.org/usage-statistic'; const STATISTIC_URL = 'http://www.egroupware.org/usage-statistic';
const SUBMISION_RATE = 2592000; // 30 days const SUBMISION_RATE = 2592000; // 30 days
@ -52,7 +52,7 @@ class admin_statistics
config::save_value(self::CONFIG_POSTPONE_SUBMIT,time()+$content['postpone'],self::CONFIG_APP); config::save_value(self::CONFIG_POSTPONE_SUBMIT,time()+$content['postpone'],self::CONFIG_APP);
$what = 'postpone'; $what = 'postpone';
} }
elseif($content['submit']) elseif(!$content['canceled'])
{ {
config::save_value(self::CONFIG_LAST_SUBMIT,time(),self::CONFIG_APP); config::save_value(self::CONFIG_LAST_SUBMIT,time(),self::CONFIG_APP);
config::save_value(self::CONFIG_SUBMIT_ID,empty($content['submit_id']) ? '***none***' : $content['submit_id'],self::CONFIG_APP); config::save_value(self::CONFIG_SUBMIT_ID,empty($content['submit_id']) ? '***none***' : $content['submit_id'],self::CONFIG_APP);
@ -128,18 +128,45 @@ class admin_statistics
if (!isset($config[self::CONFIG_LAST_SUBMIT]) || $config[self::CONFIG_LAST_SUBMIT ] <= time()-self::SUBMISION_RATE) if (!isset($config[self::CONFIG_LAST_SUBMIT]) || $config[self::CONFIG_LAST_SUBMIT ] <= time()-self::SUBMISION_RATE)
{ {
// clear etemplate_exec_id and replace form.action, before submitting the form // clear etemplate_exec_id and replace form.action, before submitting the form
$content['onclick'] = " $content['onclick'] = "return submit_statistic(this.form,'$content[submit_url]','".addslashes(lang('Submit displayed information?'))."');";
var action=this.form.action;
var exec_id=this.form['etemplate_exec_id'].value; // Webkit browsers (Chrome, Safari, ...) do NOT allow to call form.submit() from within onclick of a submit button.
this.form.action='$content[submit_url]'; // Therefor we first store our own form action, replace it with egroupware.org submit url and set a timeout calling
this.form['etemplate_exec_id'].value=''; // submit_statistic again with just the form, to do the second submit to our own webserver
this.form.target='_blank'; $GLOBALS['egw_info']['flags']['java_script'] = "<script type=\"text/javascript\">
if (!confirm('".addslashes(lang('Submit displayed information?'))."')) return false; var own_action;
this.form.submit(); var own_exec_id;
this.form.action = action;
this.form['etemplate_exec_id'].value = exec_id; function submit_statistic(form,submit_url,confirm_msg)
this.form.target = ''; {
return true;"; if (submit_url) {
if (!confirm(confirm_msg)) return false;
own_action = form.action;
own_exec_id = form['etemplate_exec_id'].value;
// submit to own webserver
window.setTimeout(function() {
submit_statistic(form);
},100);
// submit to egroupware.org
form.action=submit_url;
form['etemplate_exec_id'].value='';
form.target='_blank';
} else {
// submit to own webserver
form.action = own_action;
form['etemplate_exec_id'].value=own_exec_id;
form.target='';
form.submit();
}
return true;
}
</script>
";
} }
else // we are not due --> tell it the user else // we are not due --> tell it the user
{ {