Coder Social home page Coder Social logo

simulatesendfile's Introduction

What is it?

A simple class to fetch mod_xsendfile-headers and provide a alternative with symlinks without big modifying you software.

What does it do?

Put simply: There is a rewrite method that looks for the Sendfile-headers, creates a symlink and forwards to the symlink instead of sending the Sendfile-headers. It will be registered as shutdown-function. So it is called right before giving control back to the webserver.

Requirements

Tested with PHP 7.0 and Apache 2.4 on Linux. It should work on PHP 5.3+ but is not tested. Development started on PHP 7.0, Apache 2.4 and Windows 10. So maybe that could also work. But there were a lot of changes betweet start and now. And of course: You need the permission to use the symlink() function.

Usage

Sample code here. Just add it to the beginning of your script (or before exiting the script) and change it to your requirements.

require('xsendfile.class.php');
use mulu\xsendfile;
// set directory for symlinks
if (xsendfile::setLinkDir(__DIR__ . '/symlink/'))
{
	xsendfile::setLinkDirUri('http://localhost/stest/symlink/'); // web path to symlink-dir
	xsendfile::setExpireTime(3600); // symlinks expire in 1h
	xsendfile::register(); // register as shutdown function
	xsendfile::runGBC(); // run the gbc
}`
[...]
// Send file via X-Sendfile here

Other

There is also a wordpress-plugin available tested with Wordpress 4.7.3 and WooCommerce 3. https://github.com/muellerlukas/simulatesendfile_wordpress

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.