function log_write($data, FileDownload $file, IDownloader $downloader) { $cache = Environment::getCache("FileDownloader/log"); $log = array(); $tid = (string) $file->getTransferId(); if (!isset($cache["registry"])) { $cache["registry"] = array(); } $reg = $cache["registry"]; $reg[$tid] = true; $cache["registry"] = $reg; if (isset($cache[$tid])) { $log = $cache[$tid]; } Debugger::fireLog("Data: " . $data . "; " . $downloader->end); $data = $data . ": " . Helpers::bytes($file->transferredBytes) . " <->; "; if ($downloader instanceof AdvancedDownloader and $downloader->isInitialized()) { $data .= "position: " . Helpers::bytes($downloader->position) . "; "; //$data .= "length: ".Helpers::bytes($downloader->length)."; "; $data .= "http-range: " . Helpers::bytes($downloader->start) . "-" . Helpers::bytes($downloader->end) . "; "; $data .= "progress (con: " . round($file->transferredBytes / $downloader->end * 100) . "% X "; $data .= "file: " . round($downloader->position / $file->sourceFileSize * 100) . "%)"; } $log[] = $data; $cache[$tid] = $log; }
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @author Jan Kuchař * @copyright Copyright (c) 2009 Jan Kuchař (http://mujserver.net) * @license New BSD License * @link http://filedownloader.projekty.mujserver.net * @version $Id$ */ define("APP_DIR", dirname(__FILE__)); require_once "../load.php"; use FileDownloader\FDTools; use FileDownloader\FileDownload; /* Interface with getters and setters */ $file = new FileDownload(); $file->sourceFile = "source.txt"; $file->speedLimit = 5 * FDTools::BYTE; //$file->transferFileName = "test.txt"; //$file->mimeType = "plain/text"; // Callbacks //$file->onBeforeDownloaderStarts[] = "onBeforeDownloaderStarts"; //$file->onBeforeOutputStarts[] = "onBeforeOutputStarts"; //$file->onStatusChange[] = "onStatusChange"; //$file->onComplete[] = "onComplete"; //$file->onConnectionLost[] = "onConnectionLost"; //$file->onAbort[] = "onAbort"; //$file->onTransferContinue[] = "onTransferContinue"; //$file->onNewTransferStart[] = "onNewTransferStart"; // Start download $file->download();
* copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * Neither the name of the Mujserver.net nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @author Jan Kuchař * @copyright Copyright (c) 2009 Jan Kuchař (http://mujserver.net) * @license New BSD License * @link http://filedownloader.projekty.mujserver.net * @version $Id$ */ define("APP_DIR", dirname(__FILE__)); require_once "../load.php"; // Loads nette use FileDownloader\FileDownload; FileDownload::getInstance()->setSourceFile("FileDownloader.png")->setContentDisposition(FileDownload::CONTENT_DISPOSITION_INLINE)->download();
* copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * Neither the name of the Mujserver.net nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @author Jan Kuchař * @copyright Copyright (c) 2009 Jan Kuchař (http://mujserver.net) * @license New BSD License * @link http://filedownloader.projekty.mujserver.net * @version $Id$ */ define("APP_DIR", dirname(__FILE__)); require_once "../load.php"; use FileDownloader\FDTools; use FileDownloader\FileDownload; FileDownload::getInstance()->setSourceFile("source.txt")->setSpeedLimit(15 * FDTools::BYTE)->download();
* copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * Neither the name of the Mujserver.net nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @author Jan Kuchař * @copyright Copyright (c) 2009 Jan Kuchař (http://mujserver.net) * @license New BSD License * @link http://filedownloader.projekty.mujserver.net * @version $Id$ */ define("APP_DIR", dirname(__FILE__)); require_once "../load.php"; // Loads nette use FileDownloader\FileDownload; FileDownload::getInstance()->setSourceFile("source.txt")->download();