Ejemplo n.º 1
0
 public function __construct()
 {
     parent::__construct();
     // Check if the SubProject filter was specified.
     // If so, we won't add SQL clauses for some other filters.
     // Instead we handle them in PHP code via build_survives_filter().
     $this->HasSubProjectsFilter = false;
     $filtercount = pdo_real_escape_numeric(@$_REQUEST['filtercount']);
     for ($i = 1; $i <= $filtercount; ++$i) {
         if (empty($_REQUEST['field' . $i])) {
             continue;
         }
         $field = htmlspecialchars(pdo_real_escape_string($_REQUEST['field' . $i]));
         if ($field === 'subprojects') {
             $this->HasSubProjectsFilter = true;
             break;
         }
     }
     $this->FiltersAffectedBySubProjects = array('buildduration', 'builderrors', 'buildwarnings', 'configureduration', 'configureerrors', 'configurewarnings', 'testsduration', 'testsfailed', 'testsnotrun', 'testspassed', 'testtimestatus');
 }
Ejemplo n.º 2
0
=========================================================================*/
// To be able to access files in this CDash installation regardless
// of getcwd() value:
//
$cdashpath = str_replace('\\', '/', dirname(dirname(__FILE__)));
set_include_path($cdashpath . PATH_SEPARATOR . get_include_path());
require_once "cdash/config.php";
require_once "cdash/pdo.php";
require_once "cdash/common.php";
$projectid = pdo_real_escape_numeric($_GET["projectid"]);
if (!isset($projectid) || !is_numeric($projectid)) {
    echo "Not a valid projectid!";
    return;
}
$timestamp = pdo_real_escape_numeric($_GET["timestamp"]);
$db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}");
pdo_select_db("{$CDASH_DB_NAME}", $db);
// Find the project variables
$files = pdo_query("SELECT d.date,count(df.dailyupdateid) FROM dailyupdate as d \n                    LEFT JOIN dailyupdatefile AS df ON (df.dailyupdateid=d.id)\n                    WHERE d.projectid=" . $projectid . " \n                    AND date<='" . date("Y-m-d", $timestamp) . "'\n                    GROUP BY d.date ORDER BY d.date");
?>

    
<br>
<script language="javascript" type="text/javascript">
$(function () {
    var d1 = [];
    var dates = [];
    <?php 
$i = 0;
while ($files_array = pdo_fetch_array($files)) {
Ejemplo n.º 3
0
function client_submit()
{
    include 'config/config.php';
    if (!$CDASH_MANAGE_CLIENTS) {
        return 0;
    }
    include_once 'models/clientsite.php';
    include_once 'models/clientos.php';
    include_once 'models/clientjob.php';
    include_once 'models/clientjobschedule.php';
    include_once 'models/clientcmake.php';
    include_once 'models/clientcompiler.php';
    include_once 'models/clientlibrary.php';
    include 'config/config.php';
    require_once 'include/common.php';
    // Client asks for the site id
    if (isset($_GET['getsiteid'])) {
        if (!isset($_GET['sitename']) || !isset($_GET['systemname'])) {
            echo 'ERROR: sitename or systemname not set';
            return 0;
        }
        $sitename = htmlspecialchars(pdo_real_escape_string($_GET['sitename']));
        $systemname = htmlspecialchars(pdo_real_escape_string($_GET['systemname']));
        // Should get the site id
        $ClientSite = new ClientSite();
        $siteid = $ClientSite->GetId($sitename, $systemname);
        echo $siteid;
        return 1;
    } elseif (isset($_GET['getjob'])) {
        if (!isset($_GET['siteid'])) {
            echo '0';
            return 1;
        }
        if (!$_GET['siteid']) {
            echo '0';
            return 1;
        }
        $ClientJobSchedule = new ClientJobSchedule();
        $ClientJobSchedule->SiteId = pdo_real_escape_numeric($_GET['siteid']);
        $jobid = $ClientJobSchedule->HasJob();
        if ($jobid > 0) {
            // if we have something to do
            echo $ClientJobSchedule->GetCTestScript();
        } else {
            echo '0';
            // send zero to let the client know that nothing is there
        }
        return 1;
    } elseif (isset($_GET['submitinfo'])) {
        if (!isset($_GET['sitename']) || !isset($_GET['systemname'])) {
            echo '0';
            return 1;
        }
        $filehandle = 'php://input';
        $contents = file_get_contents($filehandle);
        $xml = new SimpleXMLElement($contents);
        // Add/Update the OS
        $ClientOS = new ClientOS();
        $ClientOS->Name = $ClientOS->GetPlatformFromName($xml->system->platform);
        $ClientOS->Version = $ClientOS->GetVersionFromName($xml->system->version);
        $ClientOS->Bits = $xml->system->bits;
        $ClientOS->Save();
        // Add/Update the site
        $ClientSite = new ClientSite();
        $ClientSite->Name = htmlspecialchars(pdo_real_escape_string($_GET['sitename']));
        $ClientSite->SystemName = htmlspecialchars(pdo_real_escape_string($_GET['systemname']));
        $ClientSite->Host = 'none';
        $ClientSite->OsId = $ClientOS->Id;
        $ClientSite->BaseDirectory = $xml->system->basedirectory;
        $ClientSite->Save();
        $siteid = $ClientSite->Id;
        // Add/Update the compiler(s)
        $compilers = array();
        foreach ($xml->compiler as $compiler) {
            $ClientCompiler = new ClientCompiler();
            $ClientCompiler->Name = $compiler->name;
            $ClientCompiler->Version = $compiler->version;
            $ClientCompiler->Command = $compiler->command;
            $ClientCompiler->Generator = $compiler->generator;
            $ClientCompiler->SiteId = $siteid;
            $ClientCompiler->Save();
            $comp = array();
            $comp['name'] = $compiler->name;
            $comp['version'] = $compiler->version;
            $comp['command'] = $compiler->command;
            $comp['generator'] = $compiler->generator;
            $compilers[] = $comp;
        }
        $ClientCompiler = new ClientCompiler();
        $ClientCompiler->SiteId = $siteid;
        $ClientCompiler->DeleteUnused($compilers);
        // Add/Update CMake(s)
        $cmakes = array();
        foreach ($xml->cmake as $cmake) {
            $ClientCMake = new ClientCMake();
            $ClientCMake->Version = $cmake->version;
            $ClientCMake->Path = $cmake->path;
            $ClientCMake->SiteId = $siteid;
            $ClientCMake->Save();
            $cm = array();
            $cm['path'] = $cmake->path;
            $cm['version'] = $cmake->version;
            $cmakes[] = $cm;
        }
        $ClientCMake = new ClientCMake();
        $ClientCMake->SiteId = $siteid;
        $ClientCMake->DeleteUnused($cmakes);
        // Add/Update Libraries
        $libraries = array();
        foreach ($xml->library as $library) {
            $ClientLibrary = new ClientLibrary();
            $ClientLibrary->Name = $library->name;
            $ClientLibrary->Path = $library->path;
            $ClientLibrary->Include = $library->include;
            $ClientLibrary->Version = $library->version;
            $ClientLibrary->SiteId = $siteid;
            $ClientLibrary->Save();
            $lib = array();
            $lib['name'] = $library->name;
            $lib['path'] = $library->path;
            $lib['version'] = $library->version;
            $lib['include'] = $library->include;
            $libraries[] = $lib;
        }
        $ClientLibrary = new ClientLibrary();
        $ClientLibrary->SiteId = $siteid;
        $ClientLibrary->DeleteUnused($libraries);
        // Add/Update Programs
        $programs = array();
        foreach ($xml->program as $program) {
            $prog = array();
            $prog['name'] = $program->name;
            $prog['path'] = $program->path;
            $prog['version'] = $program->version;
            $programs[] = $prog;
        }
        $ClientSite->UpdatePrograms($programs);
        // Add/Update the list of allowed projects
        $allowedProjects = array();
        foreach ($xml->allowedproject as $allowedProject) {
            $allowedProjects[] = $allowedProject;
        }
        $ClientSite->UpdateAllowedProjects($allowedProjects);
        return 1;
    } elseif (isset($_GET['jobdone'])) {
        // Mark the job has finished
        if (!isset($_GET['siteid'])) {
            echo '0';
            return 1;
        }
        if (!$_GET['siteid']) {
            echo '0';
            return 1;
        }
        $ClientJob = new ClientJob();
        $ClientJob->SiteId = pdo_real_escape_numeric($_GET['siteid']);
        $ClientJob->SetFinished();
        return 1;
    } elseif (isset($_GET['jobfailed'])) {
        // Mark the job has failed
        if (!isset($_GET['siteid'])) {
            echo '0';
            return 1;
        }
        if (!$_GET['siteid']) {
            echo '0';
            return 1;
        }
        $ClientJob = new ClientJob();
        $ClientJob->SiteId = pdo_real_escape_numeric($_GET['siteid']);
        $ClientJob->SetFailed();
        return 1;
    }
    return 0;
}
Ejemplo n.º 4
0
function get_subprojectid()
{
    if (!isset($_GET['subprojectid'])) {
        echo_error('subprojectid not specified.');
        return false;
    }
    $subprojectid = pdo_real_escape_numeric($_GET['subprojectid']);
    return $subprojectid;
}
Ejemplo n.º 5
0
$xml .= add_XML_value("back", "index.php?project=" . urlencode($projectname) . "&date=" . get_dashboard_date_from_project($projectname, $date));
$xml .= "</menu>";
// Get some information about the specified project
$projectname = pdo_real_escape_string($projectname);
$projectQuery = "SELECT id, nightlytime FROM project WHERE name = '{$projectname}'";
$projectResult = pdo_query($projectQuery);
if (!($projectRow = pdo_fetch_array($projectResult))) {
    die("Error:  project {$projectname} not found<br>\n");
}
$projectid = $projectRow["id"];
$nightlytime = $projectRow["nightlytime"];
checkUserPolicy(@$_SESSION['cdash']['loginid'], $projectid);
// Return the available groups
@($groupSelection = $_POST["groupSelection"]);
if ($groupSelection != NULL) {
    $groupSelection = pdo_real_escape_numeric($groupSelection);
}
if (!isset($groupSelection)) {
    $groupSelection = 0;
}
$buildgroup = pdo_query("SELECT id,name FROM buildgroup WHERE projectid='{$projectid}'");
while ($buildgroup_array = pdo_fetch_array($buildgroup)) {
    $xml .= "<group>";
    $xml .= add_XML_value("id", $buildgroup_array["id"]);
    $xml .= add_XML_value("name", $buildgroup_array["name"]);
    if ($groupSelection == $buildgroup_array["id"]) {
        $xml .= add_XML_value("selected", "1");
    }
    $xml .= "</group>";
}
$groupSelectionSQL = "";
Ejemplo n.º 6
0
require_once "cdash/common.php";
$db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}");
pdo_select_db("{$CDASH_DB_NAME}", $db);
$siteid = pdo_real_escape_numeric($_GET["siteid"]);
$buildname = htmlspecialchars(pdo_real_escape_string($_GET["buildname"]));
$buildtype = htmlspecialchars(pdo_real_escape_string($_GET["buildtype"]));
$buildgroupid = pdo_real_escape_numeric($_GET["buildgroup"]);
$divname = htmlspecialchars(pdo_real_escape_string($_GET["divname"]));
if (!isset($siteid) || !is_numeric($siteid)) {
    echo "Not a valid siteid!";
    return;
}
@($submit = $_POST["submit"]);
@($groupid = $_POST["groupid"]);
if ($groupid != NULL) {
    $groupid = pdo_real_escape_numeric($groupid);
}
@($expected = $_POST["expected"]);
@($markexpected = $_POST["markexpected"]);
@($previousgroupid = $_POST["previousgroupid"]);
if ($markexpected) {
    if (!isset($groupid) || !is_numeric($groupid)) {
        echo "Not a valid groupid!";
        return;
    }
    $expected = pdo_real_escape_string($expected);
    $markexpected = pdo_real_escape_string($markexpected);
    // If a rule already exists we update it
    pdo_query("UPDATE build2grouprule SET expected='{$expected}' WHERE groupid='{$groupid}' AND buildtype='{$buildtype}'\n                      AND buildname='{$buildname}' AND siteid='{$siteid}' AND endtime='1980-01-01 00:00:00'");
    return;
}
Ejemplo n.º 7
0
while ($project_array = pdo_fetch_array($projects)) {
    $availableproject = array();
    $availableproject['id'] = $project_array['id'];
    $availableproject['name'] = $project_array['name'];
    if ($project_array['id'] == $projectid) {
        $availableproject['selected'] = '1';
    }
    $availableprojects[] = $availableproject;
}
$response['availableprojects'] = $availableprojects;
if (!isset($projectid)) {
    $response['error'] = "Please select a project to continue.";
    echo json_encode($response);
    return;
}
$projectid = pdo_real_escape_numeric($projectid);
$response['projectid'] = $projectid;
$Project = new Project();
$Project->Id = $projectid;
$role = $Project->GetUserRole($userid);
if ($User->IsAdmin() === FALSE && $role <= 1) {
    $response['error'] = "You don't have the permissions to access this page.";
    echo json_encode($response);
    return;
}
$response['threshold'] = $Project->GetCoverageThreshold();
$SubProject = new SubProject();
$SubProject->SetProjectId($projectid);
if ($projectid >= 0) {
    $project = array();
    $project['id'] = $Project->Id;
Ejemplo n.º 8
0
  Language:  PHP
  Date:      $Date$
  Version:   $Revision$

  Copyright (c) Kitware, Inc. All rights reserved.
  See LICENSE or http://www.cdash.org/licensing/ for details.

  This software is distributed WITHOUT ANY WARRANTY; without even
  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  PURPOSE. See the above copyright notices for more information.
=========================================================================*/
require_once dirname(dirname(__DIR__)) . '/config/config.php';
require_once 'include/pdo.php';
require_once 'include/common.php';
$testid = pdo_real_escape_numeric($_GET['testid']);
$buildid = pdo_real_escape_numeric($_GET['buildid']);
$measurement = preg_replace('/[^\\da-z]/i', '', $_GET['measurement']);
$measurementname = htmlspecialchars(pdo_real_escape_string(stripslashes($measurement)));
if (!isset($buildid) || !is_numeric($buildid)) {
    echo 'Not a valid buildid!';
    return;
}
if (!isset($testid) || !is_numeric($testid)) {
    echo 'Not a valid testid!';
    return;
}
if (!isset($measurementname) || !is_string($measurementname)) {
    echo 'Not a valid measurementname!';
    return;
}
$db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}");
Ejemplo n.º 9
0
            $time = strtotime($startttime_array['starttime']);
        }
    }
    $dayFrom = date('d', $time);
    $monthFrom = date('m', $time);
    $yearFrom = date('Y', $time);
    $dayTo = date('d');
    $yearTo = date('Y');
    $monthTo = date('m');
} else {
    $dayFrom = pdo_real_escape_numeric($_POST['dayFrom']);
    $monthFrom = pdo_real_escape_numeric($_POST['monthFrom']);
    $yearFrom = pdo_real_escape_numeric($_POST['yearFrom']);
    $dayTo = pdo_real_escape_numeric($_POST['dayTo']);
    $monthTo = pdo_real_escape_numeric($_POST['monthTo']);
    $yearTo = pdo_real_escape_numeric($_POST['yearTo']);
}
$xml = '<cdash>';
$xml .= '<cssfile>' . $CDASH_CSS_FILE . '</cssfile>';
$xml .= '<version>' . $CDASH_VERSION . '</version>';
$xml .= '<title>CDash - Remove Builds</title>';
$xml .= '<menutitle>CDash</menutitle>';
$xml .= '<menusubtitle>Remove Builds</menusubtitle>';
$xml .= '<backurl>manageBackup.php</backurl>';
// List the available projects
$sql = 'SELECT id,name FROM project';
$projects = pdo_query($sql);
while ($projects_array = pdo_fetch_array($projects)) {
    $xml .= '<availableproject>';
    $xml .= add_XML_value('id', $projects_array['id']);
    $xml .= add_XML_value('name', $projects_array['name']);
Ejemplo n.º 10
0
/** Authentication function */
function auth($SessionCachePolicy = 'private_no_expire')
{
    include "cdash/config.php";
    $loginid = 1231564132;
    if (isset($CDASH_EXTERNAL_AUTH) && $CDASH_EXTERNAL_AUTH && isset($_SERVER['REMOTE_USER'])) {
        $login = $_SERVER['REMOTE_USER'];
        return authenticate($login, NULL, $SessionCachePolicy, 0);
        // we don't remember
    }
    if (@$_GET["logout"]) {
        // user requested logout
        session_name("CDash");
        session_cache_limiter('nocache');
        @session_start();
        unset($_SESSION['cdash']);
        session_destroy();
        // Remove the cookie if we have one
        $cookienames = array("CDash", str_replace('.', '_', "CDash-" . $_SERVER['SERVER_NAME']));
        // php doesn't like dot in cookie names
        foreach ($cookienames as $cookiename) {
            if (isset($_COOKIE[$cookiename])) {
                $cookievalue = $_COOKIE[$cookiename];
                $cookieuseridkey = substr($cookievalue, 0, strlen($cookievalue) - 33);
                $db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}");
                pdo_select_db("{$CDASH_DB_NAME}", $db);
                pdo_query("UPDATE " . qid("user") . " SET cookiekey='' WHERE id=" . qnum($cookieuseridkey));
                setcookie("CDash-" . $_SERVER['SERVER_NAME'], "", time() - 3600);
            }
        }
        echo "<script language=\"javascript\">window.location='index.php'</script>";
        return 0;
    }
    if (isset($_POST["sent"])) {
        @($login = $_POST["login"]);
        if ($login != NULL) {
            $login = htmlspecialchars(pdo_real_escape_string($login));
        }
        @($passwd = $_POST["passwd"]);
        if ($passwd != NULL) {
            $passwd = htmlspecialchars(pdo_real_escape_string($passwd));
        }
        @($rememberme = $_POST["rememberme"]);
        if ($rememberme != NULL) {
            $rememberme = pdo_real_escape_numeric($rememberme);
        }
        return authenticate($login, $passwd, $SessionCachePolicy, $rememberme);
    } else {
        // arrive from session var
        $cookiename = str_replace('.', '_', "CDash-" . $_SERVER['SERVER_NAME']);
        // php doesn't like dot in cookie names
        if (isset($_COOKIE[$cookiename])) {
            $db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}");
            pdo_select_db("{$CDASH_DB_NAME}", $db);
            $cookievalue = $_COOKIE[$cookiename];
            $cookiekey = substr($cookievalue, strlen($cookievalue) - 33);
            $cookieuseridkey = substr($cookievalue, 0, strlen($cookievalue) - 33);
            $sql = "SELECT email,password,id FROM " . qid("user") . "\n         WHERE cookiekey='" . pdo_real_escape_string($cookiekey) . "'";
            if (!empty($cookieuseridkey)) {
                $sql .= " AND id='" . pdo_real_escape_string($cookieuseridkey) . "'";
            }
            $result = pdo_query("{$sql}");
            if (pdo_num_rows($result) == 1) {
                $user_array = pdo_fetch_array($result);
                session_name("CDash");
                session_cache_limiter($SessionCachePolicy);
                session_set_cookie_params($CDASH_COOKIE_EXPIRATION_TIME);
                @ini_set('session.gc_maxlifetime', $CDASH_COOKIE_EXPIRATION_TIME + 600);
                session_start();
                $sessionArray = array("login" => $user_array['email'], "passwd" => $user_array['password'], "ID" => session_id(), "valid" => 1, "loginid" => $user_array['id']);
                $_SESSION['cdash'] = $sessionArray;
                return true;
            }
        }
        session_name("CDash");
        session_cache_limiter($SessionCachePolicy);
        session_set_cookie_params($CDASH_COOKIE_EXPIRATION_TIME);
        @ini_set('session.gc_maxlifetime', $CDASH_COOKIE_EXPIRATION_TIME + 600);
        session_start();
        $email = @$_SESSION['cdash']["login"];
        if (!empty($email)) {
            $db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}");
            pdo_select_db("{$CDASH_DB_NAME}", $db);
            $sql = "SELECT id,password FROM " . qid("user") . " WHERE email='" . pdo_real_escape_string($email) . "'";
            $result = pdo_query("{$sql}");
            if (pdo_num_rows($result) == 0) {
                pdo_free_result($result);
                $loginerror = "Wrong email or password.";
                return false;
            }
            $user_array = pdo_fetch_array($result);
            if ($user_array["password"] == $_SESSION['cdash']["passwd"]) {
                return true;
            }
            $loginerror = "Wrong email or password.";
            return false;
        }
    }
}
Ejemplo n.º 11
0
  Copyright (c) 2002 Kitware, Inc.  All rights reserved.
  See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.
  Copyright (c) 2012 Volkan Gezer <*****@*****.**>
=========================================================================*/
include "cdash/config.php";
require_once "cdash/pdo.php";
include 'login.php';
include_once "cdash/common.php";
include_once "models/project.php";
if ($session_OK) {
    $projectid = pdo_real_escape_numeric($_REQUEST["projectid"]);
    checkUserPolicy(@$_SESSION['cdash']['loginid'], $projectid);
    // Checks
    if (!isset($projectid) || !is_numeric($projectid)) {
        echo "Not a valid projectid!";
        return;
    }
    $project = pdo_query("SELECT * FROM project WHERE id='{$projectid}'");
    if (pdo_num_rows($project) > 0) {
        $project_array = pdo_fetch_array($project);
        $projectname = $project_array["name"];
        $nightlytime = $project_array["nightlytime"];
    }
    $submit = $_POST['submit'];
    $nameN = htmlspecialchars(pdo_real_escape_string($_POST['nameN']));
    $showTN = htmlspecialchars(pdo_real_escape_string($_POST['showTN']));
Ejemplo n.º 12
0
function rest_post()
{
    global $buildid;
    // Lookup some details about this build.
    $build = pdo_query("SELECT name, type, siteid, projectid FROM build WHERE id='{$buildid}'");
    $build_array = pdo_fetch_array($build);
    $buildtype = $build_array['type'];
    $buildname = $build_array['name'];
    $siteid = $build_array['siteid'];
    $projectid = $build_array['projectid'];
    // Should we change whether or not this build is expected?
    if (isset($_POST['expected']) && isset($_POST['groupid'])) {
        $expected = pdo_real_escape_numeric($_POST['expected']);
        $groupid = pdo_real_escape_numeric($_POST['groupid']);
        // If a rule already exists we update it.
        $build2groupexpected = pdo_query("SELECT groupid FROM build2grouprule\n                WHERE groupid='{$groupid}' AND buildtype='{$buildtype}' AND\n                buildname='{$buildname}' AND siteid='{$siteid}' AND\n                endtime='1980-01-01 00:00:00'");
        if (pdo_num_rows($build2groupexpected) > 0) {
            pdo_query("UPDATE build2grouprule SET expected='{$expected}'\n                    WHERE groupid='{$groupid}' AND buildtype='{$buildtype}' AND\n                    buildname='{$buildname}' AND siteid='{$siteid}' AND\n                    endtime='1980-01-01 00:00:00'");
        } elseif ($expected) {
            // we add the grouprule
            $now = gmdate(FMT_DATETIME);
            pdo_query("INSERT INTO build2grouprule\n                    (groupid, buildtype, buildname, siteid, expected,\n                     starttime, endtime)\n                    VALUES\n                    ('{$groupid}','{$buildtype}','{$buildname}','{$siteid}','{$expected}',\n                     '{$now}','1980-01-01 00:00:00')");
        }
    }
    // Should we move this build to a different group?
    if (isset($_POST['expected']) && isset($_POST['newgroupid'])) {
        $expected = pdo_real_escape_numeric($_POST['expected']);
        $newgroupid = pdo_real_escape_numeric($_POST['newgroupid']);
        // Remove the build from its previous group.
        $prevgroup = pdo_fetch_array(pdo_query("SELECT groupid as id FROM build2group WHERE buildid='{$buildid}'"));
        $prevgroupid = $prevgroup['id'];
        pdo_query("DELETE FROM build2group\n                WHERE groupid='{$prevgroupid}' AND buildid='{$buildid}'");
        // Insert it into the new group.
        pdo_query("INSERT INTO build2group(groupid,buildid)\n                VALUES ('{$newgroupid}','{$buildid}')");
        // Mark any previous buildgroup rule as finished as of this time.
        $now = gmdate(FMT_DATETIME);
        pdo_query("UPDATE build2grouprule SET endtime='{$now}'\n                WHERE groupid='{$prevgroupid}' AND buildtype='{$buildtype}' AND\n                buildname='{$buildname}' AND siteid='{$siteid}' AND\n                endtime='1980-01-01 00:00:00'");
        // Create the rule for the new buildgroup.
        // (begin time is set by default by mysql)
        pdo_query("INSERT INTO build2grouprule(groupid, buildtype, buildname, siteid,\n            expected, starttime, endtime)\n                VALUES ('{$newgroupid}','{$buildtype}','{$buildname}','{$siteid}','{$expected}',\n                    '{$now}','1980-01-01 00:00:00')");
    }
    // Should we change the 'done' setting for this build?
    if (isset($_POST['done'])) {
        $done = pdo_real_escape_numeric($_POST['done']);
        pdo_query("UPDATE build SET done='{$done}' WHERE id='{$buildid}'");
    }
}
Ejemplo n.º 13
0
 $xml .= "<menutitle>CDash</menutitle>";
 $xml .= "<menusubtitle>Project Roles</menusubtitle>";
 // Form post
 @($adduser = $_POST["adduser"]);
 @($removeuser = $_POST["removeuser"]);
 @($userid = $_POST["userid"]);
 if ($userid != NULL) {
     $userid = pdo_real_escape_numeric($userid);
 }
 @($role = $_POST["role"]);
 if ($role != NULL) {
     $role = pdo_real_escape_numeric($role);
 }
 @($emailtype = $_POST["emailtype"]);
 if ($emailtype != NULL) {
     $emailtype = pdo_real_escape_numeric($emailtype);
 }
 @($credentials = $_POST["credentials"]);
 @($repositoryCredential = $_POST["repositoryCredential"]);
 @($updateuser = $_POST["updateuser"]);
 @($importUsers = $_POST["importUsers"]);
 @($registerUsers = $_POST["registerUsers"]);
 @($registerUser = $_POST["registerUser"]);
 function make_seed_recoverpass()
 {
     list($usec, $sec) = explode(' ', microtime());
     return (double) $sec + (double) $usec * 100000;
 }
 // Register a user and send the email
 function register_user($projectid, $email, $firstName, $lastName, $repositoryCredential)
 {
Ejemplo n.º 14
0
     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
// To be able to access files in this CDash installation regardless
// of getcwd() value:
//
$cdashpath = str_replace('\\', '/', dirname(dirname(__FILE__)));
set_include_path($cdashpath . PATH_SEPARATOR . get_include_path());
require_once "cdash/config.php";
require_once "cdash/pdo.php";
require_once "cdash/common.php";
$projectid = pdo_real_escape_numeric($_GET["projectid"]);
$testname = htmlspecialchars(pdo_real_escape_string($_GET["testname"]));
$starttime = pdo_real_escape_numeric($_GET["starttime"]);
@($zoomout = $_GET["zoomout"]);
if (!isset($projectid) || !is_numeric($projectid)) {
    echo "Not a valid projectid!";
    return;
}
if (!isset($testname)) {
    echo "Not a valid test name!";
    return;
}
if (!isset($starttime)) {
    echo "Not a valid starttime!";
    return;
}
$db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}");
pdo_select_db("{$CDASH_DB_NAME}", $db);
Ejemplo n.º 15
0
             $User->Id = $userid;
             $email = $User->GetEmail();
             cdashmail("{$email}", $title, $messagePlainText, "From: CDash <" . $CDASH_EMAIL_FROM . ">\nReply-To: " . $CDASH_EMAIL_REPLY . "\nContent-type: text/plain; charset=utf-8\nX-Mailer: PHP/" . phpversion() . "\nMIME-Version: 1.0");
             $xml .= add_XML_value("warning", "*The email has been sent successfully.");
         } else {
             $xml .= add_XML_value("warning", "*No email sent because the coverage is green.");
         }
     }
 }
 // end sendEmail
 // If we change the priority
 if (isset($_POST['prioritySelection'])) {
     $CoverageFile2User = new CoverageFile2User();
     $CoverageFile2User->ProjectId = $projectid;
     $CoverageFile2User->FullPath = htmlspecialchars(pdo_real_escape_string($_POST['fullpath']));
     $CoverageFile2User->SetPriority(pdo_real_escape_numeric($_POST['prioritySelection']));
 }
 /** We start generating the XML here */
 // Find the recent builds for this project
 if ($projectid > 0) {
     $xml .= "<project>";
     $xml .= add_XML_value("id", $Project->Id);
     $xml .= add_XML_value("name", $Project->GetName());
     $xml .= add_XML_value("name_encoded", urlencode($Project->GetName()));
     if ($buildid > 0) {
         $xml .= add_XML_value("buildid", $buildid);
     }
     $CoverageSummary = new CoverageSummary();
     $buildids = $CoverageSummary->GetBuilds($Project->Id, $beginUTCTime, $currentUTCTime);
     rsort($buildids);
     foreach ($buildids as $buildId) {
Ejemplo n.º 16
0
function echo_main_dashboard_JSON($project_instance, $date)
{
    $start = microtime_float();
    $noforcelogin = 1;
    include_once dirname(dirname(dirname(__DIR__))) . '/config/config.php';
    require_once 'include/pdo.php';
    include 'public/login.php';
    include_once 'models/banner.php';
    include_once 'models/build.php';
    include_once 'models/subproject.php';
    $response = array();
    $db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}");
    if (!$db) {
        $response['error'] = 'Error connecting to CDash database server';
        echo json_encode($response);
        return;
    }
    if (!pdo_select_db("{$CDASH_DB_NAME}", $db)) {
        $response['error'] = 'Error selecting CDash database';
        echo json_encode($response);
        return;
    }
    $projectid = $project_instance->Id;
    $project = pdo_query("SELECT * FROM project WHERE id='{$projectid}'");
    if (pdo_num_rows($project) > 0) {
        $project_array = pdo_fetch_array($project);
        $projectname = $project_array['name'];
        if (isset($project_array['testingdataurl']) && $project_array['testingdataurl'] != '') {
            $testingdataurl = make_cdash_url(htmlentities($project_array['testingdataurl']));
        }
    } else {
        $response['error'] = "This project doesn't exist. Maybe the URL you are trying to access is wrong.";
        echo json_encode($response);
        return;
    }
    if (!checkUserPolicy(@$_SESSION['cdash']['loginid'], $project_array['id'], 1)) {
        $response['requirelogin'] = 1;
        echo json_encode($response);
        return;
    }
    $response = begin_JSON_response();
    $response['title'] = "CDash - {$projectname}";
    $response['feed'] = $CDASH_ENABLE_FEED;
    $response['showcalendar'] = 1;
    $Banner = new Banner();
    $Banner->SetProjectId(0);
    $text = $Banner->GetText();
    $banners = array();
    if ($text !== false) {
        $banners[] = $text;
    }
    $Banner->SetProjectId($projectid);
    $text = $Banner->GetText();
    if ($text !== false) {
        $banners[] = $text;
    }
    $response['banners'] = $banners;
    $site_response = array();
    // If parentid is set we need to lookup the date for this build
    // because it is not specified as a query string parameter.
    if (isset($_GET['parentid'])) {
        $parentid = pdo_real_escape_numeric($_GET['parentid']);
        $parent_build = new Build();
        $parent_build->Id = $parentid;
        $date = $parent_build->GetDate();
        $response['parentid'] = $parentid;
    } else {
        $response['parentid'] = -1;
    }
    list($previousdate, $currentstarttime, $nextdate) = get_dates($date, $project_array['nightlytime']);
    // Main dashboard section
    get_dashboard_JSON($projectname, $date, $response);
    $response['displaylabels'] = $project_array['displaylabels'];
    $page_id = 'index.php';
    $response['childview'] = 0;
    if ($CDASH_USE_LOCAL_DIRECTORY && file_exists('local/models/proProject.php')) {
        include_once 'local/models/proProject.php';
        $pro = new proProject();
        $pro->ProjectId = $projectid;
        $response['proedition'] = $pro->GetEdition(1);
    }
    if ($currentstarttime > time() && !isset($_GET['parentid'])) {
        $response['error'] = 'CDash cannot predict the future (yet)';
        echo json_encode($response);
        return;
    }
    // Menu definition
    $response['menu'] = array();
    $beginning_timestamp = $currentstarttime;
    $end_timestamp = $currentstarttime + 3600 * 24;
    $beginning_UTCDate = gmdate(FMT_DATETIME, $beginning_timestamp);
    $end_UTCDate = gmdate(FMT_DATETIME, $end_timestamp);
    if ($project_instance->GetNumberOfSubProjects($end_UTCDate) > 0) {
        $response['menu']['subprojects'] = 1;
    }
    if (isset($_GET['parentid'])) {
        $page_id = 'indexchildren.php';
        $response['childview'] = 1;
        // When a parentid is specified, we should link to the next build,
        // not the next day.
        $previous_buildid = $parent_build->GetPreviousBuildId();
        $current_buildid = $parent_build->GetCurrentBuildId();
        $next_buildid = $parent_build->GetNextBuildId();
        $base_url = 'index.php?project=' . urlencode($projectname);
        if ($previous_buildid > 0) {
            $response['menu']['previous'] = "{$base_url}&parentid={$previous_buildid}";
        } else {
            $response['menu']['noprevious'] = '1';
        }
        $response['menu']['current'] = "{$base_url}&parentid={$current_buildid}";
        if ($next_buildid > 0) {
            $response['menu']['next'] = "{$base_url}&parentid={$next_buildid}";
        } else {
            $response['menu']['nonext'] = '1';
        }
    } elseif (!has_next_date($date, $currentstarttime)) {
        $response['menu']['nonext'] = 1;
    }
    // Check if a SubProject parameter was specified.
    $subproject_name = @$_GET['subproject'];
    $subprojectid = false;
    if ($subproject_name) {
        $SubProject = new SubProject();
        $subproject_name = htmlspecialchars(pdo_real_escape_string($subproject_name));
        $SubProject->SetName($subproject_name);
        $SubProject->SetProjectId($projectid);
        $subprojectid = $SubProject->GetId();
        if ($subprojectid) {
            // Add an extra URL argument for the menu
            $response['extraurl'] = '&subproject=' . urlencode($subproject_name);
            $response['subprojectname'] = $subproject_name;
            $subproject_response = array();
            $subproject_response['name'] = $SubProject->GetName();
            $dependencies = $SubProject->GetDependencies();
            if ($dependencies) {
                $dependencies_response = array();
                foreach ($dependencies as $dependency) {
                    $dependency_response = array();
                    $DependProject = new SubProject();
                    $DependProject->SetId($dependency);
                    $dependency_response['name'] = $DependProject->GetName();
                    $dependency_response['name_encoded'] = urlencode($DependProject->GetName());
                    $dependency_response['nbuilderror'] = $DependProject->GetNumberOfErrorBuilds($beginning_UTCDate, $end_UTCDate);
                    $dependency_response['nbuildwarning'] = $DependProject->GetNumberOfWarningBuilds($beginning_UTCDate, $end_UTCDate);
                    $dependency_response['nbuildpass'] = $DependProject->GetNumberOfPassingBuilds($beginning_UTCDate, $end_UTCDate);
                    $dependency_response['nconfigureerror'] = $DependProject->GetNumberOfErrorConfigures($beginning_UTCDate, $end_UTCDate);
                    $dependency_response['nconfigurewarning'] = $DependProject->GetNumberOfWarningConfigures($beginning_UTCDate, $end_UTCDate);
                    $dependency_response['nconfigurepass'] = $DependProject->GetNumberOfPassingConfigures($beginning_UTCDate, $end_UTCDate);
                    $dependency_response['ntestpass'] = $DependProject->GetNumberOfPassingTests($beginning_UTCDate, $end_UTCDate);
                    $dependency_response['ntestfail'] = $DependProject->GetNumberOfFailingTests($beginning_UTCDate, $end_UTCDate);
                    $dependency_response['ntestnotrun'] = $DependProject->GetNumberOfNotRunTests($beginning_UTCDate, $end_UTCDate);
                    if (strlen($DependProject->GetLastSubmission()) == 0) {
                        $dependency_response['lastsubmission'] = 'NA';
                    } else {
                        $dependency_response['lastsubmission'] = $DependProject->GetLastSubmission();
                    }
                    $dependencies_response[] = $dependency_response;
                }
                $subproject_response['dependencies'] = $dependencies_response;
            }
            $response['subproject'] = $subproject_response;
        } else {
            add_log("SubProject '{$subproject_name}' does not exist", __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_WARNING);
        }
    }
    if (isset($testingdataurl)) {
        $response['testingdataurl'] = $testingdataurl;
    }
    // updates
    $updates_response = array();
    $gmdate = gmdate(FMT_DATE, $currentstarttime);
    $updates_response['url'] = 'viewChanges.php?project=' . urlencode($projectname) . '&amp;date=' . $gmdate;
    $dailyupdate = pdo_query("SELECT count(ds.dailyupdateid),count(distinct ds.author)\n            FROM dailyupdate AS d LEFT JOIN dailyupdatefile AS ds ON (ds.dailyupdateid = d.id)\n            WHERE d.date='{$gmdate}' and d.projectid='{$projectid}' GROUP BY ds.dailyupdateid");
    if (pdo_num_rows($dailyupdate) > 0) {
        $dailupdate_array = pdo_fetch_array($dailyupdate);
        $updates_response['nchanges'] = $dailupdate_array[0];
        $updates_response['nauthors'] = $dailupdate_array[1];
    } else {
        $updates_response['nchanges'] = -1;
    }
    $updates_response['timestamp'] = date('l, F d Y - H:i T', $currentstarttime);
    $response['updates'] = $updates_response;
    // This array is used to track if expected builds are found or not.
    $received_builds = array();
    // Get info about our buildgroups.
    $buildgroups_response = array();
    $buildgroup_result = pdo_query("SELECT bg.id, bg.name, bgp.position FROM buildgroup AS bg\n            LEFT JOIN buildgroupposition AS bgp ON (bgp.buildgroupid=bg.id)\n            WHERE bg.projectid={$projectid} AND bg.starttime < '{$beginning_UTCDate}' AND\n            (bg.endtime > '{$beginning_UTCDate}' OR\n             bg.endtime='1980-01-01 00:00:00')");
    while ($buildgroup_array = pdo_fetch_array($buildgroup_result)) {
        $buildgroup_response = array();
        $groupname = $buildgroup_array['name'];
        $buildgroup_response['id'] = $buildgroup_array['id'];
        $buildgroup_response['name'] = $groupname;
        $buildgroup_response['linkname'] = str_replace(' ', '_', $groupname);
        $buildgroup_response['position'] = $buildgroup_array['position'];
        $buildgroup_response['numupdatedfiles'] = 0;
        $buildgroup_response['numupdateerror'] = 0;
        $buildgroup_response['numupdatewarning'] = 0;
        $buildgroup_response['updateduration'] = 0;
        $buildgroup_response['configureduration'] = 0;
        $buildgroup_response['numconfigureerror'] = 0;
        $buildgroup_response['numconfigurewarning'] = 0;
        $buildgroup_response['numbuilderror'] = 0;
        $buildgroup_response['numbuildwarning'] = 0;
        $buildgroup_response['numtestnotrun'] = 0;
        $buildgroup_response['numtestfail'] = 0;
        $buildgroup_response['numtestpass'] = 0;
        $buildgroup_response['testduration'] = 0;
        $buildgroup_response['hasupdatedata'] = false;
        $buildgroup_response['hasconfiguredata'] = false;
        $buildgroup_response['hascompilationdata'] = false;
        $buildgroup_response['hastestdata'] = false;
        $buildgroup_response['hasnormalbuilds'] = false;
        $buildgroup_response['hasparentbuilds'] = false;
        $buildgroup_response['builds'] = array();
        $received_builds[$groupname] = array();
        $buildgroups_response[] = $buildgroup_response;
    }
    // Filters:
    //
    $filterdata = get_filterdata_from_request($page_id);
    $filter_sql = $filterdata['sql'];
    $limit_sql = '';
    if ($filterdata['limit'] > 0) {
        $limit_sql = ' LIMIT ' . $filterdata['limit'];
    }
    unset($filterdata['xml']);
    $response['filterdata'] = $filterdata;
    $response['filterurl'] = get_filterurl();
    // Check if we should be excluding some SubProjects from our
    // build results.
    $include_subprojects = false;
    $exclude_subprojects = false;
    $included_subprojects = array();
    $excluded_subprojects = array();
    $selected_subprojects = '';
    $num_selected_subprojects = 0;
    $filter_on_labels = false;
    $share_label_filters = false;
    foreach ($filterdata['filters'] as $filter) {
        if ($filter['field'] == 'subprojects') {
            if ($filter['compare'] == 92) {
                $excluded_subprojects[] = $filter['value'];
            } elseif ($filter['compare'] == 93) {
                $included_subprojects[] = $filter['value'];
            }
        } elseif ($filter['field'] == 'label') {
            $filter_on_labels = true;
        }
    }
    if ($filter_on_labels && $project_instance->ShareLabelFilters) {
        $share_label_filters = true;
        $response['sharelabelfilters'] = true;
        $label_ids_array = get_label_ids_from_filterdata($filterdata);
        $label_ids = '(' . implode(', ', $label_ids_array) . ')';
    }
    // Include takes precedence over exclude.
    if (!empty($included_subprojects)) {
        $num_selected_subprojects = count($included_subprojects);
        $selected_subprojects = implode("','", $included_subprojects);
        $selected_subprojects = "('" . $selected_subprojects . "')";
        $include_subprojects = true;
    } elseif (!empty($excluded_subprojects)) {
        $num_selected_subprojects = count($excluded_subprojects);
        $selected_subprojects = implode("','", $excluded_subprojects);
        $selected_subprojects = "('" . $selected_subprojects . "')";
        $exclude_subprojects = true;
    }
    // add a request for the subproject
    $subprojectsql = '';
    if ($subproject_name && is_numeric($subprojectid)) {
        $subprojectsql = ' AND sp2b.subprojectid=' . $subprojectid;
    }
    // Use this as the default date clause, but if $filterdata has a date clause,
    // then cancel this one out:
    //
    $date_clause = "AND b.starttime<'{$end_UTCDate}' AND b.starttime>='{$beginning_UTCDate}' ";
    if ($filterdata['hasdateclause']) {
        $date_clause = '';
    }
    $parent_clause = '';
    if (isset($_GET['parentid'])) {
        // If we have a parentid, then we should only show children of that build.
        // Date becomes irrelevant in this case.
        $parent_clause = 'AND (b.parentid = ' . qnum($_GET['parentid']) . ') ';
        $date_clause = '';
    } elseif (empty($subprojectsql)) {
        // Only show builds that are not children.
        $parent_clause = 'AND (b.parentid = -1 OR b.parentid = 0) ';
    }
    $build_rows = array();
    // If the user is logged in we display if the build has some changes for him
    $userupdatesql = '';
    if (isset($_SESSION['cdash']) && array_key_exists('loginid', $_SESSION['cdash'])) {
        $userupdatesql = "(SELECT count(updatefile.updateid) FROM updatefile,build2update,user2project,\n            user2repository\n                WHERE build2update.buildid=b.id\n                AND build2update.updateid=updatefile.updateid\n                AND user2project.projectid=b.projectid\n                AND user2project.userid='" . $_SESSION['cdash']['loginid'] . "'\n                AND user2repository.userid=user2project.userid\n                AND (user2repository.projectid=0 OR user2repository.projectid=b.projectid)\n                AND user2repository.credential=updatefile.author) AS userupdates,";
    }
    $sql = get_index_query();
    $sql .= "WHERE b.projectid='{$projectid}' AND g.type='Daily'\n        {$parent_clause} {$date_clause} {$subprojectsql} {$filter_sql} {$limit_sql}";
    // We shouldn't get any builds for group that have been deleted (otherwise something is wrong)
    $builds = pdo_query($sql);
    // Log any errors
    $pdo_error = pdo_error();
    if (strlen($pdo_error) > 0) {
        add_log('SQL error: ' . $pdo_error, 'Index.php', LOG_ERR);
    }
    // Gather up results from this query.
    $build_data = array();
    while ($build_row = pdo_fetch_array($builds)) {
        $build_data[] = $build_row;
    }
    $dynamic_builds = array();
    if (empty($filter_sql)) {
        $dynamic_builds = get_dynamic_builds($projectid, $end_UTCDate);
        $build_data = array_merge($build_data, $dynamic_builds);
    }
    // Check if we need to summarize coverage by subproject groups.
    // This happens when we have subprojects and we're looking at the children
    // of a specific build.
    $coverage_groups = array();
    if (isset($_GET['parentid']) && $_GET['parentid'] > 0 && $project_instance->GetNumberOfSubProjects($end_UTCDate) > 0) {
        $groups = $project_instance->GetSubProjectGroups();
        foreach ($groups as $group) {
            // Keep track of coverage info on a per-group basis.
            $groupId = $group->GetId();
            $coverage_groups[$groupId] = array();
            $coverageThreshold = $group->GetCoverageThreshold();
            $coverage_groups[$groupId]['thresholdgreen'] = $coverageThreshold;
            $coverage_groups[$groupId]['thresholdyellow'] = $coverageThreshold * 0.7;
            $coverage_groups[$groupId]['label'] = $group->GetName();
            $coverage_groups[$groupId]['loctested'] = 0;
            $coverage_groups[$groupId]['locuntested'] = 0;
            $coverage_groups[$groupId]['position'] = $group->GetPosition();
            $coverage_groups[$groupId]['coverages'] = array();
        }
        if (count($groups) > 1) {
            // Add a Total group too.
            $coverage_groups[0] = array();
            $coverageThreshold = $project_array['coveragethreshold'];
            $coverage_groups[0]['thresholdgreen'] = $coverageThreshold;
            $coverage_groups[0]['thresholdyellow'] = $coverageThreshold * 0.7;
            $coverage_groups[0]['label'] = 'Total';
            $coverage_groups[0]['loctested'] = 0;
            $coverage_groups[0]['locuntested'] = 0;
            $coverage_groups[0]['position'] = 0;
        }
    }
    // Fetch all the rows of builds into a php array.
    // Compute additional fields for each row that we'll need to generate the xml.
    //
    $build_rows = array();
    foreach ($build_data as $build_row) {
        // Fields that come from the initial query:
        //  id
        //  sitename
        //  stamp
        //  name
        //  siteid
        //  type
        //  generator
        //  starttime
        //  endtime
        //  submittime
        //  groupname
        //  position
        //  groupid
        //  countupdatefiles
        //  updatestatus
        //  countupdatewarnings
        //  countbuildwarnings
        //  countbuilderrors
        //  countbuilderrordiff
        //  countbuildwarningdiff
        //  configureduration
        //  countconfigureerrors
        //  countconfigurewarnings
        //  countconfigurewarningdiff
        //  counttestsnotrun
        //  counttestsnotrundiff
        //  counttestsfailed
        //  counttestsfaileddiff
        //  counttestspassed
        //  counttestspasseddiff
        //  countteststimestatusfailed
        //  countteststimestatusfaileddiff
        //  testduration
        //
        // Fields that we add within this loop:
        //  maxstarttime
        //  buildids (array of buildids for summary rows)
        //  countbuildnotes (added by users)
        //  labels
        //  updateduration
        //  countupdateerrors
        //  test
        //
        $buildid = $build_row['id'];
        $groupid = $build_row['groupid'];
        $siteid = $build_row['siteid'];
        $parentid = $build_row['parentid'];
        $build_row['buildids'][] = $buildid;
        $build_row['maxstarttime'] = $build_row['starttime'];
        // Updates
        if (!empty($build_row['updatestarttime'])) {
            $build_row['updateduration'] = round((strtotime($build_row['updateendtime']) - strtotime($build_row['updatestarttime'])) / 60, 1);
        } else {
            $build_row['updateduration'] = 0;
        }
        if (strlen($build_row['updatestatus']) > 0 && $build_row['updatestatus'] != '0') {
            $build_row['countupdateerrors'] = 1;
        } else {
            $build_row['countupdateerrors'] = 0;
        }
        // Error/Warnings differences
        if (empty($build_row['countbuilderrordiffp'])) {
            $build_row['countbuilderrordiffp'] = 0;
        }
        if (empty($build_row['countbuilderrordiffn'])) {
            $build_row['countbuilderrordiffn'] = 0;
        }
        if (empty($build_row['countbuildwarningdiffp'])) {
            $build_row['countbuildwarningdiffp'] = 0;
        }
        if (empty($build_row['countbuildwarningdiffn'])) {
            $build_row['countbuildwarningdiffn'] = 0;
        }
        $build_row['hasconfigure'] = 0;
        if ($build_row['countconfigureerrors'] != -1 || $build_row['countconfigurewarnings'] != -1) {
            $build_row['hasconfigure'] = 1;
        }
        if ($build_row['countconfigureerrors'] < 0) {
            $build_row['countconfigureerrors'] = 0;
        }
        if ($build_row['countconfigurewarnings'] < 0) {
            $build_row['countconfigurewarnings'] = 0;
        }
        if (empty($build_row['countconfigurewarningdiff'])) {
            $build_row['countconfigurewarningdiff'] = 0;
        }
        $build_row['hastest'] = 0;
        if ($build_row['counttestsfailed'] != -1) {
            $build_row['hastest'] = 1;
        }
        if (empty($build_row['testduration'])) {
            $time_array = pdo_fetch_array(pdo_query("SELECT SUM(time) FROM build2test WHERE buildid='{$buildid}'"));
            $build_row['testduration'] = round($time_array[0], 1);
        } else {
            $build_row['testduration'] = round($build_row['testduration'], 1);
        }
        $build_rows[] = $build_row;
    }
    // Generate the JSON response from the rows of builds.
    $response['coverages'] = array();
    $response['dynamicanalyses'] = array();
    $num_nightly_coverages_builds = 0;
    $show_aggregate = false;
    $response['comparecoverage'] = 0;
    foreach ($build_rows as $build_array) {
        $groupid = $build_array['groupid'];
        // Find the buildgroup array for this build.
        $i = -1;
        for ($j = 0; $j < count($buildgroups_response); $j++) {
            if ($buildgroups_response[$j]['id'] == $groupid) {
                $i = $j;
                break;
            }
        }
        if ($i == -1) {
            add_log("BuildGroup '{$groupid}' not found for build #" . $build_array['id'], __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_WARNING);
            continue;
        }
        $groupname = $buildgroups_response[$i]['name'];
        $build_response = array();
        $received_builds[$groupname][] = $build_array['sitename'] . '_' . $build_array['name'];
        $buildid = $build_array['id'];
        $siteid = $build_array['siteid'];
        $countChildrenResult = pdo_single_row_query('SELECT count(id) AS numchildren
                FROM build WHERE parentid=' . qnum($buildid));
        $numchildren = $countChildrenResult['numchildren'];
        $build_response['numchildren'] = $numchildren;
        $child_builds_hyperlink = '';
        $selected_configure_errors = 0;
        $selected_configure_warnings = 0;
        $selected_configure_duration = 0;
        $selected_build_errors = 0;
        $selected_build_warnings = 0;
        $selected_build_duration = 0;
        $selected_tests_not_run = 0;
        $selected_tests_failed = 0;
        $selected_tests_passed = 0;
        $selected_test_duration = 0;
        if ($numchildren > 0) {
            $child_builds_hyperlink = get_child_builds_hyperlink($build_array['id'], $filterdata);
            $build_response['multiplebuildshyperlink'] = $child_builds_hyperlink;
            $buildgroups_response[$i]['hasparentbuilds'] = true;
            // Compute selected (excluded or included) SubProject results.
            if ($selected_subprojects) {
                $select_query = "\n                    SELECT configureerrors, configurewarnings, configureduration,\n                           builderrors, buildwarnings, buildduration,\n                           b.starttime, b.endtime, testnotrun, testfailed, testpassed,\n                           btt.time AS testduration, sb.name\n                    FROM build AS b\n                    INNER JOIN subproject2build AS sb2b ON (b.id = sb2b.buildid)\n                    INNER JOIN subproject AS sb ON (sb2b.subprojectid = sb.id)\n                    LEFT JOIN buildtesttime AS btt ON (b.id=btt.buildid)\n                    WHERE b.parentid={$buildid}\n                    AND sb.name IN {$selected_subprojects}";
                $select_results = pdo_query($select_query);
                while ($select_array = pdo_fetch_array($select_results)) {
                    $selected_configure_errors += max(0, $select_array['configureerrors']);
                    $selected_configure_warnings += max(0, $select_array['configurewarnings']);
                    $selected_configure_duration += max(0, $select_array['configureduration']);
                    $selected_build_errors += max(0, $select_array['builderrors']);
                    $selected_build_warnings += max(0, $select_array['buildwarnings']);
                    $selected_build_duration += max(0, $select_array['buildduration']);
                    $selected_tests_not_run += max(0, $select_array['testnotrun']);
                    $selected_tests_failed += max(0, $select_array['testfailed']);
                    $selected_tests_passed += max(0, $select_array['testpassed']);
                    $selected_test_duration += max(0, $select_array['testduration']);
                }
            }
        } else {
            $buildgroups_response[$i]['hasnormalbuilds'] = true;
        }
        if (strtolower($build_array['type']) == 'continuous') {
            $buildgroups_response[$i]['sorttype'] = 'time';
        }
        // Attempt to determine the platform based on the OSName and the buildname
        $buildplatform = '';
        if (strtolower(substr($build_array['osname'], 0, 7)) == 'windows') {
            $buildplatform = 'windows';
        } elseif (strtolower(substr($build_array['osname'], 0, 8)) == 'mac os x') {
            $buildplatform = 'mac';
        } elseif (strtolower(substr($build_array['osname'], 0, 5)) == 'linux' || strtolower(substr($build_array['osname'], 0, 3)) == 'aix') {
            $buildplatform = 'linux';
        } elseif (strtolower(substr($build_array['osname'], 0, 7)) == 'freebsd') {
            $buildplatform = 'freebsd';
        } elseif (strtolower(substr($build_array['osname'], 0, 3)) == 'gnu') {
            $buildplatform = 'gnu';
        }
        // Add link based on changeid if appropriate.
        $changelink = null;
        $changeicon = null;
        if ($build_array['changeid'] && $project_instance->CvsViewerType === 'github') {
            $changelink = $project_instance->CvsUrl . '/pull/' . $build_array['changeid'];
            $changeicon = 'img/Octocat.png';
        }
        if (isset($_GET['parentid'])) {
            if (empty($site_response)) {
                $site_response['site'] = $build_array['sitename'];
                $site_response['siteoutoforder'] = $build_array['siteoutoforder'];
                $site_response['siteid'] = $siteid;
                $site_response['buildname'] = $build_array['name'];
                $site_response['buildplatform'] = $buildplatform;
                $site_response['generator'] = $build_array['generator'];
                if (!is_null($changelink)) {
                    $site_response['changelink'] = $changelink;
                    $site_response['changeicon'] = $changeicon;
                }
            }
        } else {
            $build_response['site'] = $build_array['sitename'];
            $build_response['siteoutoforder'] = $build_array['siteoutoforder'];
            $build_response['siteid'] = $siteid;
            $build_response['buildname'] = $build_array['name'];
            $build_response['buildplatform'] = $buildplatform;
            if (!is_null($changelink)) {
                $build_response['changelink'] = $changelink;
                $build_response['changeicon'] = $changeicon;
            }
        }
        if (isset($build_array['userupdates'])) {
            $build_response['userupdates'] = $build_array['userupdates'];
        }
        $build_response['id'] = $build_array['id'];
        $build_response['done'] = $build_array['done'];
        $build_response['uploadfilecount'] = $build_array['builduploadfiles'];
        $build_response['buildnotes'] = $build_array['countbuildnotes'];
        $build_response['notes'] = $build_array['countnotes'];
        // Figure out how many labels to report for this build.
        if (!array_key_exists('numlabels', $build_array) || $build_array['numlabels'] == 0) {
            $num_labels = 0;
        } else {
            $num_labels = $build_array['numlabels'];
        }
        $label_query = 'SELECT l.text FROM label AS l
            INNER JOIN label2build AS l2b ON (l.id=l2b.labelid)
            INNER JOIN build AS b ON (l2b.buildid=b.id)
            WHERE b.id=' . qnum($buildid);
        $build_labels = array();
        if ($num_selected_subprojects > 0) {
            // Special handling for whitelisting/blacklisting SubProjects.
            if ($include_subprojects) {
                $num_labels = 0;
            }
            $labels_result = pdo_query($label_query);
            while ($label_row = pdo_fetch_array($labels_result)) {
                // Whitelist case
                if ($include_subprojects && in_array($label_row['text'], $included_subprojects)) {
                    $num_labels++;
                    $build_labels[] = $label_row['text'];
                }
                // Blacklist case
                if ($exclude_subprojects) {
                    if (in_array($label_row['text'], $excluded_subprojects)) {
                        $num_labels--;
                    } else {
                        $build_labels[] = $label_row['text'];
                    }
                }
            }
            if ($num_labels === 0) {
                // Skip this build entirely if none of its SubProjects
                // survived filtering.
                continue;
            }
        }
        // Assign a label to this build based on how many labels it has.
        if ($num_labels == 0) {
            $build_label = '(none)';
        } elseif ($num_labels == 1) {
            // Exactly one label for this build
            if (!empty($build_labels)) {
                // If we're whitelisting or blacklisting we've already figured
                // out what this label is.
                $build_label = $build_labels[0];
            } else {
                // Otherwise we look it up here.
                $label_result = pdo_single_row_query($label_query);
                $build_label = $label_result['text'];
            }
        } else {
            // More than one label, just report the number.
            $build_label = "({$num_labels} labels)";
        }
        $build_response['label'] = $build_label;
        // Calculate this build's total duration.
        $duration = strtotime($build_array['endtime']) - strtotime($build_array['starttime']);
        $build_response['time'] = time_difference($duration, true);
        $build_response['timefull'] = $duration;
        $update_response = array();
        $countupdatefiles = $build_array['countupdatefiles'];
        $update_response['files'] = $countupdatefiles;
        $buildgroups_response[$i]['numupdatedfiles'] += $countupdatefiles;
        $build_response['hasupdate'] = false;
        if (!empty($build_array['updatestarttime'])) {
            $build_response['hasupdate'] = true;
            if ($build_array['countupdateerrors'] > 0) {
                $update_response['errors'] = 1;
                $buildgroups_response[$i]['numupdateerror'] += 1;
            } else {
                $update_response['errors'] = 0;
                if ($build_array['countupdatewarnings'] > 0) {
                    $update_response['warning'] = 1;
                    $buildgroups_response[$i]['numupdatewarning'] += 1;
                }
            }
            $duration = $build_array['updateduration'];
            $update_response['time'] = time_difference($duration * 60.0, true);
            $update_response['timefull'] = $duration;
            $buildgroups_response[$i]['updateduration'] += $duration;
            $buildgroups_response[$i]['hasupdatedata'] = true;
            $build_response['update'] = $update_response;
        }
        $compilation_response = array();
        if ($build_array['countbuilderrors'] >= 0) {
            if ($include_subprojects) {
                $nerrors = $selected_build_errors;
                $nwarnings = $selected_build_warnings;
                $buildduration = $selected_build_duration;
            } else {
                $nerrors = $build_array['countbuilderrors'] - $selected_build_errors;
                $nwarnings = $build_array['countbuildwarnings'] - $selected_build_warnings;
                $buildduration = $build_array['buildduration'] - $selected_build_duration;
            }
            $compilation_response['error'] = $nerrors;
            $buildgroups_response[$i]['numbuilderror'] += $nerrors;
            $compilation_response['warning'] = $nwarnings;
            $buildgroups_response[$i]['numbuildwarning'] += $nwarnings;
            $compilation_response['time'] = time_difference($buildduration, true);
            $compilation_response['timefull'] = $buildduration;
            if (!$include_subprojects && !$exclude_subprojects) {
                // Don't show diff when filtering by SubProject.
                $compilation_response['nerrordiffp'] = $build_array['countbuilderrordiffp'];
                $compilation_response['nerrordiffn'] = $build_array['countbuilderrordiffn'];
                $compilation_response['nwarningdiffp'] = $build_array['countbuildwarningdiffp'];
                $compilation_response['nwarningdiffn'] = $build_array['countbuildwarningdiffn'];
            }
        }
        $build_response['hascompilation'] = false;
        if (!empty($compilation_response)) {
            $build_response['hascompilation'] = true;
            $build_response['compilation'] = $compilation_response;
            $buildgroups_response[$i]['hascompilationdata'] = true;
        }
        $build_response['hasconfigure'] = false;
        if ($build_array['hasconfigure'] != 0) {
            $build_response['hasconfigure'] = true;
            $configure_response = array();
            if ($include_subprojects) {
                $nconfigureerrors = $selected_configure_errors;
                $nconfigurewarnings = $selected_configure_warnings;
                $configureduration = $selected_configure_duration;
            } else {
                $nconfigureerrors = $build_array['countconfigureerrors'] - $selected_configure_errors;
                $nconfigurewarnings = $build_array['countconfigurewarnings'] - $selected_configure_warnings;
                $configureduration = $build_array['configureduration'] - $selected_configure_duration;
            }
            $configure_response['error'] = $nconfigureerrors;
            $buildgroups_response[$i]['numconfigureerror'] += $nconfigureerrors;
            $configure_response['warning'] = $nconfigurewarnings;
            $buildgroups_response[$i]['numconfigurewarning'] += $nconfigurewarnings;
            if (!$include_subprojects && !$exclude_subprojects) {
                $configure_response['warningdiff'] = $build_array['countconfigurewarningdiff'];
            }
            $configure_response['time'] = time_difference($configureduration, true);
            $configure_response['timefull'] = $configureduration;
            $build_response['configure'] = $configure_response;
            $buildgroups_response[$i]['hasconfiguredata'] = true;
            $buildgroups_response[$i]['configureduration'] += $configureduration;
        }
        $build_response['hastest'] = false;
        if ($build_array['hastest'] != 0) {
            $build_response['hastest'] = true;
            $buildgroups_response[$i]['hastestdata'] = true;
            $test_response = array();
            if ($include_subprojects) {
                $nnotrun = $selected_tests_not_run;
                $nfail = $selected_tests_failed;
                $npass = $selected_tests_passed;
                $testduration = $selected_test_duration;
            } else {
                $nnotrun = $build_array['counttestsnotrun'] - $selected_tests_not_run;
                $nfail = $build_array['counttestsfailed'] - $selected_tests_failed;
                $npass = $build_array['counttestspassed'] - $selected_tests_passed;
                $testduration = $build_array['testduration'] - $selected_test_duration;
            }
            if (!$include_subprojects && !$exclude_subprojects) {
                $test_response['nnotrundiffp'] = $build_array['counttestsnotrundiffp'];
                $test_response['nnotrundiffn'] = $build_array['counttestsnotrundiffn'];
                $test_response['nfaildiffp'] = $build_array['counttestsfaileddiffp'];
                $test_response['nfaildiffn'] = $build_array['counttestsfaileddiffn'];
                $test_response['npassdiffp'] = $build_array['counttestspasseddiffp'];
                $test_response['npassdiffn'] = $build_array['counttestspasseddiffn'];
            }
            if ($project_array['showtesttime'] == 1) {
                $test_response['timestatus'] = $build_array['countteststimestatusfailed'];
                $test_response['ntimediffp'] = $build_array['countteststimestatusfaileddiffp'];
                $test_response['ntimediffn'] = $build_array['countteststimestatusfaileddiffn'];
            }
            if ($share_label_filters) {
                $label_query_base = "SELECT b2t.status, b2t.newstatus\n                    FROM build2test AS b2t\n                    INNER JOIN label2test AS l2t ON\n                    (l2t.testid=b2t.testid AND l2t.buildid=b2t.buildid)\n                    WHERE b2t.buildid = '{$buildid}' AND\n                    l2t.labelid IN {$label_ids}";
                $label_filter_query = $label_query_base . $limit_sql;
                $labels_result = pdo_query($label_filter_query);
                $nnotrun = 0;
                $nfail = 0;
                $npass = 0;
                $test_response['nfaildiffp'] = 0;
                $test_response['nfaildiffn'] = 0;
                $test_response['npassdiffp'] = 0;
                $test_response['npassdiffn'] = 0;
                $test_response['nnotrundiffp'] = 0;
                $test_response['nnotrundiffn'] = 0;
                while ($label_row = pdo_fetch_array($labels_result)) {
                    switch ($label_row['status']) {
                        case 'passed':
                            $npass++;
                            if ($label_row['newstatus'] == 1) {
                                $test_response['npassdiffp']++;
                            }
                            break;
                        case 'failed':
                            $nfail++;
                            if ($label_row['newstatus'] == 1) {
                                $test_response['nfaildiffp']++;
                            }
                            break;
                        case 'notrun':
                            $nnotrun++;
                            if ($label_row['newstatus'] == 1) {
                                $test_response['nnotrundiffp']++;
                            }
                            break;
                    }
                }
            }
            $test_response['notrun'] = $nnotrun;
            $test_response['fail'] = $nfail;
            $test_response['pass'] = $npass;
            $buildgroups_response[$i]['numtestnotrun'] += $nnotrun;
            $buildgroups_response[$i]['numtestfail'] += $nfail;
            $buildgroups_response[$i]['numtestpass'] += $npass;
            $test_response['time'] = time_difference($testduration, true);
            $test_response['timefull'] = $testduration;
            $buildgroups_response[$i]['testduration'] += $testduration;
            $build_response['test'] = $test_response;
        }
        $starttimestamp = strtotime($build_array['starttime'] . ' UTC');
        $submittimestamp = strtotime($build_array['submittime'] . ' UTC');
        // Use the default timezone.
        $build_response['builddatefull'] = $starttimestamp;
        // If the data is more than 24h old then we switch from an elapsed to a normal representation
        if (time() - $starttimestamp < 86400) {
            $build_response['builddate'] = date(FMT_DATETIMEDISPLAY, $starttimestamp);
            $build_response['builddateelapsed'] = time_difference(time() - $starttimestamp, false, 'ago');
        } else {
            $build_response['builddateelapsed'] = date(FMT_DATETIMEDISPLAY, $starttimestamp);
            $build_response['builddate'] = time_difference(time() - $starttimestamp, false, 'ago');
        }
        $build_response['submitdate'] = date(FMT_DATETIMEDISPLAY, $submittimestamp);
        // Generate a string summarizing this build's timing.
        $timesummary = $build_response['builddate'];
        if ($build_response['hasupdate'] && array_key_exists('time', $build_response['update'])) {
            $timesummary .= ', Update time: ' . $build_response['update']['time'];
        }
        if ($build_response['hasconfigure'] && array_key_exists('time', $build_response['configure'])) {
            $timesummary .= ', Configure time: ' . $build_response['configure']['time'];
        }
        if ($build_response['hascompilation'] && array_key_exists('time', $build_response['compilation'])) {
            $timesummary .= ', Build time: ' . $build_response['compilation']['time'];
        }
        if ($build_response['hastest'] && array_key_exists('time', $build_response['test'])) {
            $timesummary .= ', Test time: ' . $build_response['test']['time'];
        }
        $timesummary .= ', Total time: ' . $build_response['time'];
        $build_response['timesummary'] = $timesummary;
        if ($include_subprojects || $exclude_subprojects) {
            // Check if this build should be filtered out now that its
            // numbers have been updated by the SubProject include/exclude
            // filter.
            if (!build_survives_filter($build_response, $filterdata)) {
                continue;
            }
        }
        if ($build_array['name'] != 'Aggregate Coverage') {
            $buildgroups_response[$i]['builds'][] = $build_response;
        }
        // Coverage
        //
        // Determine if this is a parent build with no actual coverage of its own.
        $linkToChildCoverage = false;
        if ($numchildren > 0) {
            $countChildrenResult = pdo_single_row_query('SELECT count(fileid) AS nfiles FROM coverage
                    WHERE buildid=' . qnum($buildid));
            if ($countChildrenResult['nfiles'] == 0) {
                $linkToChildCoverage = true;
            }
        }
        $coverageIsGrouped = false;
        $loctested = $build_array['loctested'];
        $locuntested = $build_array['locuntested'];
        if ($loctested + $locuntested > 0) {
            $coverage_response = array();
            $coverage_response['buildid'] = $build_array['id'];
            if ($linkToChildCoverage) {
                $coverage_response['childlink'] = "{$child_builds_hyperlink}##Coverage";
            }
            if ($build_array['type'] === 'Nightly' && $build_array['name'] !== 'Aggregate Coverage') {
                $num_nightly_coverages_builds++;
                if ($num_nightly_coverages_builds > 1) {
                    $show_aggregate = true;
                    if ($linkToChildCoverage) {
                        $response['comparecoverage'] = 1;
                    }
                }
            }
            $percent = round(compute_percentcoverage($loctested, $locuntested), 2);
            if ($build_array['subprojectgroup']) {
                $groupId = $build_array['subprojectgroup'];
                if (array_key_exists($groupId, $coverage_groups)) {
                    $coverageIsGrouped = true;
                    $coverageThreshold = $coverage_groups[$groupId]['thresholdgreen'];
                    $coverage_groups[$groupId]['loctested'] += $loctested;
                    $coverage_groups[$groupId]['locuntested'] += $locuntested;
                    if (count($coverage_groups) > 1) {
                        // Add to Total.
                        $coverage_groups[0]['loctested'] += $loctested;
                        $coverage_groups[0]['locuntested'] += $locuntested;
                    }
                }
            }
            $coverage_response['percentage'] = $percent;
            $coverage_response['locuntested'] = intval($locuntested);
            $coverage_response['loctested'] = intval($loctested);
            // Compute the diff
            if (!empty($build_array['loctesteddiff'])) {
                $loctesteddiff = $build_array['loctesteddiff'];
                $locuntesteddiff = $build_array['locuntesteddiff'];
                @($previouspercent = round(($loctested - $loctesteddiff) / ($loctested - $loctesteddiff + $locuntested - $locuntesteddiff) * 100, 2));
                $percentdiff = round($percent - $previouspercent, 2);
                $coverage_response['percentagediff'] = $percentdiff;
                $coverage_response['locuntesteddiff'] = $locuntesteddiff;
                $coverage_response['loctesteddiff'] = $loctesteddiff;
            }
            $starttimestamp = strtotime($build_array['starttime'] . ' UTC');
            $coverage_response['datefull'] = $starttimestamp;
            // If the data is more than 24h old then we switch from an elapsed to a normal representation
            if (time() - $starttimestamp < 86400) {
                $coverage_response['date'] = date(FMT_DATETIMEDISPLAY, $starttimestamp);
                $coverage_response['dateelapsed'] = time_difference(time() - $starttimestamp, false, 'ago');
            } else {
                $coverage_response['dateelapsed'] = date(FMT_DATETIMEDISPLAY, $starttimestamp);
                $coverage_response['date'] = time_difference(time() - $starttimestamp, false, 'ago');
            }
            // Are there labels for this build?
            //
            $coverage_response['label'] = $build_label;
            if ($coverageIsGrouped) {
                $coverage_groups[$groupId]['coverages'][] = $coverage_response;
            } else {
                $coverage_response['site'] = $build_array['sitename'];
                $coverage_response['buildname'] = $build_array['name'];
                $response['coverages'][] = $coverage_response;
            }
        }
        if (!$coverageIsGrouped) {
            $coverageThreshold = $project_array['coveragethreshold'];
            $response['thresholdgreen'] = $coverageThreshold;
            $response['thresholdyellow'] = $coverageThreshold * 0.7;
        }
        // Dynamic Analysis
        //
        if (!empty($build_array['checker'])) {
            // Determine if this is a parent build with no dynamic analysis
            // of its own.
            $linkToChildren = false;
            if ($numchildren > 0) {
                $countChildrenResult = pdo_single_row_query('SELECT count(id) AS num FROM dynamicanalysis
                        WHERE buildid=' . qnum($build_array['id']));
                if ($countChildrenResult['num'] == 0) {
                    $linkToChildren = true;
                }
            }
            $DA_response = array();
            $DA_response['site'] = $build_array['sitename'];
            $DA_response['buildname'] = $build_array['name'];
            $DA_response['buildid'] = $build_array['id'];
            $DA_response['checker'] = $build_array['checker'];
            $DA_response['defectcount'] = $build_array['numdefects'];
            $starttimestamp = strtotime($build_array['starttime'] . ' UTC');
            $DA_response['datefull'] = $starttimestamp;
            if ($linkToChildren) {
                $DA_response['childlink'] = "{$child_builds_hyperlink}##DynamicAnalysis";
            }
            // If the data is more than 24h old then we switch from an elapsed to a normal representation
            if (time() - $starttimestamp < 86400) {
                $DA_response['date'] = date(FMT_DATETIMEDISPLAY, $starttimestamp);
                $DA_response['dateelapsed'] = time_difference(time() - $starttimestamp, false, 'ago');
            } else {
                $DA_response['dateelapsed'] = date(FMT_DATETIMEDISPLAY, $starttimestamp);
                $DA_response['date'] = time_difference(time() - $starttimestamp, false, 'ago');
            }
            // Are there labels for this build?
            //
            $DA_response['label'] = $build_label;
            $response['dynamicanalyses'][] = $DA_response;
        }
    }
    // Put some finishing touches on our buildgroups now that we're done
    // iterating over all the builds.
    $addExpected = empty($filter_sql) && pdo_num_rows($builds) + count($dynamic_builds) > 0;
    for ($i = 0; $i < count($buildgroups_response); $i++) {
        $buildgroups_response[$i]['testduration'] = time_difference($buildgroups_response[$i]['testduration'], true);
        $num_expected_builds = 0;
        if (!$filter_sql) {
            $groupname = $buildgroups_response[$i]['name'];
            $expected_builds = add_expected_builds($buildgroups_response[$i]['id'], $currentstarttime, $received_builds[$groupname]);
            if (is_array($expected_builds)) {
                $num_expected_builds = count($expected_builds);
                $buildgroups_response[$i]['builds'] = array_merge($buildgroups_response[$i]['builds'], $expected_builds);
            }
        }
        // Show how many builds this group has.
        $num_builds = count($buildgroups_response[$i]['builds']);
        $num_builds_label = '';
        if ($num_expected_builds > 0) {
            $num_actual_builds = $num_builds - $num_expected_builds;
            $num_builds_label = "{$num_actual_builds} of {$num_builds} builds";
        } else {
            if ($num_builds === 1) {
                $num_builds_label = '1 build';
            } else {
                $num_builds_label = "{$num_builds} builds";
            }
        }
        $buildgroups_response[$i]['numbuildslabel'] = $num_builds_label;
    }
    // Create a separate "all buildgroups" section of our response.
    // This is used to allow project admins to move builds between groups.
    $response['all_buildgroups'] = array();
    foreach ($buildgroups_response as $group) {
        $response['all_buildgroups'][] = array('id' => $group['id'], 'name' => $group['name']);
    }
    // At this point it is safe to remove any empty buildgroups from our response.
    function is_buildgroup_nonempty($group)
    {
        return !empty($group['builds']);
    }
    $buildgroups_response = array_filter($buildgroups_response, 'is_buildgroup_nonempty');
    // Report buildgroups as a list, not an associative array.
    // Otherwise any missing buildgroups will cause our view to
    // not honor the order specified by the project admins.
    $buildgroups_response = array_values($buildgroups_response);
    // Remove Aggregate Coverage if it should not be displayed.
    if (!$show_aggregate) {
        for ($i = 0; $i < count($response['coverages']); $i++) {
            if ($response['coverages'][$i]['buildname'] === 'Aggregate Coverage') {
                unset($response['coverages'][$i]);
            }
        }
        $response['coverages'] = array_values($response['coverages']);
    }
    if ($response['childview'] == 1) {
        // Report number of children.
        if (!empty($buildgroups_response)) {
            $numchildren = count($buildgroups_response[0]['builds']);
        } else {
            $row = pdo_single_row_query('SELECT count(id) AS numchildren
                    FROM build WHERE parentid=' . qnum($parentid));
            $numchildren = $row['numchildren'];
        }
        $response['numchildren'] = $numchildren;
    }
    // Generate coverage by group here.
    if (!empty($coverage_groups)) {
        $response['coveragegroups'] = array();
        foreach ($coverage_groups as $groupid => $group) {
            $loctested = $group['loctested'];
            $locuntested = $group['locuntested'];
            if ($loctested == 0 && $locuntested == 0) {
                continue;
            }
            $percentage = round($loctested / ($loctested + $locuntested) * 100, 2);
            $group['percentage'] = $percentage;
            $group['id'] = $groupid;
            $response['coveragegroups'][] = $group;
        }
    }
    $response['buildgroups'] = $buildgroups_response;
    $response['enableTestTiming'] = $project_array['showtesttime'];
    $end = microtime_float();
    $response['generationtime'] = round($end - $start, 3);
    if (!empty($site_response)) {
        $response = array_merge($response, $site_response);
    }
    echo json_encode(cast_data_for_JSON($response));
}
Ejemplo n.º 17
0
    }
    // Add the priority
    $CoverageFile2User = new CoverageFile2User();
    $CoverageFile2User->ProjectId = $projectid;
    $CoverageFile2User->FullPath = $covfile['fullpath'];
    $covfile['priority'] = $coveragefile_array['priority'];
    // If the user is logged in we set the users
    if (isset($coveragefile_array['userid'])) {
        $covfile['user'] = $coveragefile_array['userid'];
    }
    $covfile_array[] = $covfile;
}
// Add the coverage type
$status = -1;
if (isset($_GET['status'])) {
    $status = pdo_real_escape_numeric($_GET['status']);
}
// Do the sorting
function sort_array($a, $b)
{
    global $sortby;
    global $sortdir;
    if ($sortby == 'filename') {
        if ($a['fullpath'] == $b['fullpath']) {
            return 0;
        }
        if ($sortdir == 'desc') {
            return $a['fullpath'] > $b['fullpath'] ? -1 : 1;
        }
        return $a['fullpath'] > $b['fullpath'] ? 1 : -1;
    } elseif ($sortby == 'status') {
Ejemplo n.º 18
0
  Language:  PHP
  Date:      $Date$
  Version:   $Revision$

  Copyright (c) 2002 Kitware, Inc.  All rights reserved.
  See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
include "cdash/config.php";
require_once "cdash/pdo.php";
if (array_key_exists("imgid", $_GET)) {
    $imgid = pdo_real_escape_numeric($_GET["imgid"]);
}
// Checks
if (empty($imgid) || !is_numeric($imgid)) {
    echo "Not a valid imgid!";
    return;
}
$db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}");
pdo_select_db("{$CDASH_DB_NAME}", $db);
$result = pdo_query("SELECT * FROM image WHERE id={$imgid}");
$img_array = pdo_fetch_array($result);
switch ($img_array["extension"]) {
    case "image/jpg":
        header("Content-type: image/jpeg");
        break;
    case "image/jpeg":
Ejemplo n.º 19
0
<?php

/*=========================================================================
  Program:   CDash - Cross-Platform Dashboard System
  Module:    $Id$
  Language:  PHP
  Date:      $Date$
  Version:   $Revision$

  Copyright (c) Kitware, Inc. All rights reserved.
  See LICENSE or http://www.cdash.org/licensing/ for details.

  This software is distributed WITHOUT ANY WARRANTY; without even
  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  PURPOSE. See the above copyright notices for more information.
=========================================================================*/
require_once dirname(dirname(__DIR__)) . '/config/config.php';
require_once 'include/dailyupdates.php';
$projectid = pdo_real_escape_numeric($_GET['projectid']);
addDailyChanges($projectid);
Ejemplo n.º 20
0
function get_filterdata_array_from_request($page_id = '')
{
    $filterdata = array();
    $filters = array();
    $sql = '';
    $clauses = 0;
    if (empty($page_id)) {
        $pos = strrpos($_SERVER['SCRIPT_NAME'], '/');
        $page_id = substr($_SERVER['SCRIPT_NAME'], $pos + 1);
    }
    $filterdata['availablefilters'] = getFiltersForPage($page_id);
    $pageSpecificFilters = createPageSpecificFilters($page_id);
    if (isset($_GET['value1']) && strlen($_GET['value1']) > 0) {
        $filtercount = $_GET['filtercount'];
    } else {
        $filtercount = 0;
    }
    $filterdata['filtercount'] = $filtercount;
    $showfilters = pdo_real_escape_numeric(@$_REQUEST['showfilters']);
    if ($showfilters) {
        $filterdata['showfilters'] = 1;
    } else {
        if ($filtercount > 0) {
            $filterdata['showfilters'] = 1;
        } else {
            $filterdata['showfilters'] = 0;
        }
    }
    $showlimit = pdo_real_escape_numeric(@$_REQUEST['showlimit']);
    if ($showlimit) {
        $filterdata['showlimit'] = 1;
    } else {
        $filterdata['showlimit'] = 0;
    }
    $limit = intval(pdo_real_escape_numeric(@$_REQUEST['limit']));
    if (!is_int($limit)) {
        $limit = 0;
    }
    $filterdata['limit'] = $limit;
    @($filtercombine = htmlspecialchars(pdo_real_escape_string($_REQUEST['filtercombine'])));
    $filterdata['filtercombine'] = $filtercombine;
    if (strtolower($filtercombine) == 'or') {
        $sql_combine = 'OR';
    } else {
        $sql_combine = 'AND';
    }
    $sql = 'AND (';
    // Check for filters passed in via the query string
    for ($i = 1; $i <= $filtercount; ++$i) {
        if (empty($_REQUEST['field' . $i])) {
            continue;
        }
        $field = htmlspecialchars(pdo_real_escape_string($_REQUEST['field' . $i]));
        $compare = htmlspecialchars(pdo_real_escape_string($_REQUEST['compare' . $i]));
        $value = htmlspecialchars(pdo_real_escape_string($_REQUEST['value' . $i]));
        $cv = get_sql_compare_and_value($compare, $value);
        $sql_compare = $cv[0];
        $sql_value = $cv[1];
        $sql_field = $pageSpecificFilters->getSqlField($field);
        /* TODO: handle fieldtype.  currently defined in JS.
                   Here's how its done the old way:
                   $fieldinfo =  htmlspecialchars(pdo_real_escape_string($_REQUEST['field'.$i]));
                   $fieldinfo = preg_split('#/#', $fieldinfo, 2);
                   $field = $fieldinfo[0];
                   $fieldtype = $fieldinfo[1];
                   (end old way)
        
                   if ($fieldtype == 'date')
                   {
                   $filterdata['hasdateclause'] = 1;
                   }
                 */
        // Treat the buildstamp field as if it were a date clause so that the
        // default date clause of "builds from today only" is not used...
        //
        if ($field == 'buildstamp') {
            $filterdata['hasdateclause'] = 1;
        }
        if ($sql_field != '' && $sql_compare != '') {
            if ($clauses > 0) {
                $sql .= ' ' . $sql_combine . ' ';
            }
            $sql .= $sql_field . ' ' . $sql_compare . ' ' . $sql_value;
            ++$clauses;
        }
        $filters[] = array('key' => $field, 'value' => $value, 'compare' => $compare);
    }
    if ($clauses == 0) {
        $sql = '';
    } else {
        $sql .= ')';
    }
    $filterdata['sql'] = $sql;
    // If no filters were passed in as parameters,
    // then add one default filter so that the user sees
    // somewhere to enter filter queries in the GUI:
    //
    if (count($filters) === 0) {
        $filters[] = getDefaultFilter($page_id);
    }
    $filterdata['filters'] = $filters;
    return $filterdata;
}
Ejemplo n.º 21
0
     echo 'Not a valid usersessionid!';
     return;
 }
 $user_array = pdo_fetch_array(pdo_query('SELECT admin FROM ' . qid('user') . " WHERE id='{$userid}'"));
 if ($user_array['admin'] != 1) {
     echo "You don't have the permissions to access this page!";
     return;
 }
 $xml = begin_XML_for_XSLT();
 $xml .= '<backurl>user.php</backurl>';
 $xml .= '<title>CDash - Manage Users</title>';
 $xml .= '<menutitle>CDash</menutitle>';
 $xml .= '<menusubtitle>Manage Users</menusubtitle>';
 @($postuserid = $_POST['userid']);
 if ($postuserid != null) {
     $postuserid = pdo_real_escape_numeric($postuserid);
 }
 if (isset($_POST['adduser'])) {
     // arrive from register form
     $email = $_POST['email'];
     $passwd = $_POST['passwd'];
     $passwd2 = $_POST['passwd2'];
     if (!($passwd == $passwd2)) {
         $xml .= add_XML_value('error', 'Passwords do not match!');
     } else {
         $fname = $_POST['fname'];
         $lname = $_POST['lname'];
         $institution = $_POST['institution'];
         if ($email && $passwd && $passwd2 && $fname && $lname && $institution) {
             $User = new User();
             if ($User->GetIdFromEmail($email)) {
Ejemplo n.º 22
0
/** Function to deal with the external tool mechanism */
function post_submit()
{
    include "models/buildfile.php";
    // We expect POST to contain the following values.
    $vars = array('project', 'build', 'stamp', 'site', 'track', 'type', 'starttime', 'endtime', 'datafilesmd5');
    foreach ($vars as $var) {
        if (!isset($_POST[$var]) || empty($_POST[$var])) {
            $response_array['status'] = 1;
            $response_array['description'] = 'Variable \'' . $var . '\' not set but required.';
            echo json_encode($response_array);
            return;
        }
    }
    $projectname = htmlspecialchars(pdo_real_escape_string($_POST['project']));
    $buildname = htmlspecialchars(pdo_real_escape_string($_POST['build']));
    $buildstamp = htmlspecialchars(pdo_real_escape_string($_POST['stamp']));
    $sitename = htmlspecialchars(pdo_real_escape_string($_POST['site']));
    $track = htmlspecialchars(pdo_real_escape_string($_POST['track']));
    $type = htmlspecialchars(pdo_real_escape_string($_POST['type']));
    $starttime = htmlspecialchars(pdo_real_escape_string($_POST['starttime']));
    $endtime = htmlspecialchars(pdo_real_escape_string($_POST['endtime']));
    // Check if we have the CDash@Home scheduleid
    $scheduleid = 0;
    if (isset($_POST["clientscheduleid"])) {
        $scheduleid = pdo_real_escape_numeric($_POST["clientscheduleid"]);
    }
    // Add the build
    $build = new Build();
    $build->ProjectId = get_project_id($projectname);
    $build->StartTime = gmdate(FMT_DATETIME, $starttime);
    $build->EndTime = gmdate(FMT_DATETIME, $endtime);
    $build->SubmitTime = gmdate(FMT_DATETIME);
    $build->Name = $buildname;
    $build->InsertErrors = false;
    // we have no idea if we have errors at this point
    $build->SetStamp($buildstamp);
    // Get the site id
    $site = new Site();
    $site->Name = $sitename;
    $site->Insert();
    $build->SiteId = $site->Id;
    // Make this an "append" build, so that it doesn't result in a separate row
    // from the rest of the "normal" submission.
    $build->Append = true;
    // TODO: Check the labels and generator and other optional
    if (isset($_POST["generator"])) {
        $build->Generator = htmlspecialchars(pdo_real_escape_string($_POST['generator']));
    }
    $subprojectname = "";
    if (isset($_POST["subproject"])) {
        $subprojectname = htmlspecialchars(pdo_real_escape_string($_POST['subproject']));
        $build->SetSubProject($subprojectname);
    }
    // Check if this build already exists.
    $buildid = $build->GetIdFromName($subprojectname);
    // If not, add a new one.
    if ($buildid === 0) {
        $buildid = add_build($build, $scheduleid);
    }
    // Returns the OK submission
    $response_array['status'] = 0;
    $response_array['buildid'] = $buildid;
    $buildfile = new BuildFile();
    // Check if the files exists
    foreach ($_POST['datafilesmd5'] as $md5) {
        $buildfile->md5 = $md5;
        $old_buildid = $buildfile->MD5Exists();
        if (!$old_buildid) {
            $response_array['datafilesmd5'][] = 0;
        } else {
            $response_array['datafilesmd5'][] = 1;
            // Associate this build file with the new build if it has been previously
            // uploaded.
            require_once "copy_build_data.php";
            copy_build_data($old_buildid, $buildid, $type);
        }
    }
    echo json_encode($response_array);
}
Ejemplo n.º 23
0
  See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even 
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
$noforcelogin = 1;
include "cdash/config.php";
require_once "cdash/pdo.php";
include 'login.php';
include_once "cdash/common.php";
include "cdash/version.php";
@($buildid = $_GET["buildid"]);
if ($buildid != NULL) {
    $buildid = pdo_real_escape_numeric($buildid);
}
@($date = $_GET["date"]);
if ($date != NULL) {
    $date = htmlspecialchars(pdo_real_escape_string($date));
}
// Checks
if (!isset($buildid) || !is_numeric($buildid)) {
    echo "Not a valid buildid!";
    return;
}
$db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}");
pdo_select_db("{$CDASH_DB_NAME}", $db);
$build_array = pdo_fetch_array(pdo_query("SELECT * FROM build WHERE id='{$buildid}'"));
$projectid = $build_array["projectid"];
checkUserPolicy(@$_SESSION['cdash']['loginid'], $projectid);
Ejemplo n.º 24
0
function get_buildgroupid()
{
    if (!isset($_GET['buildgroupid'])) {
        echo_error("buildgroupid not specified.");
        return false;
    }
    $buildgroupid = pdo_real_escape_numeric($_GET['buildgroupid']);
    return $buildgroupid;
}
Ejemplo n.º 25
0
     header('location: user.php?note=unsubscribedtoproject');
 } else {
     if ($UpdateSubscription) {
         @($emailcategory_update = $_POST["emailcategory_update"]);
         @($emailcategory_configure = $_POST["emailcategory_configure"]);
         @($emailcategory_warning = $_POST["emailcategory_warning"]);
         @($emailcategory_error = $_POST["emailcategory_error"]);
         @($emailcategory_test = $_POST["emailcategory_test"]);
         @($emailcategory_dynamicanalysis = $_POST["emailcategory_dynamicanalysis"]);
         $EmailCategory = $emailcategory_update + $emailcategory_configure + $emailcategory_warning + $emailcategory_error + $emailcategory_test + $emailcategory_dynamicanalysis;
         if (pdo_num_rows($user2project) > 0) {
             $Role = pdo_real_escape_numeric($Role);
             $EmailType = pdo_real_escape_numeric($EmailType);
             $EmailCategory = pdo_real_escape_numeric($EmailCategory);
             $EmailMissingSites = pdo_real_escape_numeric($EmailMissingSites);
             $EmailSuccess = pdo_real_escape_numeric($EmailSuccess);
             pdo_query("UPDATE user2project SET role='{$Role}',emailtype='{$EmailType}',\n                         emailcategory='{$EmailCategory}',\n                         emailmissingsites='{$EmailMissingSites}',\n                         emailsuccess='{$EmailSuccess}'\n                         WHERE userid='{$userid}' AND projectid='{$projectid}'");
             // Update the repository credential
             $UserProject = new UserProject();
             $UserProject->ProjectId = $projectid;
             $UserProject->UserId = $userid;
             $UserProject->UpdateCredentials($Credentials);
             if ($Role == 0) {
                 // Remove the claim sites for this project if they are only part of this project
                 pdo_query("DELETE FROM site2user WHERE userid='{$userid}'\n                 AND siteid NOT IN\n                (SELECT build.siteid FROM build,user2project as up WHERE\n                 up.projectid = build.projectid AND up.userid='{$userid}' AND up.role>0\n                 GROUP BY build.siteid)");
             }
         }
         if (isset($_POST['emaillabels'])) {
             $LabelEmail->UpdateLabels($_POST['emaillabels']);
         } else {
             $LabelEmail->UpdateLabels(NULL);
Ejemplo n.º 26
0
function echo_submission_table()
{
    @($limit = $_REQUEST['limit']);
    if (!isset($limit)) {
        $limit = 25;
    } else {
        $limit = pdo_real_escape_numeric($limit);
    }
    $rows = pdo_all_rows_query("SELECT * FROM " . qid("submission") . " ORDER BY id DESC LIMIT " . $limit);
    $sep = ', ';
    echo "<h3>Table `submission` (most recently queued {$limit})</h3>";
    echo '<pre>';
    echo 'id, filename, projectid, status, attempts, filesize, filemd5sum, ' . 'lastupdated, created, started, finished' . "\n";
    echo "\n";
    foreach ($rows as $row) {
        echo $row['id'] . $sep . $row['filename'] . $sep . $row['projectid'] . $sep . $row['status'] . $sep . $row['attempts'] . $sep . $row['filesize'] . $sep . $row['filemd5sum'] . $sep . $row['lastupdated'] . $sep . $row['created'] . $sep . $row['started'] . $sep . $row['finished'] . "\n";
    }
    echo '</pre>';
    echo '<br/>';
}
Ejemplo n.º 27
0
         $xml .= '<site>';
         $xml .= add_XML_value('id', $siteid);
         $xml .= add_XML_value('name', $site2project_array['name']);
         $user2site = pdo_query("SELECT * FROM site2user WHERE siteid='{$siteid}' and userid='{$userid}'");
         if (pdo_num_rows($user2site) == 0) {
             $xml .= add_XML_value('claimed', '0');
         } else {
             $xml .= add_XML_value('claimed', '1');
         }
         $xml .= '</site>';
     }
 }
 // If we have a siteid we look if the user has claimed the site or not
 @($siteid = $_GET['siteid']);
 if ($siteid != null) {
     $siteid = pdo_real_escape_numeric($siteid);
 }
 if (isset($siteid) && is_numeric($siteid)) {
     $xml .= '<user>';
     $xml .= '<site>';
     $site_array = pdo_fetch_array(pdo_query("SELECT * FROM site WHERE id='{$siteid}'"));
     $siteinformation_array = array();
     $siteinformation_array['description'] = 'NA';
     $siteinformation_array['processoris64bits'] = 'NA';
     $siteinformation_array['processorvendor'] = 'NA';
     $siteinformation_array['processorvendorid'] = 'NA';
     $siteinformation_array['processorfamilyid'] = 'NA';
     $siteinformation_array['processormodelid'] = 'NA';
     $siteinformation_array['processorcachesize'] = 'NA';
     $siteinformation_array['numberlogicalcpus'] = 'NA';
     $siteinformation_array['numberphysicalcpus'] = 'NA';
Ejemplo n.º 28
0
    @($TestTimingDays = $_POST["TestTimingDays"]);
    if ($TestTimingDays != NULL) {
        $TestTimingDays = pdo_real_escape_numeric($TestTimingDays);
    }
    if (is_numeric($TestTimingDays) && $TestTimingDays > 0) {
        ComputeTestTiming($TestTimingDays);
        $xml .= add_XML_value("alert", "Timing for tests has been computed successfully.");
    } else {
        $xml .= add_XML_value("alert", "Wrong number of days.");
    }
}
// Compute the user statistics
if ($ComputeUpdateStatistics) {
    @($UpdateStatisticsDays = $_POST["UpdateStatisticsDays"]);
    if ($UpdateStatisticsDays != NULL) {
        $UpdateStatisticsDays = pdo_real_escape_numeric($UpdateStatisticsDays);
    }
    if (is_numeric($UpdateStatisticsDays) && $UpdateStatisticsDays > 0) {
        ComputeUpdateStatistics($UpdateStatisticsDays);
        $xml .= add_XML_value("alert", "User statistics has been computed successfully.");
    } else {
        $xml .= add_XML_value("alert", "Wrong number of days.");
    }
}
/** Cleanup the database */
if ($Cleanup) {
    delete_unused_rows('banner', 'projectid', 'project');
    delete_unused_rows('blockbuild', 'projectid', 'project');
    delete_unused_rows('build', 'projectid', 'project');
    delete_unused_rows('buildgroup', 'projectid', 'project');
    delete_unused_rows('labelemail', 'projectid', 'project');
Ejemplo n.º 29
0
  See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
// To be able to access files in this CDash installation regardless
// of getcwd() value:
//
$cdashpath = str_replace('\\', '/', dirname(dirname(__FILE__)));
set_include_path($cdashpath . PATH_SEPARATOR . get_include_path());
require_once "cdash/config.php";
require_once "cdash/pdo.php";
require_once "cdash/common.php";
$buildid = pdo_real_escape_numeric($_GET["buildid"]);
if (!isset($buildid) || !is_numeric($buildid)) {
    echo "Not a valid buildid!";
    return;
}
$db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}");
pdo_select_db("{$CDASH_DB_NAME}", $db);
// Find the project variables
$build = pdo_query("SELECT name,type,siteid,projectid,starttime FROM build WHERE id='{$buildid}'");
$build_array = pdo_fetch_array($build);
$buildtype = $build_array["type"];
$buildname = $build_array["name"];
$siteid = $build_array["siteid"];
$starttime = $build_array["starttime"];
$projectid = $build_array["projectid"];
// Find the other builds
Ejemplo n.º 30
0
=========================================================================*/
$noforcelogin = 1;
include dirname(__DIR__) . '/config/config.php';
require_once 'include/pdo.php';
include 'public/login.php';
include_once 'include/common.php';
include 'include/version.php';
require_once 'models/coveragefile.php';
require_once 'models/coveragefilelog.php';
@($buildid = $_GET['buildid']);
if ($buildid != null) {
    $buildid = pdo_real_escape_numeric($buildid);
}
@($fileid = $_GET['fileid']);
if ($fileid != null) {
    $fileid = pdo_real_escape_numeric($fileid);
}
@($date = $_GET['date']);
if ($date != null) {
    $date = htmlspecialchars(pdo_real_escape_string($date));
}
// Checks
if (!isset($buildid) || !is_numeric($buildid)) {
    echo 'Not a valid buildid!';
    return;
}
@($userid = $_SESSION['cdash']['loginid']);
if (!isset($userid)) {
    $userid = 0;
}
$db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}");