mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 09:43:03 +00:00
Build URLs from package names (fixes FS#15308, FS#19327).
Drop the "URLPath" field from the "Packages" table, build URLs from package names instead. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
This commit is contained in:
parent
0bb2a7b514
commit
556de318ae
6 changed files with 32 additions and 27 deletions
|
@ -277,7 +277,7 @@ if ($_COOKIE["AURSID"]):
|
|||
}
|
||||
|
||||
# Update package data
|
||||
$q = sprintf("UPDATE Packages SET ModifiedTS = UNIX_TIMESTAMP(), Name = '%s', Version = '%s-%s', License = '%s', Description = '%s', URL = '%s', LocationID = 2, FSPath = '%s', URLPath = '%s', OutOfDateTS = NULL WHERE ID = %d",
|
||||
$q = sprintf("UPDATE Packages SET ModifiedTS = UNIX_TIMESTAMP(), Name = '%s', Version = '%s-%s', License = '%s', Description = '%s', URL = '%s', LocationID = 2, FSPath = '%s', OutOfDateTS = NULL WHERE ID = %d",
|
||||
mysql_real_escape_string($new_pkgbuild['pkgname']),
|
||||
mysql_real_escape_string($new_pkgbuild['pkgver']),
|
||||
mysql_real_escape_string($new_pkgbuild['pkgrel']),
|
||||
|
@ -285,7 +285,6 @@ if ($_COOKIE["AURSID"]):
|
|||
mysql_real_escape_string($new_pkgbuild['pkgdesc']),
|
||||
mysql_real_escape_string($new_pkgbuild['url']),
|
||||
mysql_real_escape_string($incoming_pkgdir . "/" . $pkg_name . ".tar.gz"),
|
||||
mysql_real_escape_string(URL_DIR . $pkg_name . "/" . $pkg_name . ".tar.gz"),
|
||||
$pdata["ID"]);
|
||||
|
||||
db_query($q, $dbh);
|
||||
|
@ -323,7 +322,7 @@ if ($_COOKIE["AURSID"]):
|
|||
$uid = uid_from_sid($_COOKIE["AURSID"]);
|
||||
|
||||
# This is a brand new package
|
||||
$q = sprintf("INSERT INTO Packages (Name, License, Version, CategoryID, Description, URL, LocationID, SubmittedTS, SubmitterUID, MaintainerUID, FSPath, URLPath) VALUES ('%s', '%s', '%s-%s', %d, '%s', '%s', 2, UNIX_TIMESTAMP(), %d, %d, '%s', '%s')",
|
||||
$q = sprintf("INSERT INTO Packages (Name, License, Version, CategoryID, Description, URL, LocationID, SubmittedTS, SubmitterUID, MaintainerUID, FSPath) VALUES ('%s', '%s', '%s-%s', %d, '%s', '%s', 2, UNIX_TIMESTAMP(), %d, %d, '%s')",
|
||||
mysql_real_escape_string($new_pkgbuild['pkgname']),
|
||||
mysql_real_escape_string($new_pkgbuild['license']),
|
||||
mysql_real_escape_string($new_pkgbuild['pkgver']),
|
||||
|
@ -333,8 +332,7 @@ if ($_COOKIE["AURSID"]):
|
|||
mysql_real_escape_string($new_pkgbuild['url']),
|
||||
$uid,
|
||||
$uid,
|
||||
mysql_real_escape_string($incoming_pkgdir . "/" . $pkg_name . ".tar.gz"),
|
||||
mysql_real_escape_string(URL_DIR . $pkg_name . "/" . $pkg_name . ".tar.gz"));
|
||||
mysql_real_escape_string($incoming_pkgdir . "/" . $pkg_name . ".tar.gz"));
|
||||
|
||||
$result = db_query($q, $dbh);
|
||||
$packageID = mysql_insert_id($dbh);
|
||||
|
|
|
@ -18,10 +18,23 @@ include_once("aur.inc");
|
|||
**/
|
||||
class AurJSON {
|
||||
private $dbh = false;
|
||||
private $exposed_methods = array('search','info','msearch');
|
||||
private $fields = array('Packages.ID','Name','Version','CategoryID',
|
||||
'Description', 'LocationID', 'URL','URLPath','License','NumVotes',
|
||||
'(OutOfDateTS IS NOT NULL) AS OutOfDate');
|
||||
private $exposed_methods = array();
|
||||
private $fields = array();
|
||||
|
||||
/**
|
||||
* Initialize methods and database fields.
|
||||
**/
|
||||
public function __construct() {
|
||||
$this->exposed_methods = array('search', 'info', 'msearch');
|
||||
|
||||
$this->fields = array(
|
||||
'Packages.ID', 'Name', 'Version', 'CategoryID',
|
||||
'Description', 'LocationID', 'URL', 'CONCAT("' .
|
||||
mysql_real_escape_string(URL_DIR) .
|
||||
'", Name, "/", Name, ".tar.gz") AS URLPath', 'License',
|
||||
'NumVotes', '(OutOfDateTS IS NOT NULL) AS OutOfDate'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles post data, and routes the request.
|
||||
|
|
|
@ -173,8 +173,9 @@ $out_of_date_time = ($row["OutOfDateTS"] == 0) ? $msg : gmdate("r", intval($row[
|
|||
$src = $src[0];
|
||||
# It is presumably an internal source
|
||||
if ($row["LocationID"] == 2) {
|
||||
echo "<a href='".dirname($row['URLPath'])."/".$row['Name'];
|
||||
echo "/$src'>$src</a><br />\n";
|
||||
$urlpath = URL_DIR . $row['Name'];
|
||||
echo "<a href='$urlpath/$src'>";
|
||||
echo "$src</a><br />\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue