This commit is contained in:
@@ -1,77 +0,0 @@
|
||||
<?php
|
||||
|
||||
function debug(&$var, $info = FALSE)
|
||||
{
|
||||
$scope = false;
|
||||
$prefix = 'unique';
|
||||
$suffix = 'value';
|
||||
|
||||
if($scope) $vals = $scope;
|
||||
else $vals = $GLOBALS;
|
||||
|
||||
$old = $var;
|
||||
$var = $new = $prefix.rand().$suffix; $vname = FALSE;
|
||||
foreach($vals as $key => $val) if($val === $new) $vname = $key;
|
||||
$var = $old;
|
||||
|
||||
echo "<pre style='margin: 0px 0px 10px 0px; display: block; background: white; color: black; font-family: Verdana; border: 1px solid #cccccc; padding: 5px; font-size: 10px; line-height: 13px;'>";
|
||||
if($info != FALSE) echo "<b style='color: red;'>$info:</b><br>";
|
||||
do_dump($var, '$'.$vname);
|
||||
echo "</pre>";
|
||||
}
|
||||
|
||||
|
||||
function do_dump(&$var, $var_name = NULL, $indent = NULL, $reference = NULL)
|
||||
{
|
||||
$do_dump_indent = "<span style='color:#eeeeee;'>|</span> ";
|
||||
$reference = $reference.$var_name;
|
||||
$keyvar = 'the_do_dump_recursion_protection_scheme'; $keyname = 'referenced_object_name';
|
||||
|
||||
if (is_array($var) && isset($var[$keyvar]))
|
||||
{
|
||||
$real_var = &$var[$keyvar];
|
||||
$real_name = &$var[$keyname];
|
||||
$type = ucfirst(gettype($real_var));
|
||||
echo "$indent$var_name <span style='color:#a2a2a2'>$type</span> = <span style='color:#e87800;'>&$real_name</span><br>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$var = array($keyvar => $var, $keyname => $reference);
|
||||
$avar = &$var[$keyvar];
|
||||
|
||||
$type = ucfirst(gettype($avar));
|
||||
if($type == "String") $type_color = "<span style='color:green'>";
|
||||
elseif($type == "Integer") $type_color = "<span style='color:red'>";
|
||||
elseif($type == "Double"){ $type_color = "<span style='color:#0099c5'>"; $type = "Float"; }
|
||||
elseif($type == "Boolean") $type_color = "<span style='color:#92008d'>";
|
||||
elseif($type == "NULL") $type_color = "<span style='color:black'>";
|
||||
|
||||
if(is_array($avar))
|
||||
{
|
||||
$count = count($avar);
|
||||
echo "$indent" . ($var_name ? "$var_name => ":"") . "<span style='color:#a2a2a2'>$type ($count)</span><br>$indent(<br>";
|
||||
$keys = array_keys($avar);
|
||||
foreach($keys as $name)
|
||||
{
|
||||
$value = &$avar[$name];
|
||||
do_dump($value, "['$name']", $indent.$do_dump_indent, $reference);
|
||||
}
|
||||
echo "$indent)<br>";
|
||||
}
|
||||
elseif(is_object($avar))
|
||||
{
|
||||
echo "$indent$var_name <span style='color:#a2a2a2'>$type</span><br>$indent(<br>";
|
||||
foreach($avar as $name=>$value) do_dump($value, "$name", $indent.$do_dump_indent, $reference);
|
||||
echo "$indent)<br>";
|
||||
}
|
||||
elseif(is_int($avar)) echo "$indent$var_name = <span style='color:#a2a2a2'>$type(".strlen($avar).")</span> $type_color$avar</span><br>";
|
||||
elseif(is_string($avar)) echo "$indent$var_name = <span style='color:#a2a2a2'>$type(".strlen($avar).")</span> $type_color\"$avar\"</span><br>";
|
||||
elseif(is_float($avar)) echo "$indent$var_name = <span style='color:#a2a2a2'>$type(".strlen($avar).")</span> $type_color$avar</span><br>";
|
||||
elseif(is_bool($avar)) echo "$indent$var_name = <span style='color:#a2a2a2'>$type(".strlen($avar).")</span> $type_color".($avar == 1 ? "TRUE":"FALSE")."</span><br>";
|
||||
elseif(is_null($avar)) echo "$indent$var_name = <span style='color:#a2a2a2'>$type(".strlen($avar).")</span> {$type_color}NULL</span><br>";
|
||||
else echo "$indent$var_name = <span style='color:#a2a2a2'>$type(".strlen($avar).")</span> $avar<br>";
|
||||
|
||||
$var = $var[$keyvar];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
<?php
|
||||
|
||||
function clean_xml($xml)
|
||||
{
|
||||
$xml = str_replace("\\'", "'", $xml);
|
||||
$xml = str_replace("\\\"", "\"", $xml);
|
||||
$xml = str_replace("\\\\", "\\", $xml);
|
||||
$xml = str_replace("\t", "", $xml);
|
||||
$xml = str_replace("\n", "", $xml);
|
||||
$xml = str_replace("\r", "", $xml);
|
||||
$xml = trim($xml);
|
||||
return ($xml);
|
||||
}
|
||||
|
||||
function clean_invalid_char($var)
|
||||
{
|
||||
//supprimes les balises html
|
||||
$var = strip_tags($var);
|
||||
$var = str_replace("&", "&", $var);
|
||||
$var = str_replace("<", "<", $var);
|
||||
$var = str_replace(">", ">", $var);
|
||||
$var = trim($var);
|
||||
return ($var);
|
||||
}
|
||||
|
||||
function var_is_object_of_class($var, $class_name)
|
||||
{
|
||||
$res = false;
|
||||
if (is_object($var))
|
||||
{
|
||||
$name = get_class($var);
|
||||
if ($name == $class_name)
|
||||
{
|
||||
$res = true;
|
||||
}
|
||||
}
|
||||
return ($res);
|
||||
}
|
||||
|
||||
//Calcule la date de livraison en jour ouvré à partir de la date courante
|
||||
function get_delivery_date($delivery_times)
|
||||
{
|
||||
define('H', date("H"));
|
||||
define('i', date("i"));
|
||||
define('s', date("s"));
|
||||
define('m', date("m"));
|
||||
define('d', date("d"));
|
||||
define('Y', date("Y"));
|
||||
define('SUNDAY', 0);
|
||||
define('SATURDAY', 6);
|
||||
|
||||
$nb_days = 0;
|
||||
$j = 0;
|
||||
while ($nb_days < $delivery_times)
|
||||
{
|
||||
$j++;
|
||||
$date = mktime(H, i, s, m, d + $j, Y);
|
||||
$day = date("w", $date);
|
||||
if ($day != SUNDAY && $day != SATURDAY)
|
||||
{
|
||||
$nb_days++;
|
||||
}
|
||||
}
|
||||
if ($j > FIANET_MAX_DELIVERY_TIME)
|
||||
{//si on dépasse le délais de livraison max à causes des samedi et dimanche on remet le délais de livraison à son maximum
|
||||
$j = FIANET_MAX_DELIVERY_TIME;
|
||||
}
|
||||
$date = mktime(H, i, s, m, d + $j, Y);
|
||||
return (date("Y-m-d", $date));
|
||||
}
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* xml2array() will convert the given XML text to an array in the XML structure.
|
||||
* Link: http://www.bin-co.com/php/scripts/xml2array/
|
||||
* Arguments : $contents - The XML text
|
||||
* $get_attributes - 1 or 0. If this is 1 the function will get the attributes as well as the tag values - this results in a different array structure in the return value.
|
||||
* Return: The parsed XML in an array form.
|
||||
*/
|
||||
function xml2array($contents, $get_attributes=1)
|
||||
{
|
||||
if(!$contents) return array();
|
||||
|
||||
if(!function_exists('xml_parser_create'))
|
||||
{
|
||||
//print "'xml_parser_create()' function not found!";
|
||||
return array();
|
||||
}
|
||||
//Get the XML parser of PHP - PHP must have this module for the parser to work
|
||||
$parser = xml_parser_create();
|
||||
xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, 0 );
|
||||
xml_parser_set_option( $parser, XML_OPTION_SKIP_WHITE, 1 );
|
||||
xml_parse_into_struct( $parser, $contents, $xml_values );
|
||||
xml_parser_free( $parser );
|
||||
|
||||
if(!$xml_values) return;//Hmm...
|
||||
|
||||
//Initializations
|
||||
$xml_array = array();
|
||||
$parents = array();
|
||||
$opened_tags = array();
|
||||
$arr = array();
|
||||
|
||||
$current = &$xml_array;
|
||||
|
||||
//Go through the tags.
|
||||
foreach($xml_values as $data)
|
||||
{
|
||||
unset($attributes,$value);//Remove existing values, or there will be trouble
|
||||
//This command will extract these variables into the foreach scope
|
||||
// tag(string), type(string), level(int), attributes(array).
|
||||
extract($data);//We could use the array by itself, but this cooler.
|
||||
|
||||
$result = '';
|
||||
if($get_attributes)
|
||||
{//The second argument of the function decides this.
|
||||
$result = array();
|
||||
if(isset($value)) $result['value'] = $value;
|
||||
//Set the attributes too.
|
||||
if(isset($attributes))
|
||||
{
|
||||
foreach($attributes as $attr => $val)
|
||||
{
|
||||
if($get_attributes == 1) $result['attr'][$attr] = $val; //Set all the attributes in a array called 'attr'
|
||||
/** :TODO: should we change the key name to '_attr'? Someone may use the tagname 'attr'. Same goes for 'value' too */
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif(isset($value))
|
||||
{
|
||||
$result = $value;
|
||||
}
|
||||
|
||||
//See tag status and do the needed.
|
||||
if($type == "open")
|
||||
{//The starting of the tag '<tag>'
|
||||
$parent[$level-1] = &$current;
|
||||
if(!is_array($current) or (!in_array($tag, array_keys($current))))
|
||||
{ //Insert New tag
|
||||
$current[$tag] = $result;
|
||||
$current = &$current[$tag];
|
||||
|
||||
}
|
||||
else
|
||||
{ //There was another element with the same tag name
|
||||
if(isset($current[$tag][0]))
|
||||
{
|
||||
array_push($current[$tag], $result);
|
||||
}
|
||||
else
|
||||
{
|
||||
$current[$tag] = array($current[$tag],$result);
|
||||
}
|
||||
$last = count($current[$tag]) - 1;
|
||||
$current = &$current[$tag][$last];
|
||||
}
|
||||
|
||||
}
|
||||
elseif($type == "complete")
|
||||
{ //Tags that ends in 1 line '<tag />'
|
||||
//See if the key is already taken.
|
||||
if(!isset($current[$tag]))
|
||||
{ //New Key
|
||||
$current[$tag] = $result;
|
||||
//array_push($current[$tag],$result);
|
||||
}
|
||||
else
|
||||
{ //If taken, put all things inside a list(array)
|
||||
if((is_array($current[$tag]) and $get_attributes == 0)//If it is already an array...
|
||||
or (isset($current[$tag][0]) and is_array($current[$tag][0]) and $get_attributes == 1))
|
||||
{
|
||||
array_push($current[$tag],$result); // ...push the new element into that array.
|
||||
}
|
||||
else
|
||||
{ //If it is not an array...
|
||||
$current[$tag] = array($current[$tag],$result); //...Make it an array using using the existing value and the new value
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
elseif ($type == 'close')
|
||||
{ //End of tag '</tag>'
|
||||
$current = &$parent[$level-1];
|
||||
}
|
||||
}
|
||||
return($xml_array);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user