Allow filtering by license when browsing downloadable apps
This commit is contained in:
committed by
WineHQ
parent
5bb8448821
commit
57c4b64986
@@ -9,6 +9,9 @@ require(BASE."include/incl.php");
|
|||||||
|
|
||||||
apidb_header("Browse Downloadable Applications");
|
apidb_header("Browse Downloadable Applications");
|
||||||
|
|
||||||
|
/* Match specific license? */
|
||||||
|
$sLicense = version::checkLicense($aClean['sLicense']);
|
||||||
|
|
||||||
/* Set default values */
|
/* Set default values */
|
||||||
if(!$aClean['iNumVersions'] || $aClean['iNumVersions'] > 200 || $aClean['iNumVersions'] < 0)
|
if(!$aClean['iNumVersions'] || $aClean['iNumVersions'] > 200 || $aClean['iNumVersions'] < 0)
|
||||||
$aClean['iNumVersions'] = 25;
|
$aClean['iNumVersions'] = 25;
|
||||||
@@ -17,12 +20,19 @@ if(!$aClean['iPage'])
|
|||||||
$aClean['iPage'] = 1;
|
$aClean['iPage'] = 1;
|
||||||
|
|
||||||
/* Count the possible matches */
|
/* Count the possible matches */
|
||||||
$hResult = query_parameters("SELECT DISTINCT appFamily.appName,
|
$sQuery = "SELECT DISTINCT appFamily.appName,
|
||||||
appVersion.versionName, appVersion.versionId, appFamily.description
|
appVersion.versionName, appVersion.versionId, appFamily.description
|
||||||
FROM appFamily, appVersion, appData
|
FROM appFamily, appVersion, appData
|
||||||
WHERE appData.type = '?' AND appData.versionId = appVersion.versionId
|
WHERE appData.type = '?' AND appData.versionId = appVersion.versionId
|
||||||
AND appFamily.appId = appVersion.appId",
|
AND appFamily.appId = appVersion.appId";
|
||||||
"downloadurl");
|
|
||||||
|
if(!$sLicense)
|
||||||
|
$hResult = query_parameters($sQuery, "downloadurl");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$sQuery .= " AND license = '?'";
|
||||||
|
$hResult = query_parameters($sQuery, "downloadurl", $sLicense);
|
||||||
|
}
|
||||||
|
|
||||||
if($hResult && mysql_num_rows($hResult))
|
if($hResult && mysql_num_rows($hResult))
|
||||||
$num = mysql_num_rows($hResult);
|
$num = mysql_num_rows($hResult);
|
||||||
@@ -58,16 +68,38 @@ foreach($numVersionsArray as $i)
|
|||||||
|
|
||||||
echo "</select>\n";
|
echo "</select>\n";
|
||||||
|
|
||||||
|
echo "<b>Filter by license</b>\n";
|
||||||
|
$oVersion = new Version();
|
||||||
|
echo $oVersion->makeLicenseList($sLicense);
|
||||||
|
|
||||||
echo " <input type=\"submit\" value=\"Refresh\" />\n";
|
echo " <input type=\"submit\" value=\"Refresh\" />\n";
|
||||||
echo "</form></div>\n<br />\n";
|
echo "</form></div>\n<br />\n";
|
||||||
|
|
||||||
$hResult = query_parameters("SELECT DISTINCT appFamily.appName,
|
if(!$num)
|
||||||
appVersion.versionName, appVersion.versionId, appFamily.description
|
{
|
||||||
FROM appFamily, appVersion, appData
|
echo "<div align=\"center\"><font color=\"red\">No matches found</font></div>\n";
|
||||||
WHERE appData.type = '?' AND appData.versionId = appVersion.versionId
|
echo html_frame_end(" ");
|
||||||
AND appFamily.appId = appVersion.appId
|
exit;
|
||||||
ORDER BY appFamily.appName LIMIT ?, ?",
|
}
|
||||||
"downloadurl", $iLimitLower, $aClean['iNumVersions']);
|
|
||||||
|
$sQuery = "SELECT DISTINCT appFamily.appName,
|
||||||
|
appVersion.versionName, appVersion.versionId, appFamily.description
|
||||||
|
FROM appFamily, appVersion, appData
|
||||||
|
WHERE appData.type = '?' AND appData.versionId = appVersion.versionId
|
||||||
|
AND appFamily.appId = appVersion.appId ";
|
||||||
|
|
||||||
|
if(!$sLicense)
|
||||||
|
{
|
||||||
|
$sQuery .= "ORDER BY appFamily.appName LIMIT ?, ?";
|
||||||
|
$hResult = query_parameters($sQuery, "downloadurl", $iLimitLower,
|
||||||
|
$aClean['iNumVersions']);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
$sQuery .= "AND license = '?' ORDER BY appFamily.appName LIMIT ?, ?";
|
||||||
|
$hResult = query_parameters($sQuery,
|
||||||
|
"downloadurl", $sLicense, $iLimitLower,
|
||||||
|
$aClean['iNumVersions']);
|
||||||
|
}
|
||||||
|
|
||||||
if($hResult && mysql_num_rows($hResult))
|
if($hResult && mysql_num_rows($hResult))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1121,6 +1121,20 @@ class Version {
|
|||||||
return $sReturn;
|
return $sReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* In order to prevent MySQL injections. Returns matched license */
|
||||||
|
function checkLicense($sLicense)
|
||||||
|
{
|
||||||
|
$aLicense = array(LICENSE_RETAIL, LICENSE_OPENSOURCE, LICENSE_FREEWARE,
|
||||||
|
LICENSE_DEMO, LICENSE_SHAREWARE);
|
||||||
|
|
||||||
|
foreach($aLicense as $sElement)
|
||||||
|
{
|
||||||
|
if($sLicense == $sElement)
|
||||||
|
return $sElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user