Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Design Guidelines For Better Notifications UX

      July 7, 2025

      10 Top React.js Development Service Providers For Your Next Project In 2026

      July 7, 2025

      Top 7 Mistakes Enterprises Make When Outsourcing React.js Development

      July 7, 2025

      10 Top Node.js Development Companies for Enterprise-Scale Projects (2025-2026 Ranked & Reviewed)

      July 4, 2025

      5 ways to be great AI agent manager, according to business leaders

      July 7, 2025

      10 discounted gadgets I use regularly as a handyman (and why they make such a big difference)

      July 7, 2025

      How Let’s Encrypt made the internet safer and HTTPS standard – and free

      July 7, 2025

      How I used ChatGPT to quickly fix a critical open-source plugin – without touching a line of code

      July 7, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Carolina Contreras Landinez Champions Growth and Builds Strong Teams Through Mentorship

      July 7, 2025
      Recent

      Carolina Contreras Landinez Champions Growth and Builds Strong Teams Through Mentorship

      July 7, 2025

      Laravel Request Content Type Inspection Methods

      July 7, 2025

      The Pipe Operator is Coming to PHP 8.5

      July 7, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Benchmarking the Orange Pi R2S Single Board Computer

      July 7, 2025
      Recent

      Benchmarking the Orange Pi R2S Single Board Computer

      July 7, 2025

      Distribution Release: Parrot 6.4

      July 7, 2025

      Packet is the Linux App You Didn’t Know You Needed for Fast Android File Transfers

      July 7, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»News & Updates»Representative Line: Get Explosive

    Representative Line: Get Explosive

    April 3, 2025

    Sean sends us a one-line function that is a delight, if by delight you mean “horror”. You’ll be shocked to know it’s PHP.

    function proget(){foreach($_GET as $k=>$v){if($k=="h"){$GLOBALS["h"]=1;}$p=explode(",",$k);}return($p);} //function to process GET headers
    

    Based on the comment, proget is a shorthand for process_get_parameters. Which is sort of what it does. Sort of.

    Let’s go through this. We iterate across our $_GET parameters using $k for the key, $v for the value, but we never reference the value so forget it exists. We’re iterating across every key. The first thing we check is if a key "h" exists. We don’t look at its value, we just check if it exists, and if it does, we set a global variable. And this, right here, is enough for this to be a WTF. The logic of “set a global variable based on the existence of a query parameter regardless of the value of the query parameter” is… a lot. But then, somehow, this actually gets more out there.

    We explode the key on commas (explode being PHP’s much cooler name for split), which implies… our keys may be lists of values? Which I feel like is an example of someone not understanding what a “key” is. But worse than that, we just do this for every key, and return the results of performing that operation on the last key. Which means that if this function is doing anything at all, it’s entirely dependent on the order of the keys. Which, PHP does order the keys by the order they’re added, which I take to mean that if the URL has query params like ?foo=1&h=0&a,b,c,d=wtf. Or, if we’re being picky about encoding, ?foo=1&h=0&a%2Cb%2Cc%2Cd=wtf. The only good news here is that PHP handles the encoding/decoding for you, so the explode will work as expected.

    This is the kind of bad code that leaves me with lots of questions, and I’m not sure I want any of the answers. How did this happen, and why are questions best left unanswered, because I think the answers might cause more harm.

    [Advertisement] Plan Your .NET 9 Migration with Confidence
    Your journey to .NET 9 is more than just one decision.Avoid migration migraines with the advice in this free guide. Download Free Guide Now!

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleFOSS Weekly #25.14: Fedora 42 COSMIC, OnePackage, AppImage Tools and More Linux Stuff
    Next Article Rilasciato Qt 6.9: il framework per interfacce grafiche si aggiorna con prestazioni potenziate e nuovo supporto emoji

    Related Posts

    News & Updates

    5 ways to be great AI agent manager, according to business leaders

    July 7, 2025
    News & Updates

    10 discounted gadgets I use regularly as a handyman (and why they make such a big difference)

    July 7, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    How to Upgrade to Ubuntu 25.04 ‘Plucky Puffin’

    Linux

    Honey, the Amazon humanoid delivery robot is here! (well, almost)

    News & Updates

    The Ultimate SEO Toolbox for Boosting Your Website’s Performance

    Web Development

    Qilin Solidifies Claim as Top Ransomware Group

    Development

    Highlights

    News & Updates

    Microsoft lays off another 305 employees, this time closer to home

    June 3, 2025

    Microsoft confirmed 305 layoffs in Washington state this week, continuing a trend of tech job…

    CVE-2025-4030 – “PHPGurukul COVID19 Testing Management System SQL Injection”

    April 28, 2025

    TA829 and UNK_GreenSec Share Tactics and Infrastructure in Ongoing Malware Campaigns

    July 1, 2025

    CVE-2024-56524 – Radware Cloud Web Application Firewall (WAF) URL Filter Bypass Vulnerability

    May 12, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.