Posts Tagged ‘vbrowsefile’

vBrowseFile 0.0.08-rc2 first file release

by apoc · februar 28 2009 · leave a comment

Habe gestern das erste testing Release von vBrowseFile veröffentlicht.

Installation(auszug aus der README-Datei):

- install HTTP_Download with pear
    For Debian you could do this with:
        # aptitude install php-pear
        # pear install --alldeps HTTP_Download

- Make sure .htaccess Files are used
    Change VHost setting: "AllowOverride All"

- Download vBroweFile Files to an webroot/vhost-root:
    Download an packaged vbf version.
    - or -
    Checkout the latest SVN version: (will create vbrowsefile/ directory)
    $ svn co svn://mount.at/geekosphere/vbrowsefile/trunk vbrowsefile/

- Make sure the following Directories are writeable by Webserver:
    /flatfiles
    /flatfiles/cache
    /flatfiles/cache/tracks
    /flatfiles/userquery
    /smarty/templates_c

- Go with your browser to the setup.php script:
    e.g. http://example.com/vbrowsefile/setup.php

- Now you could login, change configuration, add some virtual directories
  and create some normal users

Tagged: , ,

PoC: Real Bandwidth Limiting with PHP

by apoc · februar 21 2009 · leave a comment

vBrowseFile uses a slightly modificated Version of HTTP_Download. HTTP_Download is a Pear-Module to send local Files to Browser:

Provides an interface to easily send hidden files or any arbitrary data to HTTP clients. HTTP_Download can gain its data from variables, files or stream resources.

It features:
- Basic caching capabilities
- Basic throttling mechanism
- On-the-fly gzip-compression
- Ranges (partial downloads and resuming)
- Delivery of on-the-fly generated archives through Archive_Tar and Archive_Zip
- Sending of PgSQL LOBs without the need to read all data in prior to sending

I added a ThrottleCallback functionality to HTTP_Download, a function that is executed after the BufferSize is transferred and the ThrottleDelay Time is waited. Modifications in HTTP/Download.php:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
    var $throttleCallback = null;
    [...]
    function setThrottleCallback($callback)
    {
        $this->throttleCallback = $callback;
    }
    [...]
    function callThrottleCallback()
    {
        // execute callback
        if($this->throttleCallback != null)
        {
            $callback = $this->throttleCallback;
            $callback($this);
        }
    }
    [...]
    function sendChunk($chunk, $cType = null, $bound = null)
    {
    [...]
        // right after sleep is ex
        $this->callThrottleCallback();
    [...]
    }

This Callback could be used to track the download progress and to create a real bandwidth limitation. HTTP_Download supports a basic throttling mechanism to limit the bandwidth, but this only works for one connection, so e.g. you could limit 2 downloads to each 100 KiB/s but not all 2 downloads to each 50 KiB/s to limit the overall bandwidth to 100 KiB/s, instead it would be 200 KiB/s.
For this real bandwidth limiting you could use Apache modules like cband(seems not to work with php) or mod-bw, or you could use tc. Siyb from Geekosphere wrote an article about mod-bw: Limit Bandwidth per vHost in Apache2 (on Debian/Lenny)

Another possible way to limit the bandwidth is to implement it with HTTP_Download. The Theory is, to track all running downloads and change the BufferSize to := download limit * delay / active connections every seconds with the callback function from above.

More detailed:

  • We generate a random connection id(i call it rcid) for the tracking file.
  • ThrottleDelay is set to 1 seconds.
  • BufferSize is set to 100 KiB * 1 Seconds * 1024 to setup a maximum speed of 100KiB/s.
  • The Callback would now be executed every 1 Seconds:
    • create or overwrite our own rcid file with time() inside.
    • search for other rcid files and check there time-stamp. tracking files older then 5 seconds would be deleted.
    • count all rcid tracking files. e.g. 2 means there 2 open download connections.
    • change the BufferSize. e.g. for 2 open connections: (100 KiB * 1 Seconds * 1024) / 2

This would limit the overall bandwidth of all active connections to a maximum of 100 KiB/s with a delay of ~ <5 Seconds. Without any Apache Modules or other standalone traffic sharping tools. For small installations this should work with no problem but for bigger installations a more efficient traffic shaping tool would be more effective.

Example Implementation: Read the rest of this entry »

Tagged: , , ,

vBrowseFile: development

by apoc · januar 27 2009 · one comment

vbrowsefile0005-devscr1vbrowsefile0005-devscr2vbrowsefile0005-devscr3
vbrowsefile0005-devscr4vbrowsefile0005-devscr5vbrowsefile0005-devscr6

Ich bin gerade dabei einen kleinen “Filebrowser” zu entwickeln. Dieser zeigt nicht zwangsläufig das reale Dateisystem an, sondern ist in der Lage mehrere real existierende Ordner zu einem virtuellen Ordner zusammen zu legen. Er ist nur zum einfachen herunterladen von Dateien gedacht, eine Upload-Funktion ist nicht geplant, eben sowenig wie das Umbenennen oder Löschen von Dateien. Zum Einsatz kommt PHP5, Smarty und das Pear-Paket HTML_Downloader.

siyb von Geekosphere(danke nochmal!) hat mir ein Redmine und Subversion eingerichtet.

Alles weitere wird es dann dort geben.

For our english speaking visitors:

Recently i began to develop a small Filebrowser. It does not necessarily show the real Filesystem but it can combine several directories to one virtual. The purpose is just to realise an easy way of downloading files, other features used in a common filemanager like the renaming or deleting of files are not planned. I use PHP5, Smarty and the Pear-Package HTTP_Download.

Thanks to siyb, now i can provide more informations at geekosphere wootcenter(redmine).

Tagged: , ,