TimeTrex Community Edition v16.2.0

This commit is contained in:
2022-12-13 07:10:06 +01:00
commit 472f000c1b
6810 changed files with 2636142 additions and 0 deletions

View File

@@ -0,0 +1,122 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* HTTP::Download::Archive
*
* PHP versions 4 and 5
*
* @category HTTP
* @package HTTP_Download
* @author Michael Wallner <mike@php.net>
* @copyright 2003-2005 Michael Wallner
* @license BSD, revisewd
* @version CVS: $Id: Archive.php 304423 2010-10-15 13:36:46Z clockwerx $
* @link http://pear.php.net/package/HTTP_Download
*/
/**
* Requires HTTP_Download
*/
require_once 'HTTP/Download.php';
/**
* Requires System
*/
require_once 'System.php';
/**
* HTTP_Download_Archive
*
* Helper class for sending Archives.
*
* @access public
* @version $Revision: 304423 $
*/
class HTTP_Download_Archive
{
/**
* Send a bunch of files or directories as an archive
*
* Example:
* <code>
* require_once 'HTTP/Download/Archive.php';
* HTTP_Download_Archive::send(
* 'myArchive.tgz',
* '/var/ftp/pub/mike',
* HTTP_DOWNLOAD_BZ2,
* '',
* '/var/ftp/pub'
* );
* </code>
*
* @see Archive_Tar::createModify()
* @static
* @access public
* @return mixed Returns true on success or PEAR_Error on failure.
* @param string $name name the sent archive should have
* @param mixed $files files/directories
* @param string $type archive type
* @param string $add_path path that should be prepended to the files
* @param string $strip_path path that should be stripped from the files
*/
function send($name, $files, $type = HTTP_DOWNLOAD_TGZ, $add_path = '', $strip_path = '')
{
$tmp = System::mktemp();
switch ($type = strToUpper($type))
{
case HTTP_DOWNLOAD_TAR:
include_once 'Archive/Tar.php';
$arc = new Archive_Tar($tmp);
$content_type = 'x-tar';
break;
case HTTP_DOWNLOAD_TGZ:
include_once 'Archive/Tar.php';
$arc = new Archive_Tar($tmp, 'gz');
$content_type = 'x-gzip';
break;
case HTTP_DOWNLOAD_BZ2:
include_once 'Archive/Tar.php';
$arc = new Archive_Tar($tmp, 'bz2');
$content_type = 'x-bzip2';
break;
case HTTP_DOWNLOAD_ZIP:
include_once 'Archive/Zip.php';
$arc = new Archive_Zip($tmp);
$content_type = 'x-zip';
break;
default:
return PEAR::raiseError(
'Archive type not supported: ' . $type,
HTTP_DOWNLOAD_E_INVALID_ARCHIVE_TYPE
);
}
if ($type == HTTP_DOWNLOAD_ZIP) {
$options = array( 'add_path' => $add_path,
'remove_path' => $strip_path);
if (!$arc->create($files, $options)) {
return PEAR::raiseError('Archive creation failed.');
}
} else {
if (!$e = $arc->createModify($files, $add_path, $strip_path)) {
return PEAR::raiseError('Archive creation failed.');
}
if (PEAR::isError($e)) {
return $e;
}
}
unset($arc);
$dl = new HTTP_Download(array('file' => $tmp));
$dl->setContentType('application/' . $content_type);
$dl->setContentDisposition(HTTP_DOWNLOAD_ATTACHMENT, $name);
return $dl->send();
}
}
?>

View File

@@ -0,0 +1,177 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* HTTP::Download::PgLOB
*
* PHP versions 4 and 5
*
* @category HTTP
* @package HTTP_Download
* @author Michael Wallner <mike@php.net>
* @copyright 2003-2005 Michael Wallner
* @license BSD, revised
* @version CVS: $Id: PgLOB.php 304423 2010-10-15 13:36:46Z clockwerx $
* @link http://pear.php.net/package/HTTP_Download
*/
$GLOBALS['_HTTP_Download_PgLOB_Connection'] = null;
stream_register_wrapper('pglob', 'HTTP_Download_PgLOB');
/**
* PgSQL large object stream interface for HTTP_Download
*
* Usage:
* <code>
* require_once 'HTTP/Download.php';
* require_once 'HTTP/Download/PgLOB.php';
* $db = &DB::connect('pgsql://user:pass@host/db');
* // or $db = pg_connect(...);
* $lo = HTTP_Download_PgLOB::open($db, 12345);
* $dl = &new HTTP_Download;
* $dl->setResource($lo);
* $dl->send()
* </code>
*
* @access public
* @version $Revision: 304423 $
*/
class HTTP_Download_PgLOB
{
/**
* Set Connection
*
* @static
* @access public
* @return bool
* @param mixed $conn
*/
function setConnection($conn)
{
if (is_a($conn, 'DB_Common')) {
$conn = $conn->dbh;
} elseif ( is_a($conn, 'MDB_Common') ||
is_a($conn, 'MDB2_Driver_Common')) {
$conn = $conn->connection;
}
if ($isResource = is_resource($conn)) {
$GLOBALS['_HTTP_Download_PgLOB_Connection'] = $conn;
}
return $isResource;
}
/**
* Get Connection
*
* @static
* @access public
* @return resource
*/
function getConnection()
{
if (is_resource($GLOBALS['_HTTP_Download_PgLOB_Connection'])) {
return $GLOBALS['_HTTP_Download_PgLOB_Connection'];
}
return null;
}
/**
* Open
*
* @static
* @access public
* @return resource
* @param mixed $conn
* @param int $loid
* @param string $mode
*/
function open($conn, $loid, $mode = 'rb')
{
HTTP_Download_PgLOB::setConnection($conn);
return fopen('pglob:///'. $loid, $mode);
}
/**#@+
* Stream Interface Implementation
* @internal
*/
var $ID = 0;
var $size = 0;
var $conn = null;
var $handle = null;
function stream_open($path, $mode)
{
if (!$this->conn = HTTP_Download_PgLOB::getConnection()) {
return false;
}
if (!preg_match('/(\d+)/', $path, $matches)) {
return false;
}
$this->ID = $matches[1];
if (!pg_query($this->conn, 'BEGIN')) {
return false;
}
$this->handle = pg_lo_open($this->conn, $this->ID, $mode);
if (!is_resource($this->handle)) {
return false;
}
// fetch size of lob
pg_lo_seek($this->handle, 0, PGSQL_SEEK_END);
$this->size = (int) pg_lo_tell($this->handle);
pg_lo_seek($this->handle, 0, PGSQL_SEEK_SET);
return true;
}
function stream_read($length)
{
return pg_lo_read($this->handle, $length);
}
function stream_seek($offset, $whence = SEEK_SET)
{
return pg_lo_seek($this->handle, $offset, $whence);
}
function stream_tell()
{
return pg_lo_tell($this->handle);
}
function stream_eof()
{
return pg_lo_tell($this->handle) >= $this->size;
}
function stream_flush()
{
return true;
}
function stream_stat()
{
return array('size' => $this->size, 'ino' => $this->ID);
}
function stream_write($data)
{
return pg_lo_write($this->handle, $data);
}
function stream_close()
{
if (pg_lo_close($this->handle)) {
return pg_query($this->conn, 'COMMIT');
} else {
pg_query($this->conn ,'ROLLBACK');
return false;
}
}
/**#@-*/
}
?>