Beispiel #1
0
<?php

header('Content-Type: text/html; charset=iso-8859-1');
require_once "easyem_functions.php";
$xpath = new DOMXPath(getEMComposantVariable());
if ($_POST["type"] == 'composant') {
    $composants = $xpath->query("/Elements/Element[@nom='" . $_POST["nom"] . "' and @emplacement='" . $_POST["emplacement"] . "']");
}
$xpath = new DOMXPath(getComposant());
if ($_POST["type"] == 'compotroll') {
    $composants = $xpath->query("/Elements/Element[contains(child::text(),'" . $_POST["nom"] . "') and @emplacement='" . $_POST["emplacement"] . "']");
}
if ($_POST["type"] == 'recherchecompotroll') {
    if ($_POST["famille"]) {
        $_POST["famille"] = '="' . $_POST["famille"] . '"';
    }
    if ($_POST["nom"]) {
        $_POST["nom"] = '="' . $_POST["nom"] . '"';
    }
    $emplacements = explode("|", $_POST["emplacement"]);
    unset($emplacements[count($emplacements) - 1]);
    $stremplacement = "(@emplacement";
    foreach ($emplacements as $i => $emplacement) {
        $stremplacement .= $i != count($emplacements) - 1 ? "='{$emplacement}' or @emplacement" : "='{$emplacement}') and ";
    }
    if (!$emplacements) {
        $stremplacement = "not(@emplacement) and ";
    }
    $composants = $xpath->query('/Elements/Element[' . $stremplacement . '@famille' . $_POST["famille"] . ' and @monstre' . $_POST["nom"] . ' and @niveau>="' . intval($_POST["min"]) . '" and @niveau<="' . intval($_POST["max"]) . '"]');
}
foreach ($composants as $composant) {
Beispiel #2
0
function getCrapComposant()
{
    $retour = "";
    $xpathCompo = new DOMXPath(getComposant());
    $xpath = new DOMXPath(getEMRecettes());
    foreach ($xpath->query("/Recettes/Recette/composant[not(@mundidey)]") as $composantFixe) {
        $composantsFixe[] = $composantFixe->getAttribute("nom");
    }
    $xpath = new DOMXPath(getEMComposantVariable());
    foreach ($xpath->query("/Elements/Element") as $composantFixe) {
        $composantsFixe[] = $composantFixe->nodeValue;
    }
    $xpath = new DOMXPath(getCompotrolls());
    foreach ($xpath->query("/Elements/Element") as $composantFixe) {
        $composantsFixe[] = $composantFixe->nodeValue;
    }
    $composantsFixe = implode("|", $composantsFixe);
    $xpath = new DOMXPath(getComposants());
    foreach ($xpath->query(utf8_encode("/Elements/Element[contains(child::text(),'Mauvaise')]")) as $composant) {
        if (!preg_match("#" . $composantsFixe . ".*#", $composant->nodeValue)) {
            $niveau = $xpathCompo->query('/Elements/Element[contains("' . $composant->nodeValue . '",child::text())]')->item(0);
            $niveau = $niveau->nodeValue == NULL ? "?" : $niveau->getAttribute("niveau");
            $arrayComposants[preg_replace("#.*Qualité (.*) \\[.*#", "\$1", utf8_decode($composant->nodeValue))][utf8_decode($composant->nodeValue)][] = array("nom" => utf8_decode($composant->nodeValue), "niveau" => $niveau, "id" => $composant->getAttribute("id"), "idTaniere" => $composant->getAttribute("idTaniere"));
        }
    }
    usort($arrayComposants["Très Mauvaise"], 'sortByNumber');
    usort($arrayComposants["Mauvaise"], 'sortByNumber');
    $arrayComposants = array_reverse($arrayComposants);
    foreach ($arrayComposants as $arrayQualité) {
        foreach ($arrayQualité as $composants) {
            foreach ($composants as $composant) {
                $retour .= "[" . $composant["id"] . "] " . $composant["nom"] . " " . getTanieresById($composant["idTaniere"]) . " niveau:" . $composant["niveau"] . "\n";
            }
        }
    }
    return "<textarea rows='25' cols='200'>{$retour}</textarea>";
}