Rick Santorum's Fake Donation Meter
ricksantorum.com
ricksantorum.com
Having it all wired up properly would require a whole lot of infrastructure, particularly for donation mechanisms that aren't online and aren't all tied in to a single system.
UPDATE: They took the donation page down...
Forbidden
You don't have permission to access /stillneedhelp/
on this server.I would assume that while the campaign was active they would periodically adjust the constants to reflect the current average.
val1 = 44000;
val2 = 70000;
maxVal = 100000;
deltav = val2 - val1;
vchange = deltav / deltat;
if (now < t1 && val1 == '0')
val = val1;
else
val = Math.floor((now - t1) * vchange) + val1;
If I had to guess, val1 was how many committed donations they had at 11am April 24th and val2 is how much they anticipated raising in the following 13 hours of April 24th. Note that Santorum suspended his campaign April 10th, so it looks like someone probably was updating this manually until the campaign was fully disbanded.But that's a big theoretically. This is almost certainly malice.
And it would almost certainly have gone unchecked if the developer had only hidden the BS generator script on the server side.
But as others have pointed out, that's probably asking too much given the state of this code and given that the main page 403's but they left the BS script serving.
We choose to go to the moon!
You can infer from the Javascript, but it just displays a dollar amount equal to the number of seconds elapsed since a certain time (edit: whoops, see below), according to your computer clock. If you refresh every second it will go up by $1 each time. If you set your clock back a year, the donation meter will read $-17 million.
Edit: Actually, this isn't quite accurate, it's closer to one dollar per two seconds. 1/(vchange*1000) = 1.7976923076923077 seconds to be exact...
Forbidden
You don't have permission to access /stillneedhelp/ on this server.
(with apologies to Captain Renault :-)
You could just read the quarterly reports he files with the FEC if you actually wanted to know how much he was bringing in. I suppose you could get him in hot water as an ethics violation for campaign reporting but outrage? A bit over the top I think. There are billboards that had a running total of the California state deficit, does anyone think they were repeatedly reading some sort of get_balance() api at the state treasury and putting it up? No, its a prop, a gimmick, an illustrative tool, and nothing more.
Regardless, it's almost certainly false advertising which as you mentioned is ethically questionable especially since this is supposed to be a 'leader' of citizens.
To understand how these problems can be addressed, it is instructive to consider an analogy. Imagine, for a moment, that somewhere in the basement of the Pentagon there are two computers. They are identical hardware, and they run identical software; they are as alike as two peas in a pod. On each of them, there is an executable procedure called "DestroyBaghdad". On one of the machines, executing this procedure does nothing. On the other, the effects of executing the procedure are disastrous, at least for the citizens of Iraq. The only difference between the two machines is a single wire coming out of the back of the second machine.[1]
The point, of course, is that nothing inherent to a computational language is dangerous; danger is posed only insofar as the effects of executing statements in a language include "side-effects" in the external world. If all the "wires" connecting a computational language to the outside world are cut, then executing programs in that language is harmless. (An exception to this claim is that such a program can still tie up the CPU, virtual memory, or swap space on a machine by going into an infinite loop; this can be handled via resource limitations.)
[1]It should be noted that no ethically-trained software engineer would ever consent to write a "DestroyBaghdad" procedure. Basic professional ethics would instead require him to write a "DestroyCity" procedure, to which "Baghdad" could be given as a parameter.
Reusable components and utility libraries is something different, of course.
I'm just guessing, but the site was probably not developed by a technical team, probably some web shop that specializes more on the design/layout/content side and not on the JS side.
So it's likely it's the work of a non-developer than a bad developer. The net result is the same (bad code) but the distinction is that the code was possibly written by someone who wouldn't even be considered a developer.
a) Because it isn't "right" as such. It's just "better" if the code is going to be reused. Which it isn't.
b) The code style serves as documentation. I can clearly read from this code that it's not a reusable component. It is now easier for me to get an idea of how and where this code is being used in the site.
c) Personally, I'm wary of "pre-emptive generalization". Every layer of abstraction makes the code slightly less readable. Also, unless there exists at least two use cases right now, you're not likely to get the reusability right anyway.
For a fundraising drive to fix their debt problems.
"Over 10250.602608 megabytes (and counting) of free storage."
It finds the closest entry in there to the current value of "new Date().getTime()". Then it just adds (what roughs out to) .000004 for every second's difference between the 0 value and the current getTime() value. So today it reads 10250 MB, which must come from index 2 of that array + enough seconds to add 10 MB and some. Definitely more legit than Santorum's.
Here's the code for the counter (it's embedded in that HTML file) http://pastebin.com/8tebjT79
The actual subtractions of the current time from the one in the array seem to be more detailed than what's put on the page, which is being rounded. A sample of input for format():
10250.60874337952
10250.608747448896
10250.608751518273
10250.608755583586
10250.608759652963
10250.608763722339
10250.608767787651Do you have any evidence we do?
I'd be very, very surprised if the ones used by Ron Paul and Obama weren't real. They have good engineering talent there, and (in the case of Obama at least) good political talent. This runs contrary to both.
You can also see them on peoples personal MyBO pages.
(My employer develops it.)
So, technically, yes, still a candidate.
See http://www.businessweek.com/articles/2012-04-19/the-business... for more.