Example #1
0
function valid_data($SIDU, &$exp, $cmd)
{
    if (!$exp['db'] && !$exp['drop'] && !$exp['desc'] && !$exp['data']) {
        $exp['desc'] = $exp['data'] = 1;
    }
    if ($exp['drop']) {
        $exp['desc'] = 1;
    }
    if ($exp['ext'] != 'html' && $exp['ext'] != 'sql') {
        $exp['ext'] = 'csv';
    }
    //	if (!$cmd) $exp['zip'] = 1;//default save as zip
    $exp['where'] = @trim(@stripslashes($exp['where']));
    if (!$_GET['sql']) {
        if ($SIDU[4]) {
            $exp['tabs'][0] = $SIDU[4];
        } else {
            $exp['tabs'] = @explode(",", $_GET['tab']);
        }
        if ($SIDU['eng'] == 'my') {
            foreach ($exp['tabs'] as $tab) {
                $exp['sql'][] = "SELECT * FROM `{$SIDU['1']}`.`{$tab}`";
            }
        } elseif ($SIDU['eng'] == 'pg') {
            foreach ($exp['tabs'] as $tab) {
                $exp['sql'][] = "SELECT * FROM \"{$SIDU['2']}\".\"{$tab}\"";
            }
        } else {
            foreach ($exp['tabs'] as $tab) {
                $exp['sql'][] = "SELECT * FROM {$tab}";
            }
        }
        if (!$exp['sql'][1]) {
            $res = @tm("SQL", $exp['sql'][0] . " LIMIT 1");
            $col = @get_sql_col($res, $SIDU['eng']);
            foreach ($col as $v) {
                $exp['tab_col'][] = $v[0];
            }
            if ($exp['tab_col'] != $exp['col']) {
                foreach ($exp['col'] as $k => $v) {
                    $exp['col'][$k] = @goodname($v);
                }
                $exp['sql'][0] = "SELECT " . @implode(",", $exp['col']) . @substr($exp['sql'][0], 8);
            }
            if ($exp['where']) {
                $exp['sql'][0] .= " WHERE {$exp['where']}";
            }
        }
    } else {
        $exp['sql'][0] = $_GET['sql'];
    }
}
Example #2
0
function run_sqls()
{
    global $SIDU;
    $conn = $SIDU['conn'][$SIDU[0]];
    $eng = $conn[1];
    $cook = $SIDU['cook'][$SIDU[0]];
    @tm_use_db($cook[1], $cook[2]);
    if ($_GET['sql'] == 'show vars') {
        $_POST['sqlcur'] = $eng == 'pg' ? 'SHOW ALL' : 'SHOW VARIABLES';
    } elseif (@substr($_GET['sql'], 0, 6) == 'FLUSH ') {
        if ($_GET['sql'] == 'FLUSH ALL') {
            $_POST['sqlcur'] = "FLUSH LOGS;\nFLUSH HOSTS;\nFLUSH PRIVILEGES;\nFLUSH TABLES;\nFLUSH STATUS;\nFLUSH DES_KEY_FILE;\nFLUSH QUERY CACHE;\nFLUSH USER_RESOURCES;\nFLUSH TABLES WITH READ LOCK";
        } else {
            $_POST['sqlcur'] = $_GET['sql'];
        }
    } elseif (@substr($_GET['sql'], 0, 9) == 'STATScol:') {
        $_POST['sqlcur'] = "SELECT " . @goodname(@substr($_GET['sql'], 9)) . ",count(*) FROM " . @goodname($cook[4]) . " GROUP BY 1 ORDER BY 2 DESC,1 LIMIT 20";
    } elseif ($_GET['sql']) {
        $_POST['sqlcur'] = $_GET['sql'];
    }
    $arr = @explode(chr(10), @strip($_POST['sqlcur'], 1, 0, 1));
    foreach ($arr as $v) {
        $v = @trim($v);
        if ($v) {
            $arr2[] = $v;
        }
    }
    $txt = @implode(chr(10), $arr2);
    $arr = @explode(";" . chr(10), $txt);
    foreach ($arr as $i => $sql) {
        $time_start = @microtime(true);
        $res = $eng == 'my' ? @mysql_query($sql) : ($eng == 'pg' ? @pg_query($sql) : @sqlite_query($SIDU['dbL'], $sql));
        $time_end = @microtime(true);
        $time = @round(($time_end - $time_start) * 1000);
        $SIDU[5] += $time;
        $err = @sidu_err(1);
        $RES[$i][0] = $sql;
        if ($err) {
            $RES[$i][1] = $err;
            $SIDU[8]++;
        } else {
            $RES[$i][3] = $eng == 'my' ? @mysql_num_rows($res) : ($eng == 'pg' ? @pg_num_rows($res) : @sqlite_num_rows($res));
            if ($eng == 'pg' && !$RES[$i][3]) {
                $RES[$i][2] = @pg_affected_rows($res);
                if (!$RES[$i][2]) {
                    unset($RES[$i][2]);
                }
            }
            //there is no function: sqlite_affected_rows()
            if ($RES[$i][3] === false && $eng == 'my') {
                $RES[$i][2] = @mysql_affected_rows();
            }
            if (!isset($SIDU[6]) && $RES[$i][3] !== false) {
                $SIDU[6] = $i;
                $RES[$i][5] = @get_sql_col($res, $eng);
                $RES[$i][6] = @get_sql_data($res, $eng);
            } elseif ($_POST['sqlmore'] && $RES[$i][3] !== false) {
                $RES[$i][5] = @get_sql_col($res, $eng);
                $RES[$i][6] = @get_sql_data($res, $eng);
            }
            $RES[$i][4] = $time;
        }
        @tm_his_log('S', $sql, $time, $err);
    }
    $SIDU[7] = ++$i;
    $SIDU['RES'] = $RES;
    //reset cookie
    if ($eng == 'my') {
        $db = @mysql_fetch_row(@mysql_query("SELECT database()"));
        if ($db[0] != $cook[1]) {
            $ck = @array($conn[0], $db[0]);
        }
    } elseif ($eng == 'pg') {
        $db[0] = @pg_dbname();
        if ($db[0] != $cook[1]) {
            $ck = @array($conn[0], $db[0]);
        } else {
            //sch
            $sch = pg_fetch_row(pg_query("SHOW search_path"));
            if (@substr($sch[0], 0, 8) == '"$user",') {
                $sch[0] = @substr($sch[0], 8);
            }
            $sch[0] = @str_replace('"', '', $sch[0]);
            if ($sch[0] != $cook[2]) {
                $ck = @array($conn[0], $cook[1], $sch[0]);
            }
        }
    }
    if (isset($ck)) {
        @update_sidu_cook($ck);
    }
}
Example #3
0
function main_desc($SIDU, $link, $conn)
{
    if ($SIDU['eng'] == 'pg' && $SIDU['tabinfo'][2] == 't') {
        unset($SIDU['col'][0]);
    }
    echo "<table class='grid'>\n\t<tr class='th'><td>", @lang(3724), "</td><td>", @lang(3725), "</td><td>Null</td><td>", @lang(3726), "</td><td>", @lang(3727), "</td><td>", @lang(3728), "</td><td title='", @lang(3729), "'>", @lang(3730), "</td><td title='", @lang(3731), "'>", @lang(3732), "</td><td title='", @lang(3733), "'>", @lang(3734), "</td><td title='", @lang(3735), "'>", @lang(3736), "</td><td>", @lang(3737), "</td></tr>";
    if ($SIDU[10]) {
        foreach ($SIDU['col'] as $col) {
            $coln = @goodname($col[0]);
            $colz = @is_type_int($col[1]) ? $coln : "length({$coln})";
            $sql .= ",count(" . ($SIDU['eng'] == 'sl' ? "" : "distinct ") . "{$coln}),min({$colz}),max({$colz}),avg({$colz})\n";
        }
        $sql = "SELECT " . @substr($sql, 1) . " FROM " . @goodname($SIDU[4]);
        $stat = @sql2arr($sql, -1);
        $stat = $stat[0];
    }
    foreach ($SIDU['col'] as $i => $col) {
        echo "<tr><td><a href='sql.php?id={$SIDU['0']}&#38;sql=STATScol:{$col['0']}'>{$col['0']}</a></td><td>";
        if (@strlen($col[1]) > 50) {
            echo "<input type='text' value='", @html8($col[1]), "' size='1' style='width:100%;background:#ddc'/>";
        } else {
            echo $col[1];
        }
        echo "</td><td>", $col[2] == "YES" || $col[2] == "f" ? "NULL" : "", "</td><td>{$col['3']}</td><td>";
        if ($col[7] == 'PRI' || $col[7] == 'p') {
            echo "<span class='blue'>PK</span>";
        } elseif ($col[7] == 'f') {
            echo "<span class='red'>FK</span>";
        } elseif ($col[7] == 'u' || $col[7] == 'UNI') {
            echo "<span class='green'>UK</span>";
        } else {
            echo $col[7];
        }
        $distinct = @ceil($stat[4 * $i]);
        echo "</td><td>{$col['5']}</td>\n\t\t<td align='right'", $distinct < $SIDU[10] && $distinct ? " class='green'" : "", ">{$distinct}</td>\n\t\t<td align='right'>", @ceil($stat[4 * $i + 1]), "</td>\n\t\t<td align='right'>", @ceil($stat[4 * $i + 2]), "</td>\n\t\t<td align='right'>", @ceil($stat[4 * $i + 3]), "</td>\n\t\t<td>{$col['6']}</td></tr>";
    }
    echo "</table>";
    if ($link[3] == 'v') {
        return @main_desc_view($link, $conn[1], $SIDU['tabinfo'][0]);
    }
    if ($conn[1] != 'pg') {
        if ($conn[1] == 'my') {
            $desc = @mysql_fetch_row(@tm("SQL", "SHOW CREATE TABLE `{$link['1']}`.`{$link['4']}`"));
        } else {
            $desc = @sqlite_fetch_array(@tm("SQL", "SELECT name,sql FROM sqlite_master WHERE name=tbl_name AND name='{$link['4']}' LIMIT 1"), SQLITE_NUM);
        }
        $typ = @array('char', 'varchar', 'text', 'blob', 'smallint', 'int', 'timestamp', 'datetime', 'date', 'time', 'enum', 'tinyint', 'unsigned', 'bigint', 'mediumtext', 'longblob', 'set', 'longtext', 'decimal', 'float');
        foreach ($typ as $t) {
            $mytran[" {$t}"] = " <span class='green'>{$t}</span>";
        }
        $mytran[' DEFAULT '] = " <span class='blue'>DEFAULT</span> ";
        $mytran[' default '] = " <span class='blue'>default</span> ";
        $mytran[' CHARACTER SET '] = " <span class='red'>CHARACTER SET</span> ";
        $typ = @array('PRIMARY KEY', 'UNIQUE KEY', 'KEY');
        foreach ($typ as $t) {
            $mytran[$t] = "<b>{$t}</b>";
        }
        $desc[1] = @strtr($desc[1], $mytran);
        if ($conn[1] == 'sl') {
            $res = @tm("SQL", "SELECT sql FROM sqlite_master WHERE type='index' AND tbl_name='{$link['4']}' AND sql IS NOT NULL");
            while ($row = @sqlite_fetch_array($res, SQLITE_NUM)) {
                $idx .= "<i class='green'>{$row['0']};</i>\n";
            }
        }
    } else {
        $tran = @array("'" => "''", "\\" => "\\\\");
        if ($SIDU['tabinfo'][3]) {
            $comm = "\n<b class='blue'>COMMENT ON TABLE \"{$link['4']}\" IS '" . @strtr($SIDU['tabinfo'][3], $tran) . "';</b>";
        }
        $desc[1] = "<i class='grey'>--PG desc table is experimental--oid={$SIDU[tabinfo][0]}</i>\nCREATE TABLE \"{$link['4']}\"(";
        foreach ($SIDU['col'] as $i => $v) {
            $desc[1] .= "\n\t\"{$v['0']}\" <i class='green'>{$v['1']}</i>";
            if ($v[2] == 't') {
                $desc[1] .= " NOT NULL";
            }
            if ($v[3] != '') {
                if (!@is_numeric($v[3]) && @substr($v[3], 0, 8) != 'nextval(' && $v[3] != 'now()' && $v[3] != 'true' && $v[3] != 'false') {
                    $v[3] = "'" . @strtr($v[3], $tran) . "'";
                }
                $desc[1] .= " <span class='blue'>DEFAULT</span> {$v['3']}";
            } elseif ($v[11]) {
                $desc[1] .= " <span class='blue'>DEFAULT</span> {$v['11']}";
            }
            $desc[1] .= ",";
            if ($v[6] != '') {
                $comm .= "\n<i class='blue'>COMMENT ON COLUMN \"{$link['4']}\".\"{$v['0']}\" IS '" . @strtr($v[6], $tran) . "';</i>";
            }
        }
        $fkmatch = @array("f" => "FULL", "p" => "PARTIAL", "u" => "SIMPLE");
        $fkact = @array("a" => "NO ACTION", "r" => "RESTRICT", "c" => "CASCADE", "n" => "SET NULL", "d" => "SET DEFAULT");
        $res = @tm("SQL", "SELECT *,pg_get_constraintdef(oid,TRUE) AS kstr FROM pg_constraint\nWHERE conrelid={$SIDU[tabinfo][0]} AND connamespace={$SIDU[tabinfo][1]}");
        while ($row = @pg_fetch_assoc($res)) {
            $desc[1] .= "\nCONSTRAINT \"<i class='green'>{$row['conname']}</i>\" <b>{$row['kstr']}</b>";
            if ($row['contype'] == 'f') {
                $desc[1] .= " MATCH {$fkmatch[$row[confmatchtype]]}\n\tON UPDATE {$fkact[$row[confupdtype]]} ON DELETE {$fkact[$row[confdeltype]]},";
            } else {
                $desc[1] .= ",";
            }
        }
        $desc[1] = @substr($desc[1], 0, -1) . "\n) WITH (OIDS=" . ($SIDU['tabinfo'][2] == 't' ? "TRUE" : "FALSE") . ");";
        $res = @tm("SQL", "SELECT pg_get_indexdef(indexrelid) FROM pg_index\nWHERE indrelid={$SIDU[tabinfo][0]} AND indisprimary='f'");
        while ($row = @pg_fetch_row($res)) {
            $idx .= "<i class='green'>{$row['0']};</i>\n";
        }
    }
    echo "<pre>\n\n{$desc['1']}{$comm}\n\n{$idx}\n********** Grants not ready in this version **********\n\n********** SQL HELP **********\n";
    if ($conn[1] == 'my') {
        echo "\n<b>RENAME</b> TABLE {$SIDU['4']} <b>TO</b> new_name\nALTER TABLE {$SIDU['4']} <b>ADD COLUMN</b> a INT(2),ADD COLUMN b INT(3),<b>DROP COLUMN</b> c\nALTER TABLE {$SIDU['4']} <b>CHANGE</b> a newname VARCHAR(10) NOT NULL DEFAULT '' <b>AFTER</b> c\nALTER TABLE {$SIDU['4']} <b>ADD PRIMARY KEY</b> (b)\nALTER TABLE {$SIDU['4']} <b>DROP PRIMARY KEY</b>\n\nALTER TABLE {$SIDU['4']} <b>ADD UNIQUE</b> uk (c)\nALTER TABLE {$SIDU['4']} <b>DROP KEY</b> uk\nALTER TABLE {$SIDU['4']} <b>ADD INDEX</b> idx (a,b)\nALTER TABLE {$SIDU['4']} <b>DROP KEY</b> idx";
    } else {
        echo "\nALTER TABLE {$SIDU['4']} <b>RENAME COLUMN</b> column TO new_column\nALTER TABLE {$SIDU['4']} <b>RENAME TO</b> new_name\nALTER TABLE {$SIDU['4']} SET SCHEMA new_schema\n\nALTER TABLE {$SIDU['4']} <b>ADD COLUMN</b> column type\nALTER TABLE {$SIDU['4']} <b>DROP COLUMN</b> column [ RESTRICT | CASCADE ]\nALTER TABLE {$SIDU['4']} <b>ALTER COLUMN</b> column TYPE type\nALTER TABLE {$SIDU['4']} ALTER COLUMN column <b>SET DEFAULT</b> expression\nALTER TABLE {$SIDU['4']} ALTER COLUMN column <b>DROP DEFAULT</b>\nALTER TABLE {$SIDU['4']} ALTER COLUMN column { SET | DROP } <b>NOT NULL</b>\nALTER TABLE {$SIDU['4']} <b>DROP CONSTRAINT</b> constraint_name [ RESTRICT | CASCADE ]\nALTER TABLE {$SIDU['4']} SET WITH OIDS\nALTER TABLE {$SIDU['4']} SET WITHOUT OIDS\nALTER TABLE {$SIDU['4']} OWNER TO new_owner\nALTER TABLE {$SIDU['4']} SET TABLESPACE new_tablespace\n\nCREATE UNIQUE INDEX idx ON {$SIDU['4']} (col1,col2);\nCREATE INDEX lower_title_idx ON {$SIDU['4']} ((lower(title)));\nCREATE INDEX title_idx_nulls_low ON {$SIDU['4']} (title NULLS FIRST);\nCREATE INDEX code_idx ON {$SIDU['4']} (code) TABLESPACE indexspace;\n\nALTER INDEX distributors RENAME TO suppliers;\nALTER INDEX distributors SET TABLESPACE fasttablespace;";
    }
    echo "</pre>";
}
Example #4
0
function tab_tool_save($SIDU, $cmd, $objs)
{
    //note: do not translate cmd to other lang
    $obj = @array("r" => "TABLE", "v" => "VIEW", "S" => "SEQUENCE", "f" => "FUNCTION");
    $obj = $obj[$SIDU[3]];
    if (@in_array($cmd, @array("Drop", "Analyze", "Check", "Optimize", "Repair"))) {
        $CMD = @strtoupper($cmd) . " {$obj}";
    } elseif ($cmd == 'Empty') {
        $CMD = $SIDU['eng'] == 'sl' ? "DELETE FROM" : "TRUNCATE TABLE";
    } elseif ($cmd == 'Vacuum') {
        $CMD = "VACUUM";
    } elseif ($cmd == 'Re-index') {
        $CMD = "REINDEX TABLE";
    } elseif ($cmd == 'Drop Cascade') {
        $CMD = "DROP {$obj}";
        $CMD2 = " CASCADE";
    } elseif ($cmd == 'Truncate Cascade') {
        $CMD = "TRUNCATE {$obj}";
        $CMD2 = " CASCADE";
    }
    if ($cmd == 'Analyze' && $SIDU['eng'] == 'pg') {
        $CMD = 'ANALYZE';
    }
    if (@substr($cmd, 0, 17) == "Change Engine to ") {
        $engTo = @substr($cmd, 17);
        $res = @tm("SQL", "SHOW TABLE STATUS FROM `{$SIDU['1']}`");
        while ($row = @mysql_fetch_array($res)) {
            if ($row['Engine'] != $engTo) {
                $tabs[] = $row['Name'];
            }
        }
        foreach ($objs as $v) {
            if (@in_array($v, $tabs)) {
                @tab_tool_run_sql("ALTER TABLE `{$SIDU['1']}`.`{$v}` ENGINE = {$engTo};");
            }
        }
    } elseif ($CMD == "DROP FUNCTION") {
        foreach ($objs as $v) {
            @tab_tool_run_sql("{$CMD} {$v}{$CMD2};");
        }
    } else {
        foreach ($objs as $v) {
            @tab_tool_run_sql("{$CMD} " . @goodname($v) . "{$CMD2};");
        }
    }
}
Example #5
0
function showstyles()
{
    $allstyles = array();
    $substyles = array();
    $dummy = array("type" => "", "source" => "default", "section" => "system");
    $shandle = $_SESSION["shandle"];
    $debug = $_SESSION["debug"];
    $activebrowser = $_SESSION["activebrowser"];
    $activetheme = $_SESSION["activetheme"];
    $activesection = $_SESSION["activesection"];
    $defbrowser = $_SESSION["defbrowser"];
    $deftheme = $_SESSION["deftheme"];
    $defsection = $_SESSION["defsection"];
    //$debug = "true";
    $sql = "select looking_for,theme,section,css_name,css_selector,css_value,css_place from activecss where conditional=\"browser\" order by css_name";
    if ($debug == "true") {
        echo "<!-- sql[{$sql}] -->\n";
    }
    $sresult = mysqli_query($shandle, $sql) or die("Cannot talk to acctive css table");
    $seltype = "unknown";
    while ($sdata = mysqli_fetch_array($sresult)) {
        $cbrowser = $sdata["looking_for"];
        $theme = $sdata["theme"];
        $section = $sdata["section"];
        $css_name = $sdata["css_name"];
        $css_name = goodname($css_name);
        $css_selector = $sdata["css_selector"];
        $css_value = $sdata["css_value"];
        $css_place = $sdata["css_place"];
        $selector_type = substr($css_name, 0, 1);
        $css_name = substr($css_name, 1);
        $seltype = $selector_type == "." ? "class" : $seltype;
        $seltype = $selector_type == "#" ? "id" : $seltype;
        $allstyles[$cbrowser][$theme][$css_name][$css_place]["name"] = $css_selector;
        $allstyles[$cbrowser][$theme][$css_name][$css_place]["value"] = $css_value;
        $allstyles[$cbrowser][$theme][$css_name]["section"] = $section;
        $allstyles[$cbrowser][$theme][$css_name]["type"] = $seltype;
        $_SESSION["stylelist"][$cbrowser][$theme][$css_name][$css_place]["name"] = $css_selector;
        $_SESSION["stylelist"][$cbrowser][$theme][$css_name][$css_place]["value"] = $css_value;
        $_SESSION["stylelist"][$cbrowser][$theme][$css_name]["section"] = $section;
        $_SESSION["stylelist"][$cbrowser][$theme][$css_name]["type"] = $seltype;
    }
    if ($debug == "true") {
        echo "<!-- allstyles:";
        print_r($allstyles);
        echo "-->\n";
    }
    foreach ($allstyles as $thisbrowser => $browserinfo) {
        // we have msie, firefox, etc....
        if ($debug == "true") {
            echo "<!-- processing style [{$thisbrowser}]:";
            print_r($browserinfo);
            echo "-->\n";
        }
        foreach ($browserinfo as $thistheme => $themeinfo) {
            // we have default, minimal, etc
            if ($debug == "true") {
                echo "<!-- processing theme [{$thistheme}]:";
                print_r($themeinfo);
                echo "-->\n";
            }
            foreach ($themeinfo as $thistyle => $styleinfo) {
                if ($debug == "true") {
                    echo "<!-- processing styles [{$thisbrowser}][{$thistheme}][{$thistyle}]:";
                    print_r($styleinfo);
                    echo "-->\n";
                }
                if ($thisbrowser == $defbrowser and $thistheme == $deftheme) {
                    if ($debug == "true") {
                        echo "<!-- inside [{$thisbrowser}][{$thistheme}][{$thistyle}] -->\n";
                    }
                    if ($debug == "true") {
                        echo "<!-- this is the default it can be overwritten -->\n";
                    }
                    if (!array_key_exists($thistyle, $substyles)) {
                        if ($debug == "true") {
                            echo "<!-- adding [{$thistyle}] -->\n";
                        }
                        $substyles[$thistyle] = $styleinfo;
                        $substyles[$thistyle]["source"] = $thistheme;
                    } else {
                        if ($debug == "true") {
                            echo "<!-- key exists, not writing style for [{$thisbrowser}][{$thistheme}] -->\n";
                        }
                    }
                } else {
                    if ($thisbrowser == $activebrowser and $thistheme == $activetheme) {
                        if ($debug == "true") {
                            echo "<!-- inside [{$thisbrowser}][{$thistheme}][{$thistyle}] -->\n";
                        }
                        if ($debug == "true") {
                            echo "<!-- this is NOT the default it can NOT be overwritten -->\n";
                        }
                        if ($debug == "true") {
                            echo "<!-- testing for [{$thistyle}] in :";
                            print_r($substyles);
                            echo "-->\n";
                        }
                        if ($debug == "true") {
                            echo "<!-- adding [{$thistyle}] -->\n";
                        }
                        $substyles[$thistyle] = $styleinfo;
                        $substyles[$thistyle]["source"] = $thistheme;
                    } else {
                        if ($debug == "true") {
                            echo "<!-- unmatched inside [{$thisbrowser}] vs [{$defbrowser}] : [{$thistheme}] vs [{$thistheme}] : [{$thistyle}]-->\n";
                        }
                    }
                }
            }
        }
    }
    if ($debug == "true") {
        echo "<!-- substyles:";
        print_r($substyles);
        echo "-->\n";
    }
    foreach ($substyles as $thistyle => $styleinfo) {
        //echo "<!-- processing [$thistyle]:";print_r($styleinfo);echo "-->\n";
        $_SESSION["showstyles"][$thistyle] = $styleinfo;
    }
    echo "\t<div name='stylebox' id='stylebox' class='sboxdiv'>\n";
    //echo "		styles:<br/>\n";
    $classes = "stylebox hbar selectable draggable";
    stylebox("newstyle", $dummy, "stylebox hbar selectable isdefault");
    if (count($substyles) > 0) {
        foreach ($substyles as $css_name => $css_info) {
            stylebox($css_name, $css_info, $classes);
        }
    }
    echo "\t</div>\n";
}
Example #6
0
function save_data($SIDU, $imp)
{
    echo "<p align='center'><img src='img/loading.gif'/>\n\t<br/><br/><span class='green'>", @lang(2225), "</span>\n\t<br/><br/><span class='red'>", @lang(2226), "</span></p>";
    if ($imp['del']) {
        @save_data_sql_run(0, "DELETE FROM " . @goodname($SIDU[4]), $imp);
    }
    $cols = @explode("\n", $imp['col']);
    if ($imp['pk']) {
        $pk = @explode(";", $imp['pk']);
    }
    foreach ($cols as $k => $v) {
        if (@in_array($v, $pk)) {
            $arrPK[] = $k;
        }
        $cols[$k] = @goodname($v);
    }
    if (!$imp['pk']) {
        $sql = "INSERT INTO ";
        if ($SIDU['eng'] == 'my') {
            $sql .= "`{$SIDU['1']}`.`{$SIDU['4']}`";
        } elseif ($SIDU['eng'] == 'pg') {
            $sql .= "\"{$SIDU['2']}\".\"{$SIDU['4']}\"";
        } else {
            $sql .= $SIDU[4];
        }
        $sql .= "(" . @implode(",", $cols) . ") VALUES ";
    } else {
        $sql = "UPDATE ";
        if ($SIDU['eng'] == 'my') {
            $sql .= "`{$SIDU['1']}`.`{$SIDU['4']}`";
        } elseif ($SIDU['eng'] == 'pg') {
            $sql .= "\"{$SIDU['2']}\".\"{$SIDU['4']}\"";
        } else {
            $sql .= $SIDU[4];
        }
        $sql .= " SET ";
    }
    $numCM = $numC = count($cols);
    if (!$imp['merge']) {
        $numCM++;
    }
    $numR = count($imp['file']);
    $numL = $SIDU['eng'] == 'sl' ? 1 : 200;
    //each insert max lines
    $numIns = 0;
    for ($i = $imp['cut1'] + 0; $i < $numR - $imp['cut2']; $i++) {
        $txt = @trim($imp['file'][$i]);
        if ($txt) {
            @save_data_sql($i, $SQL, $imp, $txt, $numCM, $numC, $arrPK, $cols, $numIns, $numL, $sql);
        }
    }
    if (!$imp['pk'] && $SQL) {
        if (@substr($SQL, -2) == ",\n") {
            $SQL = @substr($SQL, 0, -2);
        }
        if ($SQL) {
            @save_data_sql_run($i, $SQL, $imp);
        }
    }
    echo "<br/><p class='ok'>", @lang(2227), "</p>";
}