diff --git a/mozilla/webtools/survey/webroot/css/survey.css b/mozilla/webtools/survey/webroot/css/survey.css index 423223e8285..4993800106b 100644 --- a/mozilla/webtools/survey/webroot/css/survey.css +++ b/mozilla/webtools/survey/webroot/css/survey.css @@ -4,6 +4,10 @@ padding: .5em 0; } +.survey li { + margin: 3px 0 0 0; +} + h2 { margin: .5em 0; } diff --git a/mozilla/webtools/survey/webroot/htaccess.default b/mozilla/webtools/survey/webroot/htaccess.default index 44f99d3e221..a66a54ca075 100644 --- a/mozilla/webtools/survey/webroot/htaccess.default +++ b/mozilla/webtools/survey/webroot/htaccess.default @@ -2,3 +2,8 @@ # This allows us to have our web documents anywhere we want # and keep our includes, etc. in a safe directory. php_value auto_prepend /YOURPATH/inc/init.php + +# Set up rewrites so we can get our app data in. +RewriteEngine On +RewriteBase /survey/web/root +RewriteRule ^(.+)/(.+)/(.+)/exit.html index.php?version=$1&product=$2&useragent=$3 diff --git a/mozilla/webtools/survey/webroot/index.php b/mozilla/webtools/survey/webroot/index.php index f1ab8a2d623..009de1c3124 100644 --- a/mozilla/webtools/survey/webroot/index.php +++ b/mozilla/webtools/survey/webroot/index.php @@ -7,16 +7,68 @@ $intends = $app->getIntends(); $issues = $app->getIssues(); -if (!empty($_POST['submit'])) { -// Do the inserts and stuff. -// Redirect to thank you page. + +/** + * If the user has submitted, process and complete the transaction. + */ +if (!empty($_POST['submit'])) { + +// Clean inputs. Yes, I know, it should probably be done in the DBI. +// We're not going to be validation nazis here, since the form is optional. +$sql = array(); + +// The easy stuff. +$sql['product'] = !empty($_POST['product'])?mysql_real_escape_string($_POST['product']):null; +$sql['useragent'] = !empty($_POST['useragent'])?mysql_real_escape_string($_POST['useragent']):null; +$sql['http_user_agent'] = mysql_real_escape_string($_SERVER['HTTP_USER_AGENT']); +$sql['intend_id'] = !empty($_POST['intend_id'])?mysql_real_escape_string($_POST['intend_id']):null; +$sql['intend_text'] = !empty($_POST['intend_text'])?mysql_real_escape_string($_POST['intend_text']):null; +$sql['comments'] = !empty($_POST['comments'])?mysql_real_escape_string($_POST['comments']):null; + +// For each issue, we need to log the other text. +$sql['issue_id'] = array(); +if (!empty($_POST['issue_id']) && is_array($_POST['issue_id'])) { + foreach ($_POST['issue_id'] as $issue_id) { + $sql['issue_id'][mysql_real_escape_string($issue_id)] = !empty($_POST[$issue_id.'_text'])?mysql_real_escape_string($_POST[$issue_id.'_text']):''; + } +} + +// Insert the stuff. +$query = ""; + +// Result record. +$query .= " + INSERT INTO + result(intend_id, intend_text, product, useragent, http_user_agent, comments, date_submitted) + VALUES( + '{$sql['intend_id']}', '{$sql['intend_text']}', '{$sql['product']}', '{$sql['useragent']}', '{$sql['http_user_agent']}', '{$sql['comments']}', NOW() + );\n +"; + +if (!empty($sql['issue_id']) && count($sql['issue_id']) > 0) { + foreach ($sql['issue_id'] as $id => $text) { + $query .= " + INSERT INTO issue_result_map() VALUES(LAST_INSERT_ID(), '{$id}', '{$text}');\n + "; + } +} + +// Do the query. +$db->query($query); + +// Redirect to thank you page, and we're done. header('Location: http://'.$_SERVER['HTTP_HOST'].WEB_PATH.'/thanks.php'); exit; + + +/** + * If we haven't submitted, show the form by default. + */ } else { require_once(HEADER); -echo '
'; +echo ''; // Create intend block. echo '

How did you intend to use Firefox when you installed it?

'; @@ -24,7 +76,7 @@ echo ''; // Create issue block. @@ -36,8 +88,10 @@ foreach ($issues as $id=>$text) { echo ''; echo '

Other comments or suggestions?

'; -echo '
'; +echo '
'; +echo ''; +echo ''; echo '
'; echo '
';