Describe what this function actually does: Return the ID of a package with a given name and return NULL if such a package doesn't exist. The function name is chosen in a fashion similar to other functions from "pkgfuncs.inc.php" (pkgname_from_id(), pkgnotify_from_sid(), ...). Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- scripts/cleanup | 2 +- web/html/pkgsubmit.php | 4 ++-- web/lib/pkgfuncs.inc.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/cleanup b/scripts/cleanup index 4fc9ea2..b920c8e 100755 --- a/scripts/cleanup +++ b/scripts/cleanup @@ -25,7 +25,7 @@ exec('ls ' . INCOMING_DIR, $files); $count = 0; foreach ($files as $pkgname) { - if (!package_exists($pkgname)) { + if (!pkgid_from_name($pkgname)) { echo 'Removing ' . INCOMING_DIR . "$pkgname\n"; system('rm -r ' . INCOMING_DIR . $pkgname); $count++; diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php index 793f8ca..2e95a56 100644 --- a/web/html/pkgsubmit.php +++ b/web/html/pkgsubmit.php @@ -261,7 +261,7 @@ if ($uid): if (!$error) { # First, see if this package already exists, and if it can be overwritten - $pkg_exists = package_exists($pkg_name); + $pkg_id = pkgid_from_name($pkg_name); if (can_submit_pkg($pkg_name, $_COOKIE["AURSID"])) { if (file_exists($incoming_pkgdir)) { # Blow away the existing file/dir and contents @@ -277,7 +277,7 @@ if ($uid): if (!$error) { # Check if package name is blacklisted. - if (!$pkg_exists && pkgname_is_blacklisted($pkg_name)) { + if (!$pkg_id && pkgname_is_blacklisted($pkg_name)) { if (!canSubmitBlacklisted(account_from_sid($_COOKIE["AURSID"]))) { $error = __( "%s is on the package blacklist, please check if it's available in the official repos.", $pkg_name); } diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php index 8cd1c61..bb5a592 100644 --- a/web/lib/pkgfuncs.inc.php +++ b/web/lib/pkgfuncs.inc.php @@ -90,7 +90,7 @@ function pkgCategories() { # check to see if the package name exists # -function package_exists($name="") { +function pkgid_from_name($name="") { if (!$name) {return NULL;} $dbh = db_connect(); $q = "SELECT ID FROM Packages "; -- 1.7.6