8 define(
"TITLE_ACME_REVIEW", _(
"ACME Review"));
19 function proj_cmp($rowa, $rowb)
21 $key1 = $rowb[
'count'] - $rowa[
'count'];
27 return (strnatcasecmp($rowa[
'project_name'], $rowb[
'project_name']));
32 var $Name =
"acme_review";
33 var $Title = TITLE_ACME_REVIEW;
37 var $Dependency = array(
"browse",
"view");
50 $text = _(
"ACME High Level Review");
54 $text = _(
"ACME Low Level Review");
63 $text2 = _(
"ACME Review");
81 $sql =
"select acme_project_fk from acme_pfile where pfile_fk='$uploadtreeRow[pfile_fk]' limit 1";
84 if (pg_num_rows($result) > 0) {
86 $acme_pfileRow = pg_fetch_assoc($result);
89 $sql =
"select * from acme_project where acme_project_pk='$acme_pfileRow[acme_project_fk]'";
90 $projresult = pg_query(
$PG_CONN, $sql);
92 if (pg_num_rows($projresult) > 0) {
93 $acme_project_array[$acme_pfileRow[
'acme_project_fk']] = pg_fetch_assoc(
95 $acme_project_array[$acme_pfileRow[
'acme_project_fk']][
'count'] = (($uploadtreeRow[
'rgt'] -
96 $uploadtreeRow[
'lft']) + 1) / 2;
101 $sql =
"select uploadtree_pk, pfile_fk, lft, rgt from uploadtree where parent= $uploadtreeRow[uploadtree_pk]";
102 $childrenResult = pg_query(
$PG_CONN, $sql);
104 while ($child = pg_fetch_assoc($childrenResult)) {
107 pg_free_result($childrenResult);
109 pg_free_result($result);
124 $acme_project_array = array();
126 $sql =
"select uploadtree_pk, pfile_fk, lft, rgt from uploadtree where upload_fk='$upload_pk' and parent is null";
129 $row = pg_fetch_assoc($result);
131 pg_free_result($result);
133 return $acme_project_array;
146 $acme_project_array = array();
149 $sql =
"select distinct(acme_project_fk) as acme_project_fk, count(acme_project_fk) as filecount from acme_pfile
150 right join uploadtree on uploadtree.pfile_fk=acme_pfile.pfile_fk where upload_fk=$upload_pk
151 group by acme_project_fk order by filecount desc";
154 while ($row = pg_fetch_assoc($result)) {
155 if ($row[
'filecount'] < $MinCount) {
160 $sql =
"select * from acme_project where acme_project_pk='$row[acme_project_fk]'";
161 $projresult = pg_query(
$PG_CONN, $sql);
163 if (pg_num_rows($projresult) > 0) {
164 $acme_project_array[$idx] = pg_fetch_assoc($projresult);
165 $acme_project_array[$idx][
'count'] = $row[
'filecount'];
170 return($acme_project_array);
183 $uploadtreeRec =
GetSingleRec(
"uploadtree",
"where upload_fk=$upload_pk and parent is null");
184 $Outbuf .=
Dir2Browse($this->Name,$uploadtreeRec[
'uploadtree_pk'], NULL, 1,
"acme");
187 $URI =
"?mod=" . $this->Name .
Traceback_parm_keep(array(
"page",
"upload",
"folic",
"detail"));
188 $Outbuf .=
"<form action='" . $URI .
"' method='POST'>\n";
190 $Outbuf .=
"<table border=1>";
192 $text = _(
'Include');
193 $Outbuf .=
"<th>$text</th>";
194 $text = _(
'Project');
195 $Outbuf .=
"<th>$text</th>";
197 $Outbuf .=
"<th>$text</th>";
199 $Outbuf .=
"<th>$text</th>";
200 $text = _(
'Description');
201 $Outbuf .=
"<th>$text</th>";
202 $text = _(
'License');
203 $Outbuf .=
"<th>$text</th>";
204 $text = _(
'Version');
205 $Outbuf .=
"<th>$text</th>";
209 $RowStyle1 =
"style='background-color:lavender'";
210 $RowStyle2 =
"style='background-color:lightyellow'";
214 foreach ($acme_project_array as $project) {
219 $RowStyle = (($RowNum ++ % (2 * $ColorSpanRows)) < $ColorSpanRows) ? $RowStyle1 : $RowStyle2;
221 $Outbuf .=
"<tr $RowStyle>";
222 $Checked = $project[
'include'] ==
't' ?
"checked=\"checked\"" :
'';
223 $Outbuf .=
"<td><input type='checkbox' name='includeproj[$project[acme_project_pk]]' $Checked></td>\n";
224 $Outbuf .=
"<td>$project[project_name]</td>";
226 "&acme_project=$project[acme_project_pk]&upload=$upload_pk";
227 $Outbuf .=
"<td><a href='$ProjectListURL'>$project[count]</a></td>";
228 $Outbuf .=
"<td><a href='$project[url]'>$project[url]</a></td>";
229 $Outbuf .=
"<td>" . htmlentities($project[
'description'], ENT_HTML5 | ENT_QUOTES) .
"</td>";
230 $Outbuf .=
"<td>$project[licenses]</td>";
231 $Outbuf .=
"<td>$project[version]</td>";
234 $Outbuf .=
"</table>";
236 $Outbuf .=
"$RowNum rows found<br>";
238 $text = _(
"Save and Generate SPDX file");
239 $Outbuf .=
"<p><input type='submit' value='$text' name='spdxbtn'>\n";
241 $Outbuf .=
" <input type='submit' value='$text' name='savebtn'>\n";
242 $Outbuf .=
"</form>\n";
260 foreach ($acme_project_array as $project) {
261 $sql =
"insert into acme_upload (upload_fk, acme_project_fk, include, detail, count) values ($upload_pk, $project[acme_project_pk], true, $detail, $project[count])";
264 pg_free_result($result);
278 $spdx =
'<?xml version="1.0" encoding="UTF-8" ?>' .
"\n";
279 $spdx .=
'<rdf:RDF' .
"\n";
280 $spdx .=
' xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"' .
"\n";
281 $spdx .=
' xmlns="http://spdx.org/rdf/terms#"' .
"\n";
282 $spdx .=
' xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">' .
"\n";
283 $spdx .=
' <SpdxDocument rdf:about="http://www.spdx.org/tools#SPDXANALYSIS">' .
"\n";
284 $spdx .=
' <specVersion>SPDX-1.1</specVersion>' .
"\n";
285 $spdx .=
' <dataLicense rdf:about="http://spdx.org/licenses/PDDL-1.0" />' .
"\n";
286 $spdx .=
' <CreationInfo>' .
"\n";
287 $spdx .=
" <creator>Tool: FOSSology v " . $SysConf[
'BUILD'][
'VERSION']
288 .
" svn " . $SysConf[
'BUILD'][
'COMMIT_HASH'] .
"</creator>\n";
289 $spdx .=
"<created>" . date(
'c') .
"</created>\n";
290 $spdx .=
'</CreationInfo>' .
"\n";
292 $in_encoding = iconv_get_encoding(
"input_encoding");
293 foreach ($acme_project_array as $project) {
295 $spdx .=
"<Package>\n";
296 $spdx .=
'<name>' . str_replace(
"&",
" and ", strip_tags($project[
'project_name'])) .
'</name>' .
"\n";
297 $spdx .=
"<versionInfo>$project[version]</versionInfo>\n";
298 $spdx .=
"<licenseDeclared>$project[licenses]</licenseDeclared>\n";
299 $spdx .=
"<sourceInfo>ProjectURL: $project[url]</sourceInfo>\n";
300 $spdx .=
'<description>' . str_replace(
"&",
" and ",
301 strip_tags($project[
'description'])) .
'</description>' .
"\n";
302 $spdx .=
"</Package>\n";
318 $spdx .=
" </SpdxDocument> </rdf:RDF>\n";
336 $detail = empty($detail) ? 0 : 1;
342 if (empty($agent_pk)) {
343 echo
"Missing fossology license data. Run a license scan on this upload.<br>";
349 $acme_uploadRec =
GetSingleRec(
"acme_upload",
"where upload_fk=$upload_pk ");
350 if (empty($acme_uploadRec)) {
362 $sql =
"select * from acme_upload, acme_project "
363 .
"where acme_project_pk=acme_project_fk and detail=$detail and upload_fk=$upload_pk";
366 $acme_project_array = pg_fetch_all($result);
367 $acme_project_array_orig = $acme_project_array;
370 if (!empty($savebtn) or !empty($spdxbtn)) {
372 foreach ($acme_project_array as &$project) {
373 $project[
'include'] =
'f';
376 if (array_key_exists(
'includeproj', $_POST)) {
377 $includeArray = $_POST[
'includeproj'];
378 foreach ($acme_project_array as &$project) {
379 if (array_key_exists($project[
'acme_project_fk'], $includeArray)) {
380 $project[
'include'] =
"t";
386 $NumRecs = count($acme_project_array);
387 for ($i = 0; $i < $NumRecs; $i ++) {
388 $project = $acme_project_array[$i];
389 $project_orig = $acme_project_array_orig[$i];
390 if ($project[
'include'] != $project_orig[
'include']) {
391 $include = $project[
'include'] ?
"true" :
"false";
392 $sql =
"update acme_upload set include='$include' where acme_upload_pk='$project[acme_upload_pk]'";
395 pg_free_result($result);
402 foreach ($acme_project_array as &$project) {
403 $sql =
"select uploadtree_pk from acme_pfile, uploadtree where acme_project_fk=$project[acme_project_fk]
404 and acme_pfile.pfile_fk=uploadtree.pfile_fk and uploadtree.upload_fk=$upload_pk";
408 $ItemLicArray = array();
409 while ($acme_pfileRow = pg_fetch_assoc($result)) {
411 $acme_pfileRow[
'uploadtree_pk'], $uploadtree_tablename);
412 foreach ($LicArray as $key => $license) {
413 $ItemLicArray[$key] = $license;
416 $project[
'licenses'] =
'';
417 foreach ($ItemLicArray as $license) {
418 if ($license ==
"No_license_found") {
421 if (! empty($project[
'licenses'])) {
422 $project[
'licenses'] .=
", ";
424 $project[
'licenses'] .= $license;
430 usort($acme_project_array,
'proj_cmp');
433 if (! empty($spdxbtn)) {
441 switch ($this->OutputType) {
447 $V .= $this->
HTMLForm($acme_project_array, $upload_pk);
454 if (! $this->OutputToStdout) {
464 $NewPlugin->Initialize();
This is the Plugin class. All plugins should:
OutputOpen()
This function is called when user output is requested. This function is responsible for assigning hea...
HTMLForm($acme_project_array, $upload_pk)
create the HTML to display the form showing the found projects
RegisterMenus()
Customize submenus.
FindACMEProjects($uploadtreeRow, &$acme_project_array)
Find all the acme projects in a hierarchy, starting with $uploadtree_pk. Once you get an acme hit,...
GetProjectArray1($upload_pk, $nomosAgentpk, $MinCount=1)
Given an upload , return all the unique projects found.
GenerateSPDX($acme_project_array)
Write and return the SPDX file as a string.
Populate_acme_upload($acme_project_array, $upload_pk, $detail)
Populate the acme_upload table for this upload.
Output()
Display the loaded menu and plugins.
GetProjectArray0($upload_pk, $nomosAgentpk, $MinCount=1)
Given an upload , return all the unique projects found.
LatestAgentpk($upload_pk, $arsTableName, $arsSuccess=false)
Given an upload_pk, find the latest enabled agent_pk with results.
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
GetSingleRec($Table, $Where="")
Retrieve a single database record.
Dir2Browse($Mod, $UploadtreePk, $LinkLast=NULL, $ShowBox=1, $ShowMicro=NULL, $Enumerate=-1, $PreText='', $PostText='', $uploadtree_tablename="uploadtree")
Get an html linked string of a file browse path.
GetFileLicenses($agent, $pfile_pk, $uploadtree_pk, $uploadtree_tablename='uploadtree', $duplicate="")
get all the licenses for a single file or uploadtree
Traceback_uri()
Get the URI without query to this location.
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
Traceback_parm_keep($List)
Create a new URI, keeping only these items.
DownloadString2File($text, $name, $contentType)
Send a string to a user as a download file.
FUNCTION char * GetUploadtreeTableName(PGconn *pgConn, int upload_pk)
Get the uploadtree table name for this upload_pk If upload_pk does not exist, return "uploadtree".
#define PLUGIN_DB_READ
Plugin requires read permission on DB.
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN