Jimmy Kimmel goes nuclear over ABC cancelling him for outrageous Charlie Kirk comments... as insiders reveal he ALREADY has new job plans
This is how much first-time home owners spend on rent before buying - it's risen £46,621 in a decade
Drivers urged to avoid A12 Northbound after serious crash
Toys can tell us a lot about how tech will change our lives
Column Twenty-five years ago this month I published a book called The Playful World that explored a simple idea: that the seeds of the future can be found in the present by considering the dazzling toys we started giving our children at the turn of the millennium.…
Mortgage brokers steering borrowers to two-year fixes to line their pockets, whistleblower claims
Britain has an inflation problem and we need to stop making it worse: SIMON LAMBERT
The secret whispers, subtle nods and stunning gestures you didn't see as Trump met the King REVEALED
UK 'will formally recognise Palestine as a state'... after Trump leaves the country
Color-Changing Organogel Stretches 46 Times Its Size and Self-Heals
Read more of this story at Slashdot.
I refuse to call Camilla Parker Bowles Queen, PETER HITCHENS declares
Apprentice finalist scoops £20m payday after buying Lord Sugar out
Serious crash closes part of A12 Northbound as drivers urged to avoid
Influencer sparks concern as she shows off her VERY thin frame in a bikini: 'Are you OK?'
A12 diversion route as serious crash completely shuts road near Chelmsford
Revealed: Egyptian illegal migrant, 42, who raped woman in Hyde Park while living in the Hilton hotel is a convicted Islamic terrorist
Huawei lays out multi-year AI accelerator roadmap and claims it makes Earth’s mightiest clusters
Chinese tech giant Huawei has kicked off its annual “Connect” conference by laying out a plan to deliver increasingly powerful AI processors that look to have enough power that Middle Kingdom users won’t need to try getting Nvidia parts across the border.…
Meta teams up with Oakley on AI sports glasses with an action-ready hidden camera - the ultimate gadget for fitness influencers
Second by second, Prince Andrew's ill-judged royal appearance: JANE FRYER
CodeSOD: An Echo In Here in here
Tobbi sends us a true confession: they wrote this code.
The code we're about to look at is the kind of code that mixes JavaScript and PHP together, using PHP to generate JavaScript code. That's already a terrible anti-pattern, but Tobbi adds another layer to the whole thing.
if (AJAX) { <?php echo "AJAX.open(\"POST\", '/timesheets/v2/rapports/FactBCDetail/getDateDebutPeriode.php', true);"; ?> AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); AJAX.onreadystatechange = callback_getDateDebutPeriode; AJAX.send(strPostRequest); } if (AJAX2) { <?php echo "AJAX2.open(\"POST\", '/timesheets/v2/rapports/FactBCDetail/getDateFinPeriode.php', true);"; ?> AJAX2.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); AJAX2.onreadystatechange = callback_getDateFinPeriode; AJAX2.send(strPostRequest); }So, this uses server side code to… output string literals which could have just been written directly into the JavaScript without the PHP step.
"What was I thinking when I wrote that?" Tobbi wonders. Likely, you weren't thinking, Tobbi. Have another cup of coffee, I think you need it.
All in all, this code is pretty harmless, but is a malodorous brain-fart. As for absolution: this is why we have code reviews. Either your org doesn't do them, or it doesn't do them well. Anyone can make this kind of mistake, but only organizational failures get this code merged.