Exemplo n.º 1
0
function get_client_time($file)
{
    $array = read_yaml($file);
    if (isset($array['timestamp'])) {
        $ret = $array['timestamp'];
    } else {
        $ret = 0;
    }
    return $ret;
}
function smarty_function_navtree($args)
{
    global $PATH;
    global $ROOT;
    $tree_file = "{$ROOT}/data/navtree.yaml";
    $tree = read_yaml($tree_file);
    $short_path = preg_replace("," . $_SERVER['PATH_INFO'] . "\$,", '', $PATH);
    show_roots($tree);
    set_show($tree, $short_path);
    #header("content-type: text/plain");
    #print_r($tree);
    #exit;
    return render_navtree($tree);
}
function smarty_function_autoindex($args)
{
    global $ROOT;
    global $PATH;
    $file = $args['file'];
    $tree = read_yaml($ROOT . "/data/{$file}");
    $short_path = preg_replace("," . $_SERVER['PATH_INFO'] . "\$,", '', $PATH);
    $list = array();
    $node = find_node_path($tree, $short_path);
    if ($node == NULL) {
        return "ERROR: Could not find data for autoindex";
    }
    build_autoindex_array($node, $list);
    return render_autoindex($list);
}
Exemplo n.º 4
0
function read_worksheet($out, $file, $options = array())
{
    $ext = pathinfo($file, PATHINFO_EXTENSION);
    if (isset($options["read"]) && $options["read"] != $ext) {
        fputs(STDERR, "Warning: The file extension was ignored to adopt {$options["read"]}.\n");
        $ext = $options["read"];
    }
    switch (strtolower($ext)) {
        case "raw":
            $in = fopen($file, "r");
            while (($line = fgets($in)) !== false) {
                fputs($out, $line);
            }
            fclose($in);
            break;
        case "csv":
            $options["delimiter"] = ",";
            read_csv($out, $file, $options);
            break;
        case "tsv":
            $options["delimiter"] = "\t";
            read_csv($out, $file, $options);
            break;
        case "xlsx":
            read_excel($out, $file, $options);
            break;
        case "json":
            read_json($out, $file, $options);
            break;
        case "yml":
        case "yaml":
            read_yaml($out, $file, $options);
            break;
        case "xml":
            read_xml($out, $file, $options);
            break;
        default:
            print "Error[{$ext}]: No reader is available.\n";
            break;
    }
    return;
}
Exemplo n.º 5
0
<?php

require 'util.php';
$out = read_yaml(AUTODEFLECT_ROOT . '/site.yml');
if (isset($_GET["pretty"])) {
    echo json_encode($out, JSON_PRETTY_PRINT);
} else {
    echo json_encode($out);
}
/*******************************************************/