/** Get all the authors of a file */ public function GetAuthors($filename, $onlylast = false) { if (!$this->ProjectId) { echo 'DailyUpdate::GetAuthors(): ProjectId is not set<br>'; return false; } // Check if the note already exists $filename = pdo_real_escape_string($filename); // Remove if (substr($filename, 0, 2) == './') { $filename = substr($filename, 2); } $sql = ''; if ($onlylast) { $sql = ' ORDER BY dailyupdate.id DESC LIMIT 1'; } $query = pdo_query('SELECT DISTINCT up.userid,dailyupdate.id FROM user2project AS up,user2repository AS ur,dailyupdatefile,dailyupdate WHERE dailyupdatefile.dailyupdateid=dailyupdate.id AND dailyupdate.projectid=up.projectid AND ur.credential=dailyupdatefile.author AND up.projectid=' . qnum($this->ProjectId) . ' AND up.userid=ur.userid AND (ur.projectid=0 OR ur.projectid=' . qnum($this->ProjectId) . ")\n AND dailyupdatefile.filename LIKE '%" . $filename . "'" . $sql); if (!$query) { add_last_sql_error('DailyUpdate GetAuthors', $this->ProjectId); return false; } $authorids = array(); while ($query_array = pdo_fetch_array($query)) { $authorids[] = $query_array['userid']; } return $authorids; }
/** Save */ public function Save() { $version = pdo_real_escape_string($this->Version); $path = pdo_real_escape_string($this->Path); // Check if the version already exists $query = pdo_query("SELECT id FROM client_cmake WHERE version='" . $version . "'"); if (pdo_num_rows($query) == 0) { $sql = "INSERT INTO client_cmake (version)\n VALUES ('" . $version . "')"; pdo_query($sql); $this->Id = pdo_insert_id('client_cmake'); add_last_sql_error('clientCMake::Save()'); } else { // update $query_array = pdo_fetch_array($query); $this->Id = $query_array['id']; $sql = "UPDATE client_cmake SET version='" . $version . "' WHERE id=" . qnum($this->Id); pdo_query($sql); add_last_sql_error('clientCMake::Save()'); } // Insert into the siteid $query = pdo_query('SELECT cmakeid FROM client_site2cmake WHERE cmakeid=' . qnum($this->Id) . ' AND siteid=' . qnum($this->SiteId)); if (pdo_num_rows($query) == 0) { $sql = 'INSERT INTO client_site2cmake (siteid,cmakeid,path) VALUES (' . qnum($this->SiteId) . ',' . qnum($this->Id) . ",'" . $path . "')"; pdo_query($sql); add_last_sql_error('clientCMake::Save()'); } else { // update $sql = "UPDATE client_site2cmake SET path='" . $path . "' WHERE cmakeid=" . qnum($this->Id) . ' AND siteid=' . qnum($this->SiteId); pdo_query($sql); add_last_sql_error('clientCMake::Save()'); } }
function SetText($text) { if ($this->ProjectId == -1) { echo "Banner::SetText(): no ProjectId specified"; return false; } $this->Text = pdo_real_escape_string($text); // Check if the project is already if ($this->Exists()) { // Update the project $query = "UPDATE banner SET"; $query .= " text='" . $this->Text . "'"; $query .= " WHERE projectid='" . $this->ProjectId . "'"; if (!pdo_query($query)) { add_last_sql_error("Banner:SetText", $this->ProjectId); echo $query; return false; } } else { $query = "INSERT INTO banner (projectid,text)\n VALUES (" . qnum($this->ProjectId) . ",'" . $this->Text . "')"; if (!pdo_query($query)) { add_last_sql_error("Banner:SetText", $this->ProjectId); echo $query; return false; } } return true; }
function Insert() { $text = pdo_real_escape_string($this->Text); // Get this->Id from the database if text is already in the label table: $this->Id = pdo_get_field_value("SELECT id FROM label WHERE text='{$text}'", 'id', 0); // Or, if necessary, insert a new row, then get the id of the inserted row: if (0 == $this->Id) { $query = "INSERT INTO label (text) VALUES ('{$text}')"; if (!pdo_query($query)) { add_last_sql_error('Label::Insert'); return false; } $this->Id = pdo_insert_id('label'); } // Insert relationship records, too, but only for those relationships // established by callers. (If coming from test.php, for example, TestId // will be set, but none of the others will. Similarly for other callers.) $this->InsertAssociation('label2build', 'buildid', $this->BuildId); $this->InsertAssociation('label2buildfailure', 'buildfailureid', $this->BuildFailureId); $this->InsertAssociation('label2coveragefile', 'buildid', $this->CoverageFileBuildId, 'coveragefileid', $this->CoverageFileId); $this->InsertAssociation('label2dynamicanalysis', 'dynamicanalysisid', $this->DynamicAnalysisId); $this->InsertAssociation('label2test', 'buildid', $this->TestBuildId, 'testid', $this->TestId); // TODO: Implement this: // //$this->InsertAssociation($this->UpdateFileKey, // 'label2updatefile', 'updatefilekey'); return true; }
function MD5Exists() { $md5 = pdo_real_escape_string($this->md5); $row = pdo_single_row_query("SELECT buildid FROM buildfile WHERE md5='" . $md5 . "'"); if (empty($row)) { return false; } return $row[0]; }
public function Insert() { $role = pdo_real_escape_string($this->Role); $query = "INSERT INTO test2image (imgid,testid,role)\n VALUES ('{$this->Id}','{$this->TestId}','{$role}')"; if (!pdo_query($query)) { add_last_sql_error('TestImage Insert'); return false; } return true; }
public function Insert() { if (!$this->BuildId) { add_log('BuildId not set', 'BuildNote::Insert()', LOG_ERR, 0, $this->Id); return false; } if (!$this->Time) { add_log('Time not set', 'BuildNote::Insert()', LOG_ERR, 0, $this->Id); return false; } if (!$this->Name) { add_log('Name not set', 'BuildNote::Insert()', LOG_ERR, 0, $this->Id); return false; } if (!$this->Text) { add_log('Text not set', 'BuildNote::Insert()', LOG_ERR, 0, $this->Id); return false; } // Check if the note already exists $crc32 = $this->GetCrc32(); $text = pdo_real_escape_string($this->Text); $timestamp = pdo_real_escape_string($this->Time); $name = pdo_real_escape_string($this->Name); $notecrc32 = pdo_query("SELECT id FROM note WHERE crc32='{$crc32}'"); if (pdo_num_rows($notecrc32) == 0) { if ($this->Id) { $query = "INSERT INTO note (id,text,name,crc32) VALUES ('{$this->Id}','{$text}','{$name}','{$crc32}')"; } else { $query = "INSERT INTO note (text,name,crc32) VALUES ('{$text}','{$name}','{$crc32}')"; } if (!pdo_query($query)) { add_last_sql_error('BuildNote:Insert', 0, $this->BuildId); return false; } if (!$this->Id) { $this->Id = pdo_insert_id('note'); } } else { // already there $notecrc32_array = pdo_fetch_array($notecrc32); $this->Id = $notecrc32_array['id']; } if (!$this->Id) { echo 'BuildNote::Insert(): No NoteId'; return false; } $query = "INSERT INTO build2note (buildid,noteid,time)\n VALUES ('{$this->BuildId}','{$this->Id}','{$this->Time}')"; if (!pdo_query($query)) { add_last_sql_error('BuildNote:Insert', 0, $this->BuildId); return false; } return true; }
function Insert() { $name = pdo_real_escape_string($this->Name); $type = pdo_real_escape_string($this->Type); $value = pdo_real_escape_string($this->Value); $query = "INSERT INTO testmeasurement (testid,name,type,value)\n VALUES ('{$this->TestId}','{$name}','{$type}','{$value}')"; if (!pdo_query($query)) { add_last_sql_error("TestMeasurement Insert"); return false; } return true; }
function Insert() { if (!$this->BuildId) { echo "BuildNote::Insert(): BuildId is not set<br>"; return false; } if (!$this->Time) { echo "BuildNote::Insert(): Time is not set<br>"; return false; } if (!$this->Name) { echo "BuildNote::Insert(): Name is not set<br>"; return false; } if (!$this->Text) { echo "BuildNote::Insert(): Text is not set<br>"; return false; } // Check if the note already exists $crc32 = $this->GetCrc32(); $text = pdo_real_escape_string($this->Text); $timestamp = pdo_real_escape_string($this->Time); $name = pdo_real_escape_string($this->Name); $notecrc32 = pdo_query("SELECT id FROM note WHERE crc32='{$crc32}'"); if (pdo_num_rows($notecrc32) == 0) { if ($this->Id) { $query = "INSERT INTO note (id,text,name,crc32) VALUES ('{$this->Id}','{$text}','{$name}','{$crc32}')"; } else { $query = "INSERT INTO note (text,name,crc32) VALUES ('{$text}','{$name}','{$crc32}')"; } if (!pdo_query($query)) { add_last_sql_error("BuildNote:Insert", 0, $this->BuildId); return false; } if (!$this->Id) { $this->Id = pdo_insert_id("note"); } } else { $notecrc32_array = pdo_fetch_array($notecrc32); $this->Id = $notecrc32_array["id"]; } if (!$this->Id) { echo "BuildNote::Insert(): No NoteId"; return false; } $query = "INSERT INTO build2note (buildid,noteid,time)\n VALUES ('{$this->BuildId}','{$this->Id}','{$this->Time}')"; if (!pdo_query($query)) { add_last_sql_error("BuildNote:Insert", 0, $this->BuildId); return false; } return true; }
public function Insert() { if (!$this->BuildId) { add_log('BuildId is not set', __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_ERR); return false; } if (!$this->Filename) { add_log('Filename is not set', __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_ERR); return false; } if (!$this->Sha1Sum) { add_log('Sha1Sum is not set', __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_ERR); return false; } if (!$this->Filesize) { add_log('Filesize is not set', __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_ERR); return false; } if (empty($this->IsUrl)) { $this->IsUrl = 0; } if (!$this->IsUrl) { $filename = pdo_real_escape_string(basename($this->Filename)); } else { $filename = pdo_real_escape_string($this->Filename); } // Check if the file already exists $filequery = pdo_query("SELECT id FROM uploadfile WHERE sha1sum = '" . $this->Sha1Sum . "' AND filename ='{$filename}'"); if (pdo_num_rows($filequery) == 0) { // Insert the file into the database $query = "INSERT INTO uploadfile (filename, filesize, sha1sum, isurl) VALUES ('{$filename}','{$this->Filesize}','{$this->Sha1Sum}', '{$this->IsUrl}')"; if (!pdo_query($query)) { add_last_sql_error('Uploadfile::Insert', 0, $this->BuildId); return false; } $this->Id = pdo_insert_id('uploadfile'); } else { $filequery_array = pdo_fetch_array($filequery); $this->Id = $filequery_array['id']; } if (!$this->Id) { add_log('No Id', __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_ERR); return false; } if (!pdo_query("INSERT INTO build2uploadfile (fileid, buildid)\n VALUES ('{$this->Id}','{$this->BuildId}')")) { add_last_sql_error('UploadFile::Insert', 0, $this->BuildId); return false; } return true; }
function Insert() { if (strlen($this->DynamicAnalysisId) == 0) { echo "DynamicAnalysisDefect::Insert DynamicAnalysisId not set"; return false; } $this->Type = pdo_real_escape_string($this->Type); $this->Value = pdo_real_escape_string($this->Value); $this->DynamicAnalysisId = pdo_real_escape_string($this->DynamicAnalysisId); $query = "INSERT INTO dynamicanalysisdefect (dynamicanalysisid,type,value)\n VALUES (" . qnum($this->DynamicAnalysisId) . ",'{$this->Type}','{$this->Value}')"; if (!pdo_query($query)) { add_last_sql_error("DynamicAnalysisDefect Insert"); return false; } return true; }
public function Insert() { if (strlen($this->UpdateId) == 0) { echo 'BuildUpdateFile:Insert UpdateId not set'; return false; } $this->Filename = pdo_real_escape_string($this->Filename); // Sometimes the checkin date is not found in that case we put the usual date if ($this->CheckinDate == 'Unknown') { $this->CheckinDate = '1980-01-01'; } if (strtotime($this->CheckinDate) === false && is_numeric($this->CheckinDate)) { $this->CheckinDate = date(FMT_DATETIME, $this->CheckinDate); } elseif (strtotime($this->CheckinDate) !== false) { $this->CheckinDate = date(FMT_DATETIME, strtotime($this->CheckinDate)); } else { $this->CheckinDate = '1980-01-01'; } $this->Author = pdo_real_escape_string($this->Author); $this->UpdateId = pdo_real_escape_string($this->UpdateId); // Check if we have a robot file for this build $robot = pdo_query('SELECT authorregex FROM projectrobot,build,build2update WHERE projectrobot.projectid=build.projectid AND build2update.buildid=build.id AND build2update.updateid=' . qnum($this->UpdateId) . " AND robotname='" . $this->Author . "'"); if (pdo_num_rows($robot) > 0) { $robot_array = pdo_fetch_array($robot); $regex = $robot_array['authorregex']; preg_match($regex, $this->Log, $matches); if (isset($matches[1])) { $this->Author = $matches[1]; } } $this->Email = pdo_real_escape_string($this->Email); $this->Committer = pdo_real_escape_string($this->Committer); $this->CommitterEmail = pdo_real_escape_string($this->CommitterEmail); $this->Log = pdo_real_escape_string($this->Log); $this->Revision = pdo_real_escape_string($this->Revision); $this->PriorRevision = pdo_real_escape_string($this->PriorRevision); $query = 'INSERT INTO updatefile (updateid,filename,checkindate,author,email,log,revision,priorrevision,status,committer,committeremail) VALUES (' . qnum($this->UpdateId) . ",'{$this->Filename}','{$this->CheckinDate}','{$this->Author}','{$this->Email}',\n '{$this->Log}','{$this->Revision}','{$this->PriorRevision}','{$this->Status}','{$this->Committer}','{$this->CommitterEmail}')"; if (!pdo_query($query)) { add_last_sql_error('BuildUpdateFile Insert', 0, $this->UpdateId); return false; } }
public function Insert() { if (!$this->BuildId) { echo 'BuildError::Insert(): BuildId not set<br>'; return false; } $text = pdo_real_escape_string($this->Text); if (strlen($this->PreContext) == 0) { $precontext = 'NULL'; } else { $precontext = "'" . pdo_real_escape_string($this->PreContext) . "'"; } if (strlen($this->PostContext) == 0) { $postcontext = 'NULL'; } else { $postcontext = "'" . pdo_real_escape_string($this->PostContext) . "'"; } if (empty($this->SourceLine)) { $this->SourceLine = 0; } if (empty($this->RepeatCount)) { $this->RepeatCount = 0; } $crc32 = 0; // Compute the crc32 if ($this->SourceLine == 0) { $crc32 = crc32($text); // no need for precontext or postcontext, this doesn't work for parallel build } else { $crc32 = crc32($text . $this->SourceFile . $this->SourceLine); // some warning can be on the same line } $query = 'INSERT INTO builderror (buildid,type,logline,text,sourcefile,sourceline,precontext, postcontext,repeatcount,newstatus,crc32) VALUES (' . qnum($this->BuildId) . ',' . qnum($this->Type) . ',' . qnum($this->LogLine) . ",'{$text}','{$this->SourceFile}'," . qnum($this->SourceLine) . ', ' . $precontext . ',' . $postcontext . ',' . qnum($this->RepeatCount) . ',0,' . qnum($crc32) . ')'; if (!pdo_query($query)) { add_last_sql_error('BuildError Insert', 0, $this->BuildId); return false; } return true; }
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'); }
/** Save in the database */ function Save() { if (!$this->BuildId || !is_numeric($this->BuildId)) { echo "BuildConfigureError::Save(): BuildId not set"; return false; } if (!$this->Type || !is_numeric($this->Type)) { echo "BuildConfigureError::Save(): Type not set"; return false; } if (!$this->Exists()) { $text = pdo_real_escape_string($this->Text); $query = "INSERT INTO configureerror (buildid,type,text)\n VALUES (" . qnum($this->BuildId) . "," . qnum($this->Type) . ",'{$text}')"; if (!pdo_query($query)) { add_last_sql_error("BuildConfigureError:Save", 0, $this->BuildId); return false; } } return true; }
function Insert() { if (!is_numeric($this->ProjectId) || !is_numeric($this->BuildId) || !is_numeric($this->ResourceId) || !is_numeric($this->ResourceType) || !is_numeric($this->Type)) { return false; } $description = pdo_real_escape_string($this->Description); // If the projectid is not set but the buildid is we are trying to find // the projectid if ($this->ProjectId == 0 && $this->BuildId > 0) { $query = pdo_query("SELECT projectid FROM build WHERE id='" . $this->BuildId . "'"); if (pdo_num_rows($query) > 0) { $query_array = pdo_fetch_array($query); $this->ProjectId = $query_array['projectid']; } } // Insert a new row every time an error exists $now = date("Y-m-d H:i:s"); $sql = "INSERT INTO errorlog (projectid,buildid,type,date,resourcetype,resourceid,description)\n VALUES ('" . $this->ProjectId . "','" . $this->BuildId . "','" . $this->Type . "','" . $now . "','" . $this->ResourceType . "','" . $this->ResourceId . "','" . $description . "')"; pdo_query($sql); echo pdo_error(); // We don't log on purpose (loop loop ;) return true; }
/** Get the library id from the description */ function GetLibrary($name, $version = '') { $sql = "SELECT id FROM client_library WHERE "; $ids = array(); $firstarg = true; if ($name != '') { $name = pdo_real_escape_string($name); $sql .= " name='" . $name . "'"; $firstarg = false; } if ($version != '') { if (!$firstarg) { $sql .= " AND "; } $version = pdo_real_escape_string($version); $sql .= " version='" . $version . "'"; $firstarg = false; } $query = pdo_query($sql); while ($query_array = pdo_fetch_array($query)) { $ids[] = $query_array['id']; } return $ids; }
/** Update the content of the file */ function Update($buildid) { if (!is_numeric($buildid) || $buildid == 0) { return; } include "cdash/config.php"; // Compute the crc32 of the file (before compression for backward compatibility) $this->Crc32 = crc32($this->FullPath . $this->File); $this->FullPath = pdo_real_escape_string($this->FullPath); if ($CDASH_USE_COMPRESSION) { $file = gzcompress($this->File); if ($file === false) { $file = $this->File; } else { if ($CDASH_DB_TYPE == "pgsql") { if (strlen($this->File) < 2000) { $file = $this->File; } $file = pg_escape_bytea(base64_encode($file)); // hopefully does the escaping correctly } } } else { $file = $this->File; if ($CDASH_DB_TYPE == "pgsql") { $file = pg_escape_bytea($file); } } $file = pdo_real_escape_string($file); $coveragefile = pdo_query("SELECT id FROM coveragefile WHERE crc32=" . qnum($this->Crc32)); add_last_sql_error("CoverageFile:Update"); if (pdo_num_rows($coveragefile) > 0) { $coveragefile_array = pdo_fetch_array($coveragefile); $this->Id = $coveragefile_array["id"]; // Update the current coverage.fileid $coverage = pdo_query("SELECT c.fileid FROM coverage AS c,coveragefile AS cf \n WHERE c.fileid=cf.id AND c.buildid=" . qnum($buildid) . "\n AND cf.fullpath='{$this->FullPath}'"); $coverage_array = pdo_fetch_array($coverage); $prevfileid = $coverage_array["fileid"]; pdo_query("UPDATE coverage SET fileid=" . qnum($this->Id) . " WHERE buildid=" . qnum($buildid) . " AND fileid=" . qnum($prevfileid)); add_last_sql_error("CoverageFile:Update"); $row = pdo_single_row_query("SELECT COUNT(*) AS c FROM label2coveragefile WHERE buildid=" . qnum($buildid) . " AND coveragefileid=" . qnum($prevfileid)); if (isset($row['c']) && $row['c'] > 0) { pdo_query("UPDATE label2coveragefile SET coveragefileid=" . qnum($this->Id) . " WHERE buildid=" . qnum($buildid) . " AND coveragefileid=" . qnum($prevfileid)); add_last_sql_error("CoverageFile:Update"); } // Remove the file if the crc32 is NULL pdo_query("DELETE FROM coveragefile WHERE id=" . qnum($prevfileid) . " AND file IS NULL and crc32 IS NULL"); add_last_sql_error("CoverageFile:Update"); } else { // We find the current fileid based on the name and the file should be null $coveragefile = pdo_query("SELECT cf.id,cf.file FROM coverage AS c,coveragefile AS cf \n WHERE c.fileid=cf.id AND c.buildid=" . qnum($buildid) . "\n AND cf.fullpath='{$this->FullPath}' ORDER BY cf.id ASC"); $coveragefile_array = pdo_fetch_array($coveragefile); // The GcovTarHandler creates coveragefiles before coverages // so we need a simpler query in this case. if (empty($coveragefile_array)) { $coveragefile = pdo_query("SELECT id, file FROM coveragefile\n WHERE fullpath='{$this->FullPath}' AND file IS NULL\n ORDER BY id ASC"); $coveragefile_array = pdo_fetch_array($coveragefile); } $this->Id = $coveragefile_array["id"]; pdo_query("UPDATE coveragefile SET file='{$file}',crc32='{$this->Crc32}' WHERE id=" . qnum($this->Id)); add_last_sql_error("CoverageFile:Update"); } return true; }
$xml .= get_cdash_dashboard_xml_by_name($projectname, $date); $nightlytime = $project_array["nightlytime"]; // We select the builds list($previousdate, $currentstarttime, $nextdate, $today) = get_dates($date, $nightlytime); $xml .= "<menu>"; $xml .= add_XML_value("previous", "testOverview.php?project=" . urlencode($projectname) . "&date=" . $previousdate); if ($date != "" && date(FMT_DATE, $currentstarttime) != date(FMT_DATE)) { $xml .= add_XML_value("next", "testOverview.php?project=" . urlencode($projectname) . "&date=" . $nextdate); } else { $xml .= add_XML_value("nonext", "1"); } $xml .= add_XML_value("current", "testOverview.php?project=" . urlencode($projectname) . "&date="); $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;
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); $siteid = $build_array["siteid"]; $buildtype = $build_array["type"]; $buildname = $build_array["name"]; $starttime = $build_array["starttime"];
} @($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; } if ($submit) { // Mark any previous rule as done /*$now = gmdate(FMT_DATETIME); pdo_query("UPDATE build2grouprule SET endtime='$now' WHERE groupid='$previousgroupid' AND buildtype='$buildtype' AND buildname='$buildname' AND siteid='$siteid' AND endtime='1980-01-01 00:00:00'");*/ if (!isset($previousgroupid) || !is_numeric($previousgroupid)) { echo "Not a valid previousgroupid!"; return; } // Delete the previous rule for that build
=========================================================================*/ include "cdash/config.php"; require_once "cdash/pdo.php"; include_once "cdash/common.php"; include_once "cdash/version.php"; require_once "cdash/cdashmail.php"; $db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}"); pdo_select_db("{$CDASH_DB_NAME}", $db); $xml = begin_XML_for_XSLT(); $xml .= "<title>Recover password</title>"; if (isset($CDASH_NO_REGISTRATION) && $CDASH_NO_REGISTRATION == 1) { $xml .= add_XML_value("noregister", "1"); } @($recover = $_POST["recover"]); if ($recover) { $email = pdo_real_escape_string($_POST["email"]); $emailResult = pdo_query("SELECT id FROM " . qid("user") . " where email='{$email}'"); add_last_sql_error("recoverPassword"); if (pdo_num_rows($emailResult) == 0) { $xml .= "<warning>This email is not registered.</warning>"; } else { // Create a new password $keychars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!#\$%&"; $length = 10; // seed with microseconds function make_seed_recoverpass() { list($usec, $sec) = explode(' ', microtime()); return (double) $sec + (double) $usec * 100000; } srand(make_seed_recoverpass());
function UpdateAllowedProjects($projectNames) { if (!$this->Id) { add_log("ClientSite::UpdateAllowedProjects()", "Id not set"); return; } pdo_query("DELETE FROM client_site2project WHERE siteid=" . qnum($this->Id)); foreach ($projectNames as $projectName) { $projectid = 0; $projectName = pdo_real_escape_string($projectName); $project = pdo_query("SELECT id FROM project WHERE name='{$projectName}'"); if (pdo_num_rows($project) > 0) { $project_array = pdo_fetch_array($project); $projectid = $project_array["id"]; } if (!$projectid) { add_log("ClientSite::UpdateAllowedProjects()", "Invalid project name given: {$projectName}"); continue; } $sql = "INSERT INTO client_site2project (siteid,projectid) VALUES ('" . $this->Id . "','" . $projectid . "')"; pdo_query($sql); add_last_sql_error("clientSite::UpdateAllowedProjects()"); } }
?> <html> <head> <title>CDash-Groups Description</title> <meta name="robots" content="noindex,nofollow" /> <link rel="StyleSheet" type="text/css" href="cdash/cssfile"/> </head> <body> <table border="0" cellpadding="3" cellspacing="1" bgcolor="#0000aa" width="100%"> <tr> <th class="table-heading1"><a href="#" class="jqmClose">[close]</a></th> <th class="table-heading1">CDash Build Group Description</th> </tr> <?php $i = 0; $project = htmlspecialchars(pdo_real_escape_string($_GET["project"])); $projectid = get_project_id($project); if ($projectid < 1) { ?> </table> <center><a href="#" class="jqmClose">Close</a></center> <?php return; } $group = pdo_query("SELECT buildgroup.name,buildgroup.description\n FROM buildgroup,buildgroupposition \n WHERE buildgroup.projectid='{$projectid}' \n AND buildgroup.id = buildgroupposition.buildgroupid\n AND buildgroup.endtime = '1980-01-01 00:00:00'\n AND buildgroupposition.endtime = '1980-01-01 00:00:00'\n ORDER BY buildgroupposition.position ASC"); while ($group_array = pdo_fetch_array($group)) { ?> <tr class="<?php if ($i % 2 == 0) { echo "treven";
function rest_put() { global $projectid; if (isset($_GET['threshold'])) { // Modify an existing subproject group. $groupid = pdo_real_escape_numeric($_GET['groupid']); $Group = new SubProjectGroup(); $Group->SetProjectId($projectid); $Group->SetId($groupid); $name = pdo_real_escape_string($_GET['name']); $Group->SetName($name); $threshold = pdo_real_escape_numeric($_GET['threshold']); $Group->SetCoverageThreshold($threshold); $Group->SetIsDefault($_GET['is_default']); $Group->Save(); return; } $subprojectid = get_subprojectid(); if ($subprojectid === false) { return; } $SubProject = new SubProject(); $SubProject->SetId($subprojectid); if (isset($_GET['dependencyid'])) { // Add dependency to existing subproject. $dependencyid = pdo_real_escape_numeric($_GET['dependencyid']); $SubProject->AddDependency($dependencyid); return; } if (isset($_GET['groupname'])) { // Change which group a subproject belongs to. $groupName = pdo_real_escape_string($_GET['groupname']); $SubProject->SetGroup($groupName); $SubProject->Save(); return; } }
/** */ function pdo_real_escape_numeric($unescaped_string, $link_identifier = NULL) { global $CDASH_DB_TYPE; if (isset($CDASH_DB_TYPE) && $CDASH_DB_TYPE == "pgsql" && $unescaped_string == "") { // MySQL interprets an empty string as zero when assigned to a numeric field, // for PostgreSQL this must be done explicitly: $unescaped_string = "0"; } return pdo_real_escape_string($unescaped_string, $link_identifier); }
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; }
/** Add a credential for a given project */ function AddCredential($credential) { if (empty($credential)) { return false; } if (!$this->UserId) { add_log('UserId not set', "UserProject AddCredential()", LOG_ERR, $this->ProjectId, 0, CDASH_OBJECT_USER, $this->UserId); return false; } // Check if the credential exists for all the project or the given project $credential = pdo_real_escape_string($credential); $query = pdo_query("SELECT userid FROM user2repository WHERE userid=" . qnum($this->UserId) . "\n AND (projectid=" . qnum($this->ProjectId) . " OR projectid=0)\n AND credential='" . $credential . "'"); add_last_sql_error("UserProject AddCredential"); if (pdo_num_rows($query) == 0) { pdo_query("INSERT INTO user2repository (userid,projectid,credential)\n VALUES(" . qnum($this->UserId) . "," . qnum($this->ProjectId) . ",'" . $credential . "')"); add_last_sql_error("UserProject AddCredential"); return true; } return false; }
// If the database already exists and we have all the tables if (true === @pdo_select_db("{$CDASH_DB_NAME}", $db) && pdo_query('SELECT id FROM ' . qid('user') . ' LIMIT 1', $db, false)) { $xml .= '<database>1</database>'; } else { $xml .= '<database>0</database>'; $xml .= '<dashboard_timeframe>24</dashboard_timeframe>'; // If we should create the tables @($Submit = $_POST['Submit']); if ($Submit) { if ($db_type == 'mysql') { pdo_select_db(''); } else { pdo_select_db("{$CDASH_DB_NAME}"); } $admin_email = htmlspecialchars(pdo_real_escape_string($_POST['admin_email'])); $admin_password = htmlspecialchars(pdo_real_escape_string($_POST['admin_password'])); $valid_email = true; if (strlen($admin_email) < 6 || strstr($admin_email, '@') === false) { $xml .= '<db_created>0</db_created>'; $xml .= "<alert>* Administrator's email should be a valid email address</alert>"; $valid_email = false; } global $CDASH_MINIMUM_PASSWORD_LENGTH, $CDASH_MINIMUM_PASSWORD_COMPLEXITY, $CDASH_PASSWORD_COMPLEXITY_COUNT; if ($valid_email && strlen($admin_password) < $CDASH_MINIMUM_PASSWORD_LENGTH) { $xml .= '<db_created>0</db_created>'; $xml .= "<alert>* Administrator's password must be at least {$CDASH_MINIMUM_PASSWORD_LENGTH} characters</alert>"; $valid_email = false; } if ($valid_email) { $complexity = getPasswordComplexity($admin_password); if ($complexity < $CDASH_MINIMUM_PASSWORD_COMPLEXITY) {
// queryTests.php displays test results based on query parameters // $noforcelogin = 1; include "cdash/config.php"; require_once "cdash/pdo.php"; include 'login.php'; include_once "cdash/common.php"; include "cdash/version.php"; require_once "filterdataFunctions.php"; @($date = $_GET["date"]); if ($date != NULL) { $date = htmlspecialchars(pdo_real_escape_string($date)); } @($projectname = $_GET["project"]); if ($projectname != NULL) { $projectname = htmlspecialchars(pdo_real_escape_string($projectname)); } $start = microtime_float(); $db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}"); pdo_select_db("{$CDASH_DB_NAME}", $db); if ($projectname == '') { $project = pdo_single_row_query("SELECT * FROM project LIMIT 1"); } else { $project = pdo_single_row_query("SELECT * FROM project WHERE name='{$projectname}'"); } checkUserPolicy(@$_SESSION['cdash']['loginid'], $project['id']); list($previousdate, $currentstarttime, $nextdate) = get_dates($date, $project['nightlytime']); $xml = begin_XML_for_XSLT(); $xml .= "<title>CDash : " . $project['name'] . "</title>"; $xml .= get_cdash_dashboard_xml_by_name($project['name'], $date); // Filters: