From e9608f75362acabb2f3769259daaaa5872894c1d Mon Sep 17 00:00:00 2001 From: Marcin Juszkiewicz Date: Thu, 24 Aug 2006 11:55:02 +0000 Subject: feed-browser: more cleanups - package details switched to definition list - database check/creation moved to function - removed dead code --- contrib/feed-browser/css/feed.css | 5 ++ contrib/feed-browser/index.php | 109 +++++++++++++++++++------------------- 2 files changed, 59 insertions(+), 55 deletions(-) (limited to 'contrib') diff --git a/contrib/feed-browser/css/feed.css b/contrib/feed-browser/css/feed.css index fd9f65c5c1..7a7e55ebd6 100644 --- a/contrib/feed-browser/css/feed.css +++ b/contrib/feed-browser/css/feed.css @@ -55,3 +55,8 @@ h2 display: inline; list-style: none; } + +dt +{ + padding-top: 0.5em; +} diff --git a/contrib/feed-browser/index.php b/contrib/feed-browser/index.php index 7921a42260..1603cfd779 100644 --- a/contrib/feed-browser/index.php +++ b/contrib/feed-browser/index.php @@ -48,44 +48,9 @@ error_reporting(E_ALL); -$db_name = "./feeds.db"; -$db = sqlite_open($db_name); - -//initialiaze db -if (db_table_exists ($db, 'packages') === FALSE) -{ - sqlite_query ($db, "CREATE TABLE packages ( - p_name varchar(50), - p_version varchar(10), - p_arch varchar(12), - p_depends varchar(50), - p_maintainer varchar(50), - p_homepage varchar(100), - p_section varchar(20), - p_replaces varchar(50), - p_provides varchar(50), - p_recommends varchar(50), - p_conflicts varchar(50), - p_size int(10), - p_md5 char(32), - p_source varchar(500), - p_feed varchar(20), - p_file varchar(100), - p_desc varchar(1000))"); -} - -if (db_table_exists ($db, 'feeds') === FALSE) -{ - sqlite_query ($db, "CREATE TABLE feeds ( - f_name varchar(20), - f_uri varchar(100), - f_comments varchar(500))"); +define('DB_FILENAME', './feeds.db'); - test_insert_ipkgs ($db) ; -} - -//close the db -sqlite_close($db); +check_database(); $action = ''; @@ -159,18 +124,11 @@ function db_table_exists ($db, $mytable) return FALSE; } -function get_archs_fromdb() -{ - return db_query("SELECT DISTINCT p_arch FROM packagess ORDER BY p_arch"); -} - function db_query($query) { - global $db_name; - $result = FALSE; - if($db_h = sqlite_open($db_name)) + if($db_h = sqlite_open(DB_FILENAME)) { if($query_h = sqlite_query ($db_h, $query)) { @@ -373,43 +331,43 @@ function pkgdetails ($package) $details = sprintf("

Package details for %s %s

", $package['packages.p_name'], $package['packages.p_version']); $details .= sprintf ("

%s

", $package['packages.p_desc']); - $details .= ""; + $details .= "
"; - $details .= sprintf ("\n
", htmlentities(str_replace('@', ' at ', $package['packages.p_maintainer']))); + $details .= sprintf ("\n
Maintainer:
%s
", htmlentities(str_replace('@', ' at ', $package['packages.p_maintainer']))); if($package['packages.p_homepage']) { - $details .= sprintf ("\n", $package['packages.p_homepage']); + $details .= sprintf ("\n
Homepage:
%s
", $package['packages.p_homepage']); } if($package['packages.p_section']) { - $details .= sprintf ("\n", $package['packages.p_section'],$package['packages.p_section']); + $details .= sprintf ("\n
Section:
%s
", $package['packages.p_section'],$package['packages.p_section']); } if($package['packages.p_depends']) { - $details .= sprintf ("\n", addlinks ($package['packages.p_depends'])); + $details .= sprintf ("\n
Depends:
%s
", addlinks ($package['packages.p_depends'])); } if($package['packages.p_recommends']) { - $details .= sprintf ("\n", addlinks ($package['packages.p_recommends'])); + $details .= sprintf ("\n
Recommends:
%s
", addlinks ($package['packages.p_recommends'])); } if($package['packages.p_replaces']) { - $details .= sprintf ("\n", addlinks ($package['packages.p_replaces'])); + $details .= sprintf ("\n
Replaces:
%s
", addlinks ($package['packages.p_replaces'])); } if($package['packages.p_provides']) { - $details .= sprintf ("\n", addlinks ($package['packages.p_provides'])); + $details .= sprintf ("\n
Provides:
%s
", addlinks ($package['packages.p_provides'])); } if($package['packages.p_conflicts']) { - $details .= sprintf ("\n", addlinks ($package['packages.p_conflicts'])); + $details .= sprintf ("\n
Conflicts:
%s
", addlinks ($package['packages.p_conflicts'])); } $size = $package['packages.p_size']; @@ -429,7 +387,7 @@ function pkgdetails ($package) $size = sprintf("%s Bytes", $size); } - $details .= sprintf ("\n
Maintainer:%s
Homepage:%s
Section:%s
Depends:%s
Recommends:%s
Replaces:%s
Provides:%s
Conflicts:%s
Size:%s
", $size); + $details .= sprintf ("\n
Size:
%s
", $size); if($package['packages.p_source']) { @@ -537,4 +495,45 @@ function sectionslist() return $ipkgoutput; } +function check_database() +{ + if($db = sqlite_open(DB_FILENAME)) + { + //initialize db + if (db_table_exists ($db, 'packages') === FALSE) + { + sqlite_query ($db, "CREATE TABLE packages ( + p_name varchar(50), + p_version varchar(10), + p_arch varchar(12), + p_depends varchar(50), + p_maintainer varchar(50), + p_homepage varchar(100), + p_section varchar(20), + p_replaces varchar(50), + p_provides varchar(50), + p_recommends varchar(50), + p_conflicts varchar(50), + p_size int(10), + p_md5 char(32), + p_source varchar(500), + p_feed varchar(20), + p_file varchar(100), + p_desc varchar(1000))"); + } + + if (db_table_exists ($db, 'feeds') === FALSE) + { + sqlite_query ($db, "CREATE TABLE feeds ( + f_name varchar(20), + f_uri varchar(100), + f_comments varchar(500))"); + + test_insert_ipkgs ($db) ; + } + + sqlite_close($db); + } +} + ?> -- cgit v1.2.3