2008-12-15 15:53:33 +03:00
|
|
|
#!/usr/bin/perl -wT
|
|
|
|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
|
|
|
#
|
|
|
|
# The contents of this file are subject to the Mozilla Public
|
|
|
|
# License Version 1.1 (the "License"); you may not use this file
|
|
|
|
# except in compliance with the License. You may obtain a copy of
|
|
|
|
# the License at http://www.mozilla.org/MPL/
|
|
|
|
#
|
|
|
|
# Software distributed under the License is distributed on an "AS
|
|
|
|
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
# implied. See the License for the specific language governing
|
|
|
|
# rights and limitations under the License.
|
|
|
|
#
|
|
|
|
# The Original Code is the Bugzilla Bug Tracking System.
|
|
|
|
#
|
|
|
|
# The Initial Developer of the Original Code is Netscape Communications
|
|
|
|
# Corporation. Portions created by Netscape are
|
|
|
|
# Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
# Rights Reserved.
|
|
|
|
#
|
|
|
|
# Contributor(s): Terry Weissman <terry@mozilla.org>
|
|
|
|
# Gervase Markham <gerv@gerv.net>
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
use lib qw(. lib);
|
|
|
|
|
|
|
|
use File::Temp;
|
|
|
|
|
|
|
|
use Bugzilla;
|
|
|
|
use Bugzilla::Constants;
|
|
|
|
use Bugzilla::Util;
|
|
|
|
use Bugzilla::Error;
|
|
|
|
use Bugzilla::Bug;
|
|
|
|
use Bugzilla::Status;
|
|
|
|
|
|
|
|
Bugzilla->login();
|
|
|
|
|
|
|
|
my $cgi = Bugzilla->cgi;
|
|
|
|
my $template = Bugzilla->template;
|
|
|
|
my $vars = {};
|
|
|
|
# Connect to the shadow database if this installation is using one to improve
|
|
|
|
# performance.
|
|
|
|
my $dbh = Bugzilla->switch_to_shadow_db();
|
|
|
|
|
|
|
|
local our (%seen, %edgesdone, %bugtitles);
|
|
|
|
|
|
|
|
# CreateImagemap: This sub grabs a local filename as a parameter, reads the
|
|
|
|
# dot-generated image map datafile residing in that file and turns it into
|
|
|
|
# an HTML map element. THIS SUB IS ONLY USED FOR LOCAL DOT INSTALLATIONS.
|
|
|
|
# The map datafile won't necessarily contain the bug summaries, so we'll
|
|
|
|
# pull possible HTML titles from the %bugtitles hash (filled elsewhere
|
|
|
|
# in the code)
|
|
|
|
|
|
|
|
# The dot mapdata lines have the following format (\nsummary is optional):
|
|
|
|
# rectangle (LEFTX,TOPY) (RIGHTX,BOTTOMY) URLBASE/show_bug.cgi?id=BUGNUM BUGNUM[\nSUMMARY]
|
|
|
|
|
|
|
|
sub CreateImagemap {
|
|
|
|
my $mapfilename = shift;
|
|
|
|
my $map = "<map name=\"imagemap\">\n";
|
|
|
|
my $default;
|
|
|
|
|
|
|
|
open MAP, "<$mapfilename";
|
|
|
|
while(my $line = <MAP>) {
|
|
|
|
if($line =~ /^default ([^ ]*)(.*)$/) {
|
|
|
|
$default = qq{<area alt="" shape="default" href="$1">\n};
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($line =~ /^rectangle \((.*),(.*)\) \((.*),(.*)\) (http[^ ]*) (\d+)(\\n.*)?$/) {
|
|
|
|
my ($leftx, $rightx, $topy, $bottomy, $url, $bugid) = ($1, $3, $2, $4, $5, $6);
|
|
|
|
|
|
|
|
# Pick up bugid from the mapdata label field. Getting the title from
|
|
|
|
# bugtitle hash instead of mapdata allows us to get the summary even
|
|
|
|
# when showsummary is off, and also gives us status and resolution.
|
|
|
|
my $bugtitle = html_quote(clean_text($bugtitles{$bugid}));
|
2009-01-12 19:26:55 +03:00
|
|
|
$map .= qq{<area alt="$bugtitle" name="bug$bugid" shape="rect" } .
|
2008-12-15 15:53:33 +03:00
|
|
|
qq{title="$bugtitle" href="$url" } .
|
|
|
|
qq{coords="$leftx,$topy,$rightx,$bottomy">\n};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close MAP;
|
|
|
|
|
|
|
|
$map .= "$default</map>";
|
|
|
|
return $map;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub AddLink {
|
|
|
|
my ($blocked, $dependson, $fh) = (@_);
|
|
|
|
my $key = "$blocked,$dependson";
|
|
|
|
if (!exists $edgesdone{$key}) {
|
|
|
|
$edgesdone{$key} = 1;
|
|
|
|
print $fh "$blocked -> $dependson\n";
|
|
|
|
$seen{$blocked} = 1;
|
|
|
|
$seen{$dependson} = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# The list of valid directions. Some are not proposed in the dropdrown
|
|
|
|
# menu despite the fact that they are valid.
|
|
|
|
my @valid_rankdirs = ('LR', 'RL', 'TB', 'BT');
|
2009-02-02 15:39:26 +03:00
|
|
|
my $default_rankdir = Bugzilla->params->{graph_rankdir} || 'LR';
|
2008-12-15 15:53:33 +03:00
|
|
|
|
2009-02-02 15:39:26 +03:00
|
|
|
my $rankdir = $cgi->param('rankdir') || $default_rankdir;
|
2008-12-15 15:53:33 +03:00
|
|
|
# Make sure the submitted 'rankdir' value is valid.
|
|
|
|
if (lsearch(\@valid_rankdirs, $rankdir) < 0) {
|
2009-02-02 15:39:26 +03:00
|
|
|
$rankdir = $default_rankdir;
|
2008-12-15 15:53:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
my $display = $cgi->param('display') || 'tree';
|
|
|
|
my $webdotdir = bz_locations()->{'webdotdir'};
|
|
|
|
|
|
|
|
if (!defined $cgi->param('id') && $display ne 'doall') {
|
|
|
|
ThrowCodeError("missing_bug_id");
|
|
|
|
}
|
|
|
|
|
|
|
|
my ($fh, $filename) = File::Temp::tempfile("XXXXXXXXXX",
|
|
|
|
SUFFIX => '.dot',
|
|
|
|
DIR => $webdotdir);
|
2009-02-02 15:39:26 +03:00
|
|
|
my $urlbase = Bugzilla->params->{urlbase};
|
2008-12-15 15:53:33 +03:00
|
|
|
|
|
|
|
print $fh "digraph G {";
|
|
|
|
print $fh qq{
|
2009-03-04 14:32:21 +03:00
|
|
|
graph [URL="${urlbase}query.cgi", rankdir=$rankdir, overlap=false, splines=true]
|
2008-12-15 15:53:33 +03:00
|
|
|
node [URL="${urlbase}show_bug.cgi?id=\\N", style=filled, color=lightgrey]
|
|
|
|
};
|
|
|
|
|
|
|
|
my %baselist;
|
2009-03-04 14:32:21 +03:00
|
|
|
my %deps;
|
2008-12-15 15:53:33 +03:00
|
|
|
|
|
|
|
if ($display eq 'doall') {
|
|
|
|
my $dependencies = $dbh->selectall_arrayref(
|
|
|
|
"SELECT blocked, dependson FROM dependencies");
|
|
|
|
|
|
|
|
foreach my $dependency (@$dependencies) {
|
|
|
|
my ($blocked, $dependson) = @$dependency;
|
|
|
|
AddLink($blocked, $dependson, $fh);
|
2009-03-04 14:32:21 +03:00
|
|
|
$deps{$dependson}++;
|
2008-12-15 15:53:33 +03:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
foreach my $i (split('[\s,]+', $cgi->param('id'))) {
|
2009-07-29 15:21:49 +04:00
|
|
|
my $bug = Bugzilla::Bug->check($i);
|
|
|
|
$baselist{$bug->id} = 1;
|
2008-12-15 15:53:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
my @stack = keys(%baselist);
|
|
|
|
|
|
|
|
if ($display eq 'web') {
|
|
|
|
my $sth = $dbh->prepare(q{SELECT blocked, dependson
|
|
|
|
FROM dependencies
|
|
|
|
WHERE blocked = ? OR dependson = ?});
|
|
|
|
|
|
|
|
foreach my $id (@stack) {
|
|
|
|
my $dependencies = $dbh->selectall_arrayref($sth, undef, ($id, $id));
|
|
|
|
foreach my $dependency (@$dependencies) {
|
|
|
|
my ($blocked, $dependson) = @$dependency;
|
|
|
|
if ($blocked != $id && !exists $seen{$blocked}) {
|
|
|
|
push @stack, $blocked;
|
|
|
|
}
|
|
|
|
if ($dependson != $id && !exists $seen{$dependson}) {
|
|
|
|
push @stack, $dependson;
|
|
|
|
}
|
|
|
|
AddLink($blocked, $dependson, $fh);
|
2009-03-04 14:32:21 +03:00
|
|
|
$deps{$dependson}++;
|
2008-12-15 15:53:33 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
# This is the default: a tree instead of a spider web.
|
|
|
|
else {
|
|
|
|
my @blocker_stack = @stack;
|
|
|
|
foreach my $id (@blocker_stack) {
|
|
|
|
my $blocker_ids = Bugzilla::Bug::EmitDependList('blocked', 'dependson', $id);
|
|
|
|
foreach my $blocker_id (@$blocker_ids) {
|
|
|
|
push(@blocker_stack, $blocker_id) unless $seen{$blocker_id};
|
|
|
|
AddLink($id, $blocker_id, $fh);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
my @dependent_stack = @stack;
|
|
|
|
foreach my $id (@dependent_stack) {
|
|
|
|
my $dep_bug_ids = Bugzilla::Bug::EmitDependList('dependson', 'blocked', $id);
|
|
|
|
foreach my $dep_bug_id (@$dep_bug_ids) {
|
|
|
|
push(@dependent_stack, $dep_bug_id) unless $seen{$dep_bug_id};
|
|
|
|
AddLink($dep_bug_id, $id, $fh);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach my $k (keys(%baselist)) {
|
|
|
|
$seen{$k} = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-27 16:06:50 +04:00
|
|
|
my $sth = $dbh->prepare(q{
|
2009-09-17 22:40:44 +04:00
|
|
|
SELECT t1.bug_status, t1.resolution, t1.short_desc, t1.estimated_time, SUM(t3.work_time), t1.assigned_to, t2.login_name, t4.name, t5.name
|
2009-08-27 16:06:50 +04:00
|
|
|
FROM bugs AS t1
|
|
|
|
LEFT JOIN profiles AS t2 ON t2.userid=t1.assigned_to
|
|
|
|
LEFT JOIN longdescs AS t3 ON t3.bug_id=t1.bug_id AND t3.work_time > 0
|
2009-09-17 22:40:44 +04:00
|
|
|
LEFT JOIN products AS t4 ON t4.id=t1.product_id
|
|
|
|
LEFT JOIN components AS t5 ON t5.id=t1.component_id
|
2009-08-27 16:06:50 +04:00
|
|
|
WHERE t1.bug_id=?
|
|
|
|
GROUP BY t1.bug_id
|
|
|
|
});
|
2008-12-15 15:53:33 +03:00
|
|
|
foreach my $k (keys(%seen)) {
|
|
|
|
# Retrieve bug information from the database
|
2009-09-17 22:40:44 +04:00
|
|
|
my ($stat, $resolution, $summary, $time, $wtime, $assignee, $asslogin, $product, $component) = $dbh->selectrow_array($sth, undef, $k);
|
2008-12-15 15:53:33 +03:00
|
|
|
$stat ||= 'NEW';
|
|
|
|
$resolution ||= '';
|
|
|
|
$summary ||= '';
|
|
|
|
|
|
|
|
# Resolution and summary are shown only if user can see the bug
|
|
|
|
if (!Bugzilla->user->can_see_bug($k)) {
|
|
|
|
$resolution = $summary = '';
|
|
|
|
}
|
|
|
|
|
2009-03-04 14:32:21 +03:00
|
|
|
$vars->{short_desc} = $summary if $k eq $cgi->param('id');
|
2008-12-15 15:53:33 +03:00
|
|
|
|
2009-03-27 19:34:49 +03:00
|
|
|
my @params = ("fontname=Sans",
|
|
|
|
"fillcolor=" . GetColorByState($stat, 1),
|
2009-03-04 14:32:21 +03:00
|
|
|
"color=" . GetColorByState($stat));
|
2008-12-15 15:53:33 +03:00
|
|
|
|
2009-03-27 19:34:49 +03:00
|
|
|
push @params, "peripheries=2" if exists $baselist{$k};
|
|
|
|
|
|
|
|
if ($assignee == Bugzilla->user->id)
|
|
|
|
{
|
|
|
|
push @params, "shape=box";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
push @params, "shape=egg";
|
|
|
|
}
|
|
|
|
|
2009-08-27 16:06:50 +04:00
|
|
|
my $important = $time > 40 || $wtime > 40 || ($deps{$k}||0) > 4;
|
2009-03-04 14:32:21 +03:00
|
|
|
if ($important)
|
|
|
|
{
|
|
|
|
push @params, "width=3", "height=1.5", "fontsize=13";
|
2008-12-15 15:53:33 +03:00
|
|
|
}
|
2009-03-04 14:32:21 +03:00
|
|
|
else
|
|
|
|
{
|
|
|
|
push @params, "fontsize=10";
|
2008-12-15 15:53:33 +03:00
|
|
|
}
|
|
|
|
|
2009-03-04 14:32:21 +03:00
|
|
|
if ($summary ne "" && ($cgi->param('showsummary') || $important)) {
|
|
|
|
$summary =~ s/([\\\"])/\\$1/g;
|
|
|
|
push(@params, qq{label="$k\\n$summary"});
|
|
|
|
}
|
2008-12-15 15:53:33 +03:00
|
|
|
|
|
|
|
if (@params) {
|
|
|
|
print $fh "$k [" . join(',', @params) . "]\n";
|
|
|
|
} else {
|
|
|
|
print $fh "$k\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
# Push the bug tooltip texts into a global hash so that
|
|
|
|
# CreateImagemap sub (used with local dot installations) can
|
|
|
|
# use them later on.
|
2009-09-17 22:40:44 +04:00
|
|
|
$bugtitles{$k} = "[".trim("$stat $resolution")." $asslogin]";
|
2008-12-15 15:53:33 +03:00
|
|
|
|
|
|
|
# Show the bug summary in tooltips only if not shown on
|
|
|
|
# the graph and it is non-empty (the user can see the bug)
|
2009-03-04 14:32:21 +03:00
|
|
|
if ($summary ne "") {
|
2009-09-17 22:40:44 +04:00
|
|
|
$bugtitles{$k} .= " $product/$component - $summary";
|
2008-12-15 15:53:33 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-04 14:32:21 +03:00
|
|
|
sub GetColorByState
|
|
|
|
{
|
|
|
|
my ($state, $base) = (@_);
|
|
|
|
$base = $base ? 0 : 0x40;
|
|
|
|
my %colorbystate = (
|
|
|
|
UNCONFIRMED => 'ffffff',
|
|
|
|
NEW => 'ff8000',
|
|
|
|
ASSIGNED => 'ffff00',
|
|
|
|
RESOLVED => '00ff00',
|
|
|
|
VERIFIED => '675acd',
|
|
|
|
CLOSED => 'd0d0d0',
|
|
|
|
REOPENED => 'ff4000',
|
|
|
|
opened => '00ff00',
|
|
|
|
closed => 'c0c0c0',
|
|
|
|
);
|
|
|
|
my $color = sprintf("\"#%02x%02x%02x\"", map { int(ord($_)/0xff*(0xff-$base)) }
|
|
|
|
split //, pack 'H*',
|
|
|
|
$colorbystate{$state} ||
|
|
|
|
$colorbystate{is_open_state($state) ? 'opened' : 'closed'});
|
|
|
|
return $color;
|
2009-01-12 19:26:55 +03:00
|
|
|
}
|
2008-12-15 15:53:33 +03:00
|
|
|
|
|
|
|
print $fh "}\n";
|
|
|
|
close $fh;
|
|
|
|
|
|
|
|
chmod 0777, $filename;
|
|
|
|
|
2009-03-04 14:32:21 +03:00
|
|
|
sub buildtree
|
|
|
|
{
|
|
|
|
my $hash = shift;
|
|
|
|
my $track = shift;
|
|
|
|
my $r = {};
|
|
|
|
for (@_)
|
|
|
|
{
|
|
|
|
unless ($track->{$_})
|
|
|
|
{
|
|
|
|
$track->{$_} = 1;
|
|
|
|
$r->{$_} = buildtree($hash, $track, keys %{$hash->{$_}});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $r;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub makemap # hgap="'.int(($nodes->{$_}->[0]-$x)*20).'" vshift="'.int(($nodes->{$_}->[1]-$y)*20).'"
|
|
|
|
{
|
|
|
|
my ($nodes, $edges, $tree, $x, $y, $header) = @_;
|
|
|
|
my $map = '';
|
|
|
|
for (keys %$tree)
|
|
|
|
{
|
|
|
|
$map .= '<node background_color="'.$nodes->{$_}->[7].'" id="node_'.$_.'" text="'.$nodes->{$_}->[4].'">'."\n";
|
|
|
|
$map .= makemap($nodes, $edges, $tree->{$_}, $nodes->{$_}->[0], $nodes->{$_}->[1]);
|
|
|
|
for my $r (keys %{$edges->{$_} || {}})
|
|
|
|
{
|
|
|
|
$map .= '<arrowlink destination="node_'.$r.'" endarrow="default" />'."\n"
|
|
|
|
if $edges->{$_}->{$r};
|
|
|
|
}
|
|
|
|
$map .= '</node>' . "\n";
|
|
|
|
}
|
|
|
|
if ($header)
|
|
|
|
{
|
|
|
|
$map = <<EOF;
|
|
|
|
<?xml version="1.0" encoding="UTF-8" ?>
|
|
|
|
<map version="0.9.0">
|
|
|
|
<node background_color="#0000a0" id="root" text="$header">
|
|
|
|
$map
|
|
|
|
</node>
|
|
|
|
</map>
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
return $map;
|
|
|
|
}
|
|
|
|
|
2009-08-26 17:41:48 +04:00
|
|
|
my $dottimeout = int(Bugzilla->params->{localdottimeout});
|
2009-08-26 17:01:35 +04:00
|
|
|
my $usetwopi = scalar $cgi->param('usetwopi') && Bugzilla->params->{webtwopibase} ? 1 : 0;
|
|
|
|
my $webdotbase = Bugzilla->params->{ $usetwopi ? 'webtwopibase' : 'webdotbase' };
|
2008-12-15 15:53:33 +03:00
|
|
|
|
|
|
|
if ($webdotbase =~ /^https?:/) {
|
|
|
|
# Remote dot server. We don't hardcode 'urlbase' here in case
|
|
|
|
# 'sslbase' is in use.
|
|
|
|
$webdotbase =~ s/%([a-z]*)%/Bugzilla->params->{$1}/eg;
|
|
|
|
my $url = $webdotbase . $filename;
|
2009-03-04 14:32:21 +03:00
|
|
|
$vars->{image_url} = $url . ".gif";
|
|
|
|
$vars->{map_url} = $url . ".map";
|
2008-12-15 15:53:33 +03:00
|
|
|
} else {
|
|
|
|
# Local dot installation
|
|
|
|
|
|
|
|
# First, generate the png image file from the .dot source
|
|
|
|
|
|
|
|
my ($pngfh, $pngfilename) = File::Temp::tempfile("XXXXXXXXXX",
|
|
|
|
SUFFIX => '.png',
|
|
|
|
DIR => $webdotdir);
|
|
|
|
binmode $pngfh;
|
2009-09-23 16:58:34 +04:00
|
|
|
my $quot = $^O =~ /MSWin/ ? '"' : "'";
|
2009-08-26 19:38:49 +04:00
|
|
|
my $cmd = [$webdotbase, '-Tpng', $filename];
|
|
|
|
if ($dottimeout && $dottimeout > 0)
|
|
|
|
{
|
|
|
|
# This creepy way is the only one that seems to be truly crossplatform
|
2009-09-23 16:58:34 +04:00
|
|
|
$cmd = "perl -e $quot\$SIG{ALRM} = sub { exit 1 }; alarm $dottimeout; exec(" .
|
2009-08-26 19:38:49 +04:00
|
|
|
join(",", map { 'q{'.$_.'}' } @$cmd) .
|
2009-09-23 16:58:34 +04:00
|
|
|
");$quot";
|
2009-08-26 19:38:49 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-09-23 16:58:34 +04:00
|
|
|
$cmd = join " ", map { $quot.$_.$quot } @$cmd;
|
2009-08-26 19:38:49 +04:00
|
|
|
}
|
|
|
|
if (my $pid = open DOT, "$cmd|")
|
2009-08-26 17:41:48 +04:00
|
|
|
{
|
|
|
|
binmode DOT;
|
|
|
|
print $pngfh $_ while <DOT>;
|
|
|
|
close DOT;
|
|
|
|
}
|
2009-08-26 19:38:49 +04:00
|
|
|
unless (tell $pngfh)
|
|
|
|
{
|
|
|
|
$vars->{timeout} = 1;
|
|
|
|
}
|
2008-12-15 15:53:33 +03:00
|
|
|
close $pngfh;
|
2009-03-04 14:32:21 +03:00
|
|
|
|
2008-12-15 15:53:33 +03:00
|
|
|
# On Windows $pngfilename will contain \ instead of /
|
|
|
|
$pngfilename =~ s|\\|/|g if $^O eq 'MSWin32';
|
|
|
|
|
|
|
|
# Under mod_perl, pngfilename will have an absolute path, and we
|
|
|
|
# need to make that into a relative path.
|
|
|
|
my $cgi_root = bz_locations()->{cgi_path};
|
|
|
|
$pngfilename =~ s#^\Q$cgi_root\E/?##;
|
2009-03-04 14:32:21 +03:00
|
|
|
|
2008-12-15 15:53:33 +03:00
|
|
|
$vars->{'image_url'} = $pngfilename;
|
|
|
|
|
|
|
|
# Then, generate a imagemap datafile that contains the corner data
|
|
|
|
# for drawn bug objects. Pass it on to CreateImagemap that
|
|
|
|
# turns this monster into html.
|
|
|
|
|
|
|
|
my ($mapfh, $mapfilename) = File::Temp::tempfile("XXXXXXXXXX",
|
|
|
|
SUFFIX => '.map',
|
|
|
|
DIR => $webdotdir);
|
|
|
|
binmode $mapfh;
|
2009-08-26 19:38:49 +04:00
|
|
|
$cmd = [$webdotbase, '-Tismap', $filename];
|
|
|
|
if ($dottimeout && $dottimeout > 0)
|
|
|
|
{
|
|
|
|
# This creepy way is the only one that seems to be truly crossplatform
|
|
|
|
$cmd = "perl -e '\$SIG{ALRM} = sub { exit 1 }; alarm $dottimeout; exec(" .
|
|
|
|
join(",", map { 'q{'.$_.'}' } @$cmd) .
|
|
|
|
");'";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$cmd = join " ", map { "'$_'" } @$cmd;
|
|
|
|
}
|
|
|
|
open(DOT, "$cmd|");
|
2008-12-15 15:53:33 +03:00
|
|
|
binmode DOT;
|
|
|
|
print $mapfh $_ while <DOT>;
|
|
|
|
close DOT;
|
|
|
|
close $mapfh;
|
|
|
|
$vars->{'image_map'} = CreateImagemap($mapfilename);
|
|
|
|
}
|
|
|
|
|
|
|
|
# Cleanup any old .dot files created from previous runs.
|
|
|
|
my $since = time() - 24 * 60 * 60;
|
|
|
|
# Can't use glob, since even calling that fails taint checks for perl < 5.6
|
|
|
|
opendir(DIR, $webdotdir);
|
|
|
|
my @files = grep { /\.dot$|\.png$|\.map$/ && -f "$webdotdir/$_" } readdir(DIR);
|
|
|
|
closedir DIR;
|
|
|
|
foreach my $f (@files)
|
|
|
|
{
|
|
|
|
$f = "$webdotdir/$f";
|
|
|
|
# Here we are deleting all old files. All entries are from the
|
|
|
|
# $webdot directory. Since we're deleting the file (not following
|
|
|
|
# symlinks), this can't escape to delete anything it shouldn't
|
|
|
|
# (unless someone moves the location of $webdotdir, of course)
|
|
|
|
trick_taint($f);
|
|
|
|
if (file_mod_time($f) < $since) {
|
|
|
|
unlink $f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Make sure we only include valid integers (protects us from XSS attacks).
|
|
|
|
my @bugs = grep(detaint_natural($_), split(/[\s,]+/, $cgi->param('id')));
|
|
|
|
$vars->{'bug_id'} = join(', ', @bugs);
|
|
|
|
$vars->{'multiple_bugs'} = ($cgi->param('id') =~ /[ ,]/);
|
|
|
|
$vars->{'display'} = $display;
|
|
|
|
$vars->{'rankdir'} = $rankdir;
|
|
|
|
$vars->{'showsummary'} = $cgi->param('showsummary');
|
2009-08-26 17:01:35 +04:00
|
|
|
$vars->{'usetwopi'} = $usetwopi;
|
2008-12-15 15:53:33 +03:00
|
|
|
|
|
|
|
# Generate and return the UI (HTML page) from the appropriate template.
|
|
|
|
print $cgi->header();
|
|
|
|
$template->process("bug/dependency-graph.html.tmpl", $vars)
|
|
|
|
|| ThrowTemplateError($template->error());
|