if (filemtime($file) > $lastcheck) { $filelist[] = $file; } } $i = 0; $n = count($filelist); foreach ($filelist as $filename) { ++$i; // split on path separator $pathParts = preg_split('_[\\\\/]_', $filename); // split on cdash separator "_" $cdashParts = explode('_', $pathParts[count($pathParts) - 1]); $projectid = get_project_id($cdashParts[0]); if ($projectid != -1) { $name = get_project_name($projectid); echo 'Project [' . $name . '] importing file (' . $i . '/' . $n . '): ' . $filename . "\n"; ob_flush(); flush(); $handle = fopen($filename, 'r'); ctest_parse($handle, $projectid); fclose($handle); unset($handle); } else { echo 'Project id not found - skipping file (' . $i . '/' . $n . '): ' . $filename . "\n"; ob_flush(); flush(); } } echo 'Import backup complete. ' . $i . ' files processed.' . "\n"; echo "\n"; return 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); } }
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); } }
} $handle = fopen($file, "r"); //$contents = fread($handle,filesize($file)); echo "."; flush(); ob_flush(); $numDots++; if ($numDots > 79) { echo "<br>\n"; flush(); ob_flush(); $numDots = 0; } //$xml_array = parse_XML($contents); //ctest_parse($xml_array,$projectid); ctest_parse($handle, $projectid, false); fclose($handle); unset($handle); } echo "<br>Done for the day" . $currentDay . "<br>\n"; flush(); ob_flush(); } } // end strlen(directory)>0 echo "<a href=index.php?project=" . urlencode($projName) . ">Back to {$projName} dashboard</a>\n"; return; } // Now doing the xslt transition generate_XSLT($xml, "import"); }