. * * @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 http://github.com/remicollet/rpmphp/ * @since The begining of times. */ require 'include/main.php'; $what=(isset($_GET["what"]) ? $_GET["what"] : "%fedora"); $type=(isset($_GET["type"]) ? $_GET["type"] : "pecl"); if (!in_array($type, array('composer', 'pecl', 'pear', 'R'))) { $type = 'pecl'; } $ariane[] = array( 'url' => '#', 'text' => strtoupper($type). ' extensions in Fedora' ); $smarty->assign('ariane', $ariane); $smarty->assign('type', $type); $smarty->assign('what', $what); $smarty->assign('page_title', strtoupper($type). ' extensions in Fedora'); /** * 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'] = '' . $rpmname . ''; } 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'] . ' (' . $up['state'] . ')'; } $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
", $rpm['ver'], $rpm['rel'] ); } else { $display .= sprintf( "%s-%s
", $rpm['ver'], $rpm['rel'] ); } if ( $verup==$verpm ) { $class="check"; } break; case "": $display .= sprintf( "%s-%s
", $rpm['ver'], $rpm['rel'] ); if ( $verup==$verpm ) { $class="check"; } break; case "updates": $display .= sprintf( "%s-%s". "
(%s)
", $rpm['ver'], $rpm['rel'], $repo['sub'] ); if ($verup==$verpm && $class!='check') { $class="check"; } break; case "testing": $display .= sprintf( "%s-%s
(%s)", $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; } try { switch ($type) { case "pecl": $filter = 'php-pecl-%'; break; case "composer": case "pear": $filter = 'php-%'; break; case "R": $filter = 'R-%'; break; default: $filter = ''; } $db = new PDO ("mysql:dbname=" . MYBASE . ";host=" . MYHOST, MYUSER, MYPASS); $acl = new TableAcls($db); $smarty->assign('owners', $acl->getOwners($filter)); $acl = new TableUpstream($db); $smarty->assign('channels', $acl->getChannels($type)); $rpmrepo = new TableRpmRepo($db); $smarty->assign('repositories_update', date("r", $rpmrepo->getMaxStamp())); $smarty->assign('packages', report($db, $type)); } catch(PDOException $e) { $smarty->assign( 'error', sprintf("%s ERREUR : %s\n", date("r"), $e->getMessage()) ); } $page_content = $smarty->fetch('rpm.tpl'); $smarty->assign('page_content', $page_content); $smarty->display('main.tpl'); ?>