| « Prev | Page 1 | Page 2 | Page 3 | Next » |
Re: Authenticate or Math
2012-04-04 11:58
•
by
Greg
(unregistered)
|
|
Or a Radiohead fan
|
Then 4 == 4 is still TRUE, sadly. Try #ifdef REQUIRES_LOGIN # define 4 5 BUT_ONLY on lefthandside #endif |
|
Do I get extra credit for recognizing CodeIgniter? ... No? ... Ok...
|
|
Nah, it's because 2 is defined as a variable
The function logged_in() can modify that variable, thus enabling or disabling the following code block.... |
Re: Authenticate or Math
2012-04-04 12:14
•
by
emaN ruoY
(unregistered)
|
Then 2+2=3 and you keep the change. |
But you do get credit towards your next visit to the psychotherapist. |
On the other hand, you could probably safely remove all "|| true"s. |
Re: Authenticate or Math
2012-04-04 12:20
•
by
Rfoxmich
(unregistered)
|
|
It was thrown so it could be caught. Just try and you will understand.
|
|
2.4 + 2.4 = 4.8
If you round those values to the nearest integer you get: 2 + 2 = 5 |
Re: Authenticate or Math
2012-04-04 12:23
•
by
Rfoxmich
(unregistered)
|
|
Even that will fail if == has been overloaded so that it no longer tests for equality or modifies the value of two.
|
Re: Authenticate or Math
2012-04-04 12:25
•
by
Re: The Gonvert
(unregistered)
|
Wow, considering the number of replies, this is the best troll ever! |
Re: Authenticate or Math
2012-04-04 12:34
•
by
tj
(unregistered)
|
|
lol...pentium math error. good old days.
|
|
His logic is so wrong 2+2 obviously equals 10 (base-4).
|
Re: Authenticate or Math
2012-04-04 12:48
•
by
IV
(unregistered)
|
I imagined this as authentication code running on a server. So it won't matter what your users are running; it will matter what you are running. And it will always evaluate as true or false for all users (even assuming your theory). |
Re: Authenticate or Math
2012-04-04 13:02
•
by
Fred Flintstone
(unregistered)
|
|
Agreed. I would add code review and any testing from build verification to user acceptance to the TRWTF?
|
>>> if 2+2 == 4: etc... |
Re: Authenticate or Math
2012-04-04 13:14
•
by
foo
(unregistered)
|
You're still giving him too much credit. More like: "I want this condition to always be true (for a change request, or for debugging, doesn't matter), but I don't want/know to comment it out, or remove it (even if it's a permanent change request, after all I might lose some code, what's source control?), so perhaps I can add something to make it always true, oh yeah, I'm so clever, I'll add || and something that's always true, but what could this be? <think hard> Oh right, remember how in kindergarten I learned 2+2=4, and that's always true, wow, I'm really so clever, look how I can put my kindergarten knowledge to practical use, yeah, this looks great, and it actually works. Problem solved, and took me only 10 minutes." TRWRF is so called programmers who don't know shit about Boolean logic, including the dreaded "if foo then return true; else return false;" antipattern, or other lengthy if-else-spaghetti code (or worse, goto) instead of a simple Boolean expression. |
Re: Authenticate or Math
2012-04-04 13:18
•
by
foo
(unregistered)
|
+1 |
Re: Authenticate or Math
2012-04-04 13:19
•
by
foo
(unregistered)
|
if (foo || true == false) |
|
It is a commonly accepted practice to place OR logic into a conditional in order to bypass some dependency for testing purposes, or to stub out code that will do an authentication check at some later point, but is OK to leave unauthenticated for now. George Z should tread carefully in this code, lest he introduce a defect into something that is working in production.
|
Re: Authenticate or Math
2012-04-04 14:04
•
by
Steve
(unregistered)
|
Or 2+2=11 (base-3). Of course, if the compiler is using base-3 or base-4 arithmetic, then "4" is an undefined value and this expression should generate an error (the same as if it was "2+2=Fred" (unless, of course, Fred is 4)). |
Re: Authenticate or Math
2012-04-04 14:09
•
by
the beholder
(unregistered)
|
(ftfy) |
Re: Authenticate or Math
2012-04-04 14:14
•
by
Boolean Troll
(unregistered)
|
by both boolean logic (and operator precedence in most programming languages) A || true evaluates to the same as A... adding the || true in that case would not change the truthiness of the expression. |
|
We all realize, of course, that logged_in() has side effects, and this is a way to ensure that those side effects take place while in effect throwing away the result of the check?
|
Re: Authenticate or Math
2012-04-04 14:19
•
by
Franz Kafka
(unregistered)
|
or you could throw in a //BUGBUG and scan for those before releasing |
Re: Authenticate or Math
2012-04-04 14:26
•
by
Meep
(unregistered)
|
Rather than relying on stupid codes, use source control. hg status to see which files you changed, and then revert them. Or if you've committed, hg diff -r with the revision before the changes. |
Re: Authenticate or Math
2012-04-04 14:28
•
by
Meep
(unregistered)
|
Nice try Mr. Boolean Troll, but it fails with three-valued logic. |
|
I feel obligated to write this since no one has done it yet. TRWTF is PHP!
Actually, TRWTF is PHP syntax... who thought about using -> for object access? Really, what's the explanation for using TWO signs (which in es_ES keyboards takes THREE key-strokes) when a dot works perfectly fine in almost every other language in the world? If you wanted to fuck up the syntax, why not use \_> which takes 6 key-strokes? |
Re: Authenticate or Math
2012-04-04 14:48
•
by
Franky
(unregistered)
|
exactly, there the calculation is always: 2 + 2 = 3 + 1-for-the-own-pocket :D |
Re: Authenticate or Math
2012-04-04 14:52
•
by
Edward
(unregistered)
|
There's a good reason why it would complain of unreachable code. Because it is. |
Re: Authenticate or Math
2012-04-04 15:04
•
by
pedantic
(unregistered)
|
You'd still have to test for an empty $where array, though! |
They'd be better off using “»»”. Maximizes the annoyance for US Windows users for type-ability reasons and for many others because of charset issues… Fun for all! |
Re: Authenticate or Math
2012-04-04 15:21
•
by
Re: The Gonvert
(unregistered)
|
If I remember correctly, from C++, which PHP is written in: a.MyValue() if a is a reference a->MyValue() if a is a pointer -> looks like a pointer, get it? |
|
I can't even find those keys :-)
|
Maybe consider using a normal keyboard? Seriously, {, [, ], } and \ are all three keystrokes on a Belgian keyboard (which has a retarded design, by the way). If programming languages were supposed to be easy to type on every keyboard in the world, we'd be stuck with letters only. Hurray for END IF. |
Re: Authenticate or Math
2012-04-04 16:17
•
by
Peter
(unregistered)
|
A better version of this is "For sufficiently large values of 2": 2.5 isn't really extremely large. |
|
Probably didn't know he could just have made it || 1) if he wanted it to always test true.
|
I am not using PHP, nor am I building the SQL in the front end. This is dynamic sql as in a stored procedure that builds a sql string based on input parameters and uses sp_executesql to execute it. It is more performant in situations where totally different plans will be generated based on whether you need to join to this table or that table and apply this filter or that filter. Amusing that implode is a built in function of PHP. |
|
Does this better capture the original programmer's intent:
if ($this->ion_auto->logged_in() || assert(2 +2==4)) |
Re: Authenticate or Math
2012-04-04 16:46
•
by
default_ex
(unregistered)
|
Basic optimization knowledge? Been a long time since I seen a compiler that doesn't evaluate constant expressions during compile time unless told not to do so with some command line argument or project configuration. |
Re: Authenticate or Math
2012-04-04 17:36
•
by
Dima
(unregistered)
|
I subscribe to that. The actual WTF here is George's lack of experience that prevents him from understanding debugging patterns and enables him to make fun of it. |
Freudian slip. The code made him throw. |
Kick the fucking stupid cunt to death before the fucker breeds. Too late? Kick its fucking offsping to fucking death too. Burn the dwellings it lived in. Salt the ground it wanked on. Exterminate it from the universe. |
Re: Authenticate or Math
2012-04-04 18:24
•
by
Mr.'; Drop Database --
(unregistered)
|
Alternatively: #define EVER ;; |
|
Poorly written backdoor?
|
|
<script type="text/javascript">
var count = 2; function validate() { var un = document.myform.username.value; var pw = document.myform.pword.value; var valid = false; var unArray = ["hussan","ayaz","mehmood","faraz"]; //as many as you like = on comma after final entry var pwArray = ["password1","password2","password3","password4"]; // the corresponding password; for (var i=0; i <unArray.length;i++) { if ((un == unArray[i]) && (pw == pwArray[i])) { valid = true; break; } } if (valid) { alert ("login was successful"); window.location = "http://www.facebook.com"; return false; } var t ="tries"; if (count == 1) {t = "try"} if (count >= 1) { alert ("user name or password to dal pagal admin ajeeb hai?" + count + t + "left"); document.myform.username.value=""; document.myform.pword.value=""; setTimeout("document.myform.username.focus()",2); setTimeout(document.myform.username.select()",2); count --; } else { alert ("still incorrect you have no more tries left!"); document.myform.username.value = "no more tries allowed"; document.myform.pword.value = ""; document.myform.username.disabled = true; document.myform.pword.disabled = true; return false; } } </script> <form> <p> ENTER USER NAME <input type="text" name="username "> ENTER PASSWORD <input type=password name="pword"> <input type="button" value="Check In" name="submit" onClick= "validate"()"> </p> </form> |
|
When you're a hacker, old habits die hard...
|
Re: Authenticate or Math
2012-04-04 18:52
•
by
a;sleo
(unregistered)
|
but 2 + 2 doesn't equal 5, right? (although I guess we're talking stupid anyways) |
| « Prev | Page 1 | Page 2 | Page 3 | Next » |