Esempio n. 1
0
function cout_data($SIDU, $link, $conn, $sql)
{
    if ($_POST['cmd'] == 'data_save' || $_POST['cmd'] == 'data_del') {
        @save_data($SIDU, $conn[1], $_POST['cmd']);
    }
    $url = !$sql ? "tab" : "sql";
    echo "<form id='dataTab' name='dataTab' action='{$url}.php?id={$link['0']},{$link['1']},{$link['2']},{$link['3']},{$link['4']},{$SIDU['5']},{$SIDU['6']}' method='post'>";
    if (!$sql) {
        echo "<p style='padding:3px'>where ", @html_form("text", "f[sql]", $SIDU['f']['sql'], 300), " <img src='img/tool-run.png' onclick=\"submitForm('cmd','p1')\" class='vm'/> eg col='abc'</p>";
        foreach ($SIDU['g'] as $j => $gSize) {
            if ($gSize == -1) {
                $hidden .= "<a href='#' onclick=\"submitForm('showCol',{$j})\">{$SIDU[col][$j][0]}</a> ";
            }
        }
        if ($hidden) {
            echo "<p>", @lang(104), ": {$hidden}</p>";
        }
    }
    if (isset($SIDU['pk'])) {
        $pk = $SIDU['pk'];
    }
    foreach ($SIDU['col'] as $j => $v) {
        $disp[$j] = $SIDU['g'][$j] == -1 ? " style='display:none'" : "";
        $title = "{$v['0']} " . @str_replace("'", "", $v[1]);
        $color = '';
        if (@in_array($j, $SIDU['pk'])) {
            $title = "PK {$title}";
            $color = '06c';
        }
        if ($v[5] == 'auto_increment' || $v[1] == 'serial' || $v[1] == 'bigserial') {
            $color = 'c00';
        }
        $colH .= "<td class='td{$j}' title='{$title}'{$disp[$j]}><div class='gridH' id='gH{$j}'" . (!$SIDU['gridMode'] ? " style='width:{$SIDU[g][$j]}px'" : "") . ">";
        if (!$sql) {
            $colH .= "<a" . @get_sort_css($v[0], $SIDU[5], $SIDU[6]) . " href='#' onclick=\"submitForm('sidu7','{$v['0']}')\">" . ($color ? "<span style='color:#{$color}'>{$v['0']}</span>" : $v[0]) . "</a>";
        } else {
            $colH .= "<a>{$v['0']}</a>";
        }
        $colH .= "</div></td>";
        $jsStr .= "xHRD.init('gH{$j}',10);";
        $filter .= "<td class='td{$j}'{$disp[$j]}><input type='text' size='1' id='f{$j}' name='f[{$j}]' value='" . @html8($SIDU['f'][$j]) . "'/></td>";
        $grid .= "<td class='td{$j}'{$disp[$j]}><input type='text' size='1' name='g[{$j}]' id='g{$j}' value='" . $SIDU['g'][$j] . "'/></td>";
        if (!$sql) {
            $gridShow .= "<td class='td{$j}'{$disp[$j]}><img src='img/tool-sys.png' title='" . @lang(124) . "' onclick=\"submitForm('sidu7','del:{$v['0']}')\"/> <a href='#' onclick=\"submitForm('hideCol',{$j})\">" . @html_img('img/tool-x') . "</a></td>";
        }
        if ($v[3] == 'CURRENT_TIMESTAMP' || $v[3] == 'now()') {
            $v[3] = "'+his.getFullYear()+'-'+(parseInt(his.getMonth())+1)+'-'+his.getDate()+' '+his.getHours()+':'+his.getMinutes()+':'+his.getSeconds()+'";
        } elseif (@substr($v[3], 0, 9) == "nextval('") {
            $v[3] = '';
        } else {
            $v[3] = @html8($v[3] ? $v[3] : ($v[2] == 'YES' || $v[2] == 'f' ? 'NULL' : ''));
        }
        $align = $SIDU['col'][$j][8] == 'i' ? ' style="text-align:right"' : '';
        $id = 'data_new\'+id+\'_' . $j;
        $is_blob = @is_blob($SIDU['col'][$j]) ? ' onclick="editBlob(\\\'' . $id . '\\\')"' : '';
        $jsColNew .= '<td class="blue td' . $j . '"' . @str_replace("'", "\"", $disp[$j]) . '>';
        if ($is_blob) {
            $jsColNew .= '<input type="hidden" name="' . $id . '" id="' . $id . '" value="' . $v[3] . '"/><input type="text" value="' . $v[3] . '" size="1" id="blob' . $id . '"' . $is_blob . ' style="background:#ddc"/></td>';
        } else {
            $jsColNew .= '<input type="text" size="1" name="' . $id . '" id="' . $id . '" value="' . $v[3] . '"' . $align . $is_blob . ' onchange="document.dataTab.cbox_data_new\'+id+\'.checked=\\\'checked\\\'"/></td>';
        }
        if (!isset($SIDU['pk'])) {
            $pk[] = $j;
        }
        //no pk table with blob col will be slow here
    }
    echo "\n<table class='grid' id='dataTable'>";
    if (!$sql) {
        echo "\n<tr id='trhide' title='", @lang(105), "' style='opacity:0.6", $SIDU['gridShow'] ? "" : ";display:none", "'><td class='cbox'></td>{$gridShow}</tr>";
    }
    echo "\n<tr class='th'><td class='cbox'><input type='checkbox' onclick='checkedAll()'/></td>{$colH}</tr>";
    if (!$sql) {
        echo "\n<tr id='trgrid' title='", @lang(106), "'", $SIDU['gridShow'] ? "" : " style='display:none'", " class='grey'><td class='cbox'></td>{$grid}</tr>\n\t\t<tr class='gridf' title='", @lang(107), " eg: =12'><td class='cbox'><a href='tab.php?id={$SIDU['0']},{$SIDU['1']},{$SIDU['2']},{$SIDU['3']},{$SIDU['4']}' title='", @lang(108), "'>", @html_img("img/tool-find"), "</a></td>{$filter}</tr>";
    }
    foreach ($SIDU['data'] as $i => $row) {
        echo "\n<tr id='tr_{$i}'><td class='cbox'><input type='checkbox' name='cbox_data_{$i}'/></td>";
        foreach ($row as $j => $v) {
            $align = $SIDU['col'][$j][8] == 'i' ? " style='text-align:right'" : "";
            if (is_null($v)) {
                $v = 'NULL';
                $classNull = " null";
            } else {
                $classNull = "";
            }
            $v8 = @html8($v);
            $id = "data_{$i}" . "_{$j}";
            $is_blob = @is_blob($SIDU['col'][$j]) ? " onclick=\"editBlob('{$id}')\"" : "";
            echo "<td class='td{$j}{$classNull}'{$disp[$j]}{$align}>";
            if ($SIDU['gridMode']) {
                if ($is_blob || $sql) {
                    echo @nl2br($v8);
                } else {
                    $v8str = $v8 === 'NULL' ? "IS NULL" : "=\\'" . @strtr($v8, @array("&#039;" => "\\&#039;\\&#039;", "\\" => "\\\\\\\\")) . "\\'";
                    echo "<a href='#' onclick=\"setv('f{$j}','{$v8str}');submitForm('cmd','p1')\">" . @nl2br($v8) . "</a>";
                }
            } else {
                if ($is_blob) {
                    echo "<input type='hidden' name='{$id}' id='{$id}' value='{$v8}'/><input type='text' value='" . @substr($v8, 0, 30) . "' size='1' id='blob{$id}'{$is_blob} style='background:#ddc", $classNull ? ";color:#888;font-style:italic" : "", "'/>";
                } else {
                    echo "<input type='text' size='1'", $classNull ? " class='null'" : "", " name='{$id}' id='{$id}' value='{$v8}' onchange=\"document.dataTab.cbox_data_{$i}.checked='checked'\"{$align}/>";
                }
            }
            if (!$sql && @in_array($j, $pk)) {
                echo "<input type='hidden' name='pkV[{$i}][{$j}]' value='{$v8}'/>";
            }
            echo "</td>";
        }
        echo "</tr>";
    }
    echo "\n</table>";
    $arrH = @array('cmd', 'sidu7', 'sidu8', 'sidu9', 'showCol', 'hideCol');
    foreach ($arrH as $v) {
        echo @html_form("hidden", $v);
    }
    echo "<input type='hidden' id='gridShow' name='gridShow' value='{$SIDU['gridShow']}'/><input type='hidden' id='gridMode' name='gridMode' value='{$SIDU['gridMode']}'/>";
    echo "</form>\n<div id='blobDiv' style='display:none;width:99%;max-width:700px'>\n<input type='button' value='", @lang(109), "' onclick='editBlobSave()'/><input type='button' value='", @lang(110), "' onclick=\"showHide('blobDiv',-1)\"/><input type='hidden' id='blobTxtID'/>\n<br/><textarea id='blobTxt' style='width:99%;height:280px'></textarea>\n</div>\n<iframe name='hiddenfr' src='#' style='width:600px;height:200px;display:none'></iframe>\n<script type='text/javascript'>\nwindow.onload = function(){" . $jsStr . "}";
    if (!$sql) {
        echo "\nfunction addRow(){\n\tvar his = new Date();\n\tvar id = his.getHours()+his.getMinutes()+his.getSeconds();\n\tvar row = document.getElementById('dataTable').insertRow(4);\n\trow.innerHTML='<td class=\"cbox\"><input type=\"checkbox\" name=\"cbox_data_new'+id+'\"></td>{$jsColNew}';\n}";
    }
    echo "</script>";
}
Esempio n. 2
0
function cout_obj($SIDU, $link, $arr, $col)
{
    $arr = @sort_arr($arr, $SIDU[5], $SIDU[6]);
    $right = @array('Rows', 'Avg', 'Size', 'Auto', 'Index');
    $slink = "db.php?id={$link['0']},{$link['1']},{$link['2']},{$link['3']},{$link['4']},{$SIDU['5']},{$SIDU['6']}";
    echo "<table class='grid'><tr class='th'><td class='cbox'><input type='checkbox' onclick='checkedAll()'/></td>";
    if ($SIDU['page']['lang'] != 'en') {
        $colStr = @lang(1432);
    }
    foreach ($col as $k => $v) {
        $align[$k] = @in_array($k, $right) ? " align='right'" : "";
        echo "<td><a", @get_sort_css($k, $SIDU[5], $SIDU[6]), " href='{$slink},{$k}'>", $colStr[$k] ? $colStr[$k] : $k, "</a></td>";
    }
    echo "</tr>";
    $obj = $SIDU[3] == 'r' ? 'Table' : ($SIDU[3] == 'v' ? 'View' : ($SIDU[3] == 'S' ? 'Seq' : 'Func'));
    foreach ($arr as $i => $row) {
        echo "<tr><td class='cbox'><input type='checkbox' name='objs[]' value='", @html8($row[$obj]), "'", @in_array($row[$obj], $_POST['objs']) ? " checked='checked'" : "", "/></td>";
        foreach ($col as $k => $v) {
            $url = "tab.php?id={$link['0']},{$link['1']},{$link['2']},{$link['3']}," . $row[$k];
            if ($k == 'Table' || $k == 'View') {
                $row[$k] = "<a href='{$url}&#38;desc=1'>" . @html_img("img/x{$SIDU['3']}", @lang(1433), "class='vm'") . "</a> <a href='{$url}'>{$row[$k]}</a>";
            } elseif ($k == 'Size' || $k == 'Index' || $k == 'Avg') {
                $row[$k] = @size2str($row[$k]);
            } elseif ($k == 'Definition') {
                $row[$k] = "<input id='{$k_}{$i}' type='hidden' value='" . @html8($row[$k]) . "'/><input type='text' style='width:200px;background:#ddc' size='1' value='" . @html8(@substr($row[$k], 0, 100)) . "' onclick=\"showHide('blobDiv',1);setv('blobTxt',getv('{$k_}{$i}'))\"/>";
            }
            echo "<td{$align[$k]}", $k == 'Rows' || $k == 'PK' ? " class='green'" : ($k == 'Auto' && $row[$k] > 2000000000 ? " class='red'" : ""), ">{$row[$k]}</td>";
        }
        echo "</tr>";
    }
    echo "</table>\n<div id='blobDiv' style='display:none'>\n", @html_img("img/tool-close.gif", "Close", "onclick=\"showHide('blobDiv',-1)\""), "\n<br/><textarea id='blobTxt' style='width:490px;height:295px'></textarea>\n</div>";
}