initial commit

This commit is contained in:
Chris Sewell
2012-11-28 03:55:08 -05:00
parent 7adb399b2e
commit cf140a2e97
3247 changed files with 492437 additions and 0 deletions

62
lib/symfony/vendor/creole/util/Blob.php vendored Executable file
View File

@ -0,0 +1,62 @@
<?php
/*
* $Id: Blob.php,v 1.5 2004/03/20 04:16:50 hlellelid Exp $
*
* 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
* OWNER 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.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information please see
* <http://creole.phpdb.org>.
*/
require_once 'creole/util/Lob.php';
/**
* A class for handling binary LOBs.
*
* @author Hans Lellelid <hans@xmpl.org>
* @version $Revision: 1.5 $
* @package creole.util
*/
class Blob extends Lob {
/**
* Dump the contents of the file using fpassthru().
*
* @return void
* @throws Exception if no file or contents.
*/
function dump()
{
if (!$this->data) {
// hmmm .. must be a file that needs to read in
if ($this->inFile) {
$fp = @fopen($this->inFile, "rb");
if (!$fp) {
throw new Exception('Unable to open file: '.$this->inFile);
}
fpassthru($fp);
@fclose($fp);
} else {
throw new Exception('No data to dump');
}
} else {
echo $this->data;
}
}
}

112
lib/symfony/vendor/creole/util/Clob.php vendored Executable file
View File

@ -0,0 +1,112 @@
<?php
/*
* $Id: Clob.php,v 1.6 2004/07/27 23:15:13 hlellelid Exp $
*
* 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
* OWNER 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.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information please see
* <http://creole.phpdb.org>.
*/
require_once 'creole/util/Lob.php';
/**
* A class for handling character (ASCII) LOBs.
*
* @author Hans Lellelid <hans@xmpl.org>
* @version $Revision: 1.6 $
* @package creole.util
*/
class Clob extends Lob {
/**
* Read LOB data from file.
* @param string $file Filename may also be specified here (if not specified using setInputFile()).
* @return void
* @throws Exception - if no file specified or error on read.
* @see setInputFile()
*/
public function readFromFile($file = null)
{
if ($file !== null) {
$this->setInputFile($file);
}
if (!$this->inFile) {
throw Exception('No file specified for read.');
}
$data = null;
$file = fopen($this->inFile, "rt");
while (!feof($file)) $data .= fgets($file, 4096);
fclose($file);
if ($data === false) {
throw new Exception('Unable to read from file: '.$this->inFile);
}
$this->setContents($data);
}
/**
* Write LOB data to file.
* @param string $file Filename may also be specified here (if not set using setOutputFile()).
* @throws Exception - if no file specified, no contents to write, or error on write.
* @see setOutputFile()
*/
public function writeToFile($file = null)
{
if ($file !== null) {
$this->setOutputFile($file);
}
if (!$this->outFile) {
throw new Exception('No file specified for write');
}
if ($this->data === null) {
throw new Exception('No data to write to file');
}
$file = fopen($this->inFile, "wt");
if (fputs($file, $this->data) === false)
throw new Exception('Unable to write to file: '.$this->outFile);
fclose($file);
}
/**
* Dump the contents of the file using fpassthru().
*
* @return void
* @throws Exception if no file or contents.
*/
function dump()
{
if (!$this->data) {
// is there a file name set?
if ($this->inFile) {
$fp = @fopen($this->inFile, "r");
if (!$fp) {
throw new Exception('Unable to open file: '.$this->inFile);
}
fpassthru($fp);
@fclose($fp);
} else {
throw new Exception('No data to dump');
}
} else {
echo $this->data;
}
}
}

243
lib/symfony/vendor/creole/util/Lob.php vendored Executable file
View File

@ -0,0 +1,243 @@
<?php
/*
* $Id: Lob.php,v 1.10 2004/03/20 04:16:50 hlellelid Exp $
*
* 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
* OWNER 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.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information please see
* <http://creole.phpdb.org>.
*/
/**
* An abstract class for handling LOB (Locator Object) columns.
*
* @author Hans Lellelid <hans@xmpl.org>
* @version $Revision: 1.10 $
* @package creole.util
*/
abstract class Lob {
/**
* The contents of the Lob.
* DO NOT SET DIRECTLY (or you will disrupt the
* ability of isModified() to give accurate results).
* @var string
*/
protected $data;
/**
* File that blob should be written out to.
* @var string
*/
protected $outFile;
/**
* File that blob should be read in from
* @var string
*/
protected $inFile;
/**
* This is a 3-state value indicating whether column has been
* modified.
* Initially it is NULL. Once first call to setContents() is made
* it is FALSE, because this will be initial state of Lob. Once
* a subsequent call to setContents() is made it is TRUE.
* @var boolean
*/
private $modified = null;
/**
* Construct a new Lob.
* @param sttring $data The data contents of the Lob.
* @see setContents()
*/
public function __construct($data = null)
{
if ($data !== null) {
$this->setContents($data);
}
}
/**
* Get the contents of the LOB.
* @return string The characters in this LOB.
* @throws Exception
*/
public function getContents()
{
if ($this->data === null && $this->isFromFile()) {
$this->readFromFile();
}
return $this->data;
}
/**
* Set the contents of this LOB.
* Sets the modified flag to FALSE if this is the first call
* to setContents() for this object. Sets the bit to TRUE if
* this any subsequent call to setContents().
* @param string $bytes
*/
public function setContents($data)
{
$this->data = $data;
if ($this->modified === null) {
// if modified bit hasn't been set yet,
// then it should now be set to FALSE, since
// we just did inital population
$this->modified = false;
} elseif ($this->modified === false) {
// if it was already FALSE, then it should
// now be set to TRUE, since this is a subsequent
// modfiication.
$this->modified = true;
}
}
/**
* Dump the contents of the file to stdout.
* Must be implemented by subclasses so that binary status is handled
* correctly. (i.e. ignored for Clob, handled for Blob)
* @return void
* @throws Exception if no file or contents.
*/
abstract public function dump();
/**
* Specify the file that we want this LOB read from.
* @param string $filePath The location of the file.
* @return void
*/
public function setInputFile($filePath)
{
$this->inFile = $filePath;
}
/**
* Get the file that we want this LOB read from.
* @return string The location of the file.
*/
public function getInputFile()
{
return $this->inFile;
}
/**
* Specify the file that we want this LOB saved to.
* @param string $filePath The location of the file.
* @return void
*/
public function setOutputFile($filePath)
{
$this->outFile = $filePath;
}
/**
* Get the file that we want this LOB saved to.
* @return string $filePath The location of the file.
*/
public function getOutputFile()
{
return $this->outFile;
}
/**
* Returns whether this Lob is loaded from file.
* This is useful for bypassing need to read in the contents of the Lob.
* @return boolean Whether this LOB is to be read from a file.
*/
public function isFromFile()
{
return ($this->inFile !== null);
}
/**
* Read LOB data from file (binary safe).
* (Implementation may need to be moved into Clob / Blob subclasses, but
* since file_get_contents() is binary-safe, it hasn't been necessary so far.)
* @param string $file Filename may also be specified here (if not specified using setInputFile()).
* @return void
* @throws Exception - if no file specified or error on read.
* @see setInputFile()
*/
public function readFromFile($file = null)
{
if ($file !== null) {
$this->setInputFile($file);
}
if (!$this->inFile) {
throw Exception('No file specified for read.');
}
$data = @file_get_contents($this->inFile);
if ($data === false) {
throw new Exception('Unable to read from file: '.$this->inFile);
}
$this->setContents($data);
}
/**
* Write LOB data to file (binary safe).
* (Impl may need to move into subclasses, but so far not necessary.)
* @param string $file Filename may also be specified here (if not set using setOutputFile()).
* @throws Exception - if no file specified, no contents to write, or error on write.
* @see setOutputFile()
*/
public function writeToFile($file = null)
{
if ($file !== null) {
$this->setOutputFile($file);
}
if (!$this->outFile) {
throw new Exception('No file specified for write');
}
if ($this->data === null) {
throw new Exception('No data to write to file');
}
if (false === @file_put_contents($this->outFile, $this->data)) {
throw new Exception('Unable to write to file: '.$this->outFile);
}
}
/**
* Convenience method to get contents of LOB as string.
* @return string
*/
public function __toString()
{
return $this->getContents();
}
/**
* Set whether LOB contents have been modified after initial setting.
* @param boolean $b
*/
public function setModified($b)
{
$this->modified = $b;
}
/**
* Whether LOB contents have been modified after initial setting.
* @return boolean TRUE if the contents have been modified after initial setting.
* FALSE if contents have not been modified or if no contents have bene set.
*/
public function isModified()
{
// cast it so that NULL will also eval to false
return (boolean) $this->modified;
}
}

View File

@ -0,0 +1,164 @@
<?php
/*
* $Id: SQLStatementExtractor.php,v 1.5 2004/07/27 23:13:46 hlellelid Exp $
*
* 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
* OWNER 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.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information please see
* <http://creole.phpdb.org>.
*/
/**
* Static class for extracting SQL statements from a string or file.
*
* @author Hans Lellelid <hans@xmpl.org>
* @version $Revision: 1.5 $
* @package creole.util.sql
*/
class SQLStatementExtractor {
protected static $delimiter = ';';
/**
* Get SQL statements from file.
*
* @param string $filename Path to file to read.
* @return array SQL statements
*/
public static function extractFile($filename) {
$buffer = file_get_contents($filename);
if ($buffer === false) {
throw new Exception("Unable to read file: " . $filename);
}
return self::extractStatements(self::getLines($buffer));
}
/**
* Extract statements from string.
*
* @param string $txt
* @return array
*/
public static function extract($buffer) {
return self::extractStatements(self::getLines($buffer));
}
/**
* Extract SQL statements from array of lines.
*
* @param array $lines Lines of the read-in file.
* @return string
*/
protected static function extractStatements($lines) {
$statements = array();
$sql = "";
foreach($lines as $line) {
$line = trim($line);
if (self::startsWith("//", $line) ||
self::startsWith("--", $line) ||
self::startsWith("#", $line)) {
continue;
}
if (strlen($line) > 4 && strtoupper(substr($line,0, 4)) == "REM ") {
continue;
}
$sql .= " " . $line;
$sql = trim($sql);
// SQL defines "--" as a comment to EOL
// and in Oracle it may contain a hint
// so we cannot just remove it, instead we must end it
if (strpos($line, "--") !== false) {
$sql .= "\n";
}
if (self::endsWith(self::$delimiter, $sql)) {
$statements[] = self::substring($sql, 0, strlen($sql)-1 - strlen(self::$delimiter));
$sql = "";
}
}
return $statements;
}
//
// Some string helper methods
//
/**
* Tests if a string starts with a given string.
* @param string $check The substring to check.
* @param string $string The string to check in (haystack).
* @return boolean True if $string starts with $check, or they are equal, or $check is empty.
*/
protected static function startsWith($check, $string) {
if ($check === "" || $check === $string) {
return true;
} else {
return (strpos($string, $check) === 0) ? true : false;
}
}
/**
* Tests if a string ends with a given string.
* @param string $check The substring to check.
* @param string $string The string to check in (haystack).
* @return boolean True if $string ends with $check, or they are equal, or $check is empty.
*/
protected static function endsWith($check, $string) {
if ($check === "" || $check === $string) {
return true;
} else {
return (strpos(strrev($string), strrev($check)) === 0) ? true : false;
}
}
/**
* a natural way of getting a subtring, php's circular string buffer and strange
* return values suck if you want to program strict as of C or friends
*/
protected static function substring($string, $startpos, $endpos = -1) {
$len = strlen($string);
$endpos = (int) (($endpos === -1) ? $len-1 : $endpos);
if ($startpos > $len-1 || $startpos < 0) {
trigger_error("substring(), Startindex out of bounds must be 0<n<$len", E_USER_ERROR);
}
if ($endpos > $len-1 || $endpos < $startpos) {
trigger_error("substring(), Endindex out of bounds must be $startpos<n<".($len-1), E_USER_ERROR);
}
if ($startpos === $endpos) {
return (string) $string{$startpos};
} else {
$len = $endpos-$startpos;
}
return substr($string, $startpos, $len+1);
}
/**
* Convert string buffer into array of lines.
*
* @param string $filename
* @return array string[] lines of file.
*/
protected static function getLines($buffer) {
$lines = preg_split("/\r?\n|\r/", $buffer);
return $lines;
}
}