formatOutput = $format_output; self::$encoding = $encoding; } public static function &createXML($arr=array(), $node_name='NodeNameDefault') { $xml = self::getXMLRoot(); if (count($arr) > 1) { $xml->appendChild(self::convert($node_name, $arr)); } else { @$root_element = array_pop(array_keys($arr)); $xml->insertBefore(self::convert($root_element, $arr[$root_element])); } self::$xml = null; return $xml; } private static function &convert($node_name, $arr=array()) { $xml = self::getXMLRoot(); $node = $xml->createElement($node_name); if(is_array($arr)) { if(isset($arr['@src'])) { foreach($arr['@src'] as $key => $value) { if(!self::isValidTagName($key)) { throw new Exception('[Array2XML] Illegal character in attribute name. attribute: '.$key.' in node: '.$node_name); } $node->setAttribute($key, self::bool2str($value)); } unset($arr['@src']); } if(isset($arr['#text'])) { foreach($arr as $key => $value) { if(@$key[0]=="@") $node->setAttribute(substr($key, 1), $value); } if(isset($arr['@cdata'])) { $node->setAttribute('cdata', $arr['@cdata']); $node->appendChild($xml->createCDATASection(self::bool2str($arr['#text']))); } else { $node->appendChild($xml->createTextNode(self::bool2str($arr['#text']))); } unset($arr['#text']); return $node; } } if(is_array($arr)) { foreach($arr as $key=>$value) { if(!self::isValidTagName($key)) { throw new Exception('[Array2XML] Illegal character in tag name. tag: '.$key.' in node: '.$node_name); } if(is_array($value) && is_numeric(key($value))) { foreach($value as $k=>$v) { $node->appendChild(self::convert($key, $v)); } } else { $node->appendChild(self::convert($key, $value)); } unset($arr[$key]); } } if(!is_array($arr)) { $node->appendChild($xml->createTextNode(self::bool2str($arr))); } return $node; } private static function getXMLRoot() { if(empty(self::$xml)) { self::init(); } return self::$xml; } private static function bool2str($v) { $v = $v === true ? 'true' : $v; $v = $v === false ? 'false' : $v; return $v; } private static function isValidTagName($tag) { $pattern = '/^[a-z_]+[a-z0-9\:\-\.\_]*[^:]*$/i'; return preg_match($pattern, $tag, $matches) && $matches[0] == $tag; } } /* Class qui permet la lecture des fichiers XML */ class Xml2Array { private $xml_dom; private $xml_array; private $xml; public function __construct($xml = '') {$this->xml = $xml;} public function setXml($xml) { if(!empty($xml)) { $this->xml = $xml; } } public function get_array() { if($this->get_dom() === false){return false;} $this->xml_array = array(); $root_element = $this->xml_dom->firstChild; $this->xml_array[$root_element->tagName] = $this->node_2_array($root_element); return $this->xml_array; } private function node_2_array($dom_element) { if($dom_element->nodeType != XML_ELEMENT_NODE){return false;} $children = $dom_element->childNodes; foreach($children as $child) { if($child->nodeType != XML_ELEMENT_NODE){continue;} $prefix = ($child->prefix) ? $child->prefix.':' : ''; if(!is_array(@$result[$prefix.$child->nodeName])) { $subnode = false; foreach($children as $test_node) { if($child->nodeName == $test_node->nodeName && !$child->isSameNode($test_node)) { $subnode = true; break; } } } else { $subnode = true; } if ($subnode) { $result[$prefix.$child->nodeName][] = $this->node_2_array($child); } else { $result[$prefix.$child->nodeName] = $this->node_2_array($child); } } if (!is_array(@$result)) { 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()) { foreach ($dom_element->attributes as $attrib) { $prefix = ($attrib->prefix) ? $attrib->prefix.':' : ''; if (function_exists('html_entity_encode')) $result["@".$prefix.$attrib->nodeName] = html_entity_encode(htmlentities($attrib->nodeValue)); else $result["@".$prefix.$attrib->nodeName] = htmlentities($attrib->nodeValue); } } return $result; } private function get_dom() { if(empty($this->xml)) { echo 'Aucun fichier XML trouvé.'; return false; } $this->xml_dom = @DOMDocument::load($this->xml); if($this->xml_dom) { return $this->xml_dom; } echo 'Données XML invalide'; } } // Renvoi le XML en ARRAY function lecture_xml($config, $isAdmin = FALSE) { $converter = new Xml2Array(); $converter->setXml($config); $xml_array = $converter->get_array(); if($isAdmin) unset($xml_array['configuration']['users']); //if not admin return $xml_array; } // Renvoi le listing d'un dossier dans un ARRAY function listing_dossier($folder) { $dossier = opendir($folder); $i=0; while ($Fichier = readdir($dossier)) { if ($Fichier != "." && $Fichier != ".." && $Fichier != ".htaccess" && substr($Fichier, 0, 1) != '.') { $array[$i]=$Fichier; $i++; } } closedir($dossier); if(isset($array)) { @natsort($array); return $array; } else return FALSE; } // 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, $e) { $arrayXML = lecture_xml($a); $arrayKEY = $e; $d = false; foreach($arrayKEY as $arrayOptions => $arrayValues) { $tmp = &$arrayXML; foreach(explode('/', $arrayOptions) as $key) { if(strpos($key, "#CDATA")) { $d = true; $key = explode("#CDATA", $key); $key = $key[0]; } $tmp =& $tmp[$key]; } if($d) { $tmp["@cdata"] = $arrayValues; //$tmp["#text"] = ""; } else $tmp["#text"] = $arrayValues; //$tmp["#text"] = $arrayValues; } $savedXML = Array2XML::createXML($arrayXML); $savedXML->save($a); } // Renvoi une donnée en STRING function donnee_xml($a, $b) { $dom = new DomDocument; $dom->load($a); $xml = $dom->getElementsByTagName($b); return $xml->item(0)->nodeValue; } // Renvoi STRING // Nettoie le nom d'un fichier // Thanks to Magento script function cleanName($a) { $array = array( '&' => 'and', '@' => 'at', '©' => 'c', '®' => 'r', 'À' => 'a', 'Á' => 'a', 'Â' => 'a', 'Ä' => 'a', 'Å' => 'a', 'Æ' => 'ae','Ç' => 'c', 'È' => 'e', 'É' => 'e', 'Ë' => 'e', 'Ì' => 'i', 'Í' => 'i', 'Î' => 'i', 'Ï' => 'i', 'Ò' => 'o', 'Ó' => 'o', 'Ô' => 'o', 'Õ' => 'o', 'Ö' => 'o', 'Ø' => 'o', 'Ù' => 'u', 'Ú' => 'u', 'Û' => 'u', 'Ü' => 'u', 'Ý' => 'y', 'ß' => 'ss','à' => 'a', 'á' => 'a', 'â' => 'a', 'ä' => 'a', 'å' => 'a', 'æ' => 'ae','ç' => 'c', 'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e', 'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i', 'ò' => 'o', 'ó' => 'o', 'ô' => 'o', 'õ' => 'o', 'ö' => 'o', 'ø' => 'o', 'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'ü' => 'u', 'ý' => 'y', 'þ' => 'p', 'ÿ' => 'y', 'Ā' => 'a', 'ā' => 'a', 'Ă' => 'a', 'ă' => 'a', 'Ą' => 'a', 'ą' => 'a', 'Ć' => 'c', 'ć' => 'c', 'Ĉ' => 'c', 'ĉ' => 'c', 'Ċ' => 'c', 'ċ' => 'c', 'Č' => 'c', 'č' => 'c', 'Ď' => 'd', 'ď' => 'd', 'Đ' => 'd', 'đ' => 'd', 'Ē' => 'e', 'ē' => 'e', 'Ĕ' => 'e', 'ĕ' => 'e', 'Ė' => 'e', 'ė' => 'e', 'Ę' => 'e', 'ę' => 'e', 'Ě' => 'e', 'ě' => 'e', 'Ĝ' => 'g', 'ĝ' => 'g', 'Ğ' => 'g', 'ğ' => 'g', 'Ġ' => 'g', 'ġ' => 'g', 'Ģ' => 'g', 'ģ' => 'g', 'Ĥ' => 'h', 'ĥ' => 'h', 'Ħ' => 'h', 'ħ' => 'h', 'Ĩ' => 'i', 'ĩ' => 'i', 'Ī' => 'i', 'ī' => 'i', 'Ĭ' => 'i', 'ĭ' => 'i', 'Į' => 'i', 'į' => 'i', 'İ' => 'i', 'ı' => 'i', 'IJ' => 'ij','ij' => 'ij','Ĵ' => 'j', 'ĵ' => 'j', 'Ķ' => 'k', 'ķ' => 'k', 'ĸ' => 'k', 'Ĺ' => 'l', 'ĺ' => 'l', 'Ļ' => 'l', 'ļ' => 'l', 'Ľ' => 'l', 'ľ' => 'l', 'Ŀ' => 'l', 'ŀ' => 'l', 'Ł' => 'l', 'ł' => 'l', 'Ń' => 'n', 'ń' => 'n', 'Ņ' => 'n', 'ņ' => 'n', 'Ň' => 'n', 'ň' => 'n', 'ʼn' => 'n', 'Ŋ' => 'n', 'ŋ' => 'n', 'Ō' => 'o', 'ō' => 'o', 'Ŏ' => 'o', 'ŏ' => 'o', 'Ő' => 'o', 'ő' => 'o', 'Œ' => 'oe','œ' => 'oe','Ŕ' => 'r', 'ŕ' => 'r', 'Ŗ' => 'r', 'ŗ' => 'r', 'Ř' => 'r', 'ř' => 'r', 'Ś' => 's', 'ś' => 's', 'Ŝ' => 's', 'ŝ' => 's', 'Ş' => 's', 'ş' => 's', 'Š' => 's', 'š' => 's', 'Ţ' => 't', 'ţ' => 't', 'Ť' => 't', 'ť' => 't', 'Ŧ' => 't', 'ŧ' => 't', 'Ũ' => 'u', 'ũ' => 'u', 'Ū' => 'u', 'ū' => 'u', 'Ŭ' => 'u', 'ŭ' => 'u', 'Ů' => 'u', 'ů' => 'u', 'Ű' => 'u', 'ű' => 'u', 'Ų' => 'u', 'ų' => 'u', 'Ŵ' => 'w', 'ŵ' => 'w', 'Ŷ' => 'y', 'ŷ' => 'y', 'Ÿ' => 'y', 'Ź' => 'z', 'ź' => 'z', 'Ż' => 'z', 'ż' => 'z', 'Ž' => 'z', 'ž' => 'z', 'ſ' => 'z', 'Ə' => 'e', 'ƒ' => 'f', 'Ơ' => 'o', 'ơ' => 'o', 'Ư' => 'u', 'ư' => 'u', 'Ǎ' => 'a', 'ǎ' => 'a', 'Ǐ' => 'i', 'ǐ' => 'i', 'Ǒ' => 'o', 'ǒ' => 'o', 'Ǔ' => 'u', 'ǔ' => 'u', 'Ǖ' => 'u', 'ǖ' => 'u', 'Ǘ' => 'u', 'ǘ' => 'u', 'Ǚ' => 'u', 'ǚ' => 'u', 'Ǜ' => 'u', 'ǜ' => 'u', 'Ǻ' => 'a', 'ǻ' => 'a', 'Ǽ' => 'ae','ǽ' => 'ae','Ǿ' => 'o', 'ǿ' => 'o', 'ə' => 'e', 'Ё' => 'jo','Є' => 'e', 'І' => 'i', 'Ї' => 'i', 'А' => 'a', 'Б' => 'b', 'В' => 'v', 'Г' => 'g', 'Д' => 'd', 'Е' => 'e', 'Ж' => 'zh','З' => 'z', 'И' => 'i', 'Й' => 'j', 'К' => 'k', 'Л' => 'l', 'М' => 'm', 'Н' => 'n', 'О' => 'o', 'П' => 'p', 'Р' => 'r', 'С' => 's', 'Т' => 't', 'У' => 'u', 'Ф' => 'f', 'Х' => 'h', 'Ц' => 'c', 'Ч' => 'ch','Ш' => 'sh','Щ' => 'sch', 'Ъ' => '-', 'Ы' => 'y', 'Ь' => '-', 'Э' => 'je','Ю' => 'ju','Я' => 'ja', 'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', 'д' => 'd', 'е' => 'e', 'ж' => 'zh','з' => 'z', 'и' => 'i', 'й' => 'j', 'к' => 'k', 'л' => 'l', 'м' => 'm', 'н' => 'n', 'о' => 'o', 'п' => 'p', 'р' => 'r', 'с' => 's', 'т' => 't', 'у' => 'u', 'ф' => 'f', 'х' => 'h', 'ц' => 'c', 'ч' => 'ch', 'ш' => 'sh','щ' => 'sch','ъ' => '-','ы' => 'y', 'ь' => '-', 'э' => 'je', 'ю' => 'ju','я' => 'ja','ё' => 'jo','є' => 'e', 'і' => 'i', 'ї' => 'i', 'Ґ' => 'g', 'ґ' => 'g', 'א' => 'a', 'ב' => 'b', 'ג' => 'g', 'ד' => 'd', 'ה' => 'h', 'ו' => 'v', 'ז' => 'z', 'ח' => 'h', 'ט' => 't', 'י' => 'i', 'ך' => 'k', 'כ' => 'k', 'ל' => 'l', 'ם' => 'm', 'מ' => 'm', 'ן' => 'n', 'נ' => 'n', 'ס' => 's', 'ע' => 'e', 'ף' => 'p', 'פ' => 'p', 'ץ' => 'C', 'צ' => 'c', 'ק' => 'q', 'ר' => 'r', 'ש' => 'w', 'ת' => 't', '™' => 'tm', ); $a = strtr($a, $array); $a = preg_replace('/[^a-z0-9\._-]+/i', '-', strtolower($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) { $filename = $fichier["name"]; $source = $fichier["tmp_name"]; $type = $fichier["type"]; 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; //echo $target_path; if(move_uploaded_file($source, $target_path)) { $nom = basename($filename, ".zip"); if (is_dir($dossier.$nom)==TRUE) { $e = 2; //echo "Ce ".$page." est déjà installé."; unlink($target_path); } else { $zip = new ZipArchive(); $x = $zip->open($target_path); if ($x === true) { $zip->extractTo($dossier.$nom); $zip->close(); unlink($target_path); } //Modification pour l'installation de module $contenu = lecture_xml($dossier.$nom."/config.xml"); rename ($dossier.$nom, $dossier.$contenu['configuration']['dossier']['#text']); // $e = 0; //echo "Votre ".$page." a bien été installé."; } } else {$e=1; //echo "Une erreur est survenue. Veuillez recommencer."; } } else {$e=3; //echo "Votre fichier n'est pas un zip."; } return $e; } // Inverse de nl2br by OverSu function br2nl($replace) { return preg_replace("//i", "", $replace); } //Merci à holger1 de php.net // Supprime un dossier function removeFolder($dir) { if (is_dir($dir)) { $objects = scandir($dir); foreach ($objects as $object) { if ($object != "." && $object != "..") { if (filetype($dir."/".$object) == "dir") removeFolder($dir."/".$object); else unlink($dir."/".$object); } } reset($objects); rmdir($dir); } } // Vide un dossier function clearFolder($folder) { $dossier=opendir($folder); while ($fichier = readdir($dossier)) { if ($fichier != "." && $fichier != "..") { $Vidage= $folder.$fichier; unlink($Vidage); } } closedir($dossier); } //=== Generate a simple password //=== IN: Number of character [INT FORMAT] //=== OUT: Generated password [STRING FORMAT] //=== VAR: $N number of characters wanted function generateEasyPassword($N) { $S = ""; $C = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; srand((double)microtime()*1000); for($i=0; $i<$N; $i++) {$S .= $C[rand()%strlen($C)];} return $S; } // Envoi un mail // 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 = ($name == null)? "From: ".$expediteur."\n" : "From: ".$name." <".$expediteur.">\n"; $entete .= "Cc: \n"; $entete .= "Reply-To: ".$expediteur." \n"; $entete .= "X-Mailer: PHP/" . phpversion() . "\n" ; $entete .= "Date: ". date("D, j M Y H:i:s"); mail($destinataire, $titre, $messageHTML, $entete); } // Retourne un boolean // Vérifie si une adresse est belle et bien au format mail. 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]; } // Retourne BOOLEAN // Retourne si il y a une nouvelle version - ou pas. // Fonction non...fonctionnelle ! function checkVersion() { $v = file_get_contents(AEOS_REAL_URL.'/demo/data/config.xml'); if($v['configuration']['update']['#text']==AEOS_VERSION) return FALSE; else return TRUE; } // Retourne STRING // Retourne STRING sécurisé function CA20($a) { //XSS $a = strip_tags($a); $a = htmlspecialchars($a, ENT_QUOTES); //SQL Injection $a = htmlentities($a, ENT_QUOTES); $a = stripslashes($a); //Remove tabs //$a = trim(preg_replace('/\t+/', '', $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; } // Retourne STRING // Renvoi la valeur LANGUAGE du navigateur web sous forme "fr" function detectLang() { if(isset($_['lang'])) $l = $_['lang']; else { $l = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']); $l = strtolower(substr(chop($l[0]),0,2)); switch ($l) { case 'fr': $l = "fr_FR"; break; case 'en': $l = "en_US"; break; default: $l = "fr_FR"; break; } } return $l; } // Retourne BOOLEAN // Vérifie si un champs est vide function checkEmptyField($a) { if (empty($a) || $a=="") return TRUE; else return FALSE; } // Retourne BOOLEAN // Vérifie si un fichier lang.php est disponible pour le module $a function checkMultilangModuleAvailable($a) { if(isset($a)) if($a==1) return TRUE; else return FALSE; } //Retourne STRING // Change un paramètre dans l'URL via STRING_QUERY function changeParameterRequestURL($a, $b) { parse_str($a, $d); foreach($b as $k => $v) { $d[$k] = $v; } $d = http_build_query($d); return $d; } // Retourne HTML // Affiche une notification function showNotification($a, $b, $c = false) { $r = "

"; if($c) $r.=" "; $r.= $a."

"; return $r; } //=== Ajoute les fichiers necessaires (modules/plugins) dans les endroits appropriés (JS en bas de page et le reste dans le head) function checkFiles($b, $f, $s = FALSE, $g = FALSE) { $b = explode('/', $b); $d = listing_dossier($s.'plugins'); if(!$d) $d=Array(); $toInclude = array( "Modules" => Array( "modules", Array( $b[0] ), ), "Themes" => Array( "themes", Array( $b[1] ), ), "Plugins" => Array( "plugins", $d, ), ); // if admin, do not load MODULES/THEMES if($s) unset($toInclude['Modules']); if($s) unset($toInclude['Themes']); $return = ''; $returnedPosition = Array(); $returnedOB = Array(); foreach($toInclude as $k => $v) { foreach($v[1] as $v1k => $v1v) { $a = lecture_xml($s.$v[0].'/'.$v1v.'/config.xml'); // if only one file if(!isset($a['configuration']['fichiers']['fichier'][0]) && isset($a['configuration']['fichiers']['fichier'])) { $tmp = $a['configuration']['fichiers']['fichier']; unset($a['configuration']['fichiers']['fichier']); $a['configuration']['fichiers']['fichier'][0] = $tmp; } $nbr = @count($a['configuration']['fichiers']['fichier']); $activation = @$a['configuration']['activation']['#text']; // if admin and plugin not activate if(($s && @$a['configuration']['edition']['admin']['#text']=="TRUE") || !$s) { if((!isset($activation) || $activation==1) && $nbr>0) { $c = ''."\r\n\t"; if(isset($a['configuration']['fichiers'])) { for($i=0; $i<$nbr; $i++) { $src = $a['configuration']['fichiers']['fichier'][$i]['#text']; $type = $a['configuration']['fichiers']['fichier'][$i]['@type']; $script = $a['configuration']['fichiers']['fichier'][$i]['@script']; if($f==0) { switch($type) { case 'css': if($script=="interne") $c .= ''."\r\n\t"; else if($script=="externe") $c .= ''."\r\n\t"; else if($script=="code") $c .= ''."\r\n\t"; break; } } elseif($f==1) { switch($type) { case 'php': if($script=="interne") { ob_start(); include($s.$v[0].'/'.$v1v.'/inc/'.$src); $returnedPosition[] = $a['configuration']['edition']['position']['#text']; $returnedOB[] = ob_get_clean(); } break; } } elseif($f==2) { switch($type) { case 'js': if($script=="interne") $c .= ''."\r\n\t"; else if($script=="externe") $c .= ''."\r\n\t"; else if($script=="code") $c .= ''."\r\n\t"; break; } } } } $return .= $c; } } } } return Array("Data" => $return, "OB" => @$returnedOB, "Position" => @$returnedPosition); } // Generate all HTML and modify in order to add PHP file via plugins function insertPlugins($e, $r) { // DOM $dom = new DOMDocument(); $domRedefined = new DOMDocument; @$dom->loadHtml(utf8_decode($e)); // Remove the DOCTYPE and HTML tag previously generated $body = $dom->getElementsByTagName('html')->item(0); foreach ($body->childNodes as $child){ $domRedefined->appendChild($domRedefined->importNode($child, true)); } for($i=0; $igetElementById($r["Position"][$i]); // Prepare the HTML to insert $f = $domRedefined->createDocumentFragment(); $f->appendXML($r["OB"][$i]); $$a = $domRedefined->getElementById($r["Position"][$i]); $$a->parentNode->insertBefore($f, $$a); } return $domRedefined->saveHTML(); } ?>