diff options
author | Eudyptula <eitan@mosenkis.net> | 2009-07-17 12:27:02 -0400 |
---|---|---|
committer | Eudyptula <eitan@mosenkis.net> | 2009-07-17 12:27:02 -0400 |
commit | 0ffa58ac3b7688b4849d082abf0378b78f3cb618 (patch) | |
tree | c3db8303aea79953f9065a1532f2f3b916772751 /frontend | |
parent | Added predefined package sets; separated gentoo-specific setup into gentoo_se... (diff) | |
download | ingenue-0ffa58ac3b7688b4849d082abf0378b78f3cb618.tar.gz ingenue-0ffa58ac3b7688b4849d082abf0378b78f3cb618.tar.bz2 ingenue-0ffa58ac3b7688b4849d082abf0378b78f3cb618.zip |
Fixed bugs and added new/popular builds to welcome page
Diffstat (limited to 'frontend')
-rw-r--r-- | frontend/css/build.css | 10 | ||||
-rw-r--r-- | frontend/modules/gentoo/step3.php | 20 | ||||
-rw-r--r-- | frontend/pages/downloadimage.php | 10 | ||||
-rw-r--r-- | frontend/pages/welcome.php | 33 |
4 files changed, 62 insertions, 11 deletions
diff --git a/frontend/css/build.css b/frontend/css/build.css index 7ae7345..43ade38 100644 --- a/frontend/css/build.css +++ b/frontend/css/build.css @@ -25,6 +25,16 @@ div.build span.status.queued { div.build span.status.config { color: teal; } +div.build span.downloads { + font-weight: bold; + font-size: 90%; + text-align: right; + float: right; +} +div.build span.downloads span.time { + font-size: 90%; + font-family: monospace; +} div.build span.links { font-size: 90%; } diff --git a/frontend/modules/gentoo/step3.php b/frontend/modules/gentoo/step3.php index 89e7ec3..a4f1b30 100644 --- a/frontend/modules/gentoo/step3.php +++ b/frontend/modules/gentoo/step3.php @@ -4,17 +4,19 @@ if (in_array('timezone', $opts)) $this->select('timezone', 'timezone', 'Timezone', get_timezones()); if (in_array('dev-manager', $opts)) $this->select('dev-manager', 'dev-manager', '/dev Manager', array('udev' => 'udev', 'static-dev' => 'Static /dev')); -$profile=new sql_gentoo_profile($opts['profile']); -foreach (explode(' ', $this->get_opt('pkgsets')) as $pkgset) { - $pkgset=new sql_gentoo_pkgset($pkgset); - $pkgs=array(); - foreach (explode("\n", $pkgset->packages) as $pkg) { - if ($obj=sql_gentoo_package::from_atom($pkg, $profile)) { - $array=$obj->to_array(); - $pkgs[$pkg]="$pkg: {$array['desc']}"; +$profile=new sql_gentoo_profile($this->get_opt('profile')); +if (strlen($pkgsets=$this->get_opt('pkgsets'))) { + foreach (explode(' ', $this->get_opt('pkgsets')) as $pkgset) { + $pkgset=new sql_gentoo_pkgset($pkgset); + $pkgs=array(); + foreach (explode("\n", $pkgset->packages) as $pkg) { + if ($obj=sql_gentoo_package::from_atom($pkg, $profile)) { + $array=$obj->to_array(); + $pkgs[$pkg]="$pkg: {$array['desc']}"; + } } + $this->checkbox_array('pkgset-'.$pkgset->id, 'pkgset-'.$pkgset->id, $pkgset->name, $pkgs); } - $this->checkbox_array('pkgset-'.$pkgset->id, 'pkgset-'.$pkgset->id, $pkgset->name, $pkgs); } // TODO This shouldn't be a step at all, it should be in wizard.php to choose between bundlers // TODO This shouldn't be part of configurations, except possibly a default value. It should be for builds diff --git a/frontend/pages/downloadimage.php b/frontend/pages/downloadimage.php index 91c1161..2234a10 100644 --- a/frontend/pages/downloadimage.php +++ b/frontend/pages/downloadimage.php @@ -4,16 +4,20 @@ function init_downloadimage() { if (!isset($S['user'])) { return 'login'; } - if (!isset($request['build']) || !preg_match('/^[a-zA-Z0-9]{6}$/', $request['build'])) { + if (!(isset($request['build']) && strlen($request['build']) == 6 && ctype_alnum($request['build']))) { debug('downlaodimage', 'No build or badly formatted build requested'); return '404'; } - $r=$S['pdo']->query('SELECT * FROM `builds` WHERE `owner`='.$S['user']->id.' AND `id`="'.$request['build'].'"'); + $r=$S['pdo']->query('SELECT * FROM `builds` WHERE `id`="'.$request['build'].'"'); if ($r->rowCount() == 0) { debug('downloadimage', 'build not found or not owned by user'); return '404'; } $build=new sql_build($r->fetch(PDO::FETCH_ASSOC)); + if (!owner_or_admin($build->owner)) { + debug('downloadimage', 'Permission denied'); + return '404'; + } $files=glob(COMPLETED.'/build-'.$build->id.'.*'); if (count($files)) { if (count($files) > 1) { @@ -30,6 +34,8 @@ function init_downloadimage() { debug('downloadimage', 'image file not found'); return '404'; } + $dl=new sql_download($build->id, $S['user']->id, time()); + $dl->write(); contenttype('application/octet-stream'); header('Content-Length: '.filesize($S['file'])); header('Content-Description: File Transfer'); diff --git a/frontend/pages/welcome.php b/frontend/pages/welcome.php index d326f08..4b727e3 100644 --- a/frontend/pages/welcome.php +++ b/frontend/pages/welcome.php @@ -6,5 +6,38 @@ function init_welcome() { function body_welcome() { global $S; echo '<h2>Welcome</h2>'; + echo '<div class="box"><h3>Most Popular Downloads</h3>'; + $r=$S['pdo']->query('SELECT `build` FROM `downloads` GROUP BY `build` ORDER BY COUNT(*) DESC LIMIT 3'); + if ($r->rowCount()) { + while ($build=$r->fetch(PDO::FETCH_COLUMN)) { + $build=new sql_build($build); + echo $build->display(); + } + } else { + echo print_warning('No downloads'); + } + echo '</div>'; + echo '<div class="box"><h3>Recently Downloaded</h3>'; + $r=$S['pdo']->query('SELECT * FROM `downloads` ORDER BY `time` DESC LIMIT 3'); + if ($r->rowCount()) { + while ($download=$r->fetch(PDO::FETCH_ASSOC)) { + $download=new sql_download($download); + echo $download->get_build()->display(); + } + } else { + echo print_warning('No downloads'); + } + echo '</div>'; + echo '<div class="box"><h3>Recently Built</h3>'; + $r=$S['pdo']->query('SELECT * FROM `builds` WHERE `status`="finished/success" ORDER BY `finish` DESC LIMIT 3'); + if ($r->rowCount()) { + while ($build=$r->fetch(PDO::FETCH_ASSOC)) { + $build=new sql_build($build); + echo $build->display(); + } + } else { + echo print_warning('No finished builds'); + } + echo '</div>'; } ?> |