Exemplo n.º 1
0
 $client = new ThriftHiveClient($protocol);
 $transport->open();
 //$client->execute('add jar '.$env['hive_jar']);
 $client->execute('use ' . $_GET['database']);
 echo '<div class="container">';
 if (!@$_GET['table']) {
     die($lang['dieTableChoose']);
 } else {
     echo "<a href=dbStructure.php?database=" . $_GET['database'] . "><i class=icon-backward></i> " . $lang['back'] . "</a><br><br>";
     if (!@$_POST['submit']) {
         $sql = 'desc formatted ' . $_GET['table'];
         $client->execute($sql);
         $array_desc_table = $client->fetchAll();
         //get table description and explode the desc into a multi-dimensional array
         //获取表说明,并放入二维数组$array_desc_desc
         $etc = new Etc();
         $array_desc_table_1 = $etc->GetTableDetail($array_desc_table, "1");
         $array_desc_table_4 = @$etc->GetTableDetail($array_desc_table, "4");
         $selected = " ";
         $type = array('string' => 'String', 'tinyint' => 'Tiny int(3)', 'smallint' => 'Small int(5)', 'int' => 'Int(10)', 'bigint' => 'Big int(19)', 'double' => 'Double', 'float' => 'Float', 'boolean' => 'Boolean');
         $i = 0;
         while ('' != @$array_desc_table_1[$i]) {
             $array_desc_1 = explode('	', $array_desc_table_1[$i]);
             $array_desc_desc_1[$i]['name'] = $array_desc_1[0];
             $array_desc_desc_1[$i]['type'] = $array_desc_1[1];
             $array_desc_desc_1[$i]['comment'] = $array_desc_1[2];
             $i++;
         }
         echo $lang['alterTableWarning'];
         echo "<form method=post>";
         echo "<table class=\"table table-bordered table-condensed\">";
Exemplo n.º 2
0
<?php

ignore_user_abort(true);
set_time_limit(0);
include_once 'config.inc.php';
$etc = new Etc();
$auth = new Authorize();
if (!$_GET['database'] || '' == $_GET['database']) {
    die($lang['dieTableChoose']);
} else {
    include_once 'templates/style.css';
    //echo '<div class="container">';
    //echo '<div class="span1">';
    //echo '</div>';
    //echo '<div class="span10">';
    echo '<br />' . $_GET['database'] . '<i class=icon-backward></i>  <a href=dbStructure.php?database=' . $_GET['database'] . ' target="right">' . $lang['back'] . '</a><br /><br />';
    include_once 'templates/sql_query_navi.html';
    echo "<br /><br />";
    $transport = new TSocket(HOST, PORT);
    $protocol = new TBinaryProtocol($transport);
    $client = new ThriftHiveClient($protocol);
    $transport->open();
    $sql = 'use `' . $_GET['database'] . '`';
    //echo $sql.'<br /><br />';
    $client->execute($sql);
    //$client->fetchOne();
    $sql = 'desc formatted ' . $_GET['table'];
    $client->execute($sql);
    $array_desc_table = $client->fetchAll();
    $array_desc_table_1 = $etc->GetTableDetail($array_desc_table, "1");
    $array_desc_table_4 = @$etc->GetTableDetail($array_desc_table, "4");
Exemplo n.º 3
0
<?php

include_once 'config.inc.php';
include_once 'templates/style.css';
if (!@$_GET['path']) {
    $path = "/";
} else {
    $path = $_GET['path'];
}
$etc = new Etc();
$sql = '"dfs -ls ' . $path . '"';
$LANG = 'export LANG=' . $env['lang_set'] . '; ';
$HADOOP_HOME = 'export HADOOP_HOME=' . $env['hadoop_home'] . '; ';
$HIVE_HOME = 'export HIVE_HOME=' . $env['hive_home'] . '; ';
$JAVA_HOME = 'export JAVA_HOME=' . $env['java_home'] . '; ';
$UDF = $env['udf'] != "" ? $env['udf'] : "";
$exec = $LANG . $HADOOP_HOME . $HIVE_HOME . $JAVA_HOME . $env['hive_home'] . '/bin/hive ' . $UDF . ' -e ' . $sql;
$time = time();
$filename = $env['output_path'] . '/dfs_browse.' . $time . '.out';
$etc->NonBlockingRun($exec, $time, $filename, 1, $code);
$list_arr = file($filename);
echo '<div class="container">';
echo '<div class="span10">';
echo "<br>";
echo '<div class="btn-group">';
echo "<a class=\"btn btn-info\" href=fileBrowser.php?dir=/><i class=icon-eject></i>" . $lang['backToRoot'] . "</a>";
echo "<a class=\"btn btn-info\" href=javascript:history.back()><i class=icon-backward></i>" . $lang['back'] . "</a>";
echo "</div><br>";
echo "<table class=\"table table-bordered table-striped table-hover\">";
echo "<tr class=success>";
echo "<td>" . $lang['fileProperty'] . "</td>";
Exemplo n.º 4
0
<?php

ignore_user_abort(true);
set_time_limit(0);
include_once "config.inc.php";
$etc = new Etc();
$query = @$_GET['query'];
$time = @$_GET['time'];
if ("" == $query || "" == $time) {
    die($lang['invalidEntry']);
} else {
    $LANG = 'export LANG=' . $env['lang_set'] . '; ';
    $HADOOP_HOME = 'export HADOOP_HOME=' . $env['hadoop_home'] . '; ';
    $HIVE_HOME = 'export HIVE_HOME=' . $env['hive_home'] . '; ';
    $JAVA_HOME = 'export JAVA_HOME=' . $env['java_home'] . '; ';
    $UDF = $env['udf'] != "" ? $env['udf'] : "";
    if (file_exists($env['output_path'])) {
        $sql = trim(rawurldecode($query));
        $sql = str_replace("", "%", $sql);
        //decode for like "%"
        #$sql = str_replace('"','\"',$sql);
        #$sql = '"'.str_replace('`',"",$sql).'"';
        $sql = str_replace('`', "", $sql);
        #log sql action
        $basedir = dirname(__FILE__) . "/";
        $logfile = $basedir . $env['logs_path'] . $_SESSION['username'] . "_" . $time . ".log";
        $etc->LogAction($logfile, "w", $sql . "\n");
        #
        #didn't use sql verification, may cause be hacked
        if (!file_exists($env['output_path'] . '/hive_res.' . $time . '.out') || filesize($env['output_path'] . '/hive_res.' . $time . '.out') == 0) {
            #$exec = $LANG . $HADOOP_HOME . $HIVE_HOME . $JAVA_HOME. $env['hive_home'].'/bin/hive '.$UDF.' -e '.$sql.' > '.$env['output_path'].'/hive_res.'.$time.'.out';
Exemplo n.º 5
0
     }
 }
 $filename = $env['output_path'] . "/hive_res." . $str . ".csv";
 if ($_SESSION['role'] != "superadmin") {
     $logfile = $env['logs_path'] . $_SESSION['username'] . "_" . $str . ".log";
 } else {
     if (is_numeric(substr($_GET['str'], 0, 1))) {
         $logfile = $env['logs_path'] . $_SESSION['username'] . "_" . $_GET['str'] . ".log";
     } else {
         $logfile = $env['logs_path'] . $_GET['str'];
     }
 }
 if (file_exists($filename)) {
     if (filesize($filename) != 0) {
         echo "<input type=button class=\"btn btn-success\" name=download value=\"" . $lang['downloadResultFile'] . "\" onclick=\"window.open('download.php?str=" . $str . "');\"><br><br>";
         $etc = new Etc();
         $array_column = $etc->SplitSqlColumn($logfile);
         $array = $etc->GetResult($filename);
         $array = explode("\n", substr($array, 0, -1));
         //stop at last return
         $i = 0;
         echo "<table class=\"table table-striped table-hover table-bordered table-condensed\">\n";
         echo "<tr class=\"info\">";
         foreach ($array_column as $ka => $va) {
             echo "<td>";
             echo $va;
             echo "</td>";
         }
         echo "</tr>";
         foreach ($array as $k => $v) {
             $arr = explode(",", $v);
Exemplo n.º 6
0
<?php

include_once 'config.inc.php';
include_once 'templates/style.css';
$etc = new Etc();
if (!@$_GET['database']) {
    die($lang['dieDatabaseChoose']);
} else {
    $transport = new TSocket(HOST, PORT);
    $protocol = new TBinaryProtocol($transport);
    $client = new ThriftHiveClient($protocol);
    $transport->open();
    $client->execute('use ' . $_GET['database']);
    echo '<div class="container">';
    echo '<div class="span10">';
    if (!@$_GET['table']) {
        die($lang['dieTableChoose']);
    } else {
        $sql = "desc formatted " . $_GET['table'];
        $client->execute($sql);
        $arr = $client->fetchAll();
        $arr = $etc->GetTableDetail($arr, "2");
        $j = 0;
        foreach ($arr as $k => $v) {
            $array_desc = explode(':', $v);
            $array_desc_desc['key'][$j] = trim($array_desc[0]);
            $array_desc_desc['value'][$j] = trim($array_desc[1]);
            if ($array_desc_desc['value'][$j] == 'MANAGED_TABLE' || $array_desc_desc['value'][$j] == 'INDEX_TABLE') {
                $tmp['key'] = $array_desc_desc['key'][$j];
                $tmp['value'] = $array_desc_desc['value'][$j];
            }
Exemplo n.º 7
0
<?php

include_once 'config.inc.php';
include_once 'templates/style.css';
$etc = new Etc();
if (preg_match('/' . str_replace("/", "\\/", $_GET['dir']) . '/i', $env['logs_path']) == '0') {
    $dir = $_GET['dir'];
} else {
    $dir = $env['logs_path'];
}
if ($dh = opendir($dir)) {
    echo "<a href=history.php?dir=" . $env['logs_path'] . "><i class=\"icon-backward\"></i> Back to Root</a><br><br>";
    include_once "templates/search_history.html";
    #Read file list in ./logs/ directory
    $i = 0;
    while (($file = readdir($dh)) !== false) {
        if ($file == '.' || $file == '..') {
            continue;
        } else {
            if (!is_dir($dir . $file)) {
                if ($_SESSION['role'] == 'superadmin') {
                    $file_array[$i] = $file;
                } else {
                    if (preg_match('/' . $_SESSION['username'] . '/', $file)) {
                        $file_array[$i] = $file;
                    }
                }
            }
        }
        $i++;
    }