2004-12-12 03:51:51 +00:00
|
|
|
<?php
|
2004-12-25 20:08:00 +00:00
|
|
|
/*********************/
|
|
|
|
|
/* voting statistics */
|
|
|
|
|
/*********************/
|
2004-03-15 16:22:00 +00:00
|
|
|
|
2004-12-25 20:08:00 +00:00
|
|
|
/*
|
2004-12-27 23:54:55 +00:00
|
|
|
* application environment
|
2004-12-25 20:08:00 +00:00
|
|
|
*/
|
2004-03-15 16:22:00 +00:00
|
|
|
include("path.php");
|
2005-02-09 23:47:01 +00:00
|
|
|
include(BASE."include/incl.php");
|
2006-07-07 17:57:12 +00:00
|
|
|
require(BASE."include/filter.php");
|
2005-02-09 23:47:01 +00:00
|
|
|
require(BASE."include/category.php");
|
2004-03-15 16:22:00 +00:00
|
|
|
|
2004-11-09 22:31:15 +00:00
|
|
|
/* default to 25 apps, main categories */
|
|
|
|
|
$topNumber = 25;
|
|
|
|
|
$categoryId = "any"; /* default to all categories */
|
2004-03-15 16:22:00 +00:00
|
|
|
|
2004-11-09 22:31:15 +00:00
|
|
|
/* process the post variables to override the default settings */
|
2006-07-06 17:27:54 +00:00
|
|
|
if( !empty($aClean['iTopNumber']) AND is_numeric($aClean['iTopNumber']))
|
|
|
|
|
$topNumber = $aClean['iTopNumber'];
|
|
|
|
|
if( !empty($aClean['iCategoryId']) AND is_numeric($aClean['iCategoryId']))
|
|
|
|
|
$categoryId = $aClean['iCategoryId'];
|
2004-11-09 22:31:15 +00:00
|
|
|
|
2005-01-02 17:00:04 +00:00
|
|
|
/* Check if the value makes sense */
|
2005-01-02 22:08:00 +00:00
|
|
|
if($topNumber > 200 || $topNumber < 1)
|
2005-01-02 17:00:04 +00:00
|
|
|
$topNumber = 25;
|
|
|
|
|
|
2004-11-09 22:31:15 +00:00
|
|
|
apidb_header("Vote Stats - Top $topNumber Applications");
|
|
|
|
|
|
|
|
|
|
/* display the selection for the top number of apps to view */
|
2006-07-06 17:27:54 +00:00
|
|
|
echo "<form method=\"post\" name=\"sMessage\" action=\"".$_SERVER['PHP_SELF']."\">";
|
2004-11-09 22:31:15 +00:00
|
|
|
echo "<b>Number of top apps to display:</b>";
|
2006-07-06 17:27:54 +00:00
|
|
|
echo "<select name='iTopNumber'>";
|
2004-11-09 22:31:15 +00:00
|
|
|
$topNumberArray = array(25, 50, 100, 200);
|
|
|
|
|
|
|
|
|
|
foreach ($topNumberArray as $i => $value)
|
|
|
|
|
{
|
|
|
|
|
if($topNumberArray[$i] == $topNumber)
|
|
|
|
|
echo "<option value='$topNumberArray[$i]' SELECTED>$topNumberArray[$i]";
|
|
|
|
|
else
|
|
|
|
|
echo "<option value='$topNumberArray[$i]'>$topNumberArray[$i]";
|
|
|
|
|
}
|
|
|
|
|
echo "</select>";
|
|
|
|
|
|
|
|
|
|
/* list sub categories */
|
|
|
|
|
if($categoryId == "any")
|
|
|
|
|
$catId = 0;
|
|
|
|
|
else
|
|
|
|
|
$catId = $categoryId;
|
|
|
|
|
|
|
|
|
|
/******************************************************************/
|
|
|
|
|
/* build an array of categories from the current category back up */
|
|
|
|
|
/* the tree to the main category */
|
|
|
|
|
$cat_array = Array();
|
|
|
|
|
$cat_name_array = Array();
|
|
|
|
|
|
|
|
|
|
if($catId != 0)
|
|
|
|
|
{
|
|
|
|
|
$currentCatId = $catId;
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
2006-06-30 16:33:02 +00:00
|
|
|
$sCatQuery = "SELECT appCategory.catName, appCategory.catParent ".
|
2006-06-27 19:16:27 +00:00
|
|
|
"FROM appCategory WHERE appCategory.catId = '?'";
|
2006-06-30 16:33:02 +00:00
|
|
|
$hResult = query_parameters($sCatQuery, $currentCatId);
|
2004-03-15 16:22:00 +00:00
|
|
|
|
2006-06-21 01:04:12 +00:00
|
|
|
if($hResult)
|
2004-11-09 22:31:15 +00:00
|
|
|
{
|
2006-06-30 16:33:02 +00:00
|
|
|
$oRow = mysql_fetch_object($hResult);
|
|
|
|
|
$catParent = $oRow->catParent;
|
2004-11-09 22:31:15 +00:00
|
|
|
|
|
|
|
|
array_push($cat_array, "$currentCatId");
|
2006-06-30 16:33:02 +00:00
|
|
|
array_push($cat_name_array, "$oRow->catName");
|
2004-11-09 22:31:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$currentCatId = $catParent;
|
|
|
|
|
} while($currentCatId != 0);
|
|
|
|
|
}
|
2004-03-15 16:22:00 +00:00
|
|
|
|
2004-11-09 22:31:15 +00:00
|
|
|
/*******************************************************************/
|
|
|
|
|
/* add options for all of the categories that we are recursed into */
|
|
|
|
|
echo "<b>Section:</b>";
|
2006-07-06 17:27:54 +00:00
|
|
|
echo '<select name="iCategoryId">';
|
2004-11-09 22:31:15 +00:00
|
|
|
|
|
|
|
|
if($catId == 0)
|
2005-02-09 23:47:01 +00:00
|
|
|
echo '<option value="any" SELECTED>Any</option>';
|
2004-11-09 22:31:15 +00:00
|
|
|
else
|
2005-02-09 23:47:01 +00:00
|
|
|
echo '<option value="any">Any</option>';
|
2004-11-09 22:31:15 +00:00
|
|
|
|
|
|
|
|
$indent = 1;
|
|
|
|
|
|
|
|
|
|
/* reverse the arrays because we need the entries in the opposite order */
|
|
|
|
|
$cat_array_reversed = array_reverse($cat_array);
|
|
|
|
|
$cat_name_array_reversed = array_reverse($cat_name_array);
|
|
|
|
|
foreach ($cat_array_reversed as $i => $value)
|
|
|
|
|
{
|
|
|
|
|
/* if this is the current category, select this option */
|
|
|
|
|
if($categoryId == $cat_array_reversed[$i])
|
|
|
|
|
echo "<option value='$cat_array_reversed[$i]' SELECTED>";
|
|
|
|
|
else
|
|
|
|
|
echo "<option value='$cat_array_reversed[$i]'>";
|
|
|
|
|
|
|
|
|
|
echo str_repeat("-", $indent);
|
|
|
|
|
echo stripslashes($cat_name_array_reversed[$i]);
|
2005-02-09 23:47:01 +00:00
|
|
|
echo "</option>";
|
2004-11-09 22:31:15 +00:00
|
|
|
$indent++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/******************************************************************/
|
|
|
|
|
/* add to the list all of the sub sections of the current section */
|
|
|
|
|
$cat = new Category($catId);
|
2005-02-09 23:47:01 +00:00
|
|
|
$subs = $cat->aSubcatsIds;
|
2004-11-09 22:31:15 +00:00
|
|
|
|
|
|
|
|
if($subs)
|
|
|
|
|
{
|
2005-02-09 23:47:01 +00:00
|
|
|
while(list($i, $id) = each($subs))
|
2004-11-09 22:31:15 +00:00
|
|
|
{
|
2005-02-09 23:47:01 +00:00
|
|
|
$oSubcat = new Category($id);
|
2004-11-09 22:31:15 +00:00
|
|
|
/* if this is the current category, select this option */
|
|
|
|
|
if($id == $catId)
|
|
|
|
|
echo "<option value=$id SELECTED>";
|
|
|
|
|
else
|
|
|
|
|
echo "<option value=$id>";
|
|
|
|
|
|
|
|
|
|
echo str_repeat("-", $indent);
|
2005-02-09 23:47:01 +00:00
|
|
|
echo stripslashes($oSubcat->sName);
|
2004-11-09 22:31:15 +00:00
|
|
|
}
|
|
|
|
|
}
|
2004-12-29 20:21:31 +00:00
|
|
|
echo '</select>';
|
2005-02-09 23:47:01 +00:00
|
|
|
echo '<input type="submit" value="Refresh" />';
|
2004-12-29 20:21:31 +00:00
|
|
|
echo '</form>';
|
|
|
|
|
echo '<br />';
|
|
|
|
|
echo '<br />';
|
2004-11-09 22:31:15 +00:00
|
|
|
|
|
|
|
|
/***************************************************/
|
|
|
|
|
/* build a list of the apps in the chosen category */
|
|
|
|
|
if(strcasecmp($categoryId, "any") == 0)
|
|
|
|
|
{
|
|
|
|
|
/* leave out the appFamily.catId = '$categoryId' */
|
2006-06-27 19:16:27 +00:00
|
|
|
$hResult = query_parameters("SELECT appVotes.appId, appName, count(userId) as count ".
|
|
|
|
|
"FROM appVotes, appFamily ".
|
|
|
|
|
"WHERE appVotes.appId = appFamily.appId ".
|
|
|
|
|
"GROUP BY appId ORDER BY count DESC LIMIT ?", $topNumber);
|
2004-11-09 22:31:15 +00:00
|
|
|
} else
|
|
|
|
|
{
|
2005-01-05 05:27:30 +00:00
|
|
|
/* Display all application for a given category (including sub categories)
|
|
|
|
|
SELECT f.appId, f.appName
|
|
|
|
|
FROM appFamily AS f, appCategory AS c
|
|
|
|
|
WHERE f.catId = c.catId
|
|
|
|
|
AND (
|
|
|
|
|
c.catId =29
|
|
|
|
|
OR c.catParent =29)*/
|
|
|
|
|
|
2006-06-27 19:16:27 +00:00
|
|
|
$hResult = query_parameters("SELECT v.appId, f.appName, count( v.appId ) AS count
|
2005-01-05 05:27:30 +00:00
|
|
|
FROM appFamily AS f, appCategory AS c, appVotes AS v
|
|
|
|
|
WHERE v.appId = f.appId
|
|
|
|
|
AND f.catId = c.catId
|
|
|
|
|
AND (
|
2006-06-27 19:16:27 +00:00
|
|
|
c.catId = '?'
|
|
|
|
|
OR c.catParent = '?'
|
2005-01-05 05:27:30 +00:00
|
|
|
)
|
2005-01-08 18:14:16 +00:00
|
|
|
GROUP BY appId
|
2006-06-27 19:16:27 +00:00
|
|
|
ORDER BY count DESC LIMIT ?", $categoryId, $categoryId, $topNumber);
|
2004-11-09 22:31:15 +00:00
|
|
|
}
|
2004-03-15 16:22:00 +00:00
|
|
|
|
2006-06-27 19:16:27 +00:00
|
|
|
if($hResult)
|
2004-03-15 16:22:00 +00:00
|
|
|
{
|
|
|
|
|
echo html_frame_start("", "90%", '', 0);
|
|
|
|
|
echo html_table_begin("width='100%' align=center");
|
|
|
|
|
echo "<tr class=color4><td><font color=white>Application Name</font></td>\n";
|
|
|
|
|
echo "<td><font color=white>Votes</font></td></tr>\n";
|
|
|
|
|
|
|
|
|
|
$c = 1;
|
2006-06-21 01:04:12 +00:00
|
|
|
while($row = mysql_fetch_object($hResult))
|
2004-03-15 16:22:00 +00:00
|
|
|
{
|
2006-06-21 01:04:12 +00:00
|
|
|
$bgcolor = ($c % 2) ? "color0" : "color1";
|
2006-07-06 17:27:54 +00:00
|
|
|
$link = "<a href='appview.php?iAppId=$row->appId'>$row->appName</a>";
|
2006-06-21 01:04:12 +00:00
|
|
|
echo "<tr class=$bgcolor><td width='90%'>$c. $link </td> <td> $row->count </td></tr>\n";
|
2004-12-12 22:36:31 +00:00
|
|
|
$c++;
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
2004-11-09 22:31:15 +00:00
|
|
|
|
2004-03-15 16:22:00 +00:00
|
|
|
echo html_table_end();
|
|
|
|
|
echo html_frame_end();
|
2004-11-09 22:31:15 +00:00
|
|
|
|
|
|
|
|
/* Make sure we tell the user here are no apps, otherwise they might */
|
|
|
|
|
/* think that something went wrong with the server */
|
|
|
|
|
if($c == 1)
|
|
|
|
|
{
|
2005-05-11 03:08:07 +00:00
|
|
|
echo '<h2 align="center">No apps found in this category, please vote for your favorite apps!</h2>';
|
2004-11-09 22:31:15 +00:00
|
|
|
}
|
|
|
|
|
|
2006-07-06 17:27:54 +00:00
|
|
|
echo '<p align="center"><a href="help/?sTopic=voting">What does this screen mean?</a></p>';
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
apidb_footer();
|
|
|
|
|
?>
|