2
0
mirror of https://github.com/ACSPRI/queXS synced 2024-04-02 12:12:16 +00:00

Import from DCARF SVN

This commit is contained in:
azammitdcarf
2008-10-15 22:36:05 +00:00
parent 4f0b4f0bbb
commit 1445da495b
2237 changed files with 714445 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
<?php
require_once 'HTML/AJAX/Serializer/JSON.php';
// $Id
/**
* Error Serializer, for now just uses JSON
*
* @category HTML
* @package AJAX
* @author Joshua Eichorn <josh@bluga.net>
* @copyright 2005 Joshua Eichorn
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version Release: 0.5.2
* @link http://pear.php.net/package/HTML_AJAX
*/
class HTML_AJAX_Serializer_Error extends HTML_AJAX_Serializer_JSON
{
}
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
?>

View File

@@ -0,0 +1,96 @@
<?php
require_once 'HTML/AJAX/JSON.php';
// $Id$
/**
* JSON Serializer
*
* @category HTML
* @package AJAX
* @author Joshua Eichorn <josh@bluga.net>
* @copyright 2005 Joshua Eichorn
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version Release: 0.5.2
* @link http://pear.php.net/package/PackageName
*/
// {{{ class HTMLA_AJAX_Serialize_JSON
class HTML_AJAX_Serializer_JSON
{
// {{{ variables-properties
/**
* JSON instance
* @var HTML_AJAX_JSON
* @access private
*/
var $_json;
/**
* use json php extension http://www.aurore.net/projects/php-json/
* @access private
*/
var $_jsonext;
/**
* use loose typing to decode js objects into php associative arrays
* @access public
*/
var $loose_type;
// }}}
// {{{ constructor
function HTML_AJAX_Serializer_JSON($use_loose_type = true)
{
$this->loose_type = (bool) $use_loose_type;
$this->_jsonext = $this->_detect();
if(!$this->_jsonext) {
$use_loose_type = ($this->loose_type) ? SERVICES_JSON_LOOSE_TYPE : 0;
$this->_json = new HTML_AJAX_JSON($use_loose_type);
}
}
// }}}
// {{{ serialize
/**
* This function serializes and input passed to it.
*
* @access public
* @param string $input The input to serialize.
* @return string $input The serialized input.
*/
function serialize($input)
{
if($this->_jsonext) {
return json_encode($input);
} else {
return $this->_json->encode($input);
}
}
// }}}
// {{{ unserialize
/**
* this function unserializes the input passed to it.
*
* @access public
* @param string $input The input to unserialize
* @return string $input The unserialized input.
*/
function unserialize($input)
{
if($this->_jsonext) {
return json_decode($input, $this->loose_type);
} else {
return $this->_json->decode($input);
}
}
// }}}
// {{{ _detect
/**
* detects the loaded extension
*/
function _detect()
{
return extension_loaded('json');
}
// }}}
}
// }}}
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
?>

View File

@@ -0,0 +1,28 @@
<?php
// $Id$
/**
* Null Serializer
*
* @category HTML
* @package AJAX
* @author Joshua Eichorn <josh@bluga.net>
* @copyright 2005 Joshua Eichorn
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version Release: 0.5.2
* @link http://pear.php.net/package/PackageName
*/
class HTML_AJAX_Serializer_Null
{
function serialize($input)
{
return $input;
}
function unserialize($input)
{
return $input;
}
}
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
?>

View File

@@ -0,0 +1,88 @@
<?php
// $Id$
/**
* PHP Serializer
*
* @category HTML
* @package AJAX
* @author Arpad Ray <arpad@php.net>
* @copyright 2005 Arpad Ray
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version Release: 0.5.2
* @link http://pear.php.net/package/HTML_AJAX
*/
class HTML_AJAX_Serializer_PHP
{
function serialize($input)
{
return serialize($input);
}
/**
* Unserializes the given string
*
* Triggers an error if a class is found which is not
* in the provided array of allowed class names.
*
* @param string $input
* the serialized string to process
* @param array $allowedClasses
* an array of class names to check objects against
* before instantion
* @return mixed
* the unserialized variable on success, or false on
* failure. If this method fails it will also trigger
* a warning.
*/
function unserialize($input, $allowedClasses)
{
if (version_compare(PHP_VERSION, '4.3.10', '<')
|| (substr(PHP_VERSION, 0, 1) == '5' && version_compare(PHP_VERSION, '5.0.3', '<'))) {
trigger_error('Unsafe version of PHP for native unserialization');
return false;
}
$classes = $this->_getSerializedClassNames($input);
if ($classes === false) {
trigger_error('Invalidly serialized string');
return false;
}
$diff = array_diff($classes, $allowedClasses);
if (!empty($diff)) {
trigger_error('Class(es) not allowed to be serialized');
return false;
}
return unserialize($input);
}
/**
* Extract class names from serialized string
*
* Adapted from code by Harry Fuecks
*
* @param string $string
* the serialized string to process
* @return mixed
* an array of class names found, or false if the input
* is invalidly formed
*/
function _getSerializedClassNames($string) {
// Strip any string representations (which might contain object syntax)
while (($pos = strpos($string, 's:')) !== false) {
$pos2 = strpos($string, ':', $pos + 2);
if ($pos2 === false) {
// invalidly serialized string
return false;
}
$end = $pos + 2 + substr($string, $pos + 2, $pos2) + 1;
$string = substr($string, 0, $pos) . substr($string, $end);
}
// Pull out the class names
preg_match_all('/O:[0-9]+:"(.*)"/U', $string, $matches);
// Make sure names are unique (same object serialized twice)
return array_unique($matches[1]);
}
}
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
?>

View File

@@ -0,0 +1,67 @@
<?php
// $Id$
// {{{ http_build_query
/**
* Replacement for http_build_query()
*
* @link http://php.net/function.http-build-query
* @author vlad_mustafin@ukr.net
* @author Arpad Ray <arpad@php.net>
*/
if (!function_exists('http_build_query')) {
function http_build_query($formdata, $numeric_prefix = null, $key = null)
{
$res = array();
foreach ((array)$formdata as $k => $v) {
if (is_resource($v)) {
return null;
}
$tmp_key = urlencode(is_int($k) ? $numeric_prefix . $k : $k);
if (!is_null($key)) {
$tmp_key = $key . '[' . $tmp_key . ']';
}
$res[] = (is_scalar($v))
? $tmp_key . '=' . urlencode($v)
: http_build_query($v, null , $tmp_key);
}
$separator = ini_get('arg_separator.output');
if (strlen($separator) == 0) {
$separator = '&';
}
return implode($separator, $res);
}
}
// }}}
// {{{ class HTML_AJAX_Serialize_Urlencoded
/**
* URL Encoding Serializer
*
* @category HTML
* @package AJAX
* @author Arpad Ray <arpad@php.net>
* @author David Coallier <davidc@php.net>
* @copyright 2005 Arpad Ray
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version Release: 0.5.2
* @link http://pear.php.net/package/HTML_AJAX
*/
class HTML_AJAX_Serializer_Urlencoded
{
// {{{ serialize
function serialize($input)
{
return http_build_query(array('_HTML_AJAX' => $input));
}
// }}}
// {{{ unserialize
function unserialize($input)
{
parse_str($input, $ret);
return (isset($ret['_HTML_AJAX']) ? $ret['_HTML_AJAX'] : $ret);
}
// }}}
}
// }}}
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
?>

View File

@@ -0,0 +1,88 @@
<?php
// $Id: XML.php 583 2007-03-05 22:13:30Z jeichorn $
/**
* XML Serializer - does NOT need a js serializer, use responseXML property in XmlHttpRequest
*
* @category HTML
* @package AJAX
* @author Elizabeth Smith <auroraeosrose@gmail.com>
* @copyright 2005-2006 Elizabeth Smith
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version Release: 0.5.2
* @link http://pear.php.net/package/PackageName
*/
class HTML_AJAX_Serializer_XML
{
/**
* Serializes a domdocument into an xml string
*
* Uses dom or domxml to dump a string from a DomDocument instance
* remember dom is always the default and this will die horribly without
* a domdocument instance
*
* @access public
* @param object $input instanceof DomDocument
* @return string xml string of DomDocument
*/
function serialize($input)
{
if(empty($input))
{
return $input;
}
// we check for the dom extension
elseif (extension_loaded('Dom'))
{
return $input->saveXml();
}
// then will check for domxml
elseif (extension_loaded('Domxml'))
{
return $input->dump_mem();
}
// will throw an error
else {
$error = new HTML_AJAX_Serializer_Error();
$this->serializerNewType = 'Error';
return $error->serialize(array('errStr'=>"Missing PHP Dom extension direct XML won't work"));
}
}
/**
* Unserializes the xml string sent from the document
*
* Uses dom or domxml to pump a string into a DomDocument instance
* remember dom is always the default and this will die horribly without
* one or the other, and will throw warnings if you have bad xml
*
* @access public
* @param string $input The input to serialize.
* @return object instanceofDomDocument
*/
function unserialize($input)
{
if(empty($input))
{
return $input;
}
// we check for the dom extension
elseif (extension_loaded('Dom'))
{
$doc = new DOMDocument();
$doc->loadXML($input);
return $doc;
}
// then we check for the domxml extensions
elseif (extension_loaded('Domxml'))
{
return domxml_open_mem($input);
}
// we give up and just return the xml directly
else
{
return $input;
}
}
}
?>