. * * @category Main * @package RPMPHP * * @author Remi Collet * @author Johan Cwiklinski * @copyright 2010-2014 Remi Collet * @license http://www.gnu.org/licenses/agpl-3.0-standalone.html AGPL License 3.0 or (at your option) any later version * @link https://git.remirepo.net/cgit/web/rpmphp.git/ * @since The begining of times. */ require 'include/main.php'; $fedcli = new FedoraPkgdb(); $name = $_GET['rpm']; $type = (isset($_GET['type']) ? $_GET['type'] : "html"); /** * Retrieve people informations for a specific branch * * @param array $params Array of parameters * * @return string */ function getBranchPeople($params) { global $fedpkg; $branch = $people = null; // avoid IDE warning extract($params); $ret = null; if (isset($fedpkg[$branch]['owner'])) { if ( !$people || $people == '' || $people == 'owner' ) { $ret = $fedpkg[$branch]['owner']; } else if ( $people == 'people') { $ret_tmp = $fedpkg[$branch]['people']; } } if ( $people == 'people' && is_array($ret_tmp)) { $ret = implode($ret_tmp, ', '); } return $ret; } $smarty->registerPlugin( 'function', 'getBranchPeople', 'getBranchPeople' ); if ( !isset($name) || !$name ) { $smarty->assign('error', 'missing_name'); } else { try { $db = new PDO("mysql:dbname=" . MYBASE . ";host=" . MYHOST, MYUSER, MYPASS); $uptable = new TableUpstream($db); // Consider each part of ver/rel as integer except second part of rel (generally distro name) $sql = "SELECT rpm.*, repo.active, repo.url as repourl, packagist.pkgname, CONCAT(repo.url ,rpm.name,'-',rpm.ver,'-',rpm.rel,'.src.rpm') as rpmurl FROM rpm LEFT JOIN packagist ON (packagist.rpmname=rpm.name) INNER JOIN repo ON (repo.main=rpm.repo_main AND repo.sub=rpm.repo_sub) WHERE rpm.name=" . $uptable->escape($name) . " ORDER BY repo.id DESC, CAST(SUBSTRING_INDEX(rpm.ver,'.',1) AS SIGNED) DESC, CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(rpm.ver,'.',2),'.',-1) AS SIGNED) DESC, CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(rpm.ver,'.',3),'.',-1) AS SIGNED) DESC, CAST(SUBSTRING_INDEX(rpm.rel,'.',1) AS SIGNED) DESC, SUBSTRING_INDEX(SUBSTRING_INDEX(rpm.rel,'.',2),'.',-1) DESC, CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(rpm.rel,'.',3),'.',-1) AS SIGNED) DESC"; $resrpm = $db->query($sql); $rpm = ($resrpm ? $resrpm->fetchObject() : false); $up = $uptable->find(array('name' => $name)); $sql = "SELECT * FROM acls WHERE name = " . $uptable->escape($name); $resown=$db->query($sql); $owner = ($resown ? $resown->fetchObject() : false); if (isset($owner->name)) { // Use exact name (with case) from acl (else pkgdb could fail) $name = $owner->name; $smarty->assign('name', $name); $smarty->assign('page_title', 'Package: ' . $name); } $summary = array(); $packages = array(); $fedpkg = false; if (!$rpm) { // cleanup the name $name = preg_replace("/[^a-zA-Z0-9-_]/", ".", $name); echo "

$name not found

\n"; } else { // use name from the DB $name = $rpm->name; if ($rpm->summary) { $summary['Summary'] = $rpm->summary; } else if ($owner->summary) { $summary['Summary'] = $owner->summary; } $summary['Description'] = ( (isset($fedpkg['devel']['package']['description'])) ? $fedpkg['devel']['package']['description'] : ($ajax_infos ?? '') ); if ( $rpm->url ) { $summary['URL'] = $rpm->url; } if ($up && $up['type']) { $summary['Type'] = $up['type']; } if ($rpm->pkgname) { $summary['Composer name'] = $rpm->pkgname; } else if ($up && $up['channel']) { $summary['Channel'] = $up['channel']; } if ($up && $up['stable']) { $summary['Stable version'] = $up['stable']; } if ($up && $up['unstable'] && $up['stable']!=$up['unstable']) { $summary['Unstable version'] = $up['unstable']; if ($up['state']) { $summary['Unstable version'] .= ' (' . $up['state'] . ')'; } } if ($owner && $owner->owner) { $summary['Owner'] = $owner->owner; if ($owner->cc) { $summary['Owner'] .= ' (' . $owner->cc . ')'; } } // Only when owner (so we have the exact name) $summary['Bugzilla'] = 'https://bugzilla.redhat.com/buglist.cgi'. '?bug_status=NEW&bug_status=ASSIGNED&bug_status=ON_QA' . '&component=' . $name; $summary['Pagure'] = "https://src.fedoraproject.org/rpms/$name"; $summary['Koschei'] = "https://koschei.fedoraproject.org/package/$name"; //$summary['Packages'] = "https://apps.fedoraproject.org/packages/$name"; //if (isset($_GET['pkgdb'])) { // $fedpkg = $fedcli->getPackageInfo($name); //} else { $fedpkg = false; //} $i=0; $prev=false; do { if ($rpm->location) { $rpm->rpmurl = $rpm->repourl . $rpm->location; } $rpm->askpkgdb = false; /* if ($rpm->active && (substr($rpm->repo_main, 0, 1) == 'f' || substr($rpm->repo_sub, 0, 4) == 'epel') ) { $rpm->askpkgdb = true; } */ $packages[] = $rpm; if ( $rpm->repo_main != $prev ) { $prev = $rpm->repo_main; } } while ( $rpm = $resrpm->fetchObject() ); } $smarty->assign('pkgdb', (isset($_GET['pkgdb']) ? $_GET['pkgdb'] : null)); $smarty->assign('summary', $summary); $smarty->assign('packages', $packages); $smarty->assign('fedpkg', $fedpkg); } catch(PDOException $e) { $smarty->assign( 'error', sprintf("%s ERREUR : %s\n", date("r"), $e->getMessage()) ); } } $smarty->assign('name', $name); $smarty->assign('name_required', true); $ariane[] = array( 'url' => '#', 'text' => 'Package: ' . $name ); /* $ajax_infos = '(wait for ajax or reload with pkgdb)'; $smarty->assign('ajax_infos', $ajax_infos); */ $smarty->assign('ajax_infos', ''); $smarty->assign('ariane', $ariane); $smarty->assign('page_title', 'Package: ' . $name); if ($type == "json") { // Displays the output as json (TODO : why not use json_encode) header('Content-Type: application/json'); $json = "{"; $json .= '"package":"' . $name ."\","; $json .= '"branch":['; $cnt = 0; foreach ($packages as $package) { $cnt += 1; $json .= "{"; $json .= '"'. $package->repo_main .'":"'; if ($package->epoch) { $json .= $package->epoch.':'; } $json .= $package->ver."-".$package->rel.'"}'; if ($cnt != count($packages)) { $json .= ","; } } $json .= "]}"; echo $json; } else if ($type == "text") { // Displays the output as text header('Content-Type: text/plain'); $text = 'package: ' . $name ." \n"; $cnt = 0; foreach ($packages as $package) { $cnt += 1; $text .= $package->repo_main .': '; if ($package->epoch) { $text .= $package->epoch.':'; } $text .= $package->ver."-".$package->rel."\n"; } echo $text; } else { // Displays the output as html $page_content = $smarty->fetch('zoom.tpl'); $smarty->assign('page_content', $page_content); $smarty->display('main.tpl'); } ?>