Knowledge Base
Shopping Cart Software Online Manual
Using the mm_fileserver.php Helper File
Upload Digital Object Files via SFTP
Location Home > Shopping Cart Software Components > Administration Area > Modules > Digital Delivery > FAQs & Tutorials

Using the mm_fileserver.php Helper File

This article will demonstrate how to sell downloads while reducing bandwidth usage and prevent the file's source URL from being displayed.
The problem: Using too much bandwidth...
If you sell downloads, bandwidth consumption is a major concern. Every time a file is downloaded from a website, bandwidth is used to transfer the file data from the server to the user. Downloading a ten megabyte file will use ten megabytes of bandwidth — so if you're selling downloadable movies, or other large media files, the bandwidth adds up fast!  

  One of the advanced features of Modular Merchant's digital delivery system is that the files being sold aren't required to be hosted by Modular Merchant — they can be hosted anywhere.

For example, I can have my shopping cart and website hosted by Modular Merchant, but my hundreds of gigabytes of downloads hosted with a different host that specialized in file hosting with oodles of bandwidth for downloads. So, having my shopping cart hosted by Modular Merchant and my files downloaded from "Bulk File Hosting, Inc." solves the problem of bandwidth consumption, right?

No. Actually, this only solves half the problem.

The shopping cart software's digital delivery system is designed to prevent the downloaded file's source URL from being displayed. In order to do this, downloads hosted on a remote server must pass through the store. Thus, to the customer, the file is seen as coming from the store's download area — no matter where it is actually hosted.

The downside of this anti-piracy security mechanism is that, by streaming the file back through the shopping cart server, bandwidth is used on that server too when files are downloaded. So, we're right back where we started: even though our files are hosted on a remote server, downloads are still consuming bandwidth on the store server.

Fortunately, a very simple solution is available.
The solution: Modular Merchant's mm_fileserver.php "Helper File"...

  Modular Merchant provides a "helper file", titled "mm_fileserver.php", that you can upload to all the directories on a remote server that hosts your downloads. By simply uploading this file to the directories that contain your downloads, downloads will stop using your store's bandwidth! This "mm_fileserver.php" file can be used on any server, whether it is a Modular Merchant server or not.

The mm_fileserver.php file contains a mini version of the software used by the store for downloading files while preventing the file's URL from being displayed. When the shopping cart connects to a remote server, the first thing it does is check for the presence of an mm_fileserver.php file in the directory containing the file to be downloaded.

If an mm_fileserver.php file is found, then the store passes the download duties over to the mm_fileserver.php file, allowing it to complete the download process itself. This means that the remote server is able to perform the download without streaming the file back through the shopping cart server, thus removing the shopping cart from the download chain and not using any of the shopping cart server's bandwidth!

By simply uploading the mm_fileserver.php file to the directory that includes my downloads, I've cut my bandwidth consumption in half. Now, all of the bandwidth consumed by the downloads I sell comes only from the "Bulk File Hosting, Inc." file server.
Download the mm_fileserver.php Helper File...

  Where can I download it?
A zip file containing the "mm_fileserver.php" file can be downloaded here. Several versions are available:

Modular Merchant version 4.x
Servers running PHP 5.2.x (File updated on 10/24/2010)
Servers running PHP 5.3.x (File updated on 10/24/2010)

Modular Merchant version 3.x
Servers running PHP 5.2.x (File updated on 11/08/2010)
Servers running PHP 5.3.x (File updated on 11/08/2010)

system requirements
System Requirements for the "mm_fileserver.php" file:
In order to take advantage of the "mm_fileserver.php" file, the third-party server must meet the following system requirements:

1. You must be subscribed to the Modular Merchant Gold account plan or higher. (Remotely hosted downloads are not supported by the Bronze or Silver account plans.)

2. The server must be able to run PHP files.

3. The server must have Zend Optimizer/Guard installed. (It's free.)

4. The file server must provide static (not dynamic) URLs for the files.
For example: is compatible, but may not be.

5. Upload the "mm_fileserver.php" file in binary file format, not ASCII.

6. The "mm_fileserver.php" file must be placed in the same directory as the files to be downloaded. If you have multiple directories on your server containing downloads, upload a copy of the "mm_fileserver.php" file to each one of those directories.

a note about password protected directories
Password protected directories
For the Bandwidth Conscious:
Note that if the directory containing the downloads is password protected, then resources on the shopping cart server will still be needed in order to securely download the files, which will require store bandwidth to be used. This is because files housed within a password protected directory must be accessed and distributed in a different way by the store's digital delivery system in order to remain secure.

More info on password protected directories is available in this forum article:
Testing the mm_fileserver.php installation...

After the mm_fileserver.php file has been uploaded to the directory containing your downloads, testing it to make sure it is installed correctly is easy. To test it, simply enter its URL in a web browser.

If the mm_fileserver.php file is present, and the server meets the system requirements, the following message will be displayed:

mm_fileserver.php output:
Modular Merchant v3 mm_fileserver.php Helper File.
If you can read this message, then it means that this server:
1. Can parse PHP files
2. Has Zend Optimizer installed and configured correctly

If you see that message when viewing the mm_fileserver.php file in a web browser, then it is installed and ready to use!
Troubleshooting common problems...

This section lists some common problems that may be encountered during the initial installation and configuration of an mm_fileserver.php file on a third-party web server:

Problem: A "404 - Page Not Found" message is displayed when viewing the mm_fileserver.php file.

Solution: The mm_fileserver.php file is not present in the website directory. Check the location directory structure on the web server, and upload the mm_fileserver.php file to each of the directories that contain files to be downloaded.

Problem: The message "Fatal error: Unable to read 12345 bytes in /path/to/the/file/mm_fileserver.php on line 0" is displayed when viewing the mm_fileserver.php file.

Solution: The mm_fileserver.php file was not uploaded in binary file format. (It was likely uploaded in "ASCII" or "plain text" file format.) Check the settings of the FTP program you're using and upload the mm_fileserver.php file again, making sure it is uploaded in binary file format.

Problem: A message like "You have attempted to execute a CGI, ISAPI, or other executable program from a directory that does not allow programs to be executed" is displayed when viewing the mm_fileserver.php file

Solution: The mm_fileserver.php file is present, but does not have permission to run. Check the permisison settings of mm_fileserver.php file on the server, making sure it has the correct read/write/execute permission settings.

Problem: The message "Error message: Zend optimizer not installed" is displayed when viewing the mm_fileserver.php file.

Solution: The Zend engine is either not installed, out of date, or not configured correctly on the server. Contact the server facility to have Zend installed or updated.

Problem: Instead of the expected file, a 0 Kb "mm_fileserver.html" file is downloaded.

Solution: The most common cause of this problem is spaces in the name of the download file. (Example: "my file to") Many servers and web browsers have trouble working with files with spaces in the name. The solution is to change the spaces in the file name to underscores. (Example: "")

Problem: My download stops midway during the download process.

Solution: This is typically encountered with downloads several hundred megabytes or larger in size. Prematurely ending the download process is usually due to the remote host severing the connection. Some hosts configure their servers to perform "system cleanup" every 30 minutes or so. This cleanup may include closing connections that have been open for a certain period of time. If a download is so large that it requires more time to download than allowed by the system cleanup, the remote server may close the connection before the download has finished.

Problem: My files download correctly from one server, but don't download correctly from another server.

Solution: There's many different ways in which a server can be configured. It is possible that the way a server is configured may make it incompatible with the store's digital delivery system. The setup and config of third-party servers is out of Modular Merchant's control. If a download stops working on a remote server, the first step will be to check with the facility that manages that server.

Problem: All my files larger than a certain size won't download, but smaller files will.

Solution: Check the server to see if PHP is running in "safe mode", and take it out of safe mode if possible. Otherwise, make sure that the server allows scripts to use PHP's set_time_limit() function.

This may also be caused by a bug in certain versions of PHP that affects the way that large files are read off the server. If you suspect this is affecting your files, contact Modular Merchant for an alternative version of the mm_fileserver.php file, which may be able to prevent the download of large files from failing.

Problem: I've confirmed that the mm_fileserver.php file is in place on my server and installed correctly, but downloads are still using my store's bandwidth.

Solution: Check to make sure that the clock on the server that is hosting the mm_fileserver.php file is set correctly. When the mm_fileserver.php file receives the request to download a file, it authenticates the date of the request, to ensure that it is valid. One of these authentications is to check the age of the request. If it is too old, the mm_fileserver.php file will decline it. (This is a security feature to prevent thieves from posting a download link on their website for others to download for free. Such a link would no longer work once it gets too old.) If the clock on the server is running too fast, then the legitimate download requests from the store will be routed back through the store, because the server's inaccurate clock makes the mm_fileserver.php file think that they are old outdated requests.

— Last Edited - 12/9/2014 8:05am PST
Rank and add a comment to this article
Only logged in users may leave comments and rank articles. Log in to have your say!
  Knowledge Base Home

  QuickCode™ Tag Glossary

  Modular Homepage

Not Logged in.
Either Log in or create a User Account.

Other articles in this category...

Attach Multiple Digital Objects to a Product

Create a Digital Library using Digital Products

Create a Digital Product

Create Subscription-Based Digital Libraries

Do I need to rescan my File Storage Area when I EDIT files?

How to password-protect your downloads

Prevent broken content in "webpage" Digital Objects

Protecting Download and Intellectual Property

Send ebooks directly to Kindle/Nook

Upload Digital Object Files via SFTP

Using the mm_fileserver.php Helper File