com web/qa: Publish PFTT Reports: build.php list_builds.php pftt.php pftt_report.php
| From: | Matt Ficken | Date: | Thu, 20 Mar 2014 07:29:55 +0000 |
| Subject: | com web/qa: Publish PFTT Reports: build.php list_builds.php pftt.php pftt_report.php | ||
| Groups: | php.qa | ||
| Request: | Send a blank email to php-qa+get-67246@lists.php.net to get a copy of this message | ||
Commit: 08df867a88572e8703c28867d03f87ad55a6aa52
Author: v-mafick@microsoft.com <v-mafick@microsoft.com> Thu, 20 Mar 2014 00:29:55
-0700
Parents: 816a7ce7721eca4747c68bca69f43b0700a4b3ae
Branches: master
Link: http://git.php.net/?p=web/qa.git;a=commitdiff;h=08df867a88572e8703c28867d03f87ad55a6aa52
Log:
Publish PFTT Reports
Changed paths:
A build.php
A list_builds.php
A pftt.php
A pftt_report.php
diff --git a/build.php b/build.php new file mode 100755 index 0000000..515d174 --- /dev/null +++ b/build.php @@ -0,0 +1,105 @@ +<?php + +define('BASE_REPORT_DIR', dirname($_SERVER['SCRIPT_FILENAME'])."/pftt-reports/"); + +$branch = $_GET['branch']; +$revision = $_GET['revision']; +if (substr($branch, 0, 3)!='PHP') { + $branch = "PHP_5_6"; +} +if (substr($revision, 0, 1)!='r') { + $revision = ""; +} + + +include("include/functions.php"); + +$TITLE = "PHP: QA: PFTT: $branch: $revision"; +$SITE_UPDATE = date("D M d H:i:s Y T", filectime(__FILE__)); +/* $Id$ */ + +common_header(); + + + +?> +<h1><a href="list_builds.php?branch=<?php echo $branch; ?>"><?php echo $branch; ?></a> <?php echo $revision; ?></h1> + +<h2>Summary</h2> + +<table> + <tr> + <td><?php echo $branch; ?> <?php echo $revision; ?> <?php echo $build_type; ?> <?php echo $cpu; ?></td> + </tr> +</table> + +<br/> + +<h2>Comparison Reports</h2> + +<table> + <tr> + <td><strong>PHPT</strong> <a href="howto_phpt.htm" target="_blank">How to</a></td> + </tr> + <?php + +foreach ( scandir(BASE_REPORT_DIR."/$branch/$revision") as $report ) { + if (substr($report, 0, 4)=="PHPT" && is_file(BASE_REPORT_DIR."/$branch/$revision/$report")) { + + ?> + <tr> + <td>with <a href="<?php echo dirname($_SERVER['PHP_SELF']); ?>/pftt-reports/<?php echo $branch; ?>/<?php echo $revision; ?>/<?php echo $report; ?>" target="_blank"><?php echo $report; ?></a></td> + </tr> + <?php + + } // end if +} + + ?> +</table> +<br/> +<table> + <tr> + <td><strong>PhpUnit</strong> <a href="howto_phpunit.htm" target="_blank">How to</a></td> + </tr> + <?php + +foreach ( scandir(BASE_REPORT_DIR."/$branch/$revision") as $report ) { + if (substr($report, 0, 7)=="PhpUnit" && is_file(BASE_REPORT_DIR."/$branch/$revision/$report")) { + + ?> + <tr> + <td>with <a href="<?php echo dirname($_SERVER['PHP_SELF']); ?>/pftt-reports/<?php echo $branch; ?>/<?php echo $revision; ?>/<?php echo $report; ?>" target="_blank"><?php echo $report; ?></a></td> + </tr> + <?php + + } // end if +} + +?> +</table> +<br/> +<h2>Abbreviations</h2> +<p><b>NTS</b> - Non-Thread Safe build, use for CLI or IIS (PHP on Windows uses 2 types of builds, TS and NTS)</p> +<p><b>TS</b> - Thread Safe build, use for CLI or Apache mod_php on Windows</p> +<p><b>VC11</b> - Build compiled using VC11 (Visual Studio 2012)</p> +<p><b>VC9</b> - Build compiled using VC9 (Visual Studio 2008)</p> +<p><b>GCC</b> - Build compiled using GCC</p> +<br/> +<h2>Common Scenario Sets</h2> +<p><b>Local-FileSystem_MySQL_Apache-ModPHP-ApacheLounge-2.4.4-VC9-OpenSS</b> - Tests run on local file system, using Apache with MySQL</p> +<p><b>Local-FileSystem_MySQL_CLI</b> - Tests run on local file system on CLI with MySQL</p> +<p><b>Opcache_Local-FileSystem_MySQL_Apache-ModPHP-ApacheLounge-2</b> - Tests run on local file system, using Apache with Opcache, MySQL</p> +<p><b>Opcache_Local-FileSystem_MySQL_CLI</b> - Tests run on local file system on CLI with MySQL</p> +<p><b>Opcache_Local-FileSystem_MySQL_CLI_WinCacheU</b> - Tests run on local file system on CLI with Opcache, MySQL and WinCache (user & file caches)</p> +<p><b>SMB-DFS_MySQL_Apache-ModPHP-ApacheLounge-2.4.4-VC9-OpenSS</b> - Tests run on remote DFS file system, using Apache with MySQL</p> +<p><b>SMB-DFS_MySQL_CLI</b> - Tests run on remote DFS file system on CLI with MySQL</p> +<p><b>Opcache_SMB-DFS_MySQL_Apache-ModPHP-ApacheLounge-2</b> - Tests run on remote DFS file system, using Apache with Opcache, MySQL</p> +<p><b>Opcache_SMB-DFS_MySQL_CLI</b> - Tests run on remote DFS file system on CLI with MySQL</p> +<p><b>Opcache_SMB-DFS_MySQL_CLI_WinCacheU</b> - Tests run on remote DFS file system on CLI with Opcache, MySQL and WinCache (user & file caches)</p> + +<?php + +common_footer(); + +?> \ No newline at end of file diff --git a/list_builds.php b/list_builds.php new file mode 100755 index 0000000..f091d0a --- /dev/null +++ b/list_builds.php @@ -0,0 +1,78 @@ +<?php + +define('BASE_REPORT_DIR', dirname($_SERVER['SCRIPT_FILENAME'])."/pftt-reports/"); + +$branch = $_GET['branch']; +if (substr($branch, 0, 3)!='PHP') { + $branch = "PHP_5_6"; +} + + +include("include/functions.php"); + +$TITLE = "PHP: QA: PFTT: $branch"; +$SITE_UPDATE = date("D M d H:i:s Y T", filectime(__FILE__)); +/* $Id$ */ + +common_header(); + + +?> +<h1><a href="pftt.php"><?php echo $branch; ?></a></h1> + +<p>Choose a PHP revision or build</p> +<?php + +$latest_revision = ''; +$mtime = 0; + +foreach ( scandir(BASE_REPORT_DIR."/$branch") as $revision ) { + if ($revision=="." or $revision=="..") + continue; + if (is_dir(BASE_REPORT_DIR."/$branch/$revision")) { + $mtime = stat(BASE_REPORT_DIR."/$branch/$revision")[9]; + if ($mtime > $latest_revision_mtime) { + $latest_revision = $revision; + $latest_revision_mtime = $mtime; + } + } +} + +?> +<table> + <tr> + <td>Latest:</td> + <td><a href="build.php?branch=<?php echo $branch; ?>&revision=<?php echo $revision; ?>"><?php echo $latest_revision; ?></a></td> + </tr> +<?php /* <tr> + <td>New Failures:</td> + <td>New Crashes:</td> + </tr> */ ?> +</table> +<br/> +<table> + <?php + +foreach ( scandir(BASE_REPORT_DIR."/$branch") as $revision ) { + if ($revision=="." or $revision=="..") + continue; + if (is_dir(BASE_REPORT_DIR."/$branch/$revision")) { + + + ?> + <tr> + <td><a href="build.php?branch=<?php echo $branch; ?>&revision=<?php echo $revision; ?>"><?php echo $revision; ?></a></td> + </tr> + <?php + + } // end if +} + + + ?> +</table> +<?php + +common_footer(); + +?> \ No newline at end of file diff --git a/pftt.php b/pftt.php new file mode 100755 index 0000000..cef7cef --- /dev/null +++ b/pftt.php @@ -0,0 +1,60 @@ +<?php + +include("include/functions.php"); + +$TITLE = "PHP: QA: PFTT"; +$SITE_UPDATE = date("D M d H:i:s Y T", filectime(__FILE__)); +/* $Id$ */ + +common_header(); + +define('BASE_REPORT_DIR', dirname($_SERVER['SCRIPT_FILENAME'])."/pftt-reports/"); + +?> +<h1>PFTT</h1> + +<p>Choose a PHP Branch</p> + +<?php + +foreach ( scandir(BASE_REPORT_DIR) as $branch ) { + if ($branch=="." or $branch=="..") + continue; + if (is_dir(BASE_REPORT_DIR."/$branch")) { + $latest_revision = ''; + $mtime = 0; + + foreach ( scandir(BASE_REPORT_DIR."/$branch") as $revision ) { + if ($revision=="." or $revision=="..") + continue; + if (is_dir(BASE_REPORT_DIR."/$branch/$revision")) { + $mtime = stat(BASE_REPORT_DIR."/$branch/$revision")[9]; + if ($mtime > $latest_revision_mtime) { + $latest_revision = $revision; + $latest_revision_mtime = $mtime; + } + } + } + +?> +<table> + <tr> + <td colspan="2"><a href="list_builds.php?branch=<?php echo $branch; ?>"><?php echo $branch; ?></a></td> + <td>Latest:</td> + <td><a href="build.php?branch=<?php echo $branch; ?>&revision=<?php echo $latest_revision; ?>"><?php echo $latest_revision; ?></a></td> + </tr> +<?php /* <tr> + <td>New Failures:</td> + <td></td> + <td>New Crashes:</td> + <td></td> + </tr>*/ ?> +</table> +<br/> +<?php + + } // end if +} + +common_footer(); +?> \ No newline at end of file diff --git a/pftt_report.php b/pftt_report.php new file mode 100755 index 0000000..6f8e48e --- /dev/null +++ b/pftt_report.php @@ -0,0 +1,109 @@ +<?php + +// input via POST +// 3 parameters: branch, revision and the report file contents/name +// -branch +// -revision +// -report_file +// +// all this script does is generate a directory for the branch+revision and store the (validated) report file in it +// +// the report file will either be for PHPT or PhpUnit reports generated by PFTT (see: git.php.net/pftt2.git ) +// +// reports are stored as flat-files in pftt-reports/$branch/$revision (this is just a simple file upload script) +// +// +// INSTALL NOTE: web server user needs write access to `pftt-reports` directory +// +// the report file is pre-generated by PFTT and uploaded, instead of generating the report on upload +// or generating it when the user wants to view it. this is done because: +// 1. the result-packs (decompressed) are a lot of data +// 2. which is needed to get the output of failing tests to include in the report +// 3. simplifies the process of publishing reports as PFTT already generates reports comparing 2 builds +// 4. even just comparing the list of failing tests across multiple hosts and scenarios can be a lot of data +// (even if it was uploaded separately from the compressed result-packs) +// 5. doing the comparison is more complex meaning more error prone and since access to qa.php.net is limited to git, +// debugging, fixing and cleaning up errors in that process could be difficult + +// TODO limit number of revisions +// TODO limit number of reports per revision + + +function exit_error($msg='') { + header('HTTP/1.0 400 Bad Request'); + echo $msg; + exit; +} + +if (md5($_POST['token'])!="b1cab611a6a4ae40693c0f0f9df16692") { + exit_error("Invalid Token"); +} + +$branch = strtoupper($_POST['branch']); +$revision = strtolower($_POST['revision']); + +// do a bunch of validation on the input +switch($branch) { +case "PHP_5_3": +case "PHP_5_4": +case "PHP_5_5": +case "PHP_5_6": +case "PHP_5_7": +case "PHP_6_0": +case "PHP_MASTER": +case "MASTER": +case "STR_SIZE_AND_INT64": + // valid + break; +default: + exit_error('Invalid branch'); +} + +// revisions must either have a . (fe 5.5.10) or start with 'r' +if ((strpos($revision, ".")===FALSE and substr($revision, 0, 1)!="r") or strlen($revision)>20) { + exit_error('Invalid revision'); +} + +// validate report_file +if ($_FILES['report_file']['size'] > 100000 or $_FILES['report_file']['size'] < 100 ) { + exit_error('Invalid report file size'); +} else if ($_FILES['report_file']['type']!="text/html") { + exit_error('Invalid report type'); +} + +$file_contents = file_get_contents($_FILES['report_file']['tmp_name']); + +// validate file contents +if (substr($file_contents, 0, 6)!="<html>" or strpos($file_contents, "PFTT")===FALSE) { + exit_error('Invalid report file content'); +} + +// everything valid, now store it + +// cleanup report filename +// will be named either: +// PHPT_CMP_PHP_5_5-r31d67bd-NTS-X64-VC11_Local-FileSystem_CLI_v_PHP_5_5-rda84f3a-N.html +// PhpUnit_CMP_PHP_5_5-r31d67bd-NTS-X64-VC11_Local-FileSystem_CLI_Symfony_v_PHP_5_5-rda84f3a-N.html +// +$report_name = trim($_FILES['report_file']['name']); +if (strlen($report_name) > 80) { + $report_name = substr($report_name, 0, 80); +} +if (substr($report_name, -5) != ".html") { + $report_name .= ".html"; +} + +// decide where to store it +$report_file = dirname($_SERVER['SCRIPT_FILENAME']) . "/pftt-reports/$branch/$revision/$report_name"; +$report_dir = dirname($report_file); + +// ensure dir exists +@mkdir($report_dir, 0644, TRUE); + +// report_file is stored locally in a temporary file, move that file to the permanent location +move_uploaded_file($_FILES['report_file']['tmp_name'], $report_file); + +// done, successfully +echo "Uploaded to $report_file"; + +?> \ No newline at end of file
diff --git a/build.php b/build.php new file mode 100755 index 0000000..515d174 --- /dev/null +++ b/build.php @@ -0,0 +1,105 @@ +<?php + +define('BASE_REPORT_DIR', dirname($_SERVER['SCRIPT_FILENAME'])."/pftt-reports/"); + +$branch = $_GET['branch']; +$revision = $_GET['revision']; +if (substr($branch, 0, 3)!='PHP') { + $branch = "PHP_5_6"; +} +if (substr($revision, 0, 1)!='r') { + $revision = ""; +} + + +include("include/functions.php"); + +$TITLE = "PHP: QA: PFTT: $branch: $revision"; +$SITE_UPDATE = date("D M d H:i:s Y T", filectime(__FILE__)); +/* $Id$ */ + +common_header(); + + + +?> +<h1><a href="list_builds.php?branch=<?php echo $branch; ?>"><?php echo $branch; ?></a> <?php echo $revision; ?></h1> + +<h2>Summary</h2> + +<table> + <tr> + <td><?php echo $branch; ?> <?php echo $revision; ?> <?php echo $build_type; ?> <?php echo $cpu; ?></td> + </tr> +</table> + +<br/> + +<h2>Comparison Reports</h2> + +<table> + <tr> + <td><strong>PHPT</strong> <a href="howto_phpt.htm" target="_blank">How to</a></td> + </tr> + <?php + +foreach ( scandir(BASE_REPORT_DIR."/$branch/$revision") as $report ) { + if (substr($report, 0, 4)=="PHPT" && is_file(BASE_REPORT_DIR."/$branch/$revision/$report")) { + + ?> + <tr> + <td>with <a href="<?php echo dirname($_SERVER['PHP_SELF']); ?>/pftt-reports/<?php echo $branch; ?>/<?php echo $revision; ?>/<?php echo $report; ?>" target="_blank"><?php echo $report; ?></a></td> + </tr> + <?php + + } // end if +} + + ?> +</table> +<br/> +<table> + <tr> + <td><strong>PhpUnit</strong> <a href="howto_phpunit.htm" target="_blank">How to</a></td> + </tr> + <?php + +foreach ( scandir(BASE_REPORT_DIR."/$branch/$revision") as $report ) { + if (substr($report, 0, 7)=="PhpUnit" && is_file(BASE_REPORT_DIR."/$branch/$revision/$report")) { + + ?> + <tr> + <td>with <a href="<?php echo dirname($_SERVER['PHP_SELF']); ?>/pftt-reports/<?php echo $branch; ?>/<?php echo $revision; ?>/<?php echo $report; ?>" target="_blank"><?php echo $report; ?></a></td> + </tr> + <?php + + } // end if +} + +?> +</table> +<br/> +<h2>Abbreviations</h2> +<p><b>NTS</b> - Non-Thread Safe build, use for CLI or IIS (PHP on Windows uses 2 types of builds, TS and NTS)</p> +<p><b>TS</b> - Thread Safe build, use for CLI or Apache mod_php on Windows</p> +<p><b>VC11</b> - Build compiled using VC11 (Visual Studio 2012)</p> +<p><b>VC9</b> - Build compiled using VC9 (Visual Studio 2008)</p> +<p><b>GCC</b> - Build compiled using GCC</p> +<br/> +<h2>Common Scenario Sets</h2> +<p><b>Local-FileSystem_MySQL_Apache-ModPHP-ApacheLounge-2.4.4-VC9-OpenSS</b> - Tests run on local file system, using Apache with MySQL</p> +<p><b>Local-FileSystem_MySQL_CLI</b> - Tests run on local file system on CLI with MySQL</p> +<p><b>Opcache_Local-FileSystem_MySQL_Apache-ModPHP-ApacheLounge-2</b> - Tests run on local file system, using Apache with Opcache, MySQL</p> +<p><b>Opcache_Local-FileSystem_MySQL_CLI</b> - Tests run on local file system on CLI with MySQL</p> +<p><b>Opcache_Local-FileSystem_MySQL_CLI_WinCacheU</b> - Tests run on local file system on CLI with Opcache, MySQL and WinCache (user & file caches)</p> +<p><b>SMB-DFS_MySQL_Apache-ModPHP-ApacheLounge-2.4.4-VC9-OpenSS</b> - Tests run on remote DFS file system, using Apache with MySQL</p> +<p><b>SMB-DFS_MySQL_CLI</b> - Tests run on remote DFS file system on CLI with MySQL</p> +<p><b>Opcache_SMB-DFS_MySQL_Apache-ModPHP-ApacheLounge-2</b> - Tests run on remote DFS file system, using Apache with Opcache, MySQL</p> +<p><b>Opcache_SMB-DFS_MySQL_CLI</b> - Tests run on remote DFS file system on CLI with MySQL</p> +<p><b>Opcache_SMB-DFS_MySQL_CLI_WinCacheU</b> - Tests run on remote DFS file system on CLI with Opcache, MySQL and WinCache (user & file caches)</p> + +<?php + +common_footer(); + +?> \ No newline at end of file diff --git a/list_builds.php b/list_builds.php new file mode 100755 index 0000000..f091d0a --- /dev/null +++ b/list_builds.php @@ -0,0 +1,78 @@ +<?php + +define('BASE_REPORT_DIR', dirname($_SERVER['SCRIPT_FILENAME'])."/pftt-reports/"); + +$branch = $_GET['branch']; +if (substr($branch, 0, 3)!='PHP') { + $branch = "PHP_5_6"; +} + + +include("include/functions.php"); + +$TITLE = "PHP: QA: PFTT: $branch"; +$SITE_UPDATE = date("D M d H:i:s Y T", filectime(__FILE__)); +/* $Id$ */ + +common_header(); + + +?> +<h1><a href="pftt.php"><?php echo $branch; ?></a></h1> + +<p>Choose a PHP revision or build</p> +<?php + +$latest_revision = ''; +$mtime = 0; + +foreach ( scandir(BASE_REPORT_DIR."/$branch") as $revision ) { + if ($revision=="." or $revision=="..") + continue; + if (is_dir(BASE_REPORT_DIR."/$branch/$revision")) { + $mtime = stat(BASE_REPORT_DIR."/$branch/$revision")[9]; + if ($mtime > $latest_revision_mtime) { + $latest_revision = $revision; + $latest_revision_mtime = $mtime; + } + } +} + +?> +<table> + <tr> + <td>Latest:</td> + <td><a href="build.php?branch=<?php echo $branch; ?>&revision=<?php echo $revision; ?>"><?php echo $latest_revision; ?></a></td> + </tr> +<?php /* <tr> + <td>New Failures:</td> + <td>New Crashes:</td> + </tr> */ ?> +</table> +<br/> +<table> + <?php + +foreach ( scandir(BASE_REPORT_DIR."/$branch") as $revision ) { + if ($revision=="." or $revision=="..") + continue; + if (is_dir(BASE_REPORT_DIR."/$branch/$revision")) { + + + ?> + <tr> + <td><a href="build.php?branch=<?php echo $branch; ?>&revision=<?php echo $revision; ?>"><?php echo $revision; ?></a></td> + </tr> + <?php + + } // end if +} + + + ?> +</table> +<?php + +common_footer(); + +?> \ No newline at end of file diff --git a/pftt.php b/pftt.php new file mode 100755 index 0000000..cef7cef --- /dev/null +++ b/pftt.php @@ -0,0 +1,60 @@ +<?php + +include("include/functions.php"); + +$TITLE = "PHP: QA: PFTT"; +$SITE_UPDATE = date("D M d H:i:s Y T", filectime(__FILE__)); +/* $Id$ */ + +common_header(); + +define('BASE_REPORT_DIR', dirname($_SERVER['SCRIPT_FILENAME'])."/pftt-reports/"); + +?> +<h1>PFTT</h1> + +<p>Choose a PHP Branch</p> + +<?php + +foreach ( scandir(BASE_REPORT_DIR) as $branch ) { + if ($branch=="." or $branch=="..") + continue; + if (is_dir(BASE_REPORT_DIR."/$branch")) { + $latest_revision = ''; + $mtime = 0; + + foreach ( scandir(BASE_REPORT_DIR."/$branch") as $revision ) { + if ($revision=="." or $revision=="..") + continue; + if (is_dir(BASE_REPORT_DIR."/$branch/$revision")) { + $mtime = stat(BASE_REPORT_DIR."/$branch/$revision")[9]; + if ($mtime > $latest_revision_mtime) { + $latest_revision = $revision; + $latest_revision_mtime = $mtime; + } + } + } + +?> +<table> + <tr> + <td colspan="2"><a href="list_builds.php?branch=<?php echo $branch; ?>"><?php echo $branch; ?></a></td> + <td>Latest:</td> + <td><a href="build.php?branch=<?php echo $branch; ?>&revision=<?php echo $latest_revision; ?>"><?php echo $latest_revision; ?></a></td> + </tr> +<?php /* <tr> + <td>New Failures:</td> + <td></td> + <td>New Crashes:</td> + <td></td> + </tr>*/ ?> +</table> +<br/> +<?php + + } // end if +} + +common_footer(); +?> \ No newline at end of file diff --git a/pftt_report.php b/pftt_report.php new file mode 100755 index 0000000..6f8e48e --- /dev/null +++ b/pftt_report.php @@ -0,0 +1,109 @@ +<?php + +// input via POST +// 3 parameters: branch, revision and the report file contents/name +// -branch +// -revision +// -report_file +// +// all this script does is generate a directory for the branch+revision and store the (validated) report file in it +// +// the report file will either be for PHPT or PhpUnit reports generated by PFTT (see: git.php.net/pftt2.git ) +// +// reports are stored as flat-files in pftt-reports/$branch/$revision (this is just a simple file upload script) +// +// +// INSTALL NOTE: web server user needs write access to `pftt-reports` directory +// +// the report file is pre-generated by PFTT and uploaded, instead of generating the report on upload +// or generating it when the user wants to view it. this is done because: +// 1. the result-packs (decompressed) are a lot of data +// 2. which is needed to get the output of failing tests to include in the report +// 3. simplifies the process of publishing reports as PFTT already generates reports comparing 2 builds +// 4. even just comparing the list of failing tests across multiple hosts and scenarios can be a lot of data +// (even if it was uploaded separately from the compressed result-packs) +// 5. doing the comparison is more complex meaning more error prone and since access to qa.php.net is limited to git, +// debugging, fixing and cleaning up errors in that process could be difficult + +// TODO limit number of revisions +// TODO limit number of reports per revision + + +function exit_error($msg='') { + header('HTTP/1.0 400 Bad Request'); + echo $msg; + exit; +} + +if (md5($_POST['token'])!="b1cab611a6a4ae40693c0f0f9df16692") { + exit_error("Invalid Token"); +} + +$branch = strtoupper($_POST['branch']); +$revision = strtolower($_POST['revision']); + +// do a bunch of validation on the input +switch($branch) { +case "PHP_5_3": +case "PHP_5_4": +case "PHP_5_5": +case "PHP_5_6": +case "PHP_5_7": +case "PHP_6_0": +case "PHP_MASTER": +case "MASTER": +case "STR_SIZE_AND_INT64": + // valid + break; +default: + exit_error('Invalid branch'); +} + +// revisions must either have a . (fe 5.5.10) or start with 'r' +if ((strpos($revision, ".")===FALSE and substr($revision, 0, 1)!="r") or strlen($revision)>20) { + exit_error('Invalid revision'); +} + +// validate report_file +if ($_FILES['report_file']['size'] > 100000 or $_FILES['report_file']['size'] < 100 ) { + exit_error('Invalid report file size'); +} else if ($_FILES['report_file']['type']!="text/html") { + exit_error('Invalid report type'); +} + +$file_contents = file_get_contents($_FILES['report_file']['tmp_name']); + +// validate file contents +if (substr($file_contents, 0, 6)!="<html>" or strpos($file_contents, "PFTT")===FALSE) { + exit_error('Invalid report file content'); +} + +// everything valid, now store it + +// cleanup report filename +// will be named either: +// PHPT_CMP_PHP_5_5-r31d67bd-NTS-X64-VC11_Local-FileSystem_CLI_v_PHP_5_5-rda84f3a-N.html +// PhpUnit_CMP_PHP_5_5-r31d67bd-NTS-X64-VC11_Local-FileSystem_CLI_Symfony_v_PHP_5_5-rda84f3a-N.html +// +$report_name = trim($_FILES['report_file']['name']); +if (strlen($report_name) > 80) { + $report_name = substr($report_name, 0, 80); +} +if (substr($report_name, -5) != ".html") { + $report_name .= ".html"; +} + +// decide where to store it +$report_file = dirname($_SERVER['SCRIPT_FILENAME']) . "/pftt-reports/$branch/$revision/$report_name"; +$report_dir = dirname($report_file); + +// ensure dir exists +@mkdir($report_dir, 0644, TRUE); + +// report_file is stored locally in a temporary file, move that file to the permanent location +move_uploaded_file($_FILES['report_file']['tmp_name'], $report_file); + +// done, successfully +echo "Uploaded to $report_file"; + +?> \ No newline at end of file