示例#1
0
function showXmlTree($sys_id)
{
    global $par, $a3pr;
    global $expand;
    global $expand2;
    $g_path = $par['path'];
    $link_from_sid = $par['a3_link_from_sid'];
    $link_from_object = $par['a3_link_from_object'];
    $index = $a3pr[$sys_id]['a3_index'];
    $index2 = $a3pr[$sys_id]['a3_index2'];
    $show_all = $a3pr[$sys_id]['a3_show_all'];
    if (!$show_all) {
        $show_all = '<';
    }
    // Set expand path
    $tok = strtok($index, ".");
    $expand[1] = $tok;
    $ii = 2;
    while ($tok !== false) {
        $tok = strtok(".");
        $expand[$ii] = $tok;
        $ii++;
    }
    $tok = strtok($index2, ".");
    $expand2[1] = $tok;
    $ii = 2;
    while ($tok !== false) {
        $tok = strtok(".");
        $expand2[$ii] = $tok;
        $ii++;
    }
    $sel = $a3pr[$sys_id]['a3_object'];
    $from = $a3pr[$sys_id]['a3_from'];
    $from_father = $a3pr[$sys_id]['a3_from_father'];
    $to = $a3pr[$sys_id]['a3_to'];
    $user = $par['user'];
    $db_name = $a3pr[$sys_id]['a3_db'];
    $ix = array();
    $level = 0;
    if ($db_name) {
        $file = getXmlFileName($db_name);
    } else {
        echo "No database selected";
        //exit();
    }
    $dom = new DOMDocument();
    $dom->load($file);
    $xpath = new DOMXPath($dom);
    $question = "//object";
    //database
    $elements = $xpath->query($question);
    foreach ($elements as $element) {
        $attr_name = $element->attributes->getNamedItem("name")->nodeValue;
        $attr_id = $element->attributes->getNamedItem("id")->nodeValue;
        $attr_type = $element->attributes->getNamedItem("type")->nodeValue;
        if ($attr_id == 1 && $attr_type == 'node') {
            echo "<a href=\"{$g_path}&a3_sid={$sys_id}&a3_object_id={$attr_id}&a3_object_name={$attr_name}\">{$attr_name}</a>";
            if ($link_from_object == 1 && $link_from_sid == $sys_id) {
                echo " F";
            }
            echo "<a href=\"{$g_path}&a3_sid={$sys_id}&p1=show_all\"> {$show_all}</a>";
            if ($user && $sel == $attr_id && $from && $from != $sel) {
                echo "<a href=\"{$g_path}&a3_sid={$sys_id}&a3_object_id={$attr_id}&index={$index}&p1=to&p2={$attr_id}\"> M</a>";
            }
            echo "<br>";
            if ($show_all == '<') {
                $image = getNodeValue($db_name, $attr_id, 'void', 'type', 'image');
                if ($image != 'void') {
                    echo "<br><img src=\"{$image}\" height=\"50\" alt=\"image error\"/>";
                }
                $text = getNodeValue($db_name, $attr_id, 'void', 'type', 'text');
                if ($text != 'void') {
                    echo "{$text}";
                }
            }
            traverse($sys_id, $g_path, $element, $level, 1, $ix, $expand, $expand2, $attr_id);
        }
    }
}
示例#2
0
define("T_4_USER_LOGGED_OUT", "Logged Out!");
define("T_4_USERNAME", "Username");
define("T_4_PASSWORD", "Password");
define("T_4_USER", "User");
define("T_4_PSWD", "Pswd");
// Declarations =====================================
// Always use database: users
$_SESSION['a4_db'] = 'users';
// read SESSION parameters ===============================
$sel_db = $_SESSION['a4_db'];
$sel_object = $_SESSION['a4_object_id'];
$sel_name = $_SESSION['a4_object_name'];
$super = $_SESSION['super'];
$par['super'] = $super;
// Initiate database if necessary
$file = getXmlFileName($sel_db);
if (!file_exists($file)) {
    createDb($sel_db, 4);
    $sel_object = 1;
    $_SESSION['a4_db'] = $sel_db;
    $_SESSION['a4_object'] = $sel_object;
    echo "Database initiated !";
    $user_id = getNextNodeId($sel_db);
    createObject($sel_db, 1, 'admin', $user_id);
    // Admin username
    setObjectText($sel_db, $user_id, 'amazon');
    // default password
}
// GET ==============================================
$temp = $_GET['a4_object_id'];
if ($temp) {
示例#3
0
function createObject($db_name, $father_id, $object_name, $object_id)
{
    //echo("CreateObject - $db_name,$father_id,$object_name");
    $file = getXmlFileName($db_name);
    $dom = new DOMDocument();
    $dom->load($file);
    $xpath = new DOMXPath($dom);
    if ($father_id == 1) {
        $question = "//object";
    } else {
        $question = "//object";
    }
    $objects = $xpath->query($question);
    foreach ($objects as $object) {
        $f_id = $object->getAttribute('id');
        $f_type = $object->getAttribute('type');
        //echo("  $f_id == $father_id");
        if ($f_id == $father_id && $f_type == 'node') {
            // Create the node
            $child = $dom->createElement("object", "");
            $new_object = $object->appendChild($child);
            $new_object->setAttribute('name', $object_name);
            $new_object->setAttribute('id', $object_id);
            $new_object->setAttribute('type', 'node');
            // Create the subnode: text
            $subchild = $dom->createElement("object", "");
            $temp = $child->appendChild($subchild);
            $temp->setAttribute('name', $object_name);
            $temp->setAttribute('id', $object_id);
            $temp->setAttribute('type', 'text');
            // Create the subnode: image
            $subchild = $dom->createElement("object", "");
            $temp = $child->appendChild($subchild);
            $temp->setAttribute('name', $object_name);
            $temp->setAttribute('id', $object_id);
            $temp->setAttribute('type', 'image');
            // Create the subnode: file
            $subchild = $dom->createElement("object", "");
            $temp = $child->appendChild($subchild);
            $temp->setAttribute('name', $object_name);
            $temp->setAttribute('id', $object_id);
            $temp->setAttribute('type', 'file');
        }
    }
    $dom->save($file);
}