/** * Retrieve packages informations * * @param Object $db A reference to the database * @param string $type The current type * * @return array */ function report($db, $type) { global $what, $smarty; $packages = null; $rpmrepo = new TableRpmRepo($db); $rpmtable = new TableRpm($db); $uptable = new TableUpstream($db); $repos = $rpmrepo->getAllRepoHash(); $smarty->assign('repos', $repos); $crit = array('type' => $type, 'ORDER' => 'name'); if (substr($what, 0, 1) == '#') { $crit['channel'] = substr($what, 1); $what = '%fedora'; } $i = 0; foreach ($uptable->request($crit) as $up) { $package = null; $rpmname = $up['name']; $verup = strtolower($up['stable'] ? $up['stable'] : $up['unstable']); $sql2 = "SELECT DISTINCT owner FROM acls WHERE name = '{$rpmname}'"; $res2 = $db->query($sql2); $owners = array(); if ($res2) { while ($owner = $res2->fetchObject()) { $owners[] = $owner->owner; } } $package['name'] = $rpmname; $rpms = array(); foreach ($rpmtable->request(array('name' => $rpmname)) as $rpm) { $rpms[$rpm['repo_main'] . '-' . $rpm['repo_sub']] = $rpm; $package['name'] = '<a href="zoom.php?rpm=' . $rpmname . '" title="' . htmlentities($rpm['summary'], ENT_QUOTES) . '">' . $rpmname . '</a>'; } switch ($what) { case '%work': $display = false; if (count($rpms) && isset($rpms['devel-']) && $rpms['devel-']['ver'] != $verup) { $display = true; } break; case '%fedora': $display = count($rpms); break; case '%stable': $display = !empty($up['stable']); break; case '%all': $display = true; break; default: // owner $display = array_search($what, $owners) !== false; break; } if ($display) { if ($up['channel'] != $up['type']) { $package['channel'] = $up['channel']; } $dispowner = ""; $package['owners'] = $owners; if ($up['stable']) { $package['upstream_stable'] = $up['stable']; } if ($up['unstable'] && (!$up['stable'] || $up['stable'] != $up['unstable'])) { $package['upstream_unstable'] = $up['unstable'] . ' <small>(' . $up['state'] . ')</small>'; } $versions = null; foreach ($repos as $repomain) { $display = ""; $class = ""; foreach ($repomain as $k => $repo) { if (isset($rpms[$repo['main'] . "-" . $repo['sub']])) { $rpm = $rpms[$repo['main'] . "-" . $repo['sub']]; $verpm = $rpm['ver']; $pat = "/\\.((beta|RC)\\d*)\\./i"; if (preg_match($pat, $rpm['rel'], $res)) { $verpm .= strtolower($res[1]); } if (strpos($repo['sub'], '-os') || strpos($repo['sub'], '-beta') || strpos($repo['sub'], '-base') || strpos($repo['sub'], '-optional') || strpos($repo['sub'], '-stable')) { // For CentOS $repotype = 'base'; } else { if (strpos($repo['sub'], 'testing')) { $repotype = 'testing'; } else { if (strpos($repo['sub'], 'updates')) { $repotype = 'updates'; } else { $repotype = $repo['sub']; } } } switch ($repotype) { case "base": if (isset($rpms[$repo['main'] . "-updates"])) { $display .= sprintf("%s-%s<br/>", $rpm['ver'], $rpm['rel']); } else { $display .= sprintf("<strong>%s</strong>-%s<br/>", $rpm['ver'], $rpm['rel']); } if ($verup == $verpm) { $class = "check"; } break; case "": $display .= sprintf("<strong>%s</strong>-%s<br/>", $rpm['ver'], $rpm['rel']); if ($verup == $verpm) { $class = "check"; } break; case "updates": $display .= sprintf("<strong>%s</strong>-%s" . "<br/><small>(%s)</small><br/>", $rpm['ver'], $rpm['rel'], $repo['sub']); if ($verup == $verpm && $class != 'check') { $class = "check"; } break; case "testing": $display .= sprintf("%s-%s<br/><small>(%s)</small>", $rpm['ver'], $rpm['rel'], $repo['sub']); if ($verup == $verpm && !$class) { $class = "info"; } break; } } // RPM exists } // sub repo if ($display && empty($class)) { $class = "attn"; } $versions[] = array('class' => $class, 'display' => $display); $package['versions'] = $versions; } // mainrepo $i++; $packages[] = $package; } } return $packages; }
/** * Retrieve packages informations * * @param Object $db A reference to the database * * @return array */ function report($db) { global $what, $smarty; $packages = null; $rpmrepo = new TableRpmRepo($db); $repos = $rpmrepo->getAllRepoHash(); $smarty->assign('repos', $repos); if (substr($what, 0, 1) == '%') { $sql = sprintf("SELECT DISTINCT name\n FROM rpm\n WHERE SUBSTRING(name,1,1)='%s'\n ORDER BY name", substr($what, 1, 1)); } else { $sql = sprintf("SELECT DISTINCT name\n FROM acls\n WHERE owner='%s'\n ORDER BY name", $what); } //echo "<p>SQL=$sql</p>"; $i = 0; $res = $db->query($sql); if ($res) { while ($desc = $res->fetchObject()) { $package = null; $rpmname = $desc->name; $sql2 = "SELECT DISTINCT owner FROM acls WHERE name LIKE '{$rpmname}'"; $res2 = $db->query($sql2); $dispowner = ""; $owners = array(); if ($res2) { while ($owner = $res2->fetchObject()) { $owners[] = $owner->owner; } } $sql3 = "SELECT * FROM rpm WHERE name LIKE '{$rpmname}'"; $res3 = $db->query($sql3); $rpm = $res3 ? $res3->fetchObject() : false; if ($rpm) { $url = $rpm->url; $des = htmlentities($rpm->summary); $rpms = array(); do { $rpms[$rpm->repo_main . "-" . $rpm->repo_sub] = $rpm; } while ($rpm = $res3->fetchObject()); $package['name'] = $rpmname; $package['description'] = $des; $package['owners'] = $owners; $versions = null; foreach ($repos as $repomain) { $display = ""; $class = ""; foreach ($repomain as $repo) { if (isset($rpms[$repo['main'] . "-" . $repo['sub']])) { $rpm = $rpms[$repo['main'] . "-" . $repo['sub']]; $maxver = isset($rpms["devel-"]) ? $rpms["devel-"]->ver : ""; if (strpos($repo['sub'], '-os') || strpos($repo['sub'], '-beta') || strpos($repo['sub'], '-base') || strpos($repo['sub'], '-optional') || strpos($repo['sub'], '-stable')) { // For CentOS $repotype = 'base'; } else { if (strpos($repo['sub'], 'testing')) { $repotype = 'testing'; } else { if (strpos($repo['sub'], 'updates')) { $repotype = 'updates'; } else { $repotype = $repo['sub']; } } } switch ($repotype) { case "base": if (isset($rpms[$repo['main'] . "-updates"])) { $display .= sprintf("%s-%s<br/>", $rpm->ver, $rpm->rel); } else { $display .= sprintf("<strong>%s</strong>-%s<br/>", $rpm->ver, $rpm->rel); $class = $rpm->ver == $maxver ? "check" : "attn"; } break; case "": $display .= sprintf("<strong>%s</strong>-%s<br/>", $rpm->ver, $rpm->rel); break; case "updates": $display .= sprintf("<strong>%s</strong>-%s<br/><small>(%s)</small><br/>", $rpm->ver, $rpm->rel, $repo['sub']); $class = $rpm->ver == $maxver ? "check" : "attn"; break; case "testing": $display .= sprintf("%s-%s<br/><small>(%s)</small><br/>", $rpm->ver, $rpm->rel, $repo['sub']); $class = $rpm->ver == $maxver ? "info" : "attn"; break; } } // RPM exists } // sub repo $versions[] = array('class' => $class && $maxver ? $class : '', 'display' => $display); $package['versions'] = $versions; } // mainrepo $i++; $packages[] = $package; } } // each Line } return $packages; }