corz distro machine
- Stand-alone mode
- As a backend download engine
- Embedded menus on-the-fly
- The php source viewer
- Back-end source highlighting
- Stats, counters and admin
- Frequently asked questions
Stand-alone mode..corz distro machine was primarily designed to be self-contained automatic distribution system. Drop any files you wish to distribute into the "download" folder, simple. If you have any source files or scripts you wish to allow users to view, pop those into the "source" folder the same way.
If you don't need the source facility, simply disable it..
$machine['show_source_menu'] = false;
Drop the whole "machine" folder into your web site and rename to whatever you like. let's say you called it "goodies", and dropped it in the root of your site, navigating to..
..will bring up either the default download menu, or the source viewing menu, depending on how you set your preferences.
Users can easily switch between the "download" and "source" menus and download zips of source files from the source viewer page. All downloads are counted and totals stored in a simple flat-file database. This database is very secure.
There is also a hidden ".htaccess" file inside the "download" folder, preventing direct access to its contents, and not in the ordinary 403 DENIED way; instead when a user attempts to load that directory, or any file inside it, they will be redirected back to the main menu page. neat, check it out. You can set this up however you like.
* there is also a "docs" folder with readme's, extra css, special offers and stuff, but you don't need this to run the machine. the distribution also contains sample php source and zip files. Have fun!
As a backend download engine..corz distro machine can provide backend download and counter services for your web site.. Instead of providing direct links to the files, you send them to the distro machine! Like this..
<a href="/goodies/index.php?download=some_file.zip">some file</a>
Drop some_file.zip into your "download" folder and it's ready to go! the distro machine will handle the download and count it for you transparently.
You could easily move the machine into your root, and perhaps rename index.php to "download.php" or something like that. don't forget the invisible .ht files!
In that case, the links would then be..
<a href="/download.php?download=some_file.zip">some file</a>
Bright sparks will have figured out that this also allows you to have your downloads embedded in other web site's pages, providing a means to easily syndicate your content. All they need to do is add one valid URL..
<a href="http://mysite/download.php?download=some_file.zip">some file</a>
Of course, this may be something you want to prevent, and there are numerous ways to do this, including strict hot-linking preferences. Do read through the preferences.
Embedded menus on-the-fly..corz distro machine can create embedded download menus for your pages, too. simply pass "
&clean=true" in your url, and the distro machine will return the menu of your choice, stripped of all headers, footers and jump links, like this..
<?php include 'http://'. $_SERVER['HTTP_HOST'] .'/engine?download=menu§ion=php/newsfeed%20scripts&clean=true'; ?>
Or even (*eew*) like this..
<iframe width=400 height=160 src="/beta?download=menu&clean=true"></iframe>
Here's first example from above..
You can slam these anywhere you like, and along with its other roles, the distro machine will happily provide backend menu services for your site. Check out the download page for an extreme example. You can embed source menus this way, too.
NOTE: You can also use
readfile()in much the same way as
special features..You can specify certain parameters in the embedding URL, adding special features..
&titles=trueenable section and sub-section titles
&text=trueshow custom text (from a file)
Here's one with everything switched on..
The source viewer..corz distro machine comes with a built-in source viewer..
Many web servers don't support php source highlighting, and on those that do (you can add support in .htaccess files), you will often find the output truncated, which is frustrating.
Here is a solution which works under all conditions (php4+) and add to it by supporting a wide variety of other script formats; currently php ('.php', '.inc', 'phps'), text (.txt), shell and perl scripts (.sh, .pl), batch (.bat) files, as well as AutoIt, and more. The text highlighting code is ripped from my own textviewer script and can handle most things, though is fairly rudimentary compared to the php highlighting. Nice, though.
Simply drop any scripts you would like to have available for viewing directly into the "source" folder, and they will automagically be available from the source menu. You can enable/disable extensions in the preferences.
the pretty coloured source page..Presenting your source like this is very neat.
Remember, in order for the "download" link at the bottom to work, you will need to have a zip archive in the specified download folder, called "script-filename.zip"
For instance, to allow users to download "rss.php", you would create a zip called "rss.php.zip" (or simply "rss.zip") and drop it in the "download" folder.
Clearly, there's no way to count folks copying-and-pasting source from the source view pages, but if your download links work, they *will* use them!
The source viewing facility is disabled by default; if you want to use it; check the prefs.
Back-end source highlighting serviceThe distro machine can provide back-end source highlighting services for your web site, too. So you can have cool highlighted source code embedded within your pages, like this..
All you do is pass the regular URL, except add "
&clean=true", like this..
Rather than specifying section and file, you might prefer to use the short format, like this..
Either way, the distro machine will return your pretty coloured source with the usual source viewer page header and footer stripped off. neat.
include()to embed machine objects is now deprecated in favour of
include()has the advantage of not leaving extra requests in your web logs, but is more likely to fail on a particular server setup, though if it works on your server, it will work well.
readfile()has the advantage of working no matter what your server configuration happens to be. Your call.
You can use the source highlighting facility for non-php files, too, where it automatically converts your shell/bash/batch/perl/AutoIt/etc. scripts, .nfo files, or just plain old text into html; XHTML or HTML5, rather; which could be handy. I should make it a feature.. Auto-HTMLizing info viewer, or something. Anyway, this is what a regular text file (in this case, one of my readme's) might look like..
It looks like text, but acts like 100% XHTML strict/HTML5. And if you are wondering how on earth the cool "/engine?" links work, check out the faq page, or just dive directly into some mod_rewrite hacking.
Stats, counters and admin..I added a funky stats page so you can get a neat list of your download statistics
There's an (optional) "stats" link at the bottom-right of the menu page, which can (optionally) be hidden. Clicking that will bring up your (optionally) password protected statistics page. you can (optionally) disable this altogether.
You can edit your download scores there, too, handy if you do a few tests and don't want them messing up your statistics, etc. if the stats page is open to the public (no password has been set), editing functions are not available.
This feature was brought to you with the help of the word "optionally"