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

      CodeSOD: An Echo In Here in here

      September 19, 2025

      How To Minimize The Environmental Impact Of Your Website

      September 19, 2025

      Progress adds AI coding assistance to Telerik and Kendo UI libraries

      September 19, 2025

      Wasm 3.0 standard is now officially complete

      September 19, 2025

      Development Release: Ubuntu 25.10 Beta

      September 18, 2025

      Development Release: Linux Mint 7 Beta “LMDE”

      September 18, 2025

      Distribution Release: Tails 7.0

      September 18, 2025

      Distribution Release: Security Onion 2.4.180

      September 18, 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

      GenStudio for Performance Marketing: What’s New and What We’ve Learned

      September 19, 2025
      Recent

      GenStudio for Performance Marketing: What’s New and What We’ve Learned

      September 19, 2025

      Agentic and Generative Commerce Can Elevate CX in B2B

      September 19, 2025

      AI Momentum and Perficient’s Inclusion in Analyst Reports – Highlights From 2025 So Far

      September 18, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Denmark’s Strategic Leap Replacing Microsoft Office 365 with LibreOffice for Digital Independence

      September 19, 2025
      Recent

      Denmark’s Strategic Leap Replacing Microsoft Office 365 with LibreOffice for Digital Independence

      September 19, 2025

      Development Release: Ubuntu 25.10 Beta

      September 18, 2025

      Development Release: Linux Mint 7 Beta “LMDE”

      September 18, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Tech & Work»CodeSOD: An Echo In Here in here

    CodeSOD: An Echo In Here in here

    September 19, 2025

    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.

    
    <span class="hljs-keyword">if</span> (AJAX)
    {
        <span class="hljs-meta"><?php</span>
            <span class="hljs-keyword">echo</span> <span class="hljs-string">"AJAX.open("POST", '/timesheets/v2/rapports/FactBCDetail/getDateDebutPeriode.php', true);"</span>;
                
        <span class="hljs-meta">?></span>
        
        AJAX.<span class="hljs-title function_ invoke__">setRequestHeader</span>(<span class="hljs-string">"Content-type"</span>, <span class="hljs-string">"application/x-www-form-urlencoded"</span>);
        AJAX.onreadystatechange = callback_getDateDebutPeriode;
        AJAX.<span class="hljs-title function_ invoke__">send</span>(strPostRequest);
    }
    
    <span class="hljs-keyword">if</span> (AJAX2)
    {
        <span class="hljs-meta"><?php</span>
            <span class="hljs-keyword">echo</span> <span class="hljs-string">"AJAX2.open("POST", '/timesheets/v2/rapports/FactBCDetail/getDateFinPeriode.php', true);"</span>;
        <span class="hljs-meta">?></span>
        AJAX2.<span class="hljs-title function_ invoke__">setRequestHeader</span>(<span class="hljs-string">"Content-type"</span>, <span class="hljs-string">"application/x-www-form-urlencoded"</span>);
        AJAX2.onreadystatechange = callback_getDateFinPeriode;
        AJAX2.<span class="hljs-title function_ invoke__">send</span>(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.

    <!– Easy Reader Version: –>

    [Advertisement]
    Keep the plebs out of prod. Restrict NuGet feed privileges with ProGet. Learn more.

    Source: Read More 

    news
    Facebook Twitter Reddit Email Copy Link
    Previous ArticleHow To Minimize The Environmental Impact Of Your Website
    Next Article Agentic and Generative Commerce Can Elevate CX in B2B

    Related Posts

    Tech & Work

    How To Minimize The Environmental Impact Of Your Website

    September 19, 2025
    Tech & Work

    Progress adds AI coding assistance to Telerik and Kendo UI libraries

    September 19, 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

    CVE-2025-31713 – F5 Networks Engineer Mode Command Injection Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    SEO Poisoning Campaign Targets 8,500+ SMB Users with Malware Disguised as AI Tools

    Development

    CVE-2025-1000 – IBM Db2 Denial of Service due to Improper Automatic Client Rerouting

    Common Vulnerabilities and Exposures (CVEs)

    CVE-2025-49549 – Adobe Commerce Incorrect Authorization Bypass

    Common Vulnerabilities and Exposures (CVEs)

    Highlights

    CVE-2025-5706 – PHPGurukul Human Metapneumovirus Testing Management System SQL Injection Vulnerability

    June 5, 2025

    CVE ID : CVE-2025-5706

    Published : June 6, 2025, 1:15 a.m. | 2 hours, 29 minutes ago

    Description : A vulnerability was found in PHPGurukul Human Metapneumovirus Testing Management System 1.0. It has been declared as critical. Affected by this vulnerability is an unknown functionality of the file /new-user-testing.php. The manipulation of the argument state leads to sql injection. The attack can be launched remotely. The exploit has been disclosed to the public and may be used. Other parameters might be affected as well.

    Severity: 7.3 | HIGH

    Visit the link for more details, such as CVSS details, affected products, timeline, and more…

    Denmark’s Government Ditches Microsoft for Open Source

    June 13, 2025

    DistroWatch Weekly, Issue 1117

    April 13, 2025

    CVE-2025-9425 – iSourcecode Online Tour and Travel Management System SQL Injection Vulnerability

    August 25, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

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