コード例 #1
0
ファイル: sendemail.php プロジェクト: kitware/cdash
function send_email_to_address($emailaddress, $emailtext, $Build, $Project)
{
    include 'config/config.php';
    include_once 'include/common.php';
    require_once 'models/site.php';
    $serverURI = get_server_URI();
    // In the case of asynchronous submission, the serverURI contains /cdash
    // we need to remove it
    if ($CDASH_BASE_URL == '' && $CDASH_ASYNCHRONOUS_SUBMISSION) {
        $serverURI = substr($serverURI, 0, strrpos($serverURI, '/'));
    }
    $messagePlainText = 'A submission to CDash for the project ' . $Project->Name . ' has ';
    $titleerrors = '(';
    $i = 0;
    foreach ($emailtext['category'] as $key => $value) {
        if ($key != 'update_errors' && $key != 'configure_errors' && $key != 'build_warnings' && $key != 'build_errors' && $key != 'test_errors' && $key != 'dynamicanalysis_errors') {
            continue;
        }
        if ($i > 0) {
            $messagePlainText .= ' and ';
            $titleerrors .= ', ';
        }
        switch ($key) {
            case 'update_errors':
                $messagePlainText .= 'update errors';
                $titleerrors .= 'u=' . $value;
                break;
            case 'configure_errors':
                $messagePlainText .= 'configure errors';
                $titleerrors .= 'c=' . $value;
                break;
            case 'build_warnings':
                $messagePlainText .= 'build warnings';
                $titleerrors .= 'w=' . $value;
                break;
            case 'build_errors':
                $messagePlainText .= 'build errors';
                $titleerrors .= 'b=' . $value;
                break;
            case 'test_errors':
                $messagePlainText .= 'failing tests';
                $titleerrors .= 't=' . $value;
                break;
            case 'dynamicanalysis_errors':
                $messagePlainText .= 'failing dynamic analysis tests';
                $titleerrors .= 'd=' . $value;
                break;
        }
        $i++;
    }
    // Nothing to send we stop
    if ($i == 0) {
        return;
    }
    // Title
    $titleerrors .= '):';
    $title = 'FAILED ' . $titleerrors . ' ' . $Project->Name;
    if ($Build->GetSubProjectName()) {
        $title .= '/' . $Build->GetSubProjectName();
    }
    $title .= ' - ' . $Build->Name . ' - ' . $Build->Type;
    //$title = "CDash [".$project_array["name"]."] - ".$site_array["name"];
    //$title .= " - ".$buildname." - ".$buildtype." - ".date(FMT_DATETIMETZ,strtotime($starttime." UTC"));
    $messagePlainText .= ".\n";
    $messagePlainText .= 'You have been identified as one of the authors who ';
    $messagePlainText .= 'have checked in changes that are part of this submission ';
    $messagePlainText .= "or you are listed in the default contact list.\n\n";
    $messagePlainText .= 'Details on the submission can be found at ';
    $messagePlainText .= $serverURI;
    $messagePlainText .= '/buildSummary.php?buildid=' . $Build->Id;
    $messagePlainText .= "\n\n";
    $messagePlainText .= 'Project: ' . $Project->Name . "\n";
    if ($Build->GetSubProjectName()) {
        $messagePlainText .= 'SubProject: ' . $Build->GetSubProjectName() . "\n";
    }
    $Site = new Site();
    $Site->Id = $Build->SiteId;
    $messagePlainText .= 'Site: ' . $Site->GetName() . "\n";
    $messagePlainText .= 'Build Name: ' . $Build->Name . "\n";
    $messagePlainText .= 'Build Time: ' . date(FMT_DATETIMETZ, strtotime($Build->StartTime . ' UTC')) . "\n";
    $messagePlainText .= 'Type: ' . $Build->Type . "\n";
    foreach ($emailtext['category'] as $key => $value) {
        switch ($key) {
            case 'update_errors':
                $messagePlainText .= "Update errors: {$value}\n";
                break;
            case 'configure_errors':
                $messagePlainText .= "Configure errors: {$value}\n";
                break;
            case 'build_warnings':
                $messagePlainText .= "Warnings: {$value}\n";
                break;
            case 'build_errors':
                $messagePlainText .= "Errors: {$value}\n";
                break;
            case 'test_errors':
                $messagePlainText .= "Tests failing: {$value}\n";
                break;
            case 'dynamicanalysis_errors':
                $messagePlainText .= "Dynamic analysis tests failing: {$value}\n";
                break;
        }
    }
    foreach ($emailtext['summary'] as $summary) {
        $messagePlainText .= $summary;
    }
    $serverName = $CDASH_SERVER_NAME;
    if (strlen($serverName) == 0) {
        $serverName = $_SERVER['SERVER_NAME'];
    }
    $messagePlainText .= "\n-CDash on " . $serverName . "\n";
    $sent = false;
    // If this is the testing
    if ($CDASH_TESTING_MODE) {
        add_log($emailaddress, 'TESTING: EMAIL', LOG_DEBUG);
        add_log($title, 'TESTING: EMAILTITLE', LOG_DEBUG);
        add_log($messagePlainText, 'TESTING: EMAILBODY', LOG_DEBUG);
        $sent = true;
    } else {
        // Send the email
        if (cdashmail("{$emailaddress}", $title, $messagePlainText)) {
            add_log('email sent to: ' . $emailaddress . ' with errors ' . $titleerrors . ' for build ' . $Build->Id, 'sendemail ' . $Project->Name, LOG_INFO);
            $sent = true;
        } else {
            add_log('cannot send email to: ' . $emailaddress, 'sendemail ' . $Project->Name, LOG_ERR);
        }
    }
    return $sent;
}
コード例 #2
0
ファイル: manageCoverage.php プロジェクト: rpshaw/CDash
 $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) {
     $Build = new Build();
     $Build->Id = $buildId;
     $Build->FillFromId($Build->Id);
     $xml .= "<build>";
     $xml .= add_XML_value("id", $buildId);
     $Site = new Site();
     $Site->Id = $Build->SiteId;
     $xml .= add_XML_value("name", $Site->GetName() . "-" . $Build->GetName() . " [" . gmdate(FMT_DATETIME, strtotime($Build->StartTime)) . "]");
     if ($buildid > 0 && $buildId == $buildid) {
         $xml .= add_XML_value("selected", 1);
     }
     $xml .= "</build>";
 }
 // For now take the first one
 if ($buildid > 0) {
     // Find the files associated with the build
     $Coverage = new Coverage();
     $Coverage->BuildId = $buildid;
     $fileIds = $Coverage->GetFiles();
     $row = "0";
     sort($fileIds);
     foreach ($fileIds as $fileid) {
         $CoverageFile = new CoverageFile();
コード例 #3
0
ファイル: sendemail.php プロジェクト: rpshaw/CDash
function send_email_to_address($emailaddress, $emailtext, $Build, $Project)
{
    include "cdash/config.php";
    include_once "cdash/common.php";
    require_once "models/site.php";
    $serverURI = get_server_URI();
    // In the case of asynchronous submission, the serverURI contains /cdash
    // we need to remove it
    if ($CDASH_BASE_URL == '' && $CDASH_ASYNCHRONOUS_SUBMISSION) {
        $serverURI = substr($serverURI, 0, strrpos($serverURI, "/"));
    }
    $messagePlainText = "A submission to CDash for the project " . $Project->Name . " has ";
    $titleerrors = "(";
    $i = 0;
    foreach ($emailtext['category'] as $key => $value) {
        if ($key != 'update_errors' && $key != 'configure_errors' && $key != 'build_warnings' && $key != 'build_errors' && $key != 'test_errors' && $key != 'dynamicanalysis_errors') {
            continue;
        }
        if ($i > 0) {
            $messagePlainText .= " and ";
            $titleerrors .= ", ";
        }
        switch ($key) {
            case 'update_errors':
                $messagePlainText .= "update errors";
                $titleerrors .= "u=" . $value;
                break;
            case 'configure_errors':
                $messagePlainText .= "configure errors";
                $titleerrors .= "c=" . $value;
                break;
            case 'build_warnings':
                $messagePlainText .= "build warnings";
                $titleerrors .= "w=" . $value;
                break;
            case 'build_errors':
                $messagePlainText .= "build errors";
                $titleerrors .= "b=" . $value;
                break;
            case 'test_errors':
                $messagePlainText .= "failing tests";
                $titleerrors .= "t=" . $value;
                break;
            case 'dynamicanalysis_errors':
                $messagePlainText .= "failing dynamic analysis tests";
                $titleerrors .= "d=" . $value;
                break;
        }
        $i++;
    }
    // Nothing to send we stop
    if ($i == 0) {
        return;
    }
    // Title
    $titleerrors .= "):";
    $title = "FAILED " . $titleerrors . " " . $Project->Name;
    if ($Build->GetSubProjectName()) {
        $title .= "/" . $Build->GetSubProjectName();
    }
    $title .= " - " . $Build->Name . " - " . $Build->Type;
    //$title = "CDash [".$project_array["name"]."] - ".$site_array["name"];
    //$title .= " - ".$buildname." - ".$buildtype." - ".date(FMT_DATETIMETZ,strtotime($starttime." UTC"));
    $messagePlainText .= ".\n";
    $messagePlainText .= "You have been identified as one of the authors who ";
    $messagePlainText .= "have checked in changes that are part of this submission ";
    $messagePlainText .= "or you are listed in the default contact list.\n\n";
    $messagePlainText .= "Details on the submission can be found at ";
    $messagePlainText .= $serverURI;
    $messagePlainText .= "/buildSummary.php?buildid=" . $Build->Id;
    $messagePlainText .= "\n\n";
    $messagePlainText .= "Project: " . $Project->Name . "\n";
    if ($Build->GetSubProjectName()) {
        $messagePlainText .= "SubProject: " . $Build->GetSubProjectName() . "\n";
    }
    $Site = new Site();
    $Site->Id = $Build->SiteId;
    $messagePlainText .= "Site: " . $Site->GetName() . "\n";
    $messagePlainText .= "Build Name: " . $Build->Name . "\n";
    $messagePlainText .= "Build Time: " . date(FMT_DATETIMETZ, strtotime($Build->StartTime . " UTC")) . "\n";
    $messagePlainText .= "Type: " . $Build->Type . "\n";
    foreach ($emailtext['category'] as $key => $value) {
        switch ($key) {
            case 'update_errors':
                $messagePlainText .= "Update errors: {$value}\n";
                break;
            case 'configure_errors':
                $messagePlainText .= "Configure errors: {$value}\n";
                break;
            case 'build_warnings':
                $messagePlainText .= "Warnings: {$value}\n";
                break;
            case 'build_errors':
                $messagePlainText .= "Errors: {$value}\n";
                break;
            case 'test_errors':
                $messagePlainText .= "Tests failing: {$value}\n";
                break;
            case 'dynamicanalysis_errors':
                $messagePlainText .= "Dynamic analysis tests failing: {$value}\n";
                break;
        }
    }
    foreach ($emailtext['summary'] as $summary) {
        $messagePlainText .= $summary;
    }
    $serverName = $CDASH_SERVER_NAME;
    if (strlen($serverName) == 0) {
        $serverName = $_SERVER['SERVER_NAME'];
    }
    $messagePlainText .= "\n-CDash on " . $serverName . "\n";
    $sent = false;
    // If this is the testing
    if ($CDASH_TESTING_MODE) {
        add_log($emailaddress, "TESTING: EMAIL", LOG_TESTING);
        add_log($title, "TESTING: EMAILTITLE", LOG_TESTING);
        add_log($messagePlainText, "TESTING: EMAILBODY", LOG_TESTING);
        $sent = true;
    } else {
        // Send the email
        if (cdashmail("{$emailaddress}", $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")) {
            add_log("email sent to: " . $emailaddress . " with errors " . $titleerrors . " for build " . $Build->Id, "sendemail " . $Project->Name, LOG_INFO);
            $sent = true;
        } else {
            add_log("cannot send email to: " . $emailaddress, "sendemail " . $Project->Name, LOG_ERR);
        }
    }
    // end if testing
    return $sent;
}
コード例 #4
0
ファイル: viewFiles.php プロジェクト: rpshaw/CDash
}
$xml = begin_XML_for_XSLT();
$xml .= get_cdash_dashboard_xml(get_project_name($projectid), $date);
$db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}");
pdo_select_db("{$CDASH_DB_NAME}", $db);
$xml .= add_XML_value("title", "CDash - Uploaded files");
$xml .= add_XML_value("menutitle", "CDash");
$xml .= add_XML_value("menusubtitle", "Uploaded files");
$xml .= "<hostname>" . $_SERVER['SERVER_NAME'] . "</hostname>";
$xml .= "<date>" . date("r") . "</date>";
$xml .= "<backurl>index.php</backurl>";
$xml .= "<buildid>{$buildid}</buildid>";
$xml .= '<buildname>' . $Build->Name . '</buildname>';
$xml .= '<buildstarttime>' . $Build->StartTime . '</buildstarttime>';
$xml .= '<siteid>' . $Site->Id . '</siteid>';
$xml .= '<sitename>' . $Site->GetName() . '</sitename>';
$uploadFilesOrURLs = $Build->GetUploadedFilesOrUrls();
foreach ($uploadFilesOrURLs as $uploadFileOrURL) {
    if (!$uploadFileOrURL->IsUrl) {
        $xml .= '<uploadfile>';
        $xml .= '<id>' . $uploadFileOrURL->Id . '</id>';
        $xml .= '<href>' . $CDASH_DOWNLOAD_RELATIVE_URL . '/' . $uploadFileOrURL->Sha1Sum . '/' . $uploadFileOrURL->Filename . '</href>';
        $xml .= '<sha1sum>' . $uploadFileOrURL->Sha1Sum . '</sha1sum>';
        $xml .= '<filename>' . $uploadFileOrURL->Filename . '</filename>';
        $xml .= '<filesize>' . $uploadFileOrURL->Filesize . '</filesize>';
        $filesize = $uploadFileOrURL->Filesize;
        $ext = "b";
        if ($filesize > 1024) {
            $filesize /= 1024;
            $ext = "Kb";
        }
コード例 #5
0
ファイル: manageCoverage.php プロジェクト: kitware/cdash
 $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) {
     $Build = new Build();
     $Build->Id = $buildId;
     $Build->FillFromId($Build->Id);
     $xml .= '<build>';
     $xml .= add_XML_value('id', $buildId);
     $Site = new Site();
     $Site->Id = $Build->SiteId;
     $xml .= add_XML_value('name', $Site->GetName() . '-' . $Build->GetName() . ' [' . gmdate(FMT_DATETIME, strtotime($Build->StartTime)) . ']');
     if ($buildid > 0 && $buildId == $buildid) {
         $xml .= add_XML_value('selected', 1);
     }
     $xml .= '</build>';
 }
 // For now take the first one
 if ($buildid > 0) {
     // Find the files associated with the build
     $Coverage = new Coverage();
     $Coverage->BuildId = $buildid;
     $fileIds = $Coverage->GetFiles();
     $row = '0';
     sort($fileIds);
     foreach ($fileIds as $fileid) {
         $CoverageFile = new CoverageFile();