AEOS Calvarium v0.4
This commit is contained in:
parent
821b405f5a
commit
57b531cb62
189 changed files with 3810 additions and 1417 deletions
194
lib/aeos.lib.php
Normal file → Executable file
194
lib/aeos.lib.php
Normal file → Executable file
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
/* Class qui permet la lecture des fichiers XML */
|
||||
class Xml2Array
|
||||
{
|
||||
{
|
||||
private $xml_dom;
|
||||
private $xml_array;
|
||||
private $xml;
|
||||
|
|
@ -68,7 +68,8 @@ class Xml2Array
|
|||
|
||||
if (!is_array(@$result))
|
||||
{
|
||||
$result['#text'] = html_entity_decode(htmlentities($dom_element->nodeValue, ENT_COMPAT, 'UTF-8'), ENT_COMPAT,'ISO-8859-1');
|
||||
if (function_exists('html_entity_decode')) $result['#text'] = html_entity_decode(htmlentities($dom_element->nodeValue));
|
||||
else $result['#text'] = htmlentities($dom_element->nodeValue);
|
||||
}
|
||||
|
||||
if ($dom_element->hasAttributes())
|
||||
|
|
@ -76,7 +77,8 @@ class Xml2Array
|
|||
foreach ($dom_element->attributes as $attrib)
|
||||
{
|
||||
$prefix = ($attrib->prefix) ? $attrib->prefix.':' : '';
|
||||
$result["@".$prefix.$attrib->nodeName] = $attrib->nodeValue;
|
||||
if (function_exists('html_entity_encode')) $result["@".$prefix.$attrib->nodeName] = html_entity_encode(htmlentities($attrib->nodeValue));
|
||||
else $result["@".$prefix.$attrib->nodeName] = htmlentities($attrib->nodeValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -87,7 +89,7 @@ class Xml2Array
|
|||
{
|
||||
if(empty($this->xml))
|
||||
{
|
||||
echo '<span class="erreur">Aucun fichier XML trouvé.</span>';
|
||||
echo '<span class="erreur">Aucun fichier XML trouvé.</span>';
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -98,7 +100,8 @@ class Xml2Array
|
|||
return $this->xml_dom;
|
||||
}
|
||||
|
||||
echo '<span class="erreur">Données XML invalide</span>'; exit;
|
||||
echo '<span class="erreur">Données XML invalide</span>';
|
||||
//header('Location: '.$AEOS_REW.HOME_PAGE.'-E404.html');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -116,18 +119,40 @@ function listing_dossier($folder)
|
|||
{
|
||||
$dossier = opendir($folder);
|
||||
$i=0;
|
||||
while ($Fichier = readdir($dossier)) {
|
||||
if ($Fichier != "." && $Fichier != "..") {
|
||||
while ($Fichier = readdir($dossier))
|
||||
{
|
||||
if ($Fichier != "." && $Fichier != ".." && $Fichier != ".htaccess" && substr($Fichier, 0, 1) != '.')
|
||||
{
|
||||
$array[$i]=$Fichier;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
@natsort($array);
|
||||
return $array;
|
||||
closedir($dossier);
|
||||
return $array;
|
||||
closedir($dossier);
|
||||
}
|
||||
|
||||
// Renvoi le listing du dossier PAGE en triant par ordre
|
||||
function listing_ordre($o = NULL)
|
||||
{
|
||||
$a = array();
|
||||
$l = listing_dossier(DATA_PAGES);
|
||||
foreach ($l as &$p)
|
||||
{
|
||||
$m = lecture_xml(DATA_PAGES.$p);
|
||||
$a[$m['page']['ordre']['#text']] = $p;
|
||||
}
|
||||
switch($o)
|
||||
{
|
||||
case 1: krsort($a); break;
|
||||
case 0:
|
||||
default: ksort($a); break;
|
||||
}
|
||||
return $a;
|
||||
}
|
||||
|
||||
// Enregistre une donnée dans un XML - Chemin, OldElement, NewElement
|
||||
/*
|
||||
function ecriture_xml($a, $b, $c)
|
||||
{
|
||||
$dom = new DomDocument;
|
||||
|
|
@ -135,10 +160,46 @@ function ecriture_xml($a, $b, $c)
|
|||
$xml = $dom->getElementsByTagName($b);
|
||||
//echo $xml->item(0)->nodeValue;
|
||||
$titre = $xml->item(0);
|
||||
$titre->nodeValue = utf8_encode($c);
|
||||
$titre->nodeValue = stripslashes(utf8_encode($c));
|
||||
//echo $dom->saveXML();
|
||||
$dom->save($a);
|
||||
}
|
||||
*/
|
||||
|
||||
function ecriture_xml($a, $b, $c, $d=FALSE)
|
||||
{
|
||||
$dom = new DomDocument('1.0','UTF-8');
|
||||
$dom->load($a);
|
||||
$b = explode("/", $b);
|
||||
$i = 0;
|
||||
foreach($b as $element)
|
||||
{
|
||||
$crt = "dom".$i;
|
||||
$prec = ($i == 0)? "dom" : "dom".($i-1);
|
||||
if(substr($element, -1) == "]")
|
||||
{
|
||||
$d = explode("[", $element);
|
||||
$e = $d[0];
|
||||
$f = intval(substr($d[1], 0, -1));
|
||||
$$crt = $$prec->getElementsByTagName($e)->item($f);
|
||||
}
|
||||
else
|
||||
{
|
||||
$$crt = $$prec->getElementsByTagName($element)->item(0);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$rep = $$crt->nodeValue = stripslashes($c);
|
||||
if($d)
|
||||
{
|
||||
$ocrt = $$crt;
|
||||
$ncrt=$$crt->parentNode->appendChild($dom->createElement($element));
|
||||
$cdata=$dom->createCDATASection(stripslashes($c));
|
||||
$ncrt->appendChild($cdata);
|
||||
$$crt->parentNode->replaceChild($ncrt, $ocrt);
|
||||
}
|
||||
$dom->save($a);
|
||||
}
|
||||
|
||||
// Renvoi une donnée en STRING
|
||||
function donnee_xml($a, $b)
|
||||
|
|
@ -149,6 +210,13 @@ function donnee_xml($a, $b)
|
|||
return $xml->item(0)->nodeValue;
|
||||
}
|
||||
|
||||
function cleanName($a)
|
||||
{
|
||||
$b = array('"', '/', ',', '\\', '*', '?', '<', '>', '|', ':');
|
||||
$c = str_replace($b, "", $a);
|
||||
return utf8_decode($c);
|
||||
}
|
||||
|
||||
// Upload $fichier, le dézippe dans $dossier et affiche le message $page
|
||||
function upload_unzip($fichier, $dossier, $page)
|
||||
{
|
||||
|
|
@ -156,7 +224,7 @@ function upload_unzip($fichier, $dossier, $page)
|
|||
$source = $fichier["tmp_name"];
|
||||
$type = $fichier["type"];
|
||||
|
||||
if ($type=="application/zip" || $type=="application/x-zip-compressed" || $type=="multipart/x-zip" || $type=="application/x-compressed")
|
||||
if ($type=="application/zip" || $type=="application/x-zip-compressed" || $type=="multipart/x-zip" || $type=="application/x-compressed" || $type=="application/octet-stream")
|
||||
{
|
||||
$target_path = $dossier.$filename;
|
||||
if(move_uploaded_file($source, $target_path))
|
||||
|
|
@ -164,7 +232,7 @@ function upload_unzip($fichier, $dossier, $page)
|
|||
$nom = basename($filename, ".zip");
|
||||
if (is_dir($dossier.$nom)==TRUE)
|
||||
{
|
||||
echo "<span class='erreur'>Ce ".$page." est déjà installé.</span>";
|
||||
$e = 2; //echo "<span class='erreur'>Ce ".$page." est déjà installé.</span>";
|
||||
unlink($target_path);
|
||||
}
|
||||
else
|
||||
|
|
@ -181,12 +249,17 @@ function upload_unzip($fichier, $dossier, $page)
|
|||
$contenu = lecture_xml($dossier.$nom."/config.xml");
|
||||
rename ($dossier.$nom, $dossier.$contenu['configuration']['dossier']['#text']);
|
||||
//
|
||||
echo "<span class='valide'>Votre ".$page." a bien été installé.</span>";
|
||||
$e = 0; //echo "<span class='valide'>Votre ".$page." a bien été installé.</span>";
|
||||
}
|
||||
}
|
||||
else {echo "<span class='erreur'>Une erreur est survenue. Veuillez recommencer.</span>";}
|
||||
else {$e=1;
|
||||
//echo "<span class='erreur'>Une erreur est survenue. Veuillez recommencer.</span>";
|
||||
}
|
||||
}
|
||||
else {echo "<span class='erreur'>Votre fichier n'est pas un zip.</span>";}
|
||||
else {$e=3;
|
||||
//echo "<span class='erreur'>Votre fichier n'est pas un zip.</span>";
|
||||
}
|
||||
return $e;
|
||||
}
|
||||
|
||||
// Inverse de nl2br by OverSu
|
||||
|
|
@ -242,9 +315,10 @@ function generer_mdp($nbr)
|
|||
}
|
||||
|
||||
// Envoi un mail
|
||||
function sendMail($expediteur, $destinataire, $titre, $messageHTML){
|
||||
// Ajout du nom de l'expéditeur dans le champs 'FROM' (Optionnel)
|
||||
function sendMail($expediteur, $destinataire, $titre, $messageHTML, $name = null){
|
||||
date("D, j M Y H:i:s");
|
||||
$entete = "From: ".$expediteur."\n";
|
||||
$entete = ($name == null)? "From: ".$expediteur."\n" : "From: ".$name." <".$expediteur.">\n";
|
||||
$entete .= "Cc: \n";
|
||||
$entete .= "Reply-To: ".$expediteur." \n";
|
||||
$entete .= "X-Mailer: PHP/" . phpversion() . "\n" ;
|
||||
|
|
@ -254,10 +328,94 @@ function sendMail($expediteur, $destinataire, $titre, $messageHTML){
|
|||
|
||||
// Retourne un boolean
|
||||
// Vérifie si une adresse est belle et bien au format mail.
|
||||
function checkMail($adresse)
|
||||
function checkMail($adresse)
|
||||
{
|
||||
$Syntaxe='#^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,6}$#';
|
||||
if(preg_match($Syntaxe,$adresse)) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
// Retourne STRING
|
||||
// Permet d'afficher le chemin complet du site SANS le fichier à la fin NI le slash. (Ex: http://www.domaine.com/dossier/)
|
||||
function getBaseScript()
|
||||
{
|
||||
$fullPath = $_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'];
|
||||
$file = basename ($fullPath);
|
||||
$dir = dirname($fullPath);
|
||||
return $dir;
|
||||
}
|
||||
|
||||
// Retourne STRING
|
||||
// Transforme une chaine en URL valide
|
||||
function valideURL($s)
|
||||
{
|
||||
$p = array("?","!","@","#","%","&","*","(",")","[","]","=","+"," ",";",":","'",".","_", "&");
|
||||
$s = str_replace($p, "-", $s);
|
||||
$s = strip_tags($s);
|
||||
$m = array('@', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'à', 'á', 'â', 'ã', 'ä', 'å', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ò', 'ó', 'ô', 'õ', 'ö', 'ù', 'ú', 'û', 'ü', 'ý', 'ÿ');
|
||||
$n = array('a', 'A', 'A', 'A', 'A', 'A', 'A', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', 'a', 'a', 'a', 'a', 'a', 'a', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'o', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'y');
|
||||
while($k = strpos($s, '--')!==FALSE) $s = str_replace("--", "-", $s);
|
||||
$s = str_replace($m, $n, $s);
|
||||
return $s;
|
||||
}
|
||||
|
||||
// Retrouve STRING
|
||||
// Retourne la valeur précédente d'un array
|
||||
function getValueArray($a, $b, $c)
|
||||
{
|
||||
$k = array_flip(array_keys($a));
|
||||
$v = array_values($a);
|
||||
return $v[$k[$b]+$c];
|
||||
}
|
||||
|
||||
function showTooltip($a, $b)
|
||||
{
|
||||
$r='<a href="#" class="tooltip">';
|
||||
$r.=$a;
|
||||
$r.='<span>';
|
||||
$r.='<img class="tooltipi" src="../themes/system/images/icones/tooltip.png" />';
|
||||
$r.=$b;
|
||||
$r.='</span>';
|
||||
$r.='</a>';
|
||||
|
||||
return $r;
|
||||
}
|
||||
|
||||
// Retourne BOOLEAN
|
||||
// Retourne si il y a une nouvelle version - ou pas.
|
||||
function checkVersion()
|
||||
{
|
||||
$v = lecture_xml(AEOS_REAL_URL.'/demo/data/config.xml');
|
||||
if($v['configuration']['version']['#text']==AEOS_VERSION) return FALSE;
|
||||
else return TRUE;
|
||||
}
|
||||
|
||||
// Retourne STRING
|
||||
// Retourne STRING sécurisé
|
||||
function CA20($a)
|
||||
{
|
||||
//XSS
|
||||
strip_tags($a);
|
||||
$a = htmlspecialchars($a, ENT_QUOTES);
|
||||
|
||||
//SQL Injection
|
||||
$a = htmlentities($a, ENT_QUOTES);
|
||||
if(get_magic_quotes_gpc()===1){$a = stripslashes($a);}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
function checkInstall()
|
||||
{
|
||||
global $subdir;
|
||||
$config = $subdir."data/config.xml";
|
||||
$install = $subdir."install/index.php";
|
||||
|
||||
if (!file_exists($config))
|
||||
{
|
||||
if (!file_exists($install)) die("Fichier config.xml et script d'installation introuvable");
|
||||
else header('Location: '.$install);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue