Example #1
0
 function __construct()
 {
     global $db, $sys_folder, $sys_path, $def_dbSession, $def_dbInit;
     global $sys_dbType, $sys_dbIP, $sys_dbLogin, $sys_dbPass, $sys_dbName, $sys_dbPrefix;
     global $initSession;
     // page start time
     list($usec, $sec) = explode(" ", microtime());
     $this->time_start = (double) $usec + (double) $sec;
     // system database
     if ($def_dbInit === true) {
         $db = new phpDBConnection($sys_dbType);
         $db->connect($sys_dbIP, $sys_dbLogin, $sys_dbPass, $sys_dbName);
     }
     // db session, if any
     if ($def_dbSession == true) {
         require_once $sys_folder . "/session.php";
     } else {
         if ($initSession !== 'no' && $initSession !== false) {
             session_start();
         }
     }
     $this->getBrowserName();
 }
Example #2
0
     edit_process($db, $lstParams, $sql);
     break;
 case "dbConnect::edit_field_list":
     $sql = "SELECT null, '-- select host --'";
     foreach ($sys_dbs as $k => $v) {
         if ($sql != '') {
             $sql .= " UNION ALL ";
         }
         $sql .= "SELECT '{$v}', '{$k}'";
     }
     buildOptions($db, $lstParams, $sql, true, false);
     break;
 case "dbConnect::edit_save_data":
     $p = $_POST;
     $db = new phpDBConnection('postgres');
     $db->connect($p['host'], $p['user'], $p['pass'], 'template1', $p['port']);
     if ($db->dbConn == null) {
         print "<script>\n\t\t\t\t\t\tfrm = parent.document.getElementById('" . $lstParams["req_frame"] . "');\n\t\t\t\t\t\tfrm.style.border  = '';\n\t\t\t\t\t\tfrm.style.width   = '99%';\n\t\t\t\t\t\tfrm.style.height  = '200px';\n\t\t\t\t   </script>";
         die;
     }
     $_SESSION['ses_database'] = $p['host'] . ":" . $p['port'] . ":" . $p['user'] . ":" . $p['pass'];
     print "<script>\n\t\t\ttop.elements.databases.serverCall('refresh');\n\t\t</script>";
     break;
 case "databases::get_schemas":
     // -- schemas
     $sql = "SELECT nspname, nspname,\n\t\t\t\t\tCOALESCE(tblcnt,0) as tblcnt,\n\t\t\t\t\tCOALESCE(vwcnt,0) as vwcnt,\n\t\t\t\t\tCOALESCE(prcnt,0) as prcnt,\n\t\t\t\t\tCOALESCE(seqcnt,0) as seqcnt,\n\t\t\t\t\tto_char(COALESCE(tsize,0) + COALESCE(isize,0), '999,999,999,999') || ' Kb' as sz\n\t\t\t\tFROM pg_namespace\n\t\t\t\t\tLEFT OUTER JOIN (SELECT count(1) as tblcnt, relnamespace FROM pg_class\n\t\t\t\t\t\t\t\t\tWHERE relkind = 'r' GROUP BY relnamespace) as tbl ON tbl.relnamespace = pg_namespace.oid\n\t\t\t\t\tLEFT OUTER JOIN (SELECT count(1) as vwcnt, relnamespace FROM pg_class\n\t\t\t\t\t\t\t\t\tWHERE relkind = 'v' GROUP BY relnamespace) as vw ON vw.relnamespace = pg_namespace.oid\n\t\t\t\t\tLEFT OUTER JOIN (SELECT count(1) as prcnt, pronamespace FROM pg_proc GROUP BY pronamespace) as prcnt ON prcnt.pronamespace = pg_namespace.oid\n\t\t\t\t\tLEFT OUTER JOIN (SELECT count(1) as seqcnt, relnamespace FROM pg_class\n\t\t\t\t\t\t\t\t\tWHERE relkind = 'S' GROUP BY relnamespace) as seq ON seq.relnamespace = pg_namespace.oid\n\t\t\t\t\tLEFT OUTER JOIN (SELECT SUM(COALESCE(relpages,0)*8) as tsize, relnamespace\n\t\t\t\t\t\t\t\t\tFROM pg_class\n\t\t\t\t\t\t\t\t\tWHERE relkind = 'r' GROUP BY relnamespace) as tsize ON tsize.relnamespace = pg_namespace.oid\n\t\t\t\t\tLEFT OUTER JOIN (SELECT SUM(COALESCE(relpages,0)*8) as isize,relnamespace\n\t\t\t\t\t\t\t\t\tFROM pg_index, pg_class\n\t\t\t\t\t\t\t\t\tWHERE pg_class.oid = pg_index.indexrelid GROUP BY relnamespace) as isize ON isize.relnamespace = pg_namespace.oid\n\t\t\t\tWHERE nspname NOT LIKE 'pg_%' AND nspname != 'information_schema'\n\t\t\t\tORDER BY nspname";
     $rs = $db->execute($sql);
     print "var dbnode = dbTree.getNode('" . $lstParams['nodeid'] . "');\n\t\t\t   dbnode.nodes = []; ";
     while ($rs && !$rs->EOF) {
         print "\n\t\t\t\t var schema = dbTree.addNode(dbnode, 'sch_" . $lstParams['db'] . "." . $rs->fields[0] . "', '" . $rs->fields[0] . "');\n\t\t\t\t schema.picture = 'system/includes/silk/icons/database_table.png';\n\t\t\t\t var nd = dbTree.addNode(schema, 'tbls_" . $lstParams['db'] . "." . $rs->fields[0] . "', 'Tables (" . $rs->fields[2] . ")');\n\t\t\t\t nd.picture = 'system/includes/silk/icons/table.png';\n\t\t\t\t dbTree.addNode(nd, '" . $lstParams['nodeid'] . "_ttmp_" . $rs->fields[0] . "', '...');\n\t\t\t\t var nd = dbTree.addNode(schema, 'views_" . $lstParams['db'] . "." . $rs->fields[0] . "', 'Views (" . $rs->fields[3] . ")');\n\t\t\t\t nd.picture = 'system/includes/silk/icons/table_sort.png';\n\t\t\t\t dbTree.addNode(nd, '" . $lstParams['nodeid'] . "_vtmp_" . $rs->fields[0] . "', '...');\n\t\t\t\t var nd = dbTree.addNode(schema, 'seqs_" . $lstParams['db'] . "." . $rs->fields[0] . "', 'Sequences (" . $rs->fields[5] . ")');\n\t\t\t\t nd.picture = 'system/includes/silk/icons/table_key.png';\n\t\t\t\t dbTree.addNode(nd, '" . $lstParams['nodeid'] . "_stmp_" . $rs->fields[0] . "', '...');\n\t\t\t\t var nd = dbTree.addNode(schema, 'funs_" . $lstParams['db'] . "." . $rs->fields[0] . "', 'Functions (" . $rs->fields[4] . ")');\n\t\t\t\t nd.picture = 'system/includes/silk/icons/chart_curve.png';\n\t\t\t\t dbTree.addNode(nd, '" . $lstParams['nodeid'] . "_ftmp_" . $rs->fields[0] . "', '...');\n\t\t\t";
         $rs->moveNext();
Example #3
0
require_once "../system/security.php";
require_once $sys_folder . "/libs/phpDB.php";
require_once $sys_folder . "/libs/phpDBLib.php";
$lstParams = js_unescape($cmd);
if ($lstParams['db'] == '') {
    $lstParams['db'] = 'template1';
}
$tmp = split(":", $_SESSION['ses_database']);
$sys_dbType = 'postgres';
$sys_dbIP = $tmp[0];
$sys_dbPort = $tmp[1];
$sys_dbLogin = $tmp[2];
$sys_dbPass = $tmp[3];
$sys_dbName = $lstParams['db'];
$db = new phpDBConnection($sys_dbType);
$db->connect($sys_dbIP, $sys_dbLogin, $sys_dbPass, $sys_dbName, $sys_dbPort);
require "features.php";
switch ($lstParams['req_name'] . "::" . $lstParams['req_cmd']) {
    case "viewScript::edit_get_data":
        $vw = split("\\.", $lstParams['view']);
        $sql = "SELECT definition FROM pg_views\n\t\t\t\tWHERE viewname = '" . $vw[2] . "'\n\t\t\t\t\tAND schemaname = '" . $vw[1] . "'";
        $rs = $db->execute($sql);
        $sql = $rs->fields[0];
        // -- process edit
        print "document.getElementById('sql').value = \"CREATE OR REPLACE VIEW " . $lstParams['view'] . " AS \\n" . addslashes($sql) . "\";";
        print "top.elements['viewScript'].dataReceived();";
        break;
    case "viewData::lst_get_data":
        $tbl = split("\\.", $lstParams['view']);
        // -- get fields
        $sql = "SELECT * FROM " . $lstParams['view'] . " LIMIT 1";
Example #4
0
        if ($p['execute'] == 't') {
            $sql .= "GRANT EXECUTE ON FUNCTION " . $t[0] . " TO " . $p['user'] . ";\\n";
        }
        if ($p['all'] == 't') {
            $sql = "GRANT ALL ON FUNCTION " . $t[0] . " TO " . $p['user'] . ";\\n";
        }
        print "<script>top.execCommand(\"" . $sql . "\", 'top.elements.funPriv.output();');</script>";
        break;
    default:
        print "alert('List command is not recognized:  " . $lstParams['req_name'] . "::" . $lstParams['req_cmd'] . "');";
        break;
}
switch ($cmd) {
    case "get_script":
        $db = new phpDBConnection($sys_dbType);
        $db->connect($sys_dbIP, $sys_dbLogin, $sys_dbPass, $_GET['db']);
        $tmp = split('\\.', $fun);
        $fun = split('::', $tmp[2]);
        $funoid = $fun[1];
        $db->debug = true;
        $sql = "SELECT proname, typname, lanname, oidvectortypes(proargtypes), prosrc, proisstrict, prosecdef, \r\t\t\t\t\tprovolatile, proretset\r\t\t\t    FROM pg_proc, pg_namespace, pg_language, pg_type\r\t\t\t    WHERE pronamespace != 11\r\t\t\t\t\tAND pg_proc.pronamespace = pg_namespace.oid\r\t\t\t\t\tAND prolang = pg_language.oid\r\t\t\t\t\tAND prorettype = pg_type.oid\r\t\t\t\t\tAND pg_proc.oid = {$funoid}";
        $rs = $db->Execute($sql);
        if (!$rs->EOF) {
            $fn = $rs->fields[0];
            $type = $rs->fields[1];
            $lang = $rs->fields[2];
            $args = $rs->fields[3];
            $src = str_replace("'", "\\'", $rs->fields[4]);
            $rn = $rs->fields[5];
            $ex = $rs->fields[6];
            $prov = $rs->fields[7];