function add_container($id, $path, $type)
{
    global $oldPath;
    global $oldSite, $newSite;
    global $readClient, $writeClient;
    global $added;
    global $verbose;
    global $exit_on_error;
    #
    # have we already checked container *and* children?
    #
    if (isset($added["{$type}.{$group}"])) {
        return;
    } else {
        $added["{$type}.{$path}"] = 1;
    }
    #if ($verbose>2) echo "Adding $type $path...\n";
    #
    # create the container
    #
    if ($type == 'target') {
        checkTarget($path);
    } else {
        checkContainer($id, $path, $type);
    }
    #
    # and its children
    #
    if (isset($id)) {
        $ident->id = $id;
    }
    $ident->path = $path;
    $ident->siteName = $oldSite;
    $ident->type = strtolower($type);
    $readClient->read($ident);
    if (!$readClient->success) {
        echo "Failed reading: {$type} " . $path . "\n";
        echo print_r($ident);
        echo cleanup($readClient->response);
        if ($exit_on_error) {
            cleanexit();
        } else {
            return;
        }
    }
    $asset = $readClient->asset;
    if (isset($asset->{$type}->children) && isset($asset->{$type}->children->child)) {
        $children = $asset->{$type}->children->child;
        if (!is_array($children)) {
            $children = array($children);
        }
    } else {
        $children = "";
    }
    #
    # types of things we find in containers
    #
    $types = array("assetFactoryContainer", "pageConfigurationSetContainer", "contentTypeContainer", "dataDefinitionContainer", "metadataSetContainer", "publishSetContainer", "siteDestinationContainer", "transportContainer", "workflowDefinitionContainer", "assetFactory", "pageConfigurationSet", "contentType", "dataDefinition", "metadataSet", "publishSet", "destination", "target", "transport", "workflowDefinition", "connectorContainer", "twitterConnector", "wordPressConnector", "googleAnalyticsConnector");
    $names['transport_db'] = 'transport';
    $names['transport_fs'] = 'transport';
    $names['transport_ftp'] = 'transport';
    foreach ($types as $type) {
        $names[strtolower($type)] = $type;
    }
    if (is_array($children)) {
        while ($cur = array_pop($children)) {
            if (array_key_exists($cur->type, $names)) {
                if (preg_match('/container$/', $cur->type)) {
                    add_container($cur->id, $cur->path->path, $names[$cur->type]);
                } else {
                    if ($cur->type == 'target') {
                        checkTarget($cur->path->path);
                        add_container($cur->id, $cur->path->path, $names[$cur->type]);
                    } else {
                        checkAdminAsset($cur->id, $cur->path->path, $names[$cur->type]);
                    }
                }
            } else {
                echo "Oops: don't know what to do with " . $cur->type . " " . $cur->path->path . "\n";
            }
        }
    }
}
Пример #2
0
<?php

error_log("Inside put handler", 4);
$fs = (require_once '/app/init.php');
if ($_SERVER['REQUEST_METHOD'] != 'PUT') {
    header("HTTP/1.1 403 Bad request");
    exit;
}
function checkTarget($target)
{
    error_log("Target = " . $target . "\n");
    return $target == "data/data.json";
}
$prefix = '/';
$path = $_SERVER["REQUEST_URI"];
$path = substr($path, strlen($prefix));
if (!checkTarget($path)) {
    header("HTTP/1.1 404 Not found");
    exit;
}
/* PUT data comes in on the stdin stream */
$putdata = fopen("php://input", "r");
$fs->putStream($path, $putdata);