diff --git a/appview.php b/appview.php
index 0fc8e80..b1fb693 100644
--- a/appview.php
+++ b/appview.php
@@ -1,11 +1,11 @@
+/**********************************/
+/* code to display an application */
+/**********************************/
-
-/*
- * Application Database - appview.php
- *
+/**
+ * APPLICATION ENVIRONMENT
*/
-
include("path.php");
require(BASE."include/"."incl.php");
require(BASE."include/"."application.php");
@@ -18,41 +18,37 @@ require(BASE."include/"."category.php");
require(BASE."include/"."maintainer.php");
-global $apidb_root;
// NOTE: app Owners will see this menu too, make sure we don't show admin-only options
function admin_menu()
{
- global $appId;
- global $versionId;
global $apidb_root;
$m = new htmlmenu("Admin");
- if($versionId)
- {
- $m->add("Add Note", $apidb_root."admin/addAppNote.php?appId=$appId&versionId=$versionId");
+ if($_REQUEST[versionId]) {
+ $m->add("Add Note", $apidb_root."admin/addAppNote.php?appId=$appId&versionId=".$_REQUEST['versionId']);
$m->addmisc(" ");
- $m->add("Edit Version", $apidb_root."admin/editAppVersion.php?appId=$appId&versionId=$versionId");
+ $m->add("Edit Version", $apidb_root."admin/editAppVersion.php?appId=$appId&versionId=".$_REQUEST['versionId']);
- $url = $apidb_root."admin/deleteAny.php?what=appVersion&versionId=$versionId&confirmed=yes";
+ $url = $apidb_root."admin/deleteAny.php?what=appVersion&versionId=".$_REQUEST['versionId']."&confirmed=yes";
$m->add("Delete Version", "javascript:deleteURL(\"Are you sure?\", \"".$url."\")");
} else
{
- $m->add("Add Version", $apidb_root."admin/addAppVersion.php?appId=$appId");
+ $m->add("Add Version", $apidb_root."admin/addAppVersion.php?appId=".$_REQUEST['appId']);
$m->addmisc(" ");
-
- $m->add("Edit App", $apidb_root."admin/editAppFamily.php?appId=$appId");
-
+
+ $m->add("Edit App", $apidb_root."admin/editAppFamily.php?appId=".$_REQUEST['appId']);
+
// global admin options
if(havepriv("admin"))
{
- $url = $apidb_root."admin/deleteAny.php?what=appFamily&appId=$appId&confirmed=yes";
+ $url = $apidb_root."admin/deleteAny.php?what=appFamily&appId=".$_REQUEST['appId']."&confirmed=yes";
$m->add("Delete App", "javascript:deleteURL(\"Are you sure?\", \"".$url."\")");
$m->addmisc(" ");
- $m->add("Edit Owners", $apidb_root."admin/editAppOwners.php?appId=$appId");
- $m->add("Edit Bundle", $apidb_root."admin/editBundle.php?bundleId=$appId");
+ $m->add("Edit Owners", $apidb_root."admin/editAppOwners.php?appId=".$_REQUEST['appId']);
+ $m->add("Edit Bundle", $apidb_root."admin/editBundle.php?bundleId=".$_REQUEST['appId']);
}
}
@@ -60,34 +56,47 @@ function admin_menu()
}
-function get_screenshot_img($appId, $versionId)
+/**
+ * Get a random image for a particular version of an app.
+ * If the version is not set, get a random app image
+ */
+function get_screenshot_img($appId, $versionId="")
{
global $apidb_root;
- if(!$versionId)
- $versionId = 0;
-
- $result = mysql_query("SELECT * FROM appData WHERE appId = $appId AND versionId = $versionId AND type = 'image'");
+ if($versionId)
+ {
+ $result = mysql_query("SELECT *, RAND() AS rand FROM appData WHERE appId = $appId AND versionId = $versionId AND type = 'image' ORDER BY rand");
+ }
+ else {
+ $result = mysql_query("SELECT *, RAND() AS rand FROM appData WHERE appId = $appId AND type = 'image' ORDER BY rand");
+ }
if(!$result || !mysql_num_rows($result))
{
- $imgFile = "
";
+ $imgFile = "
";
}
else
{
$ob = mysql_fetch_object($result);
$imgFile = "";
+ "border=0 alt='$ob->description' />";
}
$img = html_frame_start("",'128','',2);
- $img .= "$imgFile";
- $img .= html_frame_end()."
";
+ if($versionId)
+ $img .= "$imgFile";
+ else
+ $img .= $imgFile;
+ $img .= html_frame_end()."
";
return $img;
}
+/**
+ * TODO: what does it do ?
+ */
function display_catpath($catId)
{
$cat = new Category($catId);
@@ -98,16 +107,18 @@ function display_catpath($catId)
echo html_frame_end();
}
-/* display the SUB apps that belong to this app */
+
+/**
+ * display the SUB apps that belong to this app
+ */
function display_bundle($appId)
{
$result = mysql_query("SELECT appFamily.appId, appName, description FROM appBundle, appFamily ".
- "WHERE bundleId = $appId AND appBundle.appId = appFamily.appId");
+ "WHERE bundleId = $appId AND appBundle.appId = appFamily.appId");
if(!$result || mysql_num_rows($result) == 0)
- {
- // do nothing
- return;
- }
+ {
+ return; // do nothing
+ }
echo html_frame_start("","98%","",0);
echo "
| ".stripslashes($ob->appName)." | \n"; - echo "$desc | \n"; - echo "
| ".stripslashes($ob->appName)." | \n"; + echo "$desc | \n"; + echo "
| Version | \n"; - echo "Description | \n"; - echo "Rating With Windows | \n"; - echo "Rating Without Windows | \n"; - echo "Comments | \n"; - echo "
| Version | \n"; + echo "Description | \n"; + echo "Rating With Windows | \n"; + echo "Rating Without Windows | \n"; + echo "Comments | \n"; + echo "
| ".$ver->versionName." | \n"; @@ -222,23 +235,25 @@ function display_versions($appId, $versions) echo "$r_count | \n"; echo "
| \n"; @@ -289,41 +301,45 @@ if($appId && !$versionId) echo " | |
| BUGS | ". " Check for bugs in bugzilla \n"; echo " |
| URL | ".$appLinkURL." |
| URL | ".$appLinkURL." |
| Links | \n"; - while($ob = mysql_fetch_object($result)) + echo " |
| Links | \n";
+ while($ob = mysql_fetch_object($result))
{
- echo " ".substr(stripslashes($ob->description),0,30)." \n"; + echo " ".substr(stripslashes($ob->description),0,30)." \n"; } - echo " |
| $img | |
| Owner | \n"; + echo "|
| Owner | \n"; echo "\n";
- while($ob = mysql_fetch_object($result))
+ while($ob = mysql_fetch_object($result))
{
$inResult = mysql_query("SELECT username,email FROM user_list WHERE userid = $ob->ownerId");
- if ($inResult && mysql_num_rows($inResult) > 0)
- {
- $foo = mysql_fetch_object($inResult);
- echo " ".substr(stripslashes($foo->username),0,30)." \n"; + if ($inResult && mysql_num_rows($inResult) > 0) + { + $foo = mysql_fetch_object($inResult); + echo " ".substr(stripslashes($foo->username),0,30)." \n"; } } - echo " |
| Description \n"; echo add_br(stripslashes($data->description)); @@ -389,24 +405,28 @@ if($appId && !$versionId) echo html_frame_end("For more details and user comments, view the versions of this application."); - //display versions + // display versions display_versions($appId,$app->getAppVersionList()); - //display bundle + // display bundle display_bundle($appId); // disabled for now //log_application_visit($appId); } + +####################################### +# We want to see a particular version # +####################################### else if($appId && $versionId) { $app = new Application($appId); $data = $app->data; - if(!$data ) + if(!$data) { // Oops! application not found or other error. do something errorpage('Internal Database Access Error. No App found.'); - exit; + exit; } $ver = $app->getAppVersion($versionId); @@ -414,7 +434,7 @@ else if($appId && $versionId) { // Oops! Version not found or other error. do something errorpage('Internal Database Access Error. No Version Found.'); - exit; + exit; } // rating menu @@ -432,37 +452,36 @@ else if($appId && $versionId) // header apidb_header("Viewing App Version - ".$data->appName); - //cat + // cat display_catpath($app->data->catId); - - //set URL + + // set URL $appLinkURL = ($ver->webPage) ? "".substr(stripslashes($ver->webPage),0,30)."": " "; - //start version display + // start version display echo html_frame_start("","98%","",0); - + echo ' | ||||||||||||||
',"\n";
echo '
| ||||||||||||||