merged questioinnaire and questionnaire_phpbb and adjusted all files to our coding guidelines...

if we want to allow dropping in other providers we could add provider files to the questionnaire directory (and grab them), if not it is best to remove the questionnaire directory and put the file under includes/

git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9719 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2009-07-07 09:29:00 +00:00
parent fa84400d28
commit 59a5278c69
4 changed files with 308 additions and 283 deletions

View file

@ -10,31 +10,33 @@
//<![CDATA[ //<![CDATA[
var iframect = 0; var iframect = 0;
function iframeUpdated() function iframe_updated()
{ {
if (iframect++ == 0) if (iframect++ == 0)
{ {
return; return;
} }
//dE('questionnaireForm', -1); //dE('questionnaire-form', -1);
//dE('questionnaireThanks', 1); //dE('questionnaire-thanks', 1);
} }
//]]> //]]>
</script> </script>
<iframe onload="iframeUpdated();" name="questionaireResult" style="display:none"></iframe> <iframe onload="iframe_updated();" name="questionaire_result" style="display: none;"></iframe>
<form action="{U_COLLECT_STATS}" method="post" target="questionaireResult" id="questionnaireForm">
<p id="show_button"><input type="button" class="button2" onclick="dE('configlist', 1);dE('show_button', -1);" value="{L_SHOW_STATISTICS}"/></p> <form action="{U_COLLECT_STATS}" method="post" target="questionaire_result" id="questionnaire-form">
<div id="configlist"> <p id="show-button"><input type="button" class="button2" onclick="dE('configlist', 1); dE('show-button', -1);" value="{L_SHOW_STATISTICS}" /></p>
<input type="button" class="button2" onclick="dE('show_button', 1);dE('configlist', -1);" value="{L_HIDE_STATISTICS}"/>
<div id="configlist">
<input type="button" class="button2" onclick="dE('show-button', 1); dE('configlist', -1);" value="{L_HIDE_STATISTICS}" />
<p class="submit-buttons"> <p class="submit-buttons">
<input class="button1" type="submit" id="submit" name="submit" value="{L_SEND_STATISTICS}" /> <input class="button1" type="submit" id="submit" name="submit" value="{L_SEND_STATISTICS}" />
</p> </p>
<!-- BEGIN providers --> <!-- BEGIN providers -->
<fieldset> <fieldset>
<legend>{providers.NAME}</legend> <legend>{providers.NAME}</legend>
<!-- BEGIN values --> <!-- BEGIN values -->
<dl> <dl>
@ -44,20 +46,22 @@ function iframeUpdated()
<!-- END values --> <!-- END values -->
</fieldset> </fieldset>
<!-- END providers --> <!-- END providers -->
</div> </div>
<p class="submit-buttons"> <p class="submit-buttons">
<input type="hidden" name="systemdata" value="{RAW_DATA}" /> <input type="hidden" name="systemdata" value="{RAW_DATA}" />
<input class="button1" type="submit" id="submit" name="submit" value="{L_SEND_STATISTICS}" /> <input class="button1" type="submit" id="submit" name="submit" value="{L_SEND_STATISTICS}" />
</p> </p>
</form> </form>
<div id="questionnaireThanks">
<p><strong>{L_THANKS_SEND_STATISTICS}</strong></p> <div id="questionnaire-thanks">
<p><strong>{L_THANKS_SEND_STATISTICS}</strong></p>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
//<![CDATA[ //<![CDATA[
dE('configlist', false); dE('configlist', false);
dE('questionnaireThanks', false); dE('questionnaire-thanks', false);
//]]> //]]>
</script> </script>
<!-- INCLUDE overall_footer.html --> <!-- INCLUDE overall_footer.html -->

View file

@ -15,8 +15,8 @@ if (!defined('IN_PHPBB'))
{ {
exit; exit;
} }
include($phpbb_root_path . 'includes/questionnaire/questionnaire_phpbb.' . $phpEx);
include($phpbb_root_path . 'includes/questionnaire/questionnaire.' . $phpEx);
/** /**
* @package acp * @package acp
@ -34,22 +34,24 @@ class acp_send_statistics
$this->tpl_name = 'acp_send_statistics'; $this->tpl_name = 'acp_send_statistics';
$this->page_title = 'ACP_SEND_STATISTICS'; $this->page_title = 'ACP_SEND_STATISTICS';
$c = new Questionnaire_Data_Collector(); $collector = new phpbb_questionnaire_data_collector();
$c->addDataProvider(new Questionnaire_PHP_Data_Provider());
$c->addDataProvider(new Questionnaire_System_Data_Provider()); // Add data provider
$c->addDataProvider(new questionnaire_phpbb_data_provider($config)); $collector->add_data_provider(new phpbb_questionnaire_php_data_provider());
$collector->add_data_provider(new phpbb_questionnaire_system_data_provider());
$collector->add_data_provider(new phpbb_questionnaire_phpbb_data_provider($config));
$template->assign_vars(array( $template->assign_vars(array(
'U_COLLECT_STATS' => $collect_url, 'U_COLLECT_STATS' => $collect_url,
'RAW_DATA' => $c->getDataForForm(), 'RAW_DATA' => $collector->get_data_for_form(),
)); ));
$raw = $c->getDataRaw(); $raw = $collector->get_data_raw();
foreach ($raw as $provider => $data) foreach ($raw as $provider => $data)
{ {
$template->assign_block_vars('providers', array( $template->assign_block_vars('providers', array(
'NAME' => htmlentities($provider), 'NAME' => htmlspecialchars($provider),
)); ));
foreach ($data as $key => $value) foreach ($data as $key => $value)
@ -60,8 +62,8 @@ class acp_send_statistics
} }
$template->assign_block_vars('providers.values', array( $template->assign_block_vars('providers.values', array(
'KEY' => htmlentities($key), 'KEY' => utf8_htmlspecialchars($key),
'VALUE' => htmlentities($value), 'VALUE' => utf8_htmlspecialchars($value),
)); ));
} }
} }

View file

@ -1,152 +1,292 @@
<?php <?php
/**
*
* @package phpBB3
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/*interface Questionnaire_Data_Provider /**
* @ignore
*/
if (!defined('IN_PHPBB'))
{ {
public function getIdentifier(); exit;
public function getData();
}*/
class Questionnaire_PHP_Data_Provider
{
function getIdentifier()
{
return 'PHP';
}
/**
* Get data about the PHP runtime setup.
*
* @return array
*/
function getData()
{
return array(
'version' => PHP_VERSION,
'sapi' => PHP_SAPI,
'int_size' => defined('PHP_INT_SIZE') ? PHP_INT_SIZE : '',
'safe_mode' => (int)ini_get('safe_mode'),
'open_basedir' => (int)ini_get('open_basedir'),
'memory_limit' => ini_get('memory_limit'),
'allow_url_fopen' => (int)ini_get('allow_url_fopen'),
'allow_url_include' => (int)ini_get('allow_url_include'),
'file_uploads' => (int)ini_get('file_uploads'),
'upload_max_filesize' => ini_get('upload_max_filesize'),
'post_max_size' => ini_get('post_max_size'),
'disable_functions' => ini_get('disable_functions'),
'disable_classes' => ini_get('disable_classes'),
'enable_dl' => (int)ini_get('enable_dl'),
'magic_quotes_gpc' => (int)ini_get('magic_quotes_gpc'),
'register_globals' => (int)ini_get('register_globals'),
'filter.default' => ini_get('filter.default'),
'zend.ze1_compatibility_mode' => (int)ini_get('zend.ze1_compatibility_mode'),
'unicode.semantics' => (int)ini_get('unicode.semantics'),
'zend_thread_safty' => (int)function_exists('zend_thread_id'),
'extensions' => get_loaded_extensions()
);
}
}
class Questionnaire_System_Data_Provider
{
function getIdentifier()
{
return 'System';
}
/**
* Get data about the general system information, like OS or IP (shortened).
*
* @return array
*/
function getData()
{
// Start discovering the IPV4 server address, if available
$serverAddress = '0.0.0.0';
if (isset($_SERVER['SERVER_ADDR'])) {
$serverAddress = $_SERVER['SERVER_ADDR'];
}
// Running on IIS?
if (isset($_SERVER['LOCAL_ADDR'])) {
$serverAddress = $_SERVER['LOCAL_ADDR'];
}
$aIPAddress = explode('.', $serverAddress);
return array(
'os' => PHP_OS,
'httpd' => $_SERVER['SERVER_SOFTWARE'],
// we don't want the real IP address (for privacy policy reasons) but only
// a network address to see whether your installation is running on a private or public network.
// IANA reserved addresses for private networks (RFC 1918) are:
// - 10.0.0.0/8
// - 172.16.0.0/12
// - 192.168.0.0/16
'ip' => $aIPAddress[0].'.'.$aIPAddress[1].'.XXX.YYY'
);
}
} }
/** /**
* This class collects data which is used to create some usage statistics. * This class collects data which is used to create some usage statistics.
* *
* The collected data is - after authorization of the administrator - submitted * The collected data is - after authorization of the administrator - submitted
* to a central server. For privacy reasons we try to collect only data which aren't private * to a central server. For privacy reasons we try to collect only data which aren't private
* or don't give any information which might help to identify the user. * or don't give any information which might help to identify the user.
* *
* @author Johannes Schlueter <johannes@php.net> * @author Johannes Schlueter <johannes@php.net>
* @copyright (c) 2007-2008 Johannes Schlueter * @copyright (c) 2007-2008 Johannes Schlueter
*/ */
class phpbb_questionnaire_data_collector
class Questionnaire_Data_Collector
{ {
var $providers; var $providers;
var $data = null; var $data = null;
/** /**
* Constructor. * Constructor.
* *
* @param array * @param array
* @param string * @param string
*/ */
function Questionnaire_Data_Collector() function phpbb_questionnaire_data_collector()
{ {
$this->providers = array(); $this->providers = array();
} }
function addDataProvider(&$provider) function add_data_provider(&$provider)
{ {
$this->providers[] = &$provider; $this->providers[] = &$provider;
} }
/** /**
* Get data as an array. * Get data as an array.
* *
* @return array All Data * @return array All Data
*/ */
function getDataRaw() function get_data_raw()
{ {
if (!$this->data) { if (!$this->data)
$this->collect(); {
} $this->collect();
}
return $this->data; return $this->data;
} }
function getDataForForm() function get_data_for_form()
{ {
return base64_encode(serialize($this->getDataRaw())); return base64_encode(serialize($this->get_data_raw()));
} }
/** /**
* Collect info into the data property. * Collect info into the data property.
* *
* @return void * @return void
*/ */
function collect() function collect()
{ {
foreach (array_keys($this->providers) as $key) { foreach (array_keys($this->providers) as $key)
{
$provider = &$this->providers[$key]; $provider = &$this->providers[$key];
$this->data[$provider->getIdentifier()] = $provider->getData(); $this->data[$provider->get_identifier()] = $provider->get_data();
} }
} }
} }
/** interface: get_indentifier(), get_data() */
/**
* Questionnaire PHP data provider
* @package phpBB3
*/
class phpbb_questionnaire_php_data_provider
{
function get_identifier()
{
return 'PHP';
}
/**
* Get data about the PHP runtime setup.
*
* @return array
*/
function get_data()
{
return array(
'version' => PHP_VERSION,
'sapi' => PHP_SAPI,
'int_size' => defined('PHP_INT_SIZE') ? PHP_INT_SIZE : '',
'safe_mode' => (int) @ini_get('safe_mode'),
'open_basedir' => (int) @ini_get('open_basedir'),
'memory_limit' => @ini_get('memory_limit'),
'allow_url_fopen' => (int) @ini_get('allow_url_fopen'),
'allow_url_include' => (int) @ini_get('allow_url_include'),
'file_uploads' => (int) @ini_get('file_uploads'),
'upload_max_filesize' => @ini_get('upload_max_filesize'),
'post_max_size' => @ini_get('post_max_size'),
'disable_functions' => @ini_get('disable_functions'),
'disable_classes' => @ini_get('disable_classes'),
'enable_dl' => (int) @ini_get('enable_dl'),
'magic_quotes_gpc' => (int) @ini_get('magic_quotes_gpc'),
'register_globals' => (int) @ini_get('register_globals'),
'filter.default' => @ini_get('filter.default'),
'zend.ze1_compatibility_mode' => (int) @ini_get('zend.ze1_compatibility_mode'),
'unicode.semantics' => (int) @ini_get('unicode.semantics'),
'zend_thread_safty' => (int) function_exists('zend_thread_id'),
'extensions' => get_loaded_extensions(),
);
}
}
/**
* Questionnaire System data provider
* @package phpBB3
*/
class phpbb_questionnaire_system_data_provider
{
function get_identifier()
{
return 'System';
}
/**
* Get data about the general system information, like OS or IP (shortened).
*
* @return array
*/
function get_data()
{
// Start discovering the IPV4 server address, if available
$server_address = '0.0.0.0';
if (!empty($_SERVER['SERVER_ADDR']))
{
$server_address = $_SERVER['SERVER_ADDR'];
}
// Running on IIS?
if (!empty($_SERVER['LOCAL_ADDR']))
{
$server_address = $_SERVER['LOCAL_ADDR'];
}
$ip_address_ary = explode('.', $server_address);
// build ip
if (!isset($ip_address_ary[0]) || !isset($ip_address_ary[1]))
{
$ip_address_ary = explode('.', '0.0.0.0');
}
return array(
'os' => PHP_OS,
'httpd' => $_SERVER['SERVER_SOFTWARE'],
// we don't want the real IP address (for privacy policy reasons) but only
// a network address to see whether your installation is running on a private or public network.
// IANA reserved addresses for private networks (RFC 1918) are:
// - 10.0.0.0/8
// - 172.16.0.0/12
// - 192.168.0.0/16
'ip' => $ip_address_ary[0] . '.' . $ip_address_ary[1] . '.XXX.YYY',
);
}
}
/**
* Questionnaire phpBB data provider
* @package phpBB3
*/
class phpbb_questionnaire_phpbb_data_provider
{
var $config;
var $unique_id;
/**
* Constructor.
*
* @param array $config
*/
function phpbb_questionnaire_phpbb_data_provider($config)
{
// generate a unique id if necessary
if (empty($config['questionnaire_unique_id']))
{
$this->unique_id = unique_id();
set_config('questionnaire_unique_id', $this->unique_id);
}
else
{
$this->unique_id = $config['questionnaire_unique_id'];
}
$this->config = $config;
}
/**
* Returns a string identifier for this data provider
*
* @return string "phpBB"
*/
function get_identifier()
{
return 'phpBB';
}
/**
* Get data about this phpBB installation.
*
* @return array Relevant anonymous config options
*/
function get_data()
{
// Exclude certain config vars
$exclude_config_vars = array(
'avatar_gallery_path' => true,
'avatar_path' => true,
'avatar_salt' => true,
'board_contact' => true,
'board_disable_msg' => true,
'board_email' => true,
'board_email_sig' => true,
'cookie_name' => true,
'icons_path' => true,
'icons_path' => true,
'jab_host' => true,
'jab_password' => true,
'jab_port' => true,
'jab_username' => true,
'ldap_base_dn' => true,
'ldap_email' => true,
'ldap_password' => true,
'ldap_port' => true,
'ldap_server' => true,
'ldap_uid' => true,
'ldap_user' => true,
'ldap_user_filter' => true,
'ranks_path' => true,
'script_path' => true,
'server_name' => true,
'server_port' => true,
'server_protocol' => true,
'site_desc' => true,
'sitename' => true,
'smilies_path' => true,
'smtp_host' => true,
'smtp_password' => true,
'smtp_port' => true,
'smtp_username' => true,
'upload_icons_path' => true,
'upload_path' => true,
'newest_user_colour' => true,
'newest_user_id' => true,
'newest_username' => true,
'rand_seed' => true,
);
$result = array();
foreach ($this->config as $name => $value)
{
// Mods may add columns for storing passwords - we do not want to grab them
if (isset($exclude_config_vars[$name]) || strpos($name, 'password') !== false)
{
continue;
}
$result['config.' . $name] = $value;
}
return $result;
}
}
?>

View file

@ -1,121 +0,0 @@
<?php
/**
*
* @package phpBB3
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
include($phpbb_root_path . 'includes/questionnaire/questionnaire.' . $phpEx);
class questionnaire_phpbb_data_provider
{
var $config;
var $unique_id;
/**
* Constructor.
*
* @param array $config
*/
function questionnaire_phpbb_data_provider($config)
{
// generate a unique id if necessary
if (!isset($config['questionnaire_unique_id']))
{
$this->unique_id = unique_id();
set_config('questionnaire_unique_id', $this->unique_id);
}
else
{
$this->unique_id = $config['questionnaire_unique_id'];
}
$this->config = $config;
}
/**
* Returns a string identifier for this data provider
*
* @return string "phpBB"
*/
function getIdentifier()
{
return 'phpBB';
}
/**
* Get data about this phpBB installation.
*
* @return array Relevant anonymous config options
*/
function getData()
{
// Exclude certain config vars
$exclude_config_vars = array(
'avatar_gallery_path' => true,
'avatar_path' => true,
'avatar_salt' => true,
'board_contact' => true,
'board_disable_msg' => true,
'board_email' => true,
'board_email_sig' => true,
'cookie_name' => true,
'icons_path' => true,
'icons_path' => true,
'jab_host' => true,
'jab_password' => true,
'jab_port' => true,
'jab_username' => true,
'ldap_base_dn' => true,
'ldap_email' => true,
'ldap_password' => true,
'ldap_port' => true,
'ldap_server' => true,
'ldap_uid' => true,
'ldap_user' => true,
'ldap_user_filter' => true,
'ranks_path' => true,
'script_path' => true,
'server_name' => true,
'server_port' => true,
'server_protocol' => true,
'site_desc' => true,
'sitename' => true,
'smilies_path' => true,
'smtp_host' => true,
'smtp_password' => true,
'smtp_port' => true,
'smtp_username' => true,
'upload_icons_path' => true,
'upload_path' => true,
'newest_user_colour' => true,
'newest_user_id' => true,
'newest_username' => true,
'rand_seed' => true,
);
$result = array();
foreach ($this->config as $name => $value)
{
if (!isset($exclude_config_vars[$name]))
{
$result['config.' . $name] = $value;
}
}
return $result;
}
}