Example #1
0
function do_submit($filehandle, $projectid, $expected_md5 = '', $do_checksum = true, $submission_id = 0)
{
    include 'cdash/config.php';
    // We find the daily updates
    // If we have php curl we do it asynchronously
    if (function_exists("curl_init") == TRUE) {
        $currentURI = get_server_URI(true);
        $request = $currentURI . "/cdash/dailyupdatescurl.php?projectid=" . $projectid;
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $request);
        curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_TIMEOUT, 1);
        if ($CDASH_USE_HTTPS) {
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        }
        curl_exec($ch);
        curl_close($ch);
    } else {
        include "cdash/dailyupdates.php";
        addDailyChanges($projectid);
    }
    if ($CDASH_USE_LOCAL_DIRECTORY && file_exists("local/submit.php")) {
        include "local/submit.php";
    }
    $scheduleid = 0;
    if ($submission_id !== 0) {
        $row = pdo_single_row_query("SELECT scheduleid from client_jobschedule2submission WHERE submissionid={$submission_id}");
        if (!empty($row)) {
            $scheduleid = $row[0];
        }
    } else {
        if (isset($_GET["clientscheduleid"])) {
            $scheduleid = pdo_real_escape_numeric($_GET["clientscheduleid"]);
        }
    }
    if ($CDASH_DB_TYPE != 'pgsql') {
        pdo_query("START TRANSACTION");
    }
    // Parse the XML file
    $handler = ctest_parse($filehandle, $projectid, $expected_md5, $do_checksum, $scheduleid);
    //this is the md5 checksum fail case
    if ($handler == FALSE) {
        //no need to log an error since ctest_parse already did
        return;
    }
    if ($CDASH_DB_TYPE != 'pgsql') {
        pdo_query("COMMIT");
    }
    // Send the emails if necessary
    if ($handler instanceof UpdateHandler) {
        send_update_email($handler, $projectid);
        sendemail($handler, $projectid);
    }
    if ($handler instanceof TestingHandler || $handler instanceof BuildHandler || $handler instanceof ConfigureHandler || $handler instanceof DynamicAnalysisHandler) {
        sendemail($handler, $projectid);
    }
    global $CDASH_ENABLE_FEED;
    if ($CDASH_ENABLE_FEED) {
        // Create the RSS feed
        CreateRSSFeed($projectid);
    }
}
Example #2
0
/**
 * This method could be running on a worker that is either remote or local, so it accepts
 * a file handle or a filename that it can query the CDash API for.
 **/
function do_submit($fileHandleOrSubmissionId, $projectid, $expected_md5 = '', $do_checksum = true, $submission_id = 0)
{
    include 'config/config.php';
    $filehandle = getSubmissionFileHandle($fileHandleOrSubmissionId);
    if ($filehandle === false) {
        // Logs will have already captured this issue at this point
        return false;
    }
    // We find the daily updates
    // If we have php curl we do it asynchronously
    $baseUrl = get_server_URI(false);
    $request = $baseUrl . '/ajax/dailyupdatescurl.php?projectid=' . $projectid;
    if ($CDASH_DAILY_UPDATES && curl_request($request) === false) {
        return false;
    }
    if ($CDASH_USE_LOCAL_DIRECTORY && file_exists('local/submit.php')) {
        include 'local/submit.php';
    }
    $scheduleid = 0;
    if ($submission_id !== 0) {
        $row = pdo_single_row_query("SELECT scheduleid from client_jobschedule2submission WHERE submissionid={$submission_id}");
        if (!empty($row)) {
            $scheduleid = $row[0];
        }
    } elseif (isset($_GET['clientscheduleid'])) {
        $scheduleid = pdo_real_escape_numeric($_GET['clientscheduleid']);
    }
    // Parse the XML file
    $handler = ctest_parse($filehandle, $projectid, $expected_md5, $do_checksum, $scheduleid);
    //this is the md5 checksum fail case
    if ($handler == false) {
        //no need to log an error since ctest_parse already did
        return false;
    }
    // Send the emails if necessary
    if ($handler instanceof UpdateHandler) {
        send_update_email($handler, $projectid);
        sendemail($handler, $projectid);
    }
    if ($handler instanceof TestingHandler || $handler instanceof BuildHandler || $handler instanceof ConfigureHandler || $handler instanceof DynamicAnalysisHandler) {
        sendemail($handler, $projectid);
    }
    global $CDASH_ENABLE_FEED;
    if ($CDASH_ENABLE_FEED) {
        // Create the RSS feed
        CreateRSSFeed($projectid);
    }
}