Poor rating at Clientcopia
-
I have seen some pretty poor ratings for clientcopia stories, but this one is Brillant!
[img]http://img297.imageshack.us/img297/7506/ratingqc7.png[/img]
-
Yeugh! When bugs go bad! This is by far not the first time we've seen some glitch generate a 39 digit number. But I think it's the first time that something actually tried to use the number.
For the brave: Yes, you can open http://clientcopia.com/quotes.php?id=5993. And yes, the script will attempt to output all of the 340282000000000014192072600942972764160 stars. Every single one. It's a pretty nice way to test just how many HTML elements your browser can display.
-
"the real WTF"™ is that they actually use 128bit integers for star ratings in the first place.
-
Ah, yes...
for ($i = 0; $i < $rating; $i++) echo "★"; for ($i = $rating; $i < 10; $i++) echo "☆";
Works nicely when the rating is between 0 and 10. Not so nicely when it isn't, as is apparent in this case.
Now I'm curious, though - how are they getting PHP to display a number that huge without resorting to scientific notation (i.e. 3.40282E+38)?
-
@Quietust said:
how are they getting PHP to display a number that huge without resorting to scientific notation (i.e. 3.40282E+38)?
It could be worse, they could be using the BC library for the ratings. After all, it is a very big number. As for the display, they're probably running it through number_format($rating, 0, '', '') at output time.
-
@Quietust said:
Ah, yes...
for ($i = 0; $i < $rating; $i++) echo "★"; for ($i = $rating; $i < 10; $i++) echo "☆";
Works nicely when the rating is between 0 and 10. Not so nicely when it isn't, as is apparent in this case.
Now I'm curious, though - how are they getting PHP to display a number that huge without resorting to scientific notation (i.e. 3.40282E+38)?I would use this for safety (note that the raings only go to 5):
for ($i = 0; $i < 5; $i++)
if ($i < $rating) echo "★"; else "☆";
-
@GettinSadda said:
for ($i = 0; $i < 5; $i++)
if ($i < $rating) echo "★"; else "☆";
Or they could check the rating form parameters properly.
The form will accept any decimal number as the input. I got bored, and pushed in a 20 rating for this post.
-
@PSWorx said:
Yeugh! When bugs go bad! This is by far not the first time we've seen some glitch generate a 39 digit number. But I think it's the first time that something actually tried to use the number.
For the brave: Yes, you can open http://clientcopia.com/quotes.php?id=5993. And yes, the script will attempt to output all of the 340282000000000014192072600942972764160 stars. Every single one. It's a pretty nice way to test just how many HTML elements your browser can display.
Actually, it isn't the only one like that. #6019 has a stupidly large rating, as does #5985. #6020 has a managable rating - about ten thousand stars. Probably someone realised it allowed you to submit stupidly large ratings, and did so to a whole bunch of them. I haven't the patience to write something that detects or even fixes the ratings.