diff --git a/mozilla/webtools/survey/inc/config-dist.php b/mozilla/webtools/survey/inc/config-dist.php new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/webtools/survey/inc/footer.php b/mozilla/webtools/survey/inc/footer.php new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/webtools/survey/inc/header.php b/mozilla/webtools/survey/inc/header.php new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/webtools/survey/inc/init.php b/mozilla/webtools/survey/inc/init.php new file mode 100644 index 00000000000..754ef67e34e --- /dev/null +++ b/mozilla/webtools/survey/inc/init.php @@ -0,0 +1,56 @@ + 'mysql', + 'dbsyntax' => 'mysql', + 'username' => DB_USER, + 'password' => DB_PASS, + 'hostspec' => DB_HOST, + 'database' => DB_NAME, + 'port' => DB_PORT + ); + $this->connect($dsn); + + // Test connection; display "gone fishing" on failure. + if (DB::isError($this->db)) { + die('Unable to connect to database. Try again in a few minutes.'); + } + } +} + +/** + * Set global variables. + */ +$db = new Survey_SQL(); +$app = new Survey(); + +/** + * Set up arrays to hold cleaned inputs. + */ +$clean = array(); +$html = array(); +$sql = array(); +?> diff --git a/mozilla/webtools/survey/lib/sql.class.php b/mozilla/webtools/survey/lib/sql.class.php new file mode 100644 index 00000000000..360ca9195ff --- /dev/null +++ b/mozilla/webtools/survey/lib/sql.class.php @@ -0,0 +1,110 @@ + + */ + +// Define query types. +define('SQL_NONE', 1); +define('SQL_ALL', 2); +define('SQL_INIT', 3); + +// Define the query formats. +define('SQL_ASSOC', 1); +define('SQL_INDEX', 2); + +class SQL { + + var $db = null; + var $result = null; + var $error = null; + var $record = null; + + /** + * Class constructor. + */ + function SQL() { } + + /** + * Connect to the database. + * + * @param string $dsn the data source name + * @return bool + */ + function connect($dsn) { + $this->db =& DB::connect($dsn); + + if(PEAR::isError($this->db)) { + $this->error =& $this->db->getMessage(); + return false; + } + return true; + } + + /** + * Disconnect from the database. + */ + function disconnect() { + $this->db->disconnect(); + } + + /** + * Query the database. + * + * @param string $query the SQL query + * @param string $type the type of query + * @param string $format the query format + */ + function query($query, $type = SQL_NONE, $format = SQL_INDEX) { + + $this->record = array(); + $_data = array(); + + // Determine fetch mode (index or associative). + $_fetchmode = ($format == SQL_ASSOC) ? DB_FETCHMODE_ASSOC : null; + + $this->result = $this->db->query($query); + if (DB::isError($this->result)) { + $this->error = $this->result->getMessage(); + return false; + } + switch ($type) { + case SQL_ALL: + // Get all the records. + while($_row = $this->result->fetchRow($_fetchmode)) { + $_data[] = $_row; + } + $this->result->free(); + $this->record = $_data; + break; + case SQL_INIT: + // Get the first record. + $this->record = $this->result->fetchRow($_fetchmode); + break; + case SQL_NONE: + default: + // Records will be looped over with next(). + break; + } + return true; + } + + /** + * Select next row in result. + * @param string $format the query format + */ + function next($format = SQL_INDEX) { + // Fetch mode (index or associative). + $_fetchmode = ($format == SQL_ASSOC) ? DB_FETCHMODE_ASSOC : null; + if ($this->record = $this->result->fetchRow($_fetchmode)) { + return true; + } else { + $this->result->free(); + return false; + } + + } +} +?> diff --git a/mozilla/webtools/survey/lib/survey.class.php b/mozilla/webtools/survey/lib/survey.class.php new file mode 100644 index 00000000000..1c38fa84ff8 --- /dev/null +++ b/mozilla/webtools/survey/lib/survey.class.php @@ -0,0 +1,57 @@ +db =& $db; + } + + /** + * Get possible intentions. + * @return arrayory names. + */ + function getIntends() + { + // Return array. + $retval = array(); + + // Gather intend list. + $this->db->query("SELECT * FROM intend ORDER BY pos, description", SQL_INIT, SQL_ASSOC); + + do { + $retval[$this->db->record['id']] = $this->db->record['description']; + } while ($this->db->next(SQL_ASSOC)); + + return $retval; + } + + /** + * Get possible issues. + * @return array + */ + function getIssues() + { + // Return array. + $retval = array(); + + // Gather platforms.. + $this->db->query("SELECT * FROM issue ORDER BY pos, description", SQL_INIT, SQL_ASSOC); + + do { + $retval[$this->db->record['id']] = $this->db->record['description']; + } while ($this->db->next(SQL_ASSOC)); + + return $retval; + } +} +?> diff --git a/mozilla/webtools/survey/webroot/htaccess.default b/mozilla/webtools/survey/webroot/htaccess.default new file mode 100644 index 00000000000..44f99d3e221 --- /dev/null +++ b/mozilla/webtools/survey/webroot/htaccess.default @@ -0,0 +1,4 @@ +# Auto-prepend our init.php script. +# 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 diff --git a/mozilla/webtools/survey/webroot/index.php b/mozilla/webtools/survey/webroot/index.php new file mode 100644 index 00000000000..9cf6a93fc8e --- /dev/null +++ b/mozilla/webtools/survey/webroot/index.php @@ -0,0 +1,37 @@ +getIntends(); +$issues = $app->getIssues(); + +if (empty($_POST['submit'])) { +echo '
'; + +// Create intend block. +echo '

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

'; +echo ''; + +// Create issue block. +echo '

What issues, if any, did you have? (select all that apply)

'; +echo ''; + +echo '

Other comments or suggestions?

'; +echo ''; + + +echo '
'; +echo '
'; +} +?> diff --git a/mozilla/webtools/survey/webroot/thanks.php b/mozilla/webtools/survey/webroot/thanks.php new file mode 100644 index 00000000000..e69de29bb2d