From 3e50491217d51725909c995b8e9edeb21c51324e Mon Sep 17 00:00:00 2001 From: "robert%accettura.com" Date: Thu, 26 Jan 2006 03:14:01 +0000 Subject: [PATCH] Server side support for screenshots, utf-8 support. Some minor code cleanup also rolled in. --- tools/reporter/config-default.inc.php | 7 + tools/reporter/htdocs/.htaccess | 1 + .../htdocs/img/theme/mozilla/header_logo.gif | Bin 5162 -> 3566 bytes tools/reporter/htdocs/report.php | 70 +++-- tools/reporter/htdocs/screenshot.php | 49 +++ tools/reporter/htdocs/service.php | 284 ++++++++++++------ .../htdocs/styles/theme/mozilla/reporter.css | 15 + tools/reporter/sql/schema.sql | 61 ++-- tools/reporter/templates/index.tpl | 6 +- tools/reporter/templates/mozilla/layout.tpl | 2 +- tools/reporter/templates/report.tpl | 177 +++++++---- 11 files changed, 462 insertions(+), 210 deletions(-) create mode 100644 tools/reporter/htdocs/screenshot.php diff --git a/tools/reporter/config-default.inc.php b/tools/reporter/config-default.inc.php index 4fc879a0746..83ab802eac2 100644 --- a/tools/reporter/config-default.inc.php +++ b/tools/reporter/config-default.inc.php @@ -47,6 +47,13 @@ $config['debug'] = false; // Service Active $config['service_active'] = true; // true=on | false=off +// Screenshot Formats +$config['screenshot_imageTypes'] = array('png' => 'image/png', + 'jpg' => 'image/jpeg'); + +// Turn on WSDL?? +$config['use_wsdl'] = false; + // Paths $config['base_url'] = 'http://reporter.server.tld'; // no trailing slash $config['base_path'] = '/path/to/reporter'; // no trailing slash diff --git a/tools/reporter/htdocs/.htaccess b/tools/reporter/htdocs/.htaccess index bea8cf5ea50..4e98fdc23e8 100644 --- a/tools/reporter/htdocs/.htaccess +++ b/tools/reporter/htdocs/.htaccess @@ -2,6 +2,7 @@ RewriteEngine On RewriteRule ^app/query(/)?(.*)$ query.php$1 [QSA,L] +RewriteRule ^app/report/screenshot(/)?(.*)$ screenshot.php$1 [QSA,L] RewriteRule ^app/report(/)?(.*)$ report.php$1 [QSA,L] RewriteRule ^app/stats(/)?(.*)$ stats.php$1 [QSA,L] RewriteRule ^app/login(/)?(.*)$ login.php$1 [QSA,L] diff --git a/tools/reporter/htdocs/img/theme/mozilla/header_logo.gif b/tools/reporter/htdocs/img/theme/mozilla/header_logo.gif index e00acf1e56e469bd4ace5dff5efef204bf8ea24a..dc076370430bf86e6ea75556b6ce80dc0da86f9f 100644 GIT binary patch literal 3566 zcmW-gdsLDMx5i%)1-U31nHMxfyknYCnNkCYib{o-98;$8mZe#tpE=f0DWajGp`kX$ zG-zaM)F6@dHRKqPnW2Y_DN}UJu*}Fqj&+(oP9Ep{vG-d0S$pmEd-h&CHZCT7TNczR z0{9;Q0E56hE{~@+ps6frr_?ZOq)~afof8Pc7K?hcgi;w}SFU#0VEPBiqEzS$3rfi}u6X<^y)$+G;#Qg}ij>(dkC zS)6_Y21it>wJFs~?K6X*NhDKfc(o$5Gp4YVqn|K{FN%$;Y@aNI4J2ugijgG9%@d`h zu3953f3#Yo@wG8mp(iz{lzmEZkA@h=Ks({J&y0cwF=7L)uuZl6X<0R_XYFH^ zoDh>*H270W*1i()MHwSqB{Dq+wfbq3xKoyrl&cvvm=;Y4PlED} z9`8%k46Xu*4ATbLbyZ=3NIGWJjOuA^8eTO|GpG?X2&A1#(hd?WCT01P#k9E0YY-V< zo6yd9&MAScQ)-+wnwFOJV|t}RDelw|x6p_MQqvcUN^LMMnDo;|)g6_rM`m2Ia8B`L z*Off3NU2!$f)@8^i8~mUFBUwGsDEYRYKPUvWDdC_s^ib#+P0!PZ!Gj?`>5Q`8U?Ed3wYLKf;3NH`0 zb7CJi|0}aRwd}!(lbYea!@I$|j_v6&Q!2gv$hM7N<__q3;wvPFGv@l_SuN>S1MW7G zrtLx5k(4`)arY%#F7PV0(E_b|*D0Xj@}k?yd_nWG25M+4rgg`z2)kt5eEH8?f_U3{ zw?Labkim@ZoY;YfZ(j|$H$=eq%Jx%(Om6c)TwJHM+8GtWyaJco-7^-gTza@`0KwTN54+yXf{01HgL<(E@v3e@$nWDY7>IxFqoERQ;C_a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I;F>a;B( z{06*P1WM@y2C*@Z2XznF=dms+n^UG)lEKVvY+vZgkFh3i0Bv|v#H~%2G0>_!@SW?+@W$l8h#&N>Uz|2eZX=b~MP=bq zuFJ&?V6{@<7&f$wa!Ib1H{pTL>^8t44{%5#m=uXorD^O~LJLSeWcJ}M602BW9~RBJkH#YURZ{r}`P zD&%2LA2pH4B=&x+ZuZ4y<#60*5i}3q27FR{@@c*kv4=zI;E@1~APArezk%y<1E2ZW zY$LjF9`3f(5aUKvSS!Ngkak3;=ZU?}XQ#=eSrB|KSlXOCZkGp@H_HFLcU} zjLy0`SetFetchMode(ADODB_FETCH_ASSOC); -$query =& $db->Execute("SELECT * - FROM report, host - WHERE report.report_id = ".$db->quote($_GET['report_id'])." - AND host.host_id = report_host_id"); +$reportQuery =& $db->Execute("SELECT * + FROM report, host + WHERE report.report_id = ".$db->quote($_GET['report_id'])." + AND host.host_id = report_host_id"); +if(!$reportQuery){ + die("DB Error"); +} + +// Init to false +$screenshot = false; + +// Only check for a screenshot if the user is an admin, and if we have a valid report +if($reportQuery->RecordCount() == 1 && $securitylib->isLoggedIn()){ + $screenshotQuery =& $db->Execute("SELECT screenshot.screenshot_report_id + FROM screenshot + WHERE screenshot.screenshot_report_id = ".$db->quote($_GET['report_id']) + ); + if(!$screenshotQuery){ + die("DB Error"); + } + if($screenshotQuery->RecordCount() == 1){ + $screenshot = true; + } +} // disconnect database $db->Close(); $content = initializeTemplate(); -if (!$query->fields){ +if (!$reportQuery->fields){ $content->assign('error', 'No Report Found'); displayPage($content, 'report', 'report.tpl', 'Mozilla Reporter - Error'); exit; } -$title = "Report for ".$query->fields['host_hostname']." - ".$query->fields['report_id']; -$content->assign('report_id', $query->fields['report_id']); -$content->assign('report_url', $query->fields['report_url']); -$content->assign('host_url', $config['base_url'].'/app/query/?host_hostname='.$query->fields['host_hostname'].'&submit_query=Query'); -$content->assign('host_hostname', $query->fields['host_hostname']); -$content->assign('report_problem_type', resolveProblemTypes($query->fields['report_problem_type'])); -$content->assign('report_behind_login', resolveBehindLogin($query->fields['report_behind_login'])); -$content->assign('report_product', $query->fields['report_product']); -$content->assign('report_gecko', $query->fields['report_gecko']); -$content->assign('report_useragent', $query->fields['report_useragent']); -$content->assign('report_buildconfig', $query->fields['report_buildconfig']); -$content->assign('report_platform', $query->fields['report_platform']); -$content->assign('report_oscpu', $query->fields['report_oscpu']); -$content->assign('report_language', $query->fields['report_language']); -$content->assign('report_file_date', $query->fields['report_file_date']); -$content->assign('report_email', $query->fields['report_email']); -$content->assign('report_ip', $query->fields['report_ip']); -$content->assign('report_description', $query->fields['report_description']); +$title = "Report for ".$reportQuery->fields['host_hostname']." - ".$reportQuery->fields['report_id']; +$content->assign('report_id', $reportQuery->fields['report_id']); +$content->assign('report_url', $reportQuery->fields['report_url']); +$content->assign('host_url', $config['base_url'].'/app/query/?host_hostname='.$reportQuery->fields['host_hostname'].'&submit_query=Query'); +$content->assign('host_hostname', $reportQuery->fields['host_hostname']); +$content->assign('report_problem_type', resolveProblemTypes($reportQuery->fields['report_problem_type'])); +$content->assign('report_behind_login', resolveBehindLogin($reportQuery->fields['report_behind_login'])); +$content->assign('report_product', $reportQuery->fields['report_product']); +$content->assign('report_gecko', $reportQuery->fields['report_gecko']); +$content->assign('report_useragent', $reportQuery->fields['report_useragent']); +$content->assign('report_buildconfig', $reportQuery->fields['report_buildconfig']); +$content->assign('report_platform', $reportQuery->fields['report_platform']); +$content->assign('report_oscpu', $reportQuery->fields['report_oscpu']); +$content->assign('report_language', $reportQuery->fields['report_language']); +$content->assign('report_file_date', $reportQuery->fields['report_file_date']); +$content->assign('report_email', $reportQuery->fields['report_email']); +$content->assign('report_ip', $reportQuery->fields['report_ip']); +$content->assign('report_description', $reportQuery->fields['report_description']); + +if($screenshot){ + $content->assign('screenshot', $screenshot); +} // Last/Next Functionality if(isset($_SESSION['reportList'])){ diff --git a/tools/reporter/htdocs/screenshot.php b/tools/reporter/htdocs/screenshot.php new file mode 100644 index 00000000000..7a8d2d72124 --- /dev/null +++ b/tools/reporter/htdocs/screenshot.php @@ -0,0 +1,49 @@ +isLoggedIn() === true){ + $db = NewDBConnection($config['db_dsn']); + $db->SetFetchMode(ADODB_FETCH_ASSOC); + + $query = $db->Execute("SELECT screenshot_data, screenshot.screenshot_format + FROM screenshot + WHERE screenshot_report_id = ".$db->quote($_GET['report_id'])); + if(!$query){ + exit; + } + + // Output the MIME header + $imageExtension = array_search($query->fields['screenshot_format'], $config['screenshot_imageTypes']); + + // This should never happen, but we test for it regardless + if($imageExtension === false){ + // XXX -> we should redirect to an error image or someting to that effect as + // in most cases, nobody would even see this error. + print "Invalid Image"; + } + + // Headers + header("Content-Type: ".$query->fields['screenshot_format']); + header("Content-disposition: inline; filename=".$_GET['report_id'].".".$imageExtension); + + // Output the image + echo $query->fields['screenshot_data']; +} else { + // XXX -> we should redirect to an error image or someting to that effect as + // in most cases, nobody would even see this error. + print "You are not authorized to view this"; +} +?> \ No newline at end of file diff --git a/tools/reporter/htdocs/service.php b/tools/reporter/htdocs/service.php index a37729736aa..36146b569a4 100644 --- a/tools/reporter/htdocs/service.php +++ b/tools/reporter/htdocs/service.php @@ -38,15 +38,28 @@ require_once('../config.inc.php'); require_once($config['base_path'].'/includes/iolib.inc.php'); -require_once($config['base_path'].'/includes/contrib/adodb/adodb.inc.php'); +require_once($config['base_path'].'/includes/db.inc.php'); require_once($config['base_path'].'/includes/contrib/nusoap/lib/nusoap.php'); // Turn off Error Reporting because it breaks xml formatting and causes errors error_reporting(0); +if($config['debug']){ + $debug = 1; +} + // Create the server instance $server = new soap_server; +// UTF-8 support is good +$server->soap_defencoding = "UTF-8"; +$server->decode_utf8 = false; + +// WSDL Support +if($config['use_wsdl']){ + $server->configureWSDL('reporterwsdl', 'urn:reporterwsdl'); +} + // Register the method to expose // Note: with NuSOAP 0.6.3, only method name is used w/o WSDL $server->register( @@ -74,20 +87,28 @@ $server->register( 'buildconfig' => 'xsd:string', 'language' => 'xsd:string', 'email' => 'xsd:string', - 'sysid' => 'xsd:string'), // input parameters - array('return' => 'xsd:string'), // output parameters - 'uri:MozillaReporter', // namespace - 'uri:MozillaReporter/submitReport', // SOAPAction - 'rpc', // style - 'encoded' // use + 'sysid' => 'xsd:string', + 'screenshot' => 'xsd:base64Binary', + 'screenshot_format' => 'xsd:string'), // input parameters + array('return' => 'xsd:string'), // output parameters + 'uri:MozillaReporter', // namespace + 'uri:MozillaReporter/submitReport', // SOAPAction + 'rpc', // style + 'encoded' // use ); -function submitReport($rmoVers, $url, $problem_type, $description, $behind_login, $platform, $oscpu, $gecko, $product, $useragent, $buildconfig, $language, $email, $sysid) { - global $config; +function submitReport($rmoVers, $url, $problem_type, $description, $behind_login, + $platform, $oscpu, $gecko, $product, $useragent, $buildconfig, + $language, $email, $sysid, $screenshot, $screenshot_format) { + global $config; + if ($config['service_active'] == false){ return new soap_fault('SERVER', '', 'The service is currently unavailable. Please try again in a few minutes.'); } + /********** + * Sanitize and Validate + **********/ // Remove any HTML tags and whitespace $rmoVers = trim(strip_all_tags($rmoVers)); $url = trim(strip_all_tags($url)); @@ -103,14 +124,17 @@ function submitReport($rmoVers, $url, $problem_type, $description, $behind_login $language = trim(strip_all_tags($language)); $email = trim(strip_all_tags($email)); $sysid = trim(strip_all_tags($sysid)); + $screenshot_format = trim(strip_all_tags($screenshot_format)); + $screenshot_width = trim(strip_all_tags($screenshot_width)); + $screenshot_height = trim(strip_all_tags($screenshot_height)); // check verison if ($rmoVers < $config['min_vers']){ return new soap_fault('Client', '', 'Your product is out of date, please upgrade. See http://reporter.mozilla.org/install for details.', $rmoVers); } - $parsedURL = parse_url($url); - if (!$url || !$parsedURL['host']){ + $parsedUrl = parse_url($url); + if (!$url || !$parsedUrl['host']){ return new soap_fault('Client', '', 'url must use a valid URL syntax http://mozilla.com/page', $url); } if (!$problem_type || $problem_type == -1 || $problem_type == "0") { @@ -127,10 +151,11 @@ function submitReport($rmoVers, $url, $problem_type, $description, $behind_login if (!$language) { return new soap_fault('Client', '', 'Invalid Localization', $language); } -/* not used until we have a way to gather this info + /* We don't explicity require this since some older clients may not return this. if (!$gecko) { return new soap_fault('Client', '', 'Invalid Gecko ID', $gecko); - }*/ + } + */ if (!$oscpu) { return new soap_fault('Client', '', 'Invalid OS CPU', $oscpu); } @@ -140,73 +165,108 @@ function submitReport($rmoVers, $url, $problem_type, $description, $behind_login if (!$buildconfig) { return new soap_fault('Client', '', 'Invalid Build Config', $buildconfig); } - if (!$sysid) { return new soap_fault('Client', '', 'No SysID Entered', $sysid); } - /* we don't require email... it's optional + /* We don't require email... it's optional if (!$email) { return new soap_fault('Client', '', 'Invalid Email', $email); - }*/ + } + */ + + // Image Validation + if($screenshot != null) { + // If no format specified, it's invalid + if($screenshot_format == null) { + return new soap_fault('Client', '', 'Invalid Screenshot', $screenshot_format); + } + // Must be in our list of approved formats. + if(!in_array($screenshot_format, $config['screenshot_imageTypes'])){ + return new soap_fault('Client', '', 'Invalid Screenshot Format', $screenshot_format); + } + } // create report_id. We just MD5 it, becase we don't need people counting reports, since it's inaccurate. // we can have dup's, so it's not a good thing for people to be saying 'mozilla.org reports 500,000 incompatable sites' $report_id = 'RMO'.str_replace(".", "", array_sum(explode(' ', microtime()))); - // Open DB - $db = NewADOConnection($config['db_dsn']); - if (!$db) die("Connection failed"); + /********** + * Open DB + **********/ + $db = NewDBConnection($config['db_dsn']); $db->SetFetchMode(ADODB_FETCH_ASSOC); - $sysIDQuery = $db->Execute("SELECT `sysid_id` FROM `sysid` WHERE `sysid_id` = ".$db->quote($sysid)); - $sysidCount = $sysIDQuery->RecordCount(); - if ($sysidCount != 1){ - return new soap_fault('Client', '', 'Invalid SysID', $sysid); + /********** + * Check for valid sysid + **********/ + $sysIdQuery = $db->Execute("SELECT sysid.sysid_id + FROM sysid + WHERE sysid.sysid_id = ".$db->quote($sysid)); + if(!$sysIdQuery){ + return new soap_fault('SERVER', '', 'Database Error SR1'); } - $queryURL = $db->Execute("SELECT `host_id` FROM `host` WHERE `host_hostname` = ".$db->quote($parsedURL['host'])); - $resultURL = $queryURL->RecordCount(); - if ($resultURL <= 0) { + if ($sysIdQuery->RecordCount() != 1){ + return new soap_fault('Client', '', 'Invalid SysID', $sysid); + } + + /********** + * Check Hostname + **********/ + $hostnameQuery = $db->Execute("SELECT host.host_id + FROM host + WHERE host.host_hostname = ".$db->quote($parsedUrl['host'])); + if(!$hostnameQuery){ + return new soap_fault('SERVER', '', 'Database Error SR2'); + } + + /********** + * Add Host + **********/ + if ($hostnameQuery->RecordCount() <= 0) { // generate hash - $host_id = md5($parsedURL['host'].microtime()); + $host_id = md5($parsedUrl['host'].microtime()); // We add the URL - $addURL = $db->Execute("INSERT INTO `host` (`host_id`, `host_hostname`, `host_date_added`) - VALUES ( - ".$db->quote($host_id).", - ".$db->quote($parsedURL['host']).", - now() - ) - "); - if (!$addURL) { - return new soap_fault('SERVER', '', 'Database Error'); + $addUrlQuery = $db->Execute("INSERT INTO host (host.host_id, host.host_hostname, host.host_date_added) + VALUES ( + ".$db->quote($host_id).", + ".$db->quote($parsedUrl['host']).", + now() + )"); + if (!$addUrlQuery) { + return new soap_fault('SERVER', '', 'Database Error SR3'); } } - else if ($resultURL == 1) { + else if ($hostnameQuery->RecordCount() == 1) { // pull the hash from DB - $host_id = $queryURL->fields['host_id']; + $host_id = $hostnameQuery->fields['host_id']; } else{ - return new soap_fault('SERVER', '', 'Host Exception Error'); + return new soap_fault('SERVER', '', 'Host Exception Error'); } - $addReport = $db->Execute("INSERT INTO `report` ( - `report_id`, - `report_url`, - `report_host_id`, - `report_problem_type`, - `report_description`, - `report_behind_login`, - `report_useragent`, - `report_platform`, - `report_oscpu`, - `report_language`, - `report_gecko`, - `report_buildconfig`, - `report_product`, - `report_email`, - `report_ip`, - `report_file_date`, - `report_sysid` - ) - VALUES ( + + /********** + * Add Report + **********/ + $addReportQuery = $db->Execute("INSERT INTO report ( + report.report_id, + report.report_url, + report.report_host_id, + report.report_problem_type, + report.report_description, + report.report_behind_login, + report.report_useragent, + report.report_platform, + report.report_oscpu, + report.report_language, + report.report_gecko, + report.report_buildconfig, + report.report_product, + report.report_email, + report.report_ip, + report.report_file_date, + report.report_sysid + ) + VALUES ( ".$db->quote($report_id).", ".$db->quote($url).", ".$db->quote($host_id).", @@ -224,25 +284,57 @@ function submitReport($rmoVers, $url, $problem_type, $description, $behind_login ".$db->quote($_SERVER['REMOTE_ADDR']).", now(), ".$db->quote($sysid)." - ) - "); - - if (!$addReport) { - return new soap_fault('SERVER', '', 'Database Error'); - } else { - return $report_id; + );"); + if (!$addReportQuery) { + return new soap_fault('SERVER', '', 'Database Error SR4'); } + + /********** + * Process Screenshot + **********/ + if($screenshot != null){ + + // Screenshots come in base64 encoded, so we need to decode. + $screenshot = base64_decode($screenshot); + + // Note we addslashes() not quote() the image, because quote() is not + // binary compatible and has ugly consequences. + $insertSsQuery = $db->Execute("INSERT screenshot( + screenshot.screenshot_report_id, + screenshot.screenshot_data, + screenshot.screenshot_format + ) + VALUES (".$db->quote($report_id).", + '".addslashes($screenshot)."', + ".$db->quote($screenshot_format)." + ); + "); + if(!$insertSsQuery){ + return new soap_fault('SERVER', '', 'Database Error SR5'); + } + // If we got this far, the screenshot was successfully added! + } + + /********** + * Disconnect (optional really) + **********/ + $db->disconnect(); + + return $report_id; } function register($language){ global $config; - // Open DB - $db = NewADOConnection($config['db_dsn']); - if (!$db) die("Connection failed"); + /********** + * Open DB + **********/ + $db = NewDBConnection($config['db_dsn']); $db->SetFetchMode(ADODB_FETCH_ASSOC); - // generate an ID + /********** + * Generate an ID + **********/ $unique = false; // in theory a collision could happen, though unlikely. So just to make sure, we do this @@ -250,41 +342,49 @@ function register($language){ while (!$unique) { $id = date("ymd").rand(1000,9999); - $query =& $db->Execute("SELECT sysid.sysid_id + $uniqueQuery =& $db->Execute("SELECT sysid.sysid_id FROM sysid - WHERE sysid.sysid_id = '$newid' + WHERE sysid.sysid_id = '$id' "); - $numRows = $query->RecordCount(); + if(!$uniqueQuery){ + return new soap_fault('SERVER', '', 'Database Error R1'); + } + $numRows = $uniqueQuery->RecordCount(); if ($numRows == 0) { // It's unique, stop the loop. $unique = true; } } - $addsysid = $db->Execute("INSERT INTO `sysid` ( - `sysid_id`, - `sysid_created`, - `sysid_created_ip`, - `sysid_language` - ) - VALUES ( - '".$id."', - now(), - '".$_SERVER['REMOTE_ADDR']."', - ".$db->quote($language)." - ) - "); - // Disconnect Database + /********** + * Register ID + **********/ + $addSysIdQuery = $db->Execute("INSERT INTO sysid ( + sysid.sysid_id, + sysid.sysid_created, + sysid.sysid_created_ip, + sysid.sysid_language + ) + VALUES ( + '".$id."', + now(), + '".$_SERVER['REMOTE_ADDR']."', + ".$db->quote($language)." + )"); + if (!$addSysIdQuery) { + return new soap_fault('SERVER', '', 'Database Error R2'); + } + + /********** + * Disconnect + **********/ $db->disconnect(); - if (!$addsysid) { - return new soap_fault('SERVER', '', 'Database Error'); - } else { - return $id; - } + return $id; } // Use the request to (try to) invoke the service $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : ''; $server->service($HTTP_RAW_POST_DATA); + ?> diff --git a/tools/reporter/htdocs/styles/theme/mozilla/reporter.css b/tools/reporter/htdocs/styles/theme/mozilla/reporter.css index 66ea09a9dcf..719c5a857b0 100644 --- a/tools/reporter/htdocs/styles/theme/mozilla/reporter.css +++ b/tools/reporter/htdocs/styles/theme/mozilla/reporter.css @@ -136,3 +136,18 @@ body { width: 45%; padding: 2px 9px 5px 9px; } + + +#report_tabs li { + list-style-type: none; + border: 1px solid red; +} + +#report_data, #report_screenshot{ +/* float: right; */ + margin-left: 110px; +} + +#report_screenshot { + text-align: center; +} \ No newline at end of file diff --git a/tools/reporter/sql/schema.sql b/tools/reporter/sql/schema.sql index f0b4dfe82e4..95782e53315 100644 --- a/tools/reporter/sql/schema.sql +++ b/tools/reporter/sql/schema.sql @@ -1,14 +1,20 @@ --- +-- phpMyAdmin SQL Dump +-- version 2.7.0-pl1 +-- http://www.phpmyadmin.net +-- +-- Host: localhost +-- Generation Time: Jan 25, 2006 at 10:07 PM +-- Server version: 4.1.15 +-- PHP Version: 4.4.1 +-- -- Database: `reporter` --- -CREATE DATABASE `reporter`; -USE reporter; +-- -- -------------------------------------------------------- --- +-- -- Table structure for table `host` --- +-- CREATE TABLE `host` ( `host_id` varchar(32) NOT NULL default '', @@ -21,17 +27,6 @@ CREATE TABLE `host` ( -- -------------------------------------------------------- --- --- Table structure for table `product` --- - -CREATE TABLE `product` ( - `product_id` varchar(150) NOT NULL default '', - `product_description` varchar(150) NOT NULL default '' -) TYPE=MyISAM; - --- -------------------------------------------------------- - -- -- Table structure for table `report` -- @@ -41,7 +36,7 @@ CREATE TABLE `report` ( `report_url` varchar(255) NOT NULL default '', `report_host_id` varchar(32) NOT NULL default '', `report_problem_type` varchar(5) NOT NULL default '0', - `report_description` tinytext NOT NULL, + `report_description` text NOT NULL, `report_behind_login` int(11) NOT NULL default '0', `report_useragent` varchar(255) NOT NULL default '', `report_platform` varchar(20) NOT NULL default '', @@ -60,15 +55,28 @@ CREATE TABLE `report` ( -- -------------------------------------------------------- +-- +-- Table structure for table `screenshot` +-- + +CREATE TABLE `screenshot` ( + `screenshot_report_id` varchar(17) NOT NULL default '', + `screenshot_data` longblob NOT NULL, + `screenshot_format` varchar(14) NOT NULL default 'png', + PRIMARY KEY (`screenshot_report_id`) +) TYPE=MyISAM; + +-- -------------------------------------------------------- + -- -- Table structure for table `sysid` --- +-- CREATE TABLE `sysid` ( - `sysid_id` varchar(10) binary NOT NULL default '', + `sysid_id` varchar(10) NOT NULL default '', `sysid_created` datetime NOT NULL default '0000-00-00 00:00:00', - `sysid_created_ip` varchar(15) binary NOT NULL default '', - `sysid_language` varchar(7) binary NOT NULL default '', + `sysid_created_ip` varchar(15) NOT NULL default '', + `sysid_language` varchar(7) NOT NULL default '', PRIMARY KEY (`sysid_id`) ) TYPE=MyISAM; @@ -79,10 +87,10 @@ CREATE TABLE `sysid` ( -- CREATE TABLE `user` ( - `user_id` int(11) NOT NULL default '0', + `user_id` int(11) NOT NULL, `user_username` varchar(50) NOT NULL default '', - `user_password` varchar(40) NOT NULL default '', - `user_realname` varchar(25) NOT NULL default '', + `user_password` varchar(16) NOT NULL default '', + `user_realname` varchar(40) NOT NULL default '', `user_email` varchar(255) NOT NULL default '', `user_added_by` tinytext NOT NULL, `user_added_datetime` datetime NOT NULL default '0000-00-00 00:00:00', @@ -90,6 +98,5 @@ CREATE TABLE `user` ( `user_last_ip_address` varchar(16) NOT NULL default '', `user_status` int(11) NOT NULL default '0', PRIMARY KEY (`user_id`), - KEY `user_password` (`user_password`), - KEY `user_id` (`user_id`) + KEY `user_username` (`user_username`) ) TYPE=MyISAM; diff --git a/tools/reporter/templates/index.tpl b/tools/reporter/templates/index.tpl index d35f1567e48..97068727360 100644 --- a/tools/reporter/templates/index.tpl +++ b/tools/reporter/templates/index.tpl @@ -91,7 +91,7 @@ -
+
{html_radios name="report_problem_type" options=$problem_types selected=$report_problem_type separator="
"} @@ -99,8 +99,8 @@ Site requires login: - - + + diff --git a/tools/reporter/templates/mozilla/layout.tpl b/tools/reporter/templates/mozilla/layout.tpl index bd7442515dc..d1da1c6a3b6 100644 --- a/tools/reporter/templates/mozilla/layout.tpl +++ b/tools/reporter/templates/mozilla/layout.tpl @@ -1,7 +1,7 @@ - + diff --git a/tools/reporter/templates/report.tpl b/tools/reporter/templates/report.tpl index ad2ad670bf6..fb94b6ecbbd 100644 --- a/tools/reporter/templates/report.tpl +++ b/tools/reporter/templates/report.tpl @@ -1,68 +1,117 @@ +{if $screenshot == true} +{literal} + +{/literal} +{/if} + +{literal} + +{/literal} + {if $error != ''} -
-

Error

-

{$error}. Back

-
+
+

Error

+

{$error}. Back

+
{else}
-
Report RMO11301752363661
- - -
-
Problem Type:
-
{$report_problem_type}
-
-
-
Behind Login:
-
{$report_behind_login}
-
-
-
Product:
-
{$report_product}
-
-
-
Gecko Version:
-
{$report_gecko}
-
-
-
Platform:
-
{$report_platform}
-
-
-
OS/CPU:
-
{$report_oscpu}
-
-
-
Language:
-
{$report_language}
-
-
-
User Agent:
-
{$report_useragent}
-
-
-
Build Config:
-
{$report_buildconfig}
-
-{if $is_admin == true} -
-
Email:
-
{$report_email}  {*this space at the end fixes some formatting issues with no text in this optional field *}
-
-
-
IP Address:
-
{$report_ip}  {*this space at the end fixes some formatting issues with no text in this optional field *}
-
-{/if} -
-
Description:
-
{$report_description}  {*this space at the end fixes some formatting issues with no text in this optional field *}
+
Report RMO11301752363661
+ +
+ + +
+
Problem Type:
+
{$report_problem_type}
+
+
+
Behind Login:
+
{$report_behind_login}
+
+
+
Product:
+
{$report_product}
+
+
+
Gecko Version:
+
{$report_gecko}
+
+
+
Platform:
+
{$report_platform}
+
+
+
OS/CPU:
+
{$report_oscpu}
+
+
+
Language:
+
{$report_language}
+
+
+
User Agent:
+
{$report_useragent}
+
+
+
Build Config:
+
{$report_buildconfig}
+
+ {if $is_admin == true} +
+
Email:
+
{$report_email}  {*this space at the end fixes some formatting issues with no text in this optional field *}
+
+
+
IP Address:
+
{$report_ip}  {*this space at the end fixes some formatting issues with no text in this optional field *}
+
+ {/if} +
+
Description:
+
{$report_description}  {*this space at the end fixes some formatting issues with no text in this optional field *}
+
+
+ {if $screenshot == true} + + {/if} +
+ +

@@ -113,9 +162,10 @@ {/if} {/strip} - {/if} | + + {/if} Back To List | @@ -123,4 +173,3 @@

{/if} -