
Originally Posted by
baileylo
Somewhere in the code should be something that looks like this
PHP Code:
<classname>::OutputRating($variable);
What do you mean somewhere in the method or the whole class?
The script I am analyzing has several method, one is OutputRating and inside that method these calls of other methods exist and all of them use the same parameter $varItem why is that posible?
PHP Code:
Rating::CheckRatingsByIp($varItem) == 0)
$averageStars = Rating::CalculateAverageRating($varItem);
I was wondering if the $varItem where is the $varItem variable is defined? inside the braces or some where before when used in classes and methods?
for further reference I have put the code being analyzed below
PHP Code:
public static function OutputRating($varItem)
{
// Verify $varItem was provided
if ($varItem != null && strlen(trim($varItem)) != 0)
{
// Check if Magic QUotes is ON
if (!get_magic_quotes_gpc())
{
$varItem = addslashes($varItem);
}
// Information for the Output
$averageStars = Rating::CalculateAverageRating($varItem);
// Check to see that the user has not already rated this item
if (Rating::CheckRatingsByIp($varItem) == 0)
{
$classes = "rating" . Rating::ShowStars($averageStars);
// Write Output HTML for the Rating Data
$output = "\r\n";
$output .= "<ul class=\"{$classes}\" id=\"{$varItem}\">\r\n";
$output .= " <li class=\"one\"><a href=\"javascript:RateItem('{$varItem}', 1);\" title=\"1 Star\">1</a></li>\r\n";
$output .= " <li class=\"two\"><a href=\"javascript:RateItem('{$varItem}', 2);\" title=\"2 Stars\">2</a></li>\r\n";
$output .= " <li class=\"three\"><a href=\"javascript:RateItem('{$varItem}', 3);\" title=\"3 Stars\">3</a></li>\r\n";
$output .= " <li class=\"four\"><a href=\"javascript:RateItem('{$varItem}', 4);\" title=\"4 Stars\">4</a></li>\r\n";
$output .= " <li class=\"five\"><a href=\"javascript:RateItem('{$varItem}', 5);\" title=\"5 Stars\">5</a></li>\r\n";
$output .= "</ul>\r\n";
}
else
{
$classes = "rated " . Rating::ShowStars($averageStars);
// Write Output HTML for the Rating Data
$output = "\r\n";
$output .= "<ul class=\"{$classes}\" id=\"{$varItem}\">\r\n";
$output .= " <li class=\"one\">1</li>\r\n";
$output .= " <li class=\"two\">2</li>\r\n";
$output .= " <li class=\"three\">3</li>\r\n";
$output .= " <li class=\"four\">4</li>\r\n";
$output .= " <li class=\"five\">5</li>\r\n";
$output .= " <li class=\"total\">[78]</li>";
$output .= "</ul>\r\n";
}
}
else
{
$output = "";
// This is a major issue. NO information can be retrieve if an item name is not passed.
Error::LogError("Variable Missing", "You must provide the item name for this function to find the average.");
}
return $output;
}
Bookmarks