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");
 
   53         $text = _(
"ACME Low Level Review");
 
   61       $text2 = _(
"ACME Review");
 
   79     $sql = 
"select acme_project_fk from acme_pfile where pfile_fk='$uploadtreeRow[pfile_fk]' limit 1";
 
   82     if (pg_num_rows($result) > 0) {
 
   84       $acme_pfileRow = pg_fetch_assoc($result);
 
   87       $sql = 
"select * from acme_project where acme_project_pk='$acme_pfileRow[acme_project_fk]'";
 
   88       $projresult = pg_query(
$PG_CONN, $sql);
 
   90       if (pg_num_rows($projresult) > 0) {
 
   91         $acme_project_array[$acme_pfileRow[
'acme_project_fk']] = pg_fetch_assoc($projresult);
 
   92         $acme_project_array[$acme_pfileRow[
'acme_project_fk']][
'count'] = ($uploadtreeRow[
'rgt'] - $uploadtreeRow[
'lft']);
 
   97       $sql = 
"select uploadtree_pk, pfile_fk, lft, rgt from uploadtree where parent= $uploadtreeRow[uploadtree_pk]";
 
   98       $childrenResult = pg_query(
$PG_CONN, $sql);
 
  100       while ($child = pg_fetch_assoc($childrenResult)) {
 
  103       pg_free_result($childrenResult);
 
  105     pg_free_result($result);
 
  120     $acme_project_array = array();  
 
  122     $sql = 
"select uploadtree_pk, pfile_fk, lft, rgt from uploadtree where upload_fk='$upload_pk' and parent is null";
 
  125     $row = pg_fetch_assoc($result);
 
  127     pg_free_result($result);
 
  129     return $acme_project_array;
 
  142     $acme_project_array = array();  
 
  145     $sql = 
"select distinct(acme_project_fk) as acme_project_fk, count(acme_project_fk) as filecount from acme_pfile 
  146             right join uploadtree on uploadtree.pfile_fk=acme_pfile.pfile_fk where upload_fk=$upload_pk 
  147             group by acme_project_fk order by filecount desc";
 
  150     while ($row = pg_fetch_assoc($result)) {
 
  151       if ($row[
'filecount'] < $MinCount) {
 
  156       $sql = 
"select * from acme_project where acme_project_pk='$row[acme_project_fk]'";
 
  157       $projresult = pg_query(
$PG_CONN, $sql);
 
  159       if (pg_num_rows($projresult) > 0) {
 
  160         $acme_project_array[$idx] = pg_fetch_assoc($projresult);
 
  161         $acme_project_array[$idx][
'count'] = $row[
'filecount'];
 
  166     return($acme_project_array);
 
  179     $uploadtreeRec = 
GetSingleRec(
"uploadtree", 
"where upload_fk=$upload_pk and parent is null");
 
  180     $Outbuf .= 
Dir2Browse($this->Name,$uploadtreeRec[
'uploadtree_pk'], NULL, 1, 
"acme");
 
  183     $URI = 
"?mod=" . $this->Name . 
Traceback_parm_keep(array( 
"page", 
"upload", 
"folic", 
"detail"));
 
  184     $Outbuf .= 
"<form action='" . $URI . 
"' method='POST'>\n";
 
  186     $Outbuf .= 
"<table border=1>";
 
  188     $text = _(
'Include');
 
  189     $Outbuf .= 
"<th>$text</th>";
 
  190     $text = _(
'Project');
 
  191     $Outbuf .= 
"<th>$text</th>";
 
  193     $Outbuf .= 
"<th>$text</th>";
 
  195     $Outbuf .= 
"<th>$text</th>";
 
  196     $text = _(
'Description');
 
  197     $Outbuf .= 
"<th>$text</th>";
 
  198     $text = _(
'License');
 
  199     $Outbuf .= 
"<th>$text</th>";
 
  200     $text = _(
'Version');
 
  201     $Outbuf .= 
"<th>$text</th>";
 
  205     $RowStyle1 = 
"style='background-color:lavender'";
 
  206     $RowStyle2 = 
"style='background-color:lightyellow'";
 
  210     if (empty($acme_project_array)) {
 
  211       $acme_project_array = array();
 
  213     foreach ($acme_project_array as $project) {
 
  215       $RowStyle = (($RowNum++ % (2*$ColorSpanRows))<$ColorSpanRows) ? $RowStyle1 : $RowStyle2;
 
  217       $Outbuf .= 
"<tr $RowStyle>";
 
  218       $Checked = $project[
'include'] == 
't' ? 
"checked=\"checked\"" : 
'' ;
 
  219       $Outbuf .= 
"<td><input type='checkbox' name='includeproj[$project[acme_project_pk]]' $Checked></td>\n";
 
  220       $Outbuf .= 
"<td>$project[project_name]</td>";
 
  221       $ProjectListURL = 
Traceback_uri() . 
"?mod=" . $this->Name . 
"&acme_project=$project[acme_project_pk]&upload=$upload_pk";
 
  222       $Outbuf .= 
"<td><a href='$ProjectListURL'>$project[count]</a></td>";
 
  223       $Outbuf .= 
"<td><a href='$project[url]'>$project[url]</a></td>";
 
  224       $Outbuf .= 
"<td>" . htmlentities($project[
'description'], ENT_HTML5 | ENT_QUOTES) . 
"</td>";
 
  225       $Outbuf .= 
"<td>$project[licenses]</td>";
 
  226       $Outbuf .= 
"<td>$project[version]</td>";
 
  229     $Outbuf .= 
"</table>";
 
  231     $Outbuf .= 
"$RowNum rows found<br>";
 
  233     $text = _(
"Save and Generate SPDX file");
 
  234     $Outbuf .= 
"<p><input type='submit' value='$text' name='spdxbtn'>\n";
 
  236     $Outbuf .= 
"   <input type='submit' value='$text' name='savebtn'>\n";
 
  237     $Outbuf .= 
"</form>\n";
 
  255     foreach ($acme_project_array as $project) {
 
  256       $sql = 
"insert into acme_upload (upload_fk, acme_project_fk, include, detail, count) values ($upload_pk, $project[acme_project_pk], true, $detail, $project[count])";
 
  259       pg_free_result($result);
 
  273     $spdx = 
'<?xml version="1.0" encoding="UTF-8" ?>' . 
"\n";
 
  274     $spdx .=
'<rdf:RDF' . 
"\n";
 
  275     $spdx .= 
'    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"' . 
"\n";
 
  276     $spdx .= 
'    xmlns="http://spdx.org/rdf/terms#"' . 
"\n";
 
  277     $spdx .= 
'    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">' . 
"\n";
 
  278     $spdx .= 
'    <SpdxDocument rdf:about="http://www.spdx.org/tools#SPDXANALYSIS">' . 
"\n";
 
  279     $spdx .= 
'      <specVersion>SPDX-1.1</specVersion>' . 
"\n";
 
  280     $spdx .= 
'      <dataLicense rdf:about="http://spdx.org/licenses/PDDL-1.0" />' . 
"\n";
 
  281     $spdx .= 
'      <CreationInfo>' . 
"\n";
 
  282     $spdx .= 
" <creator>Tool: FOSSology v " . $SysConf[
'BUILD'][
'VERSION'] . 
" svn " . $SysConf[
'BUILD'][
'COMMIT_HASH'] . 
"</creator>\n";
 
  283     $spdx .= 
"<created>" . date(
'c') . 
"</created>\n";   
 
  284     $spdx .= 
'</CreationInfo>' . 
"\n";
 
  286     $in_encoding = iconv_get_encoding(
"input_encoding");
 
  287     foreach ($acme_project_array as $project) {
 
  289       $spdx .= 
"<Package>\n";
 
  290       $spdx .= 
'<name>' . str_replace(
"&", 
" and ", strip_tags($project[
'project_name'])) . 
'</name>' . 
"\n";
 
  291       $spdx .= 
"<versionInfo>$project[version]</versionInfo>\n";
 
  292       $spdx .= 
"<licenseDeclared>$project[licenses]</licenseDeclared>\n";
 
  293       $spdx .= 
"<sourceInfo>ProjectURL: $project[url]</sourceInfo>\n";
 
  294       $spdx .= 
'<description>' . str_replace(
"&", 
" and ", strip_tags($project[
'description'])) . 
'</description>' . 
"\n";
 
  295       $spdx .= 
"</Package>\n";
 
  311     $spdx .= 
"  </SpdxDocument> </rdf:RDF>\n";
 
  330     $detail = empty($detail) ? 0 : 1;
 
  336     if (empty($agent_pk)) {
 
  337       echo 
"Missing fossology license data.  Run a license scan on this upload.<br>";
 
  343     $acme_uploadRec = 
GetSingleRec(
"acme_upload", 
"where upload_fk=$upload_pk  and detail=$detail");
 
  344     if (empty($acme_uploadRec)) {
 
  348       $acme_project_array = $this->
GetProjectArray1($upload_pk, $nomosAgentpk, $MinCount);  
 
  350       $acme_project_array = $this->
GetProjectArray0($upload_pk, $nomosAgentpk, $MinCount); 
 
  354     $sql = 
"select * from acme_upload, acme_project where acme_project_pk=acme_project_fk and detail=$detail and upload_fk=$upload_pk";
 
  357     $acme_project_array = pg_fetch_all($result);
 
  358     $acme_project_array_orig = $acme_project_array;  
 
  361     if (! empty($savebtn) or ! empty($spdxbtn)) {
 
  363       foreach ($acme_project_array as &$project) {
 
  364         $project[
'include'] = 
'f';
 
  367       if (array_key_exists(
'includeproj', $_POST)) {
 
  368         $includeArray = $_POST[
'includeproj'];
 
  369         foreach ($acme_project_array as &$project) {
 
  370           if (array_key_exists($project[
'acme_project_fk'], $includeArray)) {
 
  371             $project[
'include'] = 
"t";
 
  377       $NumRecs = count($acme_project_array);
 
  378       for ($i = 0; $i < $NumRecs; $i ++) {
 
  379         $project = $acme_project_array[$i];
 
  380         $project_orig = $acme_project_array_orig[$i];
 
  381         if ($project[
'include'] != $project_orig[
'include']) {
 
  382           $include = $project[
'include'] ? 
"true" : 
"false";
 
  383           $sql = 
"update acme_upload set include='$include' where acme_upload_pk='$project[acme_upload_pk]'";
 
  386           pg_free_result($result);
 
  393       foreach ($acme_project_array as &$project) {
 
  394         $sql = 
"select uploadtree_pk from acme_pfile, uploadtree where acme_project_fk=$project[acme_project_fk] 
  395                 and acme_pfile.pfile_fk=uploadtree.pfile_fk and uploadtree.upload_fk=$upload_pk";
 
  399         $ItemLicArray = array();
 
  400         while ($acme_pfileRow = pg_fetch_assoc($result)) {
 
  401           $LicArray = 
GetFileLicenses($agent_pk, 
'', $acme_pfileRow[
'uploadtree_pk'], $uploadtree_tablename);
 
  402           foreach ($LicArray as $key => $license) {
 
  403             $ItemLicArray[$key] = $license;
 
  406         $project[
'licenses'] = 
'';
 
  407         foreach ($ItemLicArray as $license) {
 
  408           if ($license == 
"No_license_found") {
 
  411           if (! empty($project[
'licenses'])) {
 
  412             $project[
'licenses'] .= 
", ";
 
  414           $project[
'licenses'] .= $license;
 
  420     if (! empty($acme_project_array)) {
 
  421       usort($acme_project_array, 
'proj_cmp');
 
  425     if (! empty($spdxbtn)) {
 
  433     switch ($this->OutputType) {
 
  437         $V .= $this->
HTMLForm($acme_project_array, $upload_pk);
 
  442     if (! $this->OutputToStdout) {
 
  451 $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