Ejemplo n.º 1
0
//we should quit with an error.
$limit_by_source = isset($_REQUEST[SOURCE]);
if ($limit_by_source) {
    $source = get_node_or_exit(SOURCE);
} else {
    $source = NODE_NAME_WILDCARD;
}
$limit_by_label = isset($_REQUEST[LABEL]);
if ($limit_by_label) {
    $label = get_node_or_exit(LABEL);
} else {
    $label = NODE_NAME_WILDCARD;
}
$limit_by_destination = isset($_REQUEST[DESTINATION]);
if ($limit_by_destination) {
    $destination = get_node_or_exit(DESTINATION);
} else {
    $destination = NODE_NAME_WILDCARD;
}
$node_array = array();
function node_info_with_edge($edge, $back_index)
{
    $node = array();
    $node[EDGE] = $edge;
    $path_elements = explode(PATH_SEPARATOR, $edge);
    $name_index = count($path_elements) + $back_index;
    $name = $path_elements[$name_index];
    $node[NAME] = $path_elements[$name_index];
    $node[PATH] = node_path_with_name($name);
    return $node;
}
Ejemplo n.º 2
0
<?php

//SUMMARY: Given an HTTP request with the names of the source, label, and destination nodes,
//this PHP script checks that a directory with the same name as label
//and a symbolic link to the destination directory in that directory exists
//and, if so, removes the link. If the directory is then empty, it removes the directory.
require_once 'includes/consts.php';
require_once 'includes/exit_with_error_json.php';
require_once 'includes/get_node_or_exit.php';
require_once 'includes/delete_edges_with.php';
$name = get_node_or_exit(NAME);
//Delete all edges in which this node has any role.
delete_edges_with($name, '*', '*');
delete_edges_with('*', $name, '*');
delete_edges_with('*', '*', $name);
//Delete the contents of the node directory.
$node_path = NODE_PATH . $name;
$files = scandir($node_path);
foreach ($files as $file) {
    //Skip over the loopback link to the directory itself and the parent directory backlink.
    if ($file == '.' || $file == '..') {
        continue;
    }
    //Create the path to the file relative to our current directory.
    $file_path = $node_path . '/' . $file;
    //For now, we only try to delete files instead of looking for non-label directories and trying to delete them recursively.
    if (is_file($file_path)) {
        if (!unlink($file_path)) {
            $unlink_error = error_get_last();
            exit_with_error_json("Deletion of file \"" . $file_path . "\" failed: " . $unlink_error['message']);
        }