Example #1
0
 /**
  * generate fields from services recursivly
  *
  * @param array   $map      map to add entries to
  * @param string  $ns       namespace
  * @param string  $bundle   bundle name
  * @param string  $doc      document name
  * @param boolean $embedded is this an embedded doc, further args are only for embeddeds
  * @param string  $name     name prefix of document the embedded field belongs to
  * @param string  $prefix   prefix to add to embedded field name
  *
  * @return void
  */
 private function loadFields(&$map, $ns, $bundle, $doc, $embedded = false, $name = '', $prefix = '')
 {
     if (strtolower($ns) === 'gravitondyn') {
         $ns = 'GravitonDyn';
     }
     $finder = new Finder();
     $files = $finder->files()->in(implode('/', [__DIR__, '..', '..', '..', '..', ucfirst($ns), ucfirst($bundle) . 'Bundle', 'Resources', 'config', 'doctrine']))->name(ucfirst($doc) . '.mongodb.xml');
     // we only want to find exactly one file
     if ($files->count() != 1) {
         return;
     }
     // array_pop would have been nice but won't work here, some day I'll look into iterators or whatnot
     $file = null;
     foreach ($files as $fileObject) {
         $file = $fileObject->getRealPath();
     }
     if (!file_exists($file)) {
         return;
     }
     $dom = new \DOMDocument();
     $dom->Load($file);
     $xpath = new \DOMXPath($dom);
     $xpath->registerNamespace('doctrine', 'http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping');
     $this->loadFieldsFromDOM($map, $xpath, $ns, $bundle, $doc, $embedded, $name, $prefix);
 }
Example #2
0
function add_to_xml($file, $title, $author, $price, $rating)
{
    $doc = new DOMDocument();
    $doc->Load($file);
    $list = $doc->getElementsByTagName("list")->item(0);
    $newid = (int) $list->getElementsByTagName("lastindex")->item(0)->textContent + 1;
    //echo $newid;
    $lastindex = $list->getElementsByTagName("lastindex")->item(0);
    $list->removeChild($lastindex);
    $newLastIndex = $doc->createElement("lastindex");
    $newLastIndex->appendChild($doc->createTextNode($newid));
    $list->appendChild($newLastIndex);
    //$list->getElementsByTagName("lastindex")->item(0)->appendChild($doc->createTextNode($newid));
    $newElement = $doc->createElement("item");
    $list->appendChild($newElement);
    $idd = $doc->createElement("id");
    $idd->appendChild($doc->createTextNode($newid));
    $newElement->appendChild($idd);
    $t = $doc->createElement("title");
    $t->appendChild($doc->createTextNode($title));
    $newElement->appendChild($t);
    $au = $doc->createElement("author");
    $au->appendChild($doc->createTextNode($author));
    $newElement->appendChild($au);
    $pri = $doc->createElement("price");
    $pri->appendChild($doc->createTextNode($price));
    $newElement->appendChild($pri);
    $ra = $doc->createElement("rating");
    $ra->appendChild($doc->createTextNode($rating));
    $newElement->appendChild($ra);
    $doc->save($file);
}
Example #3
0
File: mysql.php Project: rjdl/Citas
 function __construct()
 {
     global $xml, $dom, $localhost, $mysql_user, $mysql_password, $db;
     $xml = "config.xml";
     $dom = new DOMDocument();
     $dom->Load($xml);
     $localhost = $dom->getElementsByTagName('localhost')->item(0)->textContent;
     $mysql_user = $dom->getElementsByTagName('mysql_user')->item(0)->textContent;
     $mysql_password = $dom->getElementsByTagName('mysql_password')->item(0)->textContent;
     $db = $dom->getElementsByTagName('db')->item(0)->textContent;
     $query = "";
     $result = "";
 }
Example #4
0
 function install()
 {
     $doc = new DOMDocument();
     $doc->Load(dirname(__FILE__) . '/../module.xml');
     $xpath = new DOMXPath($doc);
     $xpath->registerNamespace('jelix', "http://jelix.org/ns/module/1.0");
     $query = "//jelix:module/jelix:info/jelix:version/text()";
     $entries = $xpath->evaluate($query);
     $version = $entries->item(0)->nodeValue;
     $ini = new jIniFileModifier(jApp::configPath() . 'defaultconfig.ini.php');
     $ini->setValue('version', $version, 'havefnubb');
     $ini->save();
 }
Example #5
0
 public function validateFileIntegrity($attribute, $file, $parameters)
 {
     if ($file instanceof \Symfony\Component\HttpFoundation\File\UploadedFile) {
         switch ($file->getClientMimeType()) {
             // For some reason, MP3 files routinely get scanned as octet-streams.
             // Attempt to evaluate it as music or a video.
             case "application/octet-stream":
             case "audio/mpeg":
             case "audio/mp3":
             case "video/mp4":
             case "video/flv":
             case "video/webm":
                 return FileStorage::probe($file);
             case "application/x-shockwave-flash":
                 // This is much slower than exif_imagetype but much more reliable with flash files.
                 return getimagesize($file->getPathname())['mime'] == "application/x-shockwave-flash";
             case "image/x-ms-bmp":
                 return exif_imagetype($file->getPathname()) == IMAGETYPE_BMP;
             case "image/gif":
                 return exif_imagetype($file->getPathname()) == IMAGETYPE_GIF;
             case "image/jpeg":
             case "image/jpg":
                 return exif_imagetype($file->getPathname()) == IMAGETYPE_JPEG;
             case "image/png":
                 return exif_imagetype($file->getPathname()) == IMAGETYPE_PNG;
             case "image/svg":
             case "image/svg+xml":
                 try {
                     $dom = new \DOMDocument();
                     $dom->Load($file->getPathname());
                     if ($dom->getElementsByTagName('script')->length > 0) {
                         return false;
                     }
                     return $dom->saveXML() !== false;
                 } catch (\Exception $error) {
                     return false;
                 }
                 // Things we allow but can't validate.
             // Things we allow but can't validate.
             case "application/epub+zip":
             case "application/pdf":
                 return true;
             default:
                 return false;
         }
     }
     return false;
     dd($value);
 }
 public function doTest($xmlPath, $type)
 {
     echo "\tTesting File [{$xmlPath}]\n";
     $serviceUrl = $this->client->getConfig()->serviceUrl;
     $xsdPath = "{$serviceUrl}/api_v3/index.php/service/schema/action/serve/type/{$type}";
     //		libxml_use_internal_errors(true);
     //		libxml_clear_errors();
     $doc = new DOMDocument();
     $doc->Load($xmlPath);
     //Validate the XML file against the schema
     if (!$doc->schemaValidate($xsdPath)) {
         $description = kXml::getLibXmlErrorDescription(file_get_contents($xmlPath));
         $this->fail("Type [{$type}] File [{$xmlPath}]: {$description}");
     }
 }
Example #7
0
 /**
  * retrieves the tree
  * 
  * @param boolean   clone true if tree has to be cloned
  * @return DOMXpath tree
  */
 public function getTree($clone = false, $type = Tree::TREE_DEFAULT)
 {
     /*
     TODO dit is de werkwijze van een database tree
     kijk of xml bestand bestaat en geef terug
     haal tabel op en creer xml met dom
     schrijf xml weg naar bestand
     bij een wijziging, gooi het xml bestand weg
     voer AdminTree xml functies uit (in standaard abstracte klasse..
     
     
     tree is abstract en gebruikt xml functies, implementatie gebruikt eventueel een dbConnector object.
     */
     if ($type == Tree::TREE_DEFAULT) {
         if (isset($this->tree)) {
             if (!$clone) {
                 return $this->tree;
             }
             $doc = clone $this->doc;
             return new DOMXPath($doc);
         }
     } elseif ($type == Tree::TREE_ORIGINAL) {
         if (isset($this->treeOriginal)) {
             if (!$clone) {
                 return $this->treeOriginal;
             }
             $doc = clone $this->doc;
             return new DOMXPath($doc);
         }
     }
     $doc = new DOMDocument('1.0', 'iso-8859-1');
     // We don't want to bother with white spaces
     $doc->preserveWhiteSpace = false;
     $doc->Load($this->fileName);
     $this->tree = new DOMXPath($doc);
     // create a backup of tree
     $this->treeOriginal = new DOMXpath(clone $doc);
     $this->filterTree();
     $this->doc = $doc;
     if ($type == Tree::TREE_ORIGINAL) {
         return $this->treeOriginal;
     } else {
         return $this->tree;
     }
 }
<?php

$doc = new DOMDocument();
$doc->preserveWhiteSpace = false;
$doc->Load('view.html');
$titlenode = $doc->createTextNode("Like this");
$xpath = new DOMXPath($doc);
$xpath->registerNamespace("h", "http://www.w3.org/1999/xhtml");
$query = "//h:*[@data-xp='title']/comment()";
$entries = $xpath->query($query);
foreach ($entries as $entry) {
    $entry->parentNode->replaceChild($titlenode, $entry);
}
echo $doc->saveXML();
?>

<?php 
//
//// Facade
//
//$doc = new DOMDocument;
//$doc->preserveWhiteSpace = true;
//$doc->loadHTMLFile('page/index.html');
//$xpath = new DOMXPath($doc);
//$xpath->registerNamespace("h","http://www.w3.org/1999/xhtml");
//
//$queryConnexion="//*[@id='connexion']"; //*[@id="connexion"]
//
//$entries = $xpath->query($queryConnexion);
//
//$docConnex = new DOMDocument;
Example #9
0
 function evaluateXML($xpath_query = '', $url = '')
 {
     if (empty($url)) {
         $url = $this->config->xml_data_path;
     }
     $doc = new DOMDocument();
     $doc->preserveWhiteSpace = false;
     $doc->Load($url);
     $xpath = new DOMXPath($doc);
     return $xpath->evaluate($xpath_query);
     //Array
 }
    }
    fwrite($fs, ');');
}
if (isset($_POST['check_struct_files'])) {
    getStructFilesGIT($branch, $output, $info);
    $i = 0;
    $dom = new DOMDocument();
    $dom->preserveWhiteSpace = false;
    $dom->substituteEntities = true;
    print "URL: " . $info;
    print "<br>Branch: " . $branch . "<br>";
    foreach ($output as $arr) {
        $i++;
        $xmlfile = 'xml/' . $arr[0] . '.xml';
        if (file_exists($xmlfile)) {
            $dom->Load($xmlfile);
            $tt = $dom->getElementsByTagName('file')->item(0);
            $arr["L"] = $DBCfmt[$arr[0]];
            if ($arr["L"] != $arr[1]) {
                print_r($arr);
            }
        } else {
        }
    }
}
if (isset($_POST['dbclayout'])) {
    $b_dbc = getListFiles('dbc/', 'dbc');
    $subdirs = getListSubdirs('dbc/');
    $f_w = fopen("dbclayout.xml", 'wb');
    fwrite($f_w, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n");
    fwrite($f_w, "<DBCFilesClient>\r\n");
Example #11
0
// connect to the database
include '../../config/config.php';
// confirm that the 'id' variable has been set
if (isset($_POST['category_id']) && is_numeric($_POST['category_id'])) {
    // get the 'id' variable from the URL
    $category_id = $_POST['category_id'];
    $category_name = $_POST['category_name'];
    $category_details = $_POST['category_details'];
    // update record from database
    $sql = "UPDATE tblcategory set category_name ='" . $category_name . "',category_details ='" . $category_details . "' WHERE category_id = '" . $category_id . "' LIMIT 1";
    $conn->query($sql);
    if ($conn->query($sql)) {
        $xml = new DOMDocument("1.0", "utf-8");
        $xml->formatOutput = true;
        $xml->preserveWhiteSpace = false;
        $xml->Load('../../data/category.xml');
        $root = $xml->getElementsByTagName('categories')->item(0);
        $categories = $root->getElementsByTagName('category');
        foreach ($categories as $category) {
            if ($category->getElementsByTagName('id')->item(0)->nodeValue == $category_id) {
                $category->getElementsByTagName('name')->item(0)->nodeValue = $category_name;
                $category->getElementsByTagName('details')->item(0)->nodeValue = $category_details;
            }
        }
        $xml->Save('../../data/category.xml');
        $return = array("status" => "200", "message" => "Success");
        echo json_encode($return);
    } else {
        echo "ERROR: could not prepare SQL statement.";
    }
    $conn->close();
Example #12
0
        echo $message;
    }
}
//you get the following information for each file:
// $_FILES['field_name']['name']
// $_FILES['field_name']['size']
// $_FILES['field_name']['type']
// $_FILES['field_name']['tmp_name']
// =============================================================================
// ---------------------------- END OF UPLOAD ---------------------------------
// =============================================================================
include '../../config/config.php';
$xml = new DOMDocument("1.0", "utf-8");
$xml->formatOutput = true;
$xml->preserveWhiteSpace = false;
$xml->Load('../../data/products.xml');
// $sql = "SELECT Auto_increment FROM information_schema.tables WHERE table_name='tblproduct'";
// $query = mysqli_query($conn, $sql);
// $result = mysqli_fetch_row($query);
// $id = $result[0];
$name = $_POST['product_name'];
$description = $_POST['description'];
$quantity = $_POST['quantity'];
$price = $_POST['price'];
$product_image = basename($_FILES['product_image']['name']);
$category = $_POST['category_id'];
$tags_array_string = $_POST['tags_array'];
$tags_array_id = [];
$tags_sql = '';
$stmt = $conn->prepare("INSERT INTO tblproduct (product_name,category_id,description,quantity,price,product_image) VALUES(?,?,?,?,?,?)");
$stmt->bind_param("ssssss", $name, $category, $description, $quantity, $price, $product_image);
Example #13
0
// confirm that the 'id' variable has been set
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
    // get the 'id' variable from the URL
    $id = $_GET['id'];
    // delete record from database
    if ($stmt = $conn->prepare("DELETE FROM tbluser WHERE userID = ? LIMIT 1")) {
        $stmt->bind_param("s", $id);
        $stmt->execute();
        $stmt->close();
        $return = array("status" => "200", "message" => "Success");
        echo json_encode($return);
        // delete to XML FILE
        $xml = new DOMDocument("1.0", "utf-8");
        $xml->formatOutput = true;
        $xml->preserveWhiteSpace = false;
        $xml->Load('../../data/users.xml');
        $root = $xml->getElementsByTagName('users')->item(0);
        $users = $root->getElementsByTagName('user');
        foreach ($users as $user) {
            $current_id = $user->getElementsByTagName('id')->item(0)->nodeValue;
            if ($current_id == $id) {
                $root->removeChild($user);
            }
        }
        $xml->Save('../../data/users.xml');
    } else {
        echo "ERROR: could not prepare SQL statement.";
    }
    $conn->close();
    // redirect user after delete is successful
    // header("Location: ../user_list.php");
<?php

// Step 2: Find <div class="note"> and wrap in link if found wrap in href from child edittopiclink
// This doesn't work when the DOCTYPE declaration is present, so strip that line out of the html file before handing it over to this script
if (!isset($argv) || $argc < 3) {
    die('Pass input and output file names as arguments');
}
$doc = new DOMDocument();
$doc->preserveWhiteSpace = true;
$doc->Load($argv[1]);
$xpath = new DOMXPath($doc);
$xpath->registerNamespace("x", "http://www.w3.org/1999/xhtml");
// The Sections that SKynet produces (Invalid or Unwritten topics) have the class "clicknode"
$classname = "clicknode";
$query = "//*[contains(concat(' ', normalize-space(@class), ' '), ' {$classname} ')]";
$clicknodes = $xpath->query($query);
// debug counters
$clickablecount = 0;
$linkcount = 0;
foreach ($clicknodes as $clicknode) {
    //  $editTopicLinkQuery = ".//x:a";
    //  $editTopicLinkQuery = ".//*[contains(concat(' ', normalize-space(@class), ' '), ' edittopiclink ')]";
    $editTopicLinkQuery = ".//x:a[@class='edittopiclink']";
    $editLinks = $xpath->query($editTopicLinkQuery, $clicknode);
    $clickableQuery = ".//*[contains(concat(' ', normalize-space(@class), ' '), ' clickable ')]";
    $clickables = $xpath->query($clickableQuery, $clicknode);
    $clickablecount = $clickablecount + $clickables->length;
    $linkcount = $linkcount + $editLinks->length;
    if ($clickables->length == 1) {
        if ($editLinks->length == 1) {
            /*
Example #15
0
 static function readManifest($theme)
 {
     $themesInfo = array();
     $doc = new DOMDocument();
     $doc->Load(jApp::varPath('/themes/' . $theme . '/theme.xml'));
     $xpath = new DOMXPath($doc);
     $xpath->registerNamespace(self::$ns, self::$nsURL);
     $query = '//' . self::$ns . ':info/@id';
     $entries = $xpath->query($query);
     $themeId = $entries->item(0)->nodeValue;
     $query = '//' . self::$ns . ':info/@name';
     $entries = $xpath->query($query);
     $themeName = $entries->item(0)->nodeValue;
     $query = '//' . self::$ns . ':info/@createdate';
     $entries = $xpath->query($query);
     $themeDateCreated = $entries->item(0)->nodeValue;
     $query = '//' . self::$ns . ':version/@stability';
     $entries = $xpath->query($query);
     $versionStability = $entries->item(0)->nodeValue;
     $query = '//' . self::$ns . ':version/text()';
     $entries = $xpath->query($query);
     $versionNumber = $entries->item(0)->nodeValue;
     $label = 'N/A';
     $query = '//' . self::$ns . ":label[@lang='" . jApp::config()->locale . "']/text()";
     $entries = $xpath->query($query);
     if (!is_null($entries->item(0))) {
         $label = $entries->item(0)->nodeValue;
     }
     $desc = 'N/A';
     $query = '//' . self::$ns . ":description[@lang='" . jApp::config()->locale . "']/text()";
     $entries = $xpath->query($query);
     if (!is_null($entries->item(0))) {
         $desc = $entries->item(0)->nodeValue;
     }
     $creators = array();
     $query = '//' . self::$ns . ':creator';
     $entries = $xpath->query($query);
     foreach ($entries as $entry) {
         $creatorName = '';
         $creatorNickname = '';
         $creatorEmail = '';
         $creatorActive = '';
         if ($entry->hasAttribute('name')) {
             $creatorName = $entry->getAttribute('name');
         } else {
             die("fichier theme.xml invalide");
         }
         if ($entry->hasAttribute('nickname')) {
             $creatorNickname = $entry->getAttribute('nickname');
         }
         if ($entry->hasAttribute('email')) {
             $creatorEmail = $entry->getAttribute('email');
         }
         if ($entry->hasAttribute('active')) {
             $creatorActive = $entry->getAttribute('active');
         }
         $creators[] = array('name' => $creatorName, 'nickname' => $creatorNickname, 'email' => $creatorEmail, 'active' => $creatorActive);
     }
     $query = '//' . self::$ns . ':notes';
     $entries = $xpath->query($query);
     $notes = 'N/A';
     if (!is_null($entries->item(0))) {
         $notes = $entries->item(0)->nodeValue;
     }
     $updateURL = '';
     $query = '//' . self::$ns . ':updateURL/text()';
     $entries = $xpath->query($query);
     $updateURL = $entries->item(0)->nodeValue;
     $homepageURL = '';
     $query = '//' . self::$ns . ':homepageURL/text()';
     $entries = $xpath->query($query);
     $homepageURL = $entries->item(0)->nodeValue;
     $licence = '';
     $query = '//' . self::$ns . ':licence/text()';
     $entries = $xpath->query($query);
     $licence = $entries->item(0)->nodeValue;
     $licenceURL = '';
     $query = '//' . self::$ns . ':licence/@URL';
     $entries = $xpath->query($query);
     $licenceURL = $entries->item(0)->nodeValue;
     $copyright = '';
     $query = '//' . self::$ns . ':copyright/text()';
     $entries = $xpath->query($query);
     $copyright = $entries->item(0)->nodeValue;
     $themesInfo = array('name' => strtolower($themeName), 'id' => $themeId, 'version' => $versionStability . ' ' . $versionNumber, 'dateCreate' => $themeDateCreated, 'label' => $label, 'desc' => $desc, 'creators' => $creators, 'updateURL' => $updateURL, 'homepageURL' => $homepageURL, 'licence' => $licence, 'licenceURL' => $licenceURL, 'copyright' => $copyright);
     return $themesInfo;
 }
/**
 * function parse_file
 * Takes an individual file and:
 * - Checks for additional triples that should be ascribed to all such files
 * - Searches through all the questions
 * - Creates variables for each (Data Cube Measures)
 * - Hands off the code-list data to be processed in more detail
 * 
 * $filename should be a relative or absolute path to the file to process
 * $context should be an array of additional triples to be added to the file record and to each question. 
 */
function parse_file($filename, $name, $context, $ns, &$questions, &$codelists)
{
    //We need our models to be accessible
    include "models.php";
    $dom = new DOMDocument();
    $dom->preserveWhiteSpace = false;
    $dom->Load($filename);
    $xpath = new DOMXPath($dom);
    $xpath->registerNamespace("s", "ddi:studyunit:3_0");
    $xpath->registerNamespace("l", "ddi:logicalproduct:3_0");
    $variables = $dom->getElementsByTagName("Variable");
    foreach ($variables as $variable) {
        $var_name = $variable->getElementsByTagName("Name")->item(0)->nodeValue;
        log_message(" - variable: {$var_name}");
        $var_label = $variable->getElementsByTagName("Label")->item(0)->nodeValue;
        $model_var = new Resource($ns['var'] . $var_name);
        $questions->add(new Statement($model_var, $RDF_type, $QB_MeasureProperty));
        $questions->add(new Statement($model_var, $RDF_type, $RDF_Property));
        $questions->add(new Statement($model_var, $RDFS_label, new Literal($var_label, "en")));
        $questions->add(new Statement($model_var, $RDFS_subPropertyOf, $SDMX_obsValue));
        //Add our additional triples in from here
        foreach (array_merge((array) $context['*'], (array) $context[$name]) as $additional) {
            if (!strpos($additional['s'], "http")) {
                $additional_predicate_parts = explode(":", $additional['s']);
                $additional_predicate = new Resource(($ns[$additional_predicate_parts[0]] ? $ns[$additional_predicate_parts[0]] : "http://localhost/ns0/") . $additional_predicate_parts[1]);
            } else {
                $additional_predicate = new Resource($additional['s']);
            }
            if (!strpos($additional['o'], "http")) {
                $additional_object = new Resource($additional['o']);
            } else {
                $additional_object = new Literal($additional['o']);
            }
            $questions->add(new Statement($model_var, $additional_predicate, $additional_object));
        }
    }
    //End foreach($variables as $variable)
}
Example #17
0
    $loadConfigAfterUpload = true;
}
$doc = new DOMDocument();
print "Opening/downloading original configuration ";
//
// What kind of config input do we have.
//     File or API ?
//
$configInput = PH::processIOMethod($configInput, true);
if ($configInput['status'] == 'fail') {
    fwrite(STDERR, "\n\n**ERROR** " . $configInput['msg'] . "\n\n");
    exit(1);
}
if ($configInput['type'] == 'file') {
    print "{$configInput['filename']} ... ";
    $doc->Load($configInput['filename']);
} elseif ($configInput['type'] == 'api') {
    if ($debugAPI) {
        $configInput['connector']->setShowApiCalls(true);
    }
    print "{$configInput['connector']->apihost} ... ";
    if (!isset($configInput['filename']) || $configInput['filename'] == '' || $configInput['filename'] == 'candidate-config') {
        $doc = $configInput['connector']->getCandidateConfig();
    } elseif ($configInput['filename'] == 'running-config') {
        $doc = $configInput['connector']->getRunningConfig();
    } else {
        $doc = $configInput['connector']->getSavedConfig($configInput['filename']);
    }
} else {
    derr('not supported yet');
}
Example #18
0
    $job = new job($r0->ID);
    if ($job->polling != 0 && $job->lastRun < time() - $job->polling) {
        if (!is_file(get_ini('UPLOAD_FOLDER') . 'queue/' . $job->pluginName . '_' . $job->page . '.xml') && !is_file(get_ini('UPLOAD_FOLDER') . 'running/' . $job->pluginName . '_' . $job->page . '.xml')) {
            $job->flagRunning();
            include 'plugins/' . $job->pluginName . '/task_' . $job->page . '_loader.php';
        }
    }
}
// List all job to do in the queue folder
foreach (glob(get_ini('UPLOAD_FOLDER') . "queue/*.xml") as $jobName) {
    $fileFullPath = str_replace('\\', '/', $jobName);
    $jobName = substr($jobName, strrpos($jobName, '/') + 1, strlen($jobName) - strrpos($jobName, '/') - 1);
    // Valid the xml file with XSD
    $domXmlFile = new DOMDocument();
    $domXmlFile->preserveWhiteSpace = false;
    $domXmlFile->Load(get_ini('UPLOAD_FOLDER') . 'queue/' . $jobName);
    if ($domXmlFile->schemaValidate('plugins/core/xsd/core.xsd')) {
        if ($procM->getId($jobName) == 0) {
            $childProcId = $procM->create(0, $jobName, '', 10);
            usleep(500);
            if ($procM->getCount($jobName) > 1) {
                // Wait some millisecond to avoid concurent write
                usleep(mt_rand(100, 20000));
                if ($procM->getCount($jobName) > 1) {
                    $procM->delete($childProcId);
                    exit(0);
                }
            }
            echo _('#core#_#18#') . ' ' . $jobName . '.<BR>';
            $proc = new processus($childProcId);
            $procM->update($proc->id, 'running', '2');
Example #19
0
$doc->preserveWhiteSpace = false;
$doc->Load('users.xml');
$xpath = new DOMXPath($doc);
$ids = $xpath->query("//user[name/text()='" . $_POST['username'] . "' and password/text()='" . $_POST['password'] . "']/id");
$userId = 0;
if ($ids == False) {
    echo 'Incompatible XPath key, either ' . $_POST['username'] . ' or ' . $_POST['password'];
} else {
    foreach ($ids as $id) {
        $userId = $id->nodeValue;
        break;
    }
    if ($userId == 0) {
        echo 'The User was not found.';
    } else {
        $doc2 = new DOMDocument();
        $doc2->preserveWhiteSpace = false;
        $doc2->Load('users.xml');
        $xpath2 = new DOMXPath($doc2);
        $names = $xpath2->query("//user[id/text()='" . $userId . "']/name");
        foreach ($names as $name) {
            echo 'You have logged in as ' . $name->nodeValue . ' with id ' . $userId . '.';
            break;
        }
    }
}
?>

	</body>
</html>
    exit(1);
}
// Build the proc class for this process
$procM = new processusManager();
$proc = new processus($processId);
$procM->update($proc->id, 'running', 1);
// Wait 500ms before moving the processing file
usleep(500000);
if (file_exists(get_ini('UPLOAD_FOLDER') . 'running/' . $proc->cmd)) {
    unlink(get_ini('UPLOAD_FOLDER') . 'running/' . $proc->cmd);
}
rename(get_ini('UPLOAD_FOLDER') . 'queue/' . $proc->cmd, get_ini('UPLOAD_FOLDER') . 'running/' . $proc->cmd);
// Valid the xml file with XSD
$domXmlFile = new DOMDocument();
$domXmlFile->preserveWhiteSpace = false;
$domXmlFile->Load(get_ini('UPLOAD_FOLDER') . 'running/' . $proc->cmd);
if ($domXmlFile->schemaValidate('plugins/core/xsd/core.xsd')) {
    // Get header data
    $item_XML = $domXmlFile->getElementsByTagName('XML')->item(0);
    $item_HEADER = $item_XML->getElementsByTagName('HEADER')->item(0);
    $item_DATA = $item_XML->getElementsByTagName('DATA')->item(0);
    // Set timeout both on execution script and in the database
    set_time_limit($item_HEADER->getElementsByTagName('TIMEOUT')->item(0)->nodeValue);
    $q0 = get_link()->prepare('UPDATE ' . get_ini('BDD_PREFIX') . 'core_processus SET timeout=:timeout WHERE id=:id');
    $q0->execute(array('timeout' => time() + $item_HEADER->getElementsByTagName('TIMEOUT')->item(0)->nodeValue, 'id' => $proc->id));
    // Include the file we need
    $g = $item_HEADER->getElementsByTagName('PLUGIN')->item(0)->nodeValue;
    $p = $item_HEADER->getElementsByTagName('PAGE')->item(0)->nodeValue;
    // Get the date
    $xmlDate = toTime($item_HEADER->getElementsByTagName('DATE')->item(0)->nodeValue);
    // If the Xsd file exist
Example #21
0
             $_SESSION['registerMessage'] = $registerMessage;
         }
     }
 }
 // else if (mysqli_num_rows($result) > 0) {
 // 	$registerMessage = "The email you entered is already registered.";
 // 	$_SESSION['registerMessage'] = $registerMessage;
 // }
 if (!isset($registerMessage)) {
     mysqli_query($conn, "INSERT INTO tblUser (firstName, middleName, lastName, contactNo, email, userPass, userTypeID, userName, birthdate, address) \n\t\t\t\t\t\t  VALUES ('{$firstName}', '{$middleName}', '{$lastName}', '{$contact}', '{$email1}', '{$password1}', '3', 'guest', '{$birthdate}' , '{$address}')");
     $id = mysqli_insert_id($conn);
     // CREATE AN XML DATA
     $xml = new DOMDocument("1.0", "utf-8");
     $xml->formatOutput = true;
     $xml->preserveWhiteSpace = false;
     $xml->Load('data/users.xml');
     $new_user = $xml->createElement("user");
     $new_user->appendChild($xml->createElement('id', $id));
     $new_user->appendChild($xml->createElement('firstname', $firstName));
     $new_user->appendChild($xml->createElement('middlename', $middleName));
     $new_user->appendChild($xml->createElement('lastname', $lastName));
     $new_user->appendChild($xml->createElement('contact', $contact));
     $new_user->appendChild($xml->createElement('address', $address));
     $new_user->appendChild($xml->createElement('email', $email1));
     $new_user->appendChild($xml->createElement('birthdate', $birthdate));
     $xml->getElementsByTagName('users')->item(0)->appendChild($new_user);
     $xml->Save('data/users.xml');
     // =============================
     $registerMessage = "Your have successfully created a new account.<br><a href='index.php'>Log In </a>";
     $_SESSION['registerMessage'] = $registerMessage;
 }
Example #22
0
$time_start = microtime(true);
if (!isset($_GET['server'])) {
    $SNPServer = $SNPGraphServerId;
} else {
    $SNPServer = $_GET['server'];
}
if (!isset($_GET['version'])) {
    $SNPversion = 2;
} else {
    $SNPversion = $_GET['version'];
}
header("Content-Type: text/plain");
// Opening CNML source
$cnml = new DOMDocument();
$cnml->preserveWhiteSpace = false;
$cnml->Load('../data/guifi.cnml');
$time_s = microtime(true);
// Validate the graph server
$xpath = new DOMXPath($cnml);
$query = "//service[@id=" . $SNPServer . " and @type='SNPgraphs']";
$entries = $xpath->evaluate($query);
// print count($servers);
if (count($entries) == 0) {
    echo "You must provide a valid server id\n";
    exit;
}
$arr = array();
$time_x = microtime(true);
// Query for zones with the given graph server
$xpath = new DOMXPath($cnml);
$query = "//zone[@graph_server=" . $SNPServer . "]";
Example #23
0
$action = $_POST['souhait'];
// SERVER TO DATABASE - XQUERY
// create session
/*$session = new Session("localhost", 1984, "admin", "admin");
  switch ($action) {
      case "matieres":
          $query = "doc('C:\Program Files (x86)\BaseX\MDSI_Database\matiere.xml')//matiere" ;
          break;
      case "enseignants":
          $query = "doc('C:\Program Files (x86)\BaseX\MDSI_Database\enseignant.xml')//enseignant" ;
          break;
  }
  
  $result = $session->query($query);*/
$doc = new DOMDocument();
$doc->Load('C:\\Program Files (x86)\\BaseX\\MDSI_Database\\matiere.xml');
$xpath = new DOMXPath($doc);
// Nous commençons à l'élément racine
$query = '//matiere';
$entries = $xpath->query($query);
//SERVER TO CLIENT - XSL TRANSFORMATION
$xslDoc = new DOMDocument();
$xslDoc->load('C:\\Program Files (x86)\\BaseX\\MDSI_Database\\index.xsl');
$doc = new DOMDocument();
$root = $doc->appendChild($doc->createElement('matieres'));
$i = 0;
while ($matiere = $entries->item($i++)) {
    $node = $doc->importNode($matiere, true);
    $root->appendChild($node);
}
$doc->save('tempDoc.xml');
Example #24
0
} else {
    include_once "../common/config.php.template";
}
include_once "../common/misc.php";
if (isset($_GET['nodes'])) {
    $nodes = $_GET['nodes'];
} else {
    // for testing purposes, filling the query with a fixed list
    // $nodes = '3682,2673,2653,4675,5887,6362,5531,2201,5452,3310,6446,5506,5836,5846,6032,4631,6093,3718,6530,3725,3833,4030,4120,3998,5519,5525,6038,6173,6228,6298,2784,6601,6703,1636,4796,5486,5765,5784,5816,5046,4720,6199,6291,6555,6549,6596,6616,6659,6732,2984';
    die('Error: At least one node has to be given to the query as a parameter. Syntax: qnodes?nodes=1,2,3,4,5');
}
$an = explode(',', $nodes);
// Opening CNML source
$doc = new DOMDocument();
$doc->preserveWhiteSpace = false;
$doc->Load('../data/guifi.cnml');
// building the xpath query for requested nodes
$xpath = new DOMXPath($doc);
$query = '//node[@id=' . implode(' or @id=', $an) . ']';
$entries = $xpath->query($query);
// Creating output CNML document
$docout = new DOMDocument('1.0');
// we want a nice output
$docout->formatOutput = true;
$root = $docout->createElement('cnml');
$root = $docout->appendChild($root);
// CNML attributes
// TODO: Support for multi-site DATA servers, now creatied with fixed values
$cVersion = $docout->createAttribute('version');
$root->appendChild($cVersion);
$cVersion->appendChild($docout->createTextNode('0.1'));
Example #25
0
<?php

// Provide path to MODS XML file via command line or
// via GET request.
if (PHP_SAPI === 'cli') {
    $modsXMLPath = $argv[1];
} else {
    $modsXMLPath = $_GET['modsXMLPath'];
}
// For nicer error messages see Mark A.'s note on
// http://php.net/manual/en/domdocument.schemavalidate.php
$xml = new DOMDocument();
$xml->Load($modsXMLPath);
if ($xml->schemaValidate('mods-3-5.xsd')) {
    echo "This document is valid MODS.\n";
}
 function LoadJsonCountriesCoordinates($action = 'ViewDeploymentsPerRegion')
 {
     $doc = new DOMDocument();
     // We don't want to bother with white spaces
     $doc->preserveWhiteSpace = false;
     $dir = dirname(__FILE__);
     $doc->Load($dir . '/data/countries.xml');
     $xpath = new DOMXPath($doc);
     // We starts from the root element
     $query = "//country";
     $entries = $xpath->query($query);
     $json_data = 'var countries_data = [];';
     foreach ($entries as $entry) {
         $code = $entry->attributes->item(2)->nodeValue;
         $lat_lng = $entry->attributes->item(14)->nodeValue;
         $lat_lng = @explode(',', $lat_lng);
         if (count($lat_lng) != 2) {
             continue;
         }
         $lat = $lat_lng[0];
         $lng = $lat_lng[1];
         $link = $this->owner->Link($action) . '?country=' . $code;
         $json_data .= "countries_data[\"" . $code . "\"] = { lat: " . $lat . " , lng :" . $lng . ", url: '" . $link . "'};";
     }
     return $json_data;
 }
Example #27
0
<?php

include '../../config/config.php';
$xml = new DOMDocument("1.0", "utf-8");
$xml->formatOutput = true;
$xml->preserveWhiteSpace = false;
$xml->Load('../../data/tags.xml');
// $sql = "SELECT Auto_increment FROM information_schema.tables WHERE table_name='tbltag'";
// $query = mysqli_query($conn, $sql);
// $result = mysqli_fetch_row($query);
$name = $_POST['tag_name'];
$stmt = $conn->prepare("INSERT INTO tbltag (tag_name) VALUES(?)");
$stmt->bind_param("s", $name);
$stmt->execute();
$id = mysqli_insert_id($conn);
$new_tag = $xml->createElement("tag");
$new_tag->appendChild($xml->createElement('id', $id));
$new_tag->appendChild($xml->createElement('name', $name));
$xml->getElementsByTagName('tags')->item(0)->appendChild($new_tag);
$xml->Save('../../data/tags.xml');
header('Location: ../tag_list.php');
Example #28
0
 private function GetServiceNamespace($url)
 {
     $doc = new DOMDocument();
     $doc->Load($url);
     $xpath = new DOMXPath($doc);
     $query = "/*/@targetNamespace";
     $attrs = $xpath->query($query);
     // The query will return only one node in the node list.
     foreach ($attrs as $attr) {
         $namespace = $attr->value;
     }
     return $namespace;
 }