Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8288673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:19:29+00:00 2026-06-08T12:19:29+00:00

I am very much aware that PHP is a server side language and therefore

  • 0

I am very much aware that PHP is a server side language and therefore should not allow the php file to be downloaded. However, on direct visit in Chrome to the PHP file, it downloads an obfuscated version of the file, something I’d like to prevent. Is there a way to stop the file from being served up?

The code is below.
The system works to perfection inside WordPress, but if I open up Chrome (and I presume others) and visit the update.php file directly, it downloads.

Notably, I tried to echo an HTML page but it messes up the way the system works. I’m hoping there’s some sort of .htaccess trick for this.

if (isset($_POST['action'])) {
  switch ($_POST['action']) {
    case 'version':
      echo '1.1';
      break;
    case 'info':
      $obj = new stdClass();
      $obj->slug = 'plugin.php';
      $obj->plugin_name = 'plugin.php';
      $obj->new_version = '1.1';
      $obj->requires = '3.0';
      $obj->tested = '3.3.1';
      $obj->downloaded = 12540;
      $obj->last_updated = '2012-01-12';
      $obj->sections = array(
        'description' => 'The new version of the Auto-Update plugin',
        'another_section' => 'This is another section',
        'changelog' => 'Some new features'
      );
      $obj->download_link = 'http://localhost/update.php';
      echo serialize($obj);
    case 'license':
      echo 'false';
      break;
  }
} else {
    header('Cache-Control: public');
    header('Content-Description: File Transfer');
    header('Content-Type: application/zip');
    readfile('update.zip');
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T12:19:29+00:00Added an answer on June 8, 2026 at 12:19 pm

    Your code, if it does not receive $_POST['action'], then sends update.zip to the browser in the else case.

    What you are seeing when visit the file not via a POST is not obfuscated PHP. Rather, it is sending the contents of the file update.zip to the browser for download. But since the code doesn’t supply a filename hint in the headers, it doesn’t come as update.zip and instead probably looks like a .php file with the same name as your script.

    If you want update.zip to look like a zip file, add a filename into the Content-Disposition output header:

    header('Cache-Control: public');
    header('Content-Description: File Transfer');
    
    // Change to attachment disposition, with filename
    header('Content-Disposition: attachment; filename=update.zip');
    header('Content-Type: application/zip');
    readfile('update.zip');
    

    Now, if you don’t want it sending update.zip at all, remove the entire else {} block from the bottom, and replace it with something like

    else {
      echo "You must supply an action...";
    }
    

    Update: To restrict access only to referrals by wp_autoupdate.php

    Consult $_SERVER['HTTP_REFERRER'], but know that the value of this can be spoofed. This cannot be used with 100% reliability.

    if (strpos($_SERVER['HTTP_REFERER'], 'wp_autoupdate.php') !== FALSE) {
      // Include all your exsiting code
    }
    else {
      // Don't do anything, or redirect somewhere else
      header("Location: /");
      exit();
    }
    

    To achieve 100% reliability, you would probably need to modify wp_autoupdate.php to set a session variable which is then checked by update.php, ensuring the request came from the right place.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've recently picked up PHP and it seems rather neat language enabling very quick
I'm having a bit of a problem with a very weird side effect that's
Very much related to my previous question , but I found this to be
Would very much appreciate any help or hint on were to go next. I'm
I'm very much a newbie when it comes to all this so forgive my
I get very much confused when it comes to pointers. I want to know
I am very much new to stack overflow so I do apologize if I
I'm very much new to programming and have been doing fairly well so far.
Important : Please see this very much related question: Return multiple values in C++
My question is very much like Getting the return value of a PL/SQL function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.